diff options
Diffstat (limited to 'tests/auto/popup/tst_popup.cpp')
-rw-r--r-- | tests/auto/popup/tst_popup.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/auto/popup/tst_popup.cpp b/tests/auto/popup/tst_popup.cpp index abebc5d0..6f4a2e2e 100644 --- a/tests/auto/popup/tst_popup.cpp +++ b/tests/auto/popup/tst_popup.cpp @@ -58,6 +58,7 @@ private slots: void closePolicy(); void activeFocusOnClose1(); void activeFocusOnClose2(); + void hover(); }; void tst_popup::visible() @@ -330,6 +331,55 @@ void tst_popup::activeFocusOnClose2() QVERIFY(popup1->hasActiveFocus()); } +void tst_popup::hover() +{ + QQuickApplicationHelper helper(this, QStringLiteral("hover.qml")); + QQuickApplicationWindow *window = helper.window; + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickPopup *popup = helper.window->property("popup").value<QQuickPopup*>(); + QVERIFY(popup); + + QQuickButton *parentButton = helper.window->property("parentButton").value<QQuickButton*>(); + QVERIFY(parentButton); + parentButton->setHoverEnabled(true); + + QQuickButton *childButton = helper.window->property("childButton").value<QQuickButton*>(); + QVERIFY(childButton); + childButton->setHoverEnabled(true); + + QSignalSpy openedSpy(popup, SIGNAL(opened())); + QVERIFY(openedSpy.isValid()); + popup->open(); + QVERIFY(openedSpy.count() == 1 || openedSpy.wait()); + + // hover the parent button outside the popup + QTest::mouseMove(window, QPoint(window->width() - 1, window->height() - 1)); + QVERIFY(parentButton->isHovered()); + QVERIFY(!childButton->isHovered()); + + // hover the popup background + QTest::mouseMove(window, QPoint(1, 1)); + QVERIFY(!parentButton->isHovered()); + QVERIFY(!childButton->isHovered()); + + // hover the child button in a popup + QTest::mouseMove(window, QPoint(2, 2)); + QVERIFY(!parentButton->isHovered()); + QVERIFY(childButton->isHovered()); + + QSignalSpy closedSpy(popup, SIGNAL(closed())); + QVERIFY(closedSpy.isValid()); + popup->close(); + QVERIFY(closedSpy.count() == 1 || closedSpy.wait()); + + // hover the parent button after closing the popup + QTest::mouseMove(window, QPoint(window->width() / 2, window->height() / 2)); + QVERIFY(parentButton->isHovered()); +} + QTEST_MAIN(tst_popup) #include "tst_popup.moc" |