1 /****************************************************************************
3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the test suite of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
42 #include <QtTest/QSignalSpy>
43 #include <QtDeclarative/qdeclarativeengine.h>
44 #include <QtDeclarative/qdeclarativecomponent.h>
45 #include <QtDeclarative/qsgview.h>
46 #include <private/qsgflickable_p.h>
47 #include <private/qdeclarativevaluetype_p.h>
49 #include "../../../shared/util.h"
50 #include <QtOpenGL/QGLShaderProgram>
53 // In Symbian OS test data is located in applications private dir
57 class tst_qsgflickable : public QObject
65 void cleanupTestCase();
68 void horizontalViewportSize();
69 void verticalViewportSize();
71 void boundsBehavior();
72 void maximumFlickVelocity();
73 void flickDeceleration();
75 void nestedPressDelay();
76 void flickableDirection();
78 void returnToBounds();
80 void movingAndDragging();
86 QDeclarativeEngine engine;
88 void flick(QSGView *canvas, const QPoint &from, const QPoint &to, int duration);
90 T *findItem(QSGItem *parent, const QString &objectName);
93 tst_qsgflickable::tst_qsgflickable()
97 void tst_qsgflickable::initTestCase()
102 void tst_qsgflickable::cleanupTestCase()
107 void tst_qsgflickable::create()
109 QDeclarativeEngine engine;
110 QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable01.qml"));
111 QSGFlickable *obj = qobject_cast<QSGFlickable*>(c.create());
114 QCOMPARE(obj->isAtXBeginning(), true);
115 QCOMPARE(obj->isAtXEnd(), false);
116 QCOMPARE(obj->isAtYBeginning(), true);
117 QCOMPARE(obj->isAtYEnd(), false);
118 QCOMPARE(obj->contentX(), 0.);
119 QCOMPARE(obj->contentY(), 0.);
121 QCOMPARE(obj->horizontalVelocity(), 0.);
122 QCOMPARE(obj->verticalVelocity(), 0.);
124 QCOMPARE(obj->isInteractive(), true);
125 QCOMPARE(obj->boundsBehavior(), QSGFlickable::DragAndOvershootBounds);
126 QCOMPARE(obj->pressDelay(), 0);
127 QCOMPARE(obj->maximumFlickVelocity(), 2500.);
132 void tst_qsgflickable::horizontalViewportSize()
134 QDeclarativeEngine engine;
135 QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable02.qml"));
136 QSGFlickable *obj = qobject_cast<QSGFlickable*>(c.create());
139 QCOMPARE(obj->contentWidth(), 800.);
140 QCOMPARE(obj->contentHeight(), 300.);
141 QCOMPARE(obj->isAtXBeginning(), true);
142 QCOMPARE(obj->isAtXEnd(), false);
143 QCOMPARE(obj->isAtYBeginning(), true);
144 QCOMPARE(obj->isAtYEnd(), false);
149 void tst_qsgflickable::verticalViewportSize()
151 QDeclarativeEngine engine;
152 QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable03.qml"));
153 QSGFlickable *obj = qobject_cast<QSGFlickable*>(c.create());
156 QCOMPARE(obj->contentWidth(), 200.);
157 QCOMPARE(obj->contentHeight(), 1200.);
158 QCOMPARE(obj->isAtXBeginning(), true);
159 QCOMPARE(obj->isAtXEnd(), false);
160 QCOMPARE(obj->isAtYBeginning(), true);
161 QCOMPARE(obj->isAtYEnd(), false);
166 void tst_qsgflickable::properties()
168 QDeclarativeEngine engine;
169 QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable04.qml"));
170 QSGFlickable *obj = qobject_cast<QSGFlickable*>(c.create());
173 QCOMPARE(obj->isInteractive(), false);
174 QCOMPARE(obj->boundsBehavior(), QSGFlickable::StopAtBounds);
175 QCOMPARE(obj->pressDelay(), 200);
176 QCOMPARE(obj->maximumFlickVelocity(), 2000.);
178 QVERIFY(obj->property("ok").toBool() == false);
179 QMetaObject::invokeMethod(obj, "check");
180 QVERIFY(obj->property("ok").toBool() == true);
185 void tst_qsgflickable::boundsBehavior()
187 QDeclarativeComponent component(&engine);
188 component.setData("import QtQuick 2.0; Flickable { boundsBehavior: Flickable.StopAtBounds }", QUrl::fromLocalFile(""));
189 QSGFlickable *flickable = qobject_cast<QSGFlickable*>(component.create());
190 QSignalSpy spy(flickable, SIGNAL(boundsBehaviorChanged()));
193 QVERIFY(flickable->boundsBehavior() == QSGFlickable::StopAtBounds);
195 flickable->setBoundsBehavior(QSGFlickable::DragAndOvershootBounds);
196 QVERIFY(flickable->boundsBehavior() == QSGFlickable::DragAndOvershootBounds);
197 QCOMPARE(spy.count(),1);
198 flickable->setBoundsBehavior(QSGFlickable::DragAndOvershootBounds);
199 QCOMPARE(spy.count(),1);
201 flickable->setBoundsBehavior(QSGFlickable::DragOverBounds);
202 QVERIFY(flickable->boundsBehavior() == QSGFlickable::DragOverBounds);
203 QCOMPARE(spy.count(),2);
204 flickable->setBoundsBehavior(QSGFlickable::DragOverBounds);
205 QCOMPARE(spy.count(),2);
207 flickable->setBoundsBehavior(QSGFlickable::StopAtBounds);
208 QVERIFY(flickable->boundsBehavior() == QSGFlickable::StopAtBounds);
209 QCOMPARE(spy.count(),3);
210 flickable->setBoundsBehavior(QSGFlickable::StopAtBounds);
211 QCOMPARE(spy.count(),3);
214 void tst_qsgflickable::maximumFlickVelocity()
216 QDeclarativeComponent component(&engine);
217 component.setData("import QtQuick 2.0; Flickable { maximumFlickVelocity: 1.0; }", QUrl::fromLocalFile(""));
218 QSGFlickable *flickable = qobject_cast<QSGFlickable*>(component.create());
219 QSignalSpy spy(flickable, SIGNAL(maximumFlickVelocityChanged()));
222 QCOMPARE(flickable->maximumFlickVelocity(), 1.0);
224 flickable->setMaximumFlickVelocity(2.0);
225 QCOMPARE(flickable->maximumFlickVelocity(), 2.0);
226 QCOMPARE(spy.count(),1);
227 flickable->setMaximumFlickVelocity(2.0);
228 QCOMPARE(spy.count(),1);
231 void tst_qsgflickable::flickDeceleration()
233 QDeclarativeComponent component(&engine);
234 component.setData("import QtQuick 2.0; Flickable { flickDeceleration: 1.0; }", QUrl::fromLocalFile(""));
235 QSGFlickable *flickable = qobject_cast<QSGFlickable*>(component.create());
236 QSignalSpy spy(flickable, SIGNAL(flickDecelerationChanged()));
239 QCOMPARE(flickable->flickDeceleration(), 1.0);
241 flickable->setFlickDeceleration(2.0);
242 QCOMPARE(flickable->flickDeceleration(), 2.0);
243 QCOMPARE(spy.count(),1);
244 flickable->setFlickDeceleration(2.0);
245 QCOMPARE(spy.count(),1);
248 void tst_qsgflickable::pressDelay()
250 QDeclarativeComponent component(&engine);
251 component.setData("import QtQuick 2.0; Flickable { pressDelay: 100; }", QUrl::fromLocalFile(""));
252 QSGFlickable *flickable = qobject_cast<QSGFlickable*>(component.create());
253 QSignalSpy spy(flickable, SIGNAL(pressDelayChanged()));
256 QCOMPARE(flickable->pressDelay(), 100);
258 flickable->setPressDelay(200);
259 QCOMPARE(flickable->pressDelay(), 200);
260 QCOMPARE(spy.count(),1);
261 flickable->setPressDelay(200);
262 QCOMPARE(spy.count(),1);
266 void tst_qsgflickable::nestedPressDelay()
268 QSGView *canvas = new QSGView;
269 canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/nestedPressDelay.qml"));
271 canvas->requestActivateWindow();
272 QVERIFY(canvas->rootObject() != 0);
274 QSGFlickable *outer = qobject_cast<QSGFlickable*>(canvas->rootObject());
277 QSGFlickable *inner = canvas->rootObject()->findChild<QSGFlickable*>("innerFlickable");
280 QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(150, 150));
281 // the MouseArea is not pressed immediately
282 QVERIFY(outer->property("pressed").toBool() == false);
284 // The outer pressDelay will prevail (50ms, vs. 10sec)
285 // QTRY_VERIFY() has 5sec timeout, so will timeout well within 10sec.
286 QTRY_VERIFY(outer->property("pressed").toBool() == true);
288 QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(150, 150));
293 void tst_qsgflickable::flickableDirection()
295 QDeclarativeComponent component(&engine);
296 component.setData("import QtQuick 2.0; Flickable { flickableDirection: Flickable.VerticalFlick; }", QUrl::fromLocalFile(""));
297 QSGFlickable *flickable = qobject_cast<QSGFlickable*>(component.create());
298 QSignalSpy spy(flickable, SIGNAL(flickableDirectionChanged()));
301 QCOMPARE(flickable->flickableDirection(), QSGFlickable::VerticalFlick);
303 flickable->setFlickableDirection(QSGFlickable::HorizontalAndVerticalFlick);
304 QCOMPARE(flickable->flickableDirection(), QSGFlickable::HorizontalAndVerticalFlick);
305 QCOMPARE(spy.count(),1);
307 flickable->setFlickableDirection(QSGFlickable::AutoFlickDirection);
308 QCOMPARE(flickable->flickableDirection(), QSGFlickable::AutoFlickDirection);
309 QCOMPARE(spy.count(),2);
311 flickable->setFlickableDirection(QSGFlickable::HorizontalFlick);
312 QCOMPARE(flickable->flickableDirection(), QSGFlickable::HorizontalFlick);
313 QCOMPARE(spy.count(),3);
315 flickable->setFlickableDirection(QSGFlickable::HorizontalFlick);
316 QCOMPARE(flickable->flickableDirection(), QSGFlickable::HorizontalFlick);
317 QCOMPARE(spy.count(),3);
321 void tst_qsgflickable::resizeContent()
323 QDeclarativeEngine engine;
324 QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/resize.qml"));
325 QSGItem *root = qobject_cast<QSGItem*>(c.create());
326 QSGFlickable *obj = findItem<QSGFlickable>(root, "flick");
329 QCOMPARE(obj->contentX(), 0.);
330 QCOMPARE(obj->contentY(), 0.);
331 QCOMPARE(obj->contentWidth(), 300.);
332 QCOMPARE(obj->contentHeight(), 300.);
334 QMetaObject::invokeMethod(root, "resizeContent");
336 QCOMPARE(obj->contentX(), 100.);
337 QCOMPARE(obj->contentY(), 100.);
338 QCOMPARE(obj->contentWidth(), 600.);
339 QCOMPARE(obj->contentHeight(), 600.);
345 void tst_qsgflickable::returnToBounds()
347 QDeclarativeEngine engine;
348 QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/resize.qml"));
349 QSGItem *root = qobject_cast<QSGItem*>(c.create());
350 QSGFlickable *obj = findItem<QSGFlickable>(root, "flick");
353 QCOMPARE(obj->contentX(), 0.);
354 QCOMPARE(obj->contentY(), 0.);
355 QCOMPARE(obj->contentWidth(), 300.);
356 QCOMPARE(obj->contentHeight(), 300.);
358 obj->setContentX(100);
359 obj->setContentY(400);
360 QTRY_COMPARE(obj->contentX(), 100.);
361 QTRY_COMPARE(obj->contentY(), 400.);
363 QMetaObject::invokeMethod(root, "returnToBounds");
365 QTRY_COMPARE(obj->contentX(), 0.);
366 QTRY_COMPARE(obj->contentY(), 0.);
371 void tst_qsgflickable::wheel()
373 QSGView *canvas = new QSGView;
374 canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/wheel.qml"));
376 canvas->requestActivateWindow();
377 QVERIFY(canvas->rootObject() != 0);
379 QSGFlickable *flick = canvas->rootObject()->findChild<QSGFlickable*>("flick");
383 QWheelEvent event(QPoint(200, 200), -120, Qt::NoButton, Qt::NoModifier, Qt::Vertical);
384 event.setAccepted(false);
385 QApplication::sendEvent(canvas, &event);
388 QTRY_VERIFY(flick->contentY() > 0);
389 QVERIFY(flick->contentX() == 0);
391 flick->setContentY(0);
392 QVERIFY(flick->contentY() == 0);
395 QWheelEvent event(QPoint(200, 200), -120, Qt::NoButton, Qt::NoModifier, Qt::Horizontal);
396 event.setAccepted(false);
397 QApplication::sendEvent(canvas, &event);
400 QTRY_VERIFY(flick->contentX() > 0);
401 QVERIFY(flick->contentY() == 0);
406 void tst_qsgflickable::movingAndDragging()
408 QSGView *canvas = new QSGView;
409 canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/flickable03.qml"));
411 canvas->requestActivateWindow();
412 QTest::qWaitForWindowShown(canvas);
413 QVERIFY(canvas->rootObject() != 0);
415 QSGFlickable *flickable = qobject_cast<QSGFlickable*>(canvas->rootObject());
416 QVERIFY(flickable != 0);
418 QSignalSpy vDragSpy(flickable, SIGNAL(draggingVerticallyChanged()));
419 QSignalSpy hDragSpy(flickable, SIGNAL(draggingHorizontallyChanged()));
420 QSignalSpy dragSpy(flickable, SIGNAL(draggingChanged()));
421 QSignalSpy vMoveSpy(flickable, SIGNAL(movingVerticallyChanged()));
422 QSignalSpy hMoveSpy(flickable, SIGNAL(movingHorizontallyChanged()));
423 QSignalSpy moveSpy(flickable, SIGNAL(movingChanged()));
424 QSignalSpy dragStartSpy(flickable, SIGNAL(dragStarted()));
425 QSignalSpy dragEndSpy(flickable, SIGNAL(dragEnded()));
428 QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 90));
430 QTest::mouseMove(canvas, QPoint(50, 80));
431 QTest::mouseMove(canvas, QPoint(50, 70));
432 QTest::mouseMove(canvas, QPoint(50, 60));
434 QMouseEvent moveEvent(QEvent::MouseMove, QPoint(50, 80), Qt::LeftButton, Qt::LeftButton, 0);
436 QVERIFY(!flickable->isDraggingHorizontally());
437 QVERIFY(flickable->isDraggingVertically());
438 QVERIFY(flickable->isDragging());
439 QCOMPARE(vDragSpy.count(), 1);
440 QCOMPARE(dragSpy.count(), 1);
441 QCOMPARE(hDragSpy.count(), 0);
442 QCOMPARE(dragStartSpy.count(), 1);
443 QCOMPARE(dragEndSpy.count(), 0);
445 QVERIFY(!flickable->isMovingHorizontally());
446 QVERIFY(flickable->isMovingVertically());
447 QVERIFY(flickable->isMoving());
448 QCOMPARE(vMoveSpy.count(), 1);
449 QCOMPARE(moveSpy.count(), 1);
450 QCOMPARE(hMoveSpy.count(), 0);
452 QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 60));
454 QTRY_VERIFY(!flickable->isDraggingVertically());
455 QVERIFY(!flickable->isDragging());
456 QCOMPARE(vDragSpy.count(), 2);
457 QCOMPARE(dragSpy.count(), 2);
458 QCOMPARE(hDragSpy.count(), 0);
459 QCOMPARE(dragStartSpy.count(), 1);
460 QCOMPARE(dragEndSpy.count(), 1);
462 // wait for any motion to end
463 QTRY_VERIFY(flickable->isMoving() == false);
472 dragStartSpy.clear();
475 QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(90, 50));
477 QTest::mouseMove(canvas, QPoint(80, 50));
478 QTest::mouseMove(canvas, QPoint(70, 50));
479 QTest::mouseMove(canvas, QPoint(60, 50));
481 QVERIFY(flickable->isDraggingHorizontally());
482 QVERIFY(flickable->isDragging());
483 QCOMPARE(vDragSpy.count(), 0);
484 QCOMPARE(dragSpy.count(), 1);
485 QCOMPARE(hDragSpy.count(), 1);
486 QCOMPARE(dragStartSpy.count(), 1);
487 QCOMPARE(dragEndSpy.count(), 0);
489 QVERIFY(!flickable->isMovingVertically());
490 QVERIFY(flickable->isMovingHorizontally());
491 QVERIFY(flickable->isMoving());
492 QCOMPARE(vMoveSpy.count(), 0);
493 QCOMPARE(moveSpy.count(), 1);
494 QCOMPARE(hMoveSpy.count(), 1);
496 QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(60, 50));
498 QTRY_VERIFY(!flickable->isDraggingHorizontally());
499 QVERIFY(!flickable->isDragging());
500 QCOMPARE(vDragSpy.count(), 0);
501 QCOMPARE(dragSpy.count(), 2);
502 QCOMPARE(hDragSpy.count(), 2);
503 QCOMPARE(dragStartSpy.count(), 1);
504 QCOMPARE(dragEndSpy.count(), 1);
506 // Don't test moving because a flick could occur
511 void tst_qsgflickable::disabled()
513 QSGView *canvas = new QSGView;
514 canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/disabled.qml"));
516 canvas->requestActivateWindow();
517 QVERIFY(canvas->rootObject() != 0);
519 QSGFlickable *flick = canvas->rootObject()->findChild<QSGFlickable*>("flickable");
522 QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 90));
524 QTest::mouseMove(canvas, QPoint(50, 80));
525 QTest::mouseMove(canvas, QPoint(50, 70));
526 QTest::mouseMove(canvas, QPoint(50, 60));
528 QVERIFY(flick->isMoving() == false);
530 QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 60));
532 // verify that mouse clicks on other elements still work (QTBUG-20584)
533 QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(50, 10));
534 QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 10));
536 QTRY_VERIFY(canvas->rootObject()->property("clicked").toBool() == true);
539 void tst_qsgflickable::flickVelocity()
542 QSKIP("Producing flicks on Mac CI impossible due to timing problems", SkipAll);
545 QSGView *canvas = new QSGView;
546 canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/flickable03.qml"));
548 canvas->requestActivateWindow();
549 QVERIFY(canvas->rootObject() != 0);
551 QSGFlickable *flickable = qobject_cast<QSGFlickable*>(canvas->rootObject());
552 QVERIFY(flickable != 0);
555 flick(canvas, QPoint(20,190), QPoint(20, 50), 200);
556 QVERIFY(flickable->verticalVelocity() > 0.0);
557 QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
560 flick(canvas, QPoint(20,10), QPoint(20, 140), 200);
561 QVERIFY(flickable->verticalVelocity() < 0.0);
562 QTRY_VERIFY(flickable->verticalVelocity() == 0.0);
567 void tst_qsgflickable::margins()
569 QDeclarativeEngine engine;
570 QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/margins.qml"));
571 QSGItem *root = qobject_cast<QSGItem*>(c.create());
572 QSGFlickable *obj = qobject_cast<QSGFlickable*>(root);
576 QCOMPARE(obj->contentX(), -40.);
577 QCOMPARE(obj->contentY(), -20.);
578 QCOMPARE(obj->contentWidth(), 1600.);
579 QCOMPARE(obj->contentHeight(), 600.);
580 QCOMPARE(obj->xOrigin(), 0.);
581 QCOMPARE(obj->yOrigin(), 0.);
583 // Reduce left margin
584 obj->setLeftMargin(30);
585 QTRY_COMPARE(obj->contentX(), -30.);
588 obj->setTopMargin(20);
589 QTRY_COMPARE(obj->contentY(), -20.);
591 // position to the far right, including margin
592 obj->setContentX(1600 + 50 - obj->width());
593 obj->returnToBounds();
595 QCOMPARE(obj->contentX(), 1600. + 50. - obj->width());
597 // position beyond the far right, including margin
598 obj->setContentX(1600 + 50 - obj->width() + 1.);
599 obj->returnToBounds();
600 QTRY_COMPARE(obj->contentX(), 1600. + 50. - obj->width());
602 // Reduce right margin
603 obj->setRightMargin(40);
604 QTRY_COMPARE(obj->contentX(), 1600. + 40. - obj->width());
605 QCOMPARE(obj->contentWidth(), 1600.);
607 // position to the far bottom, including margin
608 obj->setContentY(600 + 30 - obj->height());
609 obj->returnToBounds();
611 QCOMPARE(obj->contentY(), 600. + 30. - obj->height());
613 // position beyond the far bottom, including margin
614 obj->setContentY(600 + 30 - obj->height() + 1.);
615 obj->returnToBounds();
616 QTRY_COMPARE(obj->contentY(), 600. + 30. - obj->height());
618 // Reduce bottom margin
619 obj->setBottomMargin(20);
620 QTRY_COMPARE(obj->contentY(), 600. + 20. - obj->height());
621 QCOMPARE(obj->contentHeight(), 600.);
626 void tst_qsgflickable::flick(QSGView *canvas, const QPoint &from, const QPoint &to, int duration)
628 const int pointCount = 5;
629 QPoint diff = to - from;
631 // send press, five equally spaced moves, and release.
632 QTest::mousePress(canvas, Qt::LeftButton, 0, from);
634 for (int i = 0; i < pointCount; ++i) {
635 QMouseEvent mv(QEvent::MouseMove, from + (i+1)*diff/pointCount, Qt::LeftButton, Qt::LeftButton,Qt::NoModifier);
636 QApplication::sendEvent(canvas, &mv);
637 QTest::qWait(duration/pointCount);
638 QCoreApplication::processEvents();
641 QTest::mouseRelease(canvas, Qt::LeftButton, 0, to);
645 T *tst_qsgflickable::findItem(QSGItem *parent, const QString &objectName)
647 const QMetaObject &mo = T::staticMetaObject;
648 //qDebug() << parent->childItems().count() << "children";
649 for (int i = 0; i < parent->childItems().count(); ++i) {
650 QSGItem *item = qobject_cast<QSGItem*>(parent->childItems().at(i));
653 //qDebug() << "try" << item;
654 if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) {
655 return static_cast<T*>(item);
657 item = findItem<T>(item, objectName);
659 return static_cast<T*>(item);
665 QTEST_MAIN(tst_qsgflickable)
667 #include "tst_qsgflickable.moc"