aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMarco Martin <mart@kde.org>2019-10-28 12:54:31 +0100
committerMarco Martin <notmart@gmail.com>2019-11-04 14:56:19 +0100
commit611422b5968ceac6cfba034116a3d1e107d8e2df (patch)
tree4baab0dbee30c29f5d15bd438f6d747092f7c8a0 /tests/auto
parent0f92672d6f90d9dd8b5fb6c1b52215cef7089343 (diff)
Non-modal popups shouldn't set isTabFence
When a popup is not modal, all the application's main content can still be interacted with, therefore should still be possible to navigate it with tab. This issue is particularly evident with Drawer, also commonly used as a sidebar, in which tab navigation should always work. Fixes: QTBUG-79501 Change-Id: I0e8ad2e1abe57b9617c6316efbfe2f296c91b592 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> (cherry picked from commit 3358362e61ef96b3922a438d0806561285c49230)
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qquickpopup/data/tabFence.qml97
-rw-r--r--tests/auto/qquickpopup/tst_qquickpopup.cpp57
2 files changed, 154 insertions, 0 deletions
diff --git a/tests/auto/qquickpopup/data/tabFence.qml b/tests/auto/qquickpopup/data/tabFence.qml
new file mode 100644
index 00000000..2cf408e9
--- /dev/null
+++ b/tests/auto/qquickpopup/data/tabFence.qml
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2019 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.15
+import QtQuick.Layouts 1.15
+import QtQuick.Window 2.15
+import QtQuick.Controls 2.15
+
+ApplicationWindow {
+ width: 400
+ height: 400
+ objectName: "Rectangle"
+
+ property alias dialog: dialog
+ property alias outsideButton1: outsideButton1
+ property alias outsideButton2: outsideButton2
+ property alias dialogButton1: dialogButton1
+ property alias dialogButton2: dialogButton2
+
+ ColumnLayout {
+ Button {
+ id: outsideButton1
+ text: "Button1"
+ }
+ Button {
+ id: outsideButton2
+ text: "Button2"
+ }
+ }
+
+ Dialog {
+ id: dialog
+ objectName: "Dialog"
+ width: 200
+ height: 200
+ anchors.centerIn: parent
+ visible: true
+
+ ColumnLayout {
+ Button {
+ id: dialogButton1
+ text: "Button3"
+ }
+ Button {
+ id: dialogButton2
+ text: "Button4"
+ }
+ }
+ }
+}
diff --git a/tests/auto/qquickpopup/tst_qquickpopup.cpp b/tests/auto/qquickpopup/tst_qquickpopup.cpp
index c36edd6d..2c173c63 100644
--- a/tests/auto/qquickpopup/tst_qquickpopup.cpp
+++ b/tests/auto/qquickpopup/tst_qquickpopup.cpp
@@ -91,6 +91,7 @@ private slots:
void countChanged();
void toolTipCrashOnClose();
void setOverlayParentToNull();
+ void tabFence();
};
void tst_QQuickPopup::initTestCase()
@@ -1233,6 +1234,62 @@ void tst_QQuickPopup::setOverlayParentToNull()
// While nullifying the overlay parent doesn't make much sense, it shouldn't crash.
}
+void tst_QQuickPopup::tabFence()
+{
+ if (QGuiApplication::styleHints()->tabFocusBehavior() != Qt::TabFocusAllControls)
+ QSKIP("This platform only allows tab focus for text controls");
+
+ QQuickApplicationHelper helper(this, "tabFence.qml");
+
+ QQuickWindow *window = helper.window;
+ window->show();
+ QVERIFY(QTest::qWaitForWindowActive(window));
+
+ QQuickPopup *popup = window->property("dialog").value<QQuickPopup*>();
+ QVERIFY(popup);
+ popup->open();
+ popup->setModal(true);
+
+ QQuickButton *outsideButton1 = window->property("outsideButton1").value<QQuickButton*>();
+ QVERIFY(outsideButton1);
+ QQuickButton *outsideButton2 = window->property("outsideButton2").value<QQuickButton*>();
+ QVERIFY(outsideButton2);
+ QQuickButton *dialogButton1 = window->property("dialogButton1").value<QQuickButton*>();
+ QVERIFY(dialogButton1);
+ QQuickButton *dialogButton2 = window->property("dialogButton2").value<QQuickButton*>();
+ QVERIFY(dialogButton2);
+
+ // When modal, focus loops between the two external buttons
+ outsideButton1->forceActiveFocus();
+ QVERIFY(outsideButton1->hasActiveFocus());
+ QTest::keyClick(window, Qt::Key_Tab);
+ QVERIFY(outsideButton2->hasActiveFocus());
+ QTest::keyClick(window, Qt::Key_Tab);
+ QVERIFY(outsideButton1->hasActiveFocus());
+
+ // Same thing for dialog's buttons
+ dialogButton1->forceActiveFocus();
+ QVERIFY(dialogButton1->hasActiveFocus());
+ QTest::keyClick(window, Qt::Key_Tab);
+ QVERIFY(dialogButton2->hasActiveFocus());
+ QTest::keyClick(window, Qt::Key_Tab);
+ QVERIFY(dialogButton1->hasActiveFocus());
+
+ popup->setModal(false);
+
+ // When not modal, focus goes in and out of the dialog
+ outsideButton1->forceActiveFocus();
+ QVERIFY(outsideButton1->hasActiveFocus());
+ QTest::keyClick(window, Qt::Key_Tab);
+ QVERIFY(outsideButton2->hasActiveFocus());
+ QTest::keyClick(window, Qt::Key_Tab);
+ QVERIFY(dialogButton1->hasActiveFocus());
+ QTest::keyClick(window, Qt::Key_Tab);
+ QVERIFY(dialogButton2->hasActiveFocus());
+ QTest::keyClick(window, Qt::Key_Tab);
+ QVERIFY(outsideButton1->hasActiveFocus());
+}
+
QTEST_QUICKCONTROLS_MAIN(tst_QQuickPopup)
#include "tst_qquickpopup.moc"