Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'test/testutils/testutils.cpp')
-rw-r--r--test/testutils/testutils.cpp59
1 files changed, 59 insertions, 0 deletions
diff --git a/test/testutils/testutils.cpp b/test/testutils/testutils.cpp
new file mode 100644
index 000000000..281323073
--- /dev/null
+++ b/test/testutils/testutils.cpp
@@ -0,0 +1,59 @@
+#include "testutils.h"
+
+#include "creds/httpcredentials.h"
+#include "gui/accountmanager.h"
+
+#include <QCoreApplication>
+
+namespace {
+class HttpCredentialsTest : public OCC::HttpCredentials
+{
+public:
+ HttpCredentialsTest(const QString &user, const QString &password)
+ : HttpCredentials(OCC::DetermineAuthTypeJob::AuthType::Basic, user, password)
+ {
+ }
+
+ void askFromUser() override
+ {
+ }
+};
+}
+
+namespace OCC {
+
+namespace TestUtils {
+ AccountPtr createDummyAccount()
+ {
+ // don't use the account manager to create the account, it would try to use widgets
+ auto acc = Account::create();
+ HttpCredentialsTest *cred = new HttpCredentialsTest("testuser", "secret");
+ acc->setCredentials(cred);
+ acc->setUrl(QUrl(QStringLiteral("http://localhost/owncloud")));
+ acc->setDavDisplayName(QStringLiteral("fakename") + acc->uuid().toString());
+ acc->setServerVersion(QStringLiteral("10.0.0"));
+ OCC::AccountManager::instance()->addAccount(acc);
+ return acc;
+ }
+
+ FolderDefinition createDummyFolderDefinition(const QString &path)
+ {
+ OCC::FolderDefinition d;
+ d.localPath = path;
+ d.targetPath = path;
+ d.alias = path;
+ return d;
+ }
+
+ FolderMan *folderMan()
+ {
+ static FolderMan *man = [] {
+ auto man = new FolderMan;
+ QObject::connect(QCoreApplication::instance(), &QCoreApplication::aboutToQuit, man, &FolderMan::deleteLater);
+ return man;
+ }();
+ return man;
+ }
+
+}
+}