Skip to content
This repository was archived by the owner on Mar 4, 2023. It is now read-only.

Commit 0dcbb05

Browse files
committed
fix race condition in integration test
1 parent 6457c89 commit 0dcbb05

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

tests/auto/datasync/IntegrationTest/tst_integration.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -619,13 +619,13 @@ void IntegrationTest::testAddAccountOnCreate()
619619
try {
620620
QSignalSpy error1Spy(acc1, &AccountManager::lastErrorChanged);
621621
QSignalSpy grantSpy(acc1, &AccountManager::accountAccessGranted);
622+
QSignalSpy requestSpy(acc1, &AccountManager::loginRequested);
622623
QSignalSpy unlockSpy(this, &IntegrationTest::unlock);
623624

624625
//export from acc1
625-
auto password = QStringLiteral("password");
626626
QJsonObject exportData;
627-
acc1->exportAccountTrusted(false, password, [&](QJsonObject exp) {
628-
QVERIFY(AccountManager::isTrustedImport(exp));
627+
acc1->exportAccount(false, [&](const QJsonObject &exp) {
628+
QVERIFY(!AccountManager::isTrustedImport(exp));
629629
exportData = exp;
630630
emit unlock();
631631
}, [](QString e) {
@@ -644,7 +644,7 @@ void IntegrationTest::testAddAccountOnCreate()
644644
TestLib::setup(setup3);
645645
setup3.setLocalDir(setup3.localDir() + QLatin1Char('/') + setupName3)
646646
.setRemoteConfiguration(QUrl(QStringLiteral("ws://localhost:14242")))
647-
.setAccountTrusted(exportData, password, false, false);
647+
.setAccount(exportData, false, false);
648648
setup3.create(setupName3);
649649

650650
acc3 = new AccountManager(setupName3, this);
@@ -657,6 +657,17 @@ void IntegrationTest::testAddAccountOnCreate()
657657
QSignalSpy error3Spy(acc3, &AccountManager::lastErrorChanged);
658658
QSignalSpy acceptSpy(acc3, &AccountManager::importAccepted);
659659

660+
//wait and accept acc1 login request
661+
if(requestSpy.isEmpty())
662+
QVERIFY(requestSpy.wait());
663+
QCOMPARE(requestSpy.size(), 1);
664+
auto request = requestSpy.takeFirst()[0].value<LoginRequest>();
665+
QVERIFY(!request.handled());
666+
QCOMPARE(request.device().name(), acc3->deviceName());
667+
QCOMPARE(request.device().fingerprint(), acc3->deviceFingerprint());
668+
request.accept();
669+
QVERIFY(request.handled());
670+
660671
//wait for accept
661672
if(acceptSpy.isEmpty())
662673
QVERIFY(acceptSpy.wait(15000)); //give more time

0 commit comments

Comments
 (0)