Browse Source

start add dual press

mode-button
Nasi 3 years ago
parent
commit
1a0a88b384
  1. 2
      logic/include/model/Console.h
  2. 27
      logic/src/model/Console.cpp
  3. 28
      test/tst_console.cpp

2
logic/include/model/Console.h

@ -13,6 +13,8 @@ public:
Console();
void injectDataSender(DataSender* sender);
void test();
void dualPress();
void dualRelease();
};
#endif // CONSOLE_H

27
logic/src/model/Console.cpp

@ -7,11 +7,13 @@ Console::Console()
}
//********************************************************************************
void Console::injectDataSender(DataSender *sender)
{
_dataSender = sender;
}
//********************************************************************************
void Console::test()
{
QByteArray arr;
@ -20,3 +22,28 @@ void Console::test()
arr.append(0x05);
_dataSender->send(arr);
}
//********************************************************************************
void Console::dualPress()
{
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;
_dataSender->send(arr);
}
//********************************************************************************
void Console::dualRelease()
{
}
//********************************************************************************

28
test/tst_console.cpp

@ -13,19 +13,23 @@ public:
private slots:
void test_case1();
void dualPress_test_case();
};
//********************************************************************************
ConsoleTest::ConsoleTest()
{
}
//********************************************************************************
ConsoleTest::~ConsoleTest()
{
}
//********************************************************************************
void ConsoleTest::test_case1()
{
Console c;
@ -40,6 +44,30 @@ void ConsoleTest::test_case1()
QCOMPARE(t->consoleData, arr);
}
//********************************************************************************
void ConsoleTest::dualPress_test_case()
{
Console c;
auto t = new TestDataSender;
c.injectDataSender(t);
c.dualPress();
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)
#include "tst_console.moc"

Loading…
Cancel
Save