From 1a0a88b384c80181a70db4f1cec83edf57cdc312 Mon Sep 17 00:00:00 2001 From: Nasi Date: Sat, 12 Mar 2022 13:21:24 -0800 Subject: [PATCH] start add dual press --- logic/include/model/Console.h | 2 ++ logic/src/model/Console.cpp | 27 +++++++++++++++++++++++++++ test/tst_console.cpp | 28 ++++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/logic/include/model/Console.h b/logic/include/model/Console.h index 5d056a5..897551b 100644 --- a/logic/include/model/Console.h +++ b/logic/include/model/Console.h @@ -13,6 +13,8 @@ public: Console(); void injectDataSender(DataSender* sender); void test(); + void dualPress(); + void dualRelease(); }; #endif // CONSOLE_H diff --git a/logic/src/model/Console.cpp b/logic/src/model/Console.cpp index 9fc8331..918bf5d 100644 --- a/logic/src/model/Console.cpp +++ b/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() +{ + +} + +//******************************************************************************** diff --git a/test/tst_console.cpp b/test/tst_console.cpp index 355965c..523eda0 100644 --- a/test/tst_console.cpp +++ b/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"