| 1057 | } |
| 1058 | |
| 1059 | void ProjectImportTest::testImportOriginStrings() { |
| 1060 | OriginProjectParser parser; |
| 1061 | parser.setProjectFileName(QFINDTESTDATA(QLatin1String("data/strings_testing.opj"))); |
| 1062 | // parser.setGraphLayerAsPlotArea(false); // read every layer as a new coordinate system |
| 1063 | Project project; |
| 1064 | parser.importTo(&project, QStringList()); |
| 1065 | |
| 1066 | const auto& plots = project.children<CartesianPlot>(AbstractAspect::ChildIndexFlag::Recursive); |
| 1067 | QCOMPARE(plots.count(), 1); |
| 1068 | |
| 1069 | const auto* plot = plots.first(); |
| 1070 | QVERIFY(plot != nullptr); |
| 1071 | |
| 1072 | const auto& curves = plot->children<XYCurve>(); |
| 1073 | QCOMPARE(curves.count(), 3); // formula ignored |
| 1074 | // const auto* curve = curves.at(0); |
| 1075 | const auto& axes = plot->children<Axis>(); |
| 1076 | QCOMPARE(axes.count(), 4); |
| 1077 | const auto* xAxis = axes.at(0); |
| 1078 | const auto* x2Axis = axes.at(1); |
| 1079 | const auto* yAxis = axes.at(2); |
| 1080 | const auto* y2Axis = axes.at(3); |
| 1081 | |
| 1082 | // axis label |
| 1083 | QCOMPARE(xAxis->name(), QStringLiteral("x")); |
| 1084 | QCOMPARE(yAxis->name(), QStringLiteral("y")); |
| 1085 | QCOMPARE(x2Axis->name(), QStringLiteral("x top")); |
| 1086 | QCOMPARE(y2Axis->name(), QStringLiteral("y right")); |
| 1087 | QTextEdit xte(xAxis->title()->text().text); |
| 1088 | QCOMPARE(xte.toPlainText(), QStringLiteral("A")); |
| 1089 | QTextEdit yte(yAxis->title()->text().text); |
| 1090 | QCOMPARE(yte.toPlainText(), QStringLiteral("Log of x")); |
| 1091 | QTextEdit x2te(x2Axis->title()->text().text); |
| 1092 | QCOMPARE(x2te.toPlainText(), QStringLiteral("x axis title")); |
| 1093 | QTextEdit y2te(y2Axis->title()->text().text); |
| 1094 | QCOMPARE(y2te.toPlainText(), QStringLiteral("B")); |
| 1095 | |
| 1096 | // axis prefix, suffix |
| 1097 | QCOMPARE(xAxis->labelsPrefix(), QStringLiteral("pb")); |
| 1098 | QCOMPARE(xAxis->labelsSuffix(), QStringLiteral("sb")); |
| 1099 | QCOMPARE(yAxis->labelsPrefix(), QStringLiteral("pl")); |
| 1100 | QCOMPARE(yAxis->labelsSuffix(), QStringLiteral("sl")); |
| 1101 | QCOMPARE(x2Axis->labelsPrefix(), QStringLiteral("pt")); |
| 1102 | QCOMPARE(x2Axis->labelsSuffix(), QStringLiteral("st")); |
| 1103 | QCOMPARE(y2Axis->labelsPrefix(), QStringLiteral("pr")); |
| 1104 | QCOMPARE(y2Axis->labelsSuffix(), QStringLiteral("sr")); |
| 1105 | // TODO: axis formula is not imported yet |
| 1106 | QCOMPARE(xAxis->scalingFactor(), 1.); |
| 1107 | QCOMPARE(yAxis->scalingFactor(), 1.); |
| 1108 | QCOMPARE(x2Axis->scalingFactor(), 1.); |
| 1109 | QCOMPARE(y2Axis->scalingFactor(), 1.); |
| 1110 | |
| 1111 | // TODO: formula |
| 1112 | // const auto& eqCurves = plot->children<XYEquationCurve>(); |
| 1113 | // QCOMPARE(curves.count(), 1); |
| 1114 | // const auto* curve = curves.at(0); |
| 1115 | // DEBUG("EQUATION FORMULA: " << curve->equationData().expression1.toStdString()) |
| 1116 | } |