Changeset View
Changeset View
Standalone View
Standalone View
tests/auto/importertest.cpp
Show First 20 Lines • Show All 104 Lines • ▼ Show 20 Line(s) | 83 | { | |||
---|---|---|---|---|---|
105 | 105 | | |||
106 | for (const QUrl & src : qAsConst(list)) { | 106 | for (const QUrl & src : qAsConst(list)) { | ||
107 | QUrl dst = destUrl; | 107 | QUrl dst = destUrl; | ||
108 | dst.setPath(dst.path() + '/' + src.fileName()); | 108 | dst.setPath(dst.path() + '/' + src.fileName()); | ||
109 | QVERIFY(FileUtils::contentsAreIdentical(src, dst)); | 109 | QVERIFY(FileUtils::contentsAreIdentical(src, dst)); | ||
110 | } | 110 | } | ||
111 | } | 111 | } | ||
112 | 112 | | |||
113 | void ImporterTest::testSuccessfulImportRemote() | ||||
114 | { | ||||
115 | // First test import from local to remote | ||||
116 | QUrl remoteUrl = setUpRemoteTestDir(); | ||||
117 | if (!remoteUrl.isValid()) { | ||||
118 | QSKIP("Not running this test: failed to setup remote test dir."); | ||||
119 | } | ||||
120 | | ||||
121 | Importer importer(nullptr); | ||||
122 | QSignalSpy maximumChangedSpy(&importer, SIGNAL(maximumChanged(int))); | ||||
123 | QSignalSpy errorSpy(&importer, SIGNAL(error(QString))); | ||||
124 | | ||||
125 | QList<QUrl> list = mDocumentList; | ||||
126 | | ||||
127 | QEventLoop loop; | ||||
128 | connect(&importer, &Importer::importFinished, &loop, &QEventLoop::quit); | ||||
129 | importer.start(list, remoteUrl); | ||||
130 | loop.exec(); | ||||
131 | | ||||
132 | QCOMPARE(maximumChangedSpy.count(), 1); | ||||
133 | QCOMPARE(maximumChangedSpy.takeFirst().at(0).toInt(), list.count() * 100); | ||||
134 | QCOMPARE(errorSpy.count(), 0); | ||||
135 | | ||||
136 | QCOMPARE(importer.importedUrlList().count(), list.count()); | ||||
137 | QCOMPARE(importer.importedUrlList(), list); | ||||
138 | QCOMPARE(importer.skippedUrlList().count(), 0); | ||||
139 | QCOMPARE(importer.renamedCount(), 0); | ||||
140 | | ||||
141 | for (const QUrl & src : qAsConst(list)) { | ||||
142 | QUrl dst = remoteUrl; | ||||
143 | dst.setPath(dst.path() + '/' + src.fileName()); | ||||
144 | QVERIFY(FileUtils::contentsAreIdentical(src, dst)); | ||||
145 | } | ||||
146 | | ||||
147 | // Secondly test import from remote back to local | ||||
148 | QUrl localUrl = QUrl::fromLocalFile(mTempDir->path() + "/foo"); | ||||
149 | | ||||
150 | importer.start(list, localUrl); | ||||
151 | loop.exec(); | ||||
152 | | ||||
153 | QCOMPARE(maximumChangedSpy.count(), 1); | ||||
154 | QCOMPARE(maximumChangedSpy.takeFirst().at(0).toInt(), list.count() * 100); | ||||
155 | QCOMPARE(errorSpy.count(), 0); | ||||
156 | | ||||
157 | QCOMPARE(importer.importedUrlList().count(), list.count()); | ||||
158 | QCOMPARE(importer.importedUrlList(), list); | ||||
159 | QCOMPARE(importer.skippedUrlList().count(), 0); | ||||
160 | QCOMPARE(importer.renamedCount(), 0); | ||||
161 | | ||||
162 | for (const QUrl & src : qAsConst(list)) { | ||||
163 | QUrl dst = localUrl; | ||||
164 | dst.setPath(dst.path() + '/' + src.fileName()); | ||||
165 | QVERIFY(FileUtils::contentsAreIdentical(src, dst)); | ||||
166 | } | ||||
167 | } | ||||
168 | | ||||
113 | void ImporterTest::testSkippedUrlList() | 169 | void ImporterTest::testSkippedUrlList() | ||
114 | { | 170 | { | ||
115 | QUrl destUrl = QUrl::fromLocalFile(mTempDir->path() + "/foo"); | 171 | QUrl destUrl = QUrl::fromLocalFile(mTempDir->path() + "/foo"); | ||
116 | 172 | | |||
117 | Importer importer(nullptr); | 173 | Importer importer(nullptr); | ||
118 | 174 | | |||
119 | QList<QUrl> list = mDocumentList.mid(0, 1); | 175 | QList<QUrl> list = mDocumentList.mid(0, 1); | ||
120 | 176 | | |||
▲ Show 20 Lines • Show All 149 Lines • Show Last 20 Lines |