diff options
author | Felix Weilbach <felix.weilbach@nextcloud.com> | 2021-04-08 10:29:55 +0300 |
---|---|---|
committer | Felix Weilbach (Rebase PR Action) <felix.weilbach@t-online.de> | 2021-04-13 15:19:40 +0300 |
commit | b256c6e6945d69e09df443078cb9864c838795f8 (patch) | |
tree | 66f44cf07c7a74bd020fd1a2bafc202335334625 /test | |
parent | d7499b0746b599e48925bc6afce51b44923b2025 (diff) |
Ping websocket server
This helps the client to recognize if the websocket server is still alive.
Fixes #2983
Signed-off-by: Felix Weilbach <felix.weilbach@nextcloud.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/testpushnotifications.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/testpushnotifications.cpp b/test/testpushnotifications.cpp index 161ae94b8..969f0da8f 100644 --- a/test/testpushnotifications.cpp +++ b/test/testpushnotifications.cpp @@ -230,6 +230,31 @@ private slots: auto accountSent = pushNotificationsDisabledSpy.at(0).at(0).value<OCC::Account *>(); QCOMPARE(accountSent, account.data()); } + + void testPingTimeout_pingTimedOut_reconnect() + { + FakeWebSocketServer fakeServer; + std::unique_ptr<QSignalSpy> filesChangedSpy; + std::unique_ptr<QSignalSpy> notificationsChangedSpy; + std::unique_ptr<QSignalSpy> activitiesChangedSpy; + auto account = FakeWebSocketServer::createAccount(); + QVERIFY(fakeServer.authenticateAccount(account)); + + // Set the ping timeout interval to zero and check if the server attemps to authenticate again + fakeServer.clearTextMessages(); + account->pushNotifications()->setPingInterval(0); + QVERIFY(fakeServer.authenticateAccount( + account, [&](OCC::PushNotifications *pushNotifications) { + filesChangedSpy.reset(new QSignalSpy(pushNotifications, &OCC::PushNotifications::filesChanged)); + notificationsChangedSpy.reset(new QSignalSpy(pushNotifications, &OCC::PushNotifications::notificationsChanged)); + activitiesChangedSpy.reset(new QSignalSpy(pushNotifications, &OCC::PushNotifications::activitiesChanged)); + }, + [&] { + QVERIFY(verifyCalledOnceWithAccount(*filesChangedSpy, account)); + QVERIFY(verifyCalledOnceWithAccount(*notificationsChangedSpy, account)); + QVERIFY(verifyCalledOnceWithAccount(*activitiesChangedSpy, account)); + })); + } }; QTEST_GUILESS_MAIN(TestPushNotifications) |