|
@ -2,6 +2,7 @@ |
|
|
|
|
|
|
|
|
#include "TestDataSender.h" |
|
|
#include "TestDataSender.h" |
|
|
#include "model/Console.h" |
|
|
#include "model/Console.h" |
|
|
|
|
|
#include "Consolelogger.h" |
|
|
|
|
|
|
|
|
#include <QSignalSpy> |
|
|
#include <QSignalSpy> |
|
|
|
|
|
|
|
@ -18,7 +19,7 @@ private slots: |
|
|
//uncrustify on
|
|
|
//uncrustify on
|
|
|
void pressDual_test_case(); |
|
|
void pressDual_test_case(); |
|
|
void releaseDual_test_case(); |
|
|
void releaseDual_test_case(); |
|
|
void sendDatatoDual_test_case(); |
|
|
void receiveDatatoDual_test_case(); |
|
|
|
|
|
|
|
|
void pressQuad_test_case(); |
|
|
void pressQuad_test_case(); |
|
|
void releaseQuad_test_case(); |
|
|
void releaseQuad_test_case(); |
|
@ -27,6 +28,9 @@ private slots: |
|
|
void rotatFocusWithLed_test_case(); |
|
|
void rotatFocusWithLed_test_case(); |
|
|
|
|
|
|
|
|
void echoSignalTest(); |
|
|
void echoSignalTest(); |
|
|
|
|
|
void wrongProtocol(); |
|
|
|
|
|
void wrongPacketRecivedDirection(); |
|
|
|
|
|
void ledColorWrong(); |
|
|
|
|
|
|
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
@ -84,7 +88,7 @@ void ConsoleTest::releaseDual_test_case() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/*************************************************************************************************/ |
|
|
/*************************************************************************************************/ |
|
|
void ConsoleTest::sendDatatoDual_test_case() |
|
|
void ConsoleTest::receiveDatatoDual_test_case() |
|
|
{ |
|
|
{ |
|
|
Console c; |
|
|
Console c; |
|
|
auto t = new TestDataSender; |
|
|
auto t = new TestDataSender; |
|
@ -224,6 +228,88 @@ void ConsoleTest::echoSignalTest() |
|
|
QCOMPARE(t->consoleData, arr); |
|
|
QCOMPARE(t->consoleData, arr); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************************************/ |
|
|
|
|
|
void ConsoleTest::wrongProtocol() |
|
|
|
|
|
{ |
|
|
|
|
|
Console c; |
|
|
|
|
|
auto t = new TestDataSender; |
|
|
|
|
|
|
|
|
|
|
|
c.injectDataSender(t); |
|
|
|
|
|
|
|
|
|
|
|
auto log = new ConsoleLogger; |
|
|
|
|
|
c.injectLogger(log); |
|
|
|
|
|
|
|
|
|
|
|
QByteArray arr; |
|
|
|
|
|
|
|
|
|
|
|
char ledValue = 0x01; |
|
|
|
|
|
|
|
|
|
|
|
arr.resize(5); |
|
|
|
|
|
arr[0] = 0x01; |
|
|
|
|
|
arr[1] = 0x01; |
|
|
|
|
|
arr[2] = 0x03; |
|
|
|
|
|
arr[3] = static_cast<char>(0x82); |
|
|
|
|
|
arr[4] = ledValue; |
|
|
|
|
|
|
|
|
|
|
|
c.newData(arr); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ConsoleTest::wrongPacketRecivedDirection() |
|
|
|
|
|
{ |
|
|
|
|
|
Console c; |
|
|
|
|
|
auto t = new TestDataSender; |
|
|
|
|
|
c.injectDataSender(t); |
|
|
|
|
|
|
|
|
|
|
|
QByteArray arr; |
|
|
|
|
|
|
|
|
|
|
|
char ledValue = 0x01; |
|
|
|
|
|
|
|
|
|
|
|
arr.resize(8); |
|
|
|
|
|
arr[0] = 0x00; |
|
|
|
|
|
arr[1] = 0x01; |
|
|
|
|
|
arr[2] = 0x03; |
|
|
|
|
|
arr[3] = static_cast<char>(0x82); |
|
|
|
|
|
arr[4] = ledValue; |
|
|
|
|
|
arr[5] = 0x00; |
|
|
|
|
|
arr[6] = 0x00; |
|
|
|
|
|
arr[7] = 0x00; |
|
|
|
|
|
|
|
|
|
|
|
c.newData(arr); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
/*************************************************************************************************/ |
|
|
|
|
|
|
|
|
|
|
|
void ConsoleTest::ledColorWrong() |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
Console c; |
|
|
|
|
|
auto t = new TestDataSender; |
|
|
|
|
|
c.injectDataSender(t); |
|
|
|
|
|
|
|
|
|
|
|
QSignalSpy spy(&c, SIGNAL(dualLedChanged(char))); |
|
|
|
|
|
|
|
|
|
|
|
QByteArray arr; |
|
|
|
|
|
|
|
|
|
|
|
char ledValue = 0x05; |
|
|
|
|
|
|
|
|
|
|
|
arr.resize(8); |
|
|
|
|
|
arr[0] = 0x01; |
|
|
|
|
|
arr[1] = 0x01; |
|
|
|
|
|
arr[2] = 0x03; |
|
|
|
|
|
arr[3] = static_cast<char>(0x82); |
|
|
|
|
|
arr[4] = ledValue; |
|
|
|
|
|
arr[5] = 0x00; |
|
|
|
|
|
arr[6] = 0x00; |
|
|
|
|
|
arr[7] = 0x00; |
|
|
|
|
|
|
|
|
|
|
|
c.newData(arr); |
|
|
|
|
|
|
|
|
|
|
|
auto result = spy.takeFirst()[0].value<QByteArray>(); |
|
|
|
|
|
QEXPECT_FAIL("led color is wrong", "Oh my, this is soooo broken", Abort); |
|
|
|
|
|
QCOMPARE(result[0], ledValue); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/*************************************************************************************************/ |
|
|
/*************************************************************************************************/ |
|
|
|
|
|
|
|
|
QTEST_APPLESS_MAIN(ConsoleTest) |
|
|
QTEST_APPLESS_MAIN(ConsoleTest) |
|
|