Browse Source

work on rotate class

mode-button
Nasi 3 years ago
parent
commit
66d194fdb8
  1. 3
      logic/src/model/Console.cpp
  2. 13
      logic/src/model/RotayButton.cpp
  3. 27
      test/tst_console.cpp

3
logic/src/model/Console.cpp

@ -35,7 +35,8 @@ void Console::pressDual()
//********************************************************************************
void Console::releaseDual()
{
auto arr = _dual.release();
_dataSender->send(arr);
}
//********************************************************************************

13
logic/src/model/RotayButton.cpp

@ -23,7 +23,18 @@ Led *RotayButton::getLed()
//********************************************************************************
QByteArray RotayButton::rotate(int value)
{
QByteArray arr;
arr.resize(8);
arr[0] = 0x00;
arr[1] = 0X02;
arr[2] = 0X05;
arr[3] = _functionCode;
arr[4] = 0x01;
arr[5] = 0x00;
arr[6] = 0x00;
arr[7] = 0x00;
return arr;
}
//********************************************************************************

27
test/tst_console.cpp

@ -13,7 +13,8 @@ public:
private slots:
void test_case1();
void dualPress_test_case();
void pressDual_test_case();
void releaseDual_test_case();
};
@ -45,7 +46,7 @@ void ConsoleTest::test_case1()
}
//********************************************************************************
void ConsoleTest::dualPress_test_case()
void ConsoleTest::pressDual_test_case()
{
Console c;
auto t = new TestDataSender;
@ -53,7 +54,6 @@ void ConsoleTest::dualPress_test_case()
c.pressDual();
QByteArray arr;
arr.resize(8);
arr[0] = 0x00;
arr[1] = 0x01;
@ -65,7 +65,28 @@ void ConsoleTest::dualPress_test_case()
arr[7] = 0x00;
QCOMPARE(t->consoleData, arr);
}
//********************************************************************************
void ConsoleTest::releaseDual_test_case()
{
Console c;
auto t = new TestDataSender;
c.injectDataSender(t);
c.releaseDual();
QByteArray arr;
arr.resize(8);
arr[0] = 0x00;
arr[1] = 0x01;
arr[2] = 0x04;
arr[3] = 0x1D;
arr[4] = 0x00;
arr[5] = 0x00;
arr[6] = 0x00;
arr[7] = 0x00;
QCOMPARE(t->consoleData, arr);
}
QTEST_APPLESS_MAIN(ConsoleTest)

Loading…
Cancel
Save