Skip to content

Commit

Permalink
Merge branch 'fix_error_api_on_tests' into 'master'
Browse files Browse the repository at this point in the history
[buteo-syncfw] Fix error api change on unit test. Contributes to JB#31584

See merge request mer-core/buteo-syncfw!65
  • Loading branch information
pvuorela committed Apr 14, 2021
2 parents 1a50ddb + 2914531 commit 382548f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
Expand Up @@ -38,6 +38,7 @@ void ClientPluginRunnerTest::initTestCase()
iClientPrunner = new ClientPluginRunner(PLUGIN, iSprofile, iPluginMgr,
iPluginCbIf, nullptr);
}

void ClientPluginRunnerTest::cleanupTestCase()
{
QVERIFY(iSprofile);
Expand All @@ -54,6 +55,7 @@ void ClientPluginRunnerTest::cleanupTestCase()
iPluginCbIf = 0;
iClientPrunner = 0;
}

void ClientPluginRunnerTest::testCpluginRunnerConstructor()
{
SyncResults syncRes;
Expand All @@ -77,6 +79,7 @@ void ClientPluginRunnerTest::testCpluginRunnerConstructor()
dateTime = syncRes.syncTime() >= current;
QVERIFY(dateTime);
}

void ClientPluginRunnerTest::testInit()
{
SyncResults syncRes;
Expand All @@ -94,6 +97,7 @@ void ClientPluginRunnerTest::testInit()
iClientPrunner->iInitialized = true;
QCOMPARE(iClientPrunner->iInitialized, true);
}

void ClientPluginRunnerTest::testStart()
{
//test start()
Expand All @@ -105,6 +109,7 @@ void ClientPluginRunnerTest::testStart()
QVERIFY(iClientPrunner->iThread != 0);
QCOMPARE(iClientPrunner->start(), false);
}

void ClientPluginRunnerTest::testSignals()
{
QSignalSpy doneSignal(iClientPrunner, SIGNAL(done()));
Expand All @@ -117,7 +122,7 @@ void ClientPluginRunnerTest::testSignals()
QCOMPARE(successSignal.count(), 1);

QSignalSpy errorSignal(iClientPrunner, SIGNAL(error(const QString &,
const QString &, int)));
const QString &, SyncResults::MinorCode)));
iClientPrunner->onError(PROFILE, "Message", SyncResults::PLUGIN_ERROR);
QCOMPARE(errorSignal.count(), 1);

Expand Down
Expand Up @@ -71,6 +71,7 @@ void ClientThreadTest::initTestCase()
iPlugin = iPluginDerived;
iClientThreadRet = false;
}

void ClientThreadTest::cleanupTestCase()
{
QVERIFY(iSyncProfile != 0);
Expand All @@ -85,11 +86,13 @@ void ClientThreadTest::cleanupTestCase()
iClientThread = 0;
iPlugin = 0;
}

void ClientThreadTest::testClientThreadConstructor()
{
QVERIFY(iClientThread->getPlugin() == nullptr);
QCOMPARE(iClientThread->iRunning, false);
}

void ClientThreadTest::testGetPlugin()
{
iClientThreadRet = iClientThread->startThread(iPlugin);
Expand All @@ -98,17 +101,20 @@ void ClientThreadTest::testGetPlugin()
QCOMPARE(iClientThread->iRunning, true);
QCOMPARE(iClientThread->getPlugin(), iPlugin);
}

void ClientThreadTest::testGetProfileName()
{
QCOMPARE(iClientThreadRet, true);
QCOMPARE(iClientThread->getProfileName(), PROFILE);
}

void ClientThreadTest::testClientThread()
{
//The thread is already running
QCOMPARE(iClientThread->startThread(iPlugin), false);
QCOMPARE(iClientThread->iRunning, true);
}

