2017-07-03 09:30:10 +02:00
|
|
|
/*!
|
|
|
|
* \brief Unit tests for \ref UIPlugInCli
|
|
|
|
*
|
2018-03-28 15:10:51 +02:00
|
|
|
* \copyright Copyright (c) 2015-2018 Governikus GmbH & Co. KG, Germany
|
2017-07-03 09:30:10 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "CliHelper.h"
|
|
|
|
|
|
|
|
#include <QtTest/QtTest>
|
|
|
|
|
|
|
|
using namespace governikus;
|
|
|
|
|
|
|
|
class test_UIPlugInCli
|
|
|
|
: public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
QScopedPointer<CliHelper> cli;
|
|
|
|
|
|
|
|
private Q_SLOTS:
|
|
|
|
void initTestCase()
|
|
|
|
{
|
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
QSKIP("Console is not supported at the moment");
|
|
|
|
#endif
|
|
|
|
|
2017-12-20 14:54:05 +01:00
|
|
|
#ifdef Q_OS_MACOS
|
2017-07-03 09:33:28 +02:00
|
|
|
QSKIP("QProcess/CliHelper is flaky on OSX");
|
2017-07-03 09:30:10 +02:00
|
|
|
#endif
|
|
|
|
|
2017-07-03 09:33:28 +02:00
|
|
|
#if defined(Q_OS_BSD4) || defined (Q_OS_LINUX)
|
|
|
|
QSKIP("Platform plugin seems broken");
|
|
|
|
#endif
|
2017-07-03 09:30:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void init()
|
|
|
|
{
|
|
|
|
cli.reset(new CliHelper());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void cleanup()
|
|
|
|
{
|
|
|
|
cli->tearDown();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void quit()
|
|
|
|
{
|
|
|
|
CLI_VERIFY(cli->run());
|
2017-07-03 09:33:28 +02:00
|
|
|
CLI_VERIFY(cli->waitForOutput("ready"));
|
2017-07-03 09:30:10 +02:00
|
|
|
CLI_VERIFY(cli->waitForPong());
|
|
|
|
cli->send("help");
|
|
|
|
CLI_VERIFY(cli->waitForOutput("Available commands:"));
|
|
|
|
cli->send("quit");
|
|
|
|
CLI_VERIFY(cli->waitForOutput("Shutdown application"));
|
|
|
|
CLI_VERIFY(cli->waitForOutput("Emit fire shutdown"));
|
|
|
|
CLI_VERIFY(cli->waitForOutput("Shutdown ReaderManager"));
|
|
|
|
CLI_VERIFY(cli->waitForOutput("Unregister resource:"));
|
|
|
|
CLI_VERIFY(cli->waitForOutput("Quit event loop of QCoreApplication"));
|
|
|
|
cli->waitForFinished();
|
|
|
|
QCOMPARE(cli->state(), QProcess::NotRunning);
|
|
|
|
QCOMPARE(cli->exitCode(), 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void term()
|
|
|
|
{
|
|
|
|
CLI_VERIFY(cli->run());
|
2017-07-03 09:33:28 +02:00
|
|
|
CLI_VERIFY(cli->waitForOutput("ready"));
|
2017-07-03 09:30:10 +02:00
|
|
|
CLI_VERIFY(cli->waitForPong());
|
|
|
|
cli->stop();
|
|
|
|
QCOMPARE(cli->state(), QProcess::NotRunning);
|
|
|
|
QCOMPARE(cli->exitCode(), 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void termDuringOldPin()
|
|
|
|
{
|
|
|
|
CLI_VERIFY(cli->run());
|
2017-07-03 09:33:28 +02:00
|
|
|
CLI_VERIFY(cli->waitForOutput("ready"));
|
2017-07-03 09:30:10 +02:00
|
|
|
cli->send("changepin");
|
|
|
|
CLI_VERIFY(cli->waitForOutput("Please enter old PIN"));
|
|
|
|
cli->stop();
|
|
|
|
QCOMPARE(cli->state(), QProcess::NotRunning);
|
|
|
|
QCOMPARE(cli->exitCode(), 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void changePin()
|
|
|
|
{
|
|
|
|
CLI_VERIFY(cli->run());
|
2017-07-03 09:33:28 +02:00
|
|
|
CLI_VERIFY(cli->waitForOutput("ready"));
|
2017-07-03 09:30:10 +02:00
|
|
|
cli->send("changepin");
|
|
|
|
CLI_VERIFY(cli->waitForOutput("Please enter old PIN"));
|
|
|
|
cli->send("123456");
|
|
|
|
CLI_VERIFY(cli->waitForOutput("Please enter new PIN"));
|
|
|
|
cli->send("123456");
|
|
|
|
CLI_VERIFY(cli->waitForOutput("Please enter new PIN again"));
|
|
|
|
cli->send("123456");
|
|
|
|
CLI_VERIFY(cli->waitForOutput("Start"));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void getServerPort()
|
|
|
|
{
|
|
|
|
CLI_VERIFY(cli->run());
|
2017-07-03 09:33:28 +02:00
|
|
|
CLI_VERIFY(cli->waitForOutput("ready"));
|
2017-07-03 09:30:10 +02:00
|
|
|
QVERIFY(cli->getServerPort() > 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
QTEST_GUILESS_MAIN(test_UIPlugInCli)
|
|
|
|
#include "test_UIPlugInCli.moc"
|