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

Method TestSetScale

tests/backend/Retransform/RetransformTest.cpp:1019–1096  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1017}
1018
1019void 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

Callers

nothing calls this directly

Calls 15

appendMethod · 0.80
setYColumnMethod · 0.80
lengthMethod · 0.80
resetRetransformCountMethod · 0.80
elementLogCountMethod · 0.80
callCountMethod · 0.80
setColumnCountMethod · 0.45
setRowCountMethod · 0.45
columnMethod · 0.45
setColumnModeMethod · 0.45
replaceIntegerMethod · 0.45
replaceValuesMethod · 0.45

Tested by

no test coverage detected