void ClientThreadTest::testGetSyncResults()
{
SyncResults syncRes;
Expand All @@ -130,14 +136,15 @@ void ClientThreadTest::testGetSyncResults()
//QCOMPARE(syncRes.syncTime().date(), QDateTime::currentDateTime().date());

}

void ClientThreadTest::testInitError()
{
iPluginDerived->iTestClSignal = true;

//Test for the signal
QSignalSpy spy(iClientThread, SIGNAL(initError(const QString &,
const QString &,
int )));
SyncResults::MinorCode)));
QCOMPARE(iClientThread->startThread(iPlugin), true);
QTest::qWait(20);
QCOMPARE(spy.count(), 1);
Expand Down
Expand Up @@ -103,7 +103,7 @@ void ServerPluginRunnerTest::testSyncResults()
void ServerPluginRunnerTest::testSignals()
{
QSignalSpy sessionSpy(iServerPluginRunner, SIGNAL(newSession(QString)));
QSignalSpy errorSpy(iServerPluginRunner, SIGNAL(error(QString, QString, int)));
QSignalSpy errorSpy(iServerPluginRunner, SIGNAL(error(QString, QString, SyncResults::MinorCode)));
QSignalSpy successSpy(iServerPluginRunner, SIGNAL(success(QString, QString)));
QSignalSpy doneSpy(iServerPluginRunner, SIGNAL(done()));

Expand Down
Expand Up @@ -86,6 +86,7 @@ void ServerThreadTest::initTestCase()
iPluginDerived = new ServerPluginDerived(PGNAME, *iProfile, nullptr);
iThreadTestSp = iPluginDerived;
}

void ServerThreadTest::cleanupTestCase()
{
QVERIFY(iProfile != 0);
Expand All @@ -100,30 +101,35 @@ void ServerThreadTest::cleanupTestCase()
iServerThread = 0;
iThreadTestSp = 0;
}

void ServerThreadTest::testServerThreadConstructor()
{
QVERIFY(iServerThread->getPlugin() == nullptr);
QCOMPARE(iServerThread->iRunning, false);
}

void ServerThreadTest::testGetPlugin()
{
iThreadreturn = iServerThread->startThread(iThreadTestSp);
QTest::qWait(20);
QCOMPARE(iThreadreturn, true);
QCOMPARE(iServerThread->getPlugin(), iThreadTestSp);
}

void ServerThreadTest::testGetProfileName()
{
QCOMPARE(iThreadreturn, true);
QCOMPARE(iServerThread->getProfileName(), PFNAME);
}

void ServerThreadTest::testThread()
{
//The Thread is already started in testGetPlugin()
QCOMPARE(iServerThread->startThread(iThreadTestSp), false);
QCOMPARE(iServerThread->iRunning, true);
QCOMPARE(iServerThread->getPlugin(), iThreadTestSp);
}

void ServerThreadTest::testStopThErrorSignal()
{
QVERIFY(iServerThread != 0);
Expand All @@ -133,7 +139,7 @@ void ServerThreadTest::testStopThErrorSignal()

//Test for the signal
QSignalSpy spy(iServerThread, SIGNAL(initError(const QString &,
const QString &, int)));
const QString &, SyncResults::MinorCode)));
QCOMPARE(iServerThread->startThread(iThreadTestSp), true);
QTest::qWait(20);
QCOMPARE(spy.count(), 1);
Expand Down
Expand Up @@ -311,7 +311,7 @@ void SyncSessionTest :: testOnDone()
// registering unknown metatype
qRegisterMetaType<Sync::SyncStatus>("Sync::SyncStatus");

QSignalSpy sampleSpy(iSyncSession, SIGNAL(finished(QString, Sync::SyncStatus, QString, int)));
QSignalSpy sampleSpy(iSyncSession, SIGNAL(finished(QString, Sync::SyncStatus, QString, SyncResults::MinorCode)));

// call functions that emit finished() signal
iSyncSession->onDone();
Expand Down

0 comments on commit 382548f

Please sign in to comment.