From: Claudio Cambra Date: Wed, 16 Nov 2022 19:55:53 +0000 (+0100) Subject: Make accountstate fakeable for tests X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~11^2~30^2~17 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=c59ab85e22d7205a122f44b857a63798fe62c449;p=nextcloud-desktop.git Make accountstate fakeable for tests Signed-off-by: Claudio Cambra --- diff --git a/src/gui/accountstate.h b/src/gui/accountstate.h index 4e0621e33..2f46f9a86 100644 --- a/src/gui/accountstate.h +++ b/src/gui/accountstate.h @@ -27,6 +27,7 @@ #include class QSettings; +class FakeAccountState; namespace OCC { @@ -182,10 +183,10 @@ public: public slots: /// Triggers a ping to the server to update state and /// connection status and errors. - void checkConnectivity(); + virtual void checkConnectivity(); private: - void setState(State state); + virtual void setState(State state); void fetchNavigationApps(); int retryCount() const; @@ -261,6 +262,9 @@ private: QTimer _checkConnectionTimer; QElapsedTimer _lastCheckConnectionTimer; + explicit AccountState() = default; + + friend class ::FakeAccountState; }; class AccountApp : public QObject diff --git a/test/testhelper.h b/test/testhelper.h index 2ddb859e5..24a89c298 100644 --- a/test/testhelper.h +++ b/test/testhelper.h @@ -1,6 +1,7 @@ #ifndef TESTHELPER_H #define TESTHELPER_H +#include "gui/accountstate.h" #include "gui/folder.h" #include "creds/httpcredentials.h" @@ -18,6 +19,26 @@ public: OCC::FolderDefinition folderDefinition(const QString &path); +class FakeAccountState : public OCC::AccountState +{ + Q_OBJECT + +public: + explicit FakeAccountState(OCC::AccountPtr account) + : OCC::AccountState() + { + _account = account; + _state = Connected; + } + +public slots: + void checkConnectivity() override {}; + +private slots: + void setState(OCC::AccountState::State state) override { Q_UNUSED(state) }; +}; + + const QByteArray jsonValueToOccReply(const QJsonValue &jsonValue); #endif // TESTHELPER_H