mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-21 20:45:51 +03:00
Make accountstate fakeable for tests
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
b57b35e7a4
commit
c59ab85e22
2 changed files with 27 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue