MouseArea: add autotest for subtreeHoverEnabled
Verify the fix in f7e462b
.
Task-number: QTBUG-54019
Change-Id: Ia9846f9b79473ea4f72e895320cf01d5d85cc1a3
Reviewed-by: Robin Burchell <robin.burchell@viroteck.net>
This commit is contained in:
parent
28ed215281
commit
733b20af44
|
@ -0,0 +1,21 @@
|
|||
import QtQuick 2.7
|
||||
|
||||
Item {
|
||||
width: 200
|
||||
height: 200
|
||||
MouseArea {
|
||||
id: ma
|
||||
property string str: "foo!"
|
||||
width: 150; height: 150
|
||||
hoverEnabled: true
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: ma.containsMouse ? "lightsteelblue" : "gray"
|
||||
}
|
||||
Text {
|
||||
text: ma.str
|
||||
textFormat: Text.PlainText // consequently Text does not care about hover events
|
||||
}
|
||||
}
|
||||
}
|
|
@ -29,6 +29,7 @@
|
|||
#include <QtTest/QtTest>
|
||||
#include <QtTest/QSignalSpy>
|
||||
#include <QtQuick/private/qquickdrag_p.h>
|
||||
#include <QtQuick/private/qquickitem_p.h>
|
||||
#include <QtQuick/private/qquickmousearea_p.h>
|
||||
#include <QtQuick/private/qquickrectangle_p.h>
|
||||
#include <private/qquickflickable_p.h>
|
||||
|
@ -107,6 +108,7 @@ private slots:
|
|||
void hoverPropagation();
|
||||
void hoverVisible();
|
||||
void hoverAfterPress();
|
||||
void subtreeHoverEnabled();
|
||||
void disableAfterPress();
|
||||
void onWheel();
|
||||
void transformedMouseArea_data();
|
||||
|
@ -1316,6 +1318,26 @@ void tst_QQuickMouseArea::hoverAfterPress()
|
|||
QCOMPARE(mouseArea->hovered(), false);
|
||||
}
|
||||
|
||||
void tst_QQuickMouseArea::subtreeHoverEnabled()
|
||||
{
|
||||
QQuickView window;
|
||||
QByteArray errorMessage;
|
||||
QVERIFY2(initView(window, testFileUrl("qtbug54019.qml"), true, &errorMessage), errorMessage.constData());
|
||||
QQuickItem *root = window.rootObject();
|
||||
QVERIFY(root != 0);
|
||||
|
||||
QQuickMouseArea *mouseArea = root->findChild<QQuickMouseArea*>();
|
||||
QQuickItemPrivate *rootPrivate = QQuickItemPrivate::get(root);
|
||||
QVERIFY(mouseArea != 0);
|
||||
QTest::mouseMove(&window, QPoint(10, 160));
|
||||
QCOMPARE(mouseArea->hovered(), false);
|
||||
QVERIFY(rootPrivate->subtreeHoverEnabled);
|
||||
QTest::mouseMove(&window, QPoint(10, 10));
|
||||
QCOMPARE(mouseArea->hovered(), true);
|
||||
QTest::mouseMove(&window, QPoint(160, 10));
|
||||
QCOMPARE(mouseArea->hovered(), false);
|
||||
}
|
||||
|
||||
void tst_QQuickMouseArea::disableAfterPress()
|
||||
{
|
||||
QQuickView window;
|
||||
|
|
Loading…
Reference in New Issue