Changeset View
Changeset View
Standalone View
Standalone View
src/tests/matrix-sdk-sessions-test.cpp
| Show First 20 Lines • Show All 95 Lines • ▼ Show 20 Lines | #endif | ||||
| QCOMPARE(sdk->allSessions(), expected); | QCOMPARE(sdk->allSessions(), expected); | ||||
| } | } | ||||
| void MatrixSdkSessionsTest::testLoadSession() | void MatrixSdkSessionsTest::testLoadSession() | ||||
| { | { | ||||
| createSession("@mew:example.com", "device4"); | createSession("@mew:example.com", "device4"); | ||||
| auto sdk = makeMatrixSdk(); | auto sdk = makeMatrixSdk(); | ||||
| auto res = sdk->loadSession(u"@mew:example.com/device4"_s); | auto spy = QSignalSpy(sdk.get(), &MatrixSdk::loadSessionFinished); | ||||
| sdk->loadSession(u"@mew:example.com/device4"_s); | |||||
| spy.wait(); | |||||
| auto res = spy.first().at(1); | |||||
| QCOMPARE(res, MatrixSdk::SessionLoadSuccess); | QCOMPARE(res, MatrixSdk::SessionLoadSuccess); | ||||
| QCOMPARE(sdk->userId(), QStringLiteral("@mew:example.com")); | QCOMPARE(sdk->userId(), QStringLiteral("@mew:example.com")); | ||||
| QCOMPARE(sdk->deviceId(), QStringLiteral("device4")); | QCOMPARE(sdk->deviceId(), QStringLiteral("device4")); | ||||
| } | } | ||||
| void MatrixSdkSessionsTest::testSessionLock() | void MatrixSdkSessionsTest::testSessionLock() | ||||
| { | { | ||||
| #if KAZV_IS_WINDOWS | #if KAZV_IS_WINDOWS | ||||
| ▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | model.client.serverUrl = "https://example.com"; | ||||
| // this should fail | // this should fail | ||||
| sdk->serializeToFile(); | sdk->serializeToFile(); | ||||
| } | } | ||||
| // Not ideal, but this is the only way to wait for | // Not ideal, but this is the only way to wait for | ||||
| // MatrixSdkPravite to be destroyed. | // MatrixSdkPravite to be destroyed. | ||||
| QTest::qWait(100); | QTest::qWait(100); | ||||
| auto sdk = makeMatrixSdk(); | auto sdk = makeMatrixSdk(); | ||||
| auto res = sdk->loadSession(QString::fromStdString(userId + "/" + deviceId)); | auto spy = QSignalSpy(sdk.get(), &MatrixSdk::loadSessionFinished); | ||||
| sdk->loadSession(QString::fromStdString(userId + "/" + deviceId)); | |||||
| spy.wait(); | |||||
| auto res = spy.first().at(1); | |||||
| QCOMPARE(res, MatrixSdk::SessionLoadSuccess); | QCOMPARE(res, MatrixSdk::SessionLoadSuccess); | ||||
| // verify that the original data is kept | // verify that the original data is kept | ||||
| QCOMPARE(sdk->serverUrl(), u""_s); | QCOMPARE(sdk->serverUrl(), u""_s); | ||||
| // before cleaning up, add write permissions back so the files can be removed | // before cleaning up, add write permissions back so the files can be removed | ||||
| Fs::permissions( | Fs::permissions( | ||||
| sessionDir, | sessionDir, | ||||
| Fs::perms::owner_read | Fs::perms::owner_write | Fs::perms::owner_exec, | Fs::perms::owner_read | Fs::perms::owner_write | Fs::perms::owner_exec, | ||||
| Show All 9 Lines | |||||