MCPcopy Create free account
hub / github.com/FreesmTeam/FreesmLauncher / test_removeResource

Function test_removeResource

tests/ResourceFolderModel_test.cpp:151–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

149 }
150
151 void test_removeResource()
152 {
153 QString folder_resource = QFINDTESTDATA("testdata/ResourceFolderModel/test_folder");
154 QString file_mod = QFINDTESTDATA("testdata/ResourceFolderModel/supercoolmod.jar");
155
156 QTemporaryDir tmp;
157 ResourceFolderModel model(QDir(tmp.path()), nullptr);
158
159 QCOMPARE(model.size(), 0);
160
161 { EXEC_UPDATE_TASK(model.installResource(file_mod), QVERIFY) }
162
163 QCOMPARE(model.size(), 1);
164 qDebug() << "Added first mod.";
165
166 { EXEC_UPDATE_TASK(model.startWatching(), ) }
167
168 QCOMPARE(model.size(), 1);
169 qDebug() << "Started watching the temp folder.";
170
171 { EXEC_UPDATE_TASK(model.installResource(folder_resource), QVERIFY) }
172
173 QCOMPARE(model.size(), 2);
174 qDebug() << "Added second mod.";
175
176 {
177 EXEC_UPDATE_TASK(model.uninstallResource("supercoolmod.jar"), QVERIFY);
178 }
179
180 QCOMPARE(model.size(), 1);
181 qDebug() << "Removed first mod.";
182
183 QString mod_file_name{ model.at(0).fileinfo().fileName() };
184 QVERIFY(!mod_file_name.isEmpty());
185
186 {
187 EXEC_UPDATE_TASK(model.uninstallResource(mod_file_name), QVERIFY);
188 }
189
190 QCOMPARE(model.size(), 0);
191 qDebug() << "Removed second mod.";
192
193 model.stopWatching();
194 }
195
196 void test_enable_disable()
197 {
198 QString folder_resource = QFINDTESTDATA("testdata/ResourceFolderModel/test_folder");
199 QString file_mod = QFINDTESTDATA("testdata/ResourceFolderModel/supercoolmod.jar");
200
201 QTemporaryDir tmp;
202 ResourceFolderModel model(tmp.path(), nullptr);
203
204 QCOMPARE(model.size(), 0);
205
206 {
207 EXEC_UPDATE_TASK(model.installResource(folder_resource), QVERIFY)
208 }

Callers

nothing calls this directly

Calls 10

installResourceMethod · 0.80
uninstallResourceMethod · 0.80
fileinfoMethod · 0.80
QDirClass · 0.50
pathMethod · 0.45
sizeMethod · 0.45
startWatchingMethod · 0.45
atMethod · 0.45
isEmptyMethod · 0.45
stopWatchingMethod · 0.45

Tested by

no test coverage detected