From c5e60dbf0023acf751bd18fe660501ca4b195daf Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 27 Sep 2017 14:44:25 +0200 Subject: Rename tst_popup to tst_QQuickPopup Change-Id: I98f7081e94672a4454c33841934158ae82e9388f Reviewed-by: Mitch Curtis --- .gitignore | 2 +- tests/auto/auto.pro | 4 +- tests/auto/popup/data/activeFocusOnClose1.qml | 69 -- tests/auto/popup/data/activeFocusOnClose2.qml | 79 -- tests/auto/popup/data/activeFocusOnClose3.qml | 78 -- tests/auto/popup/data/applicationwindow-hover.qml | 79 -- tests/auto/popup/data/applicationwindow-wheel.qml | 81 -- tests/auto/popup/data/applicationwindow.qml | 93 -- .../popup/data/closeOnEscapeWithNestedPopups.qml | 112 --- tests/auto/popup/data/cursor.qml | 71 -- tests/auto/popup/data/grabber.qml | 80 -- tests/auto/popup/data/nested.qml | 74 -- tests/auto/popup/data/orientation.qml | 76 -- tests/auto/popup/data/window-hover.qml | 80 -- tests/auto/popup/data/window-wheel.qml | 81 -- tests/auto/popup/data/window.qml | 94 -- tests/auto/popup/popup.pro | 14 - tests/auto/popup/tst_popup.cpp | 977 --------------------- .../auto/qquickpopup/data/activeFocusOnClose1.qml | 69 ++ .../auto/qquickpopup/data/activeFocusOnClose2.qml | 79 ++ .../auto/qquickpopup/data/activeFocusOnClose3.qml | 78 ++ .../qquickpopup/data/applicationwindow-hover.qml | 79 ++ .../qquickpopup/data/applicationwindow-wheel.qml | 81 ++ tests/auto/qquickpopup/data/applicationwindow.qml | 93 ++ .../data/closeOnEscapeWithNestedPopups.qml | 112 +++ tests/auto/qquickpopup/data/cursor.qml | 71 ++ tests/auto/qquickpopup/data/grabber.qml | 80 ++ tests/auto/qquickpopup/data/nested.qml | 74 ++ tests/auto/qquickpopup/data/orientation.qml | 76 ++ tests/auto/qquickpopup/data/window-hover.qml | 80 ++ tests/auto/qquickpopup/data/window-wheel.qml | 81 ++ tests/auto/qquickpopup/data/window.qml | 94 ++ tests/auto/qquickpopup/qquickpopup.pro | 14 + tests/auto/qquickpopup/tst_qquickpopup.cpp | 977 +++++++++++++++++++++ 34 files changed, 2141 insertions(+), 2141 deletions(-) delete mode 100644 tests/auto/popup/data/activeFocusOnClose1.qml delete mode 100644 tests/auto/popup/data/activeFocusOnClose2.qml delete mode 100644 tests/auto/popup/data/activeFocusOnClose3.qml delete mode 100644 tests/auto/popup/data/applicationwindow-hover.qml delete mode 100644 tests/auto/popup/data/applicationwindow-wheel.qml delete mode 100644 tests/auto/popup/data/applicationwindow.qml delete mode 100644 tests/auto/popup/data/closeOnEscapeWithNestedPopups.qml delete mode 100644 tests/auto/popup/data/cursor.qml delete mode 100644 tests/auto/popup/data/grabber.qml delete mode 100644 tests/auto/popup/data/nested.qml delete mode 100644 tests/auto/popup/data/orientation.qml delete mode 100644 tests/auto/popup/data/window-hover.qml delete mode 100644 tests/auto/popup/data/window-wheel.qml delete mode 100644 tests/auto/popup/data/window.qml delete mode 100644 tests/auto/popup/popup.pro delete mode 100644 tests/auto/popup/tst_popup.cpp create mode 100644 tests/auto/qquickpopup/data/activeFocusOnClose1.qml create mode 100644 tests/auto/qquickpopup/data/activeFocusOnClose2.qml create mode 100644 tests/auto/qquickpopup/data/activeFocusOnClose3.qml create mode 100644 tests/auto/qquickpopup/data/applicationwindow-hover.qml create mode 100644 tests/auto/qquickpopup/data/applicationwindow-wheel.qml create mode 100644 tests/auto/qquickpopup/data/applicationwindow.qml create mode 100644 tests/auto/qquickpopup/data/closeOnEscapeWithNestedPopups.qml create mode 100644 tests/auto/qquickpopup/data/cursor.qml create mode 100644 tests/auto/qquickpopup/data/grabber.qml create mode 100644 tests/auto/qquickpopup/data/nested.qml create mode 100644 tests/auto/qquickpopup/data/orientation.qml create mode 100644 tests/auto/qquickpopup/data/window-hover.qml create mode 100644 tests/auto/qquickpopup/data/window-wheel.qml create mode 100644 tests/auto/qquickpopup/data/window.qml create mode 100644 tests/auto/qquickpopup/qquickpopup.pro create mode 100644 tests/auto/qquickpopup/tst_qquickpopup.cpp diff --git a/.gitignore b/.gitignore index dd2949f1..cc84c183 100644 --- a/.gitignore +++ b/.gitignore @@ -37,11 +37,11 @@ /tests/auto/font/tst_font /tests/auto/menu/tst_menu /tests/auto/platform/tst_platform -/tests/auto/popup/tst_popup /tests/auto/pressandhold/tst_pressandhold /tests/auto/qquickdrawer/tst_qquickdrawer /tests/auto/qquickmaterialstyle/tst_qquickmaterialstyle /tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf +/tests/auto/qquickpopup/tst_qquickpopup /tests/auto/qquickstyle/tst_qquickstyle /tests/auto/qquickstyleselector/tst_qquickstyleselector /tests/auto/qquickuniversalstyle/tst_qquickuniversalstyle diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 354d7c81..3acc4704 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -9,11 +9,11 @@ SUBDIRS += \ font \ menu \ platform \ - popup \ pressandhold \ qquickdrawer \ qquickmaterialstyle \ qquickmaterialstyleconf \ + qquickpopup \ qquickstyle \ qquickstyleselector \ qquickuniversalstyle \ @@ -24,6 +24,6 @@ SUBDIRS += \ # QTBUG-60268 boot2qt: SUBDIRS -= applicationwindow calendar controls cursor \ - qquickdrawer focus font menu platform popup qquickmaterialstyle \ + qquickdrawer focus font menu platform qquickpopup qquickmaterialstyle \ qquickmaterialstyleconf qquickuniversalstyle \ qquickuniversalstyleconf snippets diff --git a/tests/auto/popup/data/activeFocusOnClose1.qml b/tests/auto/popup/data/activeFocusOnClose1.qml deleted file mode 100644 index ee0295c1..00000000 --- a/tests/auto/popup/data/activeFocusOnClose1.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 { - width: 400 - height: 400 - - property alias focusedPopup: focusedPopup - property alias nonFocusedPopup: nonFocusedPopup - - Popup { - id: focusedPopup - focus: true - } - - Popup { - id: nonFocusedPopup - } -} diff --git a/tests/auto/popup/data/activeFocusOnClose2.qml b/tests/auto/popup/data/activeFocusOnClose2.qml deleted file mode 100644 index cb215f9b..00000000 --- a/tests/auto/popup/data/activeFocusOnClose2.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 popup1: popup1 - property alias popup2: popup2 - property alias closePopup2Button: closePopup2Button - - Popup { - id: popup1 - focus: true - } - - Popup { - id: popup2 - focus: true - - Button { - id: closePopup2Button - onClicked: { - popup1.contentItem.forceActiveFocus(); - popup2.close(); - } - } - } -} diff --git a/tests/auto/popup/data/activeFocusOnClose3.qml b/tests/auto/popup/data/activeFocusOnClose3.qml deleted file mode 100644 index a8137b34..00000000 --- a/tests/auto/popup/data/activeFocusOnClose3.qml +++ /dev/null @@ -1,78 +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: 400 - height: 400 - - property alias popup1: popup1 - property alias popup2: popup2 - - Button { - focus: true - } - - Popup { - id: popup1 - focus: true - enter: Transition { PauseAnimation { duration: 200 } } - exit: Transition { PauseAnimation { duration: 200 } } - } - - Popup { - id: popup2 - focus: true - enter: Transition { PauseAnimation { duration: 100 } } - exit: Transition { PauseAnimation { duration: 100 } } - } -} diff --git a/tests/auto/popup/data/applicationwindow-hover.qml b/tests/auto/popup/data/applicationwindow-hover.qml deleted file mode 100644 index 8cec6ba7..00000000 --- a/tests/auto/popup/data/applicationwindow-hover.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.0 - -ApplicationWindow { - width: 400 - height: 400 - - property alias popup: popup - property alias parentButton: parentButton - property alias childButton: childButton - - Button { - id: parentButton - text: "Parent" - anchors.fill: parent - - Popup { - id: popup - x: 1 - y: 1 - padding: 1 - - Button { - id: childButton - text: "Child" - } - } - } -} diff --git a/tests/auto/popup/data/applicationwindow-wheel.qml b/tests/auto/popup/data/applicationwindow-wheel.qml deleted file mode 100644 index a89bd0f6..00000000 --- a/tests/auto/popup/data/applicationwindow-wheel.qml +++ /dev/null @@ -1,81 +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.0 - -ApplicationWindow { - id: window - width: 400 - height: 400 - - property alias popup: popup - property alias popupSlider: popupSlider - property alias contentSlider: contentSlider - - Slider { - id: contentSlider - anchors.fill: parent - wheelEnabled: true - } - - Popup { - id: popup - x: 50; y: 50 - implicitWidth: parent.width - 100 - implicitHeight: parent.height - 100 - clip: true - contentItem: Slider { - id: popupSlider - wheelEnabled: true - } - } -} diff --git a/tests/auto/popup/data/applicationwindow.qml b/tests/auto/popup/data/applicationwindow.qml deleted file mode 100644 index 659aa843..00000000 --- a/tests/auto/popup/data/applicationwindow.qml +++ /dev/null @@ -1,93 +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 popup: popup - property alias popup2: popup2 - property alias button: button - - Button { - id: button - text: "Open" - anchors.centerIn: parent - anchors.verticalCenterOffset: -height - - Popup { - id: popup - y: parent.height - - Text { - color: "white" - text: "Hello, world!" - - MouseArea { - anchors.fill: parent - onClicked: popup.close() - } - } - } - } - - Popup { - id: popup2 - y: popup.y - z: 1 - contentItem: Text { - text: "Popup2" - font.pixelSize: 36 - } - } -} diff --git a/tests/auto/popup/data/closeOnEscapeWithNestedPopups.qml b/tests/auto/popup/data/closeOnEscapeWithNestedPopups.qml deleted file mode 100644 index 53dae0f9..00000000 --- a/tests/auto/popup/data/closeOnEscapeWithNestedPopups.qml +++ /dev/null @@ -1,112 +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.9 -import QtQuick.Controls 2.2 - -ApplicationWindow { - width: 400 - height: 400 - - header: ToolBar { - ToolButton { - objectName: "optionsToolButton" - text: "Options" - onClicked: optionsMenu.open() - - Menu { - id: optionsMenu - objectName: "optionsMenu" - x: parent.width - width - transformOrigin: Menu.TopRight - - MenuItem { - objectName: "settingsMenuItem" - text: "Settings" - onTriggered: settingsDialog.open() - } - } - } - } - - Shortcut { - sequence: "Esc" - enabled: stackView.depth > 1 - onActivated: stackView.pop() - } - - Component { - id: itemComponent - - Item {} - } - - StackView { - id: stackView - objectName: "stackView" - anchors.fill: parent - initialItem: Item { - objectName: "initialStackViewItem" - } - - Component.onCompleted: push(itemComponent) - } - - Dialog { - id: settingsDialog - objectName: "settingsDialog" - modal: true - - contentItem: ComboBox { - objectName: "comboBox" - model: 10 - } - } -} diff --git a/tests/auto/popup/data/cursor.qml b/tests/auto/popup/data/cursor.qml deleted file mode 100644 index fd4475a0..00000000 --- a/tests/auto/popup/data/cursor.qml +++ /dev/null @@ -1,71 +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: 400 - height: 400 - - property alias popup: popup - property alias textField: textField - - TextField { - id: textField - } - Popup { - id: popup - x: textField.x + textField.width / 2 - y: textField.y + textField.height / 2 - height / 2 - width: 100 - height: 100 - } -} diff --git a/tests/auto/popup/data/grabber.qml b/tests/auto/popup/data/grabber.qml deleted file mode 100644 index b9995b54..00000000 --- a/tests/auto/popup/data/grabber.qml +++ /dev/null @@ -1,80 +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: 400 - height: 400 - - property alias menu: menu - property alias popup: popup - property alias combo: combo.popup - - Menu { - id: menu - MenuItem { - onTriggered: popup.open() - } - } - - Popup { - id: popup - modal: true - width: 200 - height: 200 - - ComboBox { - id: combo - model: 3 - } - } -} diff --git a/tests/auto/popup/data/nested.qml b/tests/auto/popup/data/nested.qml deleted file mode 100644 index 48e51fc8..00000000 --- a/tests/auto/popup/data/nested.qml +++ /dev/null @@ -1,74 +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: 400 - height: 400 - - property alias modalPopup: modalPopup - property alias modelessPopup: modelessPopup - - Popup { - id: modalPopup - modal: true - width: 200 - height: 200 - } - - Popup { - id: modelessPopup - modal: false - width: 100 - height: 100 - } -} diff --git a/tests/auto/popup/data/orientation.qml b/tests/auto/popup/data/orientation.qml deleted file mode 100644 index cbf69b2b..00000000 --- a/tests/auto/popup/data/orientation.qml +++ /dev/null @@ -1,76 +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.0 - -Window { - width: 600 - height: 300 - - property alias popup: popup - - Rectangle { - width: 60 - height: 30 - anchors.centerIn: parent - border.width: 1 - - Popup { - id: popup - x: parent.width - y: parent.height - width: 30 - height: 60 - visible: true - } - } -} diff --git a/tests/auto/popup/data/window-hover.qml b/tests/auto/popup/data/window-hover.qml deleted file mode 100644 index 669afb08..00000000 --- a/tests/auto/popup/data/window-hover.qml +++ /dev/null @@ -1,80 +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.0 - -Window { - width: 400 - height: 400 - - property alias popup: popup - property alias parentButton: parentButton - property alias childButton: childButton - - Button { - id: parentButton - text: "Parent" - anchors.fill: parent - - Popup { - id: popup - x: 1 - y: 1 - padding: 1 - - Button { - id: childButton - text: "Child" - } - } - } -} diff --git a/tests/auto/popup/data/window-wheel.qml b/tests/auto/popup/data/window-wheel.qml deleted file mode 100644 index 45c09b45..00000000 --- a/tests/auto/popup/data/window-wheel.qml +++ /dev/null @@ -1,81 +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.0 - -Window { - id: window - width: 400 - height: 400 - - property alias popup: popup - property alias popupSlider: popupSlider - property alias contentSlider: contentSlider - - Slider { - id: contentSlider - anchors.fill: parent - wheelEnabled: true - } - - Popup { - id: popup - x: 50; y: 50 - implicitWidth: parent.width - 100 - implicitHeight: parent.height - 100 - clip: true - contentItem: Slider { - id: popupSlider - wheelEnabled: true - } - } -} diff --git a/tests/auto/popup/data/window.qml b/tests/auto/popup/data/window.qml deleted file mode 100644 index 962ab573..00000000 --- a/tests/auto/popup/data/window.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.Window 2.2 -import QtQuick.Controls 2.0 - -Window { - width: 400 - height: 400 - - property alias popup: popup - property alias popup2: popup2 - property alias button: button - - Button { - id: button - text: "Open" - anchors.centerIn: parent - anchors.verticalCenterOffset: -height - - Popup { - id: popup - y: parent.height - - Text { - color: "white" - text: "Hello, world!" - - MouseArea { - anchors.fill: parent - onClicked: popup.close() - } - } - } - } - - Popup { - id: popup2 - y: popup.y - z: 1 - contentItem: Text { - text: "Popup2" - font.pixelSize: 36 - } - } -} diff --git a/tests/auto/popup/popup.pro b/tests/auto/popup/popup.pro deleted file mode 100644 index c863ba07..00000000 --- a/tests/auto/popup/popup.pro +++ /dev/null @@ -1,14 +0,0 @@ -CONFIG += testcase -TARGET = tst_popup -SOURCES += tst_popup.cpp - -macos:CONFIG -= app_bundle - -QT += core-private gui-private qml-private quick-private testlib quicktemplates2-private - -include (../shared/util.pri) - -TESTDATA = data/* - -OTHER_FILES += \ - data/*.qml diff --git a/tests/auto/popup/tst_popup.cpp b/tests/auto/popup/tst_popup.cpp deleted file mode 100644 index f036f0c9..00000000 --- a/tests/auto/popup/tst_popup.cpp +++ /dev/null @@ -1,977 +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 "../shared/util.h" -#include "../shared/visualtestutil.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace QQuickVisualTestUtil; - -class tst_popup : public QQmlDataTest -{ - Q_OBJECT - -private slots: - void initTestCase(); - void visible_data(); - void visible(); - void state(); - void overlay_data(); - void overlay(); - void zOrder_data(); - void zOrder(); - void windowChange(); - void closePolicy_data(); - void closePolicy(); - void activeFocusOnClose1(); - void activeFocusOnClose2(); - void activeFocusOnClose3(); - void hover_data(); - void hover(); - void wheel_data(); - void wheel(); - void parentDestroyed(); - void nested(); - void grabber(); - void cursorShape(); - void componentComplete(); - void closeOnEscapeWithNestedPopups(); - void orientation_data(); - void orientation(); -}; - -void tst_popup::initTestCase() -{ - QQmlDataTest::initTestCase(); - qputenv("QML_NO_TOUCH_COMPRESSION", "1"); -} - -void tst_popup::visible_data() -{ - QTest::addColumn("source"); - QTest::newRow("Window") << "window.qml"; - QTest::newRow("ApplicationWindow") << "applicationwindow.qml"; -} - -void tst_popup::visible() -{ - QFETCH(QString, source); - QQuickApplicationHelper helper(this, source); - - QQuickWindow *window = helper.window; - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickPopup *popup = window->property("popup").value(); - QVERIFY(popup); - QQuickItem *popupItem = popup->popupItem(); - - popup->open(); - QVERIFY(popup->isVisible()); - - QQuickOverlay *overlay = QQuickOverlay::overlay(window); - QVERIFY(overlay); - QVERIFY(overlay->childItems().contains(popupItem)); - - popup->close(); - QVERIFY(!popup->isVisible()); - QVERIFY(!overlay->childItems().contains(popupItem)); - - popup->setVisible(true); - QVERIFY(popup->isVisible()); - QVERIFY(overlay->childItems().contains(popupItem)); - - popup->setVisible(false); - QVERIFY(!popup->isVisible()); - QVERIFY(!overlay->childItems().contains(popupItem)); -} - -void tst_popup::state() -{ - QQuickApplicationHelper helper(this, "applicationwindow.qml"); - - QQuickWindow *window = helper.window; - window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - - QQuickPopup *popup = window->property("popup").value(); - QVERIFY(popup); - - QCOMPARE(popup->isVisible(), false); - - QSignalSpy visibleChangedSpy(popup, SIGNAL(visibleChanged())); - QSignalSpy aboutToShowSpy(popup, SIGNAL(aboutToShow())); - QSignalSpy aboutToHideSpy(popup, SIGNAL(aboutToHide())); - QSignalSpy openedSpy(popup, SIGNAL(opened())); - QSignalSpy closedSpy(popup, SIGNAL(closed())); - - QVERIFY(visibleChangedSpy.isValid()); - QVERIFY(aboutToShowSpy.isValid()); - QVERIFY(aboutToHideSpy.isValid()); - QVERIFY(openedSpy.isValid()); - QVERIFY(closedSpy.isValid()); - - popup->open(); - QCOMPARE(visibleChangedSpy.count(), 1); - QCOMPARE(aboutToShowSpy.count(), 1); - QCOMPARE(aboutToHideSpy.count(), 0); - QTRY_COMPARE(openedSpy.count(), 1); - QCOMPARE(closedSpy.count(), 0); - - popup->close(); - QCOMPARE(visibleChangedSpy.count(), 2); - QCOMPARE(aboutToShowSpy.count(), 1); - QCOMPARE(aboutToHideSpy.count(), 1); - QCOMPARE(openedSpy.count(), 1); - QTRY_COMPARE(closedSpy.count(), 1); -} - -void tst_popup::overlay_data() -{ - QTest::addColumn("source"); - QTest::addColumn("modal"); - QTest::addColumn("dim"); - - QTest::newRow("Window") << "window.qml" << false << false; - QTest::newRow("Window,dim") << "window.qml" << false << true; - QTest::newRow("Window,modal") << "window.qml" << true << false; - QTest::newRow("Window,modal,dim") << "window.qml" << true << true; - - QTest::newRow("ApplicationWindow") << "applicationwindow.qml" << false << false; - QTest::newRow("ApplicationWindow,dim") << "applicationwindow.qml" << false << true; - QTest::newRow("ApplicationWindow,modal") << "applicationwindow.qml" << true << false; - QTest::newRow("ApplicationWindow,modal,dim") << "applicationwindow.qml" << true << true; -} - -void tst_popup::overlay() -{ - QFETCH(QString, source); - QFETCH(bool, modal); - QFETCH(bool, dim); - - QQuickApplicationHelper helper(this, source); - - QQuickWindow *window = helper.window; - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickOverlay *overlay = QQuickOverlay::overlay(window); - QVERIFY(overlay); - - QSignalSpy overlayPressedSignal(overlay, SIGNAL(pressed())); - QSignalSpy overlayReleasedSignal(overlay, SIGNAL(released())); - QVERIFY(overlayPressedSignal.isValid()); - QVERIFY(overlayReleasedSignal.isValid()); - - QVERIFY(!overlay->isVisible()); // no popups open - - QTest::mouseClick(window, Qt::LeftButton); - QCOMPARE(overlayPressedSignal.count(), 0); - QCOMPARE(overlayReleasedSignal.count(), 0); - - QQuickPopup *popup = window->property("popup").value(); - QVERIFY(popup); - - QQuickButton *button = window->property("button").value(); - QVERIFY(button); - - int overlayPressCount = 0; - int overlayReleaseCount = 0; - - popup->open(); - QVERIFY(popup->isVisible()); - QVERIFY(overlay->isVisible()); - - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); - QCOMPARE(overlayPressedSignal.count(), ++overlayPressCount); - QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount); - - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); - QCOMPARE(overlayPressedSignal.count(), overlayPressCount); - QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount); // no modal-popups open - - popup->close(); - QVERIFY(!popup->isVisible()); - QVERIFY(!overlay->isVisible()); - - popup->setDim(dim); - popup->setModal(modal); - popup->setClosePolicy(QQuickPopup::CloseOnReleaseOutside); - - // mouse - popup->open(); - QVERIFY(popup->isVisible()); - QVERIFY(overlay->isVisible()); - - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); - QCOMPARE(overlayPressedSignal.count(), ++overlayPressCount); - QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount); - - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); - QCOMPARE(overlayPressedSignal.count(), overlayPressCount); - QCOMPARE(overlayReleasedSignal.count(), ++overlayReleaseCount); - - QVERIFY(!popup->isVisible()); - QCOMPARE(overlay->isVisible(), popup->isVisible()); - - // touch - popup->open(); - QVERIFY(popup->isVisible()); - QVERIFY(overlay->isVisible()); - - struct TouchDeviceDeleter - { - static inline void cleanup(QTouchDevice *device) - { - QWindowSystemInterface::unregisterTouchDevice(device); - delete device; - } - }; - - QScopedPointer device(new QTouchDevice); - device->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(device.data()); - - QTest::touchEvent(window, device.data()).press(0, QPoint(1, 1)); - QCOMPARE(overlayPressedSignal.count(), ++overlayPressCount); - QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount); - - QTest::touchEvent(window, device.data()).release(0, QPoint(1, 1)); - QCOMPARE(overlayPressedSignal.count(), overlayPressCount); - QCOMPARE(overlayReleasedSignal.count(), ++overlayReleaseCount); - - QVERIFY(!popup->isVisible()); - QCOMPARE(overlay->isVisible(), popup->isVisible()); - - // multi-touch - popup->open(); - QVERIFY(popup->isVisible()); - QVERIFY(overlay->isVisible()); - QVERIFY(!button->isPressed()); - - QTest::touchEvent(window, device.data()).press(0, button->mapToScene(QPointF(1, 1)).toPoint()); - QVERIFY(popup->isVisible()); - QVERIFY(overlay->isVisible()); - QCOMPARE(button->isPressed(), !modal); - QCOMPARE(overlayPressedSignal.count(), ++overlayPressCount); - QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount); - - QTest::touchEvent(window, device.data()).stationary(0).press(1, button->mapToScene(QPointF(button->width() / 2, button->height() / 2)).toPoint()); - QVERIFY(popup->isVisible()); - QVERIFY(overlay->isVisible()); - QCOMPARE(button->isPressed(), !modal); - QCOMPARE(overlayPressedSignal.count(), ++overlayPressCount); - QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount); - - QTest::touchEvent(window, device.data()).release(0, button->mapToScene(QPointF(1, 1)).toPoint()).stationary(1); - QVERIFY(!popup->isVisible()); - QVERIFY(!overlay->isVisible()); - QVERIFY(!button->isPressed()); - QCOMPARE(overlayPressedSignal.count(), overlayPressCount); - QCOMPARE(overlayReleasedSignal.count(), ++overlayReleaseCount); - - QTest::touchEvent(window, device.data()).release(1, button->mapToScene(QPointF(button->width() / 2, button->height() / 2)).toPoint()); - QVERIFY(!popup->isVisible()); - QVERIFY(!overlay->isVisible()); - QVERIFY(!button->isPressed()); - QCOMPARE(overlayPressedSignal.count(), overlayPressCount); - QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount); -} - -void tst_popup::zOrder_data() -{ - QTest::addColumn("source"); - QTest::newRow("Window") << "window.qml"; - QTest::newRow("ApplicationWindow") << "applicationwindow.qml"; -} - -void tst_popup::zOrder() -{ - QFETCH(QString, source); - QQuickApplicationHelper helper(this, source); - - QQuickWindow *window = helper.window; - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickPopup *popup = window->property("popup").value(); - QVERIFY(popup); - popup->setModal(true); - - QQuickPopup *popup2 = window->property("popup2").value(); - QVERIFY(popup2); - popup2->setModal(true); - - // show popups in reverse order. popup2 has higher z-order so it appears - // on top and must be closed first, even if the other popup was opened last - popup2->open(); - popup->open(); - QVERIFY(popup2->isVisible()); - QVERIFY(popup->isVisible()); - - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); - QVERIFY(!popup2->isVisible()); - QVERIFY(popup->isVisible()); - - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); - QVERIFY(!popup2->isVisible()); - QVERIFY(!popup->isVisible()); -} - -void tst_popup::windowChange() -{ - QQuickPopup popup; - QSignalSpy spy(&popup, SIGNAL(windowChanged(QQuickWindow*))); - QVERIFY(spy.isValid()); - - QQuickItem item; - popup.setParentItem(&item); - QVERIFY(!popup.window()); - QCOMPARE(spy.count(), 0); - - QQuickWindow window; - item.setParentItem(window.contentItem()); - QCOMPARE(popup.window(), &window); - QCOMPARE(spy.count(), 1); - - item.setParentItem(nullptr); - QVERIFY(!popup.window()); - QCOMPARE(spy.count(), 2); - - popup.setParentItem(window.contentItem()); - QCOMPARE(popup.window(), &window); - QCOMPARE(spy.count(), 3); -} - -Q_DECLARE_METATYPE(QQuickPopup::ClosePolicy) - -void tst_popup::closePolicy_data() -{ - qRegisterMetaType(); - - QTest::addColumn("source"); - QTest::addColumn("closePolicy"); - - QTest::newRow("Window:NoAutoClose") << "window.qml"<< static_cast(QQuickPopup::NoAutoClose); - QTest::newRow("Window:CloseOnPressOutside") << "window.qml"<< static_cast(QQuickPopup::CloseOnPressOutside); - QTest::newRow("Window:CloseOnPressOutsideParent") << "window.qml"<< static_cast(QQuickPopup::CloseOnPressOutsideParent); - QTest::newRow("Window:CloseOnPressOutside|Parent") << "window.qml"<< static_cast(QQuickPopup::CloseOnPressOutside | QQuickPopup::CloseOnPressOutsideParent); - QTest::newRow("Window:CloseOnReleaseOutside") << "window.qml"<< static_cast(QQuickPopup::CloseOnReleaseOutside); - QTest::newRow("Window:CloseOnReleaseOutside|Parent") << "window.qml"<< static_cast(QQuickPopup::CloseOnReleaseOutside | QQuickPopup::CloseOnReleaseOutsideParent); - QTest::newRow("Window:CloseOnEscape") << "window.qml"<< static_cast(QQuickPopup::CloseOnEscape); - - QTest::newRow("ApplicationWindow:NoAutoClose") << "applicationwindow.qml"<< static_cast(QQuickPopup::NoAutoClose); - QTest::newRow("ApplicationWindow:CloseOnPressOutside") << "applicationwindow.qml"<< static_cast(QQuickPopup::CloseOnPressOutside); - QTest::newRow("ApplicationWindow:CloseOnPressOutsideParent") << "applicationwindow.qml"<< static_cast(QQuickPopup::CloseOnPressOutsideParent); - QTest::newRow("ApplicationWindow:CloseOnPressOutside|Parent") << "applicationwindow.qml"<< static_cast(QQuickPopup::CloseOnPressOutside | QQuickPopup::CloseOnPressOutsideParent); - QTest::newRow("ApplicationWindow:CloseOnReleaseOutside") << "applicationwindow.qml"<< static_cast(QQuickPopup::CloseOnReleaseOutside); - QTest::newRow("ApplicationWindow:CloseOnReleaseOutside|Parent") << "applicationwindow.qml"<< static_cast(QQuickPopup::CloseOnReleaseOutside | QQuickPopup::CloseOnReleaseOutsideParent); - QTest::newRow("ApplicationWindow:CloseOnEscape") << "applicationwindow.qml"<< static_cast(QQuickPopup::CloseOnEscape); -} - -void tst_popup::closePolicy() -{ - QFETCH(QString, source); - QFETCH(QQuickPopup::ClosePolicy, closePolicy); - - QQuickApplicationHelper helper(this, source); - - QQuickWindow *window = helper.window; - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickPopup *popup = window->property("popup").value(); - QVERIFY(popup); - - QQuickButton *button = window->property("button").value(); - QVERIFY(button); - - popup->setModal(true); - popup->setFocus(true); - popup->setClosePolicy(closePolicy); - - popup->open(); - QVERIFY(popup->isVisible()); - - // press outside popup and its parent - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); - if (closePolicy.testFlag(QQuickPopup::CloseOnPressOutside) || closePolicy.testFlag(QQuickPopup::CloseOnPressOutsideParent)) - QVERIFY(!popup->isVisible()); - else - QVERIFY(popup->isVisible()); - - popup->open(); - QVERIFY(popup->isVisible()); - - // release outside popup and its parent - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); - if (closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutside)) - QVERIFY(!popup->isVisible()); - else - QVERIFY(popup->isVisible()); - - popup->open(); - QVERIFY(popup->isVisible()); - - // press outside popup but inside its parent - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(button->x(), button->y())); - if (closePolicy.testFlag(QQuickPopup::CloseOnPressOutside) && !closePolicy.testFlag(QQuickPopup::CloseOnPressOutsideParent)) - QVERIFY(!popup->isVisible()); - else - QVERIFY(popup->isVisible()); - - popup->open(); - QVERIFY(popup->isVisible()); - - // release outside popup but inside its parent - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(button->x(), button->y())); - if (closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutside) && !closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutsideParent)) - QVERIFY(!popup->isVisible()); - else - QVERIFY(popup->isVisible()); - - popup->open(); - QVERIFY(popup->isVisible()); - - // press inside and release outside - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(button->x() + popup->x(), button->y() + popup->y())); - QVERIFY(popup->isVisible()); - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); - QVERIFY(popup->isVisible()); - - // escape - QTest::keyClick(window, Qt::Key_Escape); - if (closePolicy.testFlag(QQuickPopup::CloseOnEscape)) - QVERIFY(!popup->isVisible()); - else - QVERIFY(popup->isVisible()); -} - -void tst_popup::activeFocusOnClose1() -{ - // Test that a popup that never sets focus: true (e.g. ToolTip) doesn't affect - // the active focus item when it closes. - QQuickApplicationHelper helper(this, QStringLiteral("activeFocusOnClose1.qml")); - QQuickApplicationWindow *window = helper.appWindow; - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickPopup *focusedPopup = helper.appWindow->property("focusedPopup").value(); - QVERIFY(focusedPopup); - - QQuickPopup *nonFocusedPopup = helper.appWindow->property("nonFocusedPopup").value(); - QVERIFY(nonFocusedPopup); - - focusedPopup->open(); - QVERIFY(focusedPopup->isVisible()); - QVERIFY(focusedPopup->hasActiveFocus()); - - nonFocusedPopup->open(); - QVERIFY(nonFocusedPopup->isVisible()); - QVERIFY(focusedPopup->hasActiveFocus()); - - nonFocusedPopup->close(); - QVERIFY(!nonFocusedPopup->isVisible()); - QVERIFY(focusedPopup->hasActiveFocus()); -} - -void tst_popup::activeFocusOnClose2() -{ - // Test that a popup that sets focus: true but relinquishes focus (e.g. by - // calling forceActiveFocus() on another item) before it closes doesn't - // affect the active focus item when it closes. - QQuickApplicationHelper helper(this, QStringLiteral("activeFocusOnClose2.qml")); - QQuickApplicationWindow *window = helper.appWindow; - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickPopup *popup1 = helper.appWindow->property("popup1").value(); - QVERIFY(popup1); - - QQuickPopup *popup2 = helper.appWindow->property("popup2").value(); - QVERIFY(popup2); - - QQuickButton *closePopup2Button = helper.appWindow->property("closePopup2Button").value(); - QVERIFY(closePopup2Button); - - popup1->open(); - QVERIFY(popup1->isVisible()); - QVERIFY(popup1->hasActiveFocus()); - - popup2->open(); - QVERIFY(popup2->isVisible()); - QVERIFY(popup2->hasActiveFocus()); - - // Causes popup1.contentItem.forceActiveFocus() to be called, then closes popup2. - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, - closePopup2Button->mapToScene(QPointF(closePopup2Button->width() / 2, closePopup2Button->height() / 2)).toPoint()); - QVERIFY(!popup2->isVisible()); - QVERIFY(popup1->hasActiveFocus()); -} - -void tst_popup::activeFocusOnClose3() -{ - // Test that a closing popup that had focus doesn't steal focus from - // another popup that the focus was transferred to. - QQuickApplicationHelper helper(this, QStringLiteral("activeFocusOnClose3.qml")); - QQuickApplicationWindow *window = helper.appWindow; - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickPopup *popup1 = helper.appWindow->property("popup1").value(); - QVERIFY(popup1); - - QQuickPopup *popup2 = helper.appWindow->property("popup2").value(); - QVERIFY(popup2); - - popup1->open(); - QVERIFY(popup1->isVisible()); - QTRY_VERIFY(popup1->hasActiveFocus()); - - popup2->open(); - popup1->close(); - - QSignalSpy closedSpy(popup1, SIGNAL(closed())); - QVERIFY(closedSpy.isValid()); - QVERIFY(closedSpy.wait()); - - QVERIFY(!popup1->isVisible()); - QVERIFY(popup2->isVisible()); - QTRY_VERIFY(popup2->hasActiveFocus()); -} - -void tst_popup::hover_data() -{ - QTest::addColumn("source"); - QTest::addColumn("modal"); - - QTest::newRow("Window:modal") << "window-hover.qml" << true; - QTest::newRow("Window:modeless") << "window-hover.qml" << false; - QTest::newRow("ApplicationWindow:modal") << "applicationwindow-hover.qml" << true; - QTest::newRow("ApplicationWindow:modeless") << "applicationwindow-hover.qml" << false; -} - -void tst_popup::hover() -{ - QFETCH(QString, source); - QFETCH(bool, modal); - - QQuickApplicationHelper helper(this, source); - QQuickWindow *window = helper.window; - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickPopup *popup = window->property("popup").value(); - QVERIFY(popup); - popup->setModal(modal); - - QQuickButton *parentButton = window->property("parentButton").value(); - QVERIFY(parentButton); - parentButton->setHoverEnabled(true); - - QQuickButton *childButton = window->property("childButton").value(); - QVERIFY(childButton); - childButton->setHoverEnabled(true); - - QSignalSpy openedSpy(popup, SIGNAL(opened())); - QVERIFY(openedSpy.isValid()); - popup->open(); - QVERIFY(openedSpy.count() == 1 || openedSpy.wait()); - - // hover the parent button outside the popup - QTest::mouseMove(window, QPoint(window->width() - 1, window->height() - 1)); - QCOMPARE(parentButton->isHovered(), !modal); - QVERIFY(!childButton->isHovered()); - - // hover the popup background - QTest::mouseMove(window, QPoint(1, 1)); - QVERIFY(!parentButton->isHovered()); - QVERIFY(!childButton->isHovered()); - - // hover the child button in a popup - QTest::mouseMove(window, QPoint(2, 2)); - QVERIFY(!parentButton->isHovered()); - QVERIFY(childButton->isHovered()); - - QSignalSpy closedSpy(popup, SIGNAL(closed())); - QVERIFY(closedSpy.isValid()); - popup->close(); - QVERIFY(closedSpy.count() == 1 || closedSpy.wait()); - - // hover the parent button after closing the popup - QTest::mouseMove(window, QPoint(window->width() / 2, window->height() / 2)); - QVERIFY(parentButton->isHovered()); -} - -void tst_popup::wheel_data() -{ - QTest::addColumn("source"); - QTest::addColumn("modal"); - - QTest::newRow("Window:modal") << "window-wheel.qml" << true; - QTest::newRow("Window:modeless") << "window-wheel.qml" << false; - QTest::newRow("ApplicationWindow:modal") << "applicationwindow-wheel.qml" << true; - QTest::newRow("ApplicationWindow:modeless") << "applicationwindow-wheel.qml" << false; -} - -static bool sendWheelEvent(QQuickItem *item, const QPoint &localPos, int degrees) -{ - QQuickWindow *window = item->window(); - QWheelEvent wheelEvent(localPos, item->window()->mapToGlobal(localPos), QPoint(0, 0), QPoint(0, 8 * degrees), 0, Qt::Vertical, Qt::NoButton, 0); - QSpontaneKeyEvent::setSpontaneous(&wheelEvent); - return qGuiApp->notify(window, &wheelEvent); -} - -void tst_popup::wheel() -{ - QFETCH(QString, source); - QFETCH(bool, modal); - - QQuickApplicationHelper helper(this, source); - QQuickWindow *window = helper.window; - window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - - QQuickSlider *contentSlider = window->property("contentSlider").value(); - QVERIFY(contentSlider); - - QQuickPopup *popup = window->property("popup").value(); - QVERIFY(popup && popup->contentItem()); - popup->setModal(modal); - - QQuickSlider *popupSlider = window->property("popupSlider").value(); - QVERIFY(popupSlider); - - { - // wheel over the content - qreal oldContentValue = contentSlider->value(); - qreal oldPopupValue = popupSlider->value(); - - QVERIFY(sendWheelEvent(contentSlider, QPoint(contentSlider->width() / 2, contentSlider->height() / 2), 15)); - - QVERIFY(!qFuzzyCompare(contentSlider->value(), oldContentValue)); // must have moved - QVERIFY(qFuzzyCompare(popupSlider->value(), oldPopupValue)); // must not have moved - } - - QSignalSpy openedSpy(popup, SIGNAL(opened())); - QVERIFY(openedSpy.isValid()); - popup->open(); - QVERIFY(openedSpy.count() == 1 || openedSpy.wait()); - - { - // wheel over the popup content - qreal oldContentValue = contentSlider->value(); - qreal oldPopupValue = popupSlider->value(); - - QVERIFY(sendWheelEvent(popupSlider, QPoint(popupSlider->width() / 2, popupSlider->height() / 2), 15)); - - QVERIFY(qFuzzyCompare(contentSlider->value(), oldContentValue)); // must not have moved - QVERIFY(!qFuzzyCompare(popupSlider->value(), oldPopupValue)); // must have moved - } - - { - // wheel over the overlay - qreal oldContentValue = contentSlider->value(); - qreal oldPopupValue = popupSlider->value(); - - QVERIFY(sendWheelEvent(QQuickOverlay::overlay(window), QPoint(0, 0), 15)); - - if (modal) { - // the content below a modal overlay must not move - QVERIFY(qFuzzyCompare(contentSlider->value(), oldContentValue)); - } else { - // the content below a modeless overlay must move - QVERIFY(!qFuzzyCompare(contentSlider->value(), oldContentValue)); - } - QVERIFY(qFuzzyCompare(popupSlider->value(), oldPopupValue)); // must not have moved - } -} - -void tst_popup::parentDestroyed() -{ - QQuickPopup popup; - popup.setParentItem(new QQuickItem); - delete popup.parentItem(); - QVERIFY(!popup.parentItem()); -} - -void tst_popup::nested() -{ - QQuickApplicationHelper helper(this, QStringLiteral("nested.qml")); - QQuickWindow *window = helper.window; - window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - - QQuickPopup *modalPopup = window->property("modalPopup").value(); - QVERIFY(modalPopup); - - QQuickPopup *modelessPopup = window->property("modelessPopup").value(); - QVERIFY(modelessPopup); - - modalPopup->open(); - QCOMPARE(modalPopup->isVisible(), true); - - modelessPopup->open(); - QCOMPARE(modelessPopup->isVisible(), true); - - // click outside the modeless popup on the top, but inside the modal popup below - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(150, 150)); - - QTRY_COMPARE(modelessPopup->isVisible(), false); - QCOMPARE(modalPopup->isVisible(), true); -} - -// QTBUG-56697 -void tst_popup::grabber() -{ - QQuickApplicationHelper helper(this, QStringLiteral("grabber.qml")); - QQuickWindow *window = helper.window; - window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - - QQuickPopup *menu = window->property("menu").value(); - QVERIFY(menu); - - QQuickPopup *popup = window->property("popup").value(); - QVERIFY(popup); - - QQuickPopup *combo = window->property("combo").value(); - QVERIFY(combo); - - menu->open(); - QCOMPARE(menu->isVisible(), true); - QCOMPARE(popup->isVisible(), false); - QCOMPARE(combo->isVisible(), false); - - // click a menu item to open the popup - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(menu->width() / 2, menu->height() / 2)); - QCOMPARE(menu->isVisible(), false); - QCOMPARE(popup->isVisible(), true); - QCOMPARE(combo->isVisible(), false); - - combo->open(); - QCOMPARE(menu->isVisible(), false); - QCOMPARE(popup->isVisible(), true); - QCOMPARE(combo->isVisible(), true); - - // click outside to close both the combo popup and the parent popup - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() - 1, window->height() - 1)); - QCOMPARE(menu->isVisible(), false); - QCOMPARE(popup->isVisible(), false); - QCOMPARE(combo->isVisible(), false); - - menu->open(); - QCOMPARE(menu->isVisible(), true); - QCOMPARE(popup->isVisible(), false); - QCOMPARE(combo->isVisible(), false); - - // click outside the menu to close it (QTBUG-56697) - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() - 1, window->height() - 1)); - QCOMPARE(menu->isVisible(), false); - QCOMPARE(popup->isVisible(), false); - QCOMPARE(combo->isVisible(), false); -} - -void tst_popup::cursorShape() -{ - // Ensure that the mouse cursor has the correct shape when over a popup - // which is itself over an item with a different shape. - QQuickApplicationHelper helper(this, QStringLiteral("cursor.qml")); - QQuickApplicationWindow *window = helper.appWindow; - window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - - QQuickPopup *popup = helper.appWindow->property("popup").value(); - QVERIFY(popup); - - popup->open(); - QVERIFY(popup->isVisible()); - - QQuickItem *textField = helper.appWindow->property("textField").value(); - QVERIFY(textField); - - // Move the mouse over the text field. - const QPoint textFieldPos(popup->x() - 10, popup->y() + popup->height() / 2); - QTest::mouseMove(window, textFieldPos); - QCOMPARE(window->cursor().shape(), textField->cursor().shape()); - - // Move the mouse over the popup where it overlaps with the text field. - const QPoint textFieldOverlapPos(popup->x() + 10, popup->y() + popup->height() / 2); - QTest::mouseMove(window, textFieldOverlapPos); - QCOMPARE(window->cursor().shape(), popup->popupItem()->cursor().shape()); - - popup->close(); - QTRY_VERIFY(!popup->isVisible()); -} - -class FriendlyPopup : public QQuickPopup -{ - friend class tst_popup; -}; - -void tst_popup::componentComplete() -{ - FriendlyPopup cppPopup; - QVERIFY(cppPopup.isComponentComplete()); - - QQmlEngine engine; - QQmlComponent component(&engine); - component.setData("import QtQuick.Controls 2.2; Popup { }", QUrl()); - - FriendlyPopup *qmlPopup = static_cast(component.beginCreate(engine.rootContext())); - QVERIFY(qmlPopup); - QVERIFY(!qmlPopup->isComponentComplete()); - - component.completeCreate(); - QVERIFY(qmlPopup->isComponentComplete()); -} - -void tst_popup::closeOnEscapeWithNestedPopups() -{ - // Tests the scenario in the Gallery example, where there are nested popups that should - // close in the correct order when the Escape key is pressed. - QQuickApplicationHelper helper(this, QStringLiteral("closeOnEscapeWithNestedPopups.qml")); - QQuickApplicationWindow *window = helper.appWindow; - window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - - // The stack view should have two items, and it should pop the second when escape is pressed - // and it has focus. - QQuickStackView *stackView = window->findChild("stackView"); - QVERIFY(stackView); - QCOMPARE(stackView->depth(), 2); - - QQuickItem *optionsToolButton = window->findChild("optionsToolButton"); - QVERIFY(optionsToolButton); - - // Click on the options tool button. The settings menu should pop up. - const QPoint optionsToolButtonCenter = optionsToolButton->mapToScene( - QPointF(optionsToolButton->width() / 2, optionsToolButton->height() / 2)).toPoint(); - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, optionsToolButtonCenter); - - QQuickPopup *optionsMenu = window->findChild("optionsMenu"); - QVERIFY(optionsMenu); - QTRY_VERIFY(optionsMenu->isVisible()); - - QQuickItem *settingsMenuItem = window->findChild("settingsMenuItem"); - QVERIFY(settingsMenuItem); - - // Click on the settings menu item. The settings dialog should pop up. - const QPoint settingsMenuItemCenter = settingsMenuItem->mapToScene( - QPointF(settingsMenuItem->width() / 2, settingsMenuItem->height() / 2)).toPoint(); - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, settingsMenuItemCenter); - - QQuickPopup *settingsDialog = window->contentItem()->findChild("settingsDialog"); - QVERIFY(settingsDialog); - QTRY_VERIFY(settingsDialog->isVisible()); - - QQuickComboBox *comboBox = window->contentItem()->findChild("comboBox"); - QVERIFY(comboBox); - - // Click on the combo box button. The combo box popup should pop up. - const QPoint comboBoxCenter = comboBox->mapToScene( - QPointF(comboBox->width() / 2, comboBox->height() / 2)).toPoint(); - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, comboBoxCenter); - QTRY_VERIFY(comboBox->popup()->isVisible()); - - // Close the combo box popup with the escape key. The settings dialog should still be visible. - QTest::keyClick(window, Qt::Key_Escape); - QTRY_VERIFY(!comboBox->popup()->isVisible()); - QVERIFY(settingsDialog->isVisible()); - - // Close the settings dialog with the escape key. - QTest::keyClick(window, Qt::Key_Escape); - QTRY_VERIFY(!settingsDialog->isVisible()); - - // The stack view should still have two items. - QCOMPARE(stackView->depth(), 2); - - // Remove one by pressing the Escape key (the Shortcut should be activated). - QTest::keyClick(window, Qt::Key_Escape); - QCOMPARE(stackView->depth(), 1); -} - -void tst_popup::orientation_data() -{ - QTest::addColumn("orientation"); - QTest::addColumn("position"); - - QTest::newRow("Portrait") << Qt::PortraitOrientation << QPointF(330, 165); - QTest::newRow("Landscape") << Qt::LandscapeOrientation << QPointF(165, 270); - QTest::newRow("InvertedPortrait") << Qt::InvertedPortraitOrientation << QPointF(270, 135); - QTest::newRow("InvertedLandscape") << Qt::InvertedLandscapeOrientation << QPointF(135, 330); -} - -void tst_popup::orientation() -{ - QFETCH(Qt::ScreenOrientation, orientation); - QFETCH(QPointF, position); - - QQuickApplicationHelper helper(this, "orientation.qml"); - - QQuickWindow *window = helper.window; - window->reportContentOrientationChange(orientation); - window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickPopup *popup = window->property("popup").value(); - QVERIFY(popup); - popup->open(); - - QCOMPARE(popup->popupItem()->position(), position); -} - -QTEST_MAIN(tst_popup) - -#include "tst_popup.moc" diff --git a/tests/auto/qquickpopup/data/activeFocusOnClose1.qml b/tests/auto/qquickpopup/data/activeFocusOnClose1.qml new file mode 100644 index 00000000..ee0295c1 --- /dev/null +++ b/tests/auto/qquickpopup/data/activeFocusOnClose1.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 { + width: 400 + height: 400 + + property alias focusedPopup: focusedPopup + property alias nonFocusedPopup: nonFocusedPopup + + Popup { + id: focusedPopup + focus: true + } + + Popup { + id: nonFocusedPopup + } +} diff --git a/tests/auto/qquickpopup/data/activeFocusOnClose2.qml b/tests/auto/qquickpopup/data/activeFocusOnClose2.qml new file mode 100644 index 00000000..cb215f9b --- /dev/null +++ b/tests/auto/qquickpopup/data/activeFocusOnClose2.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 popup1: popup1 + property alias popup2: popup2 + property alias closePopup2Button: closePopup2Button + + Popup { + id: popup1 + focus: true + } + + Popup { + id: popup2 + focus: true + + Button { + id: closePopup2Button + onClicked: { + popup1.contentItem.forceActiveFocus(); + popup2.close(); + } + } + } +} diff --git a/tests/auto/qquickpopup/data/activeFocusOnClose3.qml b/tests/auto/qquickpopup/data/activeFocusOnClose3.qml new file mode 100644 index 00000000..a8137b34 --- /dev/null +++ b/tests/auto/qquickpopup/data/activeFocusOnClose3.qml @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** 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: 400 + height: 400 + + property alias popup1: popup1 + property alias popup2: popup2 + + Button { + focus: true + } + + Popup { + id: popup1 + focus: true + enter: Transition { PauseAnimation { duration: 200 } } + exit: Transition { PauseAnimation { duration: 200 } } + } + + Popup { + id: popup2 + focus: true + enter: Transition { PauseAnimation { duration: 100 } } + exit: Transition { PauseAnimation { duration: 100 } } + } +} diff --git a/tests/auto/qquickpopup/data/applicationwindow-hover.qml b/tests/auto/qquickpopup/data/applicationwindow-hover.qml new file mode 100644 index 00000000..8cec6ba7 --- /dev/null +++ b/tests/auto/qquickpopup/data/applicationwindow-hover.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.0 + +ApplicationWindow { + width: 400 + height: 400 + + property alias popup: popup + property alias parentButton: parentButton + property alias childButton: childButton + + Button { + id: parentButton + text: "Parent" + anchors.fill: parent + + Popup { + id: popup + x: 1 + y: 1 + padding: 1 + + Button { + id: childButton + text: "Child" + } + } + } +} diff --git a/tests/auto/qquickpopup/data/applicationwindow-wheel.qml b/tests/auto/qquickpopup/data/applicationwindow-wheel.qml new file mode 100644 index 00000000..a89bd0f6 --- /dev/null +++ b/tests/auto/qquickpopup/data/applicationwindow-wheel.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** 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.0 + +ApplicationWindow { + id: window + width: 400 + height: 400 + + property alias popup: popup + property alias popupSlider: popupSlider + property alias contentSlider: contentSlider + + Slider { + id: contentSlider + anchors.fill: parent + wheelEnabled: true + } + + Popup { + id: popup + x: 50; y: 50 + implicitWidth: parent.width - 100 + implicitHeight: parent.height - 100 + clip: true + contentItem: Slider { + id: popupSlider + wheelEnabled: true + } + } +} diff --git a/tests/auto/qquickpopup/data/applicationwindow.qml b/tests/auto/qquickpopup/data/applicationwindow.qml new file mode 100644 index 00000000..659aa843 --- /dev/null +++ b/tests/auto/qquickpopup/data/applicationwindow.qml @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** 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 popup: popup + property alias popup2: popup2 + property alias button: button + + Button { + id: button + text: "Open" + anchors.centerIn: parent + anchors.verticalCenterOffset: -height + + Popup { + id: popup + y: parent.height + + Text { + color: "white" + text: "Hello, world!" + + MouseArea { + anchors.fill: parent + onClicked: popup.close() + } + } + } + } + + Popup { + id: popup2 + y: popup.y + z: 1 + contentItem: Text { + text: "Popup2" + font.pixelSize: 36 + } + } +} diff --git a/tests/auto/qquickpopup/data/closeOnEscapeWithNestedPopups.qml b/tests/auto/qquickpopup/data/closeOnEscapeWithNestedPopups.qml new file mode 100644 index 00000000..53dae0f9 --- /dev/null +++ b/tests/auto/qquickpopup/data/closeOnEscapeWithNestedPopups.qml @@ -0,0 +1,112 @@ +/**************************************************************************** +** +** 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.9 +import QtQuick.Controls 2.2 + +ApplicationWindow { + width: 400 + height: 400 + + header: ToolBar { + ToolButton { + objectName: "optionsToolButton" + text: "Options" + onClicked: optionsMenu.open() + + Menu { + id: optionsMenu + objectName: "optionsMenu" + x: parent.width - width + transformOrigin: Menu.TopRight + + MenuItem { + objectName: "settingsMenuItem" + text: "Settings" + onTriggered: settingsDialog.open() + } + } + } + } + + Shortcut { + sequence: "Esc" + enabled: stackView.depth > 1 + onActivated: stackView.pop() + } + + Component { + id: itemComponent + + Item {} + } + + StackView { + id: stackView + objectName: "stackView" + anchors.fill: parent + initialItem: Item { + objectName: "initialStackViewItem" + } + + Component.onCompleted: push(itemComponent) + } + + Dialog { + id: settingsDialog + objectName: "settingsDialog" + modal: true + + contentItem: ComboBox { + objectName: "comboBox" + model: 10 + } + } +} diff --git a/tests/auto/qquickpopup/data/cursor.qml b/tests/auto/qquickpopup/data/cursor.qml new file mode 100644 index 00000000..fd4475a0 --- /dev/null +++ b/tests/auto/qquickpopup/data/cursor.qml @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** 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: 400 + height: 400 + + property alias popup: popup + property alias textField: textField + + TextField { + id: textField + } + Popup { + id: popup + x: textField.x + textField.width / 2 + y: textField.y + textField.height / 2 - height / 2 + width: 100 + height: 100 + } +} diff --git a/tests/auto/qquickpopup/data/grabber.qml b/tests/auto/qquickpopup/data/grabber.qml new file mode 100644 index 00000000..b9995b54 --- /dev/null +++ b/tests/auto/qquickpopup/data/grabber.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** 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: 400 + height: 400 + + property alias menu: menu + property alias popup: popup + property alias combo: combo.popup + + Menu { + id: menu + MenuItem { + onTriggered: popup.open() + } + } + + Popup { + id: popup + modal: true + width: 200 + height: 200 + + ComboBox { + id: combo + model: 3 + } + } +} diff --git a/tests/auto/qquickpopup/data/nested.qml b/tests/auto/qquickpopup/data/nested.qml new file mode 100644 index 00000000..48e51fc8 --- /dev/null +++ b/tests/auto/qquickpopup/data/nested.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** 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: 400 + height: 400 + + property alias modalPopup: modalPopup + property alias modelessPopup: modelessPopup + + Popup { + id: modalPopup + modal: true + width: 200 + height: 200 + } + + Popup { + id: modelessPopup + modal: false + width: 100 + height: 100 + } +} diff --git a/tests/auto/qquickpopup/data/orientation.qml b/tests/auto/qquickpopup/data/orientation.qml new file mode 100644 index 00000000..cbf69b2b --- /dev/null +++ b/tests/auto/qquickpopup/data/orientation.qml @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** 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.0 + +Window { + width: 600 + height: 300 + + property alias popup: popup + + Rectangle { + width: 60 + height: 30 + anchors.centerIn: parent + border.width: 1 + + Popup { + id: popup + x: parent.width + y: parent.height + width: 30 + height: 60 + visible: true + } + } +} diff --git a/tests/auto/qquickpopup/data/window-hover.qml b/tests/auto/qquickpopup/data/window-hover.qml new file mode 100644 index 00000000..669afb08 --- /dev/null +++ b/tests/auto/qquickpopup/data/window-hover.qml @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** 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.0 + +Window { + width: 400 + height: 400 + + property alias popup: popup + property alias parentButton: parentButton + property alias childButton: childButton + + Button { + id: parentButton + text: "Parent" + anchors.fill: parent + + Popup { + id: popup + x: 1 + y: 1 + padding: 1 + + Button { + id: childButton + text: "Child" + } + } + } +} diff --git a/tests/auto/qquickpopup/data/window-wheel.qml b/tests/auto/qquickpopup/data/window-wheel.qml new file mode 100644 index 00000000..45c09b45 --- /dev/null +++ b/tests/auto/qquickpopup/data/window-wheel.qml @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** 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.0 + +Window { + id: window + width: 400 + height: 400 + + property alias popup: popup + property alias popupSlider: popupSlider + property alias contentSlider: contentSlider + + Slider { + id: contentSlider + anchors.fill: parent + wheelEnabled: true + } + + Popup { + id: popup + x: 50; y: 50 + implicitWidth: parent.width - 100 + implicitHeight: parent.height - 100 + clip: true + contentItem: Slider { + id: popupSlider + wheelEnabled: true + } + } +} diff --git a/tests/auto/qquickpopup/data/window.qml b/tests/auto/qquickpopup/data/window.qml new file mode 100644 index 00000000..962ab573 --- /dev/null +++ b/tests/auto/qquickpopup/data/window.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.Window 2.2 +import QtQuick.Controls 2.0 + +Window { + width: 400 + height: 400 + + property alias popup: popup + property alias popup2: popup2 + property alias button: button + + Button { + id: button + text: "Open" + anchors.centerIn: parent + anchors.verticalCenterOffset: -height + + Popup { + id: popup + y: parent.height + + Text { + color: "white" + text: "Hello, world!" + + MouseArea { + anchors.fill: parent + onClicked: popup.close() + } + } + } + } + + Popup { + id: popup2 + y: popup.y + z: 1 + contentItem: Text { + text: "Popup2" + font.pixelSize: 36 + } + } +} diff --git a/tests/auto/qquickpopup/qquickpopup.pro b/tests/auto/qquickpopup/qquickpopup.pro new file mode 100644 index 00000000..935e91bd --- /dev/null +++ b/tests/auto/qquickpopup/qquickpopup.pro @@ -0,0 +1,14 @@ +CONFIG += testcase +TARGET = tst_qquickpopup +SOURCES += tst_qquickpopup.cpp + +macos:CONFIG -= app_bundle + +QT += core-private gui-private qml-private quick-private testlib quicktemplates2-private + +include (../shared/util.pri) + +TESTDATA = data/* + +OTHER_FILES += \ + data/*.qml diff --git a/tests/auto/qquickpopup/tst_qquickpopup.cpp b/tests/auto/qquickpopup/tst_qquickpopup.cpp new file mode 100644 index 00000000..3f4b2d13 --- /dev/null +++ b/tests/auto/qquickpopup/tst_qquickpopup.cpp @@ -0,0 +1,977 @@ +/**************************************************************************** +** +** 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 "../shared/util.h" +#include "../shared/visualtestutil.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace QQuickVisualTestUtil; + +class tst_QQuickPopup : public QQmlDataTest +{ + Q_OBJECT + +private slots: + void initTestCase(); + void visible_data(); + void visible(); + void state(); + void overlay_data(); + void overlay(); + void zOrder_data(); + void zOrder(); + void windowChange(); + void closePolicy_data(); + void closePolicy(); + void activeFocusOnClose1(); + void activeFocusOnClose2(); + void activeFocusOnClose3(); + void hover_data(); + void hover(); + void wheel_data(); + void wheel(); + void parentDestroyed(); + void nested(); + void grabber(); + void cursorShape(); + void componentComplete(); + void closeOnEscapeWithNestedPopups(); + void orientation_data(); + void orientation(); +}; + +void tst_QQuickPopup::initTestCase() +{ + QQmlDataTest::initTestCase(); + qputenv("QML_NO_TOUCH_COMPRESSION", "1"); +} + +void tst_QQuickPopup::visible_data() +{ + QTest::addColumn("source"); + QTest::newRow("Window") << "window.qml"; + QTest::newRow("ApplicationWindow") << "applicationwindow.qml"; +} + +void tst_QQuickPopup::visible() +{ + QFETCH(QString, source); + QQuickApplicationHelper helper(this, source); + + QQuickWindow *window = helper.window; + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickPopup *popup = window->property("popup").value(); + QVERIFY(popup); + QQuickItem *popupItem = popup->popupItem(); + + popup->open(); + QVERIFY(popup->isVisible()); + + QQuickOverlay *overlay = QQuickOverlay::overlay(window); + QVERIFY(overlay); + QVERIFY(overlay->childItems().contains(popupItem)); + + popup->close(); + QVERIFY(!popup->isVisible()); + QVERIFY(!overlay->childItems().contains(popupItem)); + + popup->setVisible(true); + QVERIFY(popup->isVisible()); + QVERIFY(overlay->childItems().contains(popupItem)); + + popup->setVisible(false); + QVERIFY(!popup->isVisible()); + QVERIFY(!overlay->childItems().contains(popupItem)); +} + +void tst_QQuickPopup::state() +{ + QQuickApplicationHelper helper(this, "applicationwindow.qml"); + + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickPopup *popup = window->property("popup").value(); + QVERIFY(popup); + + QCOMPARE(popup->isVisible(), false); + + QSignalSpy visibleChangedSpy(popup, SIGNAL(visibleChanged())); + QSignalSpy aboutToShowSpy(popup, SIGNAL(aboutToShow())); + QSignalSpy aboutToHideSpy(popup, SIGNAL(aboutToHide())); + QSignalSpy openedSpy(popup, SIGNAL(opened())); + QSignalSpy closedSpy(popup, SIGNAL(closed())); + + QVERIFY(visibleChangedSpy.isValid()); + QVERIFY(aboutToShowSpy.isValid()); + QVERIFY(aboutToHideSpy.isValid()); + QVERIFY(openedSpy.isValid()); + QVERIFY(closedSpy.isValid()); + + popup->open(); + QCOMPARE(visibleChangedSpy.count(), 1); + QCOMPARE(aboutToShowSpy.count(), 1); + QCOMPARE(aboutToHideSpy.count(), 0); + QTRY_COMPARE(openedSpy.count(), 1); + QCOMPARE(closedSpy.count(), 0); + + popup->close(); + QCOMPARE(visibleChangedSpy.count(), 2); + QCOMPARE(aboutToShowSpy.count(), 1); + QCOMPARE(aboutToHideSpy.count(), 1); + QCOMPARE(openedSpy.count(), 1); + QTRY_COMPARE(closedSpy.count(), 1); +} + +void tst_QQuickPopup::overlay_data() +{ + QTest::addColumn("source"); + QTest::addColumn("modal"); + QTest::addColumn("dim"); + + QTest::newRow("Window") << "window.qml" << false << false; + QTest::newRow("Window,dim") << "window.qml" << false << true; + QTest::newRow("Window,modal") << "window.qml" << true << false; + QTest::newRow("Window,modal,dim") << "window.qml" << true << true; + + QTest::newRow("ApplicationWindow") << "applicationwindow.qml" << false << false; + QTest::newRow("ApplicationWindow,dim") << "applicationwindow.qml" << false << true; + QTest::newRow("ApplicationWindow,modal") << "applicationwindow.qml" << true << false; + QTest::newRow("ApplicationWindow,modal,dim") << "applicationwindow.qml" << true << true; +} + +void tst_QQuickPopup::overlay() +{ + QFETCH(QString, source); + QFETCH(bool, modal); + QFETCH(bool, dim); + + QQuickApplicationHelper helper(this, source); + + QQuickWindow *window = helper.window; + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickOverlay *overlay = QQuickOverlay::overlay(window); + QVERIFY(overlay); + + QSignalSpy overlayPressedSignal(overlay, SIGNAL(pressed())); + QSignalSpy overlayReleasedSignal(overlay, SIGNAL(released())); + QVERIFY(overlayPressedSignal.isValid()); + QVERIFY(overlayReleasedSignal.isValid()); + + QVERIFY(!overlay->isVisible()); // no popups open + + QTest::mouseClick(window, Qt::LeftButton); + QCOMPARE(overlayPressedSignal.count(), 0); + QCOMPARE(overlayReleasedSignal.count(), 0); + + QQuickPopup *popup = window->property("popup").value(); + QVERIFY(popup); + + QQuickButton *button = window->property("button").value(); + QVERIFY(button); + + int overlayPressCount = 0; + int overlayReleaseCount = 0; + + popup->open(); + QVERIFY(popup->isVisible()); + QVERIFY(overlay->isVisible()); + + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); + QCOMPARE(overlayPressedSignal.count(), ++overlayPressCount); + QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount); + + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); + QCOMPARE(overlayPressedSignal.count(), overlayPressCount); + QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount); // no modal-popups open + + popup->close(); + QVERIFY(!popup->isVisible()); + QVERIFY(!overlay->isVisible()); + + popup->setDim(dim); + popup->setModal(modal); + popup->setClosePolicy(QQuickPopup::CloseOnReleaseOutside); + + // mouse + popup->open(); + QVERIFY(popup->isVisible()); + QVERIFY(overlay->isVisible()); + + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); + QCOMPARE(overlayPressedSignal.count(), ++overlayPressCount); + QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount); + + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); + QCOMPARE(overlayPressedSignal.count(), overlayPressCount); + QCOMPARE(overlayReleasedSignal.count(), ++overlayReleaseCount); + + QVERIFY(!popup->isVisible()); + QCOMPARE(overlay->isVisible(), popup->isVisible()); + + // touch + popup->open(); + QVERIFY(popup->isVisible()); + QVERIFY(overlay->isVisible()); + + struct TouchDeviceDeleter + { + static inline void cleanup(QTouchDevice *device) + { + QWindowSystemInterface::unregisterTouchDevice(device); + delete device; + } + }; + + QScopedPointer device(new QTouchDevice); + device->setType(QTouchDevice::TouchScreen); + QWindowSystemInterface::registerTouchDevice(device.data()); + + QTest::touchEvent(window, device.data()).press(0, QPoint(1, 1)); + QCOMPARE(overlayPressedSignal.count(), ++overlayPressCount); + QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount); + + QTest::touchEvent(window, device.data()).release(0, QPoint(1, 1)); + QCOMPARE(overlayPressedSignal.count(), overlayPressCount); + QCOMPARE(overlayReleasedSignal.count(), ++overlayReleaseCount); + + QVERIFY(!popup->isVisible()); + QCOMPARE(overlay->isVisible(), popup->isVisible()); + + // multi-touch + popup->open(); + QVERIFY(popup->isVisible()); + QVERIFY(overlay->isVisible()); + QVERIFY(!button->isPressed()); + + QTest::touchEvent(window, device.data()).press(0, button->mapToScene(QPointF(1, 1)).toPoint()); + QVERIFY(popup->isVisible()); + QVERIFY(overlay->isVisible()); + QCOMPARE(button->isPressed(), !modal); + QCOMPARE(overlayPressedSignal.count(), ++overlayPressCount); + QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount); + + QTest::touchEvent(window, device.data()).stationary(0).press(1, button->mapToScene(QPointF(button->width() / 2, button->height() / 2)).toPoint()); + QVERIFY(popup->isVisible()); + QVERIFY(overlay->isVisible()); + QCOMPARE(button->isPressed(), !modal); + QCOMPARE(overlayPressedSignal.count(), ++overlayPressCount); + QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount); + + QTest::touchEvent(window, device.data()).release(0, button->mapToScene(QPointF(1, 1)).toPoint()).stationary(1); + QVERIFY(!popup->isVisible()); + QVERIFY(!overlay->isVisible()); + QVERIFY(!button->isPressed()); + QCOMPARE(overlayPressedSignal.count(), overlayPressCount); + QCOMPARE(overlayReleasedSignal.count(), ++overlayReleaseCount); + + QTest::touchEvent(window, device.data()).release(1, button->mapToScene(QPointF(button->width() / 2, button->height() / 2)).toPoint()); + QVERIFY(!popup->isVisible()); + QVERIFY(!overlay->isVisible()); + QVERIFY(!button->isPressed()); + QCOMPARE(overlayPressedSignal.count(), overlayPressCount); + QCOMPARE(overlayReleasedSignal.count(), overlayReleaseCount); +} + +void tst_QQuickPopup::zOrder_data() +{ + QTest::addColumn("source"); + QTest::newRow("Window") << "window.qml"; + QTest::newRow("ApplicationWindow") << "applicationwindow.qml"; +} + +void tst_QQuickPopup::zOrder() +{ + QFETCH(QString, source); + QQuickApplicationHelper helper(this, source); + + QQuickWindow *window = helper.window; + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickPopup *popup = window->property("popup").value(); + QVERIFY(popup); + popup->setModal(true); + + QQuickPopup *popup2 = window->property("popup2").value(); + QVERIFY(popup2); + popup2->setModal(true); + + // show popups in reverse order. popup2 has higher z-order so it appears + // on top and must be closed first, even if the other popup was opened last + popup2->open(); + popup->open(); + QVERIFY(popup2->isVisible()); + QVERIFY(popup->isVisible()); + + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); + QVERIFY(!popup2->isVisible()); + QVERIFY(popup->isVisible()); + + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); + QVERIFY(!popup2->isVisible()); + QVERIFY(!popup->isVisible()); +} + +void tst_QQuickPopup::windowChange() +{ + QQuickPopup popup; + QSignalSpy spy(&popup, SIGNAL(windowChanged(QQuickWindow*))); + QVERIFY(spy.isValid()); + + QQuickItem item; + popup.setParentItem(&item); + QVERIFY(!popup.window()); + QCOMPARE(spy.count(), 0); + + QQuickWindow window; + item.setParentItem(window.contentItem()); + QCOMPARE(popup.window(), &window); + QCOMPARE(spy.count(), 1); + + item.setParentItem(nullptr); + QVERIFY(!popup.window()); + QCOMPARE(spy.count(), 2); + + popup.setParentItem(window.contentItem()); + QCOMPARE(popup.window(), &window); + QCOMPARE(spy.count(), 3); +} + +Q_DECLARE_METATYPE(QQuickPopup::ClosePolicy) + +void tst_QQuickPopup::closePolicy_data() +{ + qRegisterMetaType(); + + QTest::addColumn("source"); + QTest::addColumn("closePolicy"); + + QTest::newRow("Window:NoAutoClose") << "window.qml"<< static_cast(QQuickPopup::NoAutoClose); + QTest::newRow("Window:CloseOnPressOutside") << "window.qml"<< static_cast(QQuickPopup::CloseOnPressOutside); + QTest::newRow("Window:CloseOnPressOutsideParent") << "window.qml"<< static_cast(QQuickPopup::CloseOnPressOutsideParent); + QTest::newRow("Window:CloseOnPressOutside|Parent") << "window.qml"<< static_cast(QQuickPopup::CloseOnPressOutside | QQuickPopup::CloseOnPressOutsideParent); + QTest::newRow("Window:CloseOnReleaseOutside") << "window.qml"<< static_cast(QQuickPopup::CloseOnReleaseOutside); + QTest::newRow("Window:CloseOnReleaseOutside|Parent") << "window.qml"<< static_cast(QQuickPopup::CloseOnReleaseOutside | QQuickPopup::CloseOnReleaseOutsideParent); + QTest::newRow("Window:CloseOnEscape") << "window.qml"<< static_cast(QQuickPopup::CloseOnEscape); + + QTest::newRow("ApplicationWindow:NoAutoClose") << "applicationwindow.qml"<< static_cast(QQuickPopup::NoAutoClose); + QTest::newRow("ApplicationWindow:CloseOnPressOutside") << "applicationwindow.qml"<< static_cast(QQuickPopup::CloseOnPressOutside); + QTest::newRow("ApplicationWindow:CloseOnPressOutsideParent") << "applicationwindow.qml"<< static_cast(QQuickPopup::CloseOnPressOutsideParent); + QTest::newRow("ApplicationWindow:CloseOnPressOutside|Parent") << "applicationwindow.qml"<< static_cast(QQuickPopup::CloseOnPressOutside | QQuickPopup::CloseOnPressOutsideParent); + QTest::newRow("ApplicationWindow:CloseOnReleaseOutside") << "applicationwindow.qml"<< static_cast(QQuickPopup::CloseOnReleaseOutside); + QTest::newRow("ApplicationWindow:CloseOnReleaseOutside|Parent") << "applicationwindow.qml"<< static_cast(QQuickPopup::CloseOnReleaseOutside | QQuickPopup::CloseOnReleaseOutsideParent); + QTest::newRow("ApplicationWindow:CloseOnEscape") << "applicationwindow.qml"<< static_cast(QQuickPopup::CloseOnEscape); +} + +void tst_QQuickPopup::closePolicy() +{ + QFETCH(QString, source); + QFETCH(QQuickPopup::ClosePolicy, closePolicy); + + QQuickApplicationHelper helper(this, source); + + QQuickWindow *window = helper.window; + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickPopup *popup = window->property("popup").value(); + QVERIFY(popup); + + QQuickButton *button = window->property("button").value(); + QVERIFY(button); + + popup->setModal(true); + popup->setFocus(true); + popup->setClosePolicy(closePolicy); + + popup->open(); + QVERIFY(popup->isVisible()); + + // press outside popup and its parent + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); + if (closePolicy.testFlag(QQuickPopup::CloseOnPressOutside) || closePolicy.testFlag(QQuickPopup::CloseOnPressOutsideParent)) + QVERIFY(!popup->isVisible()); + else + QVERIFY(popup->isVisible()); + + popup->open(); + QVERIFY(popup->isVisible()); + + // release outside popup and its parent + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); + if (closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutside)) + QVERIFY(!popup->isVisible()); + else + QVERIFY(popup->isVisible()); + + popup->open(); + QVERIFY(popup->isVisible()); + + // press outside popup but inside its parent + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(button->x(), button->y())); + if (closePolicy.testFlag(QQuickPopup::CloseOnPressOutside) && !closePolicy.testFlag(QQuickPopup::CloseOnPressOutsideParent)) + QVERIFY(!popup->isVisible()); + else + QVERIFY(popup->isVisible()); + + popup->open(); + QVERIFY(popup->isVisible()); + + // release outside popup but inside its parent + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(button->x(), button->y())); + if (closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutside) && !closePolicy.testFlag(QQuickPopup::CloseOnReleaseOutsideParent)) + QVERIFY(!popup->isVisible()); + else + QVERIFY(popup->isVisible()); + + popup->open(); + QVERIFY(popup->isVisible()); + + // press inside and release outside + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(button->x() + popup->x(), button->y() + popup->y())); + QVERIFY(popup->isVisible()); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); + QVERIFY(popup->isVisible()); + + // escape + QTest::keyClick(window, Qt::Key_Escape); + if (closePolicy.testFlag(QQuickPopup::CloseOnEscape)) + QVERIFY(!popup->isVisible()); + else + QVERIFY(popup->isVisible()); +} + +void tst_QQuickPopup::activeFocusOnClose1() +{ + // Test that a popup that never sets focus: true (e.g. ToolTip) doesn't affect + // the active focus item when it closes. + QQuickApplicationHelper helper(this, QStringLiteral("activeFocusOnClose1.qml")); + QQuickApplicationWindow *window = helper.appWindow; + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickPopup *focusedPopup = helper.appWindow->property("focusedPopup").value(); + QVERIFY(focusedPopup); + + QQuickPopup *nonFocusedPopup = helper.appWindow->property("nonFocusedPopup").value(); + QVERIFY(nonFocusedPopup); + + focusedPopup->open(); + QVERIFY(focusedPopup->isVisible()); + QVERIFY(focusedPopup->hasActiveFocus()); + + nonFocusedPopup->open(); + QVERIFY(nonFocusedPopup->isVisible()); + QVERIFY(focusedPopup->hasActiveFocus()); + + nonFocusedPopup->close(); + QVERIFY(!nonFocusedPopup->isVisible()); + QVERIFY(focusedPopup->hasActiveFocus()); +} + +void tst_QQuickPopup::activeFocusOnClose2() +{ + // Test that a popup that sets focus: true but relinquishes focus (e.g. by + // calling forceActiveFocus() on another item) before it closes doesn't + // affect the active focus item when it closes. + QQuickApplicationHelper helper(this, QStringLiteral("activeFocusOnClose2.qml")); + QQuickApplicationWindow *window = helper.appWindow; + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickPopup *popup1 = helper.appWindow->property("popup1").value(); + QVERIFY(popup1); + + QQuickPopup *popup2 = helper.appWindow->property("popup2").value(); + QVERIFY(popup2); + + QQuickButton *closePopup2Button = helper.appWindow->property("closePopup2Button").value(); + QVERIFY(closePopup2Button); + + popup1->open(); + QVERIFY(popup1->isVisible()); + QVERIFY(popup1->hasActiveFocus()); + + popup2->open(); + QVERIFY(popup2->isVisible()); + QVERIFY(popup2->hasActiveFocus()); + + // Causes popup1.contentItem.forceActiveFocus() to be called, then closes popup2. + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, + closePopup2Button->mapToScene(QPointF(closePopup2Button->width() / 2, closePopup2Button->height() / 2)).toPoint()); + QVERIFY(!popup2->isVisible()); + QVERIFY(popup1->hasActiveFocus()); +} + +void tst_QQuickPopup::activeFocusOnClose3() +{ + // Test that a closing popup that had focus doesn't steal focus from + // another popup that the focus was transferred to. + QQuickApplicationHelper helper(this, QStringLiteral("activeFocusOnClose3.qml")); + QQuickApplicationWindow *window = helper.appWindow; + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickPopup *popup1 = helper.appWindow->property("popup1").value(); + QVERIFY(popup1); + + QQuickPopup *popup2 = helper.appWindow->property("popup2").value(); + QVERIFY(popup2); + + popup1->open(); + QVERIFY(popup1->isVisible()); + QTRY_VERIFY(popup1->hasActiveFocus()); + + popup2->open(); + popup1->close(); + + QSignalSpy closedSpy(popup1, SIGNAL(closed())); + QVERIFY(closedSpy.isValid()); + QVERIFY(closedSpy.wait()); + + QVERIFY(!popup1->isVisible()); + QVERIFY(popup2->isVisible()); + QTRY_VERIFY(popup2->hasActiveFocus()); +} + +void tst_QQuickPopup::hover_data() +{ + QTest::addColumn("source"); + QTest::addColumn("modal"); + + QTest::newRow("Window:modal") << "window-hover.qml" << true; + QTest::newRow("Window:modeless") << "window-hover.qml" << false; + QTest::newRow("ApplicationWindow:modal") << "applicationwindow-hover.qml" << true; + QTest::newRow("ApplicationWindow:modeless") << "applicationwindow-hover.qml" << false; +} + +void tst_QQuickPopup::hover() +{ + QFETCH(QString, source); + QFETCH(bool, modal); + + QQuickApplicationHelper helper(this, source); + QQuickWindow *window = helper.window; + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickPopup *popup = window->property("popup").value(); + QVERIFY(popup); + popup->setModal(modal); + + QQuickButton *parentButton = window->property("parentButton").value(); + QVERIFY(parentButton); + parentButton->setHoverEnabled(true); + + QQuickButton *childButton = window->property("childButton").value(); + QVERIFY(childButton); + childButton->setHoverEnabled(true); + + QSignalSpy openedSpy(popup, SIGNAL(opened())); + QVERIFY(openedSpy.isValid()); + popup->open(); + QVERIFY(openedSpy.count() == 1 || openedSpy.wait()); + + // hover the parent button outside the popup + QTest::mouseMove(window, QPoint(window->width() - 1, window->height() - 1)); + QCOMPARE(parentButton->isHovered(), !modal); + QVERIFY(!childButton->isHovered()); + + // hover the popup background + QTest::mouseMove(window, QPoint(1, 1)); + QVERIFY(!parentButton->isHovered()); + QVERIFY(!childButton->isHovered()); + + // hover the child button in a popup + QTest::mouseMove(window, QPoint(2, 2)); + QVERIFY(!parentButton->isHovered()); + QVERIFY(childButton->isHovered()); + + QSignalSpy closedSpy(popup, SIGNAL(closed())); + QVERIFY(closedSpy.isValid()); + popup->close(); + QVERIFY(closedSpy.count() == 1 || closedSpy.wait()); + + // hover the parent button after closing the popup + QTest::mouseMove(window, QPoint(window->width() / 2, window->height() / 2)); + QVERIFY(parentButton->isHovered()); +} + +void tst_QQuickPopup::wheel_data() +{ + QTest::addColumn("source"); + QTest::addColumn("modal"); + + QTest::newRow("Window:modal") << "window-wheel.qml" << true; + QTest::newRow("Window:modeless") << "window-wheel.qml" << false; + QTest::newRow("ApplicationWindow:modal") << "applicationwindow-wheel.qml" << true; + QTest::newRow("ApplicationWindow:modeless") << "applicationwindow-wheel.qml" << false; +} + +static bool sendWheelEvent(QQuickItem *item, const QPoint &localPos, int degrees) +{ + QQuickWindow *window = item->window(); + QWheelEvent wheelEvent(localPos, item->window()->mapToGlobal(localPos), QPoint(0, 0), QPoint(0, 8 * degrees), 0, Qt::Vertical, Qt::NoButton, 0); + QSpontaneKeyEvent::setSpontaneous(&wheelEvent); + return qGuiApp->notify(window, &wheelEvent); +} + +void tst_QQuickPopup::wheel() +{ + QFETCH(QString, source); + QFETCH(bool, modal); + + QQuickApplicationHelper helper(this, source); + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickSlider *contentSlider = window->property("contentSlider").value(); + QVERIFY(contentSlider); + + QQuickPopup *popup = window->property("popup").value(); + QVERIFY(popup && popup->contentItem()); + popup->setModal(modal); + + QQuickSlider *popupSlider = window->property("popupSlider").value(); + QVERIFY(popupSlider); + + { + // wheel over the content + qreal oldContentValue = contentSlider->value(); + qreal oldPopupValue = popupSlider->value(); + + QVERIFY(sendWheelEvent(contentSlider, QPoint(contentSlider->width() / 2, contentSlider->height() / 2), 15)); + + QVERIFY(!qFuzzyCompare(contentSlider->value(), oldContentValue)); // must have moved + QVERIFY(qFuzzyCompare(popupSlider->value(), oldPopupValue)); // must not have moved + } + + QSignalSpy openedSpy(popup, SIGNAL(opened())); + QVERIFY(openedSpy.isValid()); + popup->open(); + QVERIFY(openedSpy.count() == 1 || openedSpy.wait()); + + { + // wheel over the popup content + qreal oldContentValue = contentSlider->value(); + qreal oldPopupValue = popupSlider->value(); + + QVERIFY(sendWheelEvent(popupSlider, QPoint(popupSlider->width() / 2, popupSlider->height() / 2), 15)); + + QVERIFY(qFuzzyCompare(contentSlider->value(), oldContentValue)); // must not have moved + QVERIFY(!qFuzzyCompare(popupSlider->value(), oldPopupValue)); // must have moved + } + + { + // wheel over the overlay + qreal oldContentValue = contentSlider->value(); + qreal oldPopupValue = popupSlider->value(); + + QVERIFY(sendWheelEvent(QQuickOverlay::overlay(window), QPoint(0, 0), 15)); + + if (modal) { + // the content below a modal overlay must not move + QVERIFY(qFuzzyCompare(contentSlider->value(), oldContentValue)); + } else { + // the content below a modeless overlay must move + QVERIFY(!qFuzzyCompare(contentSlider->value(), oldContentValue)); + } + QVERIFY(qFuzzyCompare(popupSlider->value(), oldPopupValue)); // must not have moved + } +} + +void tst_QQuickPopup::parentDestroyed() +{ + QQuickPopup popup; + popup.setParentItem(new QQuickItem); + delete popup.parentItem(); + QVERIFY(!popup.parentItem()); +} + +void tst_QQuickPopup::nested() +{ + QQuickApplicationHelper helper(this, QStringLiteral("nested.qml")); + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickPopup *modalPopup = window->property("modalPopup").value(); + QVERIFY(modalPopup); + + QQuickPopup *modelessPopup = window->property("modelessPopup").value(); + QVERIFY(modelessPopup); + + modalPopup->open(); + QCOMPARE(modalPopup->isVisible(), true); + + modelessPopup->open(); + QCOMPARE(modelessPopup->isVisible(), true); + + // click outside the modeless popup on the top, but inside the modal popup below + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(150, 150)); + + QTRY_COMPARE(modelessPopup->isVisible(), false); + QCOMPARE(modalPopup->isVisible(), true); +} + +// QTBUG-56697 +void tst_QQuickPopup::grabber() +{ + QQuickApplicationHelper helper(this, QStringLiteral("grabber.qml")); + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickPopup *menu = window->property("menu").value(); + QVERIFY(menu); + + QQuickPopup *popup = window->property("popup").value(); + QVERIFY(popup); + + QQuickPopup *combo = window->property("combo").value(); + QVERIFY(combo); + + menu->open(); + QCOMPARE(menu->isVisible(), true); + QCOMPARE(popup->isVisible(), false); + QCOMPARE(combo->isVisible(), false); + + // click a menu item to open the popup + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(menu->width() / 2, menu->height() / 2)); + QCOMPARE(menu->isVisible(), false); + QCOMPARE(popup->isVisible(), true); + QCOMPARE(combo->isVisible(), false); + + combo->open(); + QCOMPARE(menu->isVisible(), false); + QCOMPARE(popup->isVisible(), true); + QCOMPARE(combo->isVisible(), true); + + // click outside to close both the combo popup and the parent popup + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() - 1, window->height() - 1)); + QCOMPARE(menu->isVisible(), false); + QCOMPARE(popup->isVisible(), false); + QCOMPARE(combo->isVisible(), false); + + menu->open(); + QCOMPARE(menu->isVisible(), true); + QCOMPARE(popup->isVisible(), false); + QCOMPARE(combo->isVisible(), false); + + // click outside the menu to close it (QTBUG-56697) + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() - 1, window->height() - 1)); + QCOMPARE(menu->isVisible(), false); + QCOMPARE(popup->isVisible(), false); + QCOMPARE(combo->isVisible(), false); +} + +void tst_QQuickPopup::cursorShape() +{ + // Ensure that the mouse cursor has the correct shape when over a popup + // which is itself over an item with a different shape. + QQuickApplicationHelper helper(this, QStringLiteral("cursor.qml")); + QQuickApplicationWindow *window = helper.appWindow; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickPopup *popup = helper.appWindow->property("popup").value(); + QVERIFY(popup); + + popup->open(); + QVERIFY(popup->isVisible()); + + QQuickItem *textField = helper.appWindow->property("textField").value(); + QVERIFY(textField); + + // Move the mouse over the text field. + const QPoint textFieldPos(popup->x() - 10, popup->y() + popup->height() / 2); + QTest::mouseMove(window, textFieldPos); + QCOMPARE(window->cursor().shape(), textField->cursor().shape()); + + // Move the mouse over the popup where it overlaps with the text field. + const QPoint textFieldOverlapPos(popup->x() + 10, popup->y() + popup->height() / 2); + QTest::mouseMove(window, textFieldOverlapPos); + QCOMPARE(window->cursor().shape(), popup->popupItem()->cursor().shape()); + + popup->close(); + QTRY_VERIFY(!popup->isVisible()); +} + +class FriendlyPopup : public QQuickPopup +{ + friend class tst_QQuickPopup; +}; + +void tst_QQuickPopup::componentComplete() +{ + FriendlyPopup cppPopup; + QVERIFY(cppPopup.isComponentComplete()); + + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData("import QtQuick.Controls 2.2; Popup { }", QUrl()); + + FriendlyPopup *qmlPopup = static_cast(component.beginCreate(engine.rootContext())); + QVERIFY(qmlPopup); + QVERIFY(!qmlPopup->isComponentComplete()); + + component.completeCreate(); + QVERIFY(qmlPopup->isComponentComplete()); +} + +void tst_QQuickPopup::closeOnEscapeWithNestedPopups() +{ + // Tests the scenario in the Gallery example, where there are nested popups that should + // close in the correct order when the Escape key is pressed. + QQuickApplicationHelper helper(this, QStringLiteral("closeOnEscapeWithNestedPopups.qml")); + QQuickApplicationWindow *window = helper.appWindow; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + // The stack view should have two items, and it should pop the second when escape is pressed + // and it has focus. + QQuickStackView *stackView = window->findChild("stackView"); + QVERIFY(stackView); + QCOMPARE(stackView->depth(), 2); + + QQuickItem *optionsToolButton = window->findChild("optionsToolButton"); + QVERIFY(optionsToolButton); + + // Click on the options tool button. The settings menu should pop up. + const QPoint optionsToolButtonCenter = optionsToolButton->mapToScene( + QPointF(optionsToolButton->width() / 2, optionsToolButton->height() / 2)).toPoint(); + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, optionsToolButtonCenter); + + QQuickPopup *optionsMenu = window->findChild("optionsMenu"); + QVERIFY(optionsMenu); + QTRY_VERIFY(optionsMenu->isVisible()); + + QQuickItem *settingsMenuItem = window->findChild("settingsMenuItem"); + QVERIFY(settingsMenuItem); + + // Click on the settings menu item. The settings dialog should pop up. + const QPoint settingsMenuItemCenter = settingsMenuItem->mapToScene( + QPointF(settingsMenuItem->width() / 2, settingsMenuItem->height() / 2)).toPoint(); + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, settingsMenuItemCenter); + + QQuickPopup *settingsDialog = window->contentItem()->findChild("settingsDialog"); + QVERIFY(settingsDialog); + QTRY_VERIFY(settingsDialog->isVisible()); + + QQuickComboBox *comboBox = window->contentItem()->findChild("comboBox"); + QVERIFY(comboBox); + + // Click on the combo box button. The combo box popup should pop up. + const QPoint comboBoxCenter = comboBox->mapToScene( + QPointF(comboBox->width() / 2, comboBox->height() / 2)).toPoint(); + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, comboBoxCenter); + QTRY_VERIFY(comboBox->popup()->isVisible()); + + // Close the combo box popup with the escape key. The settings dialog should still be visible. + QTest::keyClick(window, Qt::Key_Escape); + QTRY_VERIFY(!comboBox->popup()->isVisible()); + QVERIFY(settingsDialog->isVisible()); + + // Close the settings dialog with the escape key. + QTest::keyClick(window, Qt::Key_Escape); + QTRY_VERIFY(!settingsDialog->isVisible()); + + // The stack view should still have two items. + QCOMPARE(stackView->depth(), 2); + + // Remove one by pressing the Escape key (the Shortcut should be activated). + QTest::keyClick(window, Qt::Key_Escape); + QCOMPARE(stackView->depth(), 1); +} + +void tst_QQuickPopup::orientation_data() +{ + QTest::addColumn("orientation"); + QTest::addColumn("position"); + + QTest::newRow("Portrait") << Qt::PortraitOrientation << QPointF(330, 165); + QTest::newRow("Landscape") << Qt::LandscapeOrientation << QPointF(165, 270); + QTest::newRow("InvertedPortrait") << Qt::InvertedPortraitOrientation << QPointF(270, 135); + QTest::newRow("InvertedLandscape") << Qt::InvertedLandscapeOrientation << QPointF(135, 330); +} + +void tst_QQuickPopup::orientation() +{ + QFETCH(Qt::ScreenOrientation, orientation); + QFETCH(QPointF, position); + + QQuickApplicationHelper helper(this, "orientation.qml"); + + QQuickWindow *window = helper.window; + window->reportContentOrientationChange(orientation); + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickPopup *popup = window->property("popup").value(); + QVERIFY(popup); + popup->open(); + + QCOMPARE(popup->popupItem()->position(), position); +} + +QTEST_MAIN(tst_QQuickPopup) + +#include "tst_qquickpopup.moc" -- cgit v1.2.3