diff options
Diffstat (limited to 'tests/auto/qtquick2/qquickmousearea')
20 files changed, 0 insertions, 1270 deletions
diff --git a/tests/auto/qtquick2/qquickmousearea/data/clickThrough.qml b/tests/auto/qtquick2/qquickmousearea/data/clickThrough.qml deleted file mode 100644 index 3c03161faa..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/clickThrough.qml +++ /dev/null @@ -1,25 +0,0 @@ -import QtQuick 2.0 - -Item{ - width: 200 - height: 200 - property int doubleClicks: 0 - property int clicks: 0 - property int pressAndHolds: 0 - property int presses: 0 - MouseArea{ - z: 0 - anchors.fill: parent - propagateComposedEvents: true - onPressed: presses++ - onClicked: clicks++ - onPressAndHold: pressAndHolds++ - onDoubleClicked: doubleClicks++ - } - MouseArea{ - z: 1 - propagateComposedEvents: true - enabled: true - anchors.fill: parent - } -} diff --git a/tests/auto/qtquick2/qquickmousearea/data/clickThrough2.qml b/tests/auto/qtquick2/qquickmousearea/data/clickThrough2.qml deleted file mode 100644 index 2624108225..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/clickThrough2.qml +++ /dev/null @@ -1,35 +0,0 @@ -import QtQuick 2.0 - -Item{ - width: 300 - height: 300 - property int doubleClicks: 0 - property int clicks: 0 - property int pressAndHolds: 0 - property int presses: 0 - property bool letThrough: false - property bool noPropagation: false - Rectangle{ - z: 0 - color: "lightsteelblue" - width: 150 - height: 150 - MouseArea{ - anchors.fill: parent - propagateComposedEvents: true - onPressed: presses++ - onClicked: clicks++ - onPressAndHold: pressAndHolds++ - onDoubleClicked: doubleClicks++ - } - } - MouseArea{ - z: 1 - enabled: true - anchors.fill: parent - propagateComposedEvents: !noPropagation - onClicked: mouse.accepted = !letThrough; - onDoubleClicked: mouse.accepted = !letThrough; - onPressAndHold: mouse.accepted = !letThrough; - } -} diff --git a/tests/auto/qtquick2/qquickmousearea/data/clickandhold.qml b/tests/auto/qtquick2/qquickmousearea/data/clickandhold.qml deleted file mode 100644 index 5e4e48f6db..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/clickandhold.qml +++ /dev/null @@ -1,13 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - property bool clicked: false - property bool held: false - - MouseArea { - width: 200; height: 200 - onClicked: { root.clicked = true } - onPressAndHold: { root.held = true } - } -} diff --git a/tests/auto/qtquick2/qquickmousearea/data/clicktwice.qml b/tests/auto/qtquick2/qquickmousearea/data/clicktwice.qml deleted file mode 100644 index 002d1b9047..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/clicktwice.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - property int clicked: 0 - property int pressed: 0 - property int released: 0 - - MouseArea { - width: 200; height: 200 - onPressed: { root.pressed++ } - onClicked: { root.clicked++ } - onReleased: { root.released++ } - } -} - diff --git a/tests/auto/qtquick2/qquickmousearea/data/doubleclick.qml b/tests/auto/qtquick2/qquickmousearea/data/doubleclick.qml deleted file mode 100644 index 1030d0c33e..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/doubleclick.qml +++ /dev/null @@ -1,16 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - property int clicked: 0 - property int doubleClicked: 0 - property int released: 0 - - MouseArea { - width: 200; height: 200 - onClicked: { root.clicked++ } - onDoubleClicked: { root.doubleClicked++ } - onReleased: { root.released++ } - } -} - diff --git a/tests/auto/qtquick2/qquickmousearea/data/dragging.qml b/tests/auto/qtquick2/qquickmousearea/data/dragging.qml deleted file mode 100644 index d9b6ac4083..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/dragging.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 2.0 -Rectangle { - id: whiteRect - width: 200 - height: 200 - color: "white" - Rectangle { - id: blackRect - objectName: "blackrect" - color: "black" - y: 50 - x: 50 - width: 100 - height: 100 - opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200 - Text { text: blackRect.opacity} - MouseArea { - objectName: "mouseregion" - anchors.fill: parent - drag.target: blackRect - drag.axis: Drag.XandYAxis - drag.minimumX: 0 - drag.maximumX: whiteRect.width-blackRect.width - drag.minimumY: 0 - drag.maximumY: whiteRect.height-blackRect.height - } - } - } diff --git a/tests/auto/qtquick2/qquickmousearea/data/dragproperties.qml b/tests/auto/qtquick2/qquickmousearea/data/dragproperties.qml deleted file mode 100644 index 421dfe26b7..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/dragproperties.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 2.0 -Rectangle { - id: whiteRect - width: 200 - height: 200 - color: "white" - Rectangle { - id: blackRect - objectName: "blackrect" - color: "black" - y: 50 - x: 50 - width: 100 - height: 100 - opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200 - Text { text: blackRect.opacity} - MouseArea { - objectName: "mouseregion" - anchors.fill: parent - drag.target: blackRect - drag.axis: Drag.XandYAxis - drag.minimumX: 0 - drag.maximumX: whiteRect.width-blackRect.width - drag.minimumY: 0 - drag.maximumY: whiteRect.height-blackRect.height - } - } - } diff --git a/tests/auto/qtquick2/qquickmousearea/data/dragreset.qml b/tests/auto/qtquick2/qquickmousearea/data/dragreset.qml deleted file mode 100644 index d7949f9139..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/dragreset.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 2.0 -Rectangle { - id: whiteRect - width: 200 - height: 200 - color: "white" - Rectangle { - id: blackRect - objectName: "blackrect" - color: "black" - y: 50 - x: 50 - width: 100 - height: 100 - opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200 - Text { text: blackRect.opacity} - MouseArea { - objectName: "mouseregion" - anchors.fill: parent - drag.target: haveTarget ? blackRect : undefined - drag.axis: Drag.XandYAxis - drag.minimumX: 0 - drag.maximumX: whiteRect.width-blackRect.width - drag.minimumY: 0 - drag.maximumY: whiteRect.height-blackRect.height - } - } - } diff --git a/tests/auto/qtquick2/qquickmousearea/data/hoverPosition.qml b/tests/auto/qtquick2/qquickmousearea/data/hoverPosition.qml deleted file mode 100644 index 834f91ff29..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/hoverPosition.qml +++ /dev/null @@ -1,17 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400; height: 400; - - property real mouseX: mousetracker.mouseX - property real mouseY: mousetracker.mouseY - - Rectangle { - width: 100; height: 100; - MouseArea { - id: mousetracker; - anchors.fill: parent; - hoverEnabled: true - } - } -} diff --git a/tests/auto/qtquick2/qquickmousearea/data/hoverPropagation.qml b/tests/auto/qtquick2/qquickmousearea/data/hoverPropagation.qml deleted file mode 100644 index c47c794132..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/hoverPropagation.qml +++ /dev/null @@ -1,54 +0,0 @@ -import QtQuick 2.0 - -Item{ - width: 400 - height: 200 - property bool point1: ma2.containsMouse && !ma1.containsMouse - property bool point2: ma3.containsMouse && ma4.containsMouse - Rectangle{ - width: 200 - height: 200 - color: ma1.containsMouse ? "red" : "white" - MouseArea{ - id: ma1 - hoverEnabled: true - anchors.fill: parent - } - Rectangle{ - width: 100 - height: 100 - color: ma2.containsMouse ? "blue" : "white" - MouseArea{ - id: ma2 - hoverEnabled: true - anchors.fill: parent - } - } - } - - Item{ - x:200 - Rectangle{ - width: 200 - height: 200 - color: ma3.containsMouse ? "yellow" : "white" - Rectangle{ - width: 100 - height: 100 - color: ma4.containsMouse ? "green" : "white" - } - } - MouseArea{ - id: ma3 - hoverEnabled: true - width: 200 - height: 200 - MouseArea{ - id: ma4 - width: 100 - height: 100 - hoverEnabled: true - } - } - } -} diff --git a/tests/auto/qtquick2/qquickmousearea/data/hoverVisible.qml b/tests/auto/qtquick2/qquickmousearea/data/hoverVisible.qml deleted file mode 100644 index 2d65b5573e..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/hoverVisible.qml +++ /dev/null @@ -1,15 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - width: 400; height: 400; - - Rectangle { - width: 100; height: 100; - MouseArea { - id: mousetracker; objectName: "mousetracker" - anchors.fill: parent - visible: false - hoverEnabled: true - } - } -} diff --git a/tests/auto/qtquick2/qquickmousearea/data/noclickandhold.qml b/tests/auto/qtquick2/qquickmousearea/data/noclickandhold.qml deleted file mode 100644 index 6647de001d..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/noclickandhold.qml +++ /dev/null @@ -1,11 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - property bool clicked: false - - MouseArea { - width: 200; height: 200 - onClicked: { root.clicked = true } - } -} diff --git a/tests/auto/qtquick2/qquickmousearea/data/pressedCanceled.qml b/tests/auto/qtquick2/qquickmousearea/data/pressedCanceled.qml deleted file mode 100644 index 231436d0f2..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/pressedCanceled.qml +++ /dev/null @@ -1,18 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: root - color: "#ffffff" - width: 320; height: 240 - property bool pressed:mouse.pressed - property bool canceled: false - property bool released: false - - MouseArea { - id: mouse - anchors.fill: parent - onPressed: { root.canceled = false } - onCanceled: {root.canceled = true} - onReleased: {root.released = true; root.canceled = false} - } -}
\ No newline at end of file diff --git a/tests/auto/qtquick2/qquickmousearea/data/pressedOrdering.qml b/tests/auto/qtquick2/qquickmousearea/data/pressedOrdering.qml deleted file mode 100644 index 7aa3098100..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/pressedOrdering.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 2.0 - -Item { - id: root - property string value: "base" - - MouseArea { - id: mouseArea - width: 200; height: 200 - onClicked: toggleState.state = "toggled" - } - - StateGroup { - states: State { - name: "pressed" - when: mouseArea.pressed - PropertyChanges { target: root; value: "pressed" } - } - } - - StateGroup { - id: toggleState - states: State { - name: "toggled" - PropertyChanges { target: root; value: "toggled" } - } - } -} diff --git a/tests/auto/qtquick2/qquickmousearea/data/preventstealing.qml b/tests/auto/qtquick2/qquickmousearea/data/preventstealing.qml deleted file mode 100644 index fb0d6955c1..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/preventstealing.qml +++ /dev/null @@ -1,24 +0,0 @@ -import QtQuick 2.0 - -Flickable { - property bool stealing: true - width: 200 - height: 200 - contentWidth: 400 - contentHeight: 400 - Rectangle { - color: "black" - width: 400 - height: 400 - Rectangle { - x: 50; y: 50 - width: 100; height: 100 - color: "steelblue" - MouseArea { - objectName: "mousearea" - anchors.fill: parent - preventStealing: stealing - } - } - } -} diff --git a/tests/auto/qtquick2/qquickmousearea/data/rejectEvent.qml b/tests/auto/qtquick2/qquickmousearea/data/rejectEvent.qml deleted file mode 100644 index 816fc76fac..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/rejectEvent.qml +++ /dev/null @@ -1,28 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - id: root - color: "#ffffff" - width: 320; height: 240 - property bool mr1_pressed: false - property bool mr1_released: false - property bool mr1_canceled: false - property bool mr2_pressed: false - property bool mr2_released: false - property bool mr2_canceled: false - - MouseArea { - id: mouseRegion1 - anchors.fill: parent - onPressed: { root.mr1_pressed = true } - onReleased: { root.mr1_released = true } - onCanceled: { root.mr1_canceled = true } - } - MouseArea { - id: mouseRegion2 - width: 120; height: 120 - onPressed: { root.mr2_pressed = true; mouse.accepted = false } - onReleased: { root.mr2_released = true } - onCanceled: { root.mr2_canceled = true } - } -} diff --git a/tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnClick.qml b/tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnClick.qml deleted file mode 100644 index 7377a2e86c..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnClick.qml +++ /dev/null @@ -1,20 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - color: "#ffffff" - width: 320; height: 240 - MouseArea { - id: mouseRegion - objectName: "mouseregion" - anchors.fill: parent - Rectangle { - id: ball - objectName: "ball" - width: 20; height: 20 - radius: 10 - color: "#0000ff" - x: { mouseRegion.mouseX } - y: mouseRegion.mouseY - } - } -} diff --git a/tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnResize.qml b/tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnResize.qml deleted file mode 100644 index 55af864060..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/data/updateMousePosOnResize.qml +++ /dev/null @@ -1,43 +0,0 @@ -import QtQuick 2.0 - -Rectangle { - color: "#ffffff" - width: 320; height: 240 - Rectangle { - id: brother - objectName: "brother" - color: "lightgreen" - x: 200; y: 100 - width: 120; height: 120 - } - MouseArea { - id: mouseRegion - objectName: "mouseregion" - - property int x1 - property int y1 - property int x2 - property int y2 - property bool emitPositionChanged: false - property bool mouseMatchesPos: true - - anchors.fill: brother - onPressed: { - if (mouse.x != mouseX || mouse.y != mouseY) - mouseMatchesPos = false - x1 = mouseX; y1 = mouseY - anchors.fill = parent - } - onPositionChanged: { emitPositionChanged = true } - onMouseXChanged: { - if (mouse.x != mouseX || mouse.y != mouseY) - mouseMatchesPos = false - x2 = mouseX; y2 = mouseY - } - onMouseYChanged: { - if (mouse.x != mouseX || mouse.y != mouseY) - mouseMatchesPos = false - x2 = mouseX; y2 = mouseY - } - } -} diff --git a/tests/auto/qtquick2/qquickmousearea/qquickmousearea.pro b/tests/auto/qtquick2/qquickmousearea/qquickmousearea.pro deleted file mode 100644 index 67d77dc05a..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/qquickmousearea.pro +++ /dev/null @@ -1,17 +0,0 @@ -CONFIG += testcase -TARGET = tst_qquickmousearea -macx:CONFIG -= app_bundle - -HEADERS += ../../shared/testhttpserver.h -SOURCES += tst_qquickmousearea.cpp \ - ../../shared/testhttpserver.cpp - -include (../../shared/util.pri) - -testDataFiles.files = data -testDataFiles.path = . -DEPLOYMENT += testDataFiles - -CONFIG += parallel_test - -QT += core-private gui-private declarative-private quick-private network testlib diff --git a/tests/auto/qtquick2/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/qtquick2/qquickmousearea/tst_qquickmousearea.cpp deleted file mode 100644 index 66f651329a..0000000000 --- a/tests/auto/qtquick2/qquickmousearea/tst_qquickmousearea.cpp +++ /dev/null @@ -1,806 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtTest/QtTest> -#include <QtTest/QSignalSpy> -#include <QtQuick/private/qquickmousearea_p.h> -#include <QtQuick/private/qquickrectangle_p.h> -#include <private/qquickflickable_p.h> -#include <QtQuick/qquickview.h> -#include <QtDeclarative/qdeclarativecontext.h> -#include <QtDeclarative/qdeclarativeengine.h> -#include <QtOpenGL/QGLShaderProgram> -#include "../../shared/util.h" - -//#define OLDWAY - -class tst_QQuickMouseArea: public QDeclarativeDataTest -{ - Q_OBJECT -private slots: - void dragProperties(); - void resetDrag(); - void dragging(); - void updateMouseAreaPosOnClick(); - void updateMouseAreaPosOnResize(); - void noOnClickedWithPressAndHold(); - void onMousePressRejected(); - void pressedCanceledOnWindowDeactivate(); - void doubleClick(); - void clickTwice(); - void pressedOrdering(); - void preventStealing(); - void clickThrough(); - void hoverPosition(); - void hoverPropagation(); - void hoverVisible(); - -private: - QQuickView *createView(); -}; - -void tst_QQuickMouseArea::dragProperties() -{ - QQuickView *canvas = createView(); - - canvas->setSource(testFileUrl("dragproperties.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild<QQuickMouseArea*>("mouseregion"); - QQuickDrag *drag = mouseRegion->drag(); - QVERIFY(mouseRegion != 0); - QVERIFY(drag != 0); - - // target - QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect"); - QVERIFY(blackRect != 0); - QVERIFY(blackRect == drag->target()); - QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject()); - QVERIFY(rootItem != 0); - QSignalSpy targetSpy(drag, SIGNAL(targetChanged())); - drag->setTarget(rootItem); - QCOMPARE(targetSpy.count(),1); - drag->setTarget(rootItem); - QCOMPARE(targetSpy.count(),1); - - // axis - QCOMPARE(drag->axis(), QQuickDrag::XandYAxis); - QSignalSpy axisSpy(drag, SIGNAL(axisChanged())); - drag->setAxis(QQuickDrag::XAxis); - QCOMPARE(drag->axis(), QQuickDrag::XAxis); - QCOMPARE(axisSpy.count(),1); - drag->setAxis(QQuickDrag::XAxis); - QCOMPARE(axisSpy.count(),1); - - // minimum and maximum properties - QSignalSpy xminSpy(drag, SIGNAL(minimumXChanged())); - QSignalSpy xmaxSpy(drag, SIGNAL(maximumXChanged())); - QSignalSpy yminSpy(drag, SIGNAL(minimumYChanged())); - QSignalSpy ymaxSpy(drag, SIGNAL(maximumYChanged())); - - QCOMPARE(drag->xmin(), 0.0); - QCOMPARE(drag->xmax(), rootItem->width()-blackRect->width()); - QCOMPARE(drag->ymin(), 0.0); - QCOMPARE(drag->ymax(), rootItem->height()-blackRect->height()); - - drag->setXmin(10); - drag->setXmax(10); - drag->setYmin(10); - drag->setYmax(10); - - QCOMPARE(drag->xmin(), 10.0); - QCOMPARE(drag->xmax(), 10.0); - QCOMPARE(drag->ymin(), 10.0); - QCOMPARE(drag->ymax(), 10.0); - - QCOMPARE(xminSpy.count(),1); - QCOMPARE(xmaxSpy.count(),1); - QCOMPARE(yminSpy.count(),1); - QCOMPARE(ymaxSpy.count(),1); - - drag->setXmin(10); - drag->setXmax(10); - drag->setYmin(10); - drag->setYmax(10); - - QCOMPARE(xminSpy.count(),1); - QCOMPARE(xmaxSpy.count(),1); - QCOMPARE(yminSpy.count(),1); - QCOMPARE(ymaxSpy.count(),1); - - // filterChildren - QSignalSpy filterChildrenSpy(drag, SIGNAL(filterChildrenChanged())); - - drag->setFilterChildren(true); - - QVERIFY(drag->filterChildren()); - QCOMPARE(filterChildrenSpy.count(), 1); - - drag->setFilterChildren(true); - QCOMPARE(filterChildrenSpy.count(), 1); - - delete canvas; -} - -void tst_QQuickMouseArea::resetDrag() -{ - QQuickView *canvas = createView(); - - canvas->rootContext()->setContextProperty("haveTarget", QVariant(true)); - canvas->setSource(testFileUrl("dragreset.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild<QQuickMouseArea*>("mouseregion"); - QQuickDrag *drag = mouseRegion->drag(); - QVERIFY(mouseRegion != 0); - QVERIFY(drag != 0); - - // target - QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect"); - QVERIFY(blackRect != 0); - QVERIFY(blackRect == drag->target()); - QQuickItem *rootItem = qobject_cast<QQuickItem*>(canvas->rootObject()); - QVERIFY(rootItem != 0); - QSignalSpy targetSpy(drag, SIGNAL(targetChanged())); - QVERIFY(drag->target() != 0); - canvas->rootContext()->setContextProperty("haveTarget", QVariant(false)); - QCOMPARE(targetSpy.count(),1); - QVERIFY(drag->target() == 0); - - delete canvas; -} - - -void tst_QQuickMouseArea::dragging() -{ - QQuickView *canvas = createView(); - - canvas->setSource(testFileUrl("dragging.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QTest::qWait(20); - QVERIFY(canvas->rootObject() != 0); - - QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild<QQuickMouseArea*>("mouseregion"); - QQuickDrag *drag = mouseRegion->drag(); - QVERIFY(mouseRegion != 0); - QVERIFY(drag != 0); - - // target - QQuickItem *blackRect = canvas->rootObject()->findChild<QQuickItem*>("blackrect"); - QVERIFY(blackRect != 0); - QVERIFY(blackRect == drag->target()); - - QVERIFY(!drag->active()); - -#ifdef OLDWAY - QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &pressEvent); -#else - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); -#endif - - QVERIFY(!drag->active()); - QCOMPARE(blackRect->x(), 50.0); - QCOMPARE(blackRect->y(), 50.0); - - // First move event triggers drag, second is acted upon. - // This is due to possibility of higher stacked area taking precedence. - - QTest::mouseMove(canvas, QPoint(111,111)); - QTest::qWait(50); - QTest::mouseMove(canvas, QPoint(122,122)); - QTest::qWait(50); - - QVERIFY(drag->active()); - QCOMPARE(blackRect->x(), 72.0); - QCOMPARE(blackRect->y(), 72.0); - -#ifdef OLDWAY - QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &releaseEvent); -#else - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(122,122)); - QTest::qWait(50); -#endif - - QVERIFY(!drag->active()); - QCOMPARE(blackRect->x(), 72.0); - QCOMPARE(blackRect->y(), 72.0); - - delete canvas; -} - -QQuickView *tst_QQuickMouseArea::createView() -{ - QQuickView *canvas = new QQuickView(0); - canvas->setBaseSize(QSize(240,320)); - - return canvas; -} - -void tst_QQuickMouseArea::updateMouseAreaPosOnClick() -{ - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("updateMousePosOnClick.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild<QQuickMouseArea*>("mouseregion"); - QVERIFY(mouseRegion != 0); - - QQuickRectangle *rect = canvas->rootObject()->findChild<QQuickRectangle*>("ball"); - QVERIFY(rect != 0); - - QCOMPARE(mouseRegion->mouseX(), rect->x()); - QCOMPARE(mouseRegion->mouseY(), rect->y()); - - QMouseEvent event(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &event); - - QCOMPARE(mouseRegion->mouseX(), 100.0); - QCOMPARE(mouseRegion->mouseY(), 100.0); - - QCOMPARE(mouseRegion->mouseX(), rect->x()); - QCOMPARE(mouseRegion->mouseY(), rect->y()); - - delete canvas; -} - -void tst_QQuickMouseArea::updateMouseAreaPosOnResize() -{ - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("updateMousePosOnResize.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QQuickMouseArea *mouseRegion = canvas->rootObject()->findChild<QQuickMouseArea*>("mouseregion"); - QVERIFY(mouseRegion != 0); - - QQuickRectangle *rect = canvas->rootObject()->findChild<QQuickRectangle*>("brother"); - QVERIFY(rect != 0); - - QCOMPARE(mouseRegion->mouseX(), 0.0); - QCOMPARE(mouseRegion->mouseY(), 0.0); - - QMouseEvent event(QEvent::MouseButtonPress, rect->pos().toPoint(), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &event); - - QVERIFY(!mouseRegion->property("emitPositionChanged").toBool()); - QVERIFY(mouseRegion->property("mouseMatchesPos").toBool()); - - QCOMPARE(mouseRegion->property("x1").toReal(), 0.0); - QCOMPARE(mouseRegion->property("y1").toReal(), 0.0); - - QCOMPARE(mouseRegion->property("x2").toReal(), rect->x()); - QCOMPARE(mouseRegion->property("y2").toReal(), rect->y()); - - QCOMPARE(mouseRegion->mouseX(), rect->x()); - QCOMPARE(mouseRegion->mouseY(), rect->y()); - - delete canvas; -} - -void tst_QQuickMouseArea::noOnClickedWithPressAndHold() -{ - { - // We handle onPressAndHold, therefore no onClicked - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("clickandhold.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &pressEvent); - - QVERIFY(!canvas->rootObject()->property("clicked").toBool()); - QVERIFY(!canvas->rootObject()->property("held").toBool()); - - QTest::qWait(1000); - - QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &releaseEvent); - - QVERIFY(!canvas->rootObject()->property("clicked").toBool()); - QVERIFY(canvas->rootObject()->property("held").toBool()); - - delete canvas; - } - - { - // We do not handle onPressAndHold, therefore we get onClicked - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("noclickandhold.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &pressEvent); - - QVERIFY(!canvas->rootObject()->property("clicked").toBool()); - - QTest::qWait(1000); - - QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &releaseEvent); - - QVERIFY(canvas->rootObject()->property("clicked").toBool()); - - delete canvas; - } -} - -void tst_QQuickMouseArea::onMousePressRejected() -{ - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("rejectEvent.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - QVERIFY(canvas->rootObject()->property("enabled").toBool()); - - QVERIFY(!canvas->rootObject()->property("mr1_pressed").toBool()); - QVERIFY(!canvas->rootObject()->property("mr1_released").toBool()); - QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool()); - QVERIFY(!canvas->rootObject()->property("mr2_pressed").toBool()); - QVERIFY(!canvas->rootObject()->property("mr2_released").toBool()); - QVERIFY(!canvas->rootObject()->property("mr2_canceled").toBool()); - - QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &pressEvent); - - QVERIFY(canvas->rootObject()->property("mr1_pressed").toBool()); - QVERIFY(!canvas->rootObject()->property("mr1_released").toBool()); - QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool()); - QVERIFY(canvas->rootObject()->property("mr2_pressed").toBool()); - QVERIFY(!canvas->rootObject()->property("mr2_released").toBool()); - QVERIFY(canvas->rootObject()->property("mr2_canceled").toBool()); - - QTest::qWait(200); - - QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &releaseEvent); - - QVERIFY(canvas->rootObject()->property("mr1_released").toBool()); - QVERIFY(!canvas->rootObject()->property("mr1_canceled").toBool()); - QVERIFY(!canvas->rootObject()->property("mr2_released").toBool()); - - delete canvas; -} -void tst_QQuickMouseArea::pressedCanceledOnWindowDeactivate() -{ - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("pressedCanceled.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - QVERIFY(!canvas->rootObject()->property("pressed").toBool()); - QVERIFY(!canvas->rootObject()->property("canceled").toBool()); - QVERIFY(!canvas->rootObject()->property("released").toBool()); - - QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &pressEvent); - - QVERIFY(canvas->rootObject()->property("pressed").toBool()); - QVERIFY(!canvas->rootObject()->property("canceled").toBool()); - QVERIFY(!canvas->rootObject()->property("released").toBool()); - - QTest::qWait(200); - - QEvent windowDeactivateEvent(QEvent::WindowDeactivate); - QGuiApplication::sendEvent(canvas, &windowDeactivateEvent); - QVERIFY(!canvas->rootObject()->property("pressed").toBool()); - QVERIFY(canvas->rootObject()->property("canceled").toBool()); - QVERIFY(!canvas->rootObject()->property("released").toBool()); - - QTest::qWait(200); - - //press again - QGuiApplication::sendEvent(canvas, &pressEvent); - QVERIFY(canvas->rootObject()->property("pressed").toBool()); - QVERIFY(!canvas->rootObject()->property("canceled").toBool()); - QVERIFY(!canvas->rootObject()->property("released").toBool()); - - QTest::qWait(200); - - //release - QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &releaseEvent); - QVERIFY(!canvas->rootObject()->property("pressed").toBool()); - QVERIFY(!canvas->rootObject()->property("canceled").toBool()); - QVERIFY(canvas->rootObject()->property("released").toBool()); - - delete canvas; -} -void tst_QQuickMouseArea::doubleClick() -{ - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("doubleclick.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &pressEvent); - - QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &releaseEvent); - - QCOMPARE(canvas->rootObject()->property("released").toInt(), 1); - - pressEvent = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &pressEvent); - - QGuiApplication::sendEvent(canvas, &releaseEvent); - - QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 1); - QCOMPARE(canvas->rootObject()->property("doubleClicked").toInt(), 1); - QCOMPARE(canvas->rootObject()->property("released").toInt(), 2); - - delete canvas; -} - -// QTBUG-14832 -void tst_QQuickMouseArea::clickTwice() -{ - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("clicktwice.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &pressEvent); - - QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &releaseEvent); - - QCOMPARE(canvas->rootObject()->property("pressed").toInt(), 1); - QCOMPARE(canvas->rootObject()->property("released").toInt(), 1); - QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 1); - - pressEvent = QMouseEvent(QEvent::MouseButtonDblClick, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &pressEvent); - - QGuiApplication::sendEvent(canvas, &pressEvent); - QGuiApplication::sendEvent(canvas, &releaseEvent); - - QCOMPARE(canvas->rootObject()->property("pressed").toInt(), 2); - QCOMPARE(canvas->rootObject()->property("released").toInt(), 2); - QCOMPARE(canvas->rootObject()->property("clicked").toInt(), 2); - - delete canvas; -} - -void tst_QQuickMouseArea::pressedOrdering() -{ - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("pressedOrdering.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("base")); - - QMouseEvent pressEvent(QEvent::MouseButtonPress, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &pressEvent); - - QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("pressed")); - - QMouseEvent releaseEvent(QEvent::MouseButtonRelease, QPoint(100, 100), Qt::LeftButton, Qt::LeftButton, 0); - QGuiApplication::sendEvent(canvas, &releaseEvent); - - QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("toggled")); - - QGuiApplication::sendEvent(canvas, &pressEvent); - - QCOMPARE(canvas->rootObject()->property("value").toString(), QLatin1String("pressed")); - - delete canvas; -} - -void tst_QQuickMouseArea::preventStealing() -{ - QQuickView *canvas = createView(); - - canvas->setSource(testFileUrl("preventstealing.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(canvas->rootObject()); - QVERIFY(flickable != 0); - - QQuickMouseArea *mouseArea = canvas->rootObject()->findChild<QQuickMouseArea*>("mousearea"); - QVERIFY(mouseArea != 0); - - QSignalSpy mousePositionSpy(mouseArea, SIGNAL(positionChanged(QQuickMouseEvent*))); - - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(80, 80)); - - // Without preventStealing, mouse movement over MouseArea would - // cause the Flickable to steal mouse and trigger content movement. - - QTest::mouseMove(canvas,QPoint(69,69)); - QTest::mouseMove(canvas,QPoint(58,58)); - QTest::mouseMove(canvas,QPoint(47,47)); - - // We should have received all three move events - QCOMPARE(mousePositionSpy.count(), 3); - QVERIFY(mouseArea->pressed()); - - // Flickable content should not have moved. - QCOMPARE(flickable->contentX(), 0.); - QCOMPARE(flickable->contentY(), 0.); - - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(47, 47)); - - // Now allow stealing and confirm Flickable does its thing. - canvas->rootObject()->setProperty("stealing", false); - - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(80, 80)); - - // Without preventStealing, mouse movement over MouseArea would - // cause the Flickable to steal mouse and trigger content movement. - - QTest::mouseMove(canvas,QPoint(69,69)); - QTest::mouseMove(canvas,QPoint(58,58)); - QTest::mouseMove(canvas,QPoint(47,47)); - - // We should only have received the first move event - QCOMPARE(mousePositionSpy.count(), 4); - // Our press should be taken away - QVERIFY(!mouseArea->pressed()); - - // Flickable content should have moved. - - QCOMPARE(flickable->contentX(), 11.); - QCOMPARE(flickable->contentY(), 11.); - - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(50, 50)); - - delete canvas; -} - -void tst_QQuickMouseArea::clickThrough() -{ - QSKIP("QTBUG-23976 Unstable"); - //With no handlers defined click, doubleClick and PressAndHold should propagate to those with handlers - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("clickThrough.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100)); - - QTRY_COMPARE(canvas->rootObject()->property("presses").toInt(), 0); - QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 1); - - QTest::qWait(800); // to avoid generating a double click. - - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::qWait(1000); - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100)); - - QTRY_COMPARE(canvas->rootObject()->property("presses").toInt(), 0); - QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 1); - QTRY_COMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1); - - QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::qWait(100); - - QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0); - QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 2); - QTRY_COMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 1); - QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1); - - delete canvas; - - //With handlers defined click, doubleClick and PressAndHold should propagate only when explicitly ignored - canvas = createView(); - canvas->setSource(testFileUrl("clickThrough2.qml")); - canvas->show(); - canvas->requestActivateWindow(); - QVERIFY(canvas->rootObject() != 0); - - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100)); - - QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0); - QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 0); - - QTest::qWait(800); // to avoid generating a double click. - - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::qWait(1000); - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::qWait(100); - - QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0); - QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 0); - QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 0); - - QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::qWait(100); - - QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0); - QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 0); - QCOMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 0); - QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 0); - - canvas->rootObject()->setProperty("letThrough", QVariant(true)); - - QTest::qWait(800); // to avoid generating a double click. - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100)); - - QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0); - QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 1); - - QTest::qWait(800); // to avoid generating a double click. - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::qWait(1000); - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::qWait(100); - - QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0); - QCOMPARE(canvas->rootObject()->property("clicks").toInt(), 1); - QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1); - - QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::qWait(100); - - QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0); - QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 2); - QCOMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 1); - QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1); - - canvas->rootObject()->setProperty("noPropagation", QVariant(true)); - - QTest::qWait(800); // to avoid generating a double click. - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100)); - - QTest::qWait(800); // to avoid generating a double click. - QTest::mousePress(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::qWait(1000); - QTest::mouseRelease(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::qWait(100); - - QTest::mouseDClick(canvas, Qt::LeftButton, 0, QPoint(100,100)); - QTest::qWait(100); - - QCOMPARE(canvas->rootObject()->property("presses").toInt(), 0); - QTRY_COMPARE(canvas->rootObject()->property("clicks").toInt(), 2); - QCOMPARE(canvas->rootObject()->property("doubleClicks").toInt(), 1); - QCOMPARE(canvas->rootObject()->property("pressAndHolds").toInt(), 1); - - delete canvas; -} - -void tst_QQuickMouseArea::hoverPosition() -{ - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("hoverPosition.qml")); - - QQuickItem *root = canvas->rootObject(); - QVERIFY(root != 0); - - QCOMPARE(root->property("mouseX").toReal(), qreal(0)); - QCOMPARE(root->property("mouseY").toReal(), qreal(0)); - - QTest::mouseMove(canvas,QPoint(10,32)); - - - QCOMPARE(root->property("mouseX").toReal(), qreal(10)); - QCOMPARE(root->property("mouseY").toReal(), qreal(32)); - - delete canvas; -} - -void tst_QQuickMouseArea::hoverPropagation() -{ - //QTBUG-18175, to behave like GV did. - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("hoverPropagation.qml")); - - QQuickItem *root = canvas->rootObject(); - QVERIFY(root != 0); - - QCOMPARE(root->property("point1").toBool(), false); - QCOMPARE(root->property("point2").toBool(), false); - - QMouseEvent moveEvent(QEvent::MouseMove, QPoint(32, 32), Qt::NoButton, Qt::NoButton, 0); - QGuiApplication::sendEvent(canvas, &moveEvent); - - QCOMPARE(root->property("point1").toBool(), true); - QCOMPARE(root->property("point2").toBool(), false); - - QMouseEvent moveEvent2(QEvent::MouseMove, QPoint(232, 32), Qt::NoButton, Qt::NoButton, 0); - QGuiApplication::sendEvent(canvas, &moveEvent2); - QCOMPARE(root->property("point1").toBool(), false); - QCOMPARE(root->property("point2").toBool(), true); - - delete canvas; -} - -void tst_QQuickMouseArea::hoverVisible() -{ - QQuickView *canvas = createView(); - canvas->setSource(testFileUrl("hoverVisible.qml")); - - QQuickItem *root = canvas->rootObject(); - QVERIFY(root != 0); - - QQuickMouseArea *mouseTracker = canvas->rootObject()->findChild<QQuickMouseArea*>("mousetracker"); - QVERIFY(mouseTracker != 0); - - QSignalSpy enteredSpy(mouseTracker, SIGNAL(entered())); - - QTest::mouseMove(canvas,QPoint(10,32)); - - QCOMPARE(mouseTracker->hovered(), false); - QCOMPARE(enteredSpy.count(), 0); - - mouseTracker->setVisible(true); - - QCOMPARE(mouseTracker->hovered(), true); - QCOMPARE(enteredSpy.count(), 1); - - QEXPECT_FAIL("", "QTBUG-24282", Continue); - QCOMPARE(QPointF(mouseTracker->mouseX(), mouseTracker->mouseY()), QPointF(10,32)); - - delete canvas; -} - -QTEST_MAIN(tst_QQuickMouseArea) - -#include "tst_qquickmousearea.moc" |