| 983 | } |
| 984 | |
| 985 | void WorksheetElementTest::positionRelative() { |
| 986 | // WORKSHEETELEMENT_TEST() |
| 987 | SETUP_PROJECT |
| 988 | auto* element = new TextLabel(QStringLiteral("element")); |
| 989 | p->addChild(element); |
| 990 | auto* dock = new LabelWidget(nullptr); |
| 991 | // MACRO_NAME(element, dockSetElementsMethodName); |
| 992 | dock->setLabels({element}); |
| 993 | |
| 994 | // #define WORKSHEETELEMENT_MOUSE_MOVE(element, dockSetElementsMethodName) |
| 995 | element->setCoordinateSystemIndex(p->defaultCoordinateSystemIndex()); |
| 996 | auto pp = element->position(); |
| 997 | pp.point = QPointF(0, 0); |
| 998 | element->setPosition(pp); |
| 999 | element->setCoordinateBindingEnabled(false); |
| 1000 | |
| 1001 | QCOMPARE(element->positionLogical().x(), 0.0); |
| 1002 | QCOMPARE(element->positionLogical().y(), 0.0); |
| 1003 | |
| 1004 | QCOMPARE(element->horizontalAlignment(), AbstractPlot::HorizontalAlignment::Center); |
| 1005 | QCOMPARE(element->verticalAlignment(), AbstractPlot::VerticalAlignment::Center); |
| 1006 | |
| 1007 | pp = element->position(); |
| 1008 | pp.horizontalPosition = AbstractPlot::HorizontalPosition::Relative; |
| 1009 | pp.verticalPosition = AbstractPlot::VerticalPosition::Relative; |
| 1010 | pp.point = QPointF(0.2, 0.8); // 20% and 80% |
| 1011 | element->setPosition(pp); |
| 1012 | |
| 1013 | QCOMPARE(element->positionLogical().x(), 0.2); |
| 1014 | // TODO |
| 1015 | // QCOMPARE(element->positionLogical().y(), 0.8); |
| 1016 | QCOMPARE(element->positionLogical().y(), 0.2); |
| 1017 | |
| 1018 | QCOMPARE(dock->ui.sbPositionX->value(), 0.2 * 100.0); |
| 1019 | QCOMPARE(dock->ui.sbPositionY->value(), 0.8 * 100.0); |
| 1020 | } |
| 1021 | |
| 1022 | void WorksheetElementTest::positionRelativeWithBinding() { |
| 1023 | // WORKSHEETELEMENT_TEST() |
nothing calls this directly
no test coverage detected