diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2020-02-25 13:45:27 +0300 |
---|---|---|
committer | Olivier Goffart <ogoffart@woboq.com> | 2020-02-25 13:45:27 +0300 |
commit | dc1070d02d63f98a59425d02340ae8da6c9a9928 (patch) | |
tree | 7a8625591f3e71d0e62ea77ccc47061013a1abe6 /test | |
parent | a86b9677ca24ba67d7eed250c195b2dad3f8c9f9 (diff) | |
parent | aab8ee3e779adb60eebe4772995dbe7431f7f80e (diff) |
Merge remote-tracking branch 'origin/2.6'
Conflicts:
CHANGELOG.md
VERSION.cmake
src/gui/MacOSXBundleInfo.plist
src/gui/folderstatusmodel.h
src/gui/settingsdialog.cpp
Diffstat (limited to 'test')
-rw-r--r-- | test/CMakeLists.txt | 1 | ||||
-rw-r--r-- | test/testcookies.cpp | 43 | ||||
-rw-r--r-- | test/testsyncmove.cpp | 54 |
3 files changed, 88 insertions, 10 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7c1dcda17..463cdbfce 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -33,6 +33,7 @@ owncloud_add_test(OwnSql "") owncloud_add_test(SyncJournalDB "") owncloud_add_test(SyncFileItem "") owncloud_add_test(ConcatUrl "") +owncloud_add_test(Cookies "") owncloud_add_test(XmlParse "") owncloud_add_test(ChecksumValidator "") diff --git a/test/testcookies.cpp b/test/testcookies.cpp new file mode 100644 index 000000000..a5053abd9 --- /dev/null +++ b/test/testcookies.cpp @@ -0,0 +1,43 @@ +/* + This software is in the public domain, furnished "as is", without technical + support, and with no warranty, express or implied, as to its usefulness for + any purpose. +*/ + +#include <QtTest> + +#include "libsync/cookiejar.h" + +using namespace OCC; + +class TestCookies : public QObject +{ + Q_OBJECT + +private slots: + void testCookies() + { + QTemporaryDir tmp; + const QString nonexistingPath = tmp.filePath("someNonexistingDir/test.db"); + QNetworkCookie cookieA = QNetworkCookie("foo", "bar"); + // tomorrow rounded + cookieA.setExpirationDate(QDateTime(QDateTime::currentDateTimeUtc().addDays(1).date())); + const QList<QNetworkCookie> cookies = {cookieA, QNetworkCookie("foo2", "bar")}; + CookieJar jar; + jar.setAllCookies(cookies); + QCOMPARE(cookies, jar.allCookies()); + QVERIFY(jar.save(tmp.filePath("test.db"))); + // ensure we are able to create a cookie jar in a non exisitning folder (mkdir) + QVERIFY(jar.save(nonexistingPath)); + + CookieJar jar2; + QVERIFY(jar2.restore(nonexistingPath)); + // here we should have only cookieA as the second one was a session cookie + QCOMPARE(QList<QNetworkCookie>{cookieA}, jar2.allCookies()); + + } + +}; + +QTEST_APPLESS_MAIN(TestCookies) +#include "testcookies.moc" diff --git a/test/testsyncmove.cpp b/test/testsyncmove.cpp index 4122b91e0..9a503be29 100644 --- a/test/testsyncmove.cpp +++ b/test/testsyncmove.cpp @@ -287,40 +287,46 @@ private slots: QVERIFY(fakeFolder.syncOnce()); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); - int nGET = 0; - fakeFolder.setServerOverride([&](QNetworkAccessManager::Operation op, const QNetworkRequest &, QIODevice *) { - if (op == QNetworkAccessManager::GetOperation) - ++nGET; - return nullptr; - }); + OperationCounter counter; + fakeFolder.setServerOverride(counter.functor()); // Try a remote file move remote.rename("A/a1", "A/W/a1m"); remote.rename(prefix + "/A/a1", prefix + "/A/W/a1m"); QVERIFY(fakeFolder.syncOnce()); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); - QCOMPARE(nGET, 0); + QCOMPARE(counter.nGET, 0); // And a remote directory move remote.rename("A/W", "A/Q/W"); remote.rename(prefix + "/A/W", prefix + "/A/Q/W"); QVERIFY(fakeFolder.syncOnce()); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); - QCOMPARE(nGET, 0); + QCOMPARE(counter.nGET, 0); // Partial file removal (in practice, A/a2 may be moved to O/a2, but we don't care) remote.rename(prefix + "/A/a2", prefix + "/a2"); remote.remove("A/a2"); QVERIFY(fakeFolder.syncOnce()); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); - QCOMPARE(nGET, 0); + QCOMPARE(counter.nGET, 0); // Local change plus remote move at the same time fakeFolder.localModifier().appendByte(prefix + "/a2"); remote.rename(prefix + "/a2", prefix + "/a3"); QVERIFY(fakeFolder.syncOnce()); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); - QCOMPARE(nGET, 1); + QCOMPARE(counter.nGET, 1); + counter.reset(); + + // remove localy, and remote move at the same time + fakeFolder.localModifier().remove("A/Q/W/a1m"); + remote.rename("A/Q/W/a1m", "A/Q/W/a1p"); + remote.rename(prefix + "/A/Q/W/a1m", prefix + "/A/Q/W/a1p"); + QVERIFY(fakeFolder.syncOnce()); + QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); + QCOMPARE(counter.nGET, 1); + counter.reset(); } void testMovePropagation() @@ -807,6 +813,34 @@ private slots: QCOMPARE(counter.nMOVE, 2); } + void moveFileToDifferentFolderOnBothSides() + { + FakeFolder fakeFolder { FileInfo::A12_B12_C12_S12() }; + OperationCounter counter; + fakeFolder.setServerOverride(counter.functor()); + + // Test that moving a file within to different folder on both side does the right thing. + + fakeFolder.remoteModifier().rename("B/b1", "A/b1"); + fakeFolder.localModifier().rename("B/b1", "C/b1"); + + fakeFolder.localModifier().rename("B/b2", "A/b2"); + fakeFolder.remoteModifier().rename("B/b2", "C/b2"); + + QVERIFY(fakeFolder.syncOnce()); + QCOMPARE(fakeFolder.currentRemoteState(), fakeFolder.currentRemoteState()); + QVERIFY(fakeFolder.currentRemoteState().find("A/b1")); + QVERIFY(fakeFolder.currentRemoteState().find("C/b1")); + QVERIFY(fakeFolder.currentRemoteState().find("A/b2")); + QVERIFY(fakeFolder.currentRemoteState().find("C/b2")); + QCOMPARE(counter.nMOVE, 0); // Unfortunately, we can't really make a move in this case + QCOMPARE(counter.nGET, 2); + QCOMPARE(counter.nPUT, 2); + QCOMPARE(counter.nDELETE, 0); + counter.reset(); + + } + // Test that deletes don't run before renames void testRenameParallelism() { |