| 1017 | } |
| 1018 | |
| 1019 | void RetransformTest::TestSetScale() { |
| 1020 | RetransformCallCounter c; |
| 1021 | Project project; |
| 1022 | |
| 1023 | auto* sheet = new Spreadsheet(QStringLiteral("Spreadsheet"), false); |
| 1024 | sheet->setColumnCount(2); |
| 1025 | sheet->setRowCount(100); |
| 1026 | |
| 1027 | QVector<int> xData; |
| 1028 | QVector<double> yData; |
| 1029 | for (int i = 0; i < 100; i++) { |
| 1030 | xData.append(i); |
| 1031 | yData.append(i); |
| 1032 | } |
| 1033 | auto* xColumn = sheet->column(0); |
| 1034 | xColumn->setColumnMode(AbstractColumn::ColumnMode::Integer); |
| 1035 | xColumn->replaceInteger(0, xData); |
| 1036 | auto* yColumn = sheet->column(1); |
| 1037 | yColumn->setColumnMode(AbstractColumn::ColumnMode::Double); |
| 1038 | yColumn->replaceValues(0, yData); |
| 1039 | |
| 1040 | project.addChild(sheet); |
| 1041 | |
| 1042 | auto* worksheet = new Worksheet(QStringLiteral("Worksheet")); |
| 1043 | project.addChild(worksheet); |
| 1044 | |
| 1045 | auto* p = new CartesianPlot(QStringLiteral("Plot")); |
| 1046 | p->setType(CartesianPlot::Type::FourAxes); // Otherwise no axis are created |
| 1047 | worksheet->addChild(p); |
| 1048 | |
| 1049 | auto* curve = new XYCurve(QStringLiteral("curve")); |
| 1050 | p->addChild(curve); |
| 1051 | curve->setXColumn(xColumn); |
| 1052 | curve->setYColumn(yColumn); |
| 1053 | |
| 1054 | auto children = project.children(AspectType::AbstractAspect, AbstractAspect::ChildIndexFlag::Recursive); |
| 1055 | |
| 1056 | // Spreadsheet "Spreadsheet" |
| 1057 | // Column "1" |
| 1058 | // Column "2" |
| 1059 | // Worksheet "Worksheet" |
| 1060 | // CartesianPlot "Plot" |
| 1061 | // Axis "x" |
| 1062 | // Axis "x2" |
| 1063 | // Axis "y" |
| 1064 | // Axis "y2" |
| 1065 | // XYCurve "curve" |
| 1066 | QCOMPARE(children.length(), 10); |
| 1067 | for (const auto& child : children) |
| 1068 | connect(child, &AbstractAspect::retransformCalledSignal, &c, &RetransformCallCounter::aspectRetransformed); |
| 1069 | |
| 1070 | auto plots = project.children(AspectType::CartesianPlot, AbstractAspect::ChildIndexFlag::Recursive); |
| 1071 | QCOMPARE(plots.length(), 1); |
| 1072 | auto* plot = static_cast<CartesianPlot*>(plots[0]); |
| 1073 | connect(static_cast<CartesianPlot*>(plot), &CartesianPlot::scaleRetransformed, &c, &RetransformCallCounter::retransformScaleCalled); |
| 1074 | |
| 1075 | c.resetRetransformCount(); |
| 1076 |
nothing calls this directly
no test coverage detected