From 5dfa85e68c6a9fc3fbedb47737dd34c843e2ba2b Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Sat, 24 Jun 2017 10:18:43 +0200 Subject: Make ApplicationWindow::activeFocusControl work with plain Window [ChangeLog][Controls][ApplicationWindow] The attached activeFocusControl property has been made functional with a plain QML Window to make the functionality available when using QQuickWindow/View/Widget instead of ApplicationWindow. Task-number: QTBUG-61336 Change-Id: I46b91bca436d58c349c4f9ba8816245ab4ca33a4 Reviewed-by: Mitch Curtis --- .../applicationwindow/tst_applicationwindow.cpp | 52 +++++++++++++++++++++- 1 file changed, 50 insertions(+), 2 deletions(-) (limited to 'tests/auto/applicationwindow') diff --git a/tests/auto/applicationwindow/tst_applicationwindow.cpp b/tests/auto/applicationwindow/tst_applicationwindow.cpp index 60160afe..af5a7544 100644 --- a/tests/auto/applicationwindow/tst_applicationwindow.cpp +++ b/tests/auto/applicationwindow/tst_applicationwindow.cpp @@ -410,7 +410,7 @@ void tst_applicationwindow::attachedProperties() QCOMPARE(childControl->window(), childAppWindow); QCOMPARE(childControl->property("attached_window").value(), childAppWindow); QCOMPARE(childControl->property("attached_contentItem").value(), childAppWindow->contentItem()); - QCOMPARE(childControl->property("attached_activeFocusControl").value(), childAppWindow->activeFocusControl()); + QCOMPARE(childControl->property("attached_activeFocusControl").value(), childAppWindowControl); QCOMPARE(childControl->property("attached_header").value(), childAppWindow->header()); QCOMPARE(childControl->property("attached_footer").value(), childAppWindow->footer()); QCOMPARE(childControl->property("attached_overlay").value(), childAppWindow->overlay()); @@ -419,7 +419,7 @@ void tst_applicationwindow::attachedProperties() QCOMPARE(childItem->window(), childAppWindow); QCOMPARE(childItem->property("attached_window").value(), childAppWindow); QCOMPARE(childItem->property("attached_contentItem").value(), childAppWindow->contentItem()); - QCOMPARE(childItem->property("attached_activeFocusControl").value(), childAppWindow->activeFocusControl()); + QCOMPARE(childItem->property("attached_activeFocusControl").value(), childAppWindowControl); QCOMPARE(childItem->property("attached_header").value(), childAppWindow->header()); QCOMPARE(childItem->property("attached_footer").value(), childAppWindow->footer()); QCOMPARE(childItem->property("attached_overlay").value(), childAppWindow->overlay()); @@ -441,6 +441,54 @@ void tst_applicationwindow::attachedProperties() QVERIFY(!childItem->property("attached_header").value()); QVERIFY(!childItem->property("attached_footer").value()); QVERIFY(!childItem->property("attached_overlay").value()); + childAppWindow->hide(); + + childWindow->show(); + childWindow->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(childWindow)); + + QVERIFY(!childWindowControl->hasActiveFocus()); + childWindowControl->forceActiveFocus(); + QTRY_VERIFY(childWindowControl->hasActiveFocus()); + QCOMPARE(childWindow->activeFocusItem(), childWindowControl); + QCOMPARE(childWindowControl->property("attached_activeFocusControl").value(), childWindowControl); + + childControl->setParentItem(childWindow->contentItem()); + QCOMPARE(childControl->window(), childWindow); + QVERIFY(!childControl->property("attached_window").value()); + QCOMPARE(childControl->property("attached_activeFocusControl").value(), childWindowControl); + QVERIFY(!childControl->property("attached_contentItem").value()); + QVERIFY(!childControl->property("attached_header").value()); + QVERIFY(!childControl->property("attached_footer").value()); + QCOMPARE(childControl->property("attached_overlay").value(), QQuickOverlay::overlay(childWindow)); + + childItem->setParentItem(childWindow->contentItem()); + QCOMPARE(childItem->window(), childWindow); + QVERIFY(!childControl->property("attached_window").value()); + QCOMPARE(childControl->property("attached_activeFocusControl").value(), childWindowControl); + QVERIFY(!childControl->property("attached_contentItem").value()); + QVERIFY(!childControl->property("attached_header").value()); + QVERIFY(!childControl->property("attached_footer").value()); + QCOMPARE(childControl->property("attached_overlay").value(), QQuickOverlay::overlay(childWindow)); + + childControl->setParentItem(nullptr); + QVERIFY(!childControl->window()); + QVERIFY(!childControl->property("attached_window").value()); + QVERIFY(!childControl->property("attached_contentItem").value()); + QVERIFY(!childControl->property("attached_activeFocusControl").value()); + QVERIFY(!childControl->property("attached_header").value()); + QVERIFY(!childControl->property("attached_footer").value()); + QVERIFY(!childControl->property("attached_overlay").value()); + + childItem->setParentItem(nullptr); + QVERIFY(!childItem->window()); + QVERIFY(!childItem->property("attached_window").value()); + QVERIFY(!childItem->property("attached_contentItem").value()); + QVERIFY(!childItem->property("attached_activeFocusControl").value()); + QVERIFY(!childItem->property("attached_header").value()); + QVERIFY(!childItem->property("attached_footer").value()); + QVERIFY(!childItem->property("attached_overlay").value()); + childWindow->hide(); // ### A temporary workaround to unblock the CI until the crash caused // by https://codereview.qt-project.org/#/c/108517/ has been fixed... -- cgit v1.2.3