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

Commit dd9dccd

Browse files
committed
completed add device integr. test
1 parent 2f9e01b commit dd9dccd

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

tests/auto/datasync/IntegrationTest/tst_integration.cpp

Lines changed: 41 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ void IntegrationTest::testPrepareData()
136136
QCOMPARE(store1->count(), 10);
137137

138138
sync1->runOnSynchronized([this](SyncManager::SyncState s) {
139-
QCOMPARE(s, SyncManager::Synchronized);
140139
emit unlock();
140+
QCOMPARE(s, SyncManager::Synchronized);
141141
}, false);
142142
QVERIFY(unlockSpy.wait());
143143

@@ -160,8 +160,8 @@ void IntegrationTest::testPrepareData()
160160
QCOMPARE(store2->count(), 10);
161161

162162
sync2->runOnSynchronized([this](SyncManager::SyncState s) {
163-
QCOMPARE(s, SyncManager::Synchronized);
164163
emit unlock();
164+
QCOMPARE(s, SyncManager::Synchronized);
165165
}, false);
166166
QVERIFY(unlockSpy.wait());
167167

@@ -180,6 +180,9 @@ void IntegrationTest::testAddAccount()
180180
QSignalSpy requestSpy(acc1, &AccountManager::loginRequested);
181181
QSignalSpy acceptSpy(acc2, &AccountManager::importAccepted);
182182
QSignalSpy grantSpy(acc1, &AccountManager::accountAccessGranted);
183+
QSignalSpy devices1Spy(acc1, &AccountManager::accountDevices);
184+
QSignalSpy devices2Spy(acc2, &AccountManager::accountDevices);
185+
QSignalSpy unlockSpy(this, &IntegrationTest::unlock);
183186

184187
//export from acc1
185188
acc1->exportAccount(false, [this](QJsonObject exp) {
@@ -197,7 +200,7 @@ void IntegrationTest::testAddAccount()
197200
//wait and accept acc1 login request
198201
QVERIFY(requestSpy.wait());
199202
QCOMPARE(requestSpy.size(), 1);
200-
LoginRequest request = requestSpy.takeFirst()[0].value<LoginRequest>();
203+
auto request = requestSpy.takeFirst()[0].value<LoginRequest>();
201204
QVERIFY(!request.handled());
202205
QCOMPARE(request.device().name(), acc2->deviceName());
203206
QCOMPARE(request.device().fingerprint(), acc2->deviceFingerprint());
@@ -217,6 +220,41 @@ void IntegrationTest::testAddAccount()
217220
QCOMPARE(grantSpy.size(), 1);
218221
QCOMPARE(grantSpy.takeFirst()[0].toUuid(), pId);
219222

223+
//wait for sync
224+
sync1->runOnSynchronized([this](SyncManager::SyncState s) {
225+
emit unlock();
226+
QCOMPARE(s, SyncManager::Synchronized);
227+
}, true);
228+
unlockSpy.wait();
229+
sync2->runOnSynchronized([this](SyncManager::SyncState s) {
230+
emit unlock();
231+
QCOMPARE(s, SyncManager::Synchronized);
232+
});
233+
unlockSpy.wait();
234+
235+
QCOMPARE(store1->count(), 20);
236+
QCOMPAREUNORDERED(store1->keys(), TestLib::generateDataKeys(0, 19));
237+
QCOMPARE(store2->count(), 20);
238+
QCOMPAREUNORDERED(store2->keys(), TestLib::generateDataKeys(0, 19));
239+
240+
//check devices status
241+
acc1->listDevices();
242+
QVERIFY(devices1Spy.wait());
243+
QCOMPARE(devices1Spy.size(), 1);
244+
auto devices = devices1Spy.takeFirst()[0].value<QList<DeviceInfo>>();
245+
QCOMPARE(devices.size(), 1);
246+
QCOMPARE(devices[0].deviceId(), pId);
247+
QCOMPARE(devices[0].name(), acc2->deviceName());
248+
QCOMPARE(devices[0].fingerprint(), acc2->deviceFingerprint());
249+
250+
acc2->listDevices();
251+
QVERIFY(devices2Spy.wait());
252+
QCOMPARE(devices2Spy.size(), 1);
253+
devices = devices2Spy.takeFirst()[0].value<QList<DeviceInfo>>();
254+
QCOMPARE(devices.size(), 1);
255+
QCOMPARE(devices[0].name(), acc1->deviceName());
256+
QCOMPARE(devices[0].fingerprint(), acc1->deviceFingerprint());
257+
220258
QVERIFY(error1Spy.isEmpty());
221259
QVERIFY(error2Spy.isEmpty());
222260
} catch(std::exception &e) {

tests/auto/datasync/TestLib/mockconnection.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void MockConnection::close()
5454
bool MockConnection::waitForNothing()
5555
{
5656
return _msgSpy.isEmpty() &&
57-
!_msgSpy.wait(WAIT_TIMEOUT) &&
57+
!_msgSpy.wait() &&
5858
_closeSpy.isEmpty();
5959
}
6060

0 commit comments

Comments
 (0)