| 319 | } |
| 320 | |
| 321 | void AbstractAspectTest::saveLoad() { |
| 322 | Project project; |
| 323 | |
| 324 | auto* worksheet = new Worksheet(QStringLiteral("Worksheet")); |
| 325 | project.addChild(worksheet); |
| 326 | |
| 327 | auto* plot = new CartesianPlot(QStringLiteral("plot")); |
| 328 | worksheet->addChild(plot); |
| 329 | plot->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created |
| 330 | plot->setNiceExtend(false); |
| 331 | |
| 332 | auto* equationCurve{new XYEquationCurve(QStringLiteral("f(x)"))}; |
| 333 | equationCurve->setCoordinateSystemIndex(plot->defaultCoordinateSystemIndex()); |
| 334 | plot->addChild(equationCurve); |
| 335 | |
| 336 | XYEquationCurve::EquationData data; |
| 337 | data.min = QStringLiteral("0"); |
| 338 | data.max = QStringLiteral("1"); |
| 339 | data.count = 10; |
| 340 | data.expression1 = QStringLiteral("x"); |
| 341 | equationCurve->setEquationData(data); |
| 342 | equationCurve->recalculate(); |
| 343 | |
| 344 | QString savePath; |
| 345 | SAVE_PROJECT("testLinkSpreadsheetSaveLoad"); |
| 346 | |
| 347 | Project project2; |
| 348 | QCOMPARE(project2.load(savePath), true); |
| 349 | |
| 350 | const auto& childrenProject1 = |
| 351 | project.children(AspectType::AbstractAspect, {AbstractAspect::ChildIndexFlag::IncludeHidden, AbstractAspect::ChildIndexFlag::Recursive}); |
| 352 | const auto& childrenProject2 = |
| 353 | project2.children(AspectType::AbstractAspect, {AbstractAspect::ChildIndexFlag::IncludeHidden, AbstractAspect::ChildIndexFlag::Recursive}); |
| 354 | |
| 355 | QCOMPARE(childrenProject1.count(), childrenProject2.count()); |
| 356 | |
| 357 | for (int i = 0; i < childrenProject1.count(); i++) { |
| 358 | QVERIFY(childrenProject1.at(i)->type() == childrenProject2.at(i)->type()); |
| 359 | if (childrenProject1.at(i)->type() == AspectType::AbstractAspect) |
| 360 | continue; // Usually they don't implement the write basic function and therefore they cannot have the same uuid |
| 361 | |
| 362 | QVERIFY(childrenProject1.at(i)->name() == childrenProject2.at(i)->name()); |
| 363 | |
| 364 | if (childrenProject1.at(i)->path().contains(i18n("Project") + QStringLiteral("/Worksheet/plot/f(x)/x")) |
| 365 | || childrenProject1.at(i)->path().contains(i18n("Project") + QStringLiteral("/Worksheet/plot/f(x)/y"))) |
| 366 | continue; // The columns of the quation curve are not saved |
| 367 | QVERIFY(childrenProject1.at(i)->uuid() == childrenProject2.at(i)->uuid()); |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | void AbstractAspectTest::moveUp() { |
| 372 | Project project; |
nothing calls this directly
no test coverage detected