1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the test suite of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #include <QtTest/QSignalSpy>
43 #include <QtGui/QStyleHints>
44 #include <QtQml/qqmlengine.h>
45 #include <QtQml/qqmlcomponent.h>
46 #include <QtQuick/qquickview.h>
47 #include <private/qquickflickable_p.h>
48 #include <private/qquickflickable_p_p.h>
49 #include <private/qquicktransition_p.h>
50 #include <private/qqmlvaluetype_p.h>
52 #include "../../shared/util.h"
53 #include "../shared/viewtestutil.h"
54 #include "../shared/visualtestutil.h"
56 using namespace QQuickViewTestUtil;
57 using namespace QQuickVisualTestUtil;
59 class tst_qquickflickable : public QQmlDataTest
66 void horizontalViewportSize();
67 void verticalViewportSize();
69 void boundsBehavior();
71 void maximumFlickVelocity();
72 void flickDeceleration();
74 void nestedPressDelay();
75 void flickableDirection();
77 void returnToBounds();
78 void returnToBounds_data();
80 void movingAndFlicking();
81 void movingAndFlicking_data();
82 void movingAndDragging();
83 void movingAndDragging_data();
84 void flickOnRelease();
85 void pressWhileFlicking();
89 void cancelOnMouseGrab();
90 void clickAndDragWhenTransformed();
96 void tst_qquickflickable::create()
99 QQmlComponent c(&engine, testFileUrl("flickable01.qml"));
100 QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create());
103 QCOMPARE(obj->isAtXBeginning(), true);
104 QCOMPARE(obj->isAtXEnd(), false);
105 QCOMPARE(obj->isAtYBeginning(), true);
106 QCOMPARE(obj->isAtYEnd(), false);
107 QCOMPARE(obj->contentX(), 0.);
108 QCOMPARE(obj->contentY(), 0.);
110 QCOMPARE(obj->horizontalVelocity(), 0.);
111 QCOMPARE(obj->verticalVelocity(), 0.);
113 QCOMPARE(obj->isInteractive(), true);
114 QCOMPARE(obj->boundsBehavior(), QQuickFlickable::DragAndOvershootBounds);
115 QCOMPARE(obj->pressDelay(), 0);
116 QCOMPARE(obj->maximumFlickVelocity(), 2500.);
121 void tst_qquickflickable::horizontalViewportSize()
124 QQmlComponent c(&engine, testFileUrl("flickable02.qml"));
125 QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create());
128 QCOMPARE(obj->contentWidth(), 800.);
129 QCOMPARE(obj->contentHeight(), 300.);
130 QCOMPARE(obj->isAtXBeginning(), true);
131 QCOMPARE(obj->isAtXEnd(), false);
132 QCOMPARE(obj->isAtYBeginning(), true);
133 QCOMPARE(obj->isAtYEnd(), false);
138 void tst_qquickflickable::verticalViewportSize()
141 QQmlComponent c(&engine, testFileUrl("flickable03.qml"));
142 QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create());
145 QCOMPARE(obj->contentWidth(), 200.);
146 QCOMPARE(obj->contentHeight(), 6000.);
147 QCOMPARE(obj->isAtXBeginning(), true);
148 QCOMPARE(obj->isAtXEnd(), false);
149 QCOMPARE(obj->isAtYBeginning(), true);
150 QCOMPARE(obj->isAtYEnd(), false);
155 void tst_qquickflickable::properties()
158 QQmlComponent c(&engine, testFileUrl("flickable04.qml"));
159 QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(c.create());
162 QCOMPARE(obj->isInteractive(), false);
163 QCOMPARE(obj->boundsBehavior(), QQuickFlickable::StopAtBounds);
164 QCOMPARE(obj->pressDelay(), 200);
165 QCOMPARE(obj->maximumFlickVelocity(), 2000.);
167 QVERIFY(obj->property("ok").toBool() == false);
168 QMetaObject::invokeMethod(obj, "check");
169 QVERIFY(obj->property("ok").toBool() == true);
174 void tst_qquickflickable::boundsBehavior()
176 QQmlComponent component(&engine);
177 component.setData("import QtQuick 2.0; Flickable { boundsBehavior: Flickable.StopAtBounds }", QUrl::fromLocalFile(""));
178 QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(component.create());
179 QSignalSpy spy(flickable, SIGNAL(boundsBehaviorChanged()));
182 QVERIFY(flickable->boundsBehavior() == QQuickFlickable::StopAtBounds);
184 flickable->setBoundsBehavior(QQuickFlickable::DragAndOvershootBounds);
185 QVERIFY(flickable->boundsBehavior() == QQuickFlickable::DragAndOvershootBounds);
186 QCOMPARE(spy.count(),1);
187 flickable->setBoundsBehavior(QQuickFlickable::DragAndOvershootBounds);
188 QCOMPARE(spy.count(),1);
190 flickable->setBoundsBehavior(QQuickFlickable::DragOverBounds);
191 QVERIFY(flickable->boundsBehavior() == QQuickFlickable::DragOverBounds);
192 QCOMPARE(spy.count(),2);
193 flickable->setBoundsBehavior(QQuickFlickable::DragOverBounds);
194 QCOMPARE(spy.count(),2);
196 flickable->setBoundsBehavior(QQuickFlickable::StopAtBounds);
197 QVERIFY(flickable->boundsBehavior() == QQuickFlickable::StopAtBounds);
198 QCOMPARE(spy.count(),3);
199 flickable->setBoundsBehavior(QQuickFlickable::StopAtBounds);
200 QCOMPARE(spy.count(),3);
203 void tst_qquickflickable::rebound()
206 QSKIP("Producing flicks on Mac CI impossible due to timing problems");
209 QQuickView *window = new QQuickView;
210 window->setSource(testFileUrl("rebound.qml"));
212 window->requestActivateWindow();
213 QVERIFY(window->rootObject() != 0);
215 QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
216 QVERIFY(flickable != 0);
218 QQuickTransition *rebound = window->rootObject()->findChild<QQuickTransition*>("rebound");
220 QSignalSpy reboundSpy(rebound, SIGNAL(runningChanged()));
222 QSignalSpy movementStartedSpy(flickable, SIGNAL(movementStarted()));
223 QSignalSpy movementEndedSpy(flickable, SIGNAL(movementEnded()));
224 QSignalSpy vMoveSpy(flickable, SIGNAL(movingVerticallyChanged()));
225 QSignalSpy hMoveSpy(flickable, SIGNAL(movingHorizontallyChanged()));
227 // flick and test the transition is run
228 flick(window, QPoint(20,20), QPoint(120,120), 200);
230 QTRY_COMPARE(window->rootObject()->property("transitionsStarted").toInt(), 2);
231 QCOMPARE(hMoveSpy.count(), 1);
232 QCOMPARE(vMoveSpy.count(), 1);
233 QCOMPARE(movementStartedSpy.count(), 1);
234 QCOMPARE(movementEndedSpy.count(), 0);
235 QVERIFY(rebound->running());
237 QTRY_VERIFY(!flickable->isMoving());
238 QCOMPARE(flickable->contentX(), 0.0);
239 QCOMPARE(flickable->contentY(), 0.0);
241 QCOMPARE(hMoveSpy.count(), 2);
242 QCOMPARE(vMoveSpy.count(), 2);
243 QCOMPARE(movementStartedSpy.count(), 1);
244 QCOMPARE(movementEndedSpy.count(), 1);
245 QCOMPARE(window->rootObject()->property("transitionsStarted").toInt(), 2);
246 QVERIFY(!rebound->running());
247 QCOMPARE(reboundSpy.count(), 2);
251 movementStartedSpy.clear();
252 movementEndedSpy.clear();
253 window->rootObject()->setProperty("transitionsStarted", 0);
254 window->rootObject()->setProperty("transitionsFinished", 0);
256 // flick and trigger the transition multiple times
257 // (moving signals are emitted as soon as the first transition starts)
258 flick(window, QPoint(20,20), QPoint(120,120), 200); // both x and y will bounce back
259 flick(window, QPoint(20,120), QPoint(120,20), 200); // only x will bounce back
261 QVERIFY(flickable->isMoving());
262 QVERIFY(window->rootObject()->property("transitionsStarted").toInt() >= 1);
263 QCOMPARE(hMoveSpy.count(), 1);
264 QCOMPARE(vMoveSpy.count(), 1);
265 QCOMPARE(movementStartedSpy.count(), 1);
267 QTRY_VERIFY(!flickable->isMoving());
268 QCOMPARE(flickable->contentX(), 0.0);
270 // moving started/stopped signals should only have been emitted once,
271 // and when they are, all transitions should have finished
272 QCOMPARE(hMoveSpy.count(), 2);
273 QCOMPARE(vMoveSpy.count(), 2);
274 QCOMPARE(movementStartedSpy.count(), 1);
275 QCOMPARE(movementEndedSpy.count(), 1);
279 movementStartedSpy.clear();
280 movementEndedSpy.clear();
281 window->rootObject()->setProperty("transitionsStarted", 0);
282 window->rootObject()->setProperty("transitionsFinished", 0);
284 // disable and the default transition should run
285 // (i.e. moving but transition->running = false)
286 window->rootObject()->setProperty("transitionEnabled", false);
288 flick(window, QPoint(20,20), QPoint(120,120), 200);
289 QCOMPARE(window->rootObject()->property("transitionsStarted").toInt(), 0);
290 QCOMPARE(hMoveSpy.count(), 1);
291 QCOMPARE(vMoveSpy.count(), 1);
292 QCOMPARE(movementStartedSpy.count(), 1);
293 QCOMPARE(movementEndedSpy.count(), 0);
295 QTRY_VERIFY(!flickable->isMoving());
296 QCOMPARE(hMoveSpy.count(), 2);
297 QCOMPARE(vMoveSpy.count(), 2);
298 QCOMPARE(movementStartedSpy.count(), 1);
299 QCOMPARE(movementEndedSpy.count(), 1);
300 QCOMPARE(window->rootObject()->property("transitionsStarted").toInt(), 0);
305 void tst_qquickflickable::maximumFlickVelocity()
307 QQmlComponent component(&engine);
308 component.setData("import QtQuick 2.0; Flickable { maximumFlickVelocity: 1.0; }", QUrl::fromLocalFile(""));
309 QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(component.create());
310 QSignalSpy spy(flickable, SIGNAL(maximumFlickVelocityChanged()));
313 QCOMPARE(flickable->maximumFlickVelocity(), 1.0);
315 flickable->setMaximumFlickVelocity(2.0);
316 QCOMPARE(flickable->maximumFlickVelocity(), 2.0);
317 QCOMPARE(spy.count(),1);
318 flickable->setMaximumFlickVelocity(2.0);
319 QCOMPARE(spy.count(),1);
322 void tst_qquickflickable::flickDeceleration()
324 QQmlComponent component(&engine);
325 component.setData("import QtQuick 2.0; Flickable { flickDeceleration: 1.0; }", QUrl::fromLocalFile(""));
326 QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(component.create());
327 QSignalSpy spy(flickable, SIGNAL(flickDecelerationChanged()));
330 QCOMPARE(flickable->flickDeceleration(), 1.0);
332 flickable->setFlickDeceleration(2.0);
333 QCOMPARE(flickable->flickDeceleration(), 2.0);
334 QCOMPARE(spy.count(),1);
335 flickable->setFlickDeceleration(2.0);
336 QCOMPARE(spy.count(),1);
339 void tst_qquickflickable::pressDelay()
341 QQmlComponent component(&engine);
342 component.setData("import QtQuick 2.0; Flickable { pressDelay: 100; }", QUrl::fromLocalFile(""));
343 QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(component.create());
344 QSignalSpy spy(flickable, SIGNAL(pressDelayChanged()));
347 QCOMPARE(flickable->pressDelay(), 100);
349 flickable->setPressDelay(200);
350 QCOMPARE(flickable->pressDelay(), 200);
351 QCOMPARE(spy.count(),1);
352 flickable->setPressDelay(200);
353 QCOMPARE(spy.count(),1);
357 void tst_qquickflickable::nestedPressDelay()
359 QQuickView *window = new QQuickView;
360 window->setSource(testFileUrl("nestedPressDelay.qml"));
362 window->requestActivateWindow();
363 QVERIFY(window->rootObject() != 0);
365 QQuickFlickable *outer = qobject_cast<QQuickFlickable*>(window->rootObject());
368 QQuickFlickable *inner = window->rootObject()->findChild<QQuickFlickable*>("innerFlickable");
371 QTest::mousePress(window, Qt::LeftButton, 0, QPoint(150, 150));
372 // the MouseArea is not pressed immediately
373 QVERIFY(outer->property("pressed").toBool() == false);
375 // The outer pressDelay will prevail (50ms, vs. 10sec)
376 // QTRY_VERIFY() has 5sec timeout, so will timeout well within 10sec.
377 QTRY_VERIFY(outer->property("pressed").toBool() == true);
379 QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(150, 150));
384 void tst_qquickflickable::flickableDirection()
386 QQmlComponent component(&engine);
387 component.setData("import QtQuick 2.0; Flickable { flickableDirection: Flickable.VerticalFlick; }", QUrl::fromLocalFile(""));
388 QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(component.create());
389 QSignalSpy spy(flickable, SIGNAL(flickableDirectionChanged()));
392 QCOMPARE(flickable->flickableDirection(), QQuickFlickable::VerticalFlick);
394 flickable->setFlickableDirection(QQuickFlickable::HorizontalAndVerticalFlick);
395 QCOMPARE(flickable->flickableDirection(), QQuickFlickable::HorizontalAndVerticalFlick);
396 QCOMPARE(spy.count(),1);
398 flickable->setFlickableDirection(QQuickFlickable::AutoFlickDirection);
399 QCOMPARE(flickable->flickableDirection(), QQuickFlickable::AutoFlickDirection);
400 QCOMPARE(spy.count(),2);
402 flickable->setFlickableDirection(QQuickFlickable::HorizontalFlick);
403 QCOMPARE(flickable->flickableDirection(), QQuickFlickable::HorizontalFlick);
404 QCOMPARE(spy.count(),3);
406 flickable->setFlickableDirection(QQuickFlickable::HorizontalFlick);
407 QCOMPARE(flickable->flickableDirection(), QQuickFlickable::HorizontalFlick);
408 QCOMPARE(spy.count(),3);
412 void tst_qquickflickable::resizeContent()
415 QQmlComponent c(&engine, testFileUrl("resize.qml"));
416 QQuickItem *root = qobject_cast<QQuickItem*>(c.create());
417 QQuickFlickable *obj = findItem<QQuickFlickable>(root, "flick");
420 QCOMPARE(obj->contentX(), 0.);
421 QCOMPARE(obj->contentY(), 0.);
422 QCOMPARE(obj->contentWidth(), 300.);
423 QCOMPARE(obj->contentHeight(), 300.);
425 QMetaObject::invokeMethod(root, "resizeContent");
427 QCOMPARE(obj->contentX(), 100.);
428 QCOMPARE(obj->contentY(), 100.);
429 QCOMPARE(obj->contentWidth(), 600.);
430 QCOMPARE(obj->contentHeight(), 600.);
435 void tst_qquickflickable::returnToBounds()
437 QFETCH(bool, setRebound);
439 QQuickView *window = new QQuickView;
440 window->rootContext()->setContextProperty("setRebound", setRebound);
441 window->setSource(testFileUrl("resize.qml"));
442 QVERIFY(window->rootObject() != 0);
443 QQuickFlickable *obj = findItem<QQuickFlickable>(window->rootObject(), "flick");
445 QQuickTransition *rebound = window->rootObject()->findChild<QQuickTransition*>("rebound");
447 QSignalSpy reboundSpy(rebound, SIGNAL(runningChanged()));
450 QCOMPARE(obj->contentX(), 0.);
451 QCOMPARE(obj->contentY(), 0.);
452 QCOMPARE(obj->contentWidth(), 300.);
453 QCOMPARE(obj->contentHeight(), 300.);
455 obj->setContentX(100);
456 obj->setContentY(400);
457 QTRY_COMPARE(obj->contentX(), 100.);
458 QTRY_COMPARE(obj->contentY(), 400.);
460 QMetaObject::invokeMethod(window->rootObject(), "returnToBounds");
463 QTRY_VERIFY(rebound->running());
465 QTRY_COMPARE(obj->contentX(), 0.);
466 QTRY_COMPARE(obj->contentY(), 0.);
468 QVERIFY(!rebound->running());
469 QCOMPARE(reboundSpy.count(), setRebound ? 2 : 0);
474 void tst_qquickflickable::returnToBounds_data()
476 QTest::addColumn<bool>("setRebound");
478 QTest::newRow("with bounds transition") << true;
479 QTest::newRow("with bounds transition") << false;
482 void tst_qquickflickable::wheel()
484 QQuickView *window = new QQuickView;
485 window->setSource(testFileUrl("wheel.qml"));
487 window->requestActivateWindow();
488 QVERIFY(window->rootObject() != 0);
490 QQuickFlickable *flick = window->rootObject()->findChild<QQuickFlickable*>("flick");
494 QPoint pos(200, 200);
495 QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(), QPoint(0,-120), -120, Qt::Vertical, Qt::NoButton, Qt::NoModifier);
496 event.setAccepted(false);
497 QGuiApplication::sendEvent(window, &event);
500 QTRY_VERIFY(flick->contentY() > 0);
501 QVERIFY(flick->contentX() == 0);
503 flick->setContentY(0);
504 QVERIFY(flick->contentY() == 0);
507 QPoint pos(200, 200);
508 QWheelEvent event(pos, window->mapToGlobal(pos), QPoint(), QPoint(-120,0), -120, Qt::Horizontal, Qt::NoButton, Qt::NoModifier);
510 event.setAccepted(false);
511 QGuiApplication::sendEvent(window, &event);
514 QTRY_VERIFY(flick->contentX() > 0);
515 QVERIFY(flick->contentY() == 0);
520 void tst_qquickflickable::movingAndFlicking_data()
522 QTest::addColumn<bool>("verticalEnabled");
523 QTest::addColumn<bool>("horizontalEnabled");
524 QTest::addColumn<QPoint>("flickToWithoutSnapBack");
525 QTest::addColumn<QPoint>("flickToWithSnapBack");
527 QTest::newRow("vertical")
532 QTest::newRow("horizontal")
537 QTest::newRow("both")
543 void tst_qquickflickable::movingAndFlicking()
546 QSKIP("Producing flicks on Mac CI impossible due to timing problems");
549 QFETCH(bool, verticalEnabled);
550 QFETCH(bool, horizontalEnabled);
551 QFETCH(QPoint, flickToWithoutSnapBack);
552 QFETCH(QPoint, flickToWithSnapBack);
554 const QPoint flickFrom(50, 200); // centre
556 QQuickView *window = new QQuickView;
557 window->setSource(testFileUrl("flickable03.qml"));
559 window->requestActivateWindow();
560 QTest::qWaitForWindowActive(window);
561 QVERIFY(window->rootObject() != 0);
563 QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
564 QVERIFY(flickable != 0);
566 QSignalSpy vMoveSpy(flickable, SIGNAL(movingVerticallyChanged()));
567 QSignalSpy hMoveSpy(flickable, SIGNAL(movingHorizontallyChanged()));
568 QSignalSpy moveSpy(flickable, SIGNAL(movingChanged()));
569 QSignalSpy vFlickSpy(flickable, SIGNAL(flickingVerticallyChanged()));
570 QSignalSpy hFlickSpy(flickable, SIGNAL(flickingHorizontallyChanged()));
571 QSignalSpy flickSpy(flickable, SIGNAL(flickingChanged()));
573 QSignalSpy moveStartSpy(flickable, SIGNAL(movementStarted()));
574 QSignalSpy moveEndSpy(flickable, SIGNAL(movementEnded()));
575 QSignalSpy flickStartSpy(flickable, SIGNAL(flickStarted()));
576 QSignalSpy flickEndSpy(flickable, SIGNAL(flickEnded()));
578 // do a flick that keeps the view within the bounds
579 flick(window, flickFrom, flickToWithoutSnapBack, 200);
581 QVERIFY(flickable->isMoving());
582 QCOMPARE(flickable->isMovingHorizontally(), horizontalEnabled);
583 QCOMPARE(flickable->isMovingVertically(), verticalEnabled);
584 QVERIFY(flickable->isFlicking());
585 QCOMPARE(flickable->isFlickingHorizontally(), horizontalEnabled);
586 QCOMPARE(flickable->isFlickingVertically(), verticalEnabled);
588 QCOMPARE(moveSpy.count(), 1);
589 QCOMPARE(vMoveSpy.count(), verticalEnabled ? 1 : 0);
590 QCOMPARE(hMoveSpy.count(), horizontalEnabled ? 1 : 0);
591 QCOMPARE(flickSpy.count(), 1);
592 QCOMPARE(vFlickSpy.count(), verticalEnabled ? 1 : 0);
593 QCOMPARE(hFlickSpy.count(), horizontalEnabled ? 1 : 0);
595 QCOMPARE(moveStartSpy.count(), 1);
596 QCOMPARE(flickStartSpy.count(), 1);
598 // wait for any motion to end
599 QTRY_VERIFY(!flickable->isMoving());
601 QVERIFY(!flickable->isMovingHorizontally());
602 QVERIFY(!flickable->isMovingVertically());
603 QVERIFY(!flickable->isFlicking());
604 QVERIFY(!flickable->isFlickingHorizontally());
605 QVERIFY(!flickable->isFlickingVertically());
607 QCOMPARE(moveSpy.count(), 2);
608 QCOMPARE(vMoveSpy.count(), verticalEnabled ? 2 : 0);
609 QCOMPARE(hMoveSpy.count(), horizontalEnabled ? 2 : 0);
610 QCOMPARE(flickSpy.count(), 2);
611 QCOMPARE(vFlickSpy.count(), verticalEnabled ? 2 : 0);
612 QCOMPARE(hFlickSpy.count(), horizontalEnabled ? 2 : 0);
614 QCOMPARE(moveStartSpy.count(), 1);
615 QCOMPARE(moveEndSpy.count(), 1);
616 QCOMPARE(flickStartSpy.count(), 1);
617 QCOMPARE(flickEndSpy.count(), 1);
619 // Stop on a full pixel after user interaction
621 QCOMPARE(flickable->contentY(), (qreal)qRound(flickable->contentY()));
622 if (horizontalEnabled)
623 QCOMPARE(flickable->contentX(), (qreal)qRound(flickable->contentX()));
625 // clear for next flick
626 vMoveSpy.clear(); hMoveSpy.clear(); moveSpy.clear();
627 vFlickSpy.clear(); hFlickSpy.clear(); flickSpy.clear();
628 moveStartSpy.clear(); moveEndSpy.clear();
629 flickStartSpy.clear(); flickEndSpy.clear();
631 // do a flick that flicks the view out of bounds
632 flickable->setContentX(0);
633 flickable->setContentY(0);
634 QTRY_VERIFY(!flickable->isMoving());
635 flick(window, flickFrom, flickToWithSnapBack, 200);
637 QVERIFY(flickable->isMoving());
638 QCOMPARE(flickable->isMovingHorizontally(), horizontalEnabled);
639 QCOMPARE(flickable->isMovingVertically(), verticalEnabled);
640 QVERIFY(flickable->isFlicking());
641 QCOMPARE(flickable->isFlickingHorizontally(), horizontalEnabled);
642 QCOMPARE(flickable->isFlickingVertically(), verticalEnabled);
644 QCOMPARE(moveSpy.count(), 1);
645 QCOMPARE(vMoveSpy.count(), verticalEnabled ? 1 : 0);
646 QCOMPARE(hMoveSpy.count(), horizontalEnabled ? 1 : 0);
647 QCOMPARE(flickSpy.count(), 1);
648 QCOMPARE(vFlickSpy.count(), verticalEnabled ? 1 : 0);
649 QCOMPARE(hFlickSpy.count(), horizontalEnabled ? 1 : 0);
651 QCOMPARE(moveStartSpy.count(), 1);
652 QCOMPARE(moveEndSpy.count(), 0);
653 QCOMPARE(flickStartSpy.count(), 1);
654 QCOMPARE(flickEndSpy.count(), 0);
656 // wait for any motion to end
657 QTRY_VERIFY(!flickable->isMoving());
659 QVERIFY(!flickable->isMovingHorizontally());
660 QVERIFY(!flickable->isMovingVertically());
661 QVERIFY(!flickable->isFlicking());
662 QVERIFY(!flickable->isFlickingHorizontally());
663 QVERIFY(!flickable->isFlickingVertically());
665 QCOMPARE(moveSpy.count(), 2);
666 QCOMPARE(vMoveSpy.count(), verticalEnabled ? 2 : 0);
667 QCOMPARE(hMoveSpy.count(), horizontalEnabled ? 2 : 0);
668 QCOMPARE(flickSpy.count(), 2);
669 QCOMPARE(vFlickSpy.count(), verticalEnabled ? 2 : 0);
670 QCOMPARE(hFlickSpy.count(), horizontalEnabled ? 2 : 0);
672 QCOMPARE(moveStartSpy.count(), 1);
673 QCOMPARE(moveEndSpy.count(), 1);
674 QCOMPARE(flickStartSpy.count(), 1);
675 QCOMPARE(flickEndSpy.count(), 1);
677 QCOMPARE(flickable->contentX(), 0.0);
678 QCOMPARE(flickable->contentY(), 0.0);
684 void tst_qquickflickable::movingAndDragging_data()
686 QTest::addColumn<bool>("verticalEnabled");
687 QTest::addColumn<bool>("horizontalEnabled");
688 QTest::addColumn<QPoint>("moveByWithoutSnapBack");
689 QTest::addColumn<QPoint>("moveByWithSnapBack");
691 QTest::newRow("vertical")
696 QTest::newRow("horizontal")
701 QTest::newRow("both")
707 void tst_qquickflickable::movingAndDragging()
709 QFETCH(bool, verticalEnabled);
710 QFETCH(bool, horizontalEnabled);
711 QFETCH(QPoint, moveByWithoutSnapBack);
712 QFETCH(QPoint, moveByWithSnapBack);
714 const QPoint moveFrom(50, 200); // centre
716 QQuickView *window = new QQuickView;
717 window->setSource(testFileUrl("flickable03.qml"));
719 window->requestActivateWindow();
720 QTest::qWaitForWindowShown(window);
721 QVERIFY(window->rootObject() != 0);
723 QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
724 QVERIFY(flickable != 0);
726 QSignalSpy vDragSpy(flickable, SIGNAL(draggingVerticallyChanged()));
727 QSignalSpy hDragSpy(flickable, SIGNAL(draggingHorizontallyChanged()));
728 QSignalSpy dragSpy(flickable, SIGNAL(draggingChanged()));
729 QSignalSpy vMoveSpy(flickable, SIGNAL(movingVerticallyChanged()));
730 QSignalSpy hMoveSpy(flickable, SIGNAL(movingHorizontallyChanged()));
731 QSignalSpy moveSpy(flickable, SIGNAL(movingChanged()));
733 QSignalSpy dragStartSpy(flickable, SIGNAL(dragStarted()));
734 QSignalSpy dragEndSpy(flickable, SIGNAL(dragEnded()));
735 QSignalSpy moveStartSpy(flickable, SIGNAL(movementStarted()));
736 QSignalSpy moveEndSpy(flickable, SIGNAL(movementEnded()));
739 QTest::mousePress(window, Qt::LeftButton, 0, moveFrom);
740 QTest::mouseMove(window, moveFrom + moveByWithoutSnapBack);
741 QTest::mouseMove(window, moveFrom + moveByWithoutSnapBack*2);
742 QTest::mouseMove(window, moveFrom + moveByWithoutSnapBack*3);
744 QVERIFY(flickable->isMoving());
745 QCOMPARE(flickable->isMovingHorizontally(), horizontalEnabled);
746 QCOMPARE(flickable->isMovingVertically(), verticalEnabled);
747 QVERIFY(flickable->isDragging());
748 QCOMPARE(flickable->isDraggingHorizontally(), horizontalEnabled);
749 QCOMPARE(flickable->isDraggingVertically(), verticalEnabled);
751 QCOMPARE(moveSpy.count(), 1);
752 QCOMPARE(vMoveSpy.count(), verticalEnabled ? 1 : 0);
753 QCOMPARE(hMoveSpy.count(), horizontalEnabled ? 1 : 0);
754 QCOMPARE(dragSpy.count(), 1);
755 QCOMPARE(vDragSpy.count(), verticalEnabled ? 1 : 0);
756 QCOMPARE(hDragSpy.count(), horizontalEnabled ? 1 : 0);
758 QCOMPARE(moveStartSpy.count(), 1);
759 QCOMPARE(dragStartSpy.count(), 1);
761 QTest::mouseRelease(window, Qt::LeftButton, 0, moveFrom + moveByWithoutSnapBack*3);
763 QVERIFY(!flickable->isDragging());
764 QVERIFY(!flickable->isDraggingHorizontally());
765 QVERIFY(!flickable->isDraggingVertically());
766 QCOMPARE(dragSpy.count(), 2);
767 QCOMPARE(vDragSpy.count(), verticalEnabled ? 2 : 0);
768 QCOMPARE(hDragSpy.count(), horizontalEnabled ? 2 : 0);
769 QCOMPARE(dragStartSpy.count(), 1);
770 QCOMPARE(dragEndSpy.count(), 1);
771 // Don't test whether moving finished because a flick could occur
773 // wait for any motion to end
774 QTRY_VERIFY(flickable->isMoving() == false);
776 QVERIFY(!flickable->isMovingHorizontally());
777 QVERIFY(!flickable->isMovingVertically());
778 QVERIFY(!flickable->isDragging());
779 QVERIFY(!flickable->isDraggingHorizontally());
780 QVERIFY(!flickable->isDraggingVertically());
782 QCOMPARE(dragSpy.count(), 2);
783 QCOMPARE(vDragSpy.count(), verticalEnabled ? 2 : 0);
784 QCOMPARE(hDragSpy.count(), horizontalEnabled ? 2 : 0);
785 QCOMPARE(moveSpy.count(), 2);
786 QCOMPARE(vMoveSpy.count(), verticalEnabled ? 2 : 0);
787 QCOMPARE(hMoveSpy.count(), horizontalEnabled ? 2 : 0);
789 QCOMPARE(dragStartSpy.count(), 1);
790 QCOMPARE(dragEndSpy.count(), 1);
791 QCOMPARE(moveStartSpy.count(), 1);
792 QCOMPARE(moveEndSpy.count(), 1);
794 // Stop on a full pixel after user interaction
796 QCOMPARE(flickable->contentY(), (qreal)qRound(flickable->contentY()));
797 if (horizontalEnabled)
798 QCOMPARE(flickable->contentX(), (qreal)qRound(flickable->contentX()));
800 // clear for next drag
801 vMoveSpy.clear(); hMoveSpy.clear(); moveSpy.clear();
802 vDragSpy.clear(); hDragSpy.clear(); dragSpy.clear();
803 moveStartSpy.clear(); moveEndSpy.clear();
804 dragStartSpy.clear(); dragEndSpy.clear();
806 // do a drag that drags the view out of bounds
807 flickable->setContentX(0);
808 flickable->setContentY(0);
809 QTRY_VERIFY(!flickable->isMoving());
810 QTest::mousePress(window, Qt::LeftButton, 0, moveFrom);
811 QTest::mouseMove(window, moveFrom + moveByWithSnapBack);
812 QTest::mouseMove(window, moveFrom + moveByWithSnapBack*2);
813 QTest::mouseMove(window, moveFrom + moveByWithSnapBack*3);
815 QVERIFY(flickable->isMoving());
816 QCOMPARE(flickable->isMovingHorizontally(), horizontalEnabled);
817 QCOMPARE(flickable->isMovingVertically(), verticalEnabled);
818 QVERIFY(flickable->isDragging());
819 QCOMPARE(flickable->isDraggingHorizontally(), horizontalEnabled);
820 QCOMPARE(flickable->isDraggingVertically(), verticalEnabled);
822 QCOMPARE(moveSpy.count(), 1);
823 QCOMPARE(vMoveSpy.count(), verticalEnabled ? 1 : 0);
824 QCOMPARE(hMoveSpy.count(), horizontalEnabled ? 1 : 0);
825 QCOMPARE(dragSpy.count(), 1);
826 QCOMPARE(vDragSpy.count(), verticalEnabled ? 1 : 0);
827 QCOMPARE(hDragSpy.count(), horizontalEnabled ? 1 : 0);
829 QCOMPARE(moveStartSpy.count(), 1);
830 QCOMPARE(moveEndSpy.count(), 0);
831 QCOMPARE(dragStartSpy.count(), 1);
832 QCOMPARE(dragEndSpy.count(), 0);
834 QTest::mouseRelease(window, Qt::LeftButton, 0, moveFrom + moveByWithSnapBack*3);
836 // should now start snapping back to bounds (moving but not dragging)
837 QVERIFY(flickable->isMoving());
838 QCOMPARE(flickable->isMovingHorizontally(), horizontalEnabled);
839 QCOMPARE(flickable->isMovingVertically(), verticalEnabled);
840 QVERIFY(!flickable->isDragging());
841 QVERIFY(!flickable->isDraggingHorizontally());
842 QVERIFY(!flickable->isDraggingVertically());
844 QCOMPARE(moveSpy.count(), 1);
845 QCOMPARE(vMoveSpy.count(), verticalEnabled ? 1 : 0);
846 QCOMPARE(hMoveSpy.count(), horizontalEnabled ? 1 : 0);
847 QCOMPARE(dragSpy.count(), 2);
848 QCOMPARE(vDragSpy.count(), verticalEnabled ? 2 : 0);
849 QCOMPARE(hDragSpy.count(), horizontalEnabled ? 2 : 0);
851 QCOMPARE(moveStartSpy.count(), 1);
852 QCOMPARE(moveEndSpy.count(), 0);
854 // wait for any motion to end
855 QTRY_VERIFY(!flickable->isMoving());
857 QVERIFY(!flickable->isMovingHorizontally());
858 QVERIFY(!flickable->isMovingVertically());
859 QVERIFY(!flickable->isDragging());
860 QVERIFY(!flickable->isDraggingHorizontally());
861 QVERIFY(!flickable->isDraggingVertically());
863 QCOMPARE(moveSpy.count(), 2);
864 QCOMPARE(vMoveSpy.count(), verticalEnabled ? 2 : 0);
865 QCOMPARE(hMoveSpy.count(), horizontalEnabled ? 2 : 0);
866 QCOMPARE(dragSpy.count(), 2);
867 QCOMPARE(vDragSpy.count(), verticalEnabled ? 2 : 0);
868 QCOMPARE(hDragSpy.count(), horizontalEnabled ? 2 : 0);
870 QCOMPARE(moveStartSpy.count(), 1);
871 QCOMPARE(moveEndSpy.count(), 1);
872 QCOMPARE(dragStartSpy.count(), 1);
873 QCOMPARE(dragEndSpy.count(), 1);
875 QCOMPARE(flickable->contentX(), 0.0);
876 QCOMPARE(flickable->contentY(), 0.0);
881 void tst_qquickflickable::flickOnRelease()
884 QSKIP("Producing flicks on Mac CI impossible due to timing problems");
886 QQuickView *window = new QQuickView;
887 window->setSource(testFileUrl("flickable03.qml"));
889 window->requestActivateWindow();
890 QTest::qWaitForWindowShown(window);
891 QVERIFY(window->rootObject() != 0);
893 QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
894 QVERIFY(flickable != 0);
896 // Vertical with a quick press-move-release: should cause a flick in release.
897 QSignalSpy vFlickSpy(flickable, SIGNAL(flickingVerticallyChanged()));
898 // Use something that generates a huge velocity just to make it testable.
899 // In practice this feature matters on touchscreen devices where the
900 // underlying drivers will hopefully provide a pre-calculated velocity
901 // (based on more data than what the UI gets), thus making this use case
902 // working even with small movements.
903 QTest::mousePress(window, Qt::LeftButton, 0, QPoint(50, 300));
904 QTest::mouseMove(window, QPoint(50, 10), 10);
905 QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50, 10), 10);
907 QCOMPARE(vFlickSpy.count(), 1);
909 // wait for any motion to end
910 QTRY_VERIFY(flickable->isMoving() == false);
912 // Stop on a full pixel after user interaction
913 QCOMPARE(flickable->contentY(), (qreal)qRound(flickable->contentY()));
918 void tst_qquickflickable::pressWhileFlicking()
921 QSKIP("Producing flicks on Mac CI impossible due to timing problems");
924 QQuickView *window = new QQuickView;
925 window->setSource(testFileUrl("flickable03.qml"));
927 window->requestActivateWindow();
928 QTest::qWaitForWindowShown(window);
929 QVERIFY(window->rootObject() != 0);
931 QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
932 QVERIFY(flickable != 0);
934 QSignalSpy vMoveSpy(flickable, SIGNAL(movingVerticallyChanged()));
935 QSignalSpy hMoveSpy(flickable, SIGNAL(movingHorizontallyChanged()));
936 QSignalSpy moveSpy(flickable, SIGNAL(movingChanged()));
937 QSignalSpy hFlickSpy(flickable, SIGNAL(flickingHorizontallyChanged()));
938 QSignalSpy vFlickSpy(flickable, SIGNAL(flickingVerticallyChanged()));
939 QSignalSpy flickSpy(flickable, SIGNAL(flickingChanged()));
941 // flick then press while it is still moving
942 // flicking == false, moving == true;
943 flick(window, QPoint(20,190), QPoint(20, 50), 200);
944 QVERIFY(flickable->verticalVelocity() > 0.0);
945 QVERIFY(flickable->isFlicking());
946 QVERIFY(flickable->isFlickingVertically());
947 QVERIFY(!flickable->isFlickingHorizontally());
948 QVERIFY(flickable->isMoving());
949 QVERIFY(flickable->isMovingVertically());
950 QVERIFY(!flickable->isMovingHorizontally());
951 QCOMPARE(vMoveSpy.count(), 1);
952 QCOMPARE(hMoveSpy.count(), 0);
953 QCOMPARE(moveSpy.count(), 1);
954 QCOMPARE(vFlickSpy.count(), 1);
955 QCOMPARE(hFlickSpy.count(), 0);
956 QCOMPARE(flickSpy.count(), 1);
958 QTest::mousePress(window, Qt::LeftButton, 0, QPoint(20, 50));
959 QTRY_VERIFY(!flickable->isFlicking());
960 QVERIFY(!flickable->isFlickingVertically());
961 QVERIFY(flickable->isMoving());
962 QVERIFY(flickable->isMovingVertically());
964 QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(20,50));
965 QVERIFY(!flickable->isFlicking());
966 QVERIFY(!flickable->isFlickingVertically());
967 QTRY_VERIFY(!flickable->isMoving());
968 QVERIFY(!flickable->isMovingVertically());
969 // Stop on a full pixel after user interaction
970 QCOMPARE(flickable->contentX(), (qreal)qRound(flickable->contentX()));
975 void tst_qquickflickable::disabled()
977 QQuickView *window = new QQuickView;
978 window->setSource(testFileUrl("disabled.qml"));
980 window->requestActivateWindow();
981 QVERIFY(window->rootObject() != 0);
983 QQuickFlickable *flick = window->rootObject()->findChild<QQuickFlickable*>("flickable");
986 QTest::mousePress(window, Qt::LeftButton, 0, QPoint(50, 90));
988 QTest::mouseMove(window, QPoint(50, 80));
989 QTest::mouseMove(window, QPoint(50, 70));
990 QTest::mouseMove(window, QPoint(50, 60));
992 QVERIFY(flick->isMoving() == false);
994 QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50, 60));
996 // verify that mouse clicks on other elements still work (QTBUG-20584)
997 QTest::mousePress(window, Qt::LeftButton, 0, QPoint(50, 10));
998 QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50, 10));
1000 QTRY_VERIFY(window->rootObject()->property("clicked").toBool() == true);
1003 void tst_qquickflickable::flickVelocity()
1006 QSKIP("Producing flicks on Mac CI impossible due to timing problems");
1009 QQuickView *window = new QQuickView;
1010 window->setSource(testFileUrl("flickable03.qml"));
1012 window->requestActivateWindow();
1013 QVERIFY(window->rootObject() != 0);
1015 QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
1016 QVERIFY(flickable != 0);
1019 flick(window, QPoint(20,190), QPoint(20, 50), 200);
1020 QVERIFY(flickable->verticalVelocity() > 0.0);
1021 QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
1024 flick(window, QPoint(20,10), QPoint(20, 140), 200);
1025 QVERIFY(flickable->verticalVelocity() < 0.0);
1026 QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
1028 // Flick multiple times and verify that flick acceleration is applied.
1029 QQuickFlickablePrivate *fp = QQuickFlickablePrivate::get(flickable);
1030 bool boosted = false;
1031 for (int i = 0; i < 6; ++i) {
1032 flick(window, QPoint(20,390), QPoint(20, 50), 100);
1033 boosted |= fp->flickBoost > 1.0;
1037 // Flick in opposite direction -> boost cancelled.
1038 flick(window, QPoint(20,10), QPoint(20, 340), 200);
1039 QTRY_VERIFY(flickable->verticalVelocity() < 0.0);
1040 QVERIFY(fp->flickBoost == 1.0);
1045 void tst_qquickflickable::margins()
1048 QQmlComponent c(&engine, testFileUrl("margins.qml"));
1049 QQuickItem *root = qobject_cast<QQuickItem*>(c.create());
1050 QQuickFlickable *obj = qobject_cast<QQuickFlickable*>(root);
1054 QCOMPARE(obj->contentX(), -40.);
1055 QCOMPARE(obj->contentY(), -20.);
1056 QCOMPARE(obj->contentWidth(), 1600.);
1057 QCOMPARE(obj->contentHeight(), 600.);
1058 QCOMPARE(obj->originX(), 0.);
1059 QCOMPARE(obj->originY(), 0.);
1061 // Reduce left margin
1062 obj->setLeftMargin(30);
1063 QTRY_COMPARE(obj->contentX(), -30.);
1065 // Reduce top margin
1066 obj->setTopMargin(20);
1067 QTRY_COMPARE(obj->contentY(), -20.);
1069 // position to the far right, including margin
1070 obj->setContentX(1600 + 50 - obj->width());
1071 obj->returnToBounds();
1073 QCOMPARE(obj->contentX(), 1600. + 50. - obj->width());
1075 // position beyond the far right, including margin
1076 obj->setContentX(1600 + 50 - obj->width() + 1.);
1077 obj->returnToBounds();
1078 QTRY_COMPARE(obj->contentX(), 1600. + 50. - obj->width());
1080 // Reduce right margin
1081 obj->setRightMargin(40);
1082 QTRY_COMPARE(obj->contentX(), 1600. + 40. - obj->width());
1083 QCOMPARE(obj->contentWidth(), 1600.);
1085 // position to the far bottom, including margin
1086 obj->setContentY(600 + 30 - obj->height());
1087 obj->returnToBounds();
1089 QCOMPARE(obj->contentY(), 600. + 30. - obj->height());
1091 // position beyond the far bottom, including margin
1092 obj->setContentY(600 + 30 - obj->height() + 1.);
1093 obj->returnToBounds();
1094 QTRY_COMPARE(obj->contentY(), 600. + 30. - obj->height());
1096 // Reduce bottom margin
1097 obj->setBottomMargin(20);
1098 QTRY_COMPARE(obj->contentY(), 600. + 20. - obj->height());
1099 QCOMPARE(obj->contentHeight(), 600.);
1104 void tst_qquickflickable::cancelOnMouseGrab()
1106 QQuickView *window = new QQuickView;
1107 window->setSource(testFileUrl("cancel.qml"));
1109 window->requestActivateWindow();
1110 QVERIFY(window->rootObject() != 0);
1112 QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
1113 QVERIFY(flickable != 0);
1115 QTest::mousePress(window, Qt::LeftButton, 0, QPoint(10, 10));
1116 // drag out of bounds
1117 QTest::mouseMove(window, QPoint(50, 50));
1118 QTest::mouseMove(window, QPoint(100, 100));
1119 QTest::mouseMove(window, QPoint(150, 150));
1121 QVERIFY(flickable->contentX() != 0);
1122 QVERIFY(flickable->contentY() != 0);
1123 QVERIFY(flickable->isMoving());
1124 QVERIFY(flickable->isDragging());
1126 // grabbing mouse will cancel flickable interaction.
1127 QQuickItem *item = window->rootObject()->findChild<QQuickItem*>("row");
1130 QTRY_COMPARE(flickable->contentX(), 0.);
1131 QTRY_COMPARE(flickable->contentY(), 0.);
1132 QTRY_VERIFY(!flickable->isMoving());
1133 QTRY_VERIFY(!flickable->isDragging());
1135 QTest::mouseRelease(window, Qt::LeftButton, 0, QPoint(50, 10));
1138 void tst_qquickflickable::clickAndDragWhenTransformed()
1140 QQuickView *view = new QQuickView;
1141 view->setSource(testFileUrl("transformedFlickable.qml"));
1143 view->requestActivateWindow();
1144 QTest::qWaitForWindowShown(view);
1145 QVERIFY(view->rootObject() != 0);
1147 QQuickFlickable *flickable = view->rootObject()->findChild<QQuickFlickable*>("flickable");
1148 QVERIFY(flickable != 0);
1150 // click outside child rect
1151 QTest::mousePress(view, Qt::LeftButton, 0, QPoint(190, 190));
1153 QCOMPARE(flickable->property("itemPressed").toBool(), false);
1154 QTest::mouseRelease(view, Qt::LeftButton, 0, QPoint(190, 190));
1156 // click inside child rect
1157 QTest::mousePress(view, Qt::LeftButton, 0, QPoint(200, 200));
1159 QCOMPARE(flickable->property("itemPressed").toBool(), true);
1160 QTest::mouseRelease(view, Qt::LeftButton, 0, QPoint(200, 200));
1162 const int threshold = qApp->styleHints()->startDragDistance();
1164 // drag outside bounds
1165 QTest::mousePress(view, Qt::LeftButton, 0, QPoint(160, 160));
1167 QTest::mouseMove(view, QPoint(160 + threshold * 2, 160));
1168 QTest::mouseMove(view, QPoint(160 + threshold * 3, 160));
1169 QCOMPARE(flickable->isDragging(), false);
1170 QCOMPARE(flickable->property("itemPressed").toBool(), false);
1171 QTest::mouseRelease(view, Qt::LeftButton, 0, QPoint(180, 160));
1173 // drag inside bounds
1174 QTest::mousePress(view, Qt::LeftButton, 0, QPoint(200, 140));
1176 QTest::mouseMove(view, QPoint(200 + threshold * 2, 140));
1177 QTest::mouseMove(view, QPoint(200 + threshold * 3, 140));
1178 QCOMPARE(flickable->isDragging(), true);
1179 QCOMPARE(flickable->property("itemPressed").toBool(), false);
1180 QTest::mouseRelease(view, Qt::LeftButton, 0, QPoint(220, 140));
1185 QTEST_MAIN(tst_qquickflickable)
1187 #include "tst_qquickflickable.moc"