Skip to content

Commit 610c427

Browse files
committed
chore(vfs/windows): test migration from VFS to classic sync on windows
Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
1 parent c0ca583 commit 610c427

File tree

2 files changed

+74
-1
lines changed

2 files changed

+74
-1
lines changed

src/gui/folderman.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class ShareTestHelper;
2727
class EndToEndTestHelper;
2828
class TestSyncConflictsModel;
2929
class TestRemoteWipe;
30+
class TestSyncCfApi;
3031

3132
namespace OCC {
3233

@@ -415,6 +416,7 @@ private slots:
415416
friend class ::EndToEndTestHelper;
416417
friend class ::TestFolderStatusModel;
417418
friend class ::TestRemoteWipe;
419+
friend class ::TestSyncCfApi;
418420
};
419421

420422
} // namespace OCC

test/testsynccfapi.cpp

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,22 @@
77
* any purpose.
88
*/
99

10-
#include <QtTest>
1110
#include "syncenginetestutils.h"
1211
#include "common/vfs.h"
12+
<<<<<<< HEAD
1313
#include "config.h"
1414
#include <syncengine.h>
1515
#include "openfilemanager.h"
16+
=======
17+
#include "syncengine.h"
18+
#include "folderman.h"
19+
#include "accountmanager.h"
20+
#include "configfile.h"
21+
>>>>>>> 3589066678 (chore(vfs/windows): test migration from VFS to classic sync on windows)
1622
#include "vfs/cfapi/cfapiwrapper.h"
23+
#include "testhelper.h"
24+
25+
#include <QtTest>
1726

1827
namespace cfapi {
1928
using namespace OCC::CfApiWrapper;
@@ -1576,6 +1585,68 @@ private slots:
15761585

15771586
QVERIFY(fakeFolder.syncOnce());
15781587
}
1588+
1589+
void switchVfsOffWithOnDemandFolder()
1590+
{
1591+
std::unique_ptr<FolderMan> folderMan;
1592+
1593+
folderMan.reset({});
1594+
folderMan.reset(new FolderMan{});
1595+
1596+
QTemporaryDir dir;
1597+
ConfigFile::setConfDir(dir.path()); // we don't want to pollute the user's config file
1598+
1599+
QScopedPointer<FakeQNAM> fakeQnam(new FakeQNAM({}));
1600+
OCC::AccountPtr account = OCC::Account::create();
1601+
account->setCredentials(new FakeCredentials{fakeQnam.data()});
1602+
account->setUrl(QUrl(("http://example.de")));
1603+
OCC::AccountManager::instance()->addAccount(account);
1604+
1605+
FakeFolder fakeFolder{FileInfo{}};
1606+
setupVfs(fakeFolder);
1607+
1608+
fakeFolder.remoteModifier().mkdir("directory");
1609+
fakeFolder.remoteModifier().mkdir("directory/subdir");
1610+
fakeFolder.remoteModifier().insert("directory/file1");
1611+
fakeFolder.remoteModifier().insert("directory/file2");
1612+
fakeFolder.remoteModifier().insert("directory/file3");
1613+
fakeFolder.remoteModifier().insert("directory/subdir/fileTxt1.txt");
1614+
fakeFolder.remoteModifier().insert("directory/subdir/fileTxt2.txt");
1615+
fakeFolder.remoteModifier().insert("directory/subdir/fileTxt3.txt");
1616+
1617+
QVERIFY(fakeFolder.syncOnce());
1618+
1619+
FolderMan *folderman = FolderMan::instance();
1620+
QCOMPARE(folderman, folderMan.get());
1621+
OCC::AccountState *accountState = OCC::AccountManager::instance()->accounts().first().data();
1622+
const auto folder = folderman->addFolder(accountState, folderDefinition(fakeFolder.localPath()));
1623+
QVERIFY(folder);
1624+
1625+
auto realFolder = FolderMan::instance()->folderForPath(fakeFolder.localPath());
1626+
QVERIFY(realFolder);
1627+
1628+
// perform an initial sync to ensure local and remote have the same state
1629+
QVERIFY(fakeFolder.syncOnce());
1630+
1631+
auto offVfs = QSharedPointer<Vfs>(createVfsFromPlugin(Vfs::Off).release());
1632+
fakeFolder.switchToVfs(offVfs);
1633+
1634+
// Also wipes virtual files, schedules remote discovery
1635+
realFolder->setVirtualFilesEnabled(false);
1636+
realFolder->setVfsOnOffSwitchPending(false);
1637+
1638+
// Wipe pin states and selective sync db
1639+
realFolder->setRootPinState(PinState::AlwaysLocal);
1640+
realFolder->journalDb()->setSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList, {});
1641+
1642+
realFolder->processSwitchedToVirtualFiles();
1643+
1644+
fakeFolder.syncEngine().setLocalDiscoveryOptions(LocalDiscoveryStyle::DatabaseAndFilesystem);
1645+
QVERIFY(fakeFolder.syncOnce());
1646+
1647+
fakeFolder.syncEngine().setLocalDiscoveryOptions(LocalDiscoveryStyle::FilesystemOnly);
1648+
QVERIFY(fakeFolder.syncOnce());
1649+
}
15791650
};
15801651

15811652
QTEST_GUILESS_MAIN(TestSyncCfApi)

0 commit comments

Comments
 (0)