| 60 | */ |
| 61 | |
| 62 | void ProjectImportTest::testOrigin01() { |
| 63 | // import the opj file into LabPlot's project object |
| 64 | OriginProjectParser parser; |
| 65 | parser.setProjectFileName(QFINDTESTDATA(QLatin1String("data/origin8_test_tree_import.opj"))); |
| 66 | Project project; |
| 67 | parser.importTo(&project, QStringList()); |
| 68 | |
| 69 | // check the project tree for the imported project |
| 70 | |
| 71 | // first child of the root folder, spreadsheet "Book3" |
| 72 | auto* aspect = project.child<AbstractAspect>(0); |
| 73 | QCOMPARE(aspect != nullptr, true); |
| 74 | if (aspect != nullptr) |
| 75 | QCOMPARE(aspect->name(), QLatin1String("Book3")); |
| 76 | QCOMPARE(dynamic_cast<Spreadsheet*>(aspect) != nullptr, true); |
| 77 | |
| 78 | // first child of the root folder, folder "Folder" -> import into a Folder |
| 79 | aspect = project.child<AbstractAspect>(1); |
| 80 | QCOMPARE(aspect != nullptr, true); |
| 81 | if (aspect != nullptr) |
| 82 | QCOMPARE(aspect->name(), QLatin1String("Folder")); |
| 83 | QCOMPARE(dynamic_cast<Folder*>(aspect) != nullptr, true); |
| 84 | |
| 85 | // first child of "Folder", workbook "Book2" with two sheets -> import into a Workbook with two Spreadsheets |
| 86 | aspect = project.child<AbstractAspect>(1)->child<AbstractAspect>(0); |
| 87 | QCOMPARE(aspect != nullptr, true); |
| 88 | if (aspect != nullptr) |
| 89 | QCOMPARE(aspect->name(), QLatin1String("Book2")); |
| 90 | QCOMPARE(dynamic_cast<Workbook*>(aspect) != nullptr, true); |
| 91 | |
| 92 | aspect = project.child<AbstractAspect>(1)->child<AbstractAspect>(0)->child<AbstractAspect>(0); |
| 93 | QCOMPARE(aspect != nullptr, true); |
| 94 | if (aspect != nullptr) |
| 95 | QCOMPARE(aspect->name(), QLatin1String("Sheet1")); |
| 96 | QCOMPARE(dynamic_cast<Spreadsheet*>(aspect) != nullptr, true); |
| 97 | |
| 98 | aspect = project.child<AbstractAspect>(1)->child<AbstractAspect>(0)->child<AbstractAspect>(1); |
| 99 | QCOMPARE(aspect != nullptr, true); |
| 100 | if (aspect != nullptr) |
| 101 | QCOMPARE(aspect->name(), QLatin1String("Sheet2")); |
| 102 | QCOMPARE(dynamic_cast<Spreadsheet*>(aspect) != nullptr, true); |
| 103 | |
| 104 | // second child of "Folder", matrixbook "MBook" with two matrix sheets -> import into a Workbook with two Matrices |
| 105 | aspect = project.child<AbstractAspect>(1)->child<AbstractAspect>(1); |
| 106 | QCOMPARE(aspect != nullptr, true); |
| 107 | if (aspect != nullptr) |
| 108 | QCOMPARE(aspect->name(), QLatin1String("MBook2")); |
| 109 | QCOMPARE(dynamic_cast<Workbook*>(aspect) != nullptr, true); |
| 110 | |
| 111 | aspect = project.child<AbstractAspect>(1)->child<AbstractAspect>(1)->child<AbstractAspect>(0); |
| 112 | QCOMPARE(aspect != nullptr, true); |
| 113 | if (aspect != nullptr) |
| 114 | QCOMPARE(aspect->name(), QLatin1String("MSheet1")); |
| 115 | QCOMPARE(dynamic_cast<Matrix*>(aspect) != nullptr, true); |
| 116 | |
| 117 | aspect = project.child<AbstractAspect>(1)->child<AbstractAspect>(1)->child<AbstractAspect>(1); |
| 118 | QCOMPARE(aspect != nullptr, true); |
| 119 | if (aspect != nullptr) |
nothing calls this directly
no test coverage detected