Make accountstate fakeable for tests

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2022-11-16 20:55:53 +01:00
parent b57b35e7a4
commit c59ab85e22
No known key found for this signature in database
GPG key ID: C839200C384636B0
2 changed files with 27 additions and 2 deletions

View file

@ -27,6 +27,7 @@
#include <memory>
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

View file

@ -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