MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / test_removeResource

Function test_removeResource

tests/ResourceFolderModel_test.cpp:154–256  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 10

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

Tested by

no test coverage detected