on xenial help sign in
tst_DragHandle: test it also rotated
commitc8eb9ebf61167f69a1873dd11482d56af00e02c9 authorDaniel d'Andrada <daniel.dandrada@canonical.com> dateWed 12 Feb 2014, 20:12 (13 years ago) parentcf12ebe
2 files changed+46−5
tests/qmltests/Components/tst_DragHandle.cpp+45−5 tests/qmltests/Components/tst_DragHandle.qml+1
tests/qmltests/Components/tst_DragHandle.cpp+45−5
@@ -58,7 +58,9 @@ private Q_SLOTS:
5858 void cleanup(); // called right after each and every test function is executed
5959
6060 void dragThreshold_horizontal();
61+ void dragThreshold_horizontal_data();
6162 void dragThreshold_vertical();
63+ void dragThreshold_vertical_data();
6264 void stretch_horizontal();
6365 void stretch_vertical();
6466 void hintingAnimation();
@@ -145,17 +147,29 @@ void tst_DragHandle::tryCompare(std::function<qreal ()> actualFunc,
145147namespace {
146148QPointF calculateDirectionVector(DirectionalDragArea *edgeDragArea)
147149{
148−
150+ QPointF localOrigin(0., 0.);
151+ QPointF localDirection;
149152 switch (edgeDragArea->direction()) {
150153 case Direction::Upwards:
151− return QPointF(0, -1);
154+ localDirection.rx() = 0.;
155+ localDirection.ry() = -1.;
156+ break;
152157 case Direction::Downwards:
153− return QPointF(0, 1);
158+ localDirection.rx() = 0.;
159+ localDirection.ry() = 1;
160+ break;
154161 case Direction::Leftwards:
155− return QPointF(-1, 0);
162+ localDirection.rx() = -1.;
163+ localDirection.ry() = 0.;
164+ break;
156165 default: // Direction::Rightwards:
157− return QPointF(1, 0);
166+ localDirection.rx() = 1.;
167+ localDirection.ry() = 0.;
168+ break;
158169 }
170+ QPointF sceneOrigin = edgeDragArea->mapToScene(localOrigin);
171+ QPointF sceneDirection = edgeDragArea->mapToScene(localDirection);
172+ return sceneDirection - sceneOrigin;
159173}
160174}
161175
@@ -222,6 +236,11 @@ qreal tst_DragHandle::fetchDragThreshold(DirectionalDragArea *dragHandle)
222236 */
223237void tst_DragHandle::dragThreshold_horizontal()
224238{
239+ QFETCH(qreal, rotation);
240+
241+ QQuickItem *baseItem = m_view->rootObject()->findChild<QQuickItem*>("baseItem");
242+ baseItem->setRotation(rotation);
243+
225244 DirectionalDragArea *dragHandle = fetchAndSetupDragHandle("rightwardsDragHandle");
226245
227246 qreal dragThreshold = fetchDragThreshold(dragHandle);
@@ -260,8 +279,21 @@ void tst_DragHandle::dragThreshold_horizontal()
260279 QCOMPARE(parentItem->property("shown").toBool(), false);
261280}
262281
282+void tst_DragHandle::dragThreshold_horizontal_data()
283+{
284+ QTest::addColumn<qreal>("rotation");
285+
286+ QTest::newRow("not rotated") << 0.;
287+ QTest::newRow("rotated 90") << 90.;
288+}
289+
263290void tst_DragHandle::dragThreshold_vertical()
264291{
292+ QFETCH(qreal, rotation);
293+
294+ QQuickItem *baseItem = m_view->rootObject()->findChild<QQuickItem*>("baseItem");
295+ baseItem->setRotation(rotation);
296+
265297 DirectionalDragArea *dragHandle = fetchAndSetupDragHandle("downwardsDragHandle");
266298
267299 qreal dragThreshold = fetchDragThreshold(dragHandle);
@@ -300,6 +332,14 @@ void tst_DragHandle::dragThreshold_vertical()
300332 QCOMPARE(parentItem->property("shown").toBool(), false);
301333}
302334
335+void tst_DragHandle::dragThreshold_vertical_data()
336+{
337+ QTest::addColumn<qreal>("rotation");
338+
339+ QTest::newRow("not rotated") << 0.;
340+ QTest::newRow("rotated 90") << 90.;
341+}
342+
303343/*
304344 Checks that when the stretch property is true, dragging the DragHandle increases
305345 the width or height (depending on its direction) of its parent Showable
tests/qmltests/Components/tst_DragHandle.qml+1
@@ -39,6 +39,7 @@ Item {
3939
4040 Item {
4141 id: baseItem
42+ objectName: "baseItem"
4243 anchors.fill: parent
4344
4445 VerticalShowable {