You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

167 lines
3.4 KiB

#include <QtTest>
#include "TestDataSender.h"
#include "model/Console.h"
class ConsoleTest : public QObject
{
Q_OBJECT
public:
ConsoleTest();
~ConsoleTest();
//uncrustify off
private slots:
//uncrustify on
void pressDual_test_case();
void releaseDual_test_case();
void pressQuad_test_case();
void releaseQuad_test_case();
void rotateJs1NoLed_test_case();
void rotatFocusWithLed_test_case();
};
/*************************************************************************************************/
ConsoleTest::ConsoleTest()
{
}
/*************************************************************************************************/
ConsoleTest::~ConsoleTest()
{
}
/*************************************************************************************************/
void ConsoleTest::pressDual_test_case()
{
Console c;
auto t = new TestDataSender;
c.injectDataSender(t);
c.pressDual();
QByteArray arr;
arr.resize(8);
arr[0] = 0x00;
arr[1] = 0x01;
arr[2] = 0x04;
arr[3] = 0x1D;
arr[4] = 0x01;
arr[5] = 0x00;
arr[6] = 0x00;
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);
}
/*************************************************************************************************/
void ConsoleTest::pressQuad_test_case()
{
Console c;
auto t = new TestDataSender;
c.injectDataSender(t);
c.pressQuad();
QByteArray arr;
arr.resize(8);
arr[0] = 0x00;
arr[1] = 0x01;
arr[2] = 0x04;
arr[3] = 0x1C;
arr[4] = 0x01;
arr[5] = 0x00;
arr[6] = 0x00;
arr[7] = 0x00;
QCOMPARE(t->consoleData, arr);
}
/*************************************************************************************************/
void ConsoleTest::releaseQuad_test_case()
{
Console c;
auto t = new TestDataSender;
c.injectDataSender(t);
c.releaseQuad();
QByteArray arr;
arr.resize(8);
arr[0] = 0x00;
arr[1] = 0x01;
arr[2] = 0x04;
arr[3] = 0x1C;
arr[4] = 0x00;
arr[5] = 0x00;
arr[6] = 0x00;
arr[7] = 0x00;
QCOMPARE(t->consoleData, arr);
}
void ConsoleTest::rotateJs1NoLed_test_case()
{
Console c;
auto t = new TestDataSender;
c.injectDataSender(t);
c.rotateJs1(0);
QByteArray arr;
arr.resize(8);
arr[0] = 0x00;
arr[1] = 0x02;
arr[2] = 0x05;
arr[3] = 0x56;
arr[4] = static_cast<char>(0 >> 8);
arr[5] = static_cast<char>(0);
arr[6] = 0x00;
arr[7] = 0x00;
QCOMPARE(t->consoleData, arr);
}
void ConsoleTest::rotatFocusWithLed_test_case()
{
Console c;
auto t = new TestDataSender;
c.injectDataSender(t);
c.rotateFocus(4000);
QByteArray arr;
arr.resize(8);
arr[0] = 0x00;
arr[1] = 0x02;
arr[2] = 0x05;
arr[3] = 0x51;
arr[4] = static_cast<char>(4000 >> 8);
arr[5] = static_cast<char>(4000);
arr[6] = 0x00;
arr[7] = 0x00;
QCOMPARE(t->consoleData, arr);
}
QTEST_APPLESS_MAIN(ConsoleTest)
#include "tst_console.moc"