| 1303 | } |
| 1304 | |
| 1305 | void AxisTest3::autoScaleLog102Vertical() { |
| 1306 | QLocale::setDefault(QLocale::C); // use . as decimal separator |
| 1307 | Project project; |
| 1308 | auto* ws = new Worksheet(QStringLiteral("worksheet")); |
| 1309 | QVERIFY(ws != nullptr); |
| 1310 | project.addChild(ws); |
| 1311 | |
| 1312 | auto* p = new CartesianPlot(QStringLiteral("plot")); |
| 1313 | p->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axes are created |
| 1314 | QVERIFY(p != nullptr); |
| 1315 | ws->addChild(p); |
| 1316 | |
| 1317 | auto axes = p->children<Axis>(); |
| 1318 | QCOMPARE(axes.count(), 2); |
| 1319 | QCOMPARE(axes.at(0)->name(), QStringLiteral("x")); |
| 1320 | QCOMPARE(axes.at(1)->name(), QStringLiteral("y")); |
| 1321 | auto* yAxis = static_cast<Axis*>(axes.at(1)); |
| 1322 | yAxis->setMajorTicksNumber(4); |
| 1323 | QCOMPARE(yAxis->scale(), RangeT::Scale::Linear); |
| 1324 | QCOMPARE(yAxis->rangeScale(), true); |
| 1325 | yAxis->setLabelsAutoPrecision(false); |
| 1326 | yAxis->setLabelsPrecision(2); |
| 1327 | |
| 1328 | auto range = p->range(Dimension::Y, 0); |
| 1329 | range.setStart(0); |
| 1330 | range.setEnd(1); |
| 1331 | p->setRange(Dimension::Y, 0, range); |
| 1332 | p->setNiceExtend(false); |
| 1333 | p->enableAutoScale(Dimension::Y, 0, false, true); |
| 1334 | p->setRangeScale(Dimension::Y, 0, RangeT::Scale::Log10); // use different method |
| 1335 | |
| 1336 | QCOMPARE(yAxis->range(), p->range(Dimension::Y, 0)); |
| 1337 | QCOMPARE(yAxis->scale(), RangeT::Scale::Log10); |
| 1338 | |
| 1339 | VALUES_EQUAL(yAxis->range().start(), 0.01); |
| 1340 | QCOMPARE(yAxis->range().end(), 1.0); |
| 1341 | |
| 1342 | QStringList expectedStrings{ |
| 1343 | QStringLiteral("0.01"), |
| 1344 | QStringLiteral("0.05"), |
| 1345 | QStringLiteral("0.22"), |
| 1346 | QStringLiteral("1.00"), |
| 1347 | }; |
| 1348 | COMPARE_STRING_VECTORS(yAxis->tickLabelStrings(), expectedStrings); |
| 1349 | } |
| 1350 | |
| 1351 | QTEST_MAIN(AxisTest3) |
nothing calls this directly
no test coverage detected