mirror of
https://github.com/siemens-mobile-hacks/elfloader3-linux.git
synced 2026-11-25 23:57:20 +00:00
50 lines
1.4 KiB
C++
50 lines
1.4 KiB
C++
#include "../src/AppWindow.h"
|
|
|
|
#include <QHostAddress>
|
|
#include <QTcpServer>
|
|
#include <QtTest>
|
|
|
|
class AppWindowTest: public QObject {
|
|
Q_OBJECT
|
|
|
|
private slots:
|
|
void reconnectsUntilArmIpcStarts();
|
|
void forwardsKeyWithoutModifiers();
|
|
};
|
|
|
|
void AppWindowTest::reconnectsUntilArmIpcStarts() {
|
|
QTcpServer server;
|
|
QVERIFY(server.listen(QHostAddress::LocalHost, 0));
|
|
quint16 port = server.serverPort();
|
|
server.close();
|
|
|
|
AppWindow window(port);
|
|
window.connectToServer();
|
|
QTest::qWait(200);
|
|
|
|
QVERIFY(server.listen(QHostAddress::LocalHost, port));
|
|
QTRY_VERIFY_WITH_TIMEOUT(server.hasPendingConnections(), 2000);
|
|
}
|
|
|
|
void AppWindowTest::forwardsKeyWithoutModifiers() {
|
|
QTcpServer server;
|
|
QVERIFY(server.listen(QHostAddress::LocalHost, 0));
|
|
|
|
AppWindow window(server.serverPort());
|
|
window.connectToServer();
|
|
QTRY_VERIFY_WITH_TIMEOUT(server.hasPendingConnections(), 2000);
|
|
QTcpSocket *socket = server.nextPendingConnection();
|
|
|
|
QTest::keyPress(&window, Qt::Key_5);
|
|
QTRY_VERIFY_WITH_TIMEOUT(socket->bytesAvailable() >= sizeof(IpcPacketKeyEvent), 2000);
|
|
QByteArray data = socket->read(sizeof(IpcPacketKeyEvent));
|
|
auto *key = reinterpret_cast<const IpcPacketKeyEvent *>(data.constData());
|
|
QCOMPARE(key->header.cmd, IPC_CMD_KEY_EVENT);
|
|
QCOMPARE(key->keycode, static_cast<uint32_t>(IPC_KEY_5));
|
|
QCOMPARE(key->modifiers, static_cast<uint32_t>(IPC_NO_MODIFIER));
|
|
QCOMPARE(key->state, IPC_KEY_PRESS);
|
|
}
|
|
|
|
QTEST_MAIN(AppWindowTest)
|
|
|
|
#include "AppWindowTest.moc"
|