| 1143 | } |
| 1144 | |
| 1145 | void AxisTest3::autoScaleLog10() { |
| 1146 | QLocale::setDefault(QLocale::C); // use . as decimal separator |
| 1147 | Project project; |
| 1148 | auto* ws = new Worksheet(QStringLiteral("worksheet")); |
| 1149 | QVERIFY(ws != nullptr); |
| 1150 | project.addChild(ws); |
| 1151 | |
| 1152 | auto* p = new CartesianPlot(QStringLiteral("plot")); |
| 1153 | p->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axes are created |
| 1154 | QVERIFY(p != nullptr); |
| 1155 | ws->addChild(p); |
| 1156 | |
| 1157 | auto axes = p->children<Axis>(); |
| 1158 | QCOMPARE(axes.count(), 2); |
| 1159 | QCOMPARE(axes.at(0)->name(), QStringLiteral("x")); |
| 1160 | QCOMPARE(axes.at(1)->name(), QStringLiteral("y")); |
| 1161 | auto* xAxis = static_cast<Axis*>(axes.at(0)); |
| 1162 | xAxis->setMajorTicksNumber(4); |
| 1163 | QCOMPARE(xAxis->scale(), RangeT::Scale::Linear); |
| 1164 | QCOMPARE(xAxis->rangeScale(), true); |
| 1165 | |
| 1166 | auto range = p->range(Dimension::X, 0); |
| 1167 | range.setStart(10); |
| 1168 | range.setEnd(10000); |
| 1169 | p->setRange(Dimension::X, 0, range); |
| 1170 | p->setNiceExtend(false); |
| 1171 | |
| 1172 | { |
| 1173 | QStringList expectedStrings{ |
| 1174 | QStringLiteral("10"), |
| 1175 | QStringLiteral("3340"), |
| 1176 | QStringLiteral("6670"), |
| 1177 | QStringLiteral("10000"), |
| 1178 | }; |
| 1179 | COMPARE_STRING_VECTORS(xAxis->tickLabelStrings(), expectedStrings); |
| 1180 | } |
| 1181 | |
| 1182 | p->enableAutoScale(Dimension::X, 0, false, true); |
| 1183 | range = p->range(Dimension::X, 0); |
| 1184 | range.setScale(RangeT::Scale::Log10); |
| 1185 | p->setRange(Dimension::X, 0, range); |
| 1186 | |
| 1187 | QCOMPARE(xAxis->range(), range); |
| 1188 | QCOMPARE(xAxis->scale(), RangeT::Scale::Log10); |
| 1189 | |
| 1190 | { |
| 1191 | QStringList expectedStrings{ |
| 1192 | QStringLiteral("10"), |
| 1193 | QStringLiteral("100"), |
| 1194 | QStringLiteral("1000"), |
| 1195 | QStringLiteral("10000"), |
| 1196 | }; |
| 1197 | COMPARE_STRING_VECTORS(xAxis->tickLabelStrings(), expectedStrings); |
| 1198 | } |
| 1199 | |
| 1200 | xAxis->setScale(RangeT::Scale::Square); // Shall not change anything |
| 1201 | { |
| 1202 | QStringList expectedStrings{ |
nothing calls this directly
no test coverage detected