From 125c08cad177edf8baba9a6ca84425255db9c500 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 27 Sep 2017 14:48:17 +0200 Subject: Rename tst_applicationwindow to tst_QQuickApplicationWindow Change-Id: If9fc2bb41cf251af71479b25656240e0d3c238d8 Reviewed-by: Mitch Curtis --- .gitignore | 2 +- tests/auto/applicationwindow/applicationwindow.pro | 15 - .../applicationwindow/data/activeFocusControl.qml | 115 --- .../applicationwindow/data/activefocusontab.qml | 94 --- .../applicationwindow/data/attachedProperties.qml | 190 ----- .../data/basicapplicationwindow.qml | 56 -- .../data/clearfocusondestruction.qml | 74 -- tests/auto/applicationwindow/data/defaultFocus.qml | 69 -- tests/auto/applicationwindow/data/fill.qml | 79 -- .../data/focusAfterPopupClosed.qml | 111 --- tests/auto/applicationwindow/data/font.qml | 97 --- tests/auto/applicationwindow/data/layout.qml | 61 -- tests/auto/applicationwindow/data/locale.qml | 77 -- .../applicationwindow/tst_applicationwindow.cpp | 838 --------------------- tests/auto/auto.pro | 4 +- .../data/activeFocusControl.qml | 115 +++ .../data/activefocusontab.qml | 94 +++ .../data/attachedProperties.qml | 190 +++++ .../data/basicapplicationwindow.qml | 56 ++ .../data/clearfocusondestruction.qml | 74 ++ .../qquickapplicationwindow/data/defaultFocus.qml | 69 ++ tests/auto/qquickapplicationwindow/data/fill.qml | 79 ++ .../data/focusAfterPopupClosed.qml | 111 +++ tests/auto/qquickapplicationwindow/data/font.qml | 97 +++ tests/auto/qquickapplicationwindow/data/layout.qml | 61 ++ tests/auto/qquickapplicationwindow/data/locale.qml | 77 ++ .../qquickapplicationwindow.pro | 15 + .../tst_qquickapplicationwindow.cpp | 838 +++++++++++++++++++++ 28 files changed, 1879 insertions(+), 1879 deletions(-) delete mode 100644 tests/auto/applicationwindow/applicationwindow.pro delete mode 100644 tests/auto/applicationwindow/data/activeFocusControl.qml delete mode 100644 tests/auto/applicationwindow/data/activefocusontab.qml delete mode 100644 tests/auto/applicationwindow/data/attachedProperties.qml delete mode 100644 tests/auto/applicationwindow/data/basicapplicationwindow.qml delete mode 100644 tests/auto/applicationwindow/data/clearfocusondestruction.qml delete mode 100644 tests/auto/applicationwindow/data/defaultFocus.qml delete mode 100644 tests/auto/applicationwindow/data/fill.qml delete mode 100644 tests/auto/applicationwindow/data/focusAfterPopupClosed.qml delete mode 100644 tests/auto/applicationwindow/data/font.qml delete mode 100644 tests/auto/applicationwindow/data/layout.qml delete mode 100644 tests/auto/applicationwindow/data/locale.qml delete mode 100644 tests/auto/applicationwindow/tst_applicationwindow.cpp create mode 100644 tests/auto/qquickapplicationwindow/data/activeFocusControl.qml create mode 100644 tests/auto/qquickapplicationwindow/data/activefocusontab.qml create mode 100644 tests/auto/qquickapplicationwindow/data/attachedProperties.qml create mode 100644 tests/auto/qquickapplicationwindow/data/basicapplicationwindow.qml create mode 100644 tests/auto/qquickapplicationwindow/data/clearfocusondestruction.qml create mode 100644 tests/auto/qquickapplicationwindow/data/defaultFocus.qml create mode 100644 tests/auto/qquickapplicationwindow/data/fill.qml create mode 100644 tests/auto/qquickapplicationwindow/data/focusAfterPopupClosed.qml create mode 100644 tests/auto/qquickapplicationwindow/data/font.qml create mode 100644 tests/auto/qquickapplicationwindow/data/layout.qml create mode 100644 tests/auto/qquickapplicationwindow/data/locale.qml create mode 100644 tests/auto/qquickapplicationwindow/qquickapplicationwindow.pro create mode 100644 tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp diff --git a/.gitignore b/.gitignore index cc84c183..ad8e6e58 100644 --- a/.gitignore +++ b/.gitignore @@ -27,7 +27,6 @@ /examples/quickcontrols2/wearable/wearable /tests/auto/accessibility/tst_accessibility -/tests/auto/applicationwindow/tst_applicationwindow /tests/auto/calendar/tst_calendar /tests/auto/controls/default/tst_default /tests/auto/controls/material/tst_material @@ -38,6 +37,7 @@ /tests/auto/menu/tst_menu /tests/auto/platform/tst_platform /tests/auto/pressandhold/tst_pressandhold +/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow /tests/auto/qquickdrawer/tst_qquickdrawer /tests/auto/qquickmaterialstyle/tst_qquickmaterialstyle /tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf diff --git a/tests/auto/applicationwindow/applicationwindow.pro b/tests/auto/applicationwindow/applicationwindow.pro deleted file mode 100644 index f94641c7..00000000 --- a/tests/auto/applicationwindow/applicationwindow.pro +++ /dev/null @@ -1,15 +0,0 @@ -CONFIG += testcase -TARGET = tst_applicationwindow -SOURCES += tst_applicationwindow.cpp - -macos:CONFIG -= app_bundle - -QT += core-private gui-private qml-private quick-private quicktemplates2-private quickcontrols2-private testlib - -include (../shared/util.pri) - -TESTDATA = data/* - -OTHER_FILES += \ - data/*.qml - diff --git a/tests/auto/applicationwindow/data/activeFocusControl.qml b/tests/auto/applicationwindow/data/activeFocusControl.qml deleted file mode 100644 index 940e8e08..00000000 --- a/tests/auto/applicationwindow/data/activeFocusControl.qml +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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.6 -import QtQuick.Controls 2.1 - -ApplicationWindow { - width: 400 - height: 400 - - property alias container_column: column - property alias textInput_column: ti_column - property alias textEdit_column: te_column - property alias textField_column: tf_column - property alias textArea_column: ta_column - property alias spinBox_column: sp_column - property alias spinContent_column: sp_column.contentItem - - property alias container_frame: frame - property alias textInput_frame: ti_frame - property alias textEdit_frame: te_frame - property alias textField_frame: tf_frame - property alias textArea_frame: ta_frame - property alias spinBox_frame: sp_frame - property alias spinContent_frame: sp_frame.contentItem - - Column { - id: column - - TextInput { - id: ti_column - } - TextEdit { - id: te_column - } - TextField { - id: tf_column - } - TextArea { - id: ta_column - } - SpinBox { - id: sp_column - } - } - - Frame { - id: frame - - Column { - TextInput { - id: ti_frame - } - TextEdit { - id: te_frame - } - TextField { - id: tf_frame - } - TextArea { - id: ta_frame - } - SpinBox { - id: sp_frame - } - } - } -} diff --git a/tests/auto/applicationwindow/data/activefocusontab.qml b/tests/auto/applicationwindow/data/activefocusontab.qml deleted file mode 100644 index 357ea9a4..00000000 --- a/tests/auto/applicationwindow/data/activefocusontab.qml +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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.6 -import QtQuick.Controls 2.1 - -ApplicationWindow { - title: "Test Application Window" - width: 100 - height: 100 - Item { - id: main - objectName: "main" - width: 100 - height: 100 - //focus: true - Column { - anchors.fill: parent - id: column - objectName: "column" - Item { - id: sub1 - objectName: "sub1" - activeFocusOnTab: true - Accessible.role: Accessible.Table - width: 100 - height: 50 - Rectangle { - anchors.fill: parent - color: parent.activeFocus ? "red" : "black" - } - } - Item { - id: sub2 - objectName: "sub2" - activeFocusOnTab: true - Accessible.role: Accessible.Table - width: 100 - height: 50 - Rectangle { - anchors.fill: parent - color: parent.activeFocus ? "red" : "black" - } - } - } - } -} diff --git a/tests/auto/applicationwindow/data/attachedProperties.qml b/tests/auto/applicationwindow/data/attachedProperties.qml deleted file mode 100644 index 09bc47ef..00000000 --- a/tests/auto/applicationwindow/data/attachedProperties.qml +++ /dev/null @@ -1,190 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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.6 -import QtQuick.Window 2.2 -import QtQuick.Controls 2.1 - -ApplicationWindow { - property alias childControl: childControl - property alias childItem: childItem - property alias childObject: childObject - - Control { - id: childControl - - property ApplicationWindow attached_window: ApplicationWindow.window - property Item attached_contentItem: ApplicationWindow.contentItem - property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl - property Item attached_header: ApplicationWindow.header - property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay - } - - Item { - id: childItem - - property ApplicationWindow attached_window: ApplicationWindow.window - property Item attached_contentItem: ApplicationWindow.contentItem - property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl - property Item attached_header: ApplicationWindow.header - property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay - } - - QtObject { - id: childObject - - property ApplicationWindow attached_window: ApplicationWindow.window - property Item attached_contentItem: ApplicationWindow.contentItem - property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl - property Item attached_header: ApplicationWindow.header - property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay - } - - property alias childWindow: childWindow - property alias childWindowControl: childWindowControl - property alias childWindowItem: childWindowItem - property alias childWindowObject: childWindowObject - - Window { - id: childWindow - - property ApplicationWindow attached_window: ApplicationWindow.window - property Item attached_contentItem: ApplicationWindow.contentItem - property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl - property Item attached_header: ApplicationWindow.header - property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay - - Control { - id: childWindowControl - - property ApplicationWindow attached_window: ApplicationWindow.window - property Item attached_contentItem: ApplicationWindow.contentItem - property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl - property Item attached_header: ApplicationWindow.header - property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay - } - - Item { - id: childWindowItem - - property ApplicationWindow attached_window: ApplicationWindow.window - property Item attached_contentItem: ApplicationWindow.contentItem - property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl - property Item attached_header: ApplicationWindow.header - property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay - } - - QtObject { - id: childWindowObject - - property ApplicationWindow attached_window: ApplicationWindow.window - property Item attached_contentItem: ApplicationWindow.contentItem - property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl - property Item attached_header: ApplicationWindow.header - property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay - } - } - - property alias childAppWindow: childAppWindow - property alias childAppWindowControl: childAppWindowControl - property alias childAppWindowItem: childAppWindowItem - property alias childAppWindowObject: childAppWindowObject - - ApplicationWindow { - id: childAppWindow - - property ApplicationWindow attached_window: ApplicationWindow.window - property Item attached_contentItem: ApplicationWindow.contentItem - property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl - property Item attached_header: ApplicationWindow.header - property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay - - Control { - id: childAppWindowControl - - property ApplicationWindow attached_window: ApplicationWindow.window - property Item attached_contentItem: ApplicationWindow.contentItem - property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl - property Item attached_header: ApplicationWindow.header - property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay - } - - Item { - id: childAppWindowItem - - property ApplicationWindow attached_window: ApplicationWindow.window - property Item attached_contentItem: ApplicationWindow.contentItem - property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl - property Item attached_header: ApplicationWindow.header - property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay - } - - QtObject { - id: childAppWindowObject - - property ApplicationWindow attached_window: ApplicationWindow.window - property Item attached_contentItem: ApplicationWindow.contentItem - property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl - property Item attached_header: ApplicationWindow.header - property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay - } - } -} diff --git a/tests/auto/applicationwindow/data/basicapplicationwindow.qml b/tests/auto/applicationwindow/data/basicapplicationwindow.qml deleted file mode 100644 index 16182f59..00000000 --- a/tests/auto/applicationwindow/data/basicapplicationwindow.qml +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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.6 -import QtQuick.Controls 2.1 - -ApplicationWindow { - title: "Test Application Window" -} diff --git a/tests/auto/applicationwindow/data/clearfocusondestruction.qml b/tests/auto/applicationwindow/data/clearfocusondestruction.qml deleted file mode 100644 index 3589439e..00000000 --- a/tests/auto/applicationwindow/data/clearfocusondestruction.qml +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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.7 -import QtQuick.Controls 2.1 -import QtQuick.Layouts 1.3 -import QtGraphicalEffects 1.0 - -ApplicationWindow { - width: 200 - height: 200 - visible: true - - property alias textfield: textfield - - /* - * The code below is the simplest way we can trigger that the signal - * activeFocusItemChanged() is emitted during destruction of the - * ApplicationWindow. This caused a crash in QQuickApplicationWindow. - */ - FastBlur { - id: fastBlur - anchors.fill: parent - radius: 30 - source: ShaderEffectSource { - id: effectsource - sourceItem: textfield - sourceRect: Qt.rect( 0, 0, fastBlur.width, fastBlur.height ) - } - } - - TextField { - id: textfield - anchors.bottom: parent.bottom - focus: true - } -} diff --git a/tests/auto/applicationwindow/data/defaultFocus.qml b/tests/auto/applicationwindow/data/defaultFocus.qml deleted file mode 100644 index 741ce908..00000000 --- a/tests/auto/applicationwindow/data/defaultFocus.qml +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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.6 -import QtQuick.Controls 2.1 - -ApplicationWindow { - visible: true - width: 200 - height: 200 - - property bool receivedKeyPress: false - - Item { - objectName: "item" - focus: true - anchors.fill: parent - - Keys.onLeftPressed: receivedKeyPress = true - } -} - diff --git a/tests/auto/applicationwindow/data/fill.qml b/tests/auto/applicationwindow/data/fill.qml deleted file mode 100644 index 27b10d34..00000000 --- a/tests/auto/applicationwindow/data/fill.qml +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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.6 -import QtQuick.Controls 2.1 - -ApplicationWindow { - width: 400 - height: 400 - - property alias stackView: stackView - property alias nextItem: nextItem - - function pushNextItem() { - stackView.push(nextItem, StackView.Immediate); - } - - Rectangle { - id: nextItem - color: "blue" - visible: false - } - - StackView { - id: stackView - anchors.fill: parent - - initialItem: Rectangle { - color: "red" - } - } -} diff --git a/tests/auto/applicationwindow/data/focusAfterPopupClosed.qml b/tests/auto/applicationwindow/data/focusAfterPopupClosed.qml deleted file mode 100644 index f0499a3a..00000000 --- a/tests/auto/applicationwindow/data/focusAfterPopupClosed.qml +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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.6 -import QtQuick.Controls 2.1 - -ApplicationWindow { - width: 200 - height: 200 - visible: true - - signal focusScopeKeyPressed - signal focusPopupKeyPressed - - property alias fileMenu: fileMenu - property alias toolButton: toolButton - property alias focusScope: focusScope - property alias focusPopup: focusPopup - - header: ToolBar { - ToolButton { - id: toolButton - text: qsTr("File") - onClicked: fileMenu.open() - focusPolicy: Qt.TabFocus - - Menu { - id: fileMenu - y: parent.height - - MenuItem { - text: qsTr("New") - } - MenuItem { - text: qsTr("Open") - } - MenuItem { - text: qsTr("Close") - } - } - } - } - - FocusScope { - id: focusScope - focus: true - anchors.fill: parent - - Keys.onSpacePressed: focusScopeKeyPressed() - } - - Popup { - id: focusPopup - focus: true - width: parent.width - height: parent.height - - Item { - focus: true - Keys.onSpacePressed: focusPopupKeyPressed() - } - } -} - diff --git a/tests/auto/applicationwindow/data/font.qml b/tests/auto/applicationwindow/data/font.qml deleted file mode 100644 index a675aeab..00000000 --- a/tests/auto/applicationwindow/data/font.qml +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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.6 -import QtQuick.Controls 2.1 -import QtQuick.Templates 2.1 as T - -ApplicationWindow { - objectName: "appWin" - width: 400 - height: 400 - - property alias mainItem: mainItem - - font.family: "Arial" - - T.Control { - id: mainItem - objectName: "mainItem" - anchors.fill: parent - property alias item_2: _item_2; - property alias item_3: _item_3; - property alias item_4: _item_4; - property alias item_5: _item_5; - property alias item_6: _item_6; - T.Control { - id: _item_2 - objectName: "_item_2" - T.Control { - id: _item_3 - objectName: "_item_3" - } - } - T.TextArea { - id: _item_4 - objectName: "_item_4" - text: "Text Area" - } - T.TextField { - id: _item_5 - objectName: "_item_5" - text: "Text Field" - } - T.Label { - id: _item_6 - objectName: "_item_6" - text: "Label" - } - } -} diff --git a/tests/auto/applicationwindow/data/layout.qml b/tests/auto/applicationwindow/data/layout.qml deleted file mode 100644 index a80b2d48..00000000 --- a/tests/auto/applicationwindow/data/layout.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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.6 -import QtQuick.Controls 2.0 - -ApplicationWindow { - width: 200 - height: 200 - visible: true - - header: ToolBar { } - footer: ToolBar { } -} diff --git a/tests/auto/applicationwindow/data/locale.qml b/tests/auto/applicationwindow/data/locale.qml deleted file mode 100644 index 92edb53a..00000000 --- a/tests/auto/applicationwindow/data/locale.qml +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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.6 -import QtQuick.Controls 2.1 -import QtQuick.Templates 2.1 as T - -ApplicationWindow { - objectName: "appWin" - width: 400 - height: 400 - - property alias mainItem: mainItem - - T.Control { - id: mainItem - objectName: "mainItem" - anchors.fill: parent - property alias item_2: _item_2; - property alias item_3: _item_3; - T.Control { - id: _item_2 - objectName: "_item_2" - T.Control { - id: _item_3 - objectName: "_item_3" - } - } - } -} diff --git a/tests/auto/applicationwindow/tst_applicationwindow.cpp b/tests/auto/applicationwindow/tst_applicationwindow.cpp deleted file mode 100644 index f35d9b7d..00000000 --- a/tests/auto/applicationwindow/tst_applicationwindow.cpp +++ /dev/null @@ -1,838 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later 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 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../shared/util.h" -#include "../shared/visualtestutil.h" - -using namespace QQuickVisualTestUtil; - -class tst_applicationwindow : public QQmlDataTest -{ - Q_OBJECT -public: - -private slots: - void qmlCreation(); - void activeFocusOnTab1(); - void activeFocusOnTab2(); - void defaultFocus(); - void implicitFill(); - void attachedProperties(); - void font(); - void defaultFont(); - void locale(); - void activeFocusControl_data(); - void activeFocusControl(); - void focusAfterPopupClosed(); - void clearFocusOnDestruction(); - void layout(); - void componentComplete(); -}; - -void tst_applicationwindow::qmlCreation() -{ - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(testFileUrl("basicapplicationwindow.qml")); - QObject* created = component.create(); - QScopedPointer cleanup(created); - QVERIFY(created); - - QQuickWindow* window = qobject_cast(created); - QVERIFY(window); - QVERIFY(!window->isVisible()); - - QCOMPARE(created->property("title"), QVariant("Test Application Window")); - - QQuickItem* statusBar = qvariant_cast(created->property("statusBar")); - QVERIFY(!statusBar); - - QQuickItem* header = qvariant_cast(created->property("header")); - QVERIFY(!header); - - QQuickItem* footer = qvariant_cast(created->property("footer")); - QVERIFY(!footer); -} - -void tst_applicationwindow::activeFocusOnTab1() -{ - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(testFileUrl("activefocusontab.qml")); - QObject* created = component.create(); - QScopedPointer cleanup(created); - QVERIFY(created); - - QQuickWindow* window = qobject_cast(created); - QVERIFY(window); - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - QVERIFY(QGuiApplication::focusWindow() == window); - - QQuickItem* contentItem = window->contentItem(); - QVERIFY(contentItem); - QVERIFY(contentItem->hasActiveFocus()); - - QQuickItem* item = findItem(window->contentItem(), "sub1"); - QVERIFY(item); - QVERIFY(!item->hasActiveFocus()); - - // Tab: contentItem->sub1 - QKeyEvent key(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem(window->contentItem(), "sub1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // Tab: sub1->sub2 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem(window->contentItem(), "sub2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // Tab: sub2->sub1 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem(window->contentItem(), "sub1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); -} - -void tst_applicationwindow::activeFocusOnTab2() -{ - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(testFileUrl("activefocusontab.qml")); - QObject* created = component.create(); - QScopedPointer cleanup(created); - QVERIFY(created); - - QQuickWindow* window = qobject_cast(created); - QVERIFY(window); - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - QVERIFY(QGuiApplication::focusWindow() == window); - - QQuickItem* contentItem = window->contentItem(); - QVERIFY(contentItem); - QVERIFY(contentItem->hasActiveFocus()); - - QQuickItem* item = findItem(window->contentItem(), "sub2"); - QVERIFY(item); - QVERIFY(!item->hasActiveFocus()); - - // BackTab: contentItem->sub2 - QKeyEvent key(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem(window->contentItem(), "sub2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // BackTab: sub2->sub1 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem(window->contentItem(), "sub1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // BackTab: sub1->sub2 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem(window->contentItem(), "sub2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); -} - -void tst_applicationwindow::defaultFocus() -{ - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(testFileUrl("defaultFocus.qml")); - QObject* created = component.create(); - QScopedPointer cleanup(created); - Q_UNUSED(cleanup); - QVERIFY(created); - - QQuickWindow* window = qobject_cast(created); - QVERIFY(window); - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - QVERIFY(QGuiApplication::focusWindow() == window); - - QQuickItem* contentItem = window->contentItem(); - QVERIFY(contentItem); - QVERIFY(contentItem->hasActiveFocus()); - - // A single item in an ApplicationWindow with focus: true should receive focus. - QQuickItem* item = findItem(window->contentItem(), "item"); - QVERIFY(item); - QVERIFY(item->hasFocus()); - QVERIFY(item->hasActiveFocus()); -} - -void tst_applicationwindow::implicitFill() -{ - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(testFileUrl("fill.qml")); - QObject* created = component.create(); - QScopedPointer cleanup(created); - QVERIFY(created); - - QQuickWindow* window = qobject_cast(created); - QVERIFY(window); - QVERIFY(!window->isVisible()); - QCOMPARE(window->width(), 400); - QCOMPARE(window->height(), 400); - - window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickItem *stackView = window->property("stackView").value(); - QVERIFY(stackView); - QCOMPARE(stackView->width(), 400.0); - QCOMPARE(stackView->height(), 400.0); - - QQuickItem *nextItem = window->property("nextItem").value(); - QVERIFY(nextItem); - - QVERIFY(QMetaObject::invokeMethod(window, "pushNextItem")); - QCOMPARE(nextItem->width(), 400.0); - QCOMPARE(nextItem->height(), 400.0); -} - -void tst_applicationwindow::attachedProperties() -{ - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(testFileUrl("attachedProperties.qml")); - - QScopedPointer object(component.create()); - QVERIFY2(!object.isNull(), qPrintable(component.errorString())); - - QQuickApplicationWindow *window = qobject_cast(object.data()); - QVERIFY(window); - - QQuickItem *childControl = object->property("childControl").value(); - QVERIFY(childControl); - QCOMPARE(childControl->property("attached_window").value(), window); - QCOMPARE(childControl->property("attached_contentItem").value(), window->contentItem()); - QCOMPARE(childControl->property("attached_activeFocusControl").value(), window->activeFocusControl()); - QCOMPARE(childControl->property("attached_header").value(), window->header()); - QCOMPARE(childControl->property("attached_footer").value(), window->footer()); - QCOMPARE(childControl->property("attached_overlay").value(), window->overlay()); - - QQuickItem *childItem = object->property("childItem").value(); - QVERIFY(childItem); - QCOMPARE(childItem->property("attached_window").value(), window); - QCOMPARE(childItem->property("attached_contentItem").value(), window->contentItem()); - QCOMPARE(childItem->property("attached_activeFocusControl").value(), window->activeFocusControl()); - QCOMPARE(childItem->property("attached_header").value(), window->header()); - QCOMPARE(childItem->property("attached_footer").value(), window->footer()); - QCOMPARE(childItem->property("attached_overlay").value(), window->overlay()); - - QObject *childObject = object->property("childObject").value(); - QVERIFY(childObject); - QVERIFY(!childObject->property("attached_window").value()); - QVERIFY(!childObject->property("attached_contentItem").value()); - QVERIFY(!childObject->property("attached_activeFocusControl").value()); - QVERIFY(!childObject->property("attached_header").value()); - QVERIFY(!childObject->property("attached_footer").value()); - QVERIFY(!childObject->property("attached_overlay").value()); - - QQuickWindow *childWindow = object->property("childWindow").value(); - QVERIFY(childWindow); - QVERIFY(!childWindow->property("attached_window").value()); - QVERIFY(!childWindow->property("attached_contentItem").value()); - QVERIFY(!childWindow->property("attached_activeFocusControl").value()); - QVERIFY(!childWindow->property("attached_header").value()); - QVERIFY(!childWindow->property("attached_footer").value()); - QVERIFY(!childWindow->property("attached_overlay").value()); - - QQuickItem *childWindowControl = object->property("childWindowControl").value(); - QVERIFY(childWindowControl); - QVERIFY(!childWindowControl->property("attached_window").value()); - QVERIFY(!childWindowControl->property("attached_contentItem").value()); - QVERIFY(!childWindowControl->property("attached_activeFocusControl").value()); - QVERIFY(!childWindowControl->property("attached_header").value()); - QVERIFY(!childWindowControl->property("attached_footer").value()); - QCOMPARE(childWindowControl->property("attached_overlay").value(), QQuickOverlay::overlay(childWindow)); - - QQuickItem *childWindowItem = object->property("childWindowItem").value(); - QVERIFY(childWindowItem); - QVERIFY(!childWindowItem->property("attached_window").value()); - QVERIFY(!childWindowItem->property("attached_contentItem").value()); - QVERIFY(!childWindowItem->property("attached_activeFocusControl").value()); - QVERIFY(!childWindowItem->property("attached_header").value()); - QVERIFY(!childWindowItem->property("attached_footer").value()); - QCOMPARE(childWindowItem->property("attached_overlay").value(), QQuickOverlay::overlay(childWindow)); - - QObject *childWindowObject = object->property("childWindowObject").value(); - QVERIFY(childWindowObject); - QVERIFY(!childWindowObject->property("attached_window").value()); - QVERIFY(!childWindowObject->property("attached_contentItem").value()); - QVERIFY(!childWindowObject->property("attached_activeFocusControl").value()); - QVERIFY(!childWindowObject->property("attached_header").value()); - QVERIFY(!childWindowObject->property("attached_footer").value()); - QVERIFY(!childWindowObject->property("attached_overlay").value()); - - QQuickApplicationWindow *childAppWindow = object->property("childAppWindow").value(); - QVERIFY(childAppWindow); - QVERIFY(!childAppWindow->property("attached_window").value()); - QVERIFY(!childAppWindow->property("attached_contentItem").value()); - QVERIFY(!childAppWindow->property("attached_activeFocusControl").value()); - QVERIFY(!childAppWindow->property("attached_header").value()); - QVERIFY(!childAppWindow->property("attached_footer").value()); - QVERIFY(!childAppWindow->property("attached_overlay").value()); - - QQuickItem *childAppWindowControl = object->property("childAppWindowControl").value(); - QVERIFY(childAppWindowControl); - QCOMPARE(childAppWindowControl->property("attached_window").value(), childAppWindow); - QCOMPARE(childAppWindowControl->property("attached_contentItem").value(), childAppWindow->contentItem()); - QCOMPARE(childAppWindowControl->property("attached_activeFocusControl").value(), childAppWindow->activeFocusControl()); - QCOMPARE(childAppWindowControl->property("attached_header").value(), childAppWindow->header()); - QCOMPARE(childAppWindowControl->property("attached_footer").value(), childAppWindow->footer()); - QCOMPARE(childAppWindowControl->property("attached_overlay").value(), childAppWindow->overlay()); - - QQuickItem *childAppWindowItem = object->property("childAppWindowItem").value(); - QVERIFY(childAppWindowItem); - QCOMPARE(childAppWindowItem->property("attached_window").value(), childAppWindow); - QCOMPARE(childAppWindowItem->property("attached_contentItem").value(), childAppWindow->contentItem()); - QCOMPARE(childAppWindowItem->property("attached_activeFocusControl").value(), childAppWindow->activeFocusControl()); - QCOMPARE(childAppWindowItem->property("attached_header").value(), childAppWindow->header()); - QCOMPARE(childAppWindowItem->property("attached_footer").value(), childAppWindow->footer()); - QCOMPARE(childAppWindowItem->property("attached_overlay").value(), childAppWindow->overlay()); - - QObject *childAppWindowObject = object->property("childAppWindowObject").value(); - QVERIFY(childAppWindowObject); - QVERIFY(!childAppWindowObject->property("attached_window").value()); - QVERIFY(!childAppWindowObject->property("attached_contentItem").value()); - QVERIFY(!childAppWindowObject->property("attached_activeFocusControl").value()); - QVERIFY(!childAppWindowObject->property("attached_header").value()); - QVERIFY(!childAppWindowObject->property("attached_footer").value()); - QVERIFY(!childAppWindowObject->property("attached_overlay").value()); - - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QVERIFY(!childControl->hasActiveFocus()); - childControl->forceActiveFocus(); - QTRY_VERIFY(childControl->hasActiveFocus()); - QCOMPARE(window->activeFocusItem(), childControl); - QCOMPARE(childControl->property("attached_activeFocusControl").value(), childControl); - - QQuickItem *header = new QQuickItem; - window->setHeader(header); - QCOMPARE(window->header(), header); - QCOMPARE(childControl->property("attached_header").value(), header); - - QQuickItem *footer = new QQuickItem; - window->setFooter(footer); - QCOMPARE(window->footer(), footer); - QCOMPARE(childControl->property("attached_footer").value(), footer); - - childAppWindow->show(); - childAppWindow->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(childAppWindow)); - - QVERIFY(!childAppWindowControl->hasActiveFocus()); - childAppWindowControl->forceActiveFocus(); - QTRY_VERIFY(childAppWindowControl->hasActiveFocus()); - QCOMPARE(childAppWindow->activeFocusItem(), childAppWindowControl); - QCOMPARE(childAppWindowControl->property("attached_activeFocusControl").value(), childAppWindowControl); - - childControl->setParentItem(childAppWindow->contentItem()); - 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_header").value(), childAppWindow->header()); - QCOMPARE(childControl->property("attached_footer").value(), childAppWindow->footer()); - QCOMPARE(childControl->property("attached_overlay").value(), childAppWindow->overlay()); - - childItem->setParentItem(childAppWindow->contentItem()); - 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_header").value(), childAppWindow->header()); - QCOMPARE(childItem->property("attached_footer").value(), childAppWindow->footer()); - QCOMPARE(childItem->property("attached_overlay").value(), childAppWindow->overlay()); - - 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()); - - // ### A temporary workaround to unblock the CI until the crash caused - // by https://codereview.qt-project.org/#/c/108517/ has been fixed... - window->hide(); - qApp->processEvents(); -} - -void tst_applicationwindow::font() -{ - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(testFileUrl("font.qml")); - QObject* created = component.create(); - QScopedPointer cleanup(created); - QVERIFY(created); - - QQuickApplicationWindow* window = qobject_cast(created); - QVERIFY(window); - QVERIFY(!window->isVisible()); - QCOMPARE(window->width(), 400); - QCOMPARE(window->height(), 400); - - window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QFont font = window->font(); - - QQuickControl *mainItem = window->property("mainItem").value(); - QVERIFY(mainItem); - QCOMPARE(mainItem->width(), 400.0); - QCOMPARE(mainItem->height(), 400.0); - QCOMPARE(mainItem->font(), font); - - QQuickControl *item2 = mainItem->property("item_2").value(); - QVERIFY(item2); - QQuickControl *item3 = mainItem->property("item_3").value(); - QVERIFY(item3); - QQuickTextArea *item4 = mainItem->property("item_4").value(); - QVERIFY(item4); - QQuickTextField *item5 = mainItem->property("item_5").value(); - QVERIFY(item5); - QQuickLabel *item6 = mainItem->property("item_6").value(); - QVERIFY(item6); - - QCOMPARE(item2->font(), font); - QCOMPARE(item3->font(), font); - QCOMPARE(item4->font(), font); - QCOMPARE(item5->font(), font); - QCOMPARE(item6->font(), font); - - int pointSize = font.pointSize(); - font.setPixelSize(pointSize + 5); - window->setFont(font); - - QCOMPARE(window->font(), font); - QCOMPARE(mainItem->font(), font); - QCOMPARE(item2->font(), font); - QCOMPARE(item3->font(), font); - QCOMPARE(item4->font(), font); - QCOMPARE(item5->font(), font); - QCOMPARE(item6->font(), font); -} - -class TestTheme : public QQuickProxyTheme -{ -public: - TestTheme(QPlatformTheme *theme) : QQuickProxyTheme(theme), m_font("Courier") - { QGuiApplicationPrivate::platform_theme = this; } - - const QFont *font(Font type = SystemFont) const override - { - Q_UNUSED(type); - return &m_font; - } - - QFont m_font; -}; - -void tst_applicationwindow::defaultFont() -{ - TestTheme theme(QGuiApplicationPrivate::platform_theme); - - QQmlEngine engine; - QQmlComponent component(&engine); - component.setData("import QtQuick.Controls 2.1; ApplicationWindow { }", QUrl()); - - QScopedPointer window; - window.reset(static_cast(component.create())); - QVERIFY(!window.isNull()); - QCOMPARE(window->font(), *theme.font()); -} - -void tst_applicationwindow::locale() -{ - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(testFileUrl("locale.qml")); - QObject* created = component.create(); - QScopedPointer cleanup(created); - QVERIFY(created); - - QQuickApplicationWindow* window = qobject_cast(created); - QVERIFY(window); - QVERIFY(!window->isVisible()); - QCOMPARE(window->width(), 400); - QCOMPARE(window->height(), 400); - - window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QLocale l = window->locale(); - - QQuickControl *mainItem = window->property("mainItem").value(); - QVERIFY(mainItem); - QCOMPARE(mainItem->width(), 400.0); - QCOMPARE(mainItem->height(), 400.0); - QCOMPARE(mainItem->locale(), l); - - QQuickControl *item2 = mainItem->property("item_2").value(); - QVERIFY(item2); - QQuickControl *item3 = mainItem->property("item_3").value(); - QVERIFY(item3); - - QCOMPARE(item2->locale(), l); - QCOMPARE(item3->locale(), l); - - l = QLocale("en_US"); - window->setLocale(l); - - QCOMPARE(window->locale(), l); - QCOMPARE(mainItem->locale(), l); - QCOMPARE(item2->locale(), l); - QCOMPARE(item3->locale(), l); - - l = QLocale("ar_EG"); - window->setLocale(l); - - QCOMPARE(window->locale(), l); - QCOMPARE(mainItem->locale(), l); - QCOMPARE(item2->locale(), l); - QCOMPARE(item3->locale(), l); -} - -void tst_applicationwindow::activeFocusControl_data() -{ - QTest::addColumn("containerName"); - QTest::addColumn("activeFocusItemName"); - QTest::addColumn("activeFocusControlName"); - - QTest::newRow("Column:TextInput") << QByteArray("container_column") << QByteArray("textInput_column") << QByteArray(); - QTest::newRow("Column:TextEdit") << QByteArray("container_column") << QByteArray("textEdit_column") << QByteArray(); - QTest::newRow("Column:TextField") << QByteArray("container_column") << QByteArray("textField_column") << QByteArray("textField_column"); - QTest::newRow("Column:TextArea") << QByteArray("container_column") << QByteArray("textArea_column") << QByteArray("textArea_column"); - QTest::newRow("Column:SpinBox") << QByteArray("container_column") << QByteArray("spinContent_column") << QByteArray("spinBox_column"); - - QTest::newRow("Frame:TextInput") << QByteArray("container_frame") << QByteArray("textInput_frame") << QByteArray("container_frame"); - QTest::newRow("Frame:TextEdit") << QByteArray("container_frame") << QByteArray("textEdit_frame") << QByteArray("container_frame"); - QTest::newRow("Frame:TextField") << QByteArray("container_frame") << QByteArray("textField_frame") << QByteArray("textField_frame"); - QTest::newRow("Frame:TextArea") << QByteArray("container_frame") << QByteArray("textArea_frame") << QByteArray("textArea_frame"); - QTest::newRow("Frame:SpinBox") << QByteArray("container_frame") << QByteArray("spinContent_frame") << QByteArray("spinBox_frame"); -} - -void tst_applicationwindow::activeFocusControl() -{ - QFETCH(QByteArray, containerName); - QFETCH(QByteArray, activeFocusItemName); - QFETCH(QByteArray, activeFocusControlName); - - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(testFileUrl("activeFocusControl.qml")); - QScopedPointer object(component.create()); - QVERIFY(!object.isNull()); - - QQuickApplicationWindow* window = qobject_cast(object.data()); - QVERIFY(window); - QVERIFY(!window->isVisible()); - QCOMPARE(window->width(), 400); - QCOMPARE(window->height(), 400); - - window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickItem *container = window->property(containerName).value(); - QVERIFY(container); - - QQuickItem *activeFocusItem = window->property(activeFocusItemName).value(); - QVERIFY(activeFocusItem); - activeFocusItem->forceActiveFocus(); - QVERIFY(activeFocusItem->hasActiveFocus()); - QCOMPARE(window->activeFocusItem(), activeFocusItem); - - QQuickItem *activeFocusControl = window->property(activeFocusControlName).value(); - if (activeFocusControlName.isEmpty()) { - QVERIFY(!activeFocusControl); - } else { - QVERIFY(activeFocusControl); - QVERIFY(activeFocusControl->hasActiveFocus()); - } - QCOMPARE(window->activeFocusControl(), activeFocusControl); -} - -void tst_applicationwindow::focusAfterPopupClosed() -{ - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(testFileUrl("focusAfterPopupClosed.qml")); - QScopedPointer window(qobject_cast(component.create())); - QVERIFY(window); - - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window.data())); - QVERIFY(QGuiApplication::focusWindow() == window.data()); - - QQuickItem* contentItem = window->contentItem(); - QVERIFY(contentItem); - QVERIFY(contentItem->hasActiveFocus()); - - QQuickItem* focusScope = window->property("focusScope").value(); - QVERIFY(focusScope); - QVERIFY(focusScope->hasActiveFocus()); - - QSignalSpy focusScopeSpy(window.data(), SIGNAL(focusScopeKeyPressed())); - QTest::keyClick(window.data(), Qt::Key_Space); - QCOMPARE(focusScopeSpy.count(), 1); - - // Open the menu. - QQuickItem* toolButton = window->property("toolButton").value(); - QVERIFY(toolButton); - QTest::mouseClick(window.data(), Qt::LeftButton, Qt::NoModifier, - toolButton->mapFromScene(QPointF(toolButton->width() / 2, toolButton->height() / 2)).toPoint()); - QVERIFY(!focusScope->hasActiveFocus()); - - // The FocusScope shouldn't receive any key events while the menu is open. - QTest::keyClick(window.data(), Qt::Key_Space); - QCOMPARE(focusScopeSpy.count(), 1); - - // Close the menu. The FocusScope should regain focus. - QTest::keyClick(window.data(), Qt::Key_Escape); - QVERIFY(focusScope->hasActiveFocus()); - - QTest::keyClick(window.data(), Qt::Key_Space); - QCOMPARE(focusScopeSpy.count(), 2); - - QQuickPopup *focusPopup = window->property("focusPopup").value(); - QVERIFY(focusPopup); - QVERIFY(!focusPopup->hasActiveFocus()); - - focusPopup->open(); - QVERIFY(focusPopup->isVisible()); - - QSignalSpy focusPopupSpy(window.data(), SIGNAL(focusPopupKeyPressed())); - QTest::keyClick(window.data(), Qt::Key_Space); - QCOMPARE(focusPopupSpy.count(), 1); - - QQuickMenu *fileMenu = window->property("fileMenu").value(); - QVERIFY(fileMenu); - fileMenu->open(); - QVERIFY(fileMenu->isVisible()); - - // The Popup shouldn't receive any key events while the menu is open. - QTest::keyClick(window.data(), Qt::Key_Space); - QCOMPARE(focusPopupSpy.count(), 1); - - // Close the menu. The Popup should regain focus. - QTest::keyClick(window.data(), Qt::Key_Escape); - QVERIFY(focusPopup->hasActiveFocus()); - - QTest::keyClick(window.data(), Qt::Key_Space); - QCOMPARE(focusPopupSpy.count(), 2); - - // Close the popup. The FocusScope should regain focus. - QTest::keyClick(window.data(), Qt::Key_Escape); - QVERIFY(focusScope->hasActiveFocus()); - - QTest::keyClick(window.data(), Qt::Key_Space); - QCOMPARE(focusScopeSpy.count(), 3); -} - -void tst_applicationwindow::clearFocusOnDestruction() -{ - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(testFileUrl("clearfocusondestruction.qml")); - QScopedPointer window(qobject_cast(component.create())); - QVERIFY(window); - - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window.data())); - QVERIFY(QGuiApplication::focusWindow() == window.data()); - - QQuickItem* contentItem = window->contentItem(); - QVERIFY(contentItem); - QVERIFY(contentItem->hasActiveFocus()); - - QQuickItem* focusScope = window->property("textfield").value(); - QVERIFY(focusScope); - QVERIFY(focusScope->hasActiveFocus()); - - QSignalSpy spy(window.data(), SIGNAL(activeFocusControlChanged())); - // destroy the window, do not crash - window.reset(); - - /* - QQuickWindow::activeFocusItemChanged() is emitted inconsistently and - only for certain use cases. Ideally it should be emitted whenever a - QQuickWindow with a focus item is destroyed, but it doesn't... It might - also be favorable to not emit it for performance reason. - - However, activeFocusControlChanged() is emitted more consistently, which - of course makes it inconsistent with the emission of - activeFocusItemChanged().... - - Therefore, if you have good reasons to change the behavior (and not emit - it) take the test below with a grain of salt. - */ - QCOMPARE(spy.count(), 1); -} - -void tst_applicationwindow::layout() -{ - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(testFileUrl("layout.qml")); - QScopedPointer object(component.create()); - QVERIFY(!object.isNull()); - - QQuickApplicationWindow* window = qobject_cast(object.data()); - QVERIFY(window); - QVERIFY(QTest::qWaitForWindowExposed(window)); - - QQuickItem *content = window->contentItem(); - QVERIFY(content); - QQuickItem *header = window->header(); - QVERIFY(header); - QQuickItem *footer = window->footer(); - QVERIFY(footer); - - QCOMPARE(header->x(), 0.0); - QCOMPARE(header->y(), -header->height()); - QCOMPARE(header->width(), qreal(window->width())); - QVERIFY(header->height() > 0); - - QCOMPARE(footer->x(), 0.0); - QCOMPARE(footer->y(), content->height()); - QCOMPARE(footer->width(), qreal(window->width())); - QVERIFY(footer->height() > 0.0); - - QCOMPARE(content->x(), 0.0); - QCOMPARE(content->y(), header->height()); - QCOMPARE(content->width(), qreal(window->width())); - QCOMPARE(content->height(), window->height() - header->height() - footer->height()); - - header->setVisible(false); - QCOMPARE(content->x(), 0.0); - QCOMPARE(content->y(), 0.0); - QCOMPARE(content->width(), qreal(window->width())); - QCOMPARE(content->height(), window->height() - footer->height()); - - footer->setVisible(false); - QCOMPARE(content->x(), 0.0); - QCOMPARE(content->y(), 0.0); - QCOMPARE(content->width(), qreal(window->width())); - QCOMPARE(content->height(), qreal(window->height())); -} - -class FriendlyApplicationWindow : public QQuickApplicationWindow -{ - friend class tst_applicationwindow; -}; - -void tst_applicationwindow::componentComplete() -{ - FriendlyApplicationWindow cppWindow; - QVERIFY(cppWindow.isComponentComplete()); - - QQmlEngine engine; - QQmlComponent component(&engine); - component.setData("import QtQuick.Controls 2.2; ApplicationWindow { }", QUrl()); - - FriendlyApplicationWindow *qmlWindow = static_cast(component.beginCreate(engine.rootContext())); - QVERIFY(qmlWindow); - QVERIFY(!qmlWindow->isComponentComplete()); - - component.completeCreate(); - QVERIFY(qmlWindow->isComponentComplete()); -} - -QTEST_MAIN(tst_applicationwindow) - -#include "tst_applicationwindow.moc" diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 3acc4704..2eb23fd0 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -1,7 +1,6 @@ TEMPLATE = subdirs SUBDIRS += \ accessibility \ - applicationwindow \ calendar \ controls \ cursor \ @@ -10,6 +9,7 @@ SUBDIRS += \ menu \ platform \ pressandhold \ + qquickapplicationwindow \ qquickdrawer \ qquickmaterialstyle \ qquickmaterialstyleconf \ @@ -23,7 +23,7 @@ SUBDIRS += \ snippets # QTBUG-60268 -boot2qt: SUBDIRS -= applicationwindow calendar controls cursor \ +boot2qt: SUBDIRS -= qquickapplicationwindow calendar controls cursor \ qquickdrawer focus font menu platform qquickpopup qquickmaterialstyle \ qquickmaterialstyleconf qquickuniversalstyle \ qquickuniversalstyleconf snippets diff --git a/tests/auto/qquickapplicationwindow/data/activeFocusControl.qml b/tests/auto/qquickapplicationwindow/data/activeFocusControl.qml new file mode 100644 index 00000000..940e8e08 --- /dev/null +++ b/tests/auto/qquickapplicationwindow/data/activeFocusControl.qml @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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.6 +import QtQuick.Controls 2.1 + +ApplicationWindow { + width: 400 + height: 400 + + property alias container_column: column + property alias textInput_column: ti_column + property alias textEdit_column: te_column + property alias textField_column: tf_column + property alias textArea_column: ta_column + property alias spinBox_column: sp_column + property alias spinContent_column: sp_column.contentItem + + property alias container_frame: frame + property alias textInput_frame: ti_frame + property alias textEdit_frame: te_frame + property alias textField_frame: tf_frame + property alias textArea_frame: ta_frame + property alias spinBox_frame: sp_frame + property alias spinContent_frame: sp_frame.contentItem + + Column { + id: column + + TextInput { + id: ti_column + } + TextEdit { + id: te_column + } + TextField { + id: tf_column + } + TextArea { + id: ta_column + } + SpinBox { + id: sp_column + } + } + + Frame { + id: frame + + Column { + TextInput { + id: ti_frame + } + TextEdit { + id: te_frame + } + TextField { + id: tf_frame + } + TextArea { + id: ta_frame + } + SpinBox { + id: sp_frame + } + } + } +} diff --git a/tests/auto/qquickapplicationwindow/data/activefocusontab.qml b/tests/auto/qquickapplicationwindow/data/activefocusontab.qml new file mode 100644 index 00000000..357ea9a4 --- /dev/null +++ b/tests/auto/qquickapplicationwindow/data/activefocusontab.qml @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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.6 +import QtQuick.Controls 2.1 + +ApplicationWindow { + title: "Test Application Window" + width: 100 + height: 100 + Item { + id: main + objectName: "main" + width: 100 + height: 100 + //focus: true + Column { + anchors.fill: parent + id: column + objectName: "column" + Item { + id: sub1 + objectName: "sub1" + activeFocusOnTab: true + Accessible.role: Accessible.Table + width: 100 + height: 50 + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + } + Item { + id: sub2 + objectName: "sub2" + activeFocusOnTab: true + Accessible.role: Accessible.Table + width: 100 + height: 50 + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + } + } + } +} diff --git a/tests/auto/qquickapplicationwindow/data/attachedProperties.qml b/tests/auto/qquickapplicationwindow/data/attachedProperties.qml new file mode 100644 index 00000000..09bc47ef --- /dev/null +++ b/tests/auto/qquickapplicationwindow/data/attachedProperties.qml @@ -0,0 +1,190 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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.6 +import QtQuick.Window 2.2 +import QtQuick.Controls 2.1 + +ApplicationWindow { + property alias childControl: childControl + property alias childItem: childItem + property alias childObject: childObject + + Control { + id: childControl + + property ApplicationWindow attached_window: ApplicationWindow.window + property Item attached_contentItem: ApplicationWindow.contentItem + property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl + property Item attached_header: ApplicationWindow.header + property Item attached_footer: ApplicationWindow.footer + property Item attached_overlay: ApplicationWindow.overlay + } + + Item { + id: childItem + + property ApplicationWindow attached_window: ApplicationWindow.window + property Item attached_contentItem: ApplicationWindow.contentItem + property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl + property Item attached_header: ApplicationWindow.header + property Item attached_footer: ApplicationWindow.footer + property Item attached_overlay: ApplicationWindow.overlay + } + + QtObject { + id: childObject + + property ApplicationWindow attached_window: ApplicationWindow.window + property Item attached_contentItem: ApplicationWindow.contentItem + property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl + property Item attached_header: ApplicationWindow.header + property Item attached_footer: ApplicationWindow.footer + property Item attached_overlay: ApplicationWindow.overlay + } + + property alias childWindow: childWindow + property alias childWindowControl: childWindowControl + property alias childWindowItem: childWindowItem + property alias childWindowObject: childWindowObject + + Window { + id: childWindow + + property ApplicationWindow attached_window: ApplicationWindow.window + property Item attached_contentItem: ApplicationWindow.contentItem + property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl + property Item attached_header: ApplicationWindow.header + property Item attached_footer: ApplicationWindow.footer + property Item attached_overlay: ApplicationWindow.overlay + + Control { + id: childWindowControl + + property ApplicationWindow attached_window: ApplicationWindow.window + property Item attached_contentItem: ApplicationWindow.contentItem + property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl + property Item attached_header: ApplicationWindow.header + property Item attached_footer: ApplicationWindow.footer + property Item attached_overlay: ApplicationWindow.overlay + } + + Item { + id: childWindowItem + + property ApplicationWindow attached_window: ApplicationWindow.window + property Item attached_contentItem: ApplicationWindow.contentItem + property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl + property Item attached_header: ApplicationWindow.header + property Item attached_footer: ApplicationWindow.footer + property Item attached_overlay: ApplicationWindow.overlay + } + + QtObject { + id: childWindowObject + + property ApplicationWindow attached_window: ApplicationWindow.window + property Item attached_contentItem: ApplicationWindow.contentItem + property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl + property Item attached_header: ApplicationWindow.header + property Item attached_footer: ApplicationWindow.footer + property Item attached_overlay: ApplicationWindow.overlay + } + } + + property alias childAppWindow: childAppWindow + property alias childAppWindowControl: childAppWindowControl + property alias childAppWindowItem: childAppWindowItem + property alias childAppWindowObject: childAppWindowObject + + ApplicationWindow { + id: childAppWindow + + property ApplicationWindow attached_window: ApplicationWindow.window + property Item attached_contentItem: ApplicationWindow.contentItem + property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl + property Item attached_header: ApplicationWindow.header + property Item attached_footer: ApplicationWindow.footer + property Item attached_overlay: ApplicationWindow.overlay + + Control { + id: childAppWindowControl + + property ApplicationWindow attached_window: ApplicationWindow.window + property Item attached_contentItem: ApplicationWindow.contentItem + property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl + property Item attached_header: ApplicationWindow.header + property Item attached_footer: ApplicationWindow.footer + property Item attached_overlay: ApplicationWindow.overlay + } + + Item { + id: childAppWindowItem + + property ApplicationWindow attached_window: ApplicationWindow.window + property Item attached_contentItem: ApplicationWindow.contentItem + property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl + property Item attached_header: ApplicationWindow.header + property Item attached_footer: ApplicationWindow.footer + property Item attached_overlay: ApplicationWindow.overlay + } + + QtObject { + id: childAppWindowObject + + property ApplicationWindow attached_window: ApplicationWindow.window + property Item attached_contentItem: ApplicationWindow.contentItem + property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl + property Item attached_header: ApplicationWindow.header + property Item attached_footer: ApplicationWindow.footer + property Item attached_overlay: ApplicationWindow.overlay + } + } +} diff --git a/tests/auto/qquickapplicationwindow/data/basicapplicationwindow.qml b/tests/auto/qquickapplicationwindow/data/basicapplicationwindow.qml new file mode 100644 index 00000000..16182f59 --- /dev/null +++ b/tests/auto/qquickapplicationwindow/data/basicapplicationwindow.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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.6 +import QtQuick.Controls 2.1 + +ApplicationWindow { + title: "Test Application Window" +} diff --git a/tests/auto/qquickapplicationwindow/data/clearfocusondestruction.qml b/tests/auto/qquickapplicationwindow/data/clearfocusondestruction.qml new file mode 100644 index 00000000..3589439e --- /dev/null +++ b/tests/auto/qquickapplicationwindow/data/clearfocusondestruction.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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.7 +import QtQuick.Controls 2.1 +import QtQuick.Layouts 1.3 +import QtGraphicalEffects 1.0 + +ApplicationWindow { + width: 200 + height: 200 + visible: true + + property alias textfield: textfield + + /* + * The code below is the simplest way we can trigger that the signal + * activeFocusItemChanged() is emitted during destruction of the + * ApplicationWindow. This caused a crash in QQuickApplicationWindow. + */ + FastBlur { + id: fastBlur + anchors.fill: parent + radius: 30 + source: ShaderEffectSource { + id: effectsource + sourceItem: textfield + sourceRect: Qt.rect( 0, 0, fastBlur.width, fastBlur.height ) + } + } + + TextField { + id: textfield + anchors.bottom: parent.bottom + focus: true + } +} diff --git a/tests/auto/qquickapplicationwindow/data/defaultFocus.qml b/tests/auto/qquickapplicationwindow/data/defaultFocus.qml new file mode 100644 index 00000000..741ce908 --- /dev/null +++ b/tests/auto/qquickapplicationwindow/data/defaultFocus.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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.6 +import QtQuick.Controls 2.1 + +ApplicationWindow { + visible: true + width: 200 + height: 200 + + property bool receivedKeyPress: false + + Item { + objectName: "item" + focus: true + anchors.fill: parent + + Keys.onLeftPressed: receivedKeyPress = true + } +} + diff --git a/tests/auto/qquickapplicationwindow/data/fill.qml b/tests/auto/qquickapplicationwindow/data/fill.qml new file mode 100644 index 00000000..27b10d34 --- /dev/null +++ b/tests/auto/qquickapplicationwindow/data/fill.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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.6 +import QtQuick.Controls 2.1 + +ApplicationWindow { + width: 400 + height: 400 + + property alias stackView: stackView + property alias nextItem: nextItem + + function pushNextItem() { + stackView.push(nextItem, StackView.Immediate); + } + + Rectangle { + id: nextItem + color: "blue" + visible: false + } + + StackView { + id: stackView + anchors.fill: parent + + initialItem: Rectangle { + color: "red" + } + } +} diff --git a/tests/auto/qquickapplicationwindow/data/focusAfterPopupClosed.qml b/tests/auto/qquickapplicationwindow/data/focusAfterPopupClosed.qml new file mode 100644 index 00000000..f0499a3a --- /dev/null +++ b/tests/auto/qquickapplicationwindow/data/focusAfterPopupClosed.qml @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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.6 +import QtQuick.Controls 2.1 + +ApplicationWindow { + width: 200 + height: 200 + visible: true + + signal focusScopeKeyPressed + signal focusPopupKeyPressed + + property alias fileMenu: fileMenu + property alias toolButton: toolButton + property alias focusScope: focusScope + property alias focusPopup: focusPopup + + header: ToolBar { + ToolButton { + id: toolButton + text: qsTr("File") + onClicked: fileMenu.open() + focusPolicy: Qt.TabFocus + + Menu { + id: fileMenu + y: parent.height + + MenuItem { + text: qsTr("New") + } + MenuItem { + text: qsTr("Open") + } + MenuItem { + text: qsTr("Close") + } + } + } + } + + FocusScope { + id: focusScope + focus: true + anchors.fill: parent + + Keys.onSpacePressed: focusScopeKeyPressed() + } + + Popup { + id: focusPopup + focus: true + width: parent.width + height: parent.height + + Item { + focus: true + Keys.onSpacePressed: focusPopupKeyPressed() + } + } +} + diff --git a/tests/auto/qquickapplicationwindow/data/font.qml b/tests/auto/qquickapplicationwindow/data/font.qml new file mode 100644 index 00000000..a675aeab --- /dev/null +++ b/tests/auto/qquickapplicationwindow/data/font.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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.6 +import QtQuick.Controls 2.1 +import QtQuick.Templates 2.1 as T + +ApplicationWindow { + objectName: "appWin" + width: 400 + height: 400 + + property alias mainItem: mainItem + + font.family: "Arial" + + T.Control { + id: mainItem + objectName: "mainItem" + anchors.fill: parent + property alias item_2: _item_2; + property alias item_3: _item_3; + property alias item_4: _item_4; + property alias item_5: _item_5; + property alias item_6: _item_6; + T.Control { + id: _item_2 + objectName: "_item_2" + T.Control { + id: _item_3 + objectName: "_item_3" + } + } + T.TextArea { + id: _item_4 + objectName: "_item_4" + text: "Text Area" + } + T.TextField { + id: _item_5 + objectName: "_item_5" + text: "Text Field" + } + T.Label { + id: _item_6 + objectName: "_item_6" + text: "Label" + } + } +} diff --git a/tests/auto/qquickapplicationwindow/data/layout.qml b/tests/auto/qquickapplicationwindow/data/layout.qml new file mode 100644 index 00000000..a80b2d48 --- /dev/null +++ b/tests/auto/qquickapplicationwindow/data/layout.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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.6 +import QtQuick.Controls 2.0 + +ApplicationWindow { + width: 200 + height: 200 + visible: true + + header: ToolBar { } + footer: ToolBar { } +} diff --git a/tests/auto/qquickapplicationwindow/data/locale.qml b/tests/auto/qquickapplicationwindow/data/locale.qml new file mode 100644 index 00000000..92edb53a --- /dev/null +++ b/tests/auto/qquickapplicationwindow/data/locale.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2017 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.6 +import QtQuick.Controls 2.1 +import QtQuick.Templates 2.1 as T + +ApplicationWindow { + objectName: "appWin" + width: 400 + height: 400 + + property alias mainItem: mainItem + + T.Control { + id: mainItem + objectName: "mainItem" + anchors.fill: parent + property alias item_2: _item_2; + property alias item_3: _item_3; + T.Control { + id: _item_2 + objectName: "_item_2" + T.Control { + id: _item_3 + objectName: "_item_3" + } + } + } +} diff --git a/tests/auto/qquickapplicationwindow/qquickapplicationwindow.pro b/tests/auto/qquickapplicationwindow/qquickapplicationwindow.pro new file mode 100644 index 00000000..775f4c90 --- /dev/null +++ b/tests/auto/qquickapplicationwindow/qquickapplicationwindow.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qquickapplicationwindow +SOURCES += tst_qquickapplicationwindow.cpp + +macos:CONFIG -= app_bundle + +QT += core-private gui-private qml-private quick-private quicktemplates2-private quickcontrols2-private testlib + +include (../shared/util.pri) + +TESTDATA = data/* + +OTHER_FILES += \ + data/*.qml + diff --git a/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp b/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp new file mode 100644 index 00000000..19a0bf3b --- /dev/null +++ b/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp @@ -0,0 +1,838 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later 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 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../shared/util.h" +#include "../shared/visualtestutil.h" + +using namespace QQuickVisualTestUtil; + +class tst_QQuickApplicationWindow : public QQmlDataTest +{ + Q_OBJECT +public: + +private slots: + void qmlCreation(); + void activeFocusOnTab1(); + void activeFocusOnTab2(); + void defaultFocus(); + void implicitFill(); + void attachedProperties(); + void font(); + void defaultFont(); + void locale(); + void activeFocusControl_data(); + void activeFocusControl(); + void focusAfterPopupClosed(); + void clearFocusOnDestruction(); + void layout(); + void componentComplete(); +}; + +void tst_QQuickApplicationWindow::qmlCreation() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("basicapplicationwindow.qml")); + QObject* created = component.create(); + QScopedPointer cleanup(created); + QVERIFY(created); + + QQuickWindow* window = qobject_cast(created); + QVERIFY(window); + QVERIFY(!window->isVisible()); + + QCOMPARE(created->property("title"), QVariant("Test Application Window")); + + QQuickItem* statusBar = qvariant_cast(created->property("statusBar")); + QVERIFY(!statusBar); + + QQuickItem* header = qvariant_cast(created->property("header")); + QVERIFY(!header); + + QQuickItem* footer = qvariant_cast(created->property("footer")); + QVERIFY(!footer); +} + +void tst_QQuickApplicationWindow::activeFocusOnTab1() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("activefocusontab.qml")); + QObject* created = component.create(); + QScopedPointer cleanup(created); + QVERIFY(created); + + QQuickWindow* window = qobject_cast(created); + QVERIFY(window); + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QGuiApplication::focusWindow() == window); + + QQuickItem* contentItem = window->contentItem(); + QVERIFY(contentItem); + QVERIFY(contentItem->hasActiveFocus()); + + QQuickItem* item = findItem(window->contentItem(), "sub1"); + QVERIFY(item); + QVERIFY(!item->hasActiveFocus()); + + // Tab: contentItem->sub1 + QKeyEvent key(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + + item = findItem(window->contentItem(), "sub1"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // Tab: sub1->sub2 + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + + item = findItem(window->contentItem(), "sub2"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // Tab: sub2->sub1 + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + + item = findItem(window->contentItem(), "sub1"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); +} + +void tst_QQuickApplicationWindow::activeFocusOnTab2() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("activefocusontab.qml")); + QObject* created = component.create(); + QScopedPointer cleanup(created); + QVERIFY(created); + + QQuickWindow* window = qobject_cast(created); + QVERIFY(window); + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QGuiApplication::focusWindow() == window); + + QQuickItem* contentItem = window->contentItem(); + QVERIFY(contentItem); + QVERIFY(contentItem->hasActiveFocus()); + + QQuickItem* item = findItem(window->contentItem(), "sub2"); + QVERIFY(item); + QVERIFY(!item->hasActiveFocus()); + + // BackTab: contentItem->sub2 + QKeyEvent key(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + + item = findItem(window->contentItem(), "sub2"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // BackTab: sub2->sub1 + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + + item = findItem(window->contentItem(), "sub1"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // BackTab: sub1->sub2 + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + + item = findItem(window->contentItem(), "sub2"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); +} + +void tst_QQuickApplicationWindow::defaultFocus() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("defaultFocus.qml")); + QObject* created = component.create(); + QScopedPointer cleanup(created); + Q_UNUSED(cleanup); + QVERIFY(created); + + QQuickWindow* window = qobject_cast(created); + QVERIFY(window); + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QGuiApplication::focusWindow() == window); + + QQuickItem* contentItem = window->contentItem(); + QVERIFY(contentItem); + QVERIFY(contentItem->hasActiveFocus()); + + // A single item in an ApplicationWindow with focus: true should receive focus. + QQuickItem* item = findItem(window->contentItem(), "item"); + QVERIFY(item); + QVERIFY(item->hasFocus()); + QVERIFY(item->hasActiveFocus()); +} + +void tst_QQuickApplicationWindow::implicitFill() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("fill.qml")); + QObject* created = component.create(); + QScopedPointer cleanup(created); + QVERIFY(created); + + QQuickWindow* window = qobject_cast(created); + QVERIFY(window); + QVERIFY(!window->isVisible()); + QCOMPARE(window->width(), 400); + QCOMPARE(window->height(), 400); + + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickItem *stackView = window->property("stackView").value(); + QVERIFY(stackView); + QCOMPARE(stackView->width(), 400.0); + QCOMPARE(stackView->height(), 400.0); + + QQuickItem *nextItem = window->property("nextItem").value(); + QVERIFY(nextItem); + + QVERIFY(QMetaObject::invokeMethod(window, "pushNextItem")); + QCOMPARE(nextItem->width(), 400.0); + QCOMPARE(nextItem->height(), 400.0); +} + +void tst_QQuickApplicationWindow::attachedProperties() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("attachedProperties.qml")); + + QScopedPointer object(component.create()); + QVERIFY2(!object.isNull(), qPrintable(component.errorString())); + + QQuickApplicationWindow *window = qobject_cast(object.data()); + QVERIFY(window); + + QQuickItem *childControl = object->property("childControl").value(); + QVERIFY(childControl); + QCOMPARE(childControl->property("attached_window").value(), window); + QCOMPARE(childControl->property("attached_contentItem").value(), window->contentItem()); + QCOMPARE(childControl->property("attached_activeFocusControl").value(), window->activeFocusControl()); + QCOMPARE(childControl->property("attached_header").value(), window->header()); + QCOMPARE(childControl->property("attached_footer").value(), window->footer()); + QCOMPARE(childControl->property("attached_overlay").value(), window->overlay()); + + QQuickItem *childItem = object->property("childItem").value(); + QVERIFY(childItem); + QCOMPARE(childItem->property("attached_window").value(), window); + QCOMPARE(childItem->property("attached_contentItem").value(), window->contentItem()); + QCOMPARE(childItem->property("attached_activeFocusControl").value(), window->activeFocusControl()); + QCOMPARE(childItem->property("attached_header").value(), window->header()); + QCOMPARE(childItem->property("attached_footer").value(), window->footer()); + QCOMPARE(childItem->property("attached_overlay").value(), window->overlay()); + + QObject *childObject = object->property("childObject").value(); + QVERIFY(childObject); + QVERIFY(!childObject->property("attached_window").value()); + QVERIFY(!childObject->property("attached_contentItem").value()); + QVERIFY(!childObject->property("attached_activeFocusControl").value()); + QVERIFY(!childObject->property("attached_header").value()); + QVERIFY(!childObject->property("attached_footer").value()); + QVERIFY(!childObject->property("attached_overlay").value()); + + QQuickWindow *childWindow = object->property("childWindow").value(); + QVERIFY(childWindow); + QVERIFY(!childWindow->property("attached_window").value()); + QVERIFY(!childWindow->property("attached_contentItem").value()); + QVERIFY(!childWindow->property("attached_activeFocusControl").value()); + QVERIFY(!childWindow->property("attached_header").value()); + QVERIFY(!childWindow->property("attached_footer").value()); + QVERIFY(!childWindow->property("attached_overlay").value()); + + QQuickItem *childWindowControl = object->property("childWindowControl").value(); + QVERIFY(childWindowControl); + QVERIFY(!childWindowControl->property("attached_window").value()); + QVERIFY(!childWindowControl->property("attached_contentItem").value()); + QVERIFY(!childWindowControl->property("attached_activeFocusControl").value()); + QVERIFY(!childWindowControl->property("attached_header").value()); + QVERIFY(!childWindowControl->property("attached_footer").value()); + QCOMPARE(childWindowControl->property("attached_overlay").value(), QQuickOverlay::overlay(childWindow)); + + QQuickItem *childWindowItem = object->property("childWindowItem").value(); + QVERIFY(childWindowItem); + QVERIFY(!childWindowItem->property("attached_window").value()); + QVERIFY(!childWindowItem->property("attached_contentItem").value()); + QVERIFY(!childWindowItem->property("attached_activeFocusControl").value()); + QVERIFY(!childWindowItem->property("attached_header").value()); + QVERIFY(!childWindowItem->property("attached_footer").value()); + QCOMPARE(childWindowItem->property("attached_overlay").value(), QQuickOverlay::overlay(childWindow)); + + QObject *childWindowObject = object->property("childWindowObject").value(); + QVERIFY(childWindowObject); + QVERIFY(!childWindowObject->property("attached_window").value()); + QVERIFY(!childWindowObject->property("attached_contentItem").value()); + QVERIFY(!childWindowObject->property("attached_activeFocusControl").value()); + QVERIFY(!childWindowObject->property("attached_header").value()); + QVERIFY(!childWindowObject->property("attached_footer").value()); + QVERIFY(!childWindowObject->property("attached_overlay").value()); + + QQuickApplicationWindow *childAppWindow = object->property("childAppWindow").value(); + QVERIFY(childAppWindow); + QVERIFY(!childAppWindow->property("attached_window").value()); + QVERIFY(!childAppWindow->property("attached_contentItem").value()); + QVERIFY(!childAppWindow->property("attached_activeFocusControl").value()); + QVERIFY(!childAppWindow->property("attached_header").value()); + QVERIFY(!childAppWindow->property("attached_footer").value()); + QVERIFY(!childAppWindow->property("attached_overlay").value()); + + QQuickItem *childAppWindowControl = object->property("childAppWindowControl").value(); + QVERIFY(childAppWindowControl); + QCOMPARE(childAppWindowControl->property("attached_window").value(), childAppWindow); + QCOMPARE(childAppWindowControl->property("attached_contentItem").value(), childAppWindow->contentItem()); + QCOMPARE(childAppWindowControl->property("attached_activeFocusControl").value(), childAppWindow->activeFocusControl()); + QCOMPARE(childAppWindowControl->property("attached_header").value(), childAppWindow->header()); + QCOMPARE(childAppWindowControl->property("attached_footer").value(), childAppWindow->footer()); + QCOMPARE(childAppWindowControl->property("attached_overlay").value(), childAppWindow->overlay()); + + QQuickItem *childAppWindowItem = object->property("childAppWindowItem").value(); + QVERIFY(childAppWindowItem); + QCOMPARE(childAppWindowItem->property("attached_window").value(), childAppWindow); + QCOMPARE(childAppWindowItem->property("attached_contentItem").value(), childAppWindow->contentItem()); + QCOMPARE(childAppWindowItem->property("attached_activeFocusControl").value(), childAppWindow->activeFocusControl()); + QCOMPARE(childAppWindowItem->property("attached_header").value(), childAppWindow->header()); + QCOMPARE(childAppWindowItem->property("attached_footer").value(), childAppWindow->footer()); + QCOMPARE(childAppWindowItem->property("attached_overlay").value(), childAppWindow->overlay()); + + QObject *childAppWindowObject = object->property("childAppWindowObject").value(); + QVERIFY(childAppWindowObject); + QVERIFY(!childAppWindowObject->property("attached_window").value()); + QVERIFY(!childAppWindowObject->property("attached_contentItem").value()); + QVERIFY(!childAppWindowObject->property("attached_activeFocusControl").value()); + QVERIFY(!childAppWindowObject->property("attached_header").value()); + QVERIFY(!childAppWindowObject->property("attached_footer").value()); + QVERIFY(!childAppWindowObject->property("attached_overlay").value()); + + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QVERIFY(!childControl->hasActiveFocus()); + childControl->forceActiveFocus(); + QTRY_VERIFY(childControl->hasActiveFocus()); + QCOMPARE(window->activeFocusItem(), childControl); + QCOMPARE(childControl->property("attached_activeFocusControl").value(), childControl); + + QQuickItem *header = new QQuickItem; + window->setHeader(header); + QCOMPARE(window->header(), header); + QCOMPARE(childControl->property("attached_header").value(), header); + + QQuickItem *footer = new QQuickItem; + window->setFooter(footer); + QCOMPARE(window->footer(), footer); + QCOMPARE(childControl->property("attached_footer").value(), footer); + + childAppWindow->show(); + childAppWindow->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(childAppWindow)); + + QVERIFY(!childAppWindowControl->hasActiveFocus()); + childAppWindowControl->forceActiveFocus(); + QTRY_VERIFY(childAppWindowControl->hasActiveFocus()); + QCOMPARE(childAppWindow->activeFocusItem(), childAppWindowControl); + QCOMPARE(childAppWindowControl->property("attached_activeFocusControl").value(), childAppWindowControl); + + childControl->setParentItem(childAppWindow->contentItem()); + 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_header").value(), childAppWindow->header()); + QCOMPARE(childControl->property("attached_footer").value(), childAppWindow->footer()); + QCOMPARE(childControl->property("attached_overlay").value(), childAppWindow->overlay()); + + childItem->setParentItem(childAppWindow->contentItem()); + 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_header").value(), childAppWindow->header()); + QCOMPARE(childItem->property("attached_footer").value(), childAppWindow->footer()); + QCOMPARE(childItem->property("attached_overlay").value(), childAppWindow->overlay()); + + 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()); + + // ### A temporary workaround to unblock the CI until the crash caused + // by https://codereview.qt-project.org/#/c/108517/ has been fixed... + window->hide(); + qApp->processEvents(); +} + +void tst_QQuickApplicationWindow::font() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("font.qml")); + QObject* created = component.create(); + QScopedPointer cleanup(created); + QVERIFY(created); + + QQuickApplicationWindow* window = qobject_cast(created); + QVERIFY(window); + QVERIFY(!window->isVisible()); + QCOMPARE(window->width(), 400); + QCOMPARE(window->height(), 400); + + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QFont font = window->font(); + + QQuickControl *mainItem = window->property("mainItem").value(); + QVERIFY(mainItem); + QCOMPARE(mainItem->width(), 400.0); + QCOMPARE(mainItem->height(), 400.0); + QCOMPARE(mainItem->font(), font); + + QQuickControl *item2 = mainItem->property("item_2").value(); + QVERIFY(item2); + QQuickControl *item3 = mainItem->property("item_3").value(); + QVERIFY(item3); + QQuickTextArea *item4 = mainItem->property("item_4").value(); + QVERIFY(item4); + QQuickTextField *item5 = mainItem->property("item_5").value(); + QVERIFY(item5); + QQuickLabel *item6 = mainItem->property("item_6").value(); + QVERIFY(item6); + + QCOMPARE(item2->font(), font); + QCOMPARE(item3->font(), font); + QCOMPARE(item4->font(), font); + QCOMPARE(item5->font(), font); + QCOMPARE(item6->font(), font); + + int pointSize = font.pointSize(); + font.setPixelSize(pointSize + 5); + window->setFont(font); + + QCOMPARE(window->font(), font); + QCOMPARE(mainItem->font(), font); + QCOMPARE(item2->font(), font); + QCOMPARE(item3->font(), font); + QCOMPARE(item4->font(), font); + QCOMPARE(item5->font(), font); + QCOMPARE(item6->font(), font); +} + +class TestTheme : public QQuickProxyTheme +{ +public: + TestTheme(QPlatformTheme *theme) : QQuickProxyTheme(theme), m_font("Courier") + { QGuiApplicationPrivate::platform_theme = this; } + + const QFont *font(Font type = SystemFont) const override + { + Q_UNUSED(type); + return &m_font; + } + + QFont m_font; +}; + +void tst_QQuickApplicationWindow::defaultFont() +{ + TestTheme theme(QGuiApplicationPrivate::platform_theme); + + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData("import QtQuick.Controls 2.1; ApplicationWindow { }", QUrl()); + + QScopedPointer window; + window.reset(static_cast(component.create())); + QVERIFY(!window.isNull()); + QCOMPARE(window->font(), *theme.font()); +} + +void tst_QQuickApplicationWindow::locale() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("locale.qml")); + QObject* created = component.create(); + QScopedPointer cleanup(created); + QVERIFY(created); + + QQuickApplicationWindow* window = qobject_cast(created); + QVERIFY(window); + QVERIFY(!window->isVisible()); + QCOMPARE(window->width(), 400); + QCOMPARE(window->height(), 400); + + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QLocale l = window->locale(); + + QQuickControl *mainItem = window->property("mainItem").value(); + QVERIFY(mainItem); + QCOMPARE(mainItem->width(), 400.0); + QCOMPARE(mainItem->height(), 400.0); + QCOMPARE(mainItem->locale(), l); + + QQuickControl *item2 = mainItem->property("item_2").value(); + QVERIFY(item2); + QQuickControl *item3 = mainItem->property("item_3").value(); + QVERIFY(item3); + + QCOMPARE(item2->locale(), l); + QCOMPARE(item3->locale(), l); + + l = QLocale("en_US"); + window->setLocale(l); + + QCOMPARE(window->locale(), l); + QCOMPARE(mainItem->locale(), l); + QCOMPARE(item2->locale(), l); + QCOMPARE(item3->locale(), l); + + l = QLocale("ar_EG"); + window->setLocale(l); + + QCOMPARE(window->locale(), l); + QCOMPARE(mainItem->locale(), l); + QCOMPARE(item2->locale(), l); + QCOMPARE(item3->locale(), l); +} + +void tst_QQuickApplicationWindow::activeFocusControl_data() +{ + QTest::addColumn("containerName"); + QTest::addColumn("activeFocusItemName"); + QTest::addColumn("activeFocusControlName"); + + QTest::newRow("Column:TextInput") << QByteArray("container_column") << QByteArray("textInput_column") << QByteArray(); + QTest::newRow("Column:TextEdit") << QByteArray("container_column") << QByteArray("textEdit_column") << QByteArray(); + QTest::newRow("Column:TextField") << QByteArray("container_column") << QByteArray("textField_column") << QByteArray("textField_column"); + QTest::newRow("Column:TextArea") << QByteArray("container_column") << QByteArray("textArea_column") << QByteArray("textArea_column"); + QTest::newRow("Column:SpinBox") << QByteArray("container_column") << QByteArray("spinContent_column") << QByteArray("spinBox_column"); + + QTest::newRow("Frame:TextInput") << QByteArray("container_frame") << QByteArray("textInput_frame") << QByteArray("container_frame"); + QTest::newRow("Frame:TextEdit") << QByteArray("container_frame") << QByteArray("textEdit_frame") << QByteArray("container_frame"); + QTest::newRow("Frame:TextField") << QByteArray("container_frame") << QByteArray("textField_frame") << QByteArray("textField_frame"); + QTest::newRow("Frame:TextArea") << QByteArray("container_frame") << QByteArray("textArea_frame") << QByteArray("textArea_frame"); + QTest::newRow("Frame:SpinBox") << QByteArray("container_frame") << QByteArray("spinContent_frame") << QByteArray("spinBox_frame"); +} + +void tst_QQuickApplicationWindow::activeFocusControl() +{ + QFETCH(QByteArray, containerName); + QFETCH(QByteArray, activeFocusItemName); + QFETCH(QByteArray, activeFocusControlName); + + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("activeFocusControl.qml")); + QScopedPointer object(component.create()); + QVERIFY(!object.isNull()); + + QQuickApplicationWindow* window = qobject_cast(object.data()); + QVERIFY(window); + QVERIFY(!window->isVisible()); + QCOMPARE(window->width(), 400); + QCOMPARE(window->height(), 400); + + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickItem *container = window->property(containerName).value(); + QVERIFY(container); + + QQuickItem *activeFocusItem = window->property(activeFocusItemName).value(); + QVERIFY(activeFocusItem); + activeFocusItem->forceActiveFocus(); + QVERIFY(activeFocusItem->hasActiveFocus()); + QCOMPARE(window->activeFocusItem(), activeFocusItem); + + QQuickItem *activeFocusControl = window->property(activeFocusControlName).value(); + if (activeFocusControlName.isEmpty()) { + QVERIFY(!activeFocusControl); + } else { + QVERIFY(activeFocusControl); + QVERIFY(activeFocusControl->hasActiveFocus()); + } + QCOMPARE(window->activeFocusControl(), activeFocusControl); +} + +void tst_QQuickApplicationWindow::focusAfterPopupClosed() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("focusAfterPopupClosed.qml")); + QScopedPointer window(qobject_cast(component.create())); + QVERIFY(window); + + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window.data())); + QVERIFY(QGuiApplication::focusWindow() == window.data()); + + QQuickItem* contentItem = window->contentItem(); + QVERIFY(contentItem); + QVERIFY(contentItem->hasActiveFocus()); + + QQuickItem* focusScope = window->property("focusScope").value(); + QVERIFY(focusScope); + QVERIFY(focusScope->hasActiveFocus()); + + QSignalSpy focusScopeSpy(window.data(), SIGNAL(focusScopeKeyPressed())); + QTest::keyClick(window.data(), Qt::Key_Space); + QCOMPARE(focusScopeSpy.count(), 1); + + // Open the menu. + QQuickItem* toolButton = window->property("toolButton").value(); + QVERIFY(toolButton); + QTest::mouseClick(window.data(), Qt::LeftButton, Qt::NoModifier, + toolButton->mapFromScene(QPointF(toolButton->width() / 2, toolButton->height() / 2)).toPoint()); + QVERIFY(!focusScope->hasActiveFocus()); + + // The FocusScope shouldn't receive any key events while the menu is open. + QTest::keyClick(window.data(), Qt::Key_Space); + QCOMPARE(focusScopeSpy.count(), 1); + + // Close the menu. The FocusScope should regain focus. + QTest::keyClick(window.data(), Qt::Key_Escape); + QVERIFY(focusScope->hasActiveFocus()); + + QTest::keyClick(window.data(), Qt::Key_Space); + QCOMPARE(focusScopeSpy.count(), 2); + + QQuickPopup *focusPopup = window->property("focusPopup").value(); + QVERIFY(focusPopup); + QVERIFY(!focusPopup->hasActiveFocus()); + + focusPopup->open(); + QVERIFY(focusPopup->isVisible()); + + QSignalSpy focusPopupSpy(window.data(), SIGNAL(focusPopupKeyPressed())); + QTest::keyClick(window.data(), Qt::Key_Space); + QCOMPARE(focusPopupSpy.count(), 1); + + QQuickMenu *fileMenu = window->property("fileMenu").value(); + QVERIFY(fileMenu); + fileMenu->open(); + QVERIFY(fileMenu->isVisible()); + + // The Popup shouldn't receive any key events while the menu is open. + QTest::keyClick(window.data(), Qt::Key_Space); + QCOMPARE(focusPopupSpy.count(), 1); + + // Close the menu. The Popup should regain focus. + QTest::keyClick(window.data(), Qt::Key_Escape); + QVERIFY(focusPopup->hasActiveFocus()); + + QTest::keyClick(window.data(), Qt::Key_Space); + QCOMPARE(focusPopupSpy.count(), 2); + + // Close the popup. The FocusScope should regain focus. + QTest::keyClick(window.data(), Qt::Key_Escape); + QVERIFY(focusScope->hasActiveFocus()); + + QTest::keyClick(window.data(), Qt::Key_Space); + QCOMPARE(focusScopeSpy.count(), 3); +} + +void tst_QQuickApplicationWindow::clearFocusOnDestruction() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("clearfocusondestruction.qml")); + QScopedPointer window(qobject_cast(component.create())); + QVERIFY(window); + + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window.data())); + QVERIFY(QGuiApplication::focusWindow() == window.data()); + + QQuickItem* contentItem = window->contentItem(); + QVERIFY(contentItem); + QVERIFY(contentItem->hasActiveFocus()); + + QQuickItem* focusScope = window->property("textfield").value(); + QVERIFY(focusScope); + QVERIFY(focusScope->hasActiveFocus()); + + QSignalSpy spy(window.data(), SIGNAL(activeFocusControlChanged())); + // destroy the window, do not crash + window.reset(); + + /* + QQuickWindow::activeFocusItemChanged() is emitted inconsistently and + only for certain use cases. Ideally it should be emitted whenever a + QQuickWindow with a focus item is destroyed, but it doesn't... It might + also be favorable to not emit it for performance reason. + + However, activeFocusControlChanged() is emitted more consistently, which + of course makes it inconsistent with the emission of + activeFocusItemChanged().... + + Therefore, if you have good reasons to change the behavior (and not emit + it) take the test below with a grain of salt. + */ + QCOMPARE(spy.count(), 1); +} + +void tst_QQuickApplicationWindow::layout() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("layout.qml")); + QScopedPointer object(component.create()); + QVERIFY(!object.isNull()); + + QQuickApplicationWindow* window = qobject_cast(object.data()); + QVERIFY(window); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickItem *content = window->contentItem(); + QVERIFY(content); + QQuickItem *header = window->header(); + QVERIFY(header); + QQuickItem *footer = window->footer(); + QVERIFY(footer); + + QCOMPARE(header->x(), 0.0); + QCOMPARE(header->y(), -header->height()); + QCOMPARE(header->width(), qreal(window->width())); + QVERIFY(header->height() > 0); + + QCOMPARE(footer->x(), 0.0); + QCOMPARE(footer->y(), content->height()); + QCOMPARE(footer->width(), qreal(window->width())); + QVERIFY(footer->height() > 0.0); + + QCOMPARE(content->x(), 0.0); + QCOMPARE(content->y(), header->height()); + QCOMPARE(content->width(), qreal(window->width())); + QCOMPARE(content->height(), window->height() - header->height() - footer->height()); + + header->setVisible(false); + QCOMPARE(content->x(), 0.0); + QCOMPARE(content->y(), 0.0); + QCOMPARE(content->width(), qreal(window->width())); + QCOMPARE(content->height(), window->height() - footer->height()); + + footer->setVisible(false); + QCOMPARE(content->x(), 0.0); + QCOMPARE(content->y(), 0.0); + QCOMPARE(content->width(), qreal(window->width())); + QCOMPARE(content->height(), qreal(window->height())); +} + +class FriendlyApplicationWindow : public QQuickApplicationWindow +{ + friend class tst_QQuickApplicationWindow; +}; + +void tst_QQuickApplicationWindow::componentComplete() +{ + FriendlyApplicationWindow cppWindow; + QVERIFY(cppWindow.isComponentComplete()); + + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData("import QtQuick.Controls 2.2; ApplicationWindow { }", QUrl()); + + FriendlyApplicationWindow *qmlWindow = static_cast(component.beginCreate(engine.rootContext())); + QVERIFY(qmlWindow); + QVERIFY(!qmlWindow->isComponentComplete()); + + component.completeCreate(); + QVERIFY(qmlWindow->isComponentComplete()); +} + +QTEST_MAIN(tst_QQuickApplicationWindow) + +#include "tst_qquickapplicationwindow.moc" -- cgit v1.2.3