| 616 | } |
| 617 | |
| 618 | void CartesianPlotTest::rangeFormatXDataChanged() { |
| 619 | Project project; |
| 620 | |
| 621 | Spreadsheet* sheet = new Spreadsheet(QStringLiteral("Spreadsheet"), false); |
| 622 | project.addChild(sheet); |
| 623 | |
| 624 | sheet->setColumnCount(2); |
| 625 | sheet->setRowCount(3); |
| 626 | |
| 627 | sheet->column(0)->setColumnMode(AbstractColumn::ColumnMode::DateTime); |
| 628 | sheet->column(1)->setColumnMode(AbstractColumn::ColumnMode::Integer); |
| 629 | |
| 630 | sheet->column(0)->setDateTimeAt(0, QDateTime::fromString(QStringLiteral("2022-02-03 12:23:00"), Qt::ISODate)); |
| 631 | sheet->column(0)->setDateTimeAt(1, QDateTime::fromString(QStringLiteral("2022-02-04 12:23:00"), Qt::ISODate)); |
| 632 | sheet->column(0)->setDateTimeAt(2, QDateTime::fromString(QStringLiteral("2022-02-05 12:23:00"), Qt::ISODate)); |
| 633 | |
| 634 | QCOMPARE(sheet->column(0)->dateTimeAt(0), QDateTime::fromString(QStringLiteral("2022-02-03 12:23:00"), Qt::ISODate)); |
| 635 | |
| 636 | sheet->column(1)->setValueAt(0, 0); |
| 637 | sheet->column(1)->setValueAt(1, 1); |
| 638 | sheet->column(1)->setValueAt(2, 2); |
| 639 | |
| 640 | auto* worksheet = new Worksheet(QStringLiteral("Worksheet")); |
| 641 | project.addChild(worksheet); |
| 642 | |
| 643 | auto* plot = new CartesianPlot(QStringLiteral("plot")); |
| 644 | worksheet->addChild(plot); |
| 645 | plot->setType(CartesianPlot::Type::TwoAxes); // Otherwise no axis are created |
| 646 | |
| 647 | auto* curve = new XYCurve(QStringLiteral("curve")); |
| 648 | plot->addChild(curve); |
| 649 | |
| 650 | curve->setXColumn(sheet->column(1)); |
| 651 | curve->setYColumn(sheet->column(0)); |
| 652 | |
| 653 | QCOMPARE(plot->rangeFormat(Dimension::X, 0), RangeT::Format::Numeric); |
| 654 | QCOMPARE(plot->rangeFormat(Dimension::Y, 0), RangeT::Format::DateTime); |
| 655 | |
| 656 | // simulate data change |
| 657 | plot->dataChanged(curve, Dimension::X); |
| 658 | |
| 659 | QCOMPARE(plot->rangeFormat(Dimension::X, 0), RangeT::Format::Numeric); |
| 660 | QCOMPARE(plot->rangeFormat(Dimension::Y, 0), RangeT::Format::DateTime); |
| 661 | } |
| 662 | |
| 663 | void CartesianPlotTest::rangeFormatNonDefaultRange() { |
| 664 | Project project; |
nothing calls this directly
no test coverage detected