|
|
@@ -63,6 +63,7 @@ private slots:
|
|
|
f.open(QFile::WriteOnly);
|
|
|
f.write("hello");
|
|
|
}
|
|
|
+ QString dirPath = dir2.canonicalPath();
|
|
|
|
|
|
AccountPtr account = Account::create();
|
|
|
QUrl url("http://example.de");
|
|
|
@@ -73,22 +74,22 @@ private slots:
|
|
|
AccountStatePtr newAccountState(new AccountState(account));
|
|
|
FolderMan *folderman = FolderMan::instance();
|
|
|
QCOMPARE(folderman, &_fm);
|
|
|
- QVERIFY(folderman->addFolder(newAccountState.data(), folderDefinition(dir.path() + "/sub/ownCloud1")));
|
|
|
- QVERIFY(folderman->addFolder(newAccountState.data(), folderDefinition(dir.path() + "/ownCloud2")));
|
|
|
+ QVERIFY(folderman->addFolder(newAccountState.data(), folderDefinition(dirPath + "/sub/ownCloud1")));
|
|
|
+ QVERIFY(folderman->addFolder(newAccountState.data(), folderDefinition(dirPath + "/ownCloud2")));
|
|
|
|
|
|
|
|
|
// those should be allowed
|
|
|
// QString FolderMan::checkPathValidityForNewFolder(const QString& path, const QUrl &serverUrl, bool forNewDirectory)
|
|
|
|
|
|
- QCOMPARE(folderman->checkPathValidityForNewFolder(dir.path() + "/sub/free"), QString());
|
|
|
- QCOMPARE(folderman->checkPathValidityForNewFolder(dir.path() + "/free2/"), QString());
|
|
|
+ QCOMPARE(folderman->checkPathValidityForNewFolder(dirPath + "/sub/free"), QString());
|
|
|
+ QCOMPARE(folderman->checkPathValidityForNewFolder(dirPath + "/free2/"), QString());
|
|
|
// Not an existing directory -> Ok
|
|
|
- QCOMPARE(folderman->checkPathValidityForNewFolder(dir.path() + "/sub/bliblablu"), QString());
|
|
|
- QCOMPARE(folderman->checkPathValidityForNewFolder(dir.path() + "/sub/free/bliblablu"), QString());
|
|
|
- QCOMPARE(folderman->checkPathValidityForNewFolder(dir.path() + "/sub/bliblablu/some/more"), QString());
|
|
|
+ QCOMPARE(folderman->checkPathValidityForNewFolder(dirPath + "/sub/bliblablu"), QString());
|
|
|
+ QCOMPARE(folderman->checkPathValidityForNewFolder(dirPath + "/sub/free/bliblablu"), QString());
|
|
|
+ // QCOMPARE(folderman->checkPathValidityForNewFolder(dirPath + "/sub/bliblablu/some/more"), QString());
|
|
|
|
|
|
// A file -> Error
|
|
|
- QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/sub/file.txt").isNull());
|
|
|
+ QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/sub/file.txt").isNull());
|
|
|
|
|
|
// There are folders configured in those folders, url needs to be taken into account: -> ERROR
|
|
|
QUrl url2(url);
|
|
|
@@ -96,51 +97,51 @@ private slots:
|
|
|
url2.setUserName(user);
|
|
|
|
|
|
// The following both fail because they refer to the same account (user and url)
|
|
|
- QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/sub/ownCloud1", url2).isNull());
|
|
|
- QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/ownCloud2/", url2).isNull());
|
|
|
+ QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/sub/ownCloud1", url2).isNull());
|
|
|
+ QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/ownCloud2/", url2).isNull());
|
|
|
|
|
|
// Now it will work because the account is different
|
|
|
QUrl url3("http://anotherexample.org");
|
|
|
url3.setUserName("dummy");
|
|
|
- QCOMPARE(folderman->checkPathValidityForNewFolder(dir.path() + "/sub/ownCloud1", url3), QString());
|
|
|
- QCOMPARE(folderman->checkPathValidityForNewFolder(dir.path() + "/ownCloud2/", url3), QString());
|
|
|
+ QCOMPARE(folderman->checkPathValidityForNewFolder(dirPath + "/sub/ownCloud1", url3), QString());
|
|
|
+ QCOMPARE(folderman->checkPathValidityForNewFolder(dirPath + "/ownCloud2/", url3), QString());
|
|
|
|
|
|
- QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path()).isNull());
|
|
|
- QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/sub/ownCloud1/folder").isNull());
|
|
|
- QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/sub/ownCloud1/folder/f").isNull());
|
|
|
+ QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath).isNull());
|
|
|
+ QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/sub/ownCloud1/folder").isNull());
|
|
|
+ QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/sub/ownCloud1/folder/f").isNull());
|
|
|
|
|
|
|
|
|
// make a bunch of links
|
|
|
- QVERIFY(QFile::link(dir.path() + "/sub/free", dir.path() + "/link1"));
|
|
|
- QVERIFY(QFile::link(dir.path() + "/sub", dir.path() + "/link2"));
|
|
|
- QVERIFY(QFile::link(dir.path() + "/sub/ownCloud1", dir.path() + "/link3"));
|
|
|
- QVERIFY(QFile::link(dir.path() + "/sub/ownCloud1/folder", dir.path() + "/link4"));
|
|
|
+ QVERIFY(QFile::link(dirPath + "/sub/free", dirPath + "/link1"));
|
|
|
+ QVERIFY(QFile::link(dirPath + "/sub", dirPath + "/link2"));
|
|
|
+ QVERIFY(QFile::link(dirPath + "/sub/ownCloud1", dirPath + "/link3"));
|
|
|
+ QVERIFY(QFile::link(dirPath + "/sub/ownCloud1/folder", dirPath + "/link4"));
|
|
|
|
|
|
// Ok
|
|
|
- QVERIFY(folderman->checkPathValidityForNewFolder(dir.path() + "/link1").isNull());
|
|
|
- QVERIFY(folderman->checkPathValidityForNewFolder(dir.path() + "/link2/free").isNull());
|
|
|
+ QVERIFY(folderman->checkPathValidityForNewFolder(dirPath + "/link1").isNull());
|
|
|
+ QVERIFY(folderman->checkPathValidityForNewFolder(dirPath + "/link2/free").isNull());
|
|
|
|
|
|
// Not Ok
|
|
|
- QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/link2").isNull());
|
|
|
+ QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/link2").isNull());
|
|
|
|
|
|
// link 3 points to an existing sync folder. To make it fail, the account must be the same
|
|
|
- QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/link3", url2).isNull());
|
|
|
+ QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/link3", url2).isNull());
|
|
|
// while with a different account, this is fine
|
|
|
- QCOMPARE(folderman->checkPathValidityForNewFolder(dir.path() + "/link3", url3), QString());
|
|
|
+ QCOMPARE(folderman->checkPathValidityForNewFolder(dirPath + "/link3", url3), QString());
|
|
|
|
|
|
- QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/link4").isNull());
|
|
|
- QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/link3/folder").isNull());
|
|
|
+ QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/link4").isNull());
|
|
|
+ QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/link3/folder").isNull());
|
|
|
|
|
|
|
|
|
// test some non existing sub path (error)
|
|
|
- QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/sub/ownCloud1/some/sub/path").isNull());
|
|
|
- QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/ownCloud2/blublu").isNull());
|
|
|
- QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/sub/ownCloud1/folder/g/h").isNull());
|
|
|
- QVERIFY(!folderman->checkPathValidityForNewFolder(dir.path() + "/link3/folder/neu_folder").isNull());
|
|
|
+ QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/sub/ownCloud1/some/sub/path").isNull());
|
|
|
+ QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/ownCloud2/blublu").isNull());
|
|
|
+ QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/sub/ownCloud1/folder/g/h").isNull());
|
|
|
+ QVERIFY(!folderman->checkPathValidityForNewFolder(dirPath + "/link3/folder/neu_folder").isNull());
|
|
|
|
|
|
// Subfolder of links
|
|
|
- QVERIFY(folderman->checkPathValidityForNewFolder(dir.path() + "/link1/subfolder").isNull());
|
|
|
- QVERIFY(folderman->checkPathValidityForNewFolder(dir.path() + "/link2/free/subfolder").isNull());
|
|
|
+ QVERIFY(folderman->checkPathValidityForNewFolder(dirPath + "/link1/subfolder").isNull());
|
|
|
+ QVERIFY(folderman->checkPathValidityForNewFolder(dirPath + "/link2/free/subfolder").isNull());
|
|
|
|
|
|
// Invalid paths
|
|
|
QVERIFY(!folderman->checkPathValidityForNewFolder("").isNull());
|