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

Method TestLoadProject2

tests/backend/Retransform/RetransformTest.cpp:81–132  ·  view source on GitHub ↗

Problem in this project was that the second axis labels are not loaded. Zooming in/out once shows the correct range

Source from the content-addressed store, hash-verified

79
80// Problem in this project was that the second axis labels are not loaded. Zooming in/out once shows the correct range
81void RetransformTest::TestLoadProject2() {
82 QLocale::setDefault(QLocale::C); // . as decimal separator
83 RetransformCallCounter c;
84 Project project;
85
86 project.load(QFINDTESTDATA(QLatin1String("data/bars_dis_004.lml")));
87
88 QHash<QString, int> h = {{QStringLiteral("Project/Worksheet - Spreadsheet/Plot - Spreadsheet"), 1},
89 {QStringLiteral("Project/Worksheet - Spreadsheet/Plot - Spreadsheet/x"), 1},
90 {QStringLiteral("Project/Worksheet - Spreadsheet/Plot - Spreadsheet/y"), 1},
91 {QStringLiteral("Project/Worksheet - Spreadsheet/Plot - Spreadsheet/x2"), 1},
92 {QStringLiteral("Project/Worksheet - Spreadsheet/Plot - Spreadsheet/y2"), 1},
93 {QStringLiteral("Project/Worksheet - Spreadsheet/Plot - Spreadsheet/Frequency"), 1},
94 {QStringLiteral("Project/Worksheet - Spreadsheet/Plot - Spreadsheet/Cumulative"), 1},
95 {QStringLiteral("Project/Worksheet - Spreadsheet/Plot - Spreadsheet/legend"), 1}};
96
97 auto children = project.children(AspectType::AbstractAspect, AbstractAspect::ChildIndexFlag::Recursive);
98 for (auto& child : children) {
99 int expectedCallCount = 0;
100 const QString& path = child->path();
101 if (h.contains(path))
102 expectedCallCount = h.value(path);
103 COMPARE(c.callCount(child), expectedCallCount, path);
104 }
105
106 // check axis ranges
107 auto axes = project.children(AspectType::Axis, AbstractAspect::ChildIndexFlag::Recursive);
108 QCOMPARE(axes.length(), 4);
109 auto* xAxis = axes.at(0);
110 auto* xAxis2 = axes.at(1);
111 auto* yAxis1 = axes.at(2);
112 auto* yAxis2 = axes.at(3);
113
114 QCOMPARE(xAxis->name(), QStringLiteral("x"));
115 QCOMPARE(xAxis2->name(), QStringLiteral("x2"));
116 QCOMPARE(yAxis1->name(), QStringLiteral("y"));
117 QCOMPARE(yAxis2->name(), QStringLiteral("y2"));
118
119 // xAxis2 does not have any labels
120 QVector<QString> refString = {QStringLiteral("161.2"),
121 QStringLiteral("166.7"),
122 QStringLiteral("172.2"),
123 QStringLiteral("177.8"),
124 QStringLiteral("183.3"),
125 QStringLiteral("188.8"),
126 QStringLiteral("194.4")};
127 COMPARE_STRING_VECTORS(static_cast<Axis*>(xAxis)->tickLabelStrings(), refString);
128 QVector<double> ref = {0, 20, 40, 60, 80, 100};
129 COMPARE_DOUBLE_VECTORS(static_cast<Axis*>(yAxis1)->tickLabelValues(), ref);
130 ref = {0, 0.2, 0.4, 0.6, 0.8, 1.0};
131 COMPARE_DOUBLE_VECTORS(static_cast<Axis*>(yAxis2)->tickLabelValues(), ref);
132}
133
134void RetransformTest::TestResizeWindows() {
135 RetransformCallCounter c;

Callers

nothing calls this directly

Calls 10

callCountMethod · 0.80
lengthMethod · 0.80
tickLabelStringsMethod · 0.80
tickLabelValuesMethod · 0.80
loadMethod · 0.45
childrenMethod · 0.45
pathMethod · 0.45
containsMethod · 0.45
valueMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected