MCPcopy Create free account
hub / github.com/KDE/labplot / testOrigin03

Method testOrigin03

tests/import_export/Project/ProjectImportTest.cpp:203–258  ·  view source on GitHub ↗

* 1. import one single folder child * 2. import another folder child * 3. check that both children are available after the second import */

Source from the content-addressed store, hash-verified

201 * 3. check that both children are available after the second import
202 */
203void ProjectImportTest::testOrigin03() {
204 // import one single object
205 OriginProjectParser parser;
206 parser.setProjectFileName(QFINDTESTDATA(QLatin1String("data/origin8_test_tree_import.opj")));
207 Project project;
208
209 // import one single child in "Folder1"
210 QStringList selectedPathes = {QLatin1String("test_tree_import/Folder1/Book1"),
211 QLatin1String("test_tree_import/Folder1"),
212 QLatin1String("test_tree_import")};
213 parser.importTo(&project, selectedPathes);
214
215 // first child of the root folder, folder "Folder1" -> import into a Folder
216 auto* aspect = project.child<AbstractAspect>(0);
217 QCOMPARE(aspect != nullptr, true);
218 if (aspect != nullptr)
219 QCOMPARE(aspect->name(), QLatin1String("Folder1"));
220 QCOMPARE(dynamic_cast<Folder*>(aspect) != nullptr, true);
221 if (aspect != nullptr)
222 QCOMPARE(aspect->childCount<AbstractAspect>(), 1);
223
224 // first child of "Folder", workbook "Book1" with one sheet -> import into a Spreadsheet
225 aspect = project.child<AbstractAspect>(0)->child<AbstractAspect>(0);
226 QCOMPARE(aspect != nullptr, true);
227 if (aspect != nullptr)
228 QCOMPARE(aspect->name(), QLatin1String("Book1"));
229 QCOMPARE(dynamic_cast<Spreadsheet*>(aspect) != nullptr, true);
230
231 // import another child in "Folder1"
232 selectedPathes.clear();
233 selectedPathes << QLatin1String("test_tree_import/Folder1/Book4") << QLatin1String("test_tree_import/Folder1") << QLatin1String("test_tree_import");
234 parser.importTo(&project, selectedPathes);
235
236 // the first child should still be available in the project -> check it
237 aspect = project.child<AbstractAspect>(0);
238 QCOMPARE(aspect != nullptr, true);
239 if (aspect != nullptr)
240 QCOMPARE(aspect->name(), QLatin1String("Folder1"));
241 QCOMPARE(dynamic_cast<Folder*>(aspect) != nullptr, true);
242
243 aspect = project.child<AbstractAspect>(0)->child<AbstractAspect>(0);
244 QCOMPARE(aspect != nullptr, true);
245 if (aspect != nullptr)
246 QCOMPARE(aspect->name(), QLatin1String("Book1"));
247 QCOMPARE(dynamic_cast<Spreadsheet*>(aspect) != nullptr, true);
248
249 // check the second child, workbook "Book4" with one sheet -> import into a Spreadsheet
250 aspect = project.child<AbstractAspect>(0)->child<AbstractAspect>(1);
251 QCOMPARE(aspect != nullptr, true);
252 if (aspect != nullptr)
253 QCOMPARE(aspect->name(), QLatin1String("Book4"));
254 QCOMPARE(dynamic_cast<Spreadsheet*>(aspect) != nullptr, true);
255
256 if (aspect != nullptr)
257 QCOMPARE(aspect->childCount<AbstractAspect>(), 2);
258}
259
260/*

Callers

nothing calls this directly

Calls 4

setProjectFileNameMethod · 0.45
importToMethod · 0.45
nameMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected