From 96aec78737322152fb6742a7fa516489b7ce7b50 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 27 Sep 2017 14:36:19 +0200 Subject: Rename tst_Drawer to tst_QQuickDrawer Change-Id: I186b3ed95eda5178f861bc501be481c971641767 Reviewed-by: Mitch Curtis --- tests/auto/auto.pro | 4 +- .../auto/drawer/data/applicationwindow-button.qml | 70 -- tests/auto/drawer/data/applicationwindow-hover.qml | 82 -- tests/auto/drawer/data/applicationwindow-wheel.qml | 80 -- tests/auto/drawer/data/applicationwindow.qml | 65 -- tests/auto/drawer/data/dragOverModalShadow.qml | 87 -- tests/auto/drawer/data/flickable.qml | 75 -- tests/auto/drawer/data/grabber.qml | 73 -- tests/auto/drawer/data/header.qml | 73 -- tests/auto/drawer/data/multiTouch.qml | 82 -- tests/auto/drawer/data/multiple.qml | 95 -- tests/auto/drawer/data/reposition.qml | 76 -- tests/auto/drawer/data/window-button.qml | 71 -- tests/auto/drawer/data/window-hover.qml | 83 -- tests/auto/drawer/data/window-wheel.qml | 81 -- tests/auto/drawer/data/window.qml | 66 -- tests/auto/drawer/drawer.pro | 14 - tests/auto/drawer/tst_drawer.cpp | 1224 -------------------- .../qquickdrawer/data/applicationwindow-button.qml | 70 ++ .../qquickdrawer/data/applicationwindow-hover.qml | 82 ++ .../qquickdrawer/data/applicationwindow-wheel.qml | 80 ++ tests/auto/qquickdrawer/data/applicationwindow.qml | 65 ++ .../auto/qquickdrawer/data/dragOverModalShadow.qml | 87 ++ tests/auto/qquickdrawer/data/flickable.qml | 75 ++ tests/auto/qquickdrawer/data/grabber.qml | 73 ++ tests/auto/qquickdrawer/data/header.qml | 73 ++ tests/auto/qquickdrawer/data/multiTouch.qml | 82 ++ tests/auto/qquickdrawer/data/multiple.qml | 95 ++ tests/auto/qquickdrawer/data/reposition.qml | 76 ++ tests/auto/qquickdrawer/data/window-button.qml | 71 ++ tests/auto/qquickdrawer/data/window-hover.qml | 83 ++ tests/auto/qquickdrawer/data/window-wheel.qml | 81 ++ tests/auto/qquickdrawer/data/window.qml | 66 ++ tests/auto/qquickdrawer/qquickdrawer.pro | 14 + tests/auto/qquickdrawer/tst_qquickdrawer.cpp | 1224 ++++++++++++++++++++ 35 files changed, 2399 insertions(+), 2399 deletions(-) delete mode 100644 tests/auto/drawer/data/applicationwindow-button.qml delete mode 100644 tests/auto/drawer/data/applicationwindow-hover.qml delete mode 100644 tests/auto/drawer/data/applicationwindow-wheel.qml delete mode 100644 tests/auto/drawer/data/applicationwindow.qml delete mode 100644 tests/auto/drawer/data/dragOverModalShadow.qml delete mode 100644 tests/auto/drawer/data/flickable.qml delete mode 100644 tests/auto/drawer/data/grabber.qml delete mode 100644 tests/auto/drawer/data/header.qml delete mode 100644 tests/auto/drawer/data/multiTouch.qml delete mode 100644 tests/auto/drawer/data/multiple.qml delete mode 100644 tests/auto/drawer/data/reposition.qml delete mode 100644 tests/auto/drawer/data/window-button.qml delete mode 100644 tests/auto/drawer/data/window-hover.qml delete mode 100644 tests/auto/drawer/data/window-wheel.qml delete mode 100644 tests/auto/drawer/data/window.qml delete mode 100644 tests/auto/drawer/drawer.pro delete mode 100644 tests/auto/drawer/tst_drawer.cpp create mode 100644 tests/auto/qquickdrawer/data/applicationwindow-button.qml create mode 100644 tests/auto/qquickdrawer/data/applicationwindow-hover.qml create mode 100644 tests/auto/qquickdrawer/data/applicationwindow-wheel.qml create mode 100644 tests/auto/qquickdrawer/data/applicationwindow.qml create mode 100644 tests/auto/qquickdrawer/data/dragOverModalShadow.qml create mode 100644 tests/auto/qquickdrawer/data/flickable.qml create mode 100644 tests/auto/qquickdrawer/data/grabber.qml create mode 100644 tests/auto/qquickdrawer/data/header.qml create mode 100644 tests/auto/qquickdrawer/data/multiTouch.qml create mode 100644 tests/auto/qquickdrawer/data/multiple.qml create mode 100644 tests/auto/qquickdrawer/data/reposition.qml create mode 100644 tests/auto/qquickdrawer/data/window-button.qml create mode 100644 tests/auto/qquickdrawer/data/window-hover.qml create mode 100644 tests/auto/qquickdrawer/data/window-wheel.qml create mode 100644 tests/auto/qquickdrawer/data/window.qml create mode 100644 tests/auto/qquickdrawer/qquickdrawer.pro create mode 100644 tests/auto/qquickdrawer/tst_qquickdrawer.cpp (limited to 'tests/auto') diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 048eabed..354d7c81 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -5,13 +5,13 @@ SUBDIRS += \ calendar \ controls \ cursor \ - drawer \ focus \ font \ menu \ platform \ popup \ pressandhold \ + qquickdrawer \ qquickmaterialstyle \ qquickmaterialstyleconf \ qquickstyle \ @@ -24,6 +24,6 @@ SUBDIRS += \ # QTBUG-60268 boot2qt: SUBDIRS -= applicationwindow calendar controls cursor \ - drawer focus font menu platform popup qquickmaterialstyle \ + qquickdrawer focus font menu platform popup qquickmaterialstyle \ qquickmaterialstyleconf qquickuniversalstyle \ qquickuniversalstyleconf snippets diff --git a/tests/auto/drawer/data/applicationwindow-button.qml b/tests/auto/drawer/data/applicationwindow-button.qml deleted file mode 100644 index 9641351e..00000000 --- a/tests/auto/drawer/data/applicationwindow-button.qml +++ /dev/null @@ -1,70 +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 drawer: drawer - - Drawer { - id: drawer - width: 200 - height: 200 - - Button { - text: "Button" - anchors.fill: parent - } - } -} diff --git a/tests/auto/drawer/data/applicationwindow-hover.qml b/tests/auto/drawer/data/applicationwindow-hover.qml deleted file mode 100644 index 560efec3..00000000 --- a/tests/auto/drawer/data/applicationwindow-hover.qml +++ /dev/null @@ -1,82 +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 drawer: drawer - property alias backgroundButton: backgroundButton - property alias drawerButton: drawerButton - - Button { - id: backgroundButton - text: "Background" - anchors.fill: parent - } - - Drawer { - id: drawer - width: 100 - height: 400 - topPadding: 2 - leftPadding: 2 - rightPadding: 2 - bottomPadding: 2 - - contentItem: Button { - id: drawerButton - text: "Drawer" - } - } -} diff --git a/tests/auto/drawer/data/applicationwindow-wheel.qml b/tests/auto/drawer/data/applicationwindow-wheel.qml deleted file mode 100644 index 541f08aa..00000000 --- a/tests/auto/drawer/data/applicationwindow-wheel.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 { - id: window - width: 400 - height: 400 - - property alias drawer: drawer - property alias drawerSlider: drawerSlider - property alias contentSlider: contentSlider - - Slider { - id: contentSlider - anchors.fill: parent - wheelEnabled: true - } - - Drawer { - id: drawer - edge: Qt.RightEdge - width: window.width * 0.8 - height: window.height - clip: true - contentItem: Slider { - id: drawerSlider - wheelEnabled: true - } - } -} diff --git a/tests/auto/drawer/data/applicationwindow.qml b/tests/auto/drawer/data/applicationwindow.qml deleted file mode 100644 index 673c4d4c..00000000 --- a/tests/auto/drawer/data/applicationwindow.qml +++ /dev/null @@ -1,65 +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 drawer: drawer - - Drawer { - id: drawer - width: 200 - height: 200 - } -} diff --git a/tests/auto/drawer/data/dragOverModalShadow.qml b/tests/auto/drawer/data/dragOverModalShadow.qml deleted file mode 100644 index 66eb2f4b..00000000 --- a/tests/auto/drawer/data/dragOverModalShadow.qml +++ /dev/null @@ -1,87 +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 drawer: drawer - property alias popup: popup - - Drawer { - id: drawer - width: 200 - height: parent.height - dragMargin: parent.width - } - - Popup { - id: popup - modal: true - x: (parent.width - width) / 2 - y: (parent.height - height) / 2 - width: parent.width / 2 - height: parent.height / 2 - - Rectangle { - objectName: "shadow" - parent: popup.background - anchors.fill: parent - anchors.margins: -20 - - z: -1 - opacity: 0.5 - color: "silver" - } - } -} diff --git a/tests/auto/drawer/data/flickable.qml b/tests/auto/drawer/data/flickable.qml deleted file mode 100644 index 62256afd..00000000 --- a/tests/auto/drawer/data/flickable.qml +++ /dev/null @@ -1,75 +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 drawer: drawer - property alias flickable: flickable - - Drawer { - id: drawer - width: 300 - height: 400 - - contentItem: ListView { - id: flickable - model: 100 - delegate: ItemDelegate { - width: parent.width - text: index - } - } - } -} diff --git a/tests/auto/drawer/data/grabber.qml b/tests/auto/drawer/data/grabber.qml deleted file mode 100644 index e6ebe2da..00000000 --- a/tests/auto/drawer/data/grabber.qml +++ /dev/null @@ -1,73 +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 drawer: drawer - property alias popup: popup - - Drawer { - id: drawer - width: 200 - height: parent.height - } - - Popup { - id: popup - x: 200 - width: 200 - height: parent.height - } -} diff --git a/tests/auto/drawer/data/header.qml b/tests/auto/drawer/data/header.qml deleted file mode 100644 index de3af106..00000000 --- a/tests/auto/drawer/data/header.qml +++ /dev/null @@ -1,73 +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 drawer: drawer - property alias button: button - - header: ToolBar { - ToolButton { - id: button - text: "=" - } - } - - Drawer { - id: drawer - width: 200 - height: parent.height - } -} diff --git a/tests/auto/drawer/data/multiTouch.qml b/tests/auto/drawer/data/multiTouch.qml deleted file mode 100644 index 0faf3c61..00000000 --- a/tests/auto/drawer/data/multiTouch.qml +++ /dev/null @@ -1,82 +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 { - id: window - width: 400 - height: 400 - - property alias drawer: drawer - property alias popup: popup - property alias button: button - - Drawer { - id: drawer - width: window.width / 2 - height: parent.height - dragMargin: parent.width - } - - Popup { - id: popup - x: 10; y: 10 - width: window.width - 10 - height: window.height - 10 - - Button { - id: button - text: "Button" - anchors.fill: parent - } - } -} diff --git a/tests/auto/drawer/data/multiple.qml b/tests/auto/drawer/data/multiple.qml deleted file mode 100644 index 4e622fca..00000000 --- a/tests/auto/drawer/data/multiple.qml +++ /dev/null @@ -1,95 +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 leftDrawer: leftDrawer - property alias leftButton: leftButton - - property alias rightDrawer: rightDrawer - property alias rightButton: rightButton - - property alias contentButton: contentButton - - Drawer { - id: leftDrawer - width: 300 - height: 400 - z: 1 - - contentItem: Button { - id: leftButton - text: "Left" - } - } - - Button { - id: contentButton - text: "Content" - anchors.fill: parent - } - - Drawer { - id: rightDrawer - width: 300 - height: 400 - edge: Qt.RightEdge - - contentItem: Button { - id: rightButton - text: "Right" - } - } -} diff --git a/tests/auto/drawer/data/reposition.qml b/tests/auto/drawer/data/reposition.qml deleted file mode 100644 index 485da85c..00000000 --- a/tests/auto/drawer/data/reposition.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.Controls 2.0 - -ApplicationWindow { - id: window - width: 400 - height: 400 - - property alias drawer: drawer - property alias drawer2: drawer2 - - header: Item { implicitHeight: 50 } - footer: Item { implicitHeight: 50 } - - Drawer { - id: drawer - width: parent.width / 2 - implicitHeight: parent.height - } - - Drawer { - id: drawer2 - width: Math.min(window.width, window.height) / 3 * 2 - height: window.height - } -} diff --git a/tests/auto/drawer/data/window-button.qml b/tests/auto/drawer/data/window-button.qml deleted file mode 100644 index 1b8ac7d5..00000000 --- a/tests/auto/drawer/data/window-button.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.Window 2.2 -import QtQuick.Controls 2.0 - -Window { - width: 400 - height: 400 - - property alias drawer: drawer - - Drawer { - id: drawer - width: 200 - height: 200 - - Button { - text: "Button" - anchors.fill: parent - } - } -} diff --git a/tests/auto/drawer/data/window-hover.qml b/tests/auto/drawer/data/window-hover.qml deleted file mode 100644 index b35bcd99..00000000 --- a/tests/auto/drawer/data/window-hover.qml +++ /dev/null @@ -1,83 +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 drawer: drawer - property alias backgroundButton: backgroundButton - property alias drawerButton: drawerButton - - Button { - id: backgroundButton - text: "Background" - anchors.fill: parent - } - - Drawer { - id: drawer - width: 100 - height: 400 - topPadding: 2 - leftPadding: 2 - rightPadding: 2 - bottomPadding: 2 - - contentItem: Button { - id: drawerButton - text: "Drawer" - } - } -} diff --git a/tests/auto/drawer/data/window-wheel.qml b/tests/auto/drawer/data/window-wheel.qml deleted file mode 100644 index 988a541e..00000000 --- a/tests/auto/drawer/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 drawer: drawer - property alias drawerSlider: drawerSlider - property alias contentSlider: contentSlider - - Slider { - id: contentSlider - anchors.fill: parent - wheelEnabled: true - } - - Drawer { - id: drawer - edge: Qt.RightEdge - width: window.width * 0.8 - height: window.height - clip: true - contentItem: Slider { - id: drawerSlider - wheelEnabled: true - } - } -} diff --git a/tests/auto/drawer/data/window.qml b/tests/auto/drawer/data/window.qml deleted file mode 100644 index 88376ac4..00000000 --- a/tests/auto/drawer/data/window.qml +++ /dev/null @@ -1,66 +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 drawer: drawer - - Drawer { - id: drawer - width: 200 - height: 200 - } -} diff --git a/tests/auto/drawer/drawer.pro b/tests/auto/drawer/drawer.pro deleted file mode 100644 index 7dfc3638..00000000 --- a/tests/auto/drawer/drawer.pro +++ /dev/null @@ -1,14 +0,0 @@ -CONFIG += testcase -TARGET = tst_drawer -SOURCES += tst_drawer.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/drawer/tst_drawer.cpp b/tests/auto/drawer/tst_drawer.cpp deleted file mode 100644 index 0bfb3fc9..00000000 --- a/tests/auto/drawer/tst_drawer.cpp +++ /dev/null @@ -1,1224 +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 -#include -#include -#include -#include - -using namespace QQuickVisualTestUtil; - -class tst_Drawer : public QQmlDataTest -{ - Q_OBJECT - -private slots: - void initTestCase(); - - void visible_data(); - void visible(); - - void state(); - - void position_data(); - void position(); - - void dragMargin_data(); - void dragMargin(); - - void reposition(); - void header(); - - void hover_data(); - void hover(); - - void wheel_data(); - void wheel(); - - void multiple(); - - void touch_data(); - void touch(); - - void multiTouch(); - - void grabber(); - - void interactive_data(); - void interactive(); - - void flickable_data(); - void flickable(); - - void dragOverModalShadow_data(); - void dragOverModalShadow(); - - void nonModal_data(); - void nonModal(); - -private: - struct TouchDeviceDeleter - { - static inline void cleanup(QTouchDevice *device) - { - QWindowSystemInterface::unregisterTouchDevice(device); - delete device; - } - }; - - QScopedPointer touchDevice; -}; - - -void tst_Drawer::initTestCase() -{ - QQmlDataTest::initTestCase(); - qputenv("QML_NO_TOUCH_COMPRESSION", "1"); - - touchDevice.reset(new QTouchDevice); - touchDevice->setType(QTouchDevice::TouchScreen); - QWindowSystemInterface::registerTouchDevice(touchDevice.data()); -} - -void tst_Drawer::visible_data() -{ - QTest::addColumn("source"); - QTest::newRow("Window") << "window.qml"; - QTest::newRow("ApplicationWindow") << "applicationwindow.qml"; -} - -void tst_Drawer::visible() -{ - QFETCH(QString, source); - QQuickApplicationHelper helper(this, source); - - QQuickWindow *window = helper.window; - window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - - QQuickDrawer *drawer = window->property("drawer").value(); - QVERIFY(drawer); - QQuickItem *popupItem = drawer->popupItem(); - - QCOMPARE(drawer->isVisible(), false); - QCOMPARE(drawer->position(), qreal(0.0)); - - QQuickOverlay *overlay = QQuickOverlay::overlay(window); - QVERIFY(overlay); - QVERIFY(!overlay->childItems().contains(popupItem)); - - drawer->open(); - QVERIFY(drawer->isVisible()); - QVERIFY(overlay->childItems().contains(popupItem)); - QTRY_COMPARE(drawer->position(), qreal(1.0)); - - drawer->close(); - QTRY_VERIFY(!drawer->isVisible()); - QTRY_COMPARE(drawer->position(), qreal(0.0)); - QVERIFY(!overlay->childItems().contains(popupItem)); - - drawer->setVisible(true); - QVERIFY(drawer->isVisible()); - QVERIFY(overlay->childItems().contains(popupItem)); - QTRY_COMPARE(drawer->position(), qreal(1.0)); - - drawer->setVisible(false); - QTRY_VERIFY(!drawer->isVisible()); - QTRY_COMPARE(drawer->position(), qreal(0.0)); - QTRY_VERIFY(!overlay->childItems().contains(popupItem)); -} - -void tst_Drawer::state() -{ - QQuickApplicationHelper helper(this, "applicationwindow.qml"); - - QQuickWindow *window = helper.window; - window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - - QQuickDrawer *drawer = window->property("drawer").value(); - QVERIFY(drawer); - - QCOMPARE(drawer->isVisible(), false); - - QSignalSpy visibleChangedSpy(drawer, SIGNAL(visibleChanged())); - QSignalSpy aboutToShowSpy(drawer, SIGNAL(aboutToShow())); - QSignalSpy aboutToHideSpy(drawer, SIGNAL(aboutToHide())); - QSignalSpy openedSpy(drawer, SIGNAL(opened())); - QSignalSpy closedSpy(drawer, SIGNAL(closed())); - - QVERIFY(visibleChangedSpy.isValid()); - QVERIFY(aboutToShowSpy.isValid()); - QVERIFY(aboutToHideSpy.isValid()); - QVERIFY(openedSpy.isValid()); - QVERIFY(closedSpy.isValid()); - - int visibleChangedCount = 0; - int aboutToShowCount = 0; - int aboutToHideCount = 0; - int openedCount = 0; - int closedCount = 0; - - // open programmatically... - drawer->open(); - QCOMPARE(visibleChangedSpy.count(), ++visibleChangedCount); - QCOMPARE(aboutToShowSpy.count(), ++aboutToShowCount); - QCOMPARE(aboutToHideSpy.count(), aboutToHideCount); - QCOMPARE(openedSpy.count(), openedCount); - QCOMPARE(closedSpy.count(), closedCount); - - // ...and wait until fully open - QVERIFY(openedSpy.wait()); - QCOMPARE(visibleChangedSpy.count(), visibleChangedCount); - QCOMPARE(aboutToShowSpy.count(), aboutToShowCount); - QCOMPARE(aboutToHideSpy.count(), aboutToHideCount); - QCOMPARE(openedSpy.count(), ++openedCount); - QCOMPARE(closedSpy.count(), closedCount); - - // close programmatically... - drawer->close(); - QCOMPARE(visibleChangedSpy.count(), visibleChangedCount); - QCOMPARE(aboutToShowSpy.count(), aboutToShowCount); - QCOMPARE(aboutToHideSpy.count(), ++aboutToHideCount); - QCOMPARE(openedSpy.count(), openedCount); - QCOMPARE(closedSpy.count(), closedCount); - - // ...and wait until fully closed - QVERIFY(closedSpy.wait()); - QCOMPARE(visibleChangedSpy.count(), ++visibleChangedCount); - QCOMPARE(aboutToShowSpy.count(), aboutToShowCount); - QCOMPARE(aboutToHideSpy.count(), aboutToHideCount); - QCOMPARE(openedSpy.count(), openedCount); - QCOMPARE(closedSpy.count(), ++closedCount); - - // open interactively... - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(0, drawer->height() / 2)); - QTest::mouseMove(window, QPoint(drawer->width() * 0.2, drawer->height() / 2), 16); - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(drawer->width() * 0.8, drawer->height() / 2), 16); - QCOMPARE(visibleChangedSpy.count(), ++visibleChangedCount); - QCOMPARE(aboutToShowSpy.count(), ++aboutToShowCount); - QCOMPARE(aboutToHideSpy.count(), aboutToHideCount); - QCOMPARE(openedSpy.count(), openedCount); - QCOMPARE(closedSpy.count(), closedCount); - - // ...and wait until fully open - QVERIFY(openedSpy.wait()); - QCOMPARE(visibleChangedSpy.count(), visibleChangedCount); - QCOMPARE(aboutToShowSpy.count(), aboutToShowCount); - QCOMPARE(aboutToHideSpy.count(), aboutToHideCount); - QCOMPARE(openedSpy.count(), ++openedCount); - QCOMPARE(closedSpy.count(), closedCount); - - // close interactively... - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(drawer->width(), drawer->height() / 2)); - QTest::mouseMove(window, QPoint(drawer->width() * 0.8, drawer->height() / 2), 16); - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(drawer->width() * 0.2, drawer->height() / 2), 16); - QCOMPARE(visibleChangedSpy.count(), visibleChangedCount); - QCOMPARE(aboutToShowSpy.count(), aboutToShowCount); - QCOMPARE(aboutToHideSpy.count(), ++aboutToHideCount); - QCOMPARE(openedSpy.count(), openedCount); - QCOMPARE(closedSpy.count(), closedCount); - - // ...and wait until fully closed - QVERIFY(closedSpy.wait()); - QCOMPARE(visibleChangedSpy.count(), ++visibleChangedCount); - QCOMPARE(aboutToShowSpy.count(), aboutToShowCount); - QCOMPARE(aboutToHideSpy.count(), aboutToHideCount); - QCOMPARE(openedSpy.count(), openedCount); - QCOMPARE(closedSpy.count(), ++closedCount); -} - -void tst_Drawer::position_data() -{ - QTest::addColumn("edge"); - QTest::addColumn("press"); - QTest::addColumn("from"); - QTest::addColumn("to"); - QTest::addColumn("position"); - - QTest::newRow("top") << Qt::TopEdge << QPoint(100, 0) << QPoint(100, 50) << QPoint(100, 150) << qreal(0.5); - QTest::newRow("left") << Qt::LeftEdge << QPoint(0, 100) << QPoint(50, 100) << QPoint(150, 100) << qreal(0.5); - QTest::newRow("right") << Qt::RightEdge << QPoint(399, 100) << QPoint(350, 100) << QPoint(250, 100) << qreal(0.5); - QTest::newRow("bottom") << Qt::BottomEdge << QPoint(100, 399) << QPoint(100, 350) << QPoint(150, 250) << qreal(0.5); -} - -void tst_Drawer::position() -{ - QFETCH(Qt::Edge, edge); - QFETCH(QPoint, press); - QFETCH(QPoint, from); - QFETCH(QPoint, to); - QFETCH(qreal, position); - - QQuickApplicationHelper helper(this, QStringLiteral("applicationwindow.qml")); - - QQuickApplicationWindow *window = helper.appWindow; - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickDrawer *drawer = helper.appWindow->property("drawer").value(); - QVERIFY(drawer); - drawer->setEdge(edge); - - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, press); - QTest::mouseMove(window, from); - QTest::mouseMove(window, to); - QCOMPARE(drawer->position(), position); - - // moved half-way open at almost infinite speed => snap to open - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, to); - QTRY_COMPARE(drawer->position(), 1.0); -} - -void tst_Drawer::dragMargin_data() -{ - QTest::addColumn("edge"); - QTest::addColumn("dragMargin"); - QTest::addColumn("dragFromLeft"); - QTest::addColumn("dragFromRight"); - - QTest::newRow("left:0") << Qt::LeftEdge << qreal(0) << qreal(0) << qreal(0); - QTest::newRow("left:-1") << Qt::LeftEdge << qreal(-1) << qreal(0) << qreal(0); - QTest::newRow("left:startDragDistance") << Qt::LeftEdge << qreal(QGuiApplication::styleHints()->startDragDistance()) << qreal(0.45) << qreal(0); - QTest::newRow("left:startDragDistance*2") << Qt::LeftEdge << qreal(QGuiApplication::styleHints()->startDragDistance() * 2) << qreal(0.45) << qreal(0); - - QTest::newRow("right:0") << Qt::RightEdge << qreal(0) << qreal(0) << qreal(0); - QTest::newRow("right:-1") << Qt::RightEdge << qreal(-1) << qreal(0) << qreal(0); - QTest::newRow("right:startDragDistance") << Qt::RightEdge << qreal(QGuiApplication::styleHints()->startDragDistance()) << qreal(0) << qreal(0.75); - QTest::newRow("right:startDragDistance*2") << Qt::RightEdge << qreal(QGuiApplication::styleHints()->startDragDistance() * 2) << qreal(0) << qreal(0.75); -} - -void tst_Drawer::dragMargin() -{ - QFETCH(Qt::Edge, edge); - QFETCH(qreal, dragMargin); - QFETCH(qreal, dragFromLeft); - QFETCH(qreal, dragFromRight); - - QQuickApplicationHelper helper(this, QStringLiteral("applicationwindow.qml")); - - QQuickApplicationWindow *window = helper.appWindow; - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickDrawer *drawer = helper.appWindow->property("drawer").value(); - QVERIFY(drawer); - drawer->setEdge(edge); - drawer->setDragMargin(dragMargin); - - const int startDragDistance = qMax(20, QGuiApplication::styleHints()->startDragDistance() + 5) + 1; - - // drag from the left - int leftX = qMax(0, dragMargin); - int leftDistance = startDragDistance + drawer->width() * 0.45; - QVERIFY(leftDistance > QGuiApplication::styleHints()->startDragDistance()); - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(leftX, drawer->height() / 2)); - QTest::mouseMove(window, QPoint(leftX + startDragDistance, drawer->height() / 2)); - QTest::mouseMove(window, QPoint(leftX + leftDistance, drawer->height() / 2)); - QCOMPARE(drawer->position(), dragFromLeft); - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(leftX + leftDistance, drawer->height() / 2)); - - drawer->close(); - QTRY_COMPARE(drawer->position(), qreal(0.0)); - - // drag from the right - int rightX = qMin(window->width() - 1, window->width() - dragMargin); - int rightDistance = startDragDistance + drawer->width() * 0.75; - QVERIFY(rightDistance > QGuiApplication::styleHints()->startDragDistance()); - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(rightX, drawer->height() / 2)); - QTest::mouseMove(window, QPoint(rightX - startDragDistance, drawer->height() / 2)); - QTest::mouseMove(window, QPoint(rightX - rightDistance, drawer->height() / 2)); - QCOMPARE(drawer->position(), dragFromRight); - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(rightX - rightDistance, drawer->height() / 2)); -} - -static QRectF geometry(const QQuickItem *item) -{ - return QRectF(item->x(), item->y(), item->width(), item->height()); -} - -void tst_Drawer::reposition() -{ - QQuickApplicationHelper helper(this, QStringLiteral("reposition.qml")); - - QQuickApplicationWindow *window = helper.appWindow; - window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - - QQuickDrawer *drawer = window->property("drawer").value(); - QVERIFY(drawer); - QQuickItem *popupItem = drawer->popupItem(); - QVERIFY(popupItem); - - drawer->open(); - QQuickItem *dimmer = QQuickPopupPrivate::get(drawer)->dimmer; - QVERIFY(dimmer); - - QCOMPARE(geometry(dimmer), QRectF(0, 0, window->width(), window->height())); - QTRY_COMPARE(geometry(popupItem), QRectF(0, 0, window->width() / 2, window->height())); - - drawer->setY(100); - QCOMPARE(geometry(dimmer), QRectF(0, 100, window->width(), window->height() - 100)); - QCOMPARE(geometry(popupItem), QRectF(0, 100, window->width() / 2, window->height() - 100)); - - drawer->setHeight(window->height()); - QCOMPARE(geometry(dimmer), QRectF(0, 100, window->width(), window->height())); - QCOMPARE(geometry(popupItem), QRectF(0, 100, window->width() / 2, window->height())); - - drawer->resetHeight(); - QCOMPARE(geometry(dimmer), QRectF(0, 100, window->width(), window->height() - 100)); - QCOMPARE(geometry(popupItem), QRectF(0, 100, window->width() / 2, window->height() - 100)); - - drawer->setParentItem(window->contentItem()); - QCOMPARE(geometry(dimmer), QRectF(0, 150, window->width(), window->height() - 150)); - QCOMPARE(geometry(popupItem), QRectF(0, 150, window->width() / 2, window->height() - 150)); - - drawer->setEdge(Qt::RightEdge); - QCOMPARE(geometry(dimmer), QRectF(0, 150, window->width(), window->height() - 150)); - QTRY_COMPARE(geometry(popupItem), QRectF(window->width() - drawer->width(), 150, window->width() / 2, window->height() - 150)); - - window->setWidth(window->width() + 100); - QTRY_COMPARE(geometry(dimmer), QRectF(0, 150, window->width(), window->height() - 150)); - QTRY_COMPARE(geometry(popupItem), QRectF(window->width() - drawer->width(), 150, window->width() / 2, window->height() - 150)); - - drawer->close(); - QTRY_COMPARE(geometry(popupItem), QRectF(window->width(), 150, window->width() / 2, window->height() - 150)); - - QQuickDrawer *drawer2 = window->property("drawer2").value(); - QVERIFY(drawer2); - QQuickItem *popupItem2 = drawer2->popupItem(); - QVERIFY(popupItem2); - - drawer2->open(); - QVERIFY(popupItem2->isVisible()); - QCOMPARE(popupItem2->x(), -drawer2->width()); - QTRY_COMPARE(popupItem2->x(), 0.0); -} - -void tst_Drawer::header() -{ - QQuickApplicationHelper helper(this, QStringLiteral("header.qml")); - - QQuickApplicationWindow *window = helper.appWindow; - window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - - QQuickItem *content = window->contentItem(); - QVERIFY(content); - - QQuickOverlay *overlay = QQuickOverlay::overlay(window); - QVERIFY(overlay); - - QQuickDrawer *drawer = window->property("drawer").value(); - QVERIFY(drawer); - QQuickItem *popupItem = drawer->popupItem(); - - QQuickButton *button = window->property("button").value(); - QVERIFY(button); - - drawer->open(); - QVERIFY(drawer->isVisible()); - - QCOMPARE(drawer->parentItem(), overlay); - QCOMPARE(drawer->height(), overlay->height()); - QCOMPARE(popupItem->height(), overlay->height()); - - drawer->setParentItem(content); - QCOMPARE(drawer->parentItem(), content); - QCOMPARE(drawer->height(), content->height()); - QCOMPARE(popupItem->height(), content->height()); - - // must be possible to interact with the header when the drawer is below the header - QSignalSpy clickSpy(button, SIGNAL(clicked())); - QVERIFY(clickSpy.isValid()); - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(button->x() + button->width() / 2, button->y() + button->height() / 2)); - QCOMPARE(clickSpy.count(), 1); -} - -void tst_Drawer::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_Drawer::hover() -{ - QFETCH(QString, source); - QFETCH(bool, modal); - - QQuickApplicationHelper helper(this, source); - QQuickWindow *window = helper.window; - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickDrawer *drawer = window->property("drawer").value(); - QVERIFY(drawer); - drawer->setModal(modal); - - QQuickControl *drawerItem = qobject_cast(drawer->popupItem()); - QVERIFY(drawerItem); - QVERIFY(drawerItem->isHoverEnabled()); - - QQuickButton *backgroundButton = window->property("backgroundButton").value(); - QVERIFY(backgroundButton); - backgroundButton->setHoverEnabled(true); - - QQuickButton *drawerButton = window->property("drawerButton").value(); - QVERIFY(drawerButton); - drawerButton->setHoverEnabled(true); - - QSignalSpy openedSpy(drawer, SIGNAL(opened())); - QVERIFY(openedSpy.isValid()); - drawer->open(); - QVERIFY(openedSpy.count() == 1 || openedSpy.wait()); - - // hover the background button outside the drawer - QTest::mouseMove(window, QPoint(window->width() - 1, window->height() - 1)); - QCOMPARE(backgroundButton->isHovered(), !modal); - QVERIFY(!drawerButton->isHovered()); - QVERIFY(!drawerItem->isHovered()); - - // hover the drawer background - QTest::mouseMove(window, QPoint(1, 1)); - QVERIFY(!backgroundButton->isHovered()); - QVERIFY(!drawerButton->isHovered()); - QVERIFY(drawerItem->isHovered()); - - // hover the button in a drawer - QTest::mouseMove(window, QPoint(2, 2)); - QVERIFY(!backgroundButton->isHovered()); - QVERIFY(drawerButton->isHovered()); - QVERIFY(drawerItem->isHovered()); - - QSignalSpy closedSpy(drawer, SIGNAL(closed())); - QVERIFY(closedSpy.isValid()); - drawer->close(); - QVERIFY(closedSpy.count() == 1 || closedSpy.wait()); - - // hover the background button after closing the drawer - QTest::mouseMove(window, QPoint(window->width() / 2, window->height() / 2)); - QVERIFY(backgroundButton->isHovered()); - QVERIFY(!drawerButton->isHovered()); - QVERIFY(!drawerItem->isHovered()); -} - -void tst_Drawer::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_Drawer::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); - - QQuickDrawer *drawer = window->property("drawer").value(); - QVERIFY(drawer && drawer->contentItem()); - drawer->setModal(modal); - - QQuickSlider *drawerSlider = window->property("drawerSlider").value(); - QVERIFY(drawerSlider); - - { - // wheel over the content - qreal oldContentValue = contentSlider->value(); - qreal oldDrawerValue = drawerSlider->value(); - - QVERIFY(sendWheelEvent(contentSlider, QPoint(contentSlider->width() / 2, contentSlider->height() / 2), 15)); - - QVERIFY(!qFuzzyCompare(contentSlider->value(), oldContentValue)); // must have moved - QVERIFY(qFuzzyCompare(drawerSlider->value(), oldDrawerValue)); // must not have moved - } - - QSignalSpy openedSpy(drawer, SIGNAL(opened())); - QVERIFY(openedSpy.isValid()); - drawer->open(); - QVERIFY(openedSpy.count() == 1 || openedSpy.wait()); - - { - // wheel over the drawer content - qreal oldContentValue = contentSlider->value(); - qreal oldDrawerValue = drawerSlider->value(); - - QVERIFY(sendWheelEvent(drawerSlider, QPoint(drawerSlider->width() / 2, drawerSlider->height() / 2), 15)); - - QVERIFY(qFuzzyCompare(contentSlider->value(), oldContentValue)); // must not have moved - QVERIFY(!qFuzzyCompare(drawerSlider->value(), oldDrawerValue)); // must have moved - } - - { - // wheel over the overlay - qreal oldContentValue = contentSlider->value(); - qreal oldDrawerValue = drawerSlider->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(drawerSlider->value(), oldDrawerValue)); // must not have moved - } -} - -void tst_Drawer::multiple() -{ - QQuickApplicationHelper helper(this, QStringLiteral("multiple.qml")); - QQuickWindow *window = helper.window; - window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - - QQuickDrawer *leftDrawer = window->property("leftDrawer").value(); - QVERIFY(leftDrawer); - QQuickButton *leftButton = window->property("leftButton").value(); - QVERIFY(leftButton); - QSignalSpy leftClickSpy(leftButton, SIGNAL(clicked())); - QVERIFY(leftClickSpy.isValid()); - - QQuickDrawer *rightDrawer = window->property("rightDrawer").value(); - QVERIFY(rightDrawer); - QQuickButton *rightButton = window->property("rightButton").value(); - QVERIFY(rightButton); - QSignalSpy rightClickSpy(rightButton, SIGNAL(clicked())); - QVERIFY(rightClickSpy.isValid()); - - QQuickButton *contentButton = window->property("contentButton").value(); - QVERIFY(contentButton); - QSignalSpy contentClickSpy(contentButton, SIGNAL(clicked())); - QVERIFY(contentClickSpy.isValid()); - - // no drawers open, click the content - QTest::mouseClick(window, Qt::LeftButton); - QCOMPARE(contentClickSpy.count(), 1); - QCOMPARE(leftClickSpy.count(), 0); - QCOMPARE(rightClickSpy.count(), 0); - - // drag the left drawer open - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(0, window->height() / 2)); - QTest::mouseMove(window, QPoint(leftDrawer->width() / 4, window->height() / 2)); - QTest::mouseMove(window, QPoint(leftDrawer->width() / 4 * 3, window->height() / 2)); - QCOMPARE(leftDrawer->position(), 0.5); - QCOMPARE(rightDrawer->position(), 0.0); - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(leftDrawer->width() / 2, window->height() / 2)); - QTRY_COMPARE(leftDrawer->position(), 1.0); - QCOMPARE(rightDrawer->position(), 0.0); - - // cannot drag the right drawer while the left drawer is open - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() - 1, window->height() / 2)); - QTest::mouseMove(window, QPoint(window->width() - leftDrawer->width() / 2, window->height() / 2)); - QCOMPARE(leftDrawer->position(), 1.0); - QCOMPARE(rightDrawer->position(), 0.0); - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() - leftDrawer->width() / 2, window->height() / 2)); - QCOMPARE(rightDrawer->position(), 0.0); - QCOMPARE(leftDrawer->position(), 1.0); - - // open the right drawer below the left drawer - rightDrawer->open(); - QTRY_COMPARE(rightDrawer->position(), 1.0); - - // click the left drawer's button - QTest::mouseClick(window, Qt::LeftButton); - QCOMPARE(contentClickSpy.count(), 1); - QCOMPARE(leftClickSpy.count(), 1); - QCOMPARE(rightClickSpy.count(), 0); - - // click the left drawer's background (button disabled, don't leak through to the right drawer below) - leftButton->setEnabled(false); - QTest::mouseClick(window, Qt::LeftButton); - QCOMPARE(contentClickSpy.count(), 1); - QCOMPARE(leftClickSpy.count(), 1); - QCOMPARE(rightClickSpy.count(), 0); - leftButton->setEnabled(true); - - // click the overlay of the left drawer (don't leak through to right drawer below) - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() - (window->width() - leftDrawer->width()) / 2, window->height() / 2)); - QCOMPARE(contentClickSpy.count(), 1); - QCOMPARE(leftClickSpy.count(), 1); - QCOMPARE(rightClickSpy.count(), 0); - QTRY_VERIFY(!leftDrawer->isVisible()); - - // click the right drawer's button - QTest::mouseClick(window, Qt::LeftButton); - QCOMPARE(contentClickSpy.count(), 1); - QCOMPARE(leftClickSpy.count(), 1); - QCOMPARE(rightClickSpy.count(), 1); - - // cannot drag the left drawer while the right drawer is open - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(0, window->height() / 2)); - QTest::mouseMove(window, QPoint(leftDrawer->width() / 2, window->height() / 2)); - QCOMPARE(leftDrawer->position(), 0.0); - QCOMPARE(rightDrawer->position(), 1.0); - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(leftDrawer->width() / 2, window->height() / 2)); - QCOMPARE(leftDrawer->position(), 0.0); - QCOMPARE(rightDrawer->position(), 1.0); - - // click the right drawer's background (button disabled, don't leak through to the content below) - rightButton->setEnabled(false); - QTest::mouseClick(window, Qt::LeftButton); - QCOMPARE(contentClickSpy.count(), 1); - QCOMPARE(leftClickSpy.count(), 1); - QCOMPARE(rightClickSpy.count(), 1); - rightButton->setEnabled(true); - - // click the overlay of the right drawer (don't leak through to the content below) - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint((window->width() - rightDrawer->width()) / 2, window->height() / 2)); - QCOMPARE(contentClickSpy.count(), 1); - QCOMPARE(leftClickSpy.count(), 1); - QCOMPARE(rightClickSpy.count(), 1); - QTRY_VERIFY(!rightDrawer->isVisible()); - - // no drawers open, click the content - QTest::mouseClick(window, Qt::LeftButton); - QCOMPARE(contentClickSpy.count(), 2); - QCOMPARE(leftClickSpy.count(), 1); - QCOMPARE(rightClickSpy.count(), 1); - - // drag the right drawer open - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() - 1, window->height() / 2)); - QTest::mouseMove(window, QPoint(window->width() - rightDrawer->width() / 4, window->height() / 2)); - QTest::mouseMove(window, QPoint(window->width() - rightDrawer->width() / 4 * 3, window->height() / 2)); - QCOMPARE(rightDrawer->position(), 0.5); - QCOMPARE(leftDrawer->position(), 0.0); - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() - rightDrawer->width() / 2, window->height() / 2)); - QTRY_COMPARE(rightDrawer->position(), 1.0); - QCOMPARE(leftDrawer->position(), 0.0); -} - -void tst_Drawer::touch_data() -{ - QTest::addColumn("source"); - QTest::addColumn("from"); - QTest::addColumn("to"); - - QTest::newRow("Window:inside") << "window.qml" << QPoint(150, 100) << QPoint(50, 100); - QTest::newRow("Window:outside") << "window.qml" << QPoint(300, 100) << QPoint(100, 100); - QTest::newRow("ApplicationWindow:inside") << "applicationwindow.qml" << QPoint(150, 100) << QPoint(50, 100); - QTest::newRow("ApplicationWindow:outside") << "applicationwindow.qml" << QPoint(300, 100) << QPoint(100, 100); - - QTest::newRow("Window+Button:inside") << "window-button.qml" << QPoint(150, 100) << QPoint(50, 100); - QTest::newRow("Window+Button:outside") << "window-button.qml" << QPoint(300, 100) << QPoint(100, 100); - QTest::newRow("ApplicationWindow+Button:inside") << "applicationwindow-button.qml" << QPoint(150, 100) << QPoint(50, 100); - QTest::newRow("ApplicationWindow+Button:outside") << "applicationwindow-button.qml" << QPoint(300, 100) << QPoint(100, 100); -} - -void tst_Drawer::touch() -{ - QFETCH(QString, source); - QFETCH(QPoint, from); - QFETCH(QPoint, to); - - QQuickApplicationHelper helper(this, source); - - QQuickWindow *window = helper.window; - window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - - QQuickDrawer *drawer = window->property("drawer").value(); - QVERIFY(drawer); - - QSignalSpy drawerOpenedSpy(drawer, SIGNAL(opened())); - QSignalSpy drawerClosedSpy(drawer, SIGNAL(closed())); - QVERIFY(drawerOpenedSpy.isValid()); - QVERIFY(drawerClosedSpy.isValid()); - - // drag to open - QTest::touchEvent(window, touchDevice.data()).press(0, QPoint(0, 100)); - QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(50, 100)); - QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(150, 100)); - QTest::touchEvent(window, touchDevice.data()).release(0, QPoint(150, 100)); - QVERIFY(drawerOpenedSpy.wait()); - QCOMPARE(drawer->position(), 1.0); - - // drag to close - QTest::touchEvent(window, touchDevice.data()).press(0, from); - for (int x = from.x(); x > to.x(); x -= 10) - QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(x, to.y())); - QTest::touchEvent(window, touchDevice.data()).move(0, to); - QTest::touchEvent(window, touchDevice.data()).release(0, to); - QVERIFY(drawerClosedSpy.wait()); - QCOMPARE(drawer->position(), 0.0); -} - -void tst_Drawer::multiTouch() -{ - QQuickApplicationHelper helper(this, QStringLiteral("multiTouch.qml")); - QQuickWindow *window = helper.window; - window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickOverlay *overlay = QQuickOverlay::overlay(window); - QVERIFY(overlay); - - QQuickDrawer *drawer = window->property("drawer").value(); - QVERIFY(drawer); - - QQuickPopup *popup = window->property("popup").value(); - QVERIFY(popup); - - QQuickButton *button = window->property("button").value(); - QVERIFY(button); - - QSignalSpy overlayPressedSpy(overlay, SIGNAL(pressed())); - QSignalSpy overlayReleasedSpy(overlay, SIGNAL(released())); - QVERIFY(overlayPressedSpy.isValid()); - QVERIFY(overlayReleasedSpy.isValid()); - - QSignalSpy drawerOpenedSpy(drawer, SIGNAL(opened())); - QVERIFY(drawerOpenedSpy.isValid()); - - QSignalSpy buttonPressedSpy(button, SIGNAL(pressed())); - QSignalSpy buttonReleasedSpy(button, SIGNAL(released())); - QVERIFY(buttonPressedSpy.isValid()); - QVERIFY(buttonReleasedSpy.isValid()); - - popup->open(); - QVERIFY(popup->isVisible()); - - drawer->open(); - QVERIFY(drawer->isVisible()); - QVERIFY(drawerOpenedSpy.wait()); - - // 1st press - QTest::touchEvent(window, touchDevice.data()).press(0, QPoint(300, 100)); - QVERIFY(popup->isVisible()); - QVERIFY(drawer->isVisible()); - QCOMPARE(buttonPressedSpy.count(), 0); - QCOMPARE(overlayPressedSpy.count(), 1); - - // 2nd press (blocked & ignored) - QTest::touchEvent(window, touchDevice.data()).stationary(0).press(1, QPoint(300, 200)); - QVERIFY(popup->isVisible()); - QVERIFY(drawer->isVisible()); - QCOMPARE(buttonPressedSpy.count(), 0); - QCOMPARE(overlayPressedSpy.count(), 2); - - // 2nd release (blocked & ignored) - QTest::touchEvent(window, touchDevice.data()).stationary(0).release(1, QPoint(300, 200)); - QVERIFY(popup->isVisible()); - QVERIFY(drawer->isVisible()); - QCOMPARE(buttonPressedSpy.count(), 0); - QCOMPARE(buttonReleasedSpy.count(), 0); - QCOMPARE(overlayPressedSpy.count(), 2); - QCOMPARE(overlayReleasedSpy.count(), 1); - - // 1st release - QTest::touchEvent(window, touchDevice.data()).release(0, QPoint(300, 100)); - QVERIFY(popup->isVisible()); - QTRY_VERIFY(!drawer->isVisible()); - QCOMPARE(buttonPressedSpy.count(), 0); - QCOMPARE(buttonReleasedSpy.count(), 0); - QCOMPARE(overlayPressedSpy.count(), 2); - QCOMPARE(overlayReleasedSpy.count(), 2); - - drawer->open(); - QVERIFY(drawer->isVisible()); - QVERIFY(drawerOpenedSpy.wait()); - - // 1st drag - QTest::touchEvent(window, touchDevice.data()).press(0, QPoint(300, 100)); - QCOMPARE(buttonPressedSpy.count(), 0); - QCOMPARE(overlayPressedSpy.count(), 3); - for (int x = 300; x >= 100; x -= 10) { - QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(x, 100)); - QVERIFY(popup->isVisible()); - QVERIFY(drawer->isVisible()); - } - QCOMPARE(drawer->position(), 0.5); - - // 2nd drag (blocked & ignored) - QTest::touchEvent(window, touchDevice.data()).stationary(0).press(1, QPoint(300, 200)); - QCOMPARE(buttonPressedSpy.count(), 0); - QCOMPARE(overlayPressedSpy.count(), 4); - for (int x = 300; x >= 0; x -= 10) { - QTest::touchEvent(window, touchDevice.data()).stationary(0).move(1, QPoint(x, 200)); - QVERIFY(popup->isVisible()); - QVERIFY(drawer->isVisible()); - } - QCOMPARE(drawer->position(), 0.5); - - // 2nd release (blocked & ignored) - QTest::touchEvent(window, touchDevice.data()).stationary(0).release(1, QPoint(300, 0)); - QVERIFY(popup->isVisible()); - QVERIFY(drawer->isVisible()); - QCOMPARE(drawer->position(), 0.5); - QCOMPARE(buttonReleasedSpy.count(), 0); - QCOMPARE(overlayReleasedSpy.count(), 3); - - // 1st release - QTest::touchEvent(window, touchDevice.data()).release(0, QPoint(300, 100)); - QVERIFY(popup->isVisible()); - QTRY_VERIFY(!drawer->isVisible()); - QCOMPARE(buttonReleasedSpy.count(), 0); - QCOMPARE(overlayReleasedSpy.count(), 4); -} - -void tst_Drawer::grabber() -{ - QQuickApplicationHelper helper(this, QStringLiteral("grabber.qml")); - QQuickWindow *window = helper.window; - window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - - QQuickDrawer *drawer = window->property("drawer").value(); - QVERIFY(drawer); - - QSignalSpy drawerOpenedSpy(drawer, SIGNAL(opened())); - QSignalSpy drawerClosedSpy(drawer, SIGNAL(closed())); - QVERIFY(drawerOpenedSpy.isValid()); - QVERIFY(drawerClosedSpy.isValid()); - - drawer->open(); - QVERIFY(drawerOpenedSpy.wait()); - - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(300, 100)); - QVERIFY(drawerClosedSpy.wait()); - - QQuickPopup *popup = window->property("popup").value(); - QVERIFY(popup); - - QSignalSpy popupOpenedSpy(popup, SIGNAL(opened())); - QSignalSpy popupClosedSpy(popup, SIGNAL(closed())); - QVERIFY(popupOpenedSpy.isValid()); - QVERIFY(popupClosedSpy.isValid()); - - popup->open(); - QTRY_COMPARE(popupOpenedSpy.count(), 1); - - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(100, 300)); - QTRY_COMPARE(popupClosedSpy.count(), 1); -} - -void tst_Drawer::interactive_data() -{ - QTest::addColumn("source"); - QTest::newRow("Window") << "window.qml"; - QTest::newRow("ApplicationWindow") << "applicationwindow.qml"; -} - -void tst_Drawer::interactive() -{ - QFETCH(QString, source); - QQuickApplicationHelper helper(this, source); - - QQuickWindow *window = helper.window; - window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickDrawer *drawer = window->property("drawer").value(); - QVERIFY(drawer); - - drawer->setInteractive(false); - - QSignalSpy openedSpy(drawer, SIGNAL(opened())); - QSignalSpy aboutToHideSpy(drawer, SIGNAL(aboutToHide())); - QVERIFY(openedSpy.isValid()); - QVERIFY(aboutToHideSpy.isValid()); - - drawer->open(); - QVERIFY(openedSpy.wait()); - - // click outside - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(300, 100)); - QCOMPARE(aboutToHideSpy.count(), 0); - - // drag inside - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(drawer->width(), 0)); - QTest::mouseMove(window, QPoint(0, 0)); - QCOMPARE(drawer->position(), 1.0); - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(0, 0)); - QCOMPARE(drawer->position(), 1.0); - QCOMPARE(aboutToHideSpy.count(), 0); - - // drag outside - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() - 1, 0)); - QTest::mouseMove(window, QPoint(0, 0)); - QCOMPARE(drawer->position(), 1.0); - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(0, 0)); - QCOMPARE(drawer->position(), 1.0); - QCOMPARE(aboutToHideSpy.count(), 0); - - // close on escape - QTest::keyClick(window, Qt::Key_Escape); - QCOMPARE(aboutToHideSpy.count(), 0); -} - -void tst_Drawer::flickable_data() -{ - QTest::addColumn("mouse"); - QTest::addColumn("from"); - QTest::addColumn("to"); - - QTest::newRow("mouse,straight") << true << QPoint(200, 200) << QPoint(200, 100); - QTest::newRow("mouse,diagonal") << true << QPoint(200, 200) << QPoint(250, 100); - QTest::newRow("touch,straight") << false << QPoint(200, 200) << QPoint(200, 100); - QTest::newRow("touch,diagonal") << false << QPoint(200, 200) << QPoint(250, 100); -} - -void tst_Drawer::flickable() -{ - QFETCH(bool, mouse); - QFETCH(QPoint, from); - QFETCH(QPoint, to); - - QQuickApplicationHelper helper(this, QStringLiteral("flickable.qml")); - QQuickWindow *window = helper.window; - window->show(); - QVERIFY(QTest::qWaitForWindowExposed(window)); - - QQuickDrawer *drawer = window->property("drawer").value(); - QVERIFY(drawer); - - QQuickFlickable *flickable = window->property("flickable").value(); - QVERIFY(flickable); - - QSignalSpy drawerOpenedSpy(drawer, SIGNAL(opened())); - QVERIFY(drawerOpenedSpy.isValid()); - - drawer->open(); - QVERIFY(drawerOpenedSpy.wait()); - - if (mouse) - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, from); - else - QTest::touchEvent(window, touchDevice.data()).press(0, from); - - static const int steps = 10; - for (int i = 0; i < steps; ++i) { - int x = i * qAbs(from.x() - to.x()) / steps; - int y = i * qAbs(from.y() - to.y()) / steps; - - if (mouse) - QTest::mouseMove(window, QPoint(x, y)); - else - QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(x, y)); - QTest::qWait(1); // avoid infinite velocity - } - - QVERIFY(flickable->isDragging()); - - if (mouse) - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, to); - else - QTest::touchEvent(window, touchDevice.data()).release(0, to); - - QVERIFY(!flickable->isDragging()); -} - -void tst_Drawer::dragOverModalShadow_data() -{ - QTest::addColumn("mouse"); - QTest::newRow("mouse") << true; - QTest::newRow("touch") << false; -} - -// QTBUG-60602 -void tst_Drawer::dragOverModalShadow() -{ - QFETCH(bool, mouse); - - QQuickApplicationHelper helper(this, QStringLiteral("dragOverModalShadow.qml")); - QQuickWindow *window = helper.window; - window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickDrawer *drawer = window->property("drawer").value(); - QVERIFY(drawer); - - QQuickPopup *popup = window->property("popup").value(); - QVERIFY(popup); - - popup->open(); - QVERIFY(popup->isVisible()); - QVERIFY(!drawer->isVisible()); - - const QPoint from(popup->x(), popup->y() + popup->height() + 5); - const QPoint to(popup->x() + popup->width(), popup->y() + popup->height() + 5); - - if (mouse) - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, from); - else - QTest::touchEvent(window, touchDevice.data()).press(0, from); - QVERIFY(!drawer->isVisible()); - - static const int steps = 10; - for (int i = 0; i < steps; ++i) { - int x = from.x() + i * qAbs(from.x() - to.x()) / steps; - int y = from.y() + i * qAbs(from.y() - to.y()) / steps; - - if (mouse) - QTest::mouseMove(window, QPoint(x, y)); - else - QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(x, y)); - QTest::qWait(1); // avoid infinite velocity - QVERIFY(!drawer->isVisible()); - } - - if (mouse) - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, to); - else - QTest::touchEvent(window, touchDevice.data()).release(0, to); - QVERIFY(!drawer->isVisible()); -} - -void tst_Drawer::nonModal_data() -{ - QTest::addColumn("mouse"); - QTest::newRow("mouse") << true; - QTest::newRow("touch") << false; -} - -// QTBUG-59652 -void tst_Drawer::nonModal() -{ - QFETCH(bool, mouse); - - QQuickApplicationHelper helper(this, QStringLiteral("window.qml")); - QQuickWindow *window = helper.window; - window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickDrawer *drawer = window->property("drawer").value(); - QVERIFY(drawer); - drawer->setModal(false); - - const QPoint from(1, 1); - const QPoint to(150, 1); - - // drag to open - QSignalSpy openedSpy(drawer, SIGNAL(opened())); - QVERIFY(openedSpy.isValid()); - - if (mouse) - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, from); - else - QTest::touchEvent(window, touchDevice.data()).press(0, from); - - static const int steps = 10; - for (int i = 0; i < steps; ++i) { - int x = i * qAbs(from.x() - to.x()) / steps; - int y = i * qAbs(from.y() - to.y()) / steps; - - if (mouse) - QTest::mouseMove(window, QPoint(x, y)); - else - QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(x, y)); - QTest::qWait(1); // avoid infinite velocity - } - QVERIFY(drawer->isVisible()); - - if (mouse) - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, to); - else - QTest::touchEvent(window, touchDevice.data()).release(0, to); - QVERIFY(openedSpy.wait()); - - // drag to close - QSignalSpy closedSpy(drawer, SIGNAL(closed())); - QVERIFY(closedSpy.isValid()); - - if (mouse) - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, to); - else - QTest::touchEvent(window, touchDevice.data()).press(0, to); - - for (int i = steps - 1; i >= 0; --i) { - int x = i * qAbs(from.x() - to.x()) / steps; - int y = i * qAbs(from.y() - to.y()) / steps; - - if (mouse) - QTest::mouseMove(window, QPoint(x, y)); - else - QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(x, y)); - QTest::qWait(1); // avoid infinite velocity - } - QVERIFY(drawer->isVisible()); - - if (mouse) - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, from); - else - QTest::touchEvent(window, touchDevice.data()).release(0, from); - QVERIFY(closedSpy.wait()); -} - -QTEST_MAIN(tst_Drawer) - -#include "tst_drawer.moc" diff --git a/tests/auto/qquickdrawer/data/applicationwindow-button.qml b/tests/auto/qquickdrawer/data/applicationwindow-button.qml new file mode 100644 index 00000000..9641351e --- /dev/null +++ b/tests/auto/qquickdrawer/data/applicationwindow-button.qml @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** 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 drawer: drawer + + Drawer { + id: drawer + width: 200 + height: 200 + + Button { + text: "Button" + anchors.fill: parent + } + } +} diff --git a/tests/auto/qquickdrawer/data/applicationwindow-hover.qml b/tests/auto/qquickdrawer/data/applicationwindow-hover.qml new file mode 100644 index 00000000..560efec3 --- /dev/null +++ b/tests/auto/qquickdrawer/data/applicationwindow-hover.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** 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 drawer: drawer + property alias backgroundButton: backgroundButton + property alias drawerButton: drawerButton + + Button { + id: backgroundButton + text: "Background" + anchors.fill: parent + } + + Drawer { + id: drawer + width: 100 + height: 400 + topPadding: 2 + leftPadding: 2 + rightPadding: 2 + bottomPadding: 2 + + contentItem: Button { + id: drawerButton + text: "Drawer" + } + } +} diff --git a/tests/auto/qquickdrawer/data/applicationwindow-wheel.qml b/tests/auto/qquickdrawer/data/applicationwindow-wheel.qml new file mode 100644 index 00000000..541f08aa --- /dev/null +++ b/tests/auto/qquickdrawer/data/applicationwindow-wheel.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 { + id: window + width: 400 + height: 400 + + property alias drawer: drawer + property alias drawerSlider: drawerSlider + property alias contentSlider: contentSlider + + Slider { + id: contentSlider + anchors.fill: parent + wheelEnabled: true + } + + Drawer { + id: drawer + edge: Qt.RightEdge + width: window.width * 0.8 + height: window.height + clip: true + contentItem: Slider { + id: drawerSlider + wheelEnabled: true + } + } +} diff --git a/tests/auto/qquickdrawer/data/applicationwindow.qml b/tests/auto/qquickdrawer/data/applicationwindow.qml new file mode 100644 index 00000000..673c4d4c --- /dev/null +++ b/tests/auto/qquickdrawer/data/applicationwindow.qml @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** 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 drawer: drawer + + Drawer { + id: drawer + width: 200 + height: 200 + } +} diff --git a/tests/auto/qquickdrawer/data/dragOverModalShadow.qml b/tests/auto/qquickdrawer/data/dragOverModalShadow.qml new file mode 100644 index 00000000..66eb2f4b --- /dev/null +++ b/tests/auto/qquickdrawer/data/dragOverModalShadow.qml @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** 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 drawer: drawer + property alias popup: popup + + Drawer { + id: drawer + width: 200 + height: parent.height + dragMargin: parent.width + } + + Popup { + id: popup + modal: true + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + width: parent.width / 2 + height: parent.height / 2 + + Rectangle { + objectName: "shadow" + parent: popup.background + anchors.fill: parent + anchors.margins: -20 + + z: -1 + opacity: 0.5 + color: "silver" + } + } +} diff --git a/tests/auto/qquickdrawer/data/flickable.qml b/tests/auto/qquickdrawer/data/flickable.qml new file mode 100644 index 00000000..62256afd --- /dev/null +++ b/tests/auto/qquickdrawer/data/flickable.qml @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** 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 drawer: drawer + property alias flickable: flickable + + Drawer { + id: drawer + width: 300 + height: 400 + + contentItem: ListView { + id: flickable + model: 100 + delegate: ItemDelegate { + width: parent.width + text: index + } + } + } +} diff --git a/tests/auto/qquickdrawer/data/grabber.qml b/tests/auto/qquickdrawer/data/grabber.qml new file mode 100644 index 00000000..e6ebe2da --- /dev/null +++ b/tests/auto/qquickdrawer/data/grabber.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** 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 drawer: drawer + property alias popup: popup + + Drawer { + id: drawer + width: 200 + height: parent.height + } + + Popup { + id: popup + x: 200 + width: 200 + height: parent.height + } +} diff --git a/tests/auto/qquickdrawer/data/header.qml b/tests/auto/qquickdrawer/data/header.qml new file mode 100644 index 00000000..de3af106 --- /dev/null +++ b/tests/auto/qquickdrawer/data/header.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** 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 drawer: drawer + property alias button: button + + header: ToolBar { + ToolButton { + id: button + text: "=" + } + } + + Drawer { + id: drawer + width: 200 + height: parent.height + } +} diff --git a/tests/auto/qquickdrawer/data/multiTouch.qml b/tests/auto/qquickdrawer/data/multiTouch.qml new file mode 100644 index 00000000..0faf3c61 --- /dev/null +++ b/tests/auto/qquickdrawer/data/multiTouch.qml @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** 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 { + id: window + width: 400 + height: 400 + + property alias drawer: drawer + property alias popup: popup + property alias button: button + + Drawer { + id: drawer + width: window.width / 2 + height: parent.height + dragMargin: parent.width + } + + Popup { + id: popup + x: 10; y: 10 + width: window.width - 10 + height: window.height - 10 + + Button { + id: button + text: "Button" + anchors.fill: parent + } + } +} diff --git a/tests/auto/qquickdrawer/data/multiple.qml b/tests/auto/qquickdrawer/data/multiple.qml new file mode 100644 index 00000000..4e622fca --- /dev/null +++ b/tests/auto/qquickdrawer/data/multiple.qml @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** 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 leftDrawer: leftDrawer + property alias leftButton: leftButton + + property alias rightDrawer: rightDrawer + property alias rightButton: rightButton + + property alias contentButton: contentButton + + Drawer { + id: leftDrawer + width: 300 + height: 400 + z: 1 + + contentItem: Button { + id: leftButton + text: "Left" + } + } + + Button { + id: contentButton + text: "Content" + anchors.fill: parent + } + + Drawer { + id: rightDrawer + width: 300 + height: 400 + edge: Qt.RightEdge + + contentItem: Button { + id: rightButton + text: "Right" + } + } +} diff --git a/tests/auto/qquickdrawer/data/reposition.qml b/tests/auto/qquickdrawer/data/reposition.qml new file mode 100644 index 00000000..485da85c --- /dev/null +++ b/tests/auto/qquickdrawer/data/reposition.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.Controls 2.0 + +ApplicationWindow { + id: window + width: 400 + height: 400 + + property alias drawer: drawer + property alias drawer2: drawer2 + + header: Item { implicitHeight: 50 } + footer: Item { implicitHeight: 50 } + + Drawer { + id: drawer + width: parent.width / 2 + implicitHeight: parent.height + } + + Drawer { + id: drawer2 + width: Math.min(window.width, window.height) / 3 * 2 + height: window.height + } +} diff --git a/tests/auto/qquickdrawer/data/window-button.qml b/tests/auto/qquickdrawer/data/window-button.qml new file mode 100644 index 00000000..1b8ac7d5 --- /dev/null +++ b/tests/auto/qquickdrawer/data/window-button.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.Window 2.2 +import QtQuick.Controls 2.0 + +Window { + width: 400 + height: 400 + + property alias drawer: drawer + + Drawer { + id: drawer + width: 200 + height: 200 + + Button { + text: "Button" + anchors.fill: parent + } + } +} diff --git a/tests/auto/qquickdrawer/data/window-hover.qml b/tests/auto/qquickdrawer/data/window-hover.qml new file mode 100644 index 00000000..b35bcd99 --- /dev/null +++ b/tests/auto/qquickdrawer/data/window-hover.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** 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 drawer: drawer + property alias backgroundButton: backgroundButton + property alias drawerButton: drawerButton + + Button { + id: backgroundButton + text: "Background" + anchors.fill: parent + } + + Drawer { + id: drawer + width: 100 + height: 400 + topPadding: 2 + leftPadding: 2 + rightPadding: 2 + bottomPadding: 2 + + contentItem: Button { + id: drawerButton + text: "Drawer" + } + } +} diff --git a/tests/auto/qquickdrawer/data/window-wheel.qml b/tests/auto/qquickdrawer/data/window-wheel.qml new file mode 100644 index 00000000..988a541e --- /dev/null +++ b/tests/auto/qquickdrawer/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 drawer: drawer + property alias drawerSlider: drawerSlider + property alias contentSlider: contentSlider + + Slider { + id: contentSlider + anchors.fill: parent + wheelEnabled: true + } + + Drawer { + id: drawer + edge: Qt.RightEdge + width: window.width * 0.8 + height: window.height + clip: true + contentItem: Slider { + id: drawerSlider + wheelEnabled: true + } + } +} diff --git a/tests/auto/qquickdrawer/data/window.qml b/tests/auto/qquickdrawer/data/window.qml new file mode 100644 index 00000000..88376ac4 --- /dev/null +++ b/tests/auto/qquickdrawer/data/window.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** 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 drawer: drawer + + Drawer { + id: drawer + width: 200 + height: 200 + } +} diff --git a/tests/auto/qquickdrawer/qquickdrawer.pro b/tests/auto/qquickdrawer/qquickdrawer.pro new file mode 100644 index 00000000..9df205e6 --- /dev/null +++ b/tests/auto/qquickdrawer/qquickdrawer.pro @@ -0,0 +1,14 @@ +CONFIG += testcase +TARGET = tst_qquickdrawer +SOURCES += tst_qquickdrawer.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/qquickdrawer/tst_qquickdrawer.cpp b/tests/auto/qquickdrawer/tst_qquickdrawer.cpp new file mode 100644 index 00000000..9f6a556f --- /dev/null +++ b/tests/auto/qquickdrawer/tst_qquickdrawer.cpp @@ -0,0 +1,1224 @@ +/**************************************************************************** +** +** 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 +#include +#include +#include +#include + +using namespace QQuickVisualTestUtil; + +class tst_QQuickDrawer : public QQmlDataTest +{ + Q_OBJECT + +private slots: + void initTestCase(); + + void visible_data(); + void visible(); + + void state(); + + void position_data(); + void position(); + + void dragMargin_data(); + void dragMargin(); + + void reposition(); + void header(); + + void hover_data(); + void hover(); + + void wheel_data(); + void wheel(); + + void multiple(); + + void touch_data(); + void touch(); + + void multiTouch(); + + void grabber(); + + void interactive_data(); + void interactive(); + + void flickable_data(); + void flickable(); + + void dragOverModalShadow_data(); + void dragOverModalShadow(); + + void nonModal_data(); + void nonModal(); + +private: + struct TouchDeviceDeleter + { + static inline void cleanup(QTouchDevice *device) + { + QWindowSystemInterface::unregisterTouchDevice(device); + delete device; + } + }; + + QScopedPointer touchDevice; +}; + + +void tst_QQuickDrawer::initTestCase() +{ + QQmlDataTest::initTestCase(); + qputenv("QML_NO_TOUCH_COMPRESSION", "1"); + + touchDevice.reset(new QTouchDevice); + touchDevice->setType(QTouchDevice::TouchScreen); + QWindowSystemInterface::registerTouchDevice(touchDevice.data()); +} + +void tst_QQuickDrawer::visible_data() +{ + QTest::addColumn("source"); + QTest::newRow("Window") << "window.qml"; + QTest::newRow("ApplicationWindow") << "applicationwindow.qml"; +} + +void tst_QQuickDrawer::visible() +{ + QFETCH(QString, source); + QQuickApplicationHelper helper(this, source); + + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickDrawer *drawer = window->property("drawer").value(); + QVERIFY(drawer); + QQuickItem *popupItem = drawer->popupItem(); + + QCOMPARE(drawer->isVisible(), false); + QCOMPARE(drawer->position(), qreal(0.0)); + + QQuickOverlay *overlay = QQuickOverlay::overlay(window); + QVERIFY(overlay); + QVERIFY(!overlay->childItems().contains(popupItem)); + + drawer->open(); + QVERIFY(drawer->isVisible()); + QVERIFY(overlay->childItems().contains(popupItem)); + QTRY_COMPARE(drawer->position(), qreal(1.0)); + + drawer->close(); + QTRY_VERIFY(!drawer->isVisible()); + QTRY_COMPARE(drawer->position(), qreal(0.0)); + QVERIFY(!overlay->childItems().contains(popupItem)); + + drawer->setVisible(true); + QVERIFY(drawer->isVisible()); + QVERIFY(overlay->childItems().contains(popupItem)); + QTRY_COMPARE(drawer->position(), qreal(1.0)); + + drawer->setVisible(false); + QTRY_VERIFY(!drawer->isVisible()); + QTRY_COMPARE(drawer->position(), qreal(0.0)); + QTRY_VERIFY(!overlay->childItems().contains(popupItem)); +} + +void tst_QQuickDrawer::state() +{ + QQuickApplicationHelper helper(this, "applicationwindow.qml"); + + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickDrawer *drawer = window->property("drawer").value(); + QVERIFY(drawer); + + QCOMPARE(drawer->isVisible(), false); + + QSignalSpy visibleChangedSpy(drawer, SIGNAL(visibleChanged())); + QSignalSpy aboutToShowSpy(drawer, SIGNAL(aboutToShow())); + QSignalSpy aboutToHideSpy(drawer, SIGNAL(aboutToHide())); + QSignalSpy openedSpy(drawer, SIGNAL(opened())); + QSignalSpy closedSpy(drawer, SIGNAL(closed())); + + QVERIFY(visibleChangedSpy.isValid()); + QVERIFY(aboutToShowSpy.isValid()); + QVERIFY(aboutToHideSpy.isValid()); + QVERIFY(openedSpy.isValid()); + QVERIFY(closedSpy.isValid()); + + int visibleChangedCount = 0; + int aboutToShowCount = 0; + int aboutToHideCount = 0; + int openedCount = 0; + int closedCount = 0; + + // open programmatically... + drawer->open(); + QCOMPARE(visibleChangedSpy.count(), ++visibleChangedCount); + QCOMPARE(aboutToShowSpy.count(), ++aboutToShowCount); + QCOMPARE(aboutToHideSpy.count(), aboutToHideCount); + QCOMPARE(openedSpy.count(), openedCount); + QCOMPARE(closedSpy.count(), closedCount); + + // ...and wait until fully open + QVERIFY(openedSpy.wait()); + QCOMPARE(visibleChangedSpy.count(), visibleChangedCount); + QCOMPARE(aboutToShowSpy.count(), aboutToShowCount); + QCOMPARE(aboutToHideSpy.count(), aboutToHideCount); + QCOMPARE(openedSpy.count(), ++openedCount); + QCOMPARE(closedSpy.count(), closedCount); + + // close programmatically... + drawer->close(); + QCOMPARE(visibleChangedSpy.count(), visibleChangedCount); + QCOMPARE(aboutToShowSpy.count(), aboutToShowCount); + QCOMPARE(aboutToHideSpy.count(), ++aboutToHideCount); + QCOMPARE(openedSpy.count(), openedCount); + QCOMPARE(closedSpy.count(), closedCount); + + // ...and wait until fully closed + QVERIFY(closedSpy.wait()); + QCOMPARE(visibleChangedSpy.count(), ++visibleChangedCount); + QCOMPARE(aboutToShowSpy.count(), aboutToShowCount); + QCOMPARE(aboutToHideSpy.count(), aboutToHideCount); + QCOMPARE(openedSpy.count(), openedCount); + QCOMPARE(closedSpy.count(), ++closedCount); + + // open interactively... + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(0, drawer->height() / 2)); + QTest::mouseMove(window, QPoint(drawer->width() * 0.2, drawer->height() / 2), 16); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(drawer->width() * 0.8, drawer->height() / 2), 16); + QCOMPARE(visibleChangedSpy.count(), ++visibleChangedCount); + QCOMPARE(aboutToShowSpy.count(), ++aboutToShowCount); + QCOMPARE(aboutToHideSpy.count(), aboutToHideCount); + QCOMPARE(openedSpy.count(), openedCount); + QCOMPARE(closedSpy.count(), closedCount); + + // ...and wait until fully open + QVERIFY(openedSpy.wait()); + QCOMPARE(visibleChangedSpy.count(), visibleChangedCount); + QCOMPARE(aboutToShowSpy.count(), aboutToShowCount); + QCOMPARE(aboutToHideSpy.count(), aboutToHideCount); + QCOMPARE(openedSpy.count(), ++openedCount); + QCOMPARE(closedSpy.count(), closedCount); + + // close interactively... + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(drawer->width(), drawer->height() / 2)); + QTest::mouseMove(window, QPoint(drawer->width() * 0.8, drawer->height() / 2), 16); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(drawer->width() * 0.2, drawer->height() / 2), 16); + QCOMPARE(visibleChangedSpy.count(), visibleChangedCount); + QCOMPARE(aboutToShowSpy.count(), aboutToShowCount); + QCOMPARE(aboutToHideSpy.count(), ++aboutToHideCount); + QCOMPARE(openedSpy.count(), openedCount); + QCOMPARE(closedSpy.count(), closedCount); + + // ...and wait until fully closed + QVERIFY(closedSpy.wait()); + QCOMPARE(visibleChangedSpy.count(), ++visibleChangedCount); + QCOMPARE(aboutToShowSpy.count(), aboutToShowCount); + QCOMPARE(aboutToHideSpy.count(), aboutToHideCount); + QCOMPARE(openedSpy.count(), openedCount); + QCOMPARE(closedSpy.count(), ++closedCount); +} + +void tst_QQuickDrawer::position_data() +{ + QTest::addColumn("edge"); + QTest::addColumn("press"); + QTest::addColumn("from"); + QTest::addColumn("to"); + QTest::addColumn("position"); + + QTest::newRow("top") << Qt::TopEdge << QPoint(100, 0) << QPoint(100, 50) << QPoint(100, 150) << qreal(0.5); + QTest::newRow("left") << Qt::LeftEdge << QPoint(0, 100) << QPoint(50, 100) << QPoint(150, 100) << qreal(0.5); + QTest::newRow("right") << Qt::RightEdge << QPoint(399, 100) << QPoint(350, 100) << QPoint(250, 100) << qreal(0.5); + QTest::newRow("bottom") << Qt::BottomEdge << QPoint(100, 399) << QPoint(100, 350) << QPoint(150, 250) << qreal(0.5); +} + +void tst_QQuickDrawer::position() +{ + QFETCH(Qt::Edge, edge); + QFETCH(QPoint, press); + QFETCH(QPoint, from); + QFETCH(QPoint, to); + QFETCH(qreal, position); + + QQuickApplicationHelper helper(this, QStringLiteral("applicationwindow.qml")); + + QQuickApplicationWindow *window = helper.appWindow; + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickDrawer *drawer = helper.appWindow->property("drawer").value(); + QVERIFY(drawer); + drawer->setEdge(edge); + + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, press); + QTest::mouseMove(window, from); + QTest::mouseMove(window, to); + QCOMPARE(drawer->position(), position); + + // moved half-way open at almost infinite speed => snap to open + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, to); + QTRY_COMPARE(drawer->position(), 1.0); +} + +void tst_QQuickDrawer::dragMargin_data() +{ + QTest::addColumn("edge"); + QTest::addColumn("dragMargin"); + QTest::addColumn("dragFromLeft"); + QTest::addColumn("dragFromRight"); + + QTest::newRow("left:0") << Qt::LeftEdge << qreal(0) << qreal(0) << qreal(0); + QTest::newRow("left:-1") << Qt::LeftEdge << qreal(-1) << qreal(0) << qreal(0); + QTest::newRow("left:startDragDistance") << Qt::LeftEdge << qreal(QGuiApplication::styleHints()->startDragDistance()) << qreal(0.45) << qreal(0); + QTest::newRow("left:startDragDistance*2") << Qt::LeftEdge << qreal(QGuiApplication::styleHints()->startDragDistance() * 2) << qreal(0.45) << qreal(0); + + QTest::newRow("right:0") << Qt::RightEdge << qreal(0) << qreal(0) << qreal(0); + QTest::newRow("right:-1") << Qt::RightEdge << qreal(-1) << qreal(0) << qreal(0); + QTest::newRow("right:startDragDistance") << Qt::RightEdge << qreal(QGuiApplication::styleHints()->startDragDistance()) << qreal(0) << qreal(0.75); + QTest::newRow("right:startDragDistance*2") << Qt::RightEdge << qreal(QGuiApplication::styleHints()->startDragDistance() * 2) << qreal(0) << qreal(0.75); +} + +void tst_QQuickDrawer::dragMargin() +{ + QFETCH(Qt::Edge, edge); + QFETCH(qreal, dragMargin); + QFETCH(qreal, dragFromLeft); + QFETCH(qreal, dragFromRight); + + QQuickApplicationHelper helper(this, QStringLiteral("applicationwindow.qml")); + + QQuickApplicationWindow *window = helper.appWindow; + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickDrawer *drawer = helper.appWindow->property("drawer").value(); + QVERIFY(drawer); + drawer->setEdge(edge); + drawer->setDragMargin(dragMargin); + + const int startDragDistance = qMax(20, QGuiApplication::styleHints()->startDragDistance() + 5) + 1; + + // drag from the left + int leftX = qMax(0, dragMargin); + int leftDistance = startDragDistance + drawer->width() * 0.45; + QVERIFY(leftDistance > QGuiApplication::styleHints()->startDragDistance()); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(leftX, drawer->height() / 2)); + QTest::mouseMove(window, QPoint(leftX + startDragDistance, drawer->height() / 2)); + QTest::mouseMove(window, QPoint(leftX + leftDistance, drawer->height() / 2)); + QCOMPARE(drawer->position(), dragFromLeft); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(leftX + leftDistance, drawer->height() / 2)); + + drawer->close(); + QTRY_COMPARE(drawer->position(), qreal(0.0)); + + // drag from the right + int rightX = qMin(window->width() - 1, window->width() - dragMargin); + int rightDistance = startDragDistance + drawer->width() * 0.75; + QVERIFY(rightDistance > QGuiApplication::styleHints()->startDragDistance()); + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(rightX, drawer->height() / 2)); + QTest::mouseMove(window, QPoint(rightX - startDragDistance, drawer->height() / 2)); + QTest::mouseMove(window, QPoint(rightX - rightDistance, drawer->height() / 2)); + QCOMPARE(drawer->position(), dragFromRight); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(rightX - rightDistance, drawer->height() / 2)); +} + +static QRectF geometry(const QQuickItem *item) +{ + return QRectF(item->x(), item->y(), item->width(), item->height()); +} + +void tst_QQuickDrawer::reposition() +{ + QQuickApplicationHelper helper(this, QStringLiteral("reposition.qml")); + + QQuickApplicationWindow *window = helper.appWindow; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickDrawer *drawer = window->property("drawer").value(); + QVERIFY(drawer); + QQuickItem *popupItem = drawer->popupItem(); + QVERIFY(popupItem); + + drawer->open(); + QQuickItem *dimmer = QQuickPopupPrivate::get(drawer)->dimmer; + QVERIFY(dimmer); + + QCOMPARE(geometry(dimmer), QRectF(0, 0, window->width(), window->height())); + QTRY_COMPARE(geometry(popupItem), QRectF(0, 0, window->width() / 2, window->height())); + + drawer->setY(100); + QCOMPARE(geometry(dimmer), QRectF(0, 100, window->width(), window->height() - 100)); + QCOMPARE(geometry(popupItem), QRectF(0, 100, window->width() / 2, window->height() - 100)); + + drawer->setHeight(window->height()); + QCOMPARE(geometry(dimmer), QRectF(0, 100, window->width(), window->height())); + QCOMPARE(geometry(popupItem), QRectF(0, 100, window->width() / 2, window->height())); + + drawer->resetHeight(); + QCOMPARE(geometry(dimmer), QRectF(0, 100, window->width(), window->height() - 100)); + QCOMPARE(geometry(popupItem), QRectF(0, 100, window->width() / 2, window->height() - 100)); + + drawer->setParentItem(window->contentItem()); + QCOMPARE(geometry(dimmer), QRectF(0, 150, window->width(), window->height() - 150)); + QCOMPARE(geometry(popupItem), QRectF(0, 150, window->width() / 2, window->height() - 150)); + + drawer->setEdge(Qt::RightEdge); + QCOMPARE(geometry(dimmer), QRectF(0, 150, window->width(), window->height() - 150)); + QTRY_COMPARE(geometry(popupItem), QRectF(window->width() - drawer->width(), 150, window->width() / 2, window->height() - 150)); + + window->setWidth(window->width() + 100); + QTRY_COMPARE(geometry(dimmer), QRectF(0, 150, window->width(), window->height() - 150)); + QTRY_COMPARE(geometry(popupItem), QRectF(window->width() - drawer->width(), 150, window->width() / 2, window->height() - 150)); + + drawer->close(); + QTRY_COMPARE(geometry(popupItem), QRectF(window->width(), 150, window->width() / 2, window->height() - 150)); + + QQuickDrawer *drawer2 = window->property("drawer2").value(); + QVERIFY(drawer2); + QQuickItem *popupItem2 = drawer2->popupItem(); + QVERIFY(popupItem2); + + drawer2->open(); + QVERIFY(popupItem2->isVisible()); + QCOMPARE(popupItem2->x(), -drawer2->width()); + QTRY_COMPARE(popupItem2->x(), 0.0); +} + +void tst_QQuickDrawer::header() +{ + QQuickApplicationHelper helper(this, QStringLiteral("header.qml")); + + QQuickApplicationWindow *window = helper.appWindow; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickItem *content = window->contentItem(); + QVERIFY(content); + + QQuickOverlay *overlay = QQuickOverlay::overlay(window); + QVERIFY(overlay); + + QQuickDrawer *drawer = window->property("drawer").value(); + QVERIFY(drawer); + QQuickItem *popupItem = drawer->popupItem(); + + QQuickButton *button = window->property("button").value(); + QVERIFY(button); + + drawer->open(); + QVERIFY(drawer->isVisible()); + + QCOMPARE(drawer->parentItem(), overlay); + QCOMPARE(drawer->height(), overlay->height()); + QCOMPARE(popupItem->height(), overlay->height()); + + drawer->setParentItem(content); + QCOMPARE(drawer->parentItem(), content); + QCOMPARE(drawer->height(), content->height()); + QCOMPARE(popupItem->height(), content->height()); + + // must be possible to interact with the header when the drawer is below the header + QSignalSpy clickSpy(button, SIGNAL(clicked())); + QVERIFY(clickSpy.isValid()); + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(button->x() + button->width() / 2, button->y() + button->height() / 2)); + QCOMPARE(clickSpy.count(), 1); +} + +void tst_QQuickDrawer::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_QQuickDrawer::hover() +{ + QFETCH(QString, source); + QFETCH(bool, modal); + + QQuickApplicationHelper helper(this, source); + QQuickWindow *window = helper.window; + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickDrawer *drawer = window->property("drawer").value(); + QVERIFY(drawer); + drawer->setModal(modal); + + QQuickControl *drawerItem = qobject_cast(drawer->popupItem()); + QVERIFY(drawerItem); + QVERIFY(drawerItem->isHoverEnabled()); + + QQuickButton *backgroundButton = window->property("backgroundButton").value(); + QVERIFY(backgroundButton); + backgroundButton->setHoverEnabled(true); + + QQuickButton *drawerButton = window->property("drawerButton").value(); + QVERIFY(drawerButton); + drawerButton->setHoverEnabled(true); + + QSignalSpy openedSpy(drawer, SIGNAL(opened())); + QVERIFY(openedSpy.isValid()); + drawer->open(); + QVERIFY(openedSpy.count() == 1 || openedSpy.wait()); + + // hover the background button outside the drawer + QTest::mouseMove(window, QPoint(window->width() - 1, window->height() - 1)); + QCOMPARE(backgroundButton->isHovered(), !modal); + QVERIFY(!drawerButton->isHovered()); + QVERIFY(!drawerItem->isHovered()); + + // hover the drawer background + QTest::mouseMove(window, QPoint(1, 1)); + QVERIFY(!backgroundButton->isHovered()); + QVERIFY(!drawerButton->isHovered()); + QVERIFY(drawerItem->isHovered()); + + // hover the button in a drawer + QTest::mouseMove(window, QPoint(2, 2)); + QVERIFY(!backgroundButton->isHovered()); + QVERIFY(drawerButton->isHovered()); + QVERIFY(drawerItem->isHovered()); + + QSignalSpy closedSpy(drawer, SIGNAL(closed())); + QVERIFY(closedSpy.isValid()); + drawer->close(); + QVERIFY(closedSpy.count() == 1 || closedSpy.wait()); + + // hover the background button after closing the drawer + QTest::mouseMove(window, QPoint(window->width() / 2, window->height() / 2)); + QVERIFY(backgroundButton->isHovered()); + QVERIFY(!drawerButton->isHovered()); + QVERIFY(!drawerItem->isHovered()); +} + +void tst_QQuickDrawer::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_QQuickDrawer::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); + + QQuickDrawer *drawer = window->property("drawer").value(); + QVERIFY(drawer && drawer->contentItem()); + drawer->setModal(modal); + + QQuickSlider *drawerSlider = window->property("drawerSlider").value(); + QVERIFY(drawerSlider); + + { + // wheel over the content + qreal oldContentValue = contentSlider->value(); + qreal oldDrawerValue = drawerSlider->value(); + + QVERIFY(sendWheelEvent(contentSlider, QPoint(contentSlider->width() / 2, contentSlider->height() / 2), 15)); + + QVERIFY(!qFuzzyCompare(contentSlider->value(), oldContentValue)); // must have moved + QVERIFY(qFuzzyCompare(drawerSlider->value(), oldDrawerValue)); // must not have moved + } + + QSignalSpy openedSpy(drawer, SIGNAL(opened())); + QVERIFY(openedSpy.isValid()); + drawer->open(); + QVERIFY(openedSpy.count() == 1 || openedSpy.wait()); + + { + // wheel over the drawer content + qreal oldContentValue = contentSlider->value(); + qreal oldDrawerValue = drawerSlider->value(); + + QVERIFY(sendWheelEvent(drawerSlider, QPoint(drawerSlider->width() / 2, drawerSlider->height() / 2), 15)); + + QVERIFY(qFuzzyCompare(contentSlider->value(), oldContentValue)); // must not have moved + QVERIFY(!qFuzzyCompare(drawerSlider->value(), oldDrawerValue)); // must have moved + } + + { + // wheel over the overlay + qreal oldContentValue = contentSlider->value(); + qreal oldDrawerValue = drawerSlider->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(drawerSlider->value(), oldDrawerValue)); // must not have moved + } +} + +void tst_QQuickDrawer::multiple() +{ + QQuickApplicationHelper helper(this, QStringLiteral("multiple.qml")); + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickDrawer *leftDrawer = window->property("leftDrawer").value(); + QVERIFY(leftDrawer); + QQuickButton *leftButton = window->property("leftButton").value(); + QVERIFY(leftButton); + QSignalSpy leftClickSpy(leftButton, SIGNAL(clicked())); + QVERIFY(leftClickSpy.isValid()); + + QQuickDrawer *rightDrawer = window->property("rightDrawer").value(); + QVERIFY(rightDrawer); + QQuickButton *rightButton = window->property("rightButton").value(); + QVERIFY(rightButton); + QSignalSpy rightClickSpy(rightButton, SIGNAL(clicked())); + QVERIFY(rightClickSpy.isValid()); + + QQuickButton *contentButton = window->property("contentButton").value(); + QVERIFY(contentButton); + QSignalSpy contentClickSpy(contentButton, SIGNAL(clicked())); + QVERIFY(contentClickSpy.isValid()); + + // no drawers open, click the content + QTest::mouseClick(window, Qt::LeftButton); + QCOMPARE(contentClickSpy.count(), 1); + QCOMPARE(leftClickSpy.count(), 0); + QCOMPARE(rightClickSpy.count(), 0); + + // drag the left drawer open + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(0, window->height() / 2)); + QTest::mouseMove(window, QPoint(leftDrawer->width() / 4, window->height() / 2)); + QTest::mouseMove(window, QPoint(leftDrawer->width() / 4 * 3, window->height() / 2)); + QCOMPARE(leftDrawer->position(), 0.5); + QCOMPARE(rightDrawer->position(), 0.0); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(leftDrawer->width() / 2, window->height() / 2)); + QTRY_COMPARE(leftDrawer->position(), 1.0); + QCOMPARE(rightDrawer->position(), 0.0); + + // cannot drag the right drawer while the left drawer is open + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() - 1, window->height() / 2)); + QTest::mouseMove(window, QPoint(window->width() - leftDrawer->width() / 2, window->height() / 2)); + QCOMPARE(leftDrawer->position(), 1.0); + QCOMPARE(rightDrawer->position(), 0.0); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() - leftDrawer->width() / 2, window->height() / 2)); + QCOMPARE(rightDrawer->position(), 0.0); + QCOMPARE(leftDrawer->position(), 1.0); + + // open the right drawer below the left drawer + rightDrawer->open(); + QTRY_COMPARE(rightDrawer->position(), 1.0); + + // click the left drawer's button + QTest::mouseClick(window, Qt::LeftButton); + QCOMPARE(contentClickSpy.count(), 1); + QCOMPARE(leftClickSpy.count(), 1); + QCOMPARE(rightClickSpy.count(), 0); + + // click the left drawer's background (button disabled, don't leak through to the right drawer below) + leftButton->setEnabled(false); + QTest::mouseClick(window, Qt::LeftButton); + QCOMPARE(contentClickSpy.count(), 1); + QCOMPARE(leftClickSpy.count(), 1); + QCOMPARE(rightClickSpy.count(), 0); + leftButton->setEnabled(true); + + // click the overlay of the left drawer (don't leak through to right drawer below) + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() - (window->width() - leftDrawer->width()) / 2, window->height() / 2)); + QCOMPARE(contentClickSpy.count(), 1); + QCOMPARE(leftClickSpy.count(), 1); + QCOMPARE(rightClickSpy.count(), 0); + QTRY_VERIFY(!leftDrawer->isVisible()); + + // click the right drawer's button + QTest::mouseClick(window, Qt::LeftButton); + QCOMPARE(contentClickSpy.count(), 1); + QCOMPARE(leftClickSpy.count(), 1); + QCOMPARE(rightClickSpy.count(), 1); + + // cannot drag the left drawer while the right drawer is open + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(0, window->height() / 2)); + QTest::mouseMove(window, QPoint(leftDrawer->width() / 2, window->height() / 2)); + QCOMPARE(leftDrawer->position(), 0.0); + QCOMPARE(rightDrawer->position(), 1.0); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(leftDrawer->width() / 2, window->height() / 2)); + QCOMPARE(leftDrawer->position(), 0.0); + QCOMPARE(rightDrawer->position(), 1.0); + + // click the right drawer's background (button disabled, don't leak through to the content below) + rightButton->setEnabled(false); + QTest::mouseClick(window, Qt::LeftButton); + QCOMPARE(contentClickSpy.count(), 1); + QCOMPARE(leftClickSpy.count(), 1); + QCOMPARE(rightClickSpy.count(), 1); + rightButton->setEnabled(true); + + // click the overlay of the right drawer (don't leak through to the content below) + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint((window->width() - rightDrawer->width()) / 2, window->height() / 2)); + QCOMPARE(contentClickSpy.count(), 1); + QCOMPARE(leftClickSpy.count(), 1); + QCOMPARE(rightClickSpy.count(), 1); + QTRY_VERIFY(!rightDrawer->isVisible()); + + // no drawers open, click the content + QTest::mouseClick(window, Qt::LeftButton); + QCOMPARE(contentClickSpy.count(), 2); + QCOMPARE(leftClickSpy.count(), 1); + QCOMPARE(rightClickSpy.count(), 1); + + // drag the right drawer open + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() - 1, window->height() / 2)); + QTest::mouseMove(window, QPoint(window->width() - rightDrawer->width() / 4, window->height() / 2)); + QTest::mouseMove(window, QPoint(window->width() - rightDrawer->width() / 4 * 3, window->height() / 2)); + QCOMPARE(rightDrawer->position(), 0.5); + QCOMPARE(leftDrawer->position(), 0.0); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() - rightDrawer->width() / 2, window->height() / 2)); + QTRY_COMPARE(rightDrawer->position(), 1.0); + QCOMPARE(leftDrawer->position(), 0.0); +} + +void tst_QQuickDrawer::touch_data() +{ + QTest::addColumn("source"); + QTest::addColumn("from"); + QTest::addColumn("to"); + + QTest::newRow("Window:inside") << "window.qml" << QPoint(150, 100) << QPoint(50, 100); + QTest::newRow("Window:outside") << "window.qml" << QPoint(300, 100) << QPoint(100, 100); + QTest::newRow("ApplicationWindow:inside") << "applicationwindow.qml" << QPoint(150, 100) << QPoint(50, 100); + QTest::newRow("ApplicationWindow:outside") << "applicationwindow.qml" << QPoint(300, 100) << QPoint(100, 100); + + QTest::newRow("Window+Button:inside") << "window-button.qml" << QPoint(150, 100) << QPoint(50, 100); + QTest::newRow("Window+Button:outside") << "window-button.qml" << QPoint(300, 100) << QPoint(100, 100); + QTest::newRow("ApplicationWindow+Button:inside") << "applicationwindow-button.qml" << QPoint(150, 100) << QPoint(50, 100); + QTest::newRow("ApplicationWindow+Button:outside") << "applicationwindow-button.qml" << QPoint(300, 100) << QPoint(100, 100); +} + +void tst_QQuickDrawer::touch() +{ + QFETCH(QString, source); + QFETCH(QPoint, from); + QFETCH(QPoint, to); + + QQuickApplicationHelper helper(this, source); + + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickDrawer *drawer = window->property("drawer").value(); + QVERIFY(drawer); + + QSignalSpy drawerOpenedSpy(drawer, SIGNAL(opened())); + QSignalSpy drawerClosedSpy(drawer, SIGNAL(closed())); + QVERIFY(drawerOpenedSpy.isValid()); + QVERIFY(drawerClosedSpy.isValid()); + + // drag to open + QTest::touchEvent(window, touchDevice.data()).press(0, QPoint(0, 100)); + QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(50, 100)); + QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(150, 100)); + QTest::touchEvent(window, touchDevice.data()).release(0, QPoint(150, 100)); + QVERIFY(drawerOpenedSpy.wait()); + QCOMPARE(drawer->position(), 1.0); + + // drag to close + QTest::touchEvent(window, touchDevice.data()).press(0, from); + for (int x = from.x(); x > to.x(); x -= 10) + QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(x, to.y())); + QTest::touchEvent(window, touchDevice.data()).move(0, to); + QTest::touchEvent(window, touchDevice.data()).release(0, to); + QVERIFY(drawerClosedSpy.wait()); + QCOMPARE(drawer->position(), 0.0); +} + +void tst_QQuickDrawer::multiTouch() +{ + QQuickApplicationHelper helper(this, QStringLiteral("multiTouch.qml")); + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickOverlay *overlay = QQuickOverlay::overlay(window); + QVERIFY(overlay); + + QQuickDrawer *drawer = window->property("drawer").value(); + QVERIFY(drawer); + + QQuickPopup *popup = window->property("popup").value(); + QVERIFY(popup); + + QQuickButton *button = window->property("button").value(); + QVERIFY(button); + + QSignalSpy overlayPressedSpy(overlay, SIGNAL(pressed())); + QSignalSpy overlayReleasedSpy(overlay, SIGNAL(released())); + QVERIFY(overlayPressedSpy.isValid()); + QVERIFY(overlayReleasedSpy.isValid()); + + QSignalSpy drawerOpenedSpy(drawer, SIGNAL(opened())); + QVERIFY(drawerOpenedSpy.isValid()); + + QSignalSpy buttonPressedSpy(button, SIGNAL(pressed())); + QSignalSpy buttonReleasedSpy(button, SIGNAL(released())); + QVERIFY(buttonPressedSpy.isValid()); + QVERIFY(buttonReleasedSpy.isValid()); + + popup->open(); + QVERIFY(popup->isVisible()); + + drawer->open(); + QVERIFY(drawer->isVisible()); + QVERIFY(drawerOpenedSpy.wait()); + + // 1st press + QTest::touchEvent(window, touchDevice.data()).press(0, QPoint(300, 100)); + QVERIFY(popup->isVisible()); + QVERIFY(drawer->isVisible()); + QCOMPARE(buttonPressedSpy.count(), 0); + QCOMPARE(overlayPressedSpy.count(), 1); + + // 2nd press (blocked & ignored) + QTest::touchEvent(window, touchDevice.data()).stationary(0).press(1, QPoint(300, 200)); + QVERIFY(popup->isVisible()); + QVERIFY(drawer->isVisible()); + QCOMPARE(buttonPressedSpy.count(), 0); + QCOMPARE(overlayPressedSpy.count(), 2); + + // 2nd release (blocked & ignored) + QTest::touchEvent(window, touchDevice.data()).stationary(0).release(1, QPoint(300, 200)); + QVERIFY(popup->isVisible()); + QVERIFY(drawer->isVisible()); + QCOMPARE(buttonPressedSpy.count(), 0); + QCOMPARE(buttonReleasedSpy.count(), 0); + QCOMPARE(overlayPressedSpy.count(), 2); + QCOMPARE(overlayReleasedSpy.count(), 1); + + // 1st release + QTest::touchEvent(window, touchDevice.data()).release(0, QPoint(300, 100)); + QVERIFY(popup->isVisible()); + QTRY_VERIFY(!drawer->isVisible()); + QCOMPARE(buttonPressedSpy.count(), 0); + QCOMPARE(buttonReleasedSpy.count(), 0); + QCOMPARE(overlayPressedSpy.count(), 2); + QCOMPARE(overlayReleasedSpy.count(), 2); + + drawer->open(); + QVERIFY(drawer->isVisible()); + QVERIFY(drawerOpenedSpy.wait()); + + // 1st drag + QTest::touchEvent(window, touchDevice.data()).press(0, QPoint(300, 100)); + QCOMPARE(buttonPressedSpy.count(), 0); + QCOMPARE(overlayPressedSpy.count(), 3); + for (int x = 300; x >= 100; x -= 10) { + QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(x, 100)); + QVERIFY(popup->isVisible()); + QVERIFY(drawer->isVisible()); + } + QCOMPARE(drawer->position(), 0.5); + + // 2nd drag (blocked & ignored) + QTest::touchEvent(window, touchDevice.data()).stationary(0).press(1, QPoint(300, 200)); + QCOMPARE(buttonPressedSpy.count(), 0); + QCOMPARE(overlayPressedSpy.count(), 4); + for (int x = 300; x >= 0; x -= 10) { + QTest::touchEvent(window, touchDevice.data()).stationary(0).move(1, QPoint(x, 200)); + QVERIFY(popup->isVisible()); + QVERIFY(drawer->isVisible()); + } + QCOMPARE(drawer->position(), 0.5); + + // 2nd release (blocked & ignored) + QTest::touchEvent(window, touchDevice.data()).stationary(0).release(1, QPoint(300, 0)); + QVERIFY(popup->isVisible()); + QVERIFY(drawer->isVisible()); + QCOMPARE(drawer->position(), 0.5); + QCOMPARE(buttonReleasedSpy.count(), 0); + QCOMPARE(overlayReleasedSpy.count(), 3); + + // 1st release + QTest::touchEvent(window, touchDevice.data()).release(0, QPoint(300, 100)); + QVERIFY(popup->isVisible()); + QTRY_VERIFY(!drawer->isVisible()); + QCOMPARE(buttonReleasedSpy.count(), 0); + QCOMPARE(overlayReleasedSpy.count(), 4); +} + +void tst_QQuickDrawer::grabber() +{ + QQuickApplicationHelper helper(this, QStringLiteral("grabber.qml")); + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickDrawer *drawer = window->property("drawer").value(); + QVERIFY(drawer); + + QSignalSpy drawerOpenedSpy(drawer, SIGNAL(opened())); + QSignalSpy drawerClosedSpy(drawer, SIGNAL(closed())); + QVERIFY(drawerOpenedSpy.isValid()); + QVERIFY(drawerClosedSpy.isValid()); + + drawer->open(); + QVERIFY(drawerOpenedSpy.wait()); + + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(300, 100)); + QVERIFY(drawerClosedSpy.wait()); + + QQuickPopup *popup = window->property("popup").value(); + QVERIFY(popup); + + QSignalSpy popupOpenedSpy(popup, SIGNAL(opened())); + QSignalSpy popupClosedSpy(popup, SIGNAL(closed())); + QVERIFY(popupOpenedSpy.isValid()); + QVERIFY(popupClosedSpy.isValid()); + + popup->open(); + QTRY_COMPARE(popupOpenedSpy.count(), 1); + + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(100, 300)); + QTRY_COMPARE(popupClosedSpy.count(), 1); +} + +void tst_QQuickDrawer::interactive_data() +{ + QTest::addColumn("source"); + QTest::newRow("Window") << "window.qml"; + QTest::newRow("ApplicationWindow") << "applicationwindow.qml"; +} + +void tst_QQuickDrawer::interactive() +{ + QFETCH(QString, source); + QQuickApplicationHelper helper(this, source); + + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickDrawer *drawer = window->property("drawer").value(); + QVERIFY(drawer); + + drawer->setInteractive(false); + + QSignalSpy openedSpy(drawer, SIGNAL(opened())); + QSignalSpy aboutToHideSpy(drawer, SIGNAL(aboutToHide())); + QVERIFY(openedSpy.isValid()); + QVERIFY(aboutToHideSpy.isValid()); + + drawer->open(); + QVERIFY(openedSpy.wait()); + + // click outside + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(300, 100)); + QCOMPARE(aboutToHideSpy.count(), 0); + + // drag inside + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(drawer->width(), 0)); + QTest::mouseMove(window, QPoint(0, 0)); + QCOMPARE(drawer->position(), 1.0); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(0, 0)); + QCOMPARE(drawer->position(), 1.0); + QCOMPARE(aboutToHideSpy.count(), 0); + + // drag outside + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(window->width() - 1, 0)); + QTest::mouseMove(window, QPoint(0, 0)); + QCOMPARE(drawer->position(), 1.0); + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(0, 0)); + QCOMPARE(drawer->position(), 1.0); + QCOMPARE(aboutToHideSpy.count(), 0); + + // close on escape + QTest::keyClick(window, Qt::Key_Escape); + QCOMPARE(aboutToHideSpy.count(), 0); +} + +void tst_QQuickDrawer::flickable_data() +{ + QTest::addColumn("mouse"); + QTest::addColumn("from"); + QTest::addColumn("to"); + + QTest::newRow("mouse,straight") << true << QPoint(200, 200) << QPoint(200, 100); + QTest::newRow("mouse,diagonal") << true << QPoint(200, 200) << QPoint(250, 100); + QTest::newRow("touch,straight") << false << QPoint(200, 200) << QPoint(200, 100); + QTest::newRow("touch,diagonal") << false << QPoint(200, 200) << QPoint(250, 100); +} + +void tst_QQuickDrawer::flickable() +{ + QFETCH(bool, mouse); + QFETCH(QPoint, from); + QFETCH(QPoint, to); + + QQuickApplicationHelper helper(this, QStringLiteral("flickable.qml")); + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickDrawer *drawer = window->property("drawer").value(); + QVERIFY(drawer); + + QQuickFlickable *flickable = window->property("flickable").value(); + QVERIFY(flickable); + + QSignalSpy drawerOpenedSpy(drawer, SIGNAL(opened())); + QVERIFY(drawerOpenedSpy.isValid()); + + drawer->open(); + QVERIFY(drawerOpenedSpy.wait()); + + if (mouse) + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, from); + else + QTest::touchEvent(window, touchDevice.data()).press(0, from); + + static const int steps = 10; + for (int i = 0; i < steps; ++i) { + int x = i * qAbs(from.x() - to.x()) / steps; + int y = i * qAbs(from.y() - to.y()) / steps; + + if (mouse) + QTest::mouseMove(window, QPoint(x, y)); + else + QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(x, y)); + QTest::qWait(1); // avoid infinite velocity + } + + QVERIFY(flickable->isDragging()); + + if (mouse) + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, to); + else + QTest::touchEvent(window, touchDevice.data()).release(0, to); + + QVERIFY(!flickable->isDragging()); +} + +void tst_QQuickDrawer::dragOverModalShadow_data() +{ + QTest::addColumn("mouse"); + QTest::newRow("mouse") << true; + QTest::newRow("touch") << false; +} + +// QTBUG-60602 +void tst_QQuickDrawer::dragOverModalShadow() +{ + QFETCH(bool, mouse); + + QQuickApplicationHelper helper(this, QStringLiteral("dragOverModalShadow.qml")); + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickDrawer *drawer = window->property("drawer").value(); + QVERIFY(drawer); + + QQuickPopup *popup = window->property("popup").value(); + QVERIFY(popup); + + popup->open(); + QVERIFY(popup->isVisible()); + QVERIFY(!drawer->isVisible()); + + const QPoint from(popup->x(), popup->y() + popup->height() + 5); + const QPoint to(popup->x() + popup->width(), popup->y() + popup->height() + 5); + + if (mouse) + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, from); + else + QTest::touchEvent(window, touchDevice.data()).press(0, from); + QVERIFY(!drawer->isVisible()); + + static const int steps = 10; + for (int i = 0; i < steps; ++i) { + int x = from.x() + i * qAbs(from.x() - to.x()) / steps; + int y = from.y() + i * qAbs(from.y() - to.y()) / steps; + + if (mouse) + QTest::mouseMove(window, QPoint(x, y)); + else + QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(x, y)); + QTest::qWait(1); // avoid infinite velocity + QVERIFY(!drawer->isVisible()); + } + + if (mouse) + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, to); + else + QTest::touchEvent(window, touchDevice.data()).release(0, to); + QVERIFY(!drawer->isVisible()); +} + +void tst_QQuickDrawer::nonModal_data() +{ + QTest::addColumn("mouse"); + QTest::newRow("mouse") << true; + QTest::newRow("touch") << false; +} + +// QTBUG-59652 +void tst_QQuickDrawer::nonModal() +{ + QFETCH(bool, mouse); + + QQuickApplicationHelper helper(this, QStringLiteral("window.qml")); + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickDrawer *drawer = window->property("drawer").value(); + QVERIFY(drawer); + drawer->setModal(false); + + const QPoint from(1, 1); + const QPoint to(150, 1); + + // drag to open + QSignalSpy openedSpy(drawer, SIGNAL(opened())); + QVERIFY(openedSpy.isValid()); + + if (mouse) + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, from); + else + QTest::touchEvent(window, touchDevice.data()).press(0, from); + + static const int steps = 10; + for (int i = 0; i < steps; ++i) { + int x = i * qAbs(from.x() - to.x()) / steps; + int y = i * qAbs(from.y() - to.y()) / steps; + + if (mouse) + QTest::mouseMove(window, QPoint(x, y)); + else + QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(x, y)); + QTest::qWait(1); // avoid infinite velocity + } + QVERIFY(drawer->isVisible()); + + if (mouse) + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, to); + else + QTest::touchEvent(window, touchDevice.data()).release(0, to); + QVERIFY(openedSpy.wait()); + + // drag to close + QSignalSpy closedSpy(drawer, SIGNAL(closed())); + QVERIFY(closedSpy.isValid()); + + if (mouse) + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, to); + else + QTest::touchEvent(window, touchDevice.data()).press(0, to); + + for (int i = steps - 1; i >= 0; --i) { + int x = i * qAbs(from.x() - to.x()) / steps; + int y = i * qAbs(from.y() - to.y()) / steps; + + if (mouse) + QTest::mouseMove(window, QPoint(x, y)); + else + QTest::touchEvent(window, touchDevice.data()).move(0, QPoint(x, y)); + QTest::qWait(1); // avoid infinite velocity + } + QVERIFY(drawer->isVisible()); + + if (mouse) + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, from); + else + QTest::touchEvent(window, touchDevice.data()).release(0, from); + QVERIFY(closedSpy.wait()); +} + +QTEST_MAIN(tst_QQuickDrawer) + +#include "tst_qquickdrawer.moc" -- cgit v1.2.3 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 --- 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 +++++++++++++++++++++ 33 files changed, 2140 insertions(+), 2140 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 (limited to 'tests/auto') 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 From 125c08cad177edf8baba9a6ca84425255db9c500 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 27 Sep 2017 14:48:17 +0200 Subject: Rename tst_applicationwindow to tst_QQuickApplicationWindow Change-Id: If9fc2bb41cf251af71479b25656240e0d3c238d8 Reviewed-by: Mitch Curtis --- tests/auto/applicationwindow/applicationwindow.pro | 15 - .../applicationwindow/data/activeFocusControl.qml | 115 --- .../applicationwindow/data/activefocusontab.qml | 94 --- .../applicationwindow/data/attachedProperties.qml | 190 ----- .../data/basicapplicationwindow.qml | 56 -- .../data/clearfocusondestruction.qml | 74 -- tests/auto/applicationwindow/data/defaultFocus.qml | 69 -- tests/auto/applicationwindow/data/fill.qml | 79 -- .../data/focusAfterPopupClosed.qml | 111 --- tests/auto/applicationwindow/data/font.qml | 97 --- tests/auto/applicationwindow/data/layout.qml | 61 -- tests/auto/applicationwindow/data/locale.qml | 77 -- .../applicationwindow/tst_applicationwindow.cpp | 838 --------------------- tests/auto/auto.pro | 4 +- .../data/activeFocusControl.qml | 115 +++ .../data/activefocusontab.qml | 94 +++ .../data/attachedProperties.qml | 190 +++++ .../data/basicapplicationwindow.qml | 56 ++ .../data/clearfocusondestruction.qml | 74 ++ .../qquickapplicationwindow/data/defaultFocus.qml | 69 ++ tests/auto/qquickapplicationwindow/data/fill.qml | 79 ++ .../data/focusAfterPopupClosed.qml | 111 +++ tests/auto/qquickapplicationwindow/data/font.qml | 97 +++ tests/auto/qquickapplicationwindow/data/layout.qml | 61 ++ tests/auto/qquickapplicationwindow/data/locale.qml | 77 ++ .../qquickapplicationwindow.pro | 15 + .../tst_qquickapplicationwindow.cpp | 838 +++++++++++++++++++++ 27 files changed, 1878 insertions(+), 1878 deletions(-) delete mode 100644 tests/auto/applicationwindow/applicationwindow.pro delete mode 100644 tests/auto/applicationwindow/data/activeFocusControl.qml delete mode 100644 tests/auto/applicationwindow/data/activefocusontab.qml delete mode 100644 tests/auto/applicationwindow/data/attachedProperties.qml delete mode 100644 tests/auto/applicationwindow/data/basicapplicationwindow.qml delete mode 100644 tests/auto/applicationwindow/data/clearfocusondestruction.qml delete mode 100644 tests/auto/applicationwindow/data/defaultFocus.qml delete mode 100644 tests/auto/applicationwindow/data/fill.qml delete mode 100644 tests/auto/applicationwindow/data/focusAfterPopupClosed.qml delete mode 100644 tests/auto/applicationwindow/data/font.qml delete mode 100644 tests/auto/applicationwindow/data/layout.qml delete mode 100644 tests/auto/applicationwindow/data/locale.qml delete mode 100644 tests/auto/applicationwindow/tst_applicationwindow.cpp create mode 100644 tests/auto/qquickapplicationwindow/data/activeFocusControl.qml create mode 100644 tests/auto/qquickapplicationwindow/data/activefocusontab.qml create mode 100644 tests/auto/qquickapplicationwindow/data/attachedProperties.qml create mode 100644 tests/auto/qquickapplicationwindow/data/basicapplicationwindow.qml create mode 100644 tests/auto/qquickapplicationwindow/data/clearfocusondestruction.qml create mode 100644 tests/auto/qquickapplicationwindow/data/defaultFocus.qml create mode 100644 tests/auto/qquickapplicationwindow/data/fill.qml create mode 100644 tests/auto/qquickapplicationwindow/data/focusAfterPopupClosed.qml create mode 100644 tests/auto/qquickapplicationwindow/data/font.qml create mode 100644 tests/auto/qquickapplicationwindow/data/layout.qml create mode 100644 tests/auto/qquickapplicationwindow/data/locale.qml create mode 100644 tests/auto/qquickapplicationwindow/qquickapplicationwindow.pro create mode 100644 tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp (limited to 'tests/auto') diff --git a/tests/auto/applicationwindow/applicationwindow.pro b/tests/auto/applicationwindow/applicationwindow.pro deleted file mode 100644 index f94641c7..00000000 --- a/tests/auto/applicationwindow/applicationwindow.pro +++ /dev/null @@ -1,15 +0,0 @@ -CONFIG += testcase -TARGET = tst_applicationwindow -SOURCES += tst_applicationwindow.cpp - -macos:CONFIG -= app_bundle - -QT += core-private gui-private qml-private quick-private quicktemplates2-private quickcontrols2-private testlib - -include (../shared/util.pri) - -TESTDATA = data/* - -OTHER_FILES += \ - data/*.qml - diff --git a/tests/auto/applicationwindow/data/activeFocusControl.qml b/tests/auto/applicationwindow/data/activeFocusControl.qml deleted file mode 100644 index 940e8e08..00000000 --- a/tests/auto/applicationwindow/data/activeFocusControl.qml +++ /dev/null @@ -1,115 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.6 -import QtQuick.Controls 2.1 - -ApplicationWindow { - width: 400 - height: 400 - - property alias container_column: column - property alias textInput_column: ti_column - property alias textEdit_column: te_column - property alias textField_column: tf_column - property alias textArea_column: ta_column - property alias spinBox_column: sp_column - property alias spinContent_column: sp_column.contentItem - - property alias container_frame: frame - property alias textInput_frame: ti_frame - property alias textEdit_frame: te_frame - property alias textField_frame: tf_frame - property alias textArea_frame: ta_frame - property alias spinBox_frame: sp_frame - property alias spinContent_frame: sp_frame.contentItem - - Column { - id: column - - TextInput { - id: ti_column - } - TextEdit { - id: te_column - } - TextField { - id: tf_column - } - TextArea { - id: ta_column - } - SpinBox { - id: sp_column - } - } - - Frame { - id: frame - - Column { - TextInput { - id: ti_frame - } - TextEdit { - id: te_frame - } - TextField { - id: tf_frame - } - TextArea { - id: ta_frame - } - SpinBox { - id: sp_frame - } - } - } -} diff --git a/tests/auto/applicationwindow/data/activefocusontab.qml b/tests/auto/applicationwindow/data/activefocusontab.qml deleted file mode 100644 index 357ea9a4..00000000 --- a/tests/auto/applicationwindow/data/activefocusontab.qml +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.6 -import QtQuick.Controls 2.1 - -ApplicationWindow { - title: "Test Application Window" - width: 100 - height: 100 - Item { - id: main - objectName: "main" - width: 100 - height: 100 - //focus: true - Column { - anchors.fill: parent - id: column - objectName: "column" - Item { - id: sub1 - objectName: "sub1" - activeFocusOnTab: true - Accessible.role: Accessible.Table - width: 100 - height: 50 - Rectangle { - anchors.fill: parent - color: parent.activeFocus ? "red" : "black" - } - } - Item { - id: sub2 - objectName: "sub2" - activeFocusOnTab: true - Accessible.role: Accessible.Table - width: 100 - height: 50 - Rectangle { - anchors.fill: parent - color: parent.activeFocus ? "red" : "black" - } - } - } - } -} diff --git a/tests/auto/applicationwindow/data/attachedProperties.qml b/tests/auto/applicationwindow/data/attachedProperties.qml deleted file mode 100644 index 09bc47ef..00000000 --- a/tests/auto/applicationwindow/data/attachedProperties.qml +++ /dev/null @@ -1,190 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.6 -import QtQuick.Window 2.2 -import QtQuick.Controls 2.1 - -ApplicationWindow { - property alias childControl: childControl - property alias childItem: childItem - property alias childObject: childObject - - Control { - id: childControl - - property ApplicationWindow attached_window: ApplicationWindow.window - property Item attached_contentItem: ApplicationWindow.contentItem - property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl - property Item attached_header: ApplicationWindow.header - property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay - } - - Item { - id: childItem - - property ApplicationWindow attached_window: ApplicationWindow.window - property Item attached_contentItem: ApplicationWindow.contentItem - property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl - property Item attached_header: ApplicationWindow.header - property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay - } - - QtObject { - id: childObject - - property ApplicationWindow attached_window: ApplicationWindow.window - property Item attached_contentItem: ApplicationWindow.contentItem - property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl - property Item attached_header: ApplicationWindow.header - property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay - } - - property alias childWindow: childWindow - property alias childWindowControl: childWindowControl - property alias childWindowItem: childWindowItem - property alias childWindowObject: childWindowObject - - Window { - id: childWindow - - property ApplicationWindow attached_window: ApplicationWindow.window - property Item attached_contentItem: ApplicationWindow.contentItem - property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl - property Item attached_header: ApplicationWindow.header - property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay - - Control { - id: childWindowControl - - property ApplicationWindow attached_window: ApplicationWindow.window - property Item attached_contentItem: ApplicationWindow.contentItem - property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl - property Item attached_header: ApplicationWindow.header - property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay - } - - Item { - id: childWindowItem - - property ApplicationWindow attached_window: ApplicationWindow.window - property Item attached_contentItem: ApplicationWindow.contentItem - property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl - property Item attached_header: ApplicationWindow.header - property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay - } - - QtObject { - id: childWindowObject - - property ApplicationWindow attached_window: ApplicationWindow.window - property Item attached_contentItem: ApplicationWindow.contentItem - property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl - property Item attached_header: ApplicationWindow.header - property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay - } - } - - property alias childAppWindow: childAppWindow - property alias childAppWindowControl: childAppWindowControl - property alias childAppWindowItem: childAppWindowItem - property alias childAppWindowObject: childAppWindowObject - - ApplicationWindow { - id: childAppWindow - - property ApplicationWindow attached_window: ApplicationWindow.window - property Item attached_contentItem: ApplicationWindow.contentItem - property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl - property Item attached_header: ApplicationWindow.header - property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay - - Control { - id: childAppWindowControl - - property ApplicationWindow attached_window: ApplicationWindow.window - property Item attached_contentItem: ApplicationWindow.contentItem - property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl - property Item attached_header: ApplicationWindow.header - property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay - } - - Item { - id: childAppWindowItem - - property ApplicationWindow attached_window: ApplicationWindow.window - property Item attached_contentItem: ApplicationWindow.contentItem - property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl - property Item attached_header: ApplicationWindow.header - property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay - } - - QtObject { - id: childAppWindowObject - - property ApplicationWindow attached_window: ApplicationWindow.window - property Item attached_contentItem: ApplicationWindow.contentItem - property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl - property Item attached_header: ApplicationWindow.header - property Item attached_footer: ApplicationWindow.footer - property Item attached_overlay: ApplicationWindow.overlay - } - } -} diff --git a/tests/auto/applicationwindow/data/basicapplicationwindow.qml b/tests/auto/applicationwindow/data/basicapplicationwindow.qml deleted file mode 100644 index 16182f59..00000000 --- a/tests/auto/applicationwindow/data/basicapplicationwindow.qml +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.6 -import QtQuick.Controls 2.1 - -ApplicationWindow { - title: "Test Application Window" -} diff --git a/tests/auto/applicationwindow/data/clearfocusondestruction.qml b/tests/auto/applicationwindow/data/clearfocusondestruction.qml deleted file mode 100644 index 3589439e..00000000 --- a/tests/auto/applicationwindow/data/clearfocusondestruction.qml +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.7 -import QtQuick.Controls 2.1 -import QtQuick.Layouts 1.3 -import QtGraphicalEffects 1.0 - -ApplicationWindow { - width: 200 - height: 200 - visible: true - - property alias textfield: textfield - - /* - * The code below is the simplest way we can trigger that the signal - * activeFocusItemChanged() is emitted during destruction of the - * ApplicationWindow. This caused a crash in QQuickApplicationWindow. - */ - FastBlur { - id: fastBlur - anchors.fill: parent - radius: 30 - source: ShaderEffectSource { - id: effectsource - sourceItem: textfield - sourceRect: Qt.rect( 0, 0, fastBlur.width, fastBlur.height ) - } - } - - TextField { - id: textfield - anchors.bottom: parent.bottom - focus: true - } -} diff --git a/tests/auto/applicationwindow/data/defaultFocus.qml b/tests/auto/applicationwindow/data/defaultFocus.qml deleted file mode 100644 index 741ce908..00000000 --- a/tests/auto/applicationwindow/data/defaultFocus.qml +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.6 -import QtQuick.Controls 2.1 - -ApplicationWindow { - visible: true - width: 200 - height: 200 - - property bool receivedKeyPress: false - - Item { - objectName: "item" - focus: true - anchors.fill: parent - - Keys.onLeftPressed: receivedKeyPress = true - } -} - diff --git a/tests/auto/applicationwindow/data/fill.qml b/tests/auto/applicationwindow/data/fill.qml deleted file mode 100644 index 27b10d34..00000000 --- a/tests/auto/applicationwindow/data/fill.qml +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.6 -import QtQuick.Controls 2.1 - -ApplicationWindow { - width: 400 - height: 400 - - property alias stackView: stackView - property alias nextItem: nextItem - - function pushNextItem() { - stackView.push(nextItem, StackView.Immediate); - } - - Rectangle { - id: nextItem - color: "blue" - visible: false - } - - StackView { - id: stackView - anchors.fill: parent - - initialItem: Rectangle { - color: "red" - } - } -} diff --git a/tests/auto/applicationwindow/data/focusAfterPopupClosed.qml b/tests/auto/applicationwindow/data/focusAfterPopupClosed.qml deleted file mode 100644 index f0499a3a..00000000 --- a/tests/auto/applicationwindow/data/focusAfterPopupClosed.qml +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.6 -import QtQuick.Controls 2.1 - -ApplicationWindow { - width: 200 - height: 200 - visible: true - - signal focusScopeKeyPressed - signal focusPopupKeyPressed - - property alias fileMenu: fileMenu - property alias toolButton: toolButton - property alias focusScope: focusScope - property alias focusPopup: focusPopup - - header: ToolBar { - ToolButton { - id: toolButton - text: qsTr("File") - onClicked: fileMenu.open() - focusPolicy: Qt.TabFocus - - Menu { - id: fileMenu - y: parent.height - - MenuItem { - text: qsTr("New") - } - MenuItem { - text: qsTr("Open") - } - MenuItem { - text: qsTr("Close") - } - } - } - } - - FocusScope { - id: focusScope - focus: true - anchors.fill: parent - - Keys.onSpacePressed: focusScopeKeyPressed() - } - - Popup { - id: focusPopup - focus: true - width: parent.width - height: parent.height - - Item { - focus: true - Keys.onSpacePressed: focusPopupKeyPressed() - } - } -} - diff --git a/tests/auto/applicationwindow/data/font.qml b/tests/auto/applicationwindow/data/font.qml deleted file mode 100644 index a675aeab..00000000 --- a/tests/auto/applicationwindow/data/font.qml +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.6 -import QtQuick.Controls 2.1 -import QtQuick.Templates 2.1 as T - -ApplicationWindow { - objectName: "appWin" - width: 400 - height: 400 - - property alias mainItem: mainItem - - font.family: "Arial" - - T.Control { - id: mainItem - objectName: "mainItem" - anchors.fill: parent - property alias item_2: _item_2; - property alias item_3: _item_3; - property alias item_4: _item_4; - property alias item_5: _item_5; - property alias item_6: _item_6; - T.Control { - id: _item_2 - objectName: "_item_2" - T.Control { - id: _item_3 - objectName: "_item_3" - } - } - T.TextArea { - id: _item_4 - objectName: "_item_4" - text: "Text Area" - } - T.TextField { - id: _item_5 - objectName: "_item_5" - text: "Text Field" - } - T.Label { - id: _item_6 - objectName: "_item_6" - text: "Label" - } - } -} diff --git a/tests/auto/applicationwindow/data/layout.qml b/tests/auto/applicationwindow/data/layout.qml deleted file mode 100644 index a80b2d48..00000000 --- a/tests/auto/applicationwindow/data/layout.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.6 -import QtQuick.Controls 2.0 - -ApplicationWindow { - width: 200 - height: 200 - visible: true - - header: ToolBar { } - footer: ToolBar { } -} diff --git a/tests/auto/applicationwindow/data/locale.qml b/tests/auto/applicationwindow/data/locale.qml deleted file mode 100644 index 92edb53a..00000000 --- a/tests/auto/applicationwindow/data/locale.qml +++ /dev/null @@ -1,77 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.6 -import QtQuick.Controls 2.1 -import QtQuick.Templates 2.1 as T - -ApplicationWindow { - objectName: "appWin" - width: 400 - height: 400 - - property alias mainItem: mainItem - - T.Control { - id: mainItem - objectName: "mainItem" - anchors.fill: parent - property alias item_2: _item_2; - property alias item_3: _item_3; - T.Control { - id: _item_2 - objectName: "_item_2" - T.Control { - id: _item_3 - objectName: "_item_3" - } - } - } -} diff --git a/tests/auto/applicationwindow/tst_applicationwindow.cpp b/tests/auto/applicationwindow/tst_applicationwindow.cpp deleted file mode 100644 index f35d9b7d..00000000 --- a/tests/auto/applicationwindow/tst_applicationwindow.cpp +++ /dev/null @@ -1,838 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../shared/util.h" -#include "../shared/visualtestutil.h" - -using namespace QQuickVisualTestUtil; - -class tst_applicationwindow : public QQmlDataTest -{ - Q_OBJECT -public: - -private slots: - void qmlCreation(); - void activeFocusOnTab1(); - void activeFocusOnTab2(); - void defaultFocus(); - void implicitFill(); - void attachedProperties(); - void font(); - void defaultFont(); - void locale(); - void activeFocusControl_data(); - void activeFocusControl(); - void focusAfterPopupClosed(); - void clearFocusOnDestruction(); - void layout(); - void componentComplete(); -}; - -void tst_applicationwindow::qmlCreation() -{ - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(testFileUrl("basicapplicationwindow.qml")); - QObject* created = component.create(); - QScopedPointer cleanup(created); - QVERIFY(created); - - QQuickWindow* window = qobject_cast(created); - QVERIFY(window); - QVERIFY(!window->isVisible()); - - QCOMPARE(created->property("title"), QVariant("Test Application Window")); - - QQuickItem* statusBar = qvariant_cast(created->property("statusBar")); - QVERIFY(!statusBar); - - QQuickItem* header = qvariant_cast(created->property("header")); - QVERIFY(!header); - - QQuickItem* footer = qvariant_cast(created->property("footer")); - QVERIFY(!footer); -} - -void tst_applicationwindow::activeFocusOnTab1() -{ - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(testFileUrl("activefocusontab.qml")); - QObject* created = component.create(); - QScopedPointer cleanup(created); - QVERIFY(created); - - QQuickWindow* window = qobject_cast(created); - QVERIFY(window); - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - QVERIFY(QGuiApplication::focusWindow() == window); - - QQuickItem* contentItem = window->contentItem(); - QVERIFY(contentItem); - QVERIFY(contentItem->hasActiveFocus()); - - QQuickItem* item = findItem(window->contentItem(), "sub1"); - QVERIFY(item); - QVERIFY(!item->hasActiveFocus()); - - // Tab: contentItem->sub1 - QKeyEvent key(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem(window->contentItem(), "sub1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // Tab: sub1->sub2 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem(window->contentItem(), "sub2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // Tab: sub2->sub1 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem(window->contentItem(), "sub1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); -} - -void tst_applicationwindow::activeFocusOnTab2() -{ - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(testFileUrl("activefocusontab.qml")); - QObject* created = component.create(); - QScopedPointer cleanup(created); - QVERIFY(created); - - QQuickWindow* window = qobject_cast(created); - QVERIFY(window); - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - QVERIFY(QGuiApplication::focusWindow() == window); - - QQuickItem* contentItem = window->contentItem(); - QVERIFY(contentItem); - QVERIFY(contentItem->hasActiveFocus()); - - QQuickItem* item = findItem(window->contentItem(), "sub2"); - QVERIFY(item); - QVERIFY(!item->hasActiveFocus()); - - // BackTab: contentItem->sub2 - QKeyEvent key(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem(window->contentItem(), "sub2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // BackTab: sub2->sub1 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem(window->contentItem(), "sub1"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); - - // BackTab: sub1->sub2 - key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); - QGuiApplication::sendEvent(window, &key); - QVERIFY(key.isAccepted()); - - item = findItem(window->contentItem(), "sub2"); - QVERIFY(item); - QVERIFY(item->hasActiveFocus()); -} - -void tst_applicationwindow::defaultFocus() -{ - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(testFileUrl("defaultFocus.qml")); - QObject* created = component.create(); - QScopedPointer cleanup(created); - Q_UNUSED(cleanup); - QVERIFY(created); - - QQuickWindow* window = qobject_cast(created); - QVERIFY(window); - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - QVERIFY(QGuiApplication::focusWindow() == window); - - QQuickItem* contentItem = window->contentItem(); - QVERIFY(contentItem); - QVERIFY(contentItem->hasActiveFocus()); - - // A single item in an ApplicationWindow with focus: true should receive focus. - QQuickItem* item = findItem(window->contentItem(), "item"); - QVERIFY(item); - QVERIFY(item->hasFocus()); - QVERIFY(item->hasActiveFocus()); -} - -void tst_applicationwindow::implicitFill() -{ - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(testFileUrl("fill.qml")); - QObject* created = component.create(); - QScopedPointer cleanup(created); - QVERIFY(created); - - QQuickWindow* window = qobject_cast(created); - QVERIFY(window); - QVERIFY(!window->isVisible()); - QCOMPARE(window->width(), 400); - QCOMPARE(window->height(), 400); - - window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickItem *stackView = window->property("stackView").value(); - QVERIFY(stackView); - QCOMPARE(stackView->width(), 400.0); - QCOMPARE(stackView->height(), 400.0); - - QQuickItem *nextItem = window->property("nextItem").value(); - QVERIFY(nextItem); - - QVERIFY(QMetaObject::invokeMethod(window, "pushNextItem")); - QCOMPARE(nextItem->width(), 400.0); - QCOMPARE(nextItem->height(), 400.0); -} - -void tst_applicationwindow::attachedProperties() -{ - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(testFileUrl("attachedProperties.qml")); - - QScopedPointer object(component.create()); - QVERIFY2(!object.isNull(), qPrintable(component.errorString())); - - QQuickApplicationWindow *window = qobject_cast(object.data()); - QVERIFY(window); - - QQuickItem *childControl = object->property("childControl").value(); - QVERIFY(childControl); - QCOMPARE(childControl->property("attached_window").value(), window); - QCOMPARE(childControl->property("attached_contentItem").value(), window->contentItem()); - QCOMPARE(childControl->property("attached_activeFocusControl").value(), window->activeFocusControl()); - QCOMPARE(childControl->property("attached_header").value(), window->header()); - QCOMPARE(childControl->property("attached_footer").value(), window->footer()); - QCOMPARE(childControl->property("attached_overlay").value(), window->overlay()); - - QQuickItem *childItem = object->property("childItem").value(); - QVERIFY(childItem); - QCOMPARE(childItem->property("attached_window").value(), window); - QCOMPARE(childItem->property("attached_contentItem").value(), window->contentItem()); - QCOMPARE(childItem->property("attached_activeFocusControl").value(), window->activeFocusControl()); - QCOMPARE(childItem->property("attached_header").value(), window->header()); - QCOMPARE(childItem->property("attached_footer").value(), window->footer()); - QCOMPARE(childItem->property("attached_overlay").value(), window->overlay()); - - QObject *childObject = object->property("childObject").value(); - QVERIFY(childObject); - QVERIFY(!childObject->property("attached_window").value()); - QVERIFY(!childObject->property("attached_contentItem").value()); - QVERIFY(!childObject->property("attached_activeFocusControl").value()); - QVERIFY(!childObject->property("attached_header").value()); - QVERIFY(!childObject->property("attached_footer").value()); - QVERIFY(!childObject->property("attached_overlay").value()); - - QQuickWindow *childWindow = object->property("childWindow").value(); - QVERIFY(childWindow); - QVERIFY(!childWindow->property("attached_window").value()); - QVERIFY(!childWindow->property("attached_contentItem").value()); - QVERIFY(!childWindow->property("attached_activeFocusControl").value()); - QVERIFY(!childWindow->property("attached_header").value()); - QVERIFY(!childWindow->property("attached_footer").value()); - QVERIFY(!childWindow->property("attached_overlay").value()); - - QQuickItem *childWindowControl = object->property("childWindowControl").value(); - QVERIFY(childWindowControl); - QVERIFY(!childWindowControl->property("attached_window").value()); - QVERIFY(!childWindowControl->property("attached_contentItem").value()); - QVERIFY(!childWindowControl->property("attached_activeFocusControl").value()); - QVERIFY(!childWindowControl->property("attached_header").value()); - QVERIFY(!childWindowControl->property("attached_footer").value()); - QCOMPARE(childWindowControl->property("attached_overlay").value(), QQuickOverlay::overlay(childWindow)); - - QQuickItem *childWindowItem = object->property("childWindowItem").value(); - QVERIFY(childWindowItem); - QVERIFY(!childWindowItem->property("attached_window").value()); - QVERIFY(!childWindowItem->property("attached_contentItem").value()); - QVERIFY(!childWindowItem->property("attached_activeFocusControl").value()); - QVERIFY(!childWindowItem->property("attached_header").value()); - QVERIFY(!childWindowItem->property("attached_footer").value()); - QCOMPARE(childWindowItem->property("attached_overlay").value(), QQuickOverlay::overlay(childWindow)); - - QObject *childWindowObject = object->property("childWindowObject").value(); - QVERIFY(childWindowObject); - QVERIFY(!childWindowObject->property("attached_window").value()); - QVERIFY(!childWindowObject->property("attached_contentItem").value()); - QVERIFY(!childWindowObject->property("attached_activeFocusControl").value()); - QVERIFY(!childWindowObject->property("attached_header").value()); - QVERIFY(!childWindowObject->property("attached_footer").value()); - QVERIFY(!childWindowObject->property("attached_overlay").value()); - - QQuickApplicationWindow *childAppWindow = object->property("childAppWindow").value(); - QVERIFY(childAppWindow); - QVERIFY(!childAppWindow->property("attached_window").value()); - QVERIFY(!childAppWindow->property("attached_contentItem").value()); - QVERIFY(!childAppWindow->property("attached_activeFocusControl").value()); - QVERIFY(!childAppWindow->property("attached_header").value()); - QVERIFY(!childAppWindow->property("attached_footer").value()); - QVERIFY(!childAppWindow->property("attached_overlay").value()); - - QQuickItem *childAppWindowControl = object->property("childAppWindowControl").value(); - QVERIFY(childAppWindowControl); - QCOMPARE(childAppWindowControl->property("attached_window").value(), childAppWindow); - QCOMPARE(childAppWindowControl->property("attached_contentItem").value(), childAppWindow->contentItem()); - QCOMPARE(childAppWindowControl->property("attached_activeFocusControl").value(), childAppWindow->activeFocusControl()); - QCOMPARE(childAppWindowControl->property("attached_header").value(), childAppWindow->header()); - QCOMPARE(childAppWindowControl->property("attached_footer").value(), childAppWindow->footer()); - QCOMPARE(childAppWindowControl->property("attached_overlay").value(), childAppWindow->overlay()); - - QQuickItem *childAppWindowItem = object->property("childAppWindowItem").value(); - QVERIFY(childAppWindowItem); - QCOMPARE(childAppWindowItem->property("attached_window").value(), childAppWindow); - QCOMPARE(childAppWindowItem->property("attached_contentItem").value(), childAppWindow->contentItem()); - QCOMPARE(childAppWindowItem->property("attached_activeFocusControl").value(), childAppWindow->activeFocusControl()); - QCOMPARE(childAppWindowItem->property("attached_header").value(), childAppWindow->header()); - QCOMPARE(childAppWindowItem->property("attached_footer").value(), childAppWindow->footer()); - QCOMPARE(childAppWindowItem->property("attached_overlay").value(), childAppWindow->overlay()); - - QObject *childAppWindowObject = object->property("childAppWindowObject").value(); - QVERIFY(childAppWindowObject); - QVERIFY(!childAppWindowObject->property("attached_window").value()); - QVERIFY(!childAppWindowObject->property("attached_contentItem").value()); - QVERIFY(!childAppWindowObject->property("attached_activeFocusControl").value()); - QVERIFY(!childAppWindowObject->property("attached_header").value()); - QVERIFY(!childAppWindowObject->property("attached_footer").value()); - QVERIFY(!childAppWindowObject->property("attached_overlay").value()); - - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QVERIFY(!childControl->hasActiveFocus()); - childControl->forceActiveFocus(); - QTRY_VERIFY(childControl->hasActiveFocus()); - QCOMPARE(window->activeFocusItem(), childControl); - QCOMPARE(childControl->property("attached_activeFocusControl").value(), childControl); - - QQuickItem *header = new QQuickItem; - window->setHeader(header); - QCOMPARE(window->header(), header); - QCOMPARE(childControl->property("attached_header").value(), header); - - QQuickItem *footer = new QQuickItem; - window->setFooter(footer); - QCOMPARE(window->footer(), footer); - QCOMPARE(childControl->property("attached_footer").value(), footer); - - childAppWindow->show(); - childAppWindow->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(childAppWindow)); - - QVERIFY(!childAppWindowControl->hasActiveFocus()); - childAppWindowControl->forceActiveFocus(); - QTRY_VERIFY(childAppWindowControl->hasActiveFocus()); - QCOMPARE(childAppWindow->activeFocusItem(), childAppWindowControl); - QCOMPARE(childAppWindowControl->property("attached_activeFocusControl").value(), childAppWindowControl); - - childControl->setParentItem(childAppWindow->contentItem()); - QCOMPARE(childControl->window(), childAppWindow); - QCOMPARE(childControl->property("attached_window").value(), childAppWindow); - QCOMPARE(childControl->property("attached_contentItem").value(), childAppWindow->contentItem()); - QCOMPARE(childControl->property("attached_activeFocusControl").value(), childAppWindow->activeFocusControl()); - QCOMPARE(childControl->property("attached_header").value(), childAppWindow->header()); - QCOMPARE(childControl->property("attached_footer").value(), childAppWindow->footer()); - QCOMPARE(childControl->property("attached_overlay").value(), childAppWindow->overlay()); - - childItem->setParentItem(childAppWindow->contentItem()); - QCOMPARE(childItem->window(), childAppWindow); - QCOMPARE(childItem->property("attached_window").value(), childAppWindow); - QCOMPARE(childItem->property("attached_contentItem").value(), childAppWindow->contentItem()); - QCOMPARE(childItem->property("attached_activeFocusControl").value(), childAppWindow->activeFocusControl()); - QCOMPARE(childItem->property("attached_header").value(), childAppWindow->header()); - QCOMPARE(childItem->property("attached_footer").value(), childAppWindow->footer()); - QCOMPARE(childItem->property("attached_overlay").value(), childAppWindow->overlay()); - - childControl->setParentItem(nullptr); - QVERIFY(!childControl->window()); - QVERIFY(!childControl->property("attached_window").value()); - QVERIFY(!childControl->property("attached_contentItem").value()); - QVERIFY(!childControl->property("attached_activeFocusControl").value()); - QVERIFY(!childControl->property("attached_header").value()); - QVERIFY(!childControl->property("attached_footer").value()); - QVERIFY(!childControl->property("attached_overlay").value()); - - childItem->setParentItem(nullptr); - QVERIFY(!childItem->window()); - QVERIFY(!childItem->property("attached_window").value()); - QVERIFY(!childItem->property("attached_contentItem").value()); - QVERIFY(!childItem->property("attached_activeFocusControl").value()); - QVERIFY(!childItem->property("attached_header").value()); - QVERIFY(!childItem->property("attached_footer").value()); - QVERIFY(!childItem->property("attached_overlay").value()); - - // ### A temporary workaround to unblock the CI until the crash caused - // by https://codereview.qt-project.org/#/c/108517/ has been fixed... - window->hide(); - qApp->processEvents(); -} - -void tst_applicationwindow::font() -{ - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(testFileUrl("font.qml")); - QObject* created = component.create(); - QScopedPointer cleanup(created); - QVERIFY(created); - - QQuickApplicationWindow* window = qobject_cast(created); - QVERIFY(window); - QVERIFY(!window->isVisible()); - QCOMPARE(window->width(), 400); - QCOMPARE(window->height(), 400); - - window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QFont font = window->font(); - - QQuickControl *mainItem = window->property("mainItem").value(); - QVERIFY(mainItem); - QCOMPARE(mainItem->width(), 400.0); - QCOMPARE(mainItem->height(), 400.0); - QCOMPARE(mainItem->font(), font); - - QQuickControl *item2 = mainItem->property("item_2").value(); - QVERIFY(item2); - QQuickControl *item3 = mainItem->property("item_3").value(); - QVERIFY(item3); - QQuickTextArea *item4 = mainItem->property("item_4").value(); - QVERIFY(item4); - QQuickTextField *item5 = mainItem->property("item_5").value(); - QVERIFY(item5); - QQuickLabel *item6 = mainItem->property("item_6").value(); - QVERIFY(item6); - - QCOMPARE(item2->font(), font); - QCOMPARE(item3->font(), font); - QCOMPARE(item4->font(), font); - QCOMPARE(item5->font(), font); - QCOMPARE(item6->font(), font); - - int pointSize = font.pointSize(); - font.setPixelSize(pointSize + 5); - window->setFont(font); - - QCOMPARE(window->font(), font); - QCOMPARE(mainItem->font(), font); - QCOMPARE(item2->font(), font); - QCOMPARE(item3->font(), font); - QCOMPARE(item4->font(), font); - QCOMPARE(item5->font(), font); - QCOMPARE(item6->font(), font); -} - -class TestTheme : public QQuickProxyTheme -{ -public: - TestTheme(QPlatformTheme *theme) : QQuickProxyTheme(theme), m_font("Courier") - { QGuiApplicationPrivate::platform_theme = this; } - - const QFont *font(Font type = SystemFont) const override - { - Q_UNUSED(type); - return &m_font; - } - - QFont m_font; -}; - -void tst_applicationwindow::defaultFont() -{ - TestTheme theme(QGuiApplicationPrivate::platform_theme); - - QQmlEngine engine; - QQmlComponent component(&engine); - component.setData("import QtQuick.Controls 2.1; ApplicationWindow { }", QUrl()); - - QScopedPointer window; - window.reset(static_cast(component.create())); - QVERIFY(!window.isNull()); - QCOMPARE(window->font(), *theme.font()); -} - -void tst_applicationwindow::locale() -{ - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(testFileUrl("locale.qml")); - QObject* created = component.create(); - QScopedPointer cleanup(created); - QVERIFY(created); - - QQuickApplicationWindow* window = qobject_cast(created); - QVERIFY(window); - QVERIFY(!window->isVisible()); - QCOMPARE(window->width(), 400); - QCOMPARE(window->height(), 400); - - window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QLocale l = window->locale(); - - QQuickControl *mainItem = window->property("mainItem").value(); - QVERIFY(mainItem); - QCOMPARE(mainItem->width(), 400.0); - QCOMPARE(mainItem->height(), 400.0); - QCOMPARE(mainItem->locale(), l); - - QQuickControl *item2 = mainItem->property("item_2").value(); - QVERIFY(item2); - QQuickControl *item3 = mainItem->property("item_3").value(); - QVERIFY(item3); - - QCOMPARE(item2->locale(), l); - QCOMPARE(item3->locale(), l); - - l = QLocale("en_US"); - window->setLocale(l); - - QCOMPARE(window->locale(), l); - QCOMPARE(mainItem->locale(), l); - QCOMPARE(item2->locale(), l); - QCOMPARE(item3->locale(), l); - - l = QLocale("ar_EG"); - window->setLocale(l); - - QCOMPARE(window->locale(), l); - QCOMPARE(mainItem->locale(), l); - QCOMPARE(item2->locale(), l); - QCOMPARE(item3->locale(), l); -} - -void tst_applicationwindow::activeFocusControl_data() -{ - QTest::addColumn("containerName"); - QTest::addColumn("activeFocusItemName"); - QTest::addColumn("activeFocusControlName"); - - QTest::newRow("Column:TextInput") << QByteArray("container_column") << QByteArray("textInput_column") << QByteArray(); - QTest::newRow("Column:TextEdit") << QByteArray("container_column") << QByteArray("textEdit_column") << QByteArray(); - QTest::newRow("Column:TextField") << QByteArray("container_column") << QByteArray("textField_column") << QByteArray("textField_column"); - QTest::newRow("Column:TextArea") << QByteArray("container_column") << QByteArray("textArea_column") << QByteArray("textArea_column"); - QTest::newRow("Column:SpinBox") << QByteArray("container_column") << QByteArray("spinContent_column") << QByteArray("spinBox_column"); - - QTest::newRow("Frame:TextInput") << QByteArray("container_frame") << QByteArray("textInput_frame") << QByteArray("container_frame"); - QTest::newRow("Frame:TextEdit") << QByteArray("container_frame") << QByteArray("textEdit_frame") << QByteArray("container_frame"); - QTest::newRow("Frame:TextField") << QByteArray("container_frame") << QByteArray("textField_frame") << QByteArray("textField_frame"); - QTest::newRow("Frame:TextArea") << QByteArray("container_frame") << QByteArray("textArea_frame") << QByteArray("textArea_frame"); - QTest::newRow("Frame:SpinBox") << QByteArray("container_frame") << QByteArray("spinContent_frame") << QByteArray("spinBox_frame"); -} - -void tst_applicationwindow::activeFocusControl() -{ - QFETCH(QByteArray, containerName); - QFETCH(QByteArray, activeFocusItemName); - QFETCH(QByteArray, activeFocusControlName); - - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(testFileUrl("activeFocusControl.qml")); - QScopedPointer object(component.create()); - QVERIFY(!object.isNull()); - - QQuickApplicationWindow* window = qobject_cast(object.data()); - QVERIFY(window); - QVERIFY(!window->isVisible()); - QCOMPARE(window->width(), 400); - QCOMPARE(window->height(), 400); - - window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickItem *container = window->property(containerName).value(); - QVERIFY(container); - - QQuickItem *activeFocusItem = window->property(activeFocusItemName).value(); - QVERIFY(activeFocusItem); - activeFocusItem->forceActiveFocus(); - QVERIFY(activeFocusItem->hasActiveFocus()); - QCOMPARE(window->activeFocusItem(), activeFocusItem); - - QQuickItem *activeFocusControl = window->property(activeFocusControlName).value(); - if (activeFocusControlName.isEmpty()) { - QVERIFY(!activeFocusControl); - } else { - QVERIFY(activeFocusControl); - QVERIFY(activeFocusControl->hasActiveFocus()); - } - QCOMPARE(window->activeFocusControl(), activeFocusControl); -} - -void tst_applicationwindow::focusAfterPopupClosed() -{ - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(testFileUrl("focusAfterPopupClosed.qml")); - QScopedPointer window(qobject_cast(component.create())); - QVERIFY(window); - - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window.data())); - QVERIFY(QGuiApplication::focusWindow() == window.data()); - - QQuickItem* contentItem = window->contentItem(); - QVERIFY(contentItem); - QVERIFY(contentItem->hasActiveFocus()); - - QQuickItem* focusScope = window->property("focusScope").value(); - QVERIFY(focusScope); - QVERIFY(focusScope->hasActiveFocus()); - - QSignalSpy focusScopeSpy(window.data(), SIGNAL(focusScopeKeyPressed())); - QTest::keyClick(window.data(), Qt::Key_Space); - QCOMPARE(focusScopeSpy.count(), 1); - - // Open the menu. - QQuickItem* toolButton = window->property("toolButton").value(); - QVERIFY(toolButton); - QTest::mouseClick(window.data(), Qt::LeftButton, Qt::NoModifier, - toolButton->mapFromScene(QPointF(toolButton->width() / 2, toolButton->height() / 2)).toPoint()); - QVERIFY(!focusScope->hasActiveFocus()); - - // The FocusScope shouldn't receive any key events while the menu is open. - QTest::keyClick(window.data(), Qt::Key_Space); - QCOMPARE(focusScopeSpy.count(), 1); - - // Close the menu. The FocusScope should regain focus. - QTest::keyClick(window.data(), Qt::Key_Escape); - QVERIFY(focusScope->hasActiveFocus()); - - QTest::keyClick(window.data(), Qt::Key_Space); - QCOMPARE(focusScopeSpy.count(), 2); - - QQuickPopup *focusPopup = window->property("focusPopup").value(); - QVERIFY(focusPopup); - QVERIFY(!focusPopup->hasActiveFocus()); - - focusPopup->open(); - QVERIFY(focusPopup->isVisible()); - - QSignalSpy focusPopupSpy(window.data(), SIGNAL(focusPopupKeyPressed())); - QTest::keyClick(window.data(), Qt::Key_Space); - QCOMPARE(focusPopupSpy.count(), 1); - - QQuickMenu *fileMenu = window->property("fileMenu").value(); - QVERIFY(fileMenu); - fileMenu->open(); - QVERIFY(fileMenu->isVisible()); - - // The Popup shouldn't receive any key events while the menu is open. - QTest::keyClick(window.data(), Qt::Key_Space); - QCOMPARE(focusPopupSpy.count(), 1); - - // Close the menu. The Popup should regain focus. - QTest::keyClick(window.data(), Qt::Key_Escape); - QVERIFY(focusPopup->hasActiveFocus()); - - QTest::keyClick(window.data(), Qt::Key_Space); - QCOMPARE(focusPopupSpy.count(), 2); - - // Close the popup. The FocusScope should regain focus. - QTest::keyClick(window.data(), Qt::Key_Escape); - QVERIFY(focusScope->hasActiveFocus()); - - QTest::keyClick(window.data(), Qt::Key_Space); - QCOMPARE(focusScopeSpy.count(), 3); -} - -void tst_applicationwindow::clearFocusOnDestruction() -{ - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(testFileUrl("clearfocusondestruction.qml")); - QScopedPointer window(qobject_cast(component.create())); - QVERIFY(window); - - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window.data())); - QVERIFY(QGuiApplication::focusWindow() == window.data()); - - QQuickItem* contentItem = window->contentItem(); - QVERIFY(contentItem); - QVERIFY(contentItem->hasActiveFocus()); - - QQuickItem* focusScope = window->property("textfield").value(); - QVERIFY(focusScope); - QVERIFY(focusScope->hasActiveFocus()); - - QSignalSpy spy(window.data(), SIGNAL(activeFocusControlChanged())); - // destroy the window, do not crash - window.reset(); - - /* - QQuickWindow::activeFocusItemChanged() is emitted inconsistently and - only for certain use cases. Ideally it should be emitted whenever a - QQuickWindow with a focus item is destroyed, but it doesn't... It might - also be favorable to not emit it for performance reason. - - However, activeFocusControlChanged() is emitted more consistently, which - of course makes it inconsistent with the emission of - activeFocusItemChanged().... - - Therefore, if you have good reasons to change the behavior (and not emit - it) take the test below with a grain of salt. - */ - QCOMPARE(spy.count(), 1); -} - -void tst_applicationwindow::layout() -{ - QQmlEngine engine; - QQmlComponent component(&engine); - component.loadUrl(testFileUrl("layout.qml")); - QScopedPointer object(component.create()); - QVERIFY(!object.isNull()); - - QQuickApplicationWindow* window = qobject_cast(object.data()); - QVERIFY(window); - QVERIFY(QTest::qWaitForWindowExposed(window)); - - QQuickItem *content = window->contentItem(); - QVERIFY(content); - QQuickItem *header = window->header(); - QVERIFY(header); - QQuickItem *footer = window->footer(); - QVERIFY(footer); - - QCOMPARE(header->x(), 0.0); - QCOMPARE(header->y(), -header->height()); - QCOMPARE(header->width(), qreal(window->width())); - QVERIFY(header->height() > 0); - - QCOMPARE(footer->x(), 0.0); - QCOMPARE(footer->y(), content->height()); - QCOMPARE(footer->width(), qreal(window->width())); - QVERIFY(footer->height() > 0.0); - - QCOMPARE(content->x(), 0.0); - QCOMPARE(content->y(), header->height()); - QCOMPARE(content->width(), qreal(window->width())); - QCOMPARE(content->height(), window->height() - header->height() - footer->height()); - - header->setVisible(false); - QCOMPARE(content->x(), 0.0); - QCOMPARE(content->y(), 0.0); - QCOMPARE(content->width(), qreal(window->width())); - QCOMPARE(content->height(), window->height() - footer->height()); - - footer->setVisible(false); - QCOMPARE(content->x(), 0.0); - QCOMPARE(content->y(), 0.0); - QCOMPARE(content->width(), qreal(window->width())); - QCOMPARE(content->height(), qreal(window->height())); -} - -class FriendlyApplicationWindow : public QQuickApplicationWindow -{ - friend class tst_applicationwindow; -}; - -void tst_applicationwindow::componentComplete() -{ - FriendlyApplicationWindow cppWindow; - QVERIFY(cppWindow.isComponentComplete()); - - QQmlEngine engine; - QQmlComponent component(&engine); - component.setData("import QtQuick.Controls 2.2; ApplicationWindow { }", QUrl()); - - FriendlyApplicationWindow *qmlWindow = static_cast(component.beginCreate(engine.rootContext())); - QVERIFY(qmlWindow); - QVERIFY(!qmlWindow->isComponentComplete()); - - component.completeCreate(); - QVERIFY(qmlWindow->isComponentComplete()); -} - -QTEST_MAIN(tst_applicationwindow) - -#include "tst_applicationwindow.moc" diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 3acc4704..2eb23fd0 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -1,7 +1,6 @@ TEMPLATE = subdirs SUBDIRS += \ accessibility \ - applicationwindow \ calendar \ controls \ cursor \ @@ -10,6 +9,7 @@ SUBDIRS += \ menu \ platform \ pressandhold \ + qquickapplicationwindow \ qquickdrawer \ qquickmaterialstyle \ qquickmaterialstyleconf \ @@ -23,7 +23,7 @@ SUBDIRS += \ snippets # QTBUG-60268 -boot2qt: SUBDIRS -= applicationwindow calendar controls cursor \ +boot2qt: SUBDIRS -= qquickapplicationwindow calendar controls cursor \ qquickdrawer focus font menu platform qquickpopup qquickmaterialstyle \ qquickmaterialstyleconf qquickuniversalstyle \ qquickuniversalstyleconf snippets diff --git a/tests/auto/qquickapplicationwindow/data/activeFocusControl.qml b/tests/auto/qquickapplicationwindow/data/activeFocusControl.qml new file mode 100644 index 00000000..940e8e08 --- /dev/null +++ b/tests/auto/qquickapplicationwindow/data/activeFocusControl.qml @@ -0,0 +1,115 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Controls 2.1 + +ApplicationWindow { + width: 400 + height: 400 + + property alias container_column: column + property alias textInput_column: ti_column + property alias textEdit_column: te_column + property alias textField_column: tf_column + property alias textArea_column: ta_column + property alias spinBox_column: sp_column + property alias spinContent_column: sp_column.contentItem + + property alias container_frame: frame + property alias textInput_frame: ti_frame + property alias textEdit_frame: te_frame + property alias textField_frame: tf_frame + property alias textArea_frame: ta_frame + property alias spinBox_frame: sp_frame + property alias spinContent_frame: sp_frame.contentItem + + Column { + id: column + + TextInput { + id: ti_column + } + TextEdit { + id: te_column + } + TextField { + id: tf_column + } + TextArea { + id: ta_column + } + SpinBox { + id: sp_column + } + } + + Frame { + id: frame + + Column { + TextInput { + id: ti_frame + } + TextEdit { + id: te_frame + } + TextField { + id: tf_frame + } + TextArea { + id: ta_frame + } + SpinBox { + id: sp_frame + } + } + } +} diff --git a/tests/auto/qquickapplicationwindow/data/activefocusontab.qml b/tests/auto/qquickapplicationwindow/data/activefocusontab.qml new file mode 100644 index 00000000..357ea9a4 --- /dev/null +++ b/tests/auto/qquickapplicationwindow/data/activefocusontab.qml @@ -0,0 +1,94 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Controls 2.1 + +ApplicationWindow { + title: "Test Application Window" + width: 100 + height: 100 + Item { + id: main + objectName: "main" + width: 100 + height: 100 + //focus: true + Column { + anchors.fill: parent + id: column + objectName: "column" + Item { + id: sub1 + objectName: "sub1" + activeFocusOnTab: true + Accessible.role: Accessible.Table + width: 100 + height: 50 + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + } + Item { + id: sub2 + objectName: "sub2" + activeFocusOnTab: true + Accessible.role: Accessible.Table + width: 100 + height: 50 + Rectangle { + anchors.fill: parent + color: parent.activeFocus ? "red" : "black" + } + } + } + } +} diff --git a/tests/auto/qquickapplicationwindow/data/attachedProperties.qml b/tests/auto/qquickapplicationwindow/data/attachedProperties.qml new file mode 100644 index 00000000..09bc47ef --- /dev/null +++ b/tests/auto/qquickapplicationwindow/data/attachedProperties.qml @@ -0,0 +1,190 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Window 2.2 +import QtQuick.Controls 2.1 + +ApplicationWindow { + property alias childControl: childControl + property alias childItem: childItem + property alias childObject: childObject + + Control { + id: childControl + + property ApplicationWindow attached_window: ApplicationWindow.window + property Item attached_contentItem: ApplicationWindow.contentItem + property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl + property Item attached_header: ApplicationWindow.header + property Item attached_footer: ApplicationWindow.footer + property Item attached_overlay: ApplicationWindow.overlay + } + + Item { + id: childItem + + property ApplicationWindow attached_window: ApplicationWindow.window + property Item attached_contentItem: ApplicationWindow.contentItem + property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl + property Item attached_header: ApplicationWindow.header + property Item attached_footer: ApplicationWindow.footer + property Item attached_overlay: ApplicationWindow.overlay + } + + QtObject { + id: childObject + + property ApplicationWindow attached_window: ApplicationWindow.window + property Item attached_contentItem: ApplicationWindow.contentItem + property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl + property Item attached_header: ApplicationWindow.header + property Item attached_footer: ApplicationWindow.footer + property Item attached_overlay: ApplicationWindow.overlay + } + + property alias childWindow: childWindow + property alias childWindowControl: childWindowControl + property alias childWindowItem: childWindowItem + property alias childWindowObject: childWindowObject + + Window { + id: childWindow + + property ApplicationWindow attached_window: ApplicationWindow.window + property Item attached_contentItem: ApplicationWindow.contentItem + property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl + property Item attached_header: ApplicationWindow.header + property Item attached_footer: ApplicationWindow.footer + property Item attached_overlay: ApplicationWindow.overlay + + Control { + id: childWindowControl + + property ApplicationWindow attached_window: ApplicationWindow.window + property Item attached_contentItem: ApplicationWindow.contentItem + property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl + property Item attached_header: ApplicationWindow.header + property Item attached_footer: ApplicationWindow.footer + property Item attached_overlay: ApplicationWindow.overlay + } + + Item { + id: childWindowItem + + property ApplicationWindow attached_window: ApplicationWindow.window + property Item attached_contentItem: ApplicationWindow.contentItem + property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl + property Item attached_header: ApplicationWindow.header + property Item attached_footer: ApplicationWindow.footer + property Item attached_overlay: ApplicationWindow.overlay + } + + QtObject { + id: childWindowObject + + property ApplicationWindow attached_window: ApplicationWindow.window + property Item attached_contentItem: ApplicationWindow.contentItem + property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl + property Item attached_header: ApplicationWindow.header + property Item attached_footer: ApplicationWindow.footer + property Item attached_overlay: ApplicationWindow.overlay + } + } + + property alias childAppWindow: childAppWindow + property alias childAppWindowControl: childAppWindowControl + property alias childAppWindowItem: childAppWindowItem + property alias childAppWindowObject: childAppWindowObject + + ApplicationWindow { + id: childAppWindow + + property ApplicationWindow attached_window: ApplicationWindow.window + property Item attached_contentItem: ApplicationWindow.contentItem + property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl + property Item attached_header: ApplicationWindow.header + property Item attached_footer: ApplicationWindow.footer + property Item attached_overlay: ApplicationWindow.overlay + + Control { + id: childAppWindowControl + + property ApplicationWindow attached_window: ApplicationWindow.window + property Item attached_contentItem: ApplicationWindow.contentItem + property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl + property Item attached_header: ApplicationWindow.header + property Item attached_footer: ApplicationWindow.footer + property Item attached_overlay: ApplicationWindow.overlay + } + + Item { + id: childAppWindowItem + + property ApplicationWindow attached_window: ApplicationWindow.window + property Item attached_contentItem: ApplicationWindow.contentItem + property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl + property Item attached_header: ApplicationWindow.header + property Item attached_footer: ApplicationWindow.footer + property Item attached_overlay: ApplicationWindow.overlay + } + + QtObject { + id: childAppWindowObject + + property ApplicationWindow attached_window: ApplicationWindow.window + property Item attached_contentItem: ApplicationWindow.contentItem + property Item attached_activeFocusControl: ApplicationWindow.activeFocusControl + property Item attached_header: ApplicationWindow.header + property Item attached_footer: ApplicationWindow.footer + property Item attached_overlay: ApplicationWindow.overlay + } + } +} diff --git a/tests/auto/qquickapplicationwindow/data/basicapplicationwindow.qml b/tests/auto/qquickapplicationwindow/data/basicapplicationwindow.qml new file mode 100644 index 00000000..16182f59 --- /dev/null +++ b/tests/auto/qquickapplicationwindow/data/basicapplicationwindow.qml @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Controls 2.1 + +ApplicationWindow { + title: "Test Application Window" +} diff --git a/tests/auto/qquickapplicationwindow/data/clearfocusondestruction.qml b/tests/auto/qquickapplicationwindow/data/clearfocusondestruction.qml new file mode 100644 index 00000000..3589439e --- /dev/null +++ b/tests/auto/qquickapplicationwindow/data/clearfocusondestruction.qml @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.7 +import QtQuick.Controls 2.1 +import QtQuick.Layouts 1.3 +import QtGraphicalEffects 1.0 + +ApplicationWindow { + width: 200 + height: 200 + visible: true + + property alias textfield: textfield + + /* + * The code below is the simplest way we can trigger that the signal + * activeFocusItemChanged() is emitted during destruction of the + * ApplicationWindow. This caused a crash in QQuickApplicationWindow. + */ + FastBlur { + id: fastBlur + anchors.fill: parent + radius: 30 + source: ShaderEffectSource { + id: effectsource + sourceItem: textfield + sourceRect: Qt.rect( 0, 0, fastBlur.width, fastBlur.height ) + } + } + + TextField { + id: textfield + anchors.bottom: parent.bottom + focus: true + } +} diff --git a/tests/auto/qquickapplicationwindow/data/defaultFocus.qml b/tests/auto/qquickapplicationwindow/data/defaultFocus.qml new file mode 100644 index 00000000..741ce908 --- /dev/null +++ b/tests/auto/qquickapplicationwindow/data/defaultFocus.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Controls 2.1 + +ApplicationWindow { + visible: true + width: 200 + height: 200 + + property bool receivedKeyPress: false + + Item { + objectName: "item" + focus: true + anchors.fill: parent + + Keys.onLeftPressed: receivedKeyPress = true + } +} + diff --git a/tests/auto/qquickapplicationwindow/data/fill.qml b/tests/auto/qquickapplicationwindow/data/fill.qml new file mode 100644 index 00000000..27b10d34 --- /dev/null +++ b/tests/auto/qquickapplicationwindow/data/fill.qml @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Controls 2.1 + +ApplicationWindow { + width: 400 + height: 400 + + property alias stackView: stackView + property alias nextItem: nextItem + + function pushNextItem() { + stackView.push(nextItem, StackView.Immediate); + } + + Rectangle { + id: nextItem + color: "blue" + visible: false + } + + StackView { + id: stackView + anchors.fill: parent + + initialItem: Rectangle { + color: "red" + } + } +} diff --git a/tests/auto/qquickapplicationwindow/data/focusAfterPopupClosed.qml b/tests/auto/qquickapplicationwindow/data/focusAfterPopupClosed.qml new file mode 100644 index 00000000..f0499a3a --- /dev/null +++ b/tests/auto/qquickapplicationwindow/data/focusAfterPopupClosed.qml @@ -0,0 +1,111 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Controls 2.1 + +ApplicationWindow { + width: 200 + height: 200 + visible: true + + signal focusScopeKeyPressed + signal focusPopupKeyPressed + + property alias fileMenu: fileMenu + property alias toolButton: toolButton + property alias focusScope: focusScope + property alias focusPopup: focusPopup + + header: ToolBar { + ToolButton { + id: toolButton + text: qsTr("File") + onClicked: fileMenu.open() + focusPolicy: Qt.TabFocus + + Menu { + id: fileMenu + y: parent.height + + MenuItem { + text: qsTr("New") + } + MenuItem { + text: qsTr("Open") + } + MenuItem { + text: qsTr("Close") + } + } + } + } + + FocusScope { + id: focusScope + focus: true + anchors.fill: parent + + Keys.onSpacePressed: focusScopeKeyPressed() + } + + Popup { + id: focusPopup + focus: true + width: parent.width + height: parent.height + + Item { + focus: true + Keys.onSpacePressed: focusPopupKeyPressed() + } + } +} + diff --git a/tests/auto/qquickapplicationwindow/data/font.qml b/tests/auto/qquickapplicationwindow/data/font.qml new file mode 100644 index 00000000..a675aeab --- /dev/null +++ b/tests/auto/qquickapplicationwindow/data/font.qml @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Controls 2.1 +import QtQuick.Templates 2.1 as T + +ApplicationWindow { + objectName: "appWin" + width: 400 + height: 400 + + property alias mainItem: mainItem + + font.family: "Arial" + + T.Control { + id: mainItem + objectName: "mainItem" + anchors.fill: parent + property alias item_2: _item_2; + property alias item_3: _item_3; + property alias item_4: _item_4; + property alias item_5: _item_5; + property alias item_6: _item_6; + T.Control { + id: _item_2 + objectName: "_item_2" + T.Control { + id: _item_3 + objectName: "_item_3" + } + } + T.TextArea { + id: _item_4 + objectName: "_item_4" + text: "Text Area" + } + T.TextField { + id: _item_5 + objectName: "_item_5" + text: "Text Field" + } + T.Label { + id: _item_6 + objectName: "_item_6" + text: "Label" + } + } +} diff --git a/tests/auto/qquickapplicationwindow/data/layout.qml b/tests/auto/qquickapplicationwindow/data/layout.qml new file mode 100644 index 00000000..a80b2d48 --- /dev/null +++ b/tests/auto/qquickapplicationwindow/data/layout.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Controls 2.0 + +ApplicationWindow { + width: 200 + height: 200 + visible: true + + header: ToolBar { } + footer: ToolBar { } +} diff --git a/tests/auto/qquickapplicationwindow/data/locale.qml b/tests/auto/qquickapplicationwindow/data/locale.qml new file mode 100644 index 00000000..92edb53a --- /dev/null +++ b/tests/auto/qquickapplicationwindow/data/locale.qml @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Controls 2.1 +import QtQuick.Templates 2.1 as T + +ApplicationWindow { + objectName: "appWin" + width: 400 + height: 400 + + property alias mainItem: mainItem + + T.Control { + id: mainItem + objectName: "mainItem" + anchors.fill: parent + property alias item_2: _item_2; + property alias item_3: _item_3; + T.Control { + id: _item_2 + objectName: "_item_2" + T.Control { + id: _item_3 + objectName: "_item_3" + } + } + } +} diff --git a/tests/auto/qquickapplicationwindow/qquickapplicationwindow.pro b/tests/auto/qquickapplicationwindow/qquickapplicationwindow.pro new file mode 100644 index 00000000..775f4c90 --- /dev/null +++ b/tests/auto/qquickapplicationwindow/qquickapplicationwindow.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qquickapplicationwindow +SOURCES += tst_qquickapplicationwindow.cpp + +macos:CONFIG -= app_bundle + +QT += core-private gui-private qml-private quick-private quicktemplates2-private quickcontrols2-private testlib + +include (../shared/util.pri) + +TESTDATA = data/* + +OTHER_FILES += \ + data/*.qml + diff --git a/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp b/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp new file mode 100644 index 00000000..19a0bf3b --- /dev/null +++ b/tests/auto/qquickapplicationwindow/tst_qquickapplicationwindow.cpp @@ -0,0 +1,838 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../shared/util.h" +#include "../shared/visualtestutil.h" + +using namespace QQuickVisualTestUtil; + +class tst_QQuickApplicationWindow : public QQmlDataTest +{ + Q_OBJECT +public: + +private slots: + void qmlCreation(); + void activeFocusOnTab1(); + void activeFocusOnTab2(); + void defaultFocus(); + void implicitFill(); + void attachedProperties(); + void font(); + void defaultFont(); + void locale(); + void activeFocusControl_data(); + void activeFocusControl(); + void focusAfterPopupClosed(); + void clearFocusOnDestruction(); + void layout(); + void componentComplete(); +}; + +void tst_QQuickApplicationWindow::qmlCreation() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("basicapplicationwindow.qml")); + QObject* created = component.create(); + QScopedPointer cleanup(created); + QVERIFY(created); + + QQuickWindow* window = qobject_cast(created); + QVERIFY(window); + QVERIFY(!window->isVisible()); + + QCOMPARE(created->property("title"), QVariant("Test Application Window")); + + QQuickItem* statusBar = qvariant_cast(created->property("statusBar")); + QVERIFY(!statusBar); + + QQuickItem* header = qvariant_cast(created->property("header")); + QVERIFY(!header); + + QQuickItem* footer = qvariant_cast(created->property("footer")); + QVERIFY(!footer); +} + +void tst_QQuickApplicationWindow::activeFocusOnTab1() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("activefocusontab.qml")); + QObject* created = component.create(); + QScopedPointer cleanup(created); + QVERIFY(created); + + QQuickWindow* window = qobject_cast(created); + QVERIFY(window); + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QGuiApplication::focusWindow() == window); + + QQuickItem* contentItem = window->contentItem(); + QVERIFY(contentItem); + QVERIFY(contentItem->hasActiveFocus()); + + QQuickItem* item = findItem(window->contentItem(), "sub1"); + QVERIFY(item); + QVERIFY(!item->hasActiveFocus()); + + // Tab: contentItem->sub1 + QKeyEvent key(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + + item = findItem(window->contentItem(), "sub1"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // Tab: sub1->sub2 + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + + item = findItem(window->contentItem(), "sub2"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // Tab: sub2->sub1 + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "", false, 1); + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + + item = findItem(window->contentItem(), "sub1"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); +} + +void tst_QQuickApplicationWindow::activeFocusOnTab2() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("activefocusontab.qml")); + QObject* created = component.create(); + QScopedPointer cleanup(created); + QVERIFY(created); + + QQuickWindow* window = qobject_cast(created); + QVERIFY(window); + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QGuiApplication::focusWindow() == window); + + QQuickItem* contentItem = window->contentItem(); + QVERIFY(contentItem); + QVERIFY(contentItem->hasActiveFocus()); + + QQuickItem* item = findItem(window->contentItem(), "sub2"); + QVERIFY(item); + QVERIFY(!item->hasActiveFocus()); + + // BackTab: contentItem->sub2 + QKeyEvent key(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + + item = findItem(window->contentItem(), "sub2"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // BackTab: sub2->sub1 + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + + item = findItem(window->contentItem(), "sub1"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); + + // BackTab: sub1->sub2 + key = QKeyEvent(QEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "", false, 1); + QGuiApplication::sendEvent(window, &key); + QVERIFY(key.isAccepted()); + + item = findItem(window->contentItem(), "sub2"); + QVERIFY(item); + QVERIFY(item->hasActiveFocus()); +} + +void tst_QQuickApplicationWindow::defaultFocus() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("defaultFocus.qml")); + QObject* created = component.create(); + QScopedPointer cleanup(created); + Q_UNUSED(cleanup); + QVERIFY(created); + + QQuickWindow* window = qobject_cast(created); + QVERIFY(window); + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QGuiApplication::focusWindow() == window); + + QQuickItem* contentItem = window->contentItem(); + QVERIFY(contentItem); + QVERIFY(contentItem->hasActiveFocus()); + + // A single item in an ApplicationWindow with focus: true should receive focus. + QQuickItem* item = findItem(window->contentItem(), "item"); + QVERIFY(item); + QVERIFY(item->hasFocus()); + QVERIFY(item->hasActiveFocus()); +} + +void tst_QQuickApplicationWindow::implicitFill() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("fill.qml")); + QObject* created = component.create(); + QScopedPointer cleanup(created); + QVERIFY(created); + + QQuickWindow* window = qobject_cast(created); + QVERIFY(window); + QVERIFY(!window->isVisible()); + QCOMPARE(window->width(), 400); + QCOMPARE(window->height(), 400); + + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickItem *stackView = window->property("stackView").value(); + QVERIFY(stackView); + QCOMPARE(stackView->width(), 400.0); + QCOMPARE(stackView->height(), 400.0); + + QQuickItem *nextItem = window->property("nextItem").value(); + QVERIFY(nextItem); + + QVERIFY(QMetaObject::invokeMethod(window, "pushNextItem")); + QCOMPARE(nextItem->width(), 400.0); + QCOMPARE(nextItem->height(), 400.0); +} + +void tst_QQuickApplicationWindow::attachedProperties() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("attachedProperties.qml")); + + QScopedPointer object(component.create()); + QVERIFY2(!object.isNull(), qPrintable(component.errorString())); + + QQuickApplicationWindow *window = qobject_cast(object.data()); + QVERIFY(window); + + QQuickItem *childControl = object->property("childControl").value(); + QVERIFY(childControl); + QCOMPARE(childControl->property("attached_window").value(), window); + QCOMPARE(childControl->property("attached_contentItem").value(), window->contentItem()); + QCOMPARE(childControl->property("attached_activeFocusControl").value(), window->activeFocusControl()); + QCOMPARE(childControl->property("attached_header").value(), window->header()); + QCOMPARE(childControl->property("attached_footer").value(), window->footer()); + QCOMPARE(childControl->property("attached_overlay").value(), window->overlay()); + + QQuickItem *childItem = object->property("childItem").value(); + QVERIFY(childItem); + QCOMPARE(childItem->property("attached_window").value(), window); + QCOMPARE(childItem->property("attached_contentItem").value(), window->contentItem()); + QCOMPARE(childItem->property("attached_activeFocusControl").value(), window->activeFocusControl()); + QCOMPARE(childItem->property("attached_header").value(), window->header()); + QCOMPARE(childItem->property("attached_footer").value(), window->footer()); + QCOMPARE(childItem->property("attached_overlay").value(), window->overlay()); + + QObject *childObject = object->property("childObject").value(); + QVERIFY(childObject); + QVERIFY(!childObject->property("attached_window").value()); + QVERIFY(!childObject->property("attached_contentItem").value()); + QVERIFY(!childObject->property("attached_activeFocusControl").value()); + QVERIFY(!childObject->property("attached_header").value()); + QVERIFY(!childObject->property("attached_footer").value()); + QVERIFY(!childObject->property("attached_overlay").value()); + + QQuickWindow *childWindow = object->property("childWindow").value(); + QVERIFY(childWindow); + QVERIFY(!childWindow->property("attached_window").value()); + QVERIFY(!childWindow->property("attached_contentItem").value()); + QVERIFY(!childWindow->property("attached_activeFocusControl").value()); + QVERIFY(!childWindow->property("attached_header").value()); + QVERIFY(!childWindow->property("attached_footer").value()); + QVERIFY(!childWindow->property("attached_overlay").value()); + + QQuickItem *childWindowControl = object->property("childWindowControl").value(); + QVERIFY(childWindowControl); + QVERIFY(!childWindowControl->property("attached_window").value()); + QVERIFY(!childWindowControl->property("attached_contentItem").value()); + QVERIFY(!childWindowControl->property("attached_activeFocusControl").value()); + QVERIFY(!childWindowControl->property("attached_header").value()); + QVERIFY(!childWindowControl->property("attached_footer").value()); + QCOMPARE(childWindowControl->property("attached_overlay").value(), QQuickOverlay::overlay(childWindow)); + + QQuickItem *childWindowItem = object->property("childWindowItem").value(); + QVERIFY(childWindowItem); + QVERIFY(!childWindowItem->property("attached_window").value()); + QVERIFY(!childWindowItem->property("attached_contentItem").value()); + QVERIFY(!childWindowItem->property("attached_activeFocusControl").value()); + QVERIFY(!childWindowItem->property("attached_header").value()); + QVERIFY(!childWindowItem->property("attached_footer").value()); + QCOMPARE(childWindowItem->property("attached_overlay").value(), QQuickOverlay::overlay(childWindow)); + + QObject *childWindowObject = object->property("childWindowObject").value(); + QVERIFY(childWindowObject); + QVERIFY(!childWindowObject->property("attached_window").value()); + QVERIFY(!childWindowObject->property("attached_contentItem").value()); + QVERIFY(!childWindowObject->property("attached_activeFocusControl").value()); + QVERIFY(!childWindowObject->property("attached_header").value()); + QVERIFY(!childWindowObject->property("attached_footer").value()); + QVERIFY(!childWindowObject->property("attached_overlay").value()); + + QQuickApplicationWindow *childAppWindow = object->property("childAppWindow").value(); + QVERIFY(childAppWindow); + QVERIFY(!childAppWindow->property("attached_window").value()); + QVERIFY(!childAppWindow->property("attached_contentItem").value()); + QVERIFY(!childAppWindow->property("attached_activeFocusControl").value()); + QVERIFY(!childAppWindow->property("attached_header").value()); + QVERIFY(!childAppWindow->property("attached_footer").value()); + QVERIFY(!childAppWindow->property("attached_overlay").value()); + + QQuickItem *childAppWindowControl = object->property("childAppWindowControl").value(); + QVERIFY(childAppWindowControl); + QCOMPARE(childAppWindowControl->property("attached_window").value(), childAppWindow); + QCOMPARE(childAppWindowControl->property("attached_contentItem").value(), childAppWindow->contentItem()); + QCOMPARE(childAppWindowControl->property("attached_activeFocusControl").value(), childAppWindow->activeFocusControl()); + QCOMPARE(childAppWindowControl->property("attached_header").value(), childAppWindow->header()); + QCOMPARE(childAppWindowControl->property("attached_footer").value(), childAppWindow->footer()); + QCOMPARE(childAppWindowControl->property("attached_overlay").value(), childAppWindow->overlay()); + + QQuickItem *childAppWindowItem = object->property("childAppWindowItem").value(); + QVERIFY(childAppWindowItem); + QCOMPARE(childAppWindowItem->property("attached_window").value(), childAppWindow); + QCOMPARE(childAppWindowItem->property("attached_contentItem").value(), childAppWindow->contentItem()); + QCOMPARE(childAppWindowItem->property("attached_activeFocusControl").value(), childAppWindow->activeFocusControl()); + QCOMPARE(childAppWindowItem->property("attached_header").value(), childAppWindow->header()); + QCOMPARE(childAppWindowItem->property("attached_footer").value(), childAppWindow->footer()); + QCOMPARE(childAppWindowItem->property("attached_overlay").value(), childAppWindow->overlay()); + + QObject *childAppWindowObject = object->property("childAppWindowObject").value(); + QVERIFY(childAppWindowObject); + QVERIFY(!childAppWindowObject->property("attached_window").value()); + QVERIFY(!childAppWindowObject->property("attached_contentItem").value()); + QVERIFY(!childAppWindowObject->property("attached_activeFocusControl").value()); + QVERIFY(!childAppWindowObject->property("attached_header").value()); + QVERIFY(!childAppWindowObject->property("attached_footer").value()); + QVERIFY(!childAppWindowObject->property("attached_overlay").value()); + + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QVERIFY(!childControl->hasActiveFocus()); + childControl->forceActiveFocus(); + QTRY_VERIFY(childControl->hasActiveFocus()); + QCOMPARE(window->activeFocusItem(), childControl); + QCOMPARE(childControl->property("attached_activeFocusControl").value(), childControl); + + QQuickItem *header = new QQuickItem; + window->setHeader(header); + QCOMPARE(window->header(), header); + QCOMPARE(childControl->property("attached_header").value(), header); + + QQuickItem *footer = new QQuickItem; + window->setFooter(footer); + QCOMPARE(window->footer(), footer); + QCOMPARE(childControl->property("attached_footer").value(), footer); + + childAppWindow->show(); + childAppWindow->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(childAppWindow)); + + QVERIFY(!childAppWindowControl->hasActiveFocus()); + childAppWindowControl->forceActiveFocus(); + QTRY_VERIFY(childAppWindowControl->hasActiveFocus()); + QCOMPARE(childAppWindow->activeFocusItem(), childAppWindowControl); + QCOMPARE(childAppWindowControl->property("attached_activeFocusControl").value(), childAppWindowControl); + + childControl->setParentItem(childAppWindow->contentItem()); + QCOMPARE(childControl->window(), childAppWindow); + QCOMPARE(childControl->property("attached_window").value(), childAppWindow); + QCOMPARE(childControl->property("attached_contentItem").value(), childAppWindow->contentItem()); + QCOMPARE(childControl->property("attached_activeFocusControl").value(), childAppWindow->activeFocusControl()); + QCOMPARE(childControl->property("attached_header").value(), childAppWindow->header()); + QCOMPARE(childControl->property("attached_footer").value(), childAppWindow->footer()); + QCOMPARE(childControl->property("attached_overlay").value(), childAppWindow->overlay()); + + childItem->setParentItem(childAppWindow->contentItem()); + QCOMPARE(childItem->window(), childAppWindow); + QCOMPARE(childItem->property("attached_window").value(), childAppWindow); + QCOMPARE(childItem->property("attached_contentItem").value(), childAppWindow->contentItem()); + QCOMPARE(childItem->property("attached_activeFocusControl").value(), childAppWindow->activeFocusControl()); + QCOMPARE(childItem->property("attached_header").value(), childAppWindow->header()); + QCOMPARE(childItem->property("attached_footer").value(), childAppWindow->footer()); + QCOMPARE(childItem->property("attached_overlay").value(), childAppWindow->overlay()); + + childControl->setParentItem(nullptr); + QVERIFY(!childControl->window()); + QVERIFY(!childControl->property("attached_window").value()); + QVERIFY(!childControl->property("attached_contentItem").value()); + QVERIFY(!childControl->property("attached_activeFocusControl").value()); + QVERIFY(!childControl->property("attached_header").value()); + QVERIFY(!childControl->property("attached_footer").value()); + QVERIFY(!childControl->property("attached_overlay").value()); + + childItem->setParentItem(nullptr); + QVERIFY(!childItem->window()); + QVERIFY(!childItem->property("attached_window").value()); + QVERIFY(!childItem->property("attached_contentItem").value()); + QVERIFY(!childItem->property("attached_activeFocusControl").value()); + QVERIFY(!childItem->property("attached_header").value()); + QVERIFY(!childItem->property("attached_footer").value()); + QVERIFY(!childItem->property("attached_overlay").value()); + + // ### A temporary workaround to unblock the CI until the crash caused + // by https://codereview.qt-project.org/#/c/108517/ has been fixed... + window->hide(); + qApp->processEvents(); +} + +void tst_QQuickApplicationWindow::font() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("font.qml")); + QObject* created = component.create(); + QScopedPointer cleanup(created); + QVERIFY(created); + + QQuickApplicationWindow* window = qobject_cast(created); + QVERIFY(window); + QVERIFY(!window->isVisible()); + QCOMPARE(window->width(), 400); + QCOMPARE(window->height(), 400); + + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QFont font = window->font(); + + QQuickControl *mainItem = window->property("mainItem").value(); + QVERIFY(mainItem); + QCOMPARE(mainItem->width(), 400.0); + QCOMPARE(mainItem->height(), 400.0); + QCOMPARE(mainItem->font(), font); + + QQuickControl *item2 = mainItem->property("item_2").value(); + QVERIFY(item2); + QQuickControl *item3 = mainItem->property("item_3").value(); + QVERIFY(item3); + QQuickTextArea *item4 = mainItem->property("item_4").value(); + QVERIFY(item4); + QQuickTextField *item5 = mainItem->property("item_5").value(); + QVERIFY(item5); + QQuickLabel *item6 = mainItem->property("item_6").value(); + QVERIFY(item6); + + QCOMPARE(item2->font(), font); + QCOMPARE(item3->font(), font); + QCOMPARE(item4->font(), font); + QCOMPARE(item5->font(), font); + QCOMPARE(item6->font(), font); + + int pointSize = font.pointSize(); + font.setPixelSize(pointSize + 5); + window->setFont(font); + + QCOMPARE(window->font(), font); + QCOMPARE(mainItem->font(), font); + QCOMPARE(item2->font(), font); + QCOMPARE(item3->font(), font); + QCOMPARE(item4->font(), font); + QCOMPARE(item5->font(), font); + QCOMPARE(item6->font(), font); +} + +class TestTheme : public QQuickProxyTheme +{ +public: + TestTheme(QPlatformTheme *theme) : QQuickProxyTheme(theme), m_font("Courier") + { QGuiApplicationPrivate::platform_theme = this; } + + const QFont *font(Font type = SystemFont) const override + { + Q_UNUSED(type); + return &m_font; + } + + QFont m_font; +}; + +void tst_QQuickApplicationWindow::defaultFont() +{ + TestTheme theme(QGuiApplicationPrivate::platform_theme); + + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData("import QtQuick.Controls 2.1; ApplicationWindow { }", QUrl()); + + QScopedPointer window; + window.reset(static_cast(component.create())); + QVERIFY(!window.isNull()); + QCOMPARE(window->font(), *theme.font()); +} + +void tst_QQuickApplicationWindow::locale() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("locale.qml")); + QObject* created = component.create(); + QScopedPointer cleanup(created); + QVERIFY(created); + + QQuickApplicationWindow* window = qobject_cast(created); + QVERIFY(window); + QVERIFY(!window->isVisible()); + QCOMPARE(window->width(), 400); + QCOMPARE(window->height(), 400); + + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QLocale l = window->locale(); + + QQuickControl *mainItem = window->property("mainItem").value(); + QVERIFY(mainItem); + QCOMPARE(mainItem->width(), 400.0); + QCOMPARE(mainItem->height(), 400.0); + QCOMPARE(mainItem->locale(), l); + + QQuickControl *item2 = mainItem->property("item_2").value(); + QVERIFY(item2); + QQuickControl *item3 = mainItem->property("item_3").value(); + QVERIFY(item3); + + QCOMPARE(item2->locale(), l); + QCOMPARE(item3->locale(), l); + + l = QLocale("en_US"); + window->setLocale(l); + + QCOMPARE(window->locale(), l); + QCOMPARE(mainItem->locale(), l); + QCOMPARE(item2->locale(), l); + QCOMPARE(item3->locale(), l); + + l = QLocale("ar_EG"); + window->setLocale(l); + + QCOMPARE(window->locale(), l); + QCOMPARE(mainItem->locale(), l); + QCOMPARE(item2->locale(), l); + QCOMPARE(item3->locale(), l); +} + +void tst_QQuickApplicationWindow::activeFocusControl_data() +{ + QTest::addColumn("containerName"); + QTest::addColumn("activeFocusItemName"); + QTest::addColumn("activeFocusControlName"); + + QTest::newRow("Column:TextInput") << QByteArray("container_column") << QByteArray("textInput_column") << QByteArray(); + QTest::newRow("Column:TextEdit") << QByteArray("container_column") << QByteArray("textEdit_column") << QByteArray(); + QTest::newRow("Column:TextField") << QByteArray("container_column") << QByteArray("textField_column") << QByteArray("textField_column"); + QTest::newRow("Column:TextArea") << QByteArray("container_column") << QByteArray("textArea_column") << QByteArray("textArea_column"); + QTest::newRow("Column:SpinBox") << QByteArray("container_column") << QByteArray("spinContent_column") << QByteArray("spinBox_column"); + + QTest::newRow("Frame:TextInput") << QByteArray("container_frame") << QByteArray("textInput_frame") << QByteArray("container_frame"); + QTest::newRow("Frame:TextEdit") << QByteArray("container_frame") << QByteArray("textEdit_frame") << QByteArray("container_frame"); + QTest::newRow("Frame:TextField") << QByteArray("container_frame") << QByteArray("textField_frame") << QByteArray("textField_frame"); + QTest::newRow("Frame:TextArea") << QByteArray("container_frame") << QByteArray("textArea_frame") << QByteArray("textArea_frame"); + QTest::newRow("Frame:SpinBox") << QByteArray("container_frame") << QByteArray("spinContent_frame") << QByteArray("spinBox_frame"); +} + +void tst_QQuickApplicationWindow::activeFocusControl() +{ + QFETCH(QByteArray, containerName); + QFETCH(QByteArray, activeFocusItemName); + QFETCH(QByteArray, activeFocusControlName); + + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("activeFocusControl.qml")); + QScopedPointer object(component.create()); + QVERIFY(!object.isNull()); + + QQuickApplicationWindow* window = qobject_cast(object.data()); + QVERIFY(window); + QVERIFY(!window->isVisible()); + QCOMPARE(window->width(), 400); + QCOMPARE(window->height(), 400); + + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickItem *container = window->property(containerName).value(); + QVERIFY(container); + + QQuickItem *activeFocusItem = window->property(activeFocusItemName).value(); + QVERIFY(activeFocusItem); + activeFocusItem->forceActiveFocus(); + QVERIFY(activeFocusItem->hasActiveFocus()); + QCOMPARE(window->activeFocusItem(), activeFocusItem); + + QQuickItem *activeFocusControl = window->property(activeFocusControlName).value(); + if (activeFocusControlName.isEmpty()) { + QVERIFY(!activeFocusControl); + } else { + QVERIFY(activeFocusControl); + QVERIFY(activeFocusControl->hasActiveFocus()); + } + QCOMPARE(window->activeFocusControl(), activeFocusControl); +} + +void tst_QQuickApplicationWindow::focusAfterPopupClosed() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("focusAfterPopupClosed.qml")); + QScopedPointer window(qobject_cast(component.create())); + QVERIFY(window); + + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window.data())); + QVERIFY(QGuiApplication::focusWindow() == window.data()); + + QQuickItem* contentItem = window->contentItem(); + QVERIFY(contentItem); + QVERIFY(contentItem->hasActiveFocus()); + + QQuickItem* focusScope = window->property("focusScope").value(); + QVERIFY(focusScope); + QVERIFY(focusScope->hasActiveFocus()); + + QSignalSpy focusScopeSpy(window.data(), SIGNAL(focusScopeKeyPressed())); + QTest::keyClick(window.data(), Qt::Key_Space); + QCOMPARE(focusScopeSpy.count(), 1); + + // Open the menu. + QQuickItem* toolButton = window->property("toolButton").value(); + QVERIFY(toolButton); + QTest::mouseClick(window.data(), Qt::LeftButton, Qt::NoModifier, + toolButton->mapFromScene(QPointF(toolButton->width() / 2, toolButton->height() / 2)).toPoint()); + QVERIFY(!focusScope->hasActiveFocus()); + + // The FocusScope shouldn't receive any key events while the menu is open. + QTest::keyClick(window.data(), Qt::Key_Space); + QCOMPARE(focusScopeSpy.count(), 1); + + // Close the menu. The FocusScope should regain focus. + QTest::keyClick(window.data(), Qt::Key_Escape); + QVERIFY(focusScope->hasActiveFocus()); + + QTest::keyClick(window.data(), Qt::Key_Space); + QCOMPARE(focusScopeSpy.count(), 2); + + QQuickPopup *focusPopup = window->property("focusPopup").value(); + QVERIFY(focusPopup); + QVERIFY(!focusPopup->hasActiveFocus()); + + focusPopup->open(); + QVERIFY(focusPopup->isVisible()); + + QSignalSpy focusPopupSpy(window.data(), SIGNAL(focusPopupKeyPressed())); + QTest::keyClick(window.data(), Qt::Key_Space); + QCOMPARE(focusPopupSpy.count(), 1); + + QQuickMenu *fileMenu = window->property("fileMenu").value(); + QVERIFY(fileMenu); + fileMenu->open(); + QVERIFY(fileMenu->isVisible()); + + // The Popup shouldn't receive any key events while the menu is open. + QTest::keyClick(window.data(), Qt::Key_Space); + QCOMPARE(focusPopupSpy.count(), 1); + + // Close the menu. The Popup should regain focus. + QTest::keyClick(window.data(), Qt::Key_Escape); + QVERIFY(focusPopup->hasActiveFocus()); + + QTest::keyClick(window.data(), Qt::Key_Space); + QCOMPARE(focusPopupSpy.count(), 2); + + // Close the popup. The FocusScope should regain focus. + QTest::keyClick(window.data(), Qt::Key_Escape); + QVERIFY(focusScope->hasActiveFocus()); + + QTest::keyClick(window.data(), Qt::Key_Space); + QCOMPARE(focusScopeSpy.count(), 3); +} + +void tst_QQuickApplicationWindow::clearFocusOnDestruction() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("clearfocusondestruction.qml")); + QScopedPointer window(qobject_cast(component.create())); + QVERIFY(window); + + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window.data())); + QVERIFY(QGuiApplication::focusWindow() == window.data()); + + QQuickItem* contentItem = window->contentItem(); + QVERIFY(contentItem); + QVERIFY(contentItem->hasActiveFocus()); + + QQuickItem* focusScope = window->property("textfield").value(); + QVERIFY(focusScope); + QVERIFY(focusScope->hasActiveFocus()); + + QSignalSpy spy(window.data(), SIGNAL(activeFocusControlChanged())); + // destroy the window, do not crash + window.reset(); + + /* + QQuickWindow::activeFocusItemChanged() is emitted inconsistently and + only for certain use cases. Ideally it should be emitted whenever a + QQuickWindow with a focus item is destroyed, but it doesn't... It might + also be favorable to not emit it for performance reason. + + However, activeFocusControlChanged() is emitted more consistently, which + of course makes it inconsistent with the emission of + activeFocusItemChanged().... + + Therefore, if you have good reasons to change the behavior (and not emit + it) take the test below with a grain of salt. + */ + QCOMPARE(spy.count(), 1); +} + +void tst_QQuickApplicationWindow::layout() +{ + QQmlEngine engine; + QQmlComponent component(&engine); + component.loadUrl(testFileUrl("layout.qml")); + QScopedPointer object(component.create()); + QVERIFY(!object.isNull()); + + QQuickApplicationWindow* window = qobject_cast(object.data()); + QVERIFY(window); + QVERIFY(QTest::qWaitForWindowExposed(window)); + + QQuickItem *content = window->contentItem(); + QVERIFY(content); + QQuickItem *header = window->header(); + QVERIFY(header); + QQuickItem *footer = window->footer(); + QVERIFY(footer); + + QCOMPARE(header->x(), 0.0); + QCOMPARE(header->y(), -header->height()); + QCOMPARE(header->width(), qreal(window->width())); + QVERIFY(header->height() > 0); + + QCOMPARE(footer->x(), 0.0); + QCOMPARE(footer->y(), content->height()); + QCOMPARE(footer->width(), qreal(window->width())); + QVERIFY(footer->height() > 0.0); + + QCOMPARE(content->x(), 0.0); + QCOMPARE(content->y(), header->height()); + QCOMPARE(content->width(), qreal(window->width())); + QCOMPARE(content->height(), window->height() - header->height() - footer->height()); + + header->setVisible(false); + QCOMPARE(content->x(), 0.0); + QCOMPARE(content->y(), 0.0); + QCOMPARE(content->width(), qreal(window->width())); + QCOMPARE(content->height(), window->height() - footer->height()); + + footer->setVisible(false); + QCOMPARE(content->x(), 0.0); + QCOMPARE(content->y(), 0.0); + QCOMPARE(content->width(), qreal(window->width())); + QCOMPARE(content->height(), qreal(window->height())); +} + +class FriendlyApplicationWindow : public QQuickApplicationWindow +{ + friend class tst_QQuickApplicationWindow; +}; + +void tst_QQuickApplicationWindow::componentComplete() +{ + FriendlyApplicationWindow cppWindow; + QVERIFY(cppWindow.isComponentComplete()); + + QQmlEngine engine; + QQmlComponent component(&engine); + component.setData("import QtQuick.Controls 2.2; ApplicationWindow { }", QUrl()); + + FriendlyApplicationWindow *qmlWindow = static_cast(component.beginCreate(engine.rootContext())); + QVERIFY(qmlWindow); + QVERIFY(!qmlWindow->isComponentComplete()); + + component.completeCreate(); + QVERIFY(qmlWindow->isComponentComplete()); +} + +QTEST_MAIN(tst_QQuickApplicationWindow) + +#include "tst_qquickapplicationwindow.moc" -- cgit v1.2.3 From 576a97774e04858adee9f2080e485a715e985820 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 27 Sep 2017 15:14:32 +0200 Subject: Rename tst_menu to tst_QQuickMenu Change-Id: I1c7e1a2b337e9d16bc6c9b098db08f29f1b9d1e6 Reviewed-by: Mitch Curtis --- tests/auto/auto.pro | 4 +- tests/auto/menu/data/addItem.qml | 71 ---- tests/auto/menu/data/applicationwindow.qml | 91 ----- tests/auto/menu/data/menuSeparator.qml | 83 ---- tests/auto/menu/data/order.qml | 81 ---- tests/auto/menu/data/pressAndHold.qml | 73 ---- tests/auto/menu/data/repeater.qml | 69 ---- tests/auto/menu/menu.pro | 15 - tests/auto/menu/tst_menu.cpp | 482 ----------------------- tests/auto/qquickmenu/data/addItem.qml | 71 ++++ tests/auto/qquickmenu/data/applicationwindow.qml | 91 +++++ tests/auto/qquickmenu/data/menuSeparator.qml | 83 ++++ tests/auto/qquickmenu/data/order.qml | 81 ++++ tests/auto/qquickmenu/data/pressAndHold.qml | 73 ++++ tests/auto/qquickmenu/data/repeater.qml | 69 ++++ tests/auto/qquickmenu/qquickmenu.pro | 15 + tests/auto/qquickmenu/tst_qquickmenu.cpp | 482 +++++++++++++++++++++++ 17 files changed, 967 insertions(+), 967 deletions(-) delete mode 100644 tests/auto/menu/data/addItem.qml delete mode 100644 tests/auto/menu/data/applicationwindow.qml delete mode 100644 tests/auto/menu/data/menuSeparator.qml delete mode 100644 tests/auto/menu/data/order.qml delete mode 100644 tests/auto/menu/data/pressAndHold.qml delete mode 100644 tests/auto/menu/data/repeater.qml delete mode 100644 tests/auto/menu/menu.pro delete mode 100644 tests/auto/menu/tst_menu.cpp create mode 100644 tests/auto/qquickmenu/data/addItem.qml create mode 100644 tests/auto/qquickmenu/data/applicationwindow.qml create mode 100644 tests/auto/qquickmenu/data/menuSeparator.qml create mode 100644 tests/auto/qquickmenu/data/order.qml create mode 100644 tests/auto/qquickmenu/data/pressAndHold.qml create mode 100644 tests/auto/qquickmenu/data/repeater.qml create mode 100644 tests/auto/qquickmenu/qquickmenu.pro create mode 100644 tests/auto/qquickmenu/tst_qquickmenu.cpp (limited to 'tests/auto') diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 2eb23fd0..0aeef414 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -6,13 +6,13 @@ SUBDIRS += \ cursor \ focus \ font \ - menu \ platform \ pressandhold \ qquickapplicationwindow \ qquickdrawer \ qquickmaterialstyle \ qquickmaterialstyleconf \ + qquickmenu \ qquickpopup \ qquickstyle \ qquickstyleselector \ @@ -24,6 +24,6 @@ SUBDIRS += \ # QTBUG-60268 boot2qt: SUBDIRS -= qquickapplicationwindow calendar controls cursor \ - qquickdrawer focus font menu platform qquickpopup qquickmaterialstyle \ + qquickdrawer focus font qquickmenu platform qquickpopup qquickmaterialstyle \ qquickmaterialstyleconf qquickuniversalstyle \ qquickuniversalstyleconf snippets diff --git a/tests/auto/menu/data/addItem.qml b/tests/auto/menu/data/addItem.qml deleted file mode 100644 index 0668e439..00000000 --- a/tests/auto/menu/data/addItem.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.1 - -ApplicationWindow { - width: 200 - height: 200 - - property alias menu: menu - - MenuItem { - id: newMenuItem - text: qsTr("New") - } - - Menu { - id: menu - y: parent.height - - Component.onCompleted: addItem(newMenuItem) - } -} diff --git a/tests/auto/menu/data/applicationwindow.qml b/tests/auto/menu/data/applicationwindow.qml deleted file mode 100644 index 265a2f1a..00000000 --- a/tests/auto/menu/data/applicationwindow.qml +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.6 -import QtQuick.Controls 2.1 - -ApplicationWindow { - title: "Test Application Window" - width: 400 - height: 400 - - property alias emptyMenu: emptyMenu - property alias menu: menu - property alias menuButton: menuButton - - Menu { - id: emptyMenu - } - - Menu { - id: menu - - MenuItem { - objectName: "firstMenuItem" - text: "A" - } - MenuItem { - objectName: "secondMenuItem" - text: "B" - } - MenuItem { - objectName: "thirdMenuItem" - text: "C" - } - } - - Button { - id: menuButton - x: 250 - visible: false - text: "Open Menu" - onClicked: menu.open() - } -} diff --git a/tests/auto/menu/data/menuSeparator.qml b/tests/auto/menu/data/menuSeparator.qml deleted file mode 100644 index 6cdf8b27..00000000 --- a/tests/auto/menu/data/menuSeparator.qml +++ /dev/null @@ -1,83 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.6 -import QtQuick.Controls 2.1 - -ApplicationWindow { - width: 200 - height: 200 - - property alias menu: menu - - MenuItem { - id: newMenuItem - text: qsTr("New") - } - - MenuSeparator { - id: menuSeparator - } - - MenuItem { - id: saveMenuItem - text: qsTr("Save") - } - - Menu { - id: menu - - Component.onCompleted: { - addItem(newMenuItem) - addItem(menuSeparator) - addItem(saveMenuItem) - } - } -} diff --git a/tests/auto/menu/data/order.qml b/tests/auto/menu/data/order.qml deleted file mode 100644 index db5c3c1a..00000000 --- a/tests/auto/menu/data/order.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.Controls 2.1 - -ApplicationWindow { - width: 200 - height: 200 - - property alias menu: menu - - Component { - id: menuItem - MenuItem { } - } - - Menu { - id: menu - property alias repeater: repeater - MenuItem { text: "static_1" } - Repeater { - id: repeater - model: 2 - MenuItem { text: "repeated_" + (index + 2) } - } - MenuItem { text: "static_4" } - Component.onCompleted: { - addItem(menuItem.createObject(menu.contentItem, {text: "dynamic_5"})) - addItem(menuItem.createObject(menu.contentItem, {text: "dynamic_6"})) - insertItem(0, menuItem.createObject(menu.contentItem, {text: "dynamic_0"})) - } - } -} diff --git a/tests/auto/menu/data/pressAndHold.qml b/tests/auto/menu/data/pressAndHold.qml deleted file mode 100644 index 6f0acd3a..00000000 --- a/tests/auto/menu/data/pressAndHold.qml +++ /dev/null @@ -1,73 +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 menu: menu - - MouseArea { - anchors.fill: parent - onPressAndHold: menu.open() - } - - Menu { - id: menu - x: (parent.width - width) / 2 - y: (parent.height - height) / 2 - MenuItem { text: "One" } - MenuItem { text: "Two" } - MenuItem { text: "Three" } - } -} diff --git a/tests/auto/menu/data/repeater.qml b/tests/auto/menu/data/repeater.qml deleted file mode 100644 index 2172f86a..00000000 --- a/tests/auto/menu/data/repeater.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: 200 - height: 200 - - property alias menu: menu - property alias repeater: repeater - - Menu { - id: menu - Repeater { - id: repeater - model: 5 - MenuItem { property int idx: index } - } - } -} diff --git a/tests/auto/menu/menu.pro b/tests/auto/menu/menu.pro deleted file mode 100644 index 9c9d9b48..00000000 --- a/tests/auto/menu/menu.pro +++ /dev/null @@ -1,15 +0,0 @@ -CONFIG += testcase -TARGET = tst_menu -SOURCES += tst_menu.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/menu/tst_menu.cpp b/tests/auto/menu/tst_menu.cpp deleted file mode 100644 index 79598373..00000000 --- a/tests/auto/menu/tst_menu.cpp +++ /dev/null @@ -1,482 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL3$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPLv3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or later as published by the Free -** Software Foundation and appearing in the file LICENSE.GPL included in -** the packaging of this file. Please review the following information to -** ensure the GNU General Public License version 2.0 requirements will be -** met: http://www.gnu.org/licenses/gpl-2.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include "../shared/util.h" -#include "../shared/visualtestutil.h" - -#include -#include -#include -#include -#include -#include - -using namespace QQuickVisualTestUtil; - -class tst_menu : public QQmlDataTest -{ - Q_OBJECT - -public: - -private slots: - void defaults(); - void mouse(); - void pressAndHold(); - void contextMenuKeyboard(); - void menuButton(); - void addItem(); - void menuSeparator(); - void repeater(); - void order(); -}; - -void tst_menu::defaults() -{ - QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml")); - - QQuickMenu *emptyMenu = helper.appWindow->property("emptyMenu").value(); - QCOMPARE(emptyMenu->isVisible(), false); - QCOMPARE(emptyMenu->contentItem()->property("currentIndex"), QVariant(-1)); -} - -void tst_menu::mouse() -{ - QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml")); - - QQuickApplicationWindow *window = helper.appWindow; - window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickMenu *menu = window->property("menu").value(); - menu->open(); - QVERIFY(menu->isVisible()); - QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem())); - - QQuickItem *firstItem = menu->itemAt(0); - QSignalSpy clickedSpy(firstItem, SIGNAL(clicked())); - QSignalSpy triggeredSpy(firstItem, SIGNAL(triggered())); - QSignalSpy visibleSpy(menu, SIGNAL(visibleChanged())); - - // Ensure that presses cause the current index to change, - // so that the highlight acts as a way of illustrating press state. - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(firstItem->width() / 2, firstItem->height() / 2)); - QVERIFY(firstItem->hasActiveFocus()); - QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(0)); - QVERIFY(menu->isVisible()); - - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(firstItem->width() / 2, firstItem->height() / 2)); - QCOMPARE(clickedSpy.count(), 1); - QCOMPARE(triggeredSpy.count(), 1); - QCOMPARE(visibleSpy.count(), 1); - QVERIFY(!menu->isVisible()); - QVERIFY(!window->overlay()->childItems().contains(menu->contentItem())); - QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(-1)); - - menu->open(); - QCOMPARE(visibleSpy.count(), 2); - QVERIFY(menu->isVisible()); - QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem())); - - // Ensure that we have enough space to click outside of the menu. - QVERIFY(window->width() > menu->contentItem()->width()); - QVERIFY(window->height() > menu->contentItem()->height()); - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, - QPoint(menu->contentItem()->width() + 1, menu->contentItem()->height() + 1)); - QCOMPARE(visibleSpy.count(), 3); - QVERIFY(!menu->isVisible()); - QVERIFY(!window->overlay()->childItems().contains(menu->contentItem()->parentItem())); - - menu->open(); - QCOMPARE(visibleSpy.count(), 4); - QVERIFY(menu->isVisible()); - QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem())); - - // Try pressing within the menu and releasing outside of it; it should close. - // TODO: won't work until QQuickPopup::releasedOutside() actually gets emitted -// QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(firstItem->width() / 2, firstItem->height() / 2)); -// QVERIFY(firstItem->hasActiveFocus()); -// QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(0)); -// QVERIFY(menu->isVisible()); -// QCOMPARE(triggeredSpy.count(), 1); - -// QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(menu->contentItem()->width() + 1, firstItem->height() / 2)); -// QCOMPARE(clickedSpy.count(), 1); -// QCOMPARE(triggeredSpy.count(), 1); -// QCOMPARE(visibleSpy.count(), 5); -// QVERIFY(!menu->isVisible()); -// QVERIFY(!window->overlay()->childItems().contains(menu->contentItem())); -// QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(-1)); -} - -void tst_menu::pressAndHold() -{ - QQuickApplicationHelper helper(this, QLatin1String("pressAndHold.qml")); - - QQuickWindow *window = helper.window; - window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickMenu *menu = window->property("menu").value(); - QVERIFY(menu); - - QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); - QTRY_VERIFY(menu->isVisible()); - - QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); - QVERIFY(menu->isVisible()); - - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); - QTRY_VERIFY(!menu->isVisible()); -} - -void tst_menu::contextMenuKeyboard() -{ - if (QGuiApplication::styleHints()->tabFocusBehavior() != Qt::TabFocusAllControls) - QSKIP("This platform only allows tab focus for text controls"); - - QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml")); - - QQuickApplicationWindow *window = helper.appWindow; - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - QVERIFY(QGuiApplication::focusWindow() == window); - - QQuickMenu *menu = window->property("menu").value(); - QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(-1)); - - QQuickMenuItem *firstItem = qobject_cast(menu->itemAt(0)); - QVERIFY(firstItem); - QSignalSpy visibleSpy(menu, SIGNAL(visibleChanged())); - - menu->setFocus(true); - menu->open(); - QCOMPARE(visibleSpy.count(), 1); - QVERIFY(menu->isVisible()); - QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem())); - QVERIFY(!firstItem->hasActiveFocus()); - QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(-1)); - - QTest::keyClick(window, Qt::Key_Tab); - QVERIFY(firstItem->hasActiveFocus()); - QVERIFY(firstItem->hasVisualFocus()); - QCOMPARE(firstItem->focusReason(), Qt::TabFocusReason); - QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(0)); - - QQuickMenuItem *secondItem = qobject_cast(menu->itemAt(1)); - QVERIFY(secondItem); - QTest::keyClick(window, Qt::Key_Tab); - QVERIFY(!firstItem->hasActiveFocus()); - QVERIFY(!firstItem->hasVisualFocus()); - QVERIFY(secondItem->hasActiveFocus()); - QVERIFY(secondItem->hasVisualFocus()); - QCOMPARE(secondItem->focusReason(), Qt::TabFocusReason); - QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(1)); - - QSignalSpy secondTriggeredSpy(secondItem, SIGNAL(triggered())); - QTest::keyClick(window, Qt::Key_Space); - QCOMPARE(secondTriggeredSpy.count(), 1); - QCOMPARE(visibleSpy.count(), 2); - QVERIFY(!menu->isVisible()); - QVERIFY(!window->overlay()->childItems().contains(menu->contentItem())); - QVERIFY(!firstItem->hasActiveFocus()); - QVERIFY(!firstItem->hasVisualFocus()); - QVERIFY(!secondItem->hasActiveFocus()); - QVERIFY(!secondItem->hasVisualFocus()); - QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(-1)); - - menu->open(); - QCOMPARE(visibleSpy.count(), 3); - QVERIFY(menu->isVisible()); - QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem())); - QVERIFY(!firstItem->hasActiveFocus()); - QVERIFY(!firstItem->hasVisualFocus()); - QVERIFY(!secondItem->hasActiveFocus()); - QVERIFY(!secondItem->hasVisualFocus()); - QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(-1)); - - QTest::keyClick(window, Qt::Key_Down); - QVERIFY(firstItem->hasActiveFocus()); - QVERIFY(firstItem->hasVisualFocus()); - QCOMPARE(firstItem->focusReason(), Qt::TabFocusReason); - - QTest::keyClick(window, Qt::Key_Down); - QVERIFY(secondItem->hasActiveFocus()); - QVERIFY(secondItem->hasVisualFocus()); - QCOMPARE(secondItem->focusReason(), Qt::TabFocusReason); - - QTest::keyClick(window, Qt::Key_Down); - QQuickMenuItem *thirdItem = qobject_cast(menu->itemAt(2)); - QVERIFY(thirdItem); - QVERIFY(!firstItem->hasActiveFocus()); - QVERIFY(!firstItem->hasVisualFocus()); - QVERIFY(!secondItem->hasActiveFocus()); - QVERIFY(!secondItem->hasVisualFocus()); - QVERIFY(thirdItem->hasActiveFocus()); - QVERIFY(thirdItem->hasVisualFocus()); - QCOMPARE(thirdItem->focusReason(), Qt::TabFocusReason); - - // Key navigation shouldn't wrap by default. - QTest::keyClick(window, Qt::Key_Down); - QVERIFY(!firstItem->hasActiveFocus()); - QVERIFY(!firstItem->hasVisualFocus()); - QVERIFY(!secondItem->hasActiveFocus()); - QVERIFY(!secondItem->hasVisualFocus()); - QVERIFY(thirdItem->hasActiveFocus()); - QVERIFY(thirdItem->hasVisualFocus()); - QCOMPARE(thirdItem->focusReason(), Qt::TabFocusReason); - - QTest::keyClick(window, Qt::Key_Up); - QVERIFY(!firstItem->hasActiveFocus()); - QVERIFY(!firstItem->hasVisualFocus()); - QVERIFY(secondItem->hasActiveFocus()); - QVERIFY(secondItem->hasVisualFocus()); - QCOMPARE(secondItem->focusReason(), Qt::BacktabFocusReason); - QVERIFY(!thirdItem->hasActiveFocus()); - QVERIFY(!thirdItem->hasVisualFocus()); - - QTest::keyClick(window, Qt::Key_Backtab); - QVERIFY(firstItem->hasActiveFocus()); - QVERIFY(firstItem->hasVisualFocus()); - QCOMPARE(firstItem->focusReason(), Qt::BacktabFocusReason); - QVERIFY(!secondItem->hasActiveFocus()); - QVERIFY(!secondItem->hasVisualFocus()); - QVERIFY(!thirdItem->hasActiveFocus()); - QVERIFY(!thirdItem->hasVisualFocus()); - - QTest::keyClick(window, Qt::Key_Escape); - QCOMPARE(visibleSpy.count(), 4); - QVERIFY(!menu->isVisible()); -} - -void tst_menu::menuButton() -{ - if (QGuiApplication::styleHints()->tabFocusBehavior() != Qt::TabFocusAllControls) - QSKIP("This platform only allows tab focus for text controls"); - - QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml")); - - QQuickApplicationWindow *window = helper.appWindow; - window->show(); - window->requestActivate(); - QVERIFY(QTest::qWaitForWindowActive(window)); - QVERIFY(QGuiApplication::focusWindow() == window); - - QQuickMenu *menu = window->property("menu").value(); - QQuickButton *menuButton = window->property("menuButton").value(); - QSignalSpy visibleSpy(menu, SIGNAL(visibleChanged())); - - menuButton->setVisible(true); - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, - menuButton->mapToScene(QPointF(menuButton->width() / 2, menuButton->height() / 2)).toPoint()); - QCOMPARE(visibleSpy.count(), 1); - QVERIFY(menu->isVisible()); - - QTest::keyClick(window, Qt::Key_Tab); - QQuickItem *firstItem = menu->itemAt(0); - QVERIFY(firstItem->hasActiveFocus()); -} - -void tst_menu::addItem() -{ - QQuickApplicationHelper helper(this, QLatin1String("addItem.qml")); - QQuickApplicationWindow *window = helper.appWindow; - window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickMenu *menu = window->property("menu").value(); - QVERIFY(menu); - menu->open(); - QVERIFY(menu->isVisible()); - - QQuickItem *menuItem = menu->itemAt(0); - QVERIFY(menuItem); - QTRY_VERIFY(!QQuickItemPrivate::get(menuItem)->culled); // QTBUG-53262 - - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, - menuItem->mapToScene(QPointF(menuItem->width() / 2, menuItem->height() / 2)).toPoint()); - QTRY_VERIFY(!menu->isVisible()); -} - -void tst_menu::menuSeparator() -{ - QQuickApplicationHelper helper(this, QLatin1String("menuSeparator.qml")); - QQuickWindow *window = helper.window; - window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickMenu *menu = window->property("menu").value(); - QVERIFY(menu); - menu->open(); - QVERIFY(menu->isVisible()); - - QQuickMenuItem *newMenuItem = qobject_cast(menu->itemAt(0)); - QVERIFY(newMenuItem); - QCOMPARE(newMenuItem->text(), QStringLiteral("New")); - - QQuickMenuSeparator *menuSeparator = qobject_cast(menu->itemAt(1)); - QVERIFY(menuSeparator); - - QQuickMenuItem *saveMenuItem = qobject_cast(menu->itemAt(2)); - QVERIFY(saveMenuItem); - QCOMPARE(saveMenuItem->text(), QStringLiteral("Save")); - QTRY_VERIFY(!QQuickItemPrivate::get(saveMenuItem)->culled); // QTBUG-53262 - - // Clicking on items should still close the menu. - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, - newMenuItem->mapToScene(QPointF(newMenuItem->width() / 2, newMenuItem->height() / 2)).toPoint()); - QTRY_VERIFY(!menu->isVisible()); - - menu->open(); - QVERIFY(menu->isVisible()); - - // Clicking on a separator shouldn't close the menu. - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, - menuSeparator->mapToScene(QPointF(menuSeparator->width() / 2, menuSeparator->height() / 2)).toPoint()); - QVERIFY(menu->isVisible()); - - // Clicking on items should still close the menu. - QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, - saveMenuItem->mapToScene(QPointF(saveMenuItem->width() / 2, saveMenuItem->height() / 2)).toPoint()); - QTRY_VERIFY(!menu->isVisible()); - - menu->open(); - QVERIFY(menu->isVisible()); - - // Key navigation skips separators - QTest::keyClick(window, Qt::Key_Down); - QVERIFY(newMenuItem->hasActiveFocus()); - QVERIFY(newMenuItem->hasVisualFocus()); - QCOMPARE(newMenuItem->focusReason(), Qt::TabFocusReason); - - QTest::keyClick(window, Qt::Key_Down); - QVERIFY(saveMenuItem->hasActiveFocus()); - QVERIFY(saveMenuItem->hasVisualFocus()); - QCOMPARE(saveMenuItem->focusReason(), Qt::TabFocusReason); - - QTest::keyClick(window, Qt::Key_Down); - QVERIFY(saveMenuItem->hasActiveFocus()); - QVERIFY(saveMenuItem->hasVisualFocus()); - QCOMPARE(saveMenuItem->focusReason(), Qt::TabFocusReason); - - QTest::keyClick(window, Qt::Key_Up); - QVERIFY(newMenuItem->hasActiveFocus()); - QVERIFY(newMenuItem->hasVisualFocus()); - QCOMPARE(newMenuItem->focusReason(), Qt::BacktabFocusReason); - - QTest::keyClick(window, Qt::Key_Up); - QVERIFY(newMenuItem->hasActiveFocus()); - QVERIFY(newMenuItem->hasVisualFocus()); - QCOMPARE(newMenuItem->focusReason(), Qt::BacktabFocusReason); -} - -void tst_menu::repeater() -{ - QQuickApplicationHelper helper(this, QLatin1String("repeater.qml")); - QQuickWindow *window = helper.window; - window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickMenu *menu = window->property("menu").value(); - QVERIFY(menu); - menu->open(); - QVERIFY(menu->isVisible()); - - QObject *repeater = window->property("repeater").value(); - QVERIFY(repeater); - - int count = repeater->property("count").toInt(); - QCOMPARE(count, 5); - - for (int i = 0; i < count; ++i) { - QQuickItem *item = menu->itemAt(i); - QVERIFY(item); - QCOMPARE(item->property("idx").toInt(), i); - - QQuickItem *repeaterItem = nullptr; - QVERIFY(QMetaObject::invokeMethod(repeater, "itemAt", Q_RETURN_ARG(QQuickItem*, repeaterItem), Q_ARG(int, i))); - QCOMPARE(item, repeaterItem); - } - - repeater->setProperty("model", 3); - - count = repeater->property("count").toInt(); - QCOMPARE(count, 3); - - for (int i = 0; i < count; ++i) { - QQuickItem *item = menu->itemAt(i); - QVERIFY(item); - QCOMPARE(item->property("idx").toInt(), i); - - QQuickItem *repeaterItem = nullptr; - QVERIFY(QMetaObject::invokeMethod(repeater, "itemAt", Q_RETURN_ARG(QQuickItem*, repeaterItem), Q_ARG(int, i))); - QCOMPARE(item, repeaterItem); - } -} - -void tst_menu::order() -{ - QQuickApplicationHelper helper(this, QLatin1String("order.qml")); - QQuickWindow *window = helper.window; - window->show(); - QVERIFY(QTest::qWaitForWindowActive(window)); - - QQuickMenu *menu = window->property("menu").value(); - QVERIFY(menu); - menu->open(); - QVERIFY(menu->isVisible()); - - const QStringList texts = {"dynamic_0", "static_1", "repeated_2", "repeated_3", "static_4", "dynamic_5", "dynamic_6"}; - - for (int i = 0; i < texts.count(); ++i) { - QQuickItem *item = menu->itemAt(i); - QVERIFY(item); - QCOMPARE(item->property("text").toString(), texts.at(i)); - } -} - -QTEST_MAIN(tst_menu) - -#include "tst_menu.moc" diff --git a/tests/auto/qquickmenu/data/addItem.qml b/tests/auto/qquickmenu/data/addItem.qml new file mode 100644 index 00000000..0668e439 --- /dev/null +++ b/tests/auto/qquickmenu/data/addItem.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.1 + +ApplicationWindow { + width: 200 + height: 200 + + property alias menu: menu + + MenuItem { + id: newMenuItem + text: qsTr("New") + } + + Menu { + id: menu + y: parent.height + + Component.onCompleted: addItem(newMenuItem) + } +} diff --git a/tests/auto/qquickmenu/data/applicationwindow.qml b/tests/auto/qquickmenu/data/applicationwindow.qml new file mode 100644 index 00000000..265a2f1a --- /dev/null +++ b/tests/auto/qquickmenu/data/applicationwindow.qml @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Controls 2.1 + +ApplicationWindow { + title: "Test Application Window" + width: 400 + height: 400 + + property alias emptyMenu: emptyMenu + property alias menu: menu + property alias menuButton: menuButton + + Menu { + id: emptyMenu + } + + Menu { + id: menu + + MenuItem { + objectName: "firstMenuItem" + text: "A" + } + MenuItem { + objectName: "secondMenuItem" + text: "B" + } + MenuItem { + objectName: "thirdMenuItem" + text: "C" + } + } + + Button { + id: menuButton + x: 250 + visible: false + text: "Open Menu" + onClicked: menu.open() + } +} diff --git a/tests/auto/qquickmenu/data/menuSeparator.qml b/tests/auto/qquickmenu/data/menuSeparator.qml new file mode 100644 index 00000000..6cdf8b27 --- /dev/null +++ b/tests/auto/qquickmenu/data/menuSeparator.qml @@ -0,0 +1,83 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** BSD License Usage +** Alternatively, you may use this file under the terms of the BSD license +** as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of The Qt Company Ltd nor the names of its +** contributors may be used to endorse or promote products derived +** from this software without specific prior written permission. +** +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import QtQuick.Controls 2.1 + +ApplicationWindow { + width: 200 + height: 200 + + property alias menu: menu + + MenuItem { + id: newMenuItem + text: qsTr("New") + } + + MenuSeparator { + id: menuSeparator + } + + MenuItem { + id: saveMenuItem + text: qsTr("Save") + } + + Menu { + id: menu + + Component.onCompleted: { + addItem(newMenuItem) + addItem(menuSeparator) + addItem(saveMenuItem) + } + } +} diff --git a/tests/auto/qquickmenu/data/order.qml b/tests/auto/qquickmenu/data/order.qml new file mode 100644 index 00000000..db5c3c1a --- /dev/null +++ b/tests/auto/qquickmenu/data/order.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.Controls 2.1 + +ApplicationWindow { + width: 200 + height: 200 + + property alias menu: menu + + Component { + id: menuItem + MenuItem { } + } + + Menu { + id: menu + property alias repeater: repeater + MenuItem { text: "static_1" } + Repeater { + id: repeater + model: 2 + MenuItem { text: "repeated_" + (index + 2) } + } + MenuItem { text: "static_4" } + Component.onCompleted: { + addItem(menuItem.createObject(menu.contentItem, {text: "dynamic_5"})) + addItem(menuItem.createObject(menu.contentItem, {text: "dynamic_6"})) + insertItem(0, menuItem.createObject(menu.contentItem, {text: "dynamic_0"})) + } + } +} diff --git a/tests/auto/qquickmenu/data/pressAndHold.qml b/tests/auto/qquickmenu/data/pressAndHold.qml new file mode 100644 index 00000000..6f0acd3a --- /dev/null +++ b/tests/auto/qquickmenu/data/pressAndHold.qml @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** 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 menu: menu + + MouseArea { + anchors.fill: parent + onPressAndHold: menu.open() + } + + Menu { + id: menu + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + MenuItem { text: "One" } + MenuItem { text: "Two" } + MenuItem { text: "Three" } + } +} diff --git a/tests/auto/qquickmenu/data/repeater.qml b/tests/auto/qquickmenu/data/repeater.qml new file mode 100644 index 00000000..2172f86a --- /dev/null +++ b/tests/auto/qquickmenu/data/repeater.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: 200 + height: 200 + + property alias menu: menu + property alias repeater: repeater + + Menu { + id: menu + Repeater { + id: repeater + model: 5 + MenuItem { property int idx: index } + } + } +} diff --git a/tests/auto/qquickmenu/qquickmenu.pro b/tests/auto/qquickmenu/qquickmenu.pro new file mode 100644 index 00000000..ee539842 --- /dev/null +++ b/tests/auto/qquickmenu/qquickmenu.pro @@ -0,0 +1,15 @@ +CONFIG += testcase +TARGET = tst_qquickmenu +SOURCES += tst_qquickmenu.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/qquickmenu/tst_qquickmenu.cpp b/tests/auto/qquickmenu/tst_qquickmenu.cpp new file mode 100644 index 00000000..717e892b --- /dev/null +++ b/tests/auto/qquickmenu/tst_qquickmenu.cpp @@ -0,0 +1,482 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "../shared/util.h" +#include "../shared/visualtestutil.h" + +#include +#include +#include +#include +#include +#include + +using namespace QQuickVisualTestUtil; + +class tst_QQuickMenu : public QQmlDataTest +{ + Q_OBJECT + +public: + +private slots: + void defaults(); + void mouse(); + void pressAndHold(); + void contextMenuKeyboard(); + void menuButton(); + void addItem(); + void menuSeparator(); + void repeater(); + void order(); +}; + +void tst_QQuickMenu::defaults() +{ + QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml")); + + QQuickMenu *emptyMenu = helper.appWindow->property("emptyMenu").value(); + QCOMPARE(emptyMenu->isVisible(), false); + QCOMPARE(emptyMenu->contentItem()->property("currentIndex"), QVariant(-1)); +} + +void tst_QQuickMenu::mouse() +{ + QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml")); + + QQuickApplicationWindow *window = helper.appWindow; + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickMenu *menu = window->property("menu").value(); + menu->open(); + QVERIFY(menu->isVisible()); + QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem())); + + QQuickItem *firstItem = menu->itemAt(0); + QSignalSpy clickedSpy(firstItem, SIGNAL(clicked())); + QSignalSpy triggeredSpy(firstItem, SIGNAL(triggered())); + QSignalSpy visibleSpy(menu, SIGNAL(visibleChanged())); + + // Ensure that presses cause the current index to change, + // so that the highlight acts as a way of illustrating press state. + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(firstItem->width() / 2, firstItem->height() / 2)); + QVERIFY(firstItem->hasActiveFocus()); + QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(0)); + QVERIFY(menu->isVisible()); + + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(firstItem->width() / 2, firstItem->height() / 2)); + QCOMPARE(clickedSpy.count(), 1); + QCOMPARE(triggeredSpy.count(), 1); + QCOMPARE(visibleSpy.count(), 1); + QVERIFY(!menu->isVisible()); + QVERIFY(!window->overlay()->childItems().contains(menu->contentItem())); + QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(-1)); + + menu->open(); + QCOMPARE(visibleSpy.count(), 2); + QVERIFY(menu->isVisible()); + QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem())); + + // Ensure that we have enough space to click outside of the menu. + QVERIFY(window->width() > menu->contentItem()->width()); + QVERIFY(window->height() > menu->contentItem()->height()); + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, + QPoint(menu->contentItem()->width() + 1, menu->contentItem()->height() + 1)); + QCOMPARE(visibleSpy.count(), 3); + QVERIFY(!menu->isVisible()); + QVERIFY(!window->overlay()->childItems().contains(menu->contentItem()->parentItem())); + + menu->open(); + QCOMPARE(visibleSpy.count(), 4); + QVERIFY(menu->isVisible()); + QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem())); + + // Try pressing within the menu and releasing outside of it; it should close. + // TODO: won't work until QQuickPopup::releasedOutside() actually gets emitted +// QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(firstItem->width() / 2, firstItem->height() / 2)); +// QVERIFY(firstItem->hasActiveFocus()); +// QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(0)); +// QVERIFY(menu->isVisible()); +// QCOMPARE(triggeredSpy.count(), 1); + +// QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(menu->contentItem()->width() + 1, firstItem->height() / 2)); +// QCOMPARE(clickedSpy.count(), 1); +// QCOMPARE(triggeredSpy.count(), 1); +// QCOMPARE(visibleSpy.count(), 5); +// QVERIFY(!menu->isVisible()); +// QVERIFY(!window->overlay()->childItems().contains(menu->contentItem())); +// QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(-1)); +} + +void tst_QQuickMenu::pressAndHold() +{ + QQuickApplicationHelper helper(this, QLatin1String("pressAndHold.qml")); + + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickMenu *menu = window->property("menu").value(); + QVERIFY(menu); + + QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); + QTRY_VERIFY(menu->isVisible()); + + QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); + QVERIFY(menu->isVisible()); + + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, QPoint(1, 1)); + QTRY_VERIFY(!menu->isVisible()); +} + +void tst_QQuickMenu::contextMenuKeyboard() +{ + if (QGuiApplication::styleHints()->tabFocusBehavior() != Qt::TabFocusAllControls) + QSKIP("This platform only allows tab focus for text controls"); + + QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml")); + + QQuickApplicationWindow *window = helper.appWindow; + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QGuiApplication::focusWindow() == window); + + QQuickMenu *menu = window->property("menu").value(); + QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(-1)); + + QQuickMenuItem *firstItem = qobject_cast(menu->itemAt(0)); + QVERIFY(firstItem); + QSignalSpy visibleSpy(menu, SIGNAL(visibleChanged())); + + menu->setFocus(true); + menu->open(); + QCOMPARE(visibleSpy.count(), 1); + QVERIFY(menu->isVisible()); + QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem())); + QVERIFY(!firstItem->hasActiveFocus()); + QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(-1)); + + QTest::keyClick(window, Qt::Key_Tab); + QVERIFY(firstItem->hasActiveFocus()); + QVERIFY(firstItem->hasVisualFocus()); + QCOMPARE(firstItem->focusReason(), Qt::TabFocusReason); + QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(0)); + + QQuickMenuItem *secondItem = qobject_cast(menu->itemAt(1)); + QVERIFY(secondItem); + QTest::keyClick(window, Qt::Key_Tab); + QVERIFY(!firstItem->hasActiveFocus()); + QVERIFY(!firstItem->hasVisualFocus()); + QVERIFY(secondItem->hasActiveFocus()); + QVERIFY(secondItem->hasVisualFocus()); + QCOMPARE(secondItem->focusReason(), Qt::TabFocusReason); + QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(1)); + + QSignalSpy secondTriggeredSpy(secondItem, SIGNAL(triggered())); + QTest::keyClick(window, Qt::Key_Space); + QCOMPARE(secondTriggeredSpy.count(), 1); + QCOMPARE(visibleSpy.count(), 2); + QVERIFY(!menu->isVisible()); + QVERIFY(!window->overlay()->childItems().contains(menu->contentItem())); + QVERIFY(!firstItem->hasActiveFocus()); + QVERIFY(!firstItem->hasVisualFocus()); + QVERIFY(!secondItem->hasActiveFocus()); + QVERIFY(!secondItem->hasVisualFocus()); + QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(-1)); + + menu->open(); + QCOMPARE(visibleSpy.count(), 3); + QVERIFY(menu->isVisible()); + QVERIFY(window->overlay()->childItems().contains(menu->contentItem()->parentItem())); + QVERIFY(!firstItem->hasActiveFocus()); + QVERIFY(!firstItem->hasVisualFocus()); + QVERIFY(!secondItem->hasActiveFocus()); + QVERIFY(!secondItem->hasVisualFocus()); + QCOMPARE(menu->contentItem()->property("currentIndex"), QVariant(-1)); + + QTest::keyClick(window, Qt::Key_Down); + QVERIFY(firstItem->hasActiveFocus()); + QVERIFY(firstItem->hasVisualFocus()); + QCOMPARE(firstItem->focusReason(), Qt::TabFocusReason); + + QTest::keyClick(window, Qt::Key_Down); + QVERIFY(secondItem->hasActiveFocus()); + QVERIFY(secondItem->hasVisualFocus()); + QCOMPARE(secondItem->focusReason(), Qt::TabFocusReason); + + QTest::keyClick(window, Qt::Key_Down); + QQuickMenuItem *thirdItem = qobject_cast(menu->itemAt(2)); + QVERIFY(thirdItem); + QVERIFY(!firstItem->hasActiveFocus()); + QVERIFY(!firstItem->hasVisualFocus()); + QVERIFY(!secondItem->hasActiveFocus()); + QVERIFY(!secondItem->hasVisualFocus()); + QVERIFY(thirdItem->hasActiveFocus()); + QVERIFY(thirdItem->hasVisualFocus()); + QCOMPARE(thirdItem->focusReason(), Qt::TabFocusReason); + + // Key navigation shouldn't wrap by default. + QTest::keyClick(window, Qt::Key_Down); + QVERIFY(!firstItem->hasActiveFocus()); + QVERIFY(!firstItem->hasVisualFocus()); + QVERIFY(!secondItem->hasActiveFocus()); + QVERIFY(!secondItem->hasVisualFocus()); + QVERIFY(thirdItem->hasActiveFocus()); + QVERIFY(thirdItem->hasVisualFocus()); + QCOMPARE(thirdItem->focusReason(), Qt::TabFocusReason); + + QTest::keyClick(window, Qt::Key_Up); + QVERIFY(!firstItem->hasActiveFocus()); + QVERIFY(!firstItem->hasVisualFocus()); + QVERIFY(secondItem->hasActiveFocus()); + QVERIFY(secondItem->hasVisualFocus()); + QCOMPARE(secondItem->focusReason(), Qt::BacktabFocusReason); + QVERIFY(!thirdItem->hasActiveFocus()); + QVERIFY(!thirdItem->hasVisualFocus()); + + QTest::keyClick(window, Qt::Key_Backtab); + QVERIFY(firstItem->hasActiveFocus()); + QVERIFY(firstItem->hasVisualFocus()); + QCOMPARE(firstItem->focusReason(), Qt::BacktabFocusReason); + QVERIFY(!secondItem->hasActiveFocus()); + QVERIFY(!secondItem->hasVisualFocus()); + QVERIFY(!thirdItem->hasActiveFocus()); + QVERIFY(!thirdItem->hasVisualFocus()); + + QTest::keyClick(window, Qt::Key_Escape); + QCOMPARE(visibleSpy.count(), 4); + QVERIFY(!menu->isVisible()); +} + +void tst_QQuickMenu::menuButton() +{ + if (QGuiApplication::styleHints()->tabFocusBehavior() != Qt::TabFocusAllControls) + QSKIP("This platform only allows tab focus for text controls"); + + QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml")); + + QQuickApplicationWindow *window = helper.appWindow; + window->show(); + window->requestActivate(); + QVERIFY(QTest::qWaitForWindowActive(window)); + QVERIFY(QGuiApplication::focusWindow() == window); + + QQuickMenu *menu = window->property("menu").value(); + QQuickButton *menuButton = window->property("menuButton").value(); + QSignalSpy visibleSpy(menu, SIGNAL(visibleChanged())); + + menuButton->setVisible(true); + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, + menuButton->mapToScene(QPointF(menuButton->width() / 2, menuButton->height() / 2)).toPoint()); + QCOMPARE(visibleSpy.count(), 1); + QVERIFY(menu->isVisible()); + + QTest::keyClick(window, Qt::Key_Tab); + QQuickItem *firstItem = menu->itemAt(0); + QVERIFY(firstItem->hasActiveFocus()); +} + +void tst_QQuickMenu::addItem() +{ + QQuickApplicationHelper helper(this, QLatin1String("addItem.qml")); + QQuickApplicationWindow *window = helper.appWindow; + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickMenu *menu = window->property("menu").value(); + QVERIFY(menu); + menu->open(); + QVERIFY(menu->isVisible()); + + QQuickItem *menuItem = menu->itemAt(0); + QVERIFY(menuItem); + QTRY_VERIFY(!QQuickItemPrivate::get(menuItem)->culled); // QTBUG-53262 + + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, + menuItem->mapToScene(QPointF(menuItem->width() / 2, menuItem->height() / 2)).toPoint()); + QTRY_VERIFY(!menu->isVisible()); +} + +void tst_QQuickMenu::menuSeparator() +{ + QQuickApplicationHelper helper(this, QLatin1String("menuSeparator.qml")); + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickMenu *menu = window->property("menu").value(); + QVERIFY(menu); + menu->open(); + QVERIFY(menu->isVisible()); + + QQuickMenuItem *newMenuItem = qobject_cast(menu->itemAt(0)); + QVERIFY(newMenuItem); + QCOMPARE(newMenuItem->text(), QStringLiteral("New")); + + QQuickMenuSeparator *menuSeparator = qobject_cast(menu->itemAt(1)); + QVERIFY(menuSeparator); + + QQuickMenuItem *saveMenuItem = qobject_cast(menu->itemAt(2)); + QVERIFY(saveMenuItem); + QCOMPARE(saveMenuItem->text(), QStringLiteral("Save")); + QTRY_VERIFY(!QQuickItemPrivate::get(saveMenuItem)->culled); // QTBUG-53262 + + // Clicking on items should still close the menu. + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, + newMenuItem->mapToScene(QPointF(newMenuItem->width() / 2, newMenuItem->height() / 2)).toPoint()); + QTRY_VERIFY(!menu->isVisible()); + + menu->open(); + QVERIFY(menu->isVisible()); + + // Clicking on a separator shouldn't close the menu. + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, + menuSeparator->mapToScene(QPointF(menuSeparator->width() / 2, menuSeparator->height() / 2)).toPoint()); + QVERIFY(menu->isVisible()); + + // Clicking on items should still close the menu. + QTest::mouseClick(window, Qt::LeftButton, Qt::NoModifier, + saveMenuItem->mapToScene(QPointF(saveMenuItem->width() / 2, saveMenuItem->height() / 2)).toPoint()); + QTRY_VERIFY(!menu->isVisible()); + + menu->open(); + QVERIFY(menu->isVisible()); + + // Key navigation skips separators + QTest::keyClick(window, Qt::Key_Down); + QVERIFY(newMenuItem->hasActiveFocus()); + QVERIFY(newMenuItem->hasVisualFocus()); + QCOMPARE(newMenuItem->focusReason(), Qt::TabFocusReason); + + QTest::keyClick(window, Qt::Key_Down); + QVERIFY(saveMenuItem->hasActiveFocus()); + QVERIFY(saveMenuItem->hasVisualFocus()); + QCOMPARE(saveMenuItem->focusReason(), Qt::TabFocusReason); + + QTest::keyClick(window, Qt::Key_Down); + QVERIFY(saveMenuItem->hasActiveFocus()); + QVERIFY(saveMenuItem->hasVisualFocus()); + QCOMPARE(saveMenuItem->focusReason(), Qt::TabFocusReason); + + QTest::keyClick(window, Qt::Key_Up); + QVERIFY(newMenuItem->hasActiveFocus()); + QVERIFY(newMenuItem->hasVisualFocus()); + QCOMPARE(newMenuItem->focusReason(), Qt::BacktabFocusReason); + + QTest::keyClick(window, Qt::Key_Up); + QVERIFY(newMenuItem->hasActiveFocus()); + QVERIFY(newMenuItem->hasVisualFocus()); + QCOMPARE(newMenuItem->focusReason(), Qt::BacktabFocusReason); +} + +void tst_QQuickMenu::repeater() +{ + QQuickApplicationHelper helper(this, QLatin1String("repeater.qml")); + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickMenu *menu = window->property("menu").value(); + QVERIFY(menu); + menu->open(); + QVERIFY(menu->isVisible()); + + QObject *repeater = window->property("repeater").value(); + QVERIFY(repeater); + + int count = repeater->property("count").toInt(); + QCOMPARE(count, 5); + + for (int i = 0; i < count; ++i) { + QQuickItem *item = menu->itemAt(i); + QVERIFY(item); + QCOMPARE(item->property("idx").toInt(), i); + + QQuickItem *repeaterItem = nullptr; + QVERIFY(QMetaObject::invokeMethod(repeater, "itemAt", Q_RETURN_ARG(QQuickItem*, repeaterItem), Q_ARG(int, i))); + QCOMPARE(item, repeaterItem); + } + + repeater->setProperty("model", 3); + + count = repeater->property("count").toInt(); + QCOMPARE(count, 3); + + for (int i = 0; i < count; ++i) { + QQuickItem *item = menu->itemAt(i); + QVERIFY(item); + QCOMPARE(item->property("idx").toInt(), i); + + QQuickItem *repeaterItem = nullptr; + QVERIFY(QMetaObject::invokeMethod(repeater, "itemAt", Q_RETURN_ARG(QQuickItem*, repeaterItem), Q_ARG(int, i))); + QCOMPARE(item, repeaterItem); + } +} + +void tst_QQuickMenu::order() +{ + QQuickApplicationHelper helper(this, QLatin1String("order.qml")); + QQuickWindow *window = helper.window; + window->show(); + QVERIFY(QTest::qWaitForWindowActive(window)); + + QQuickMenu *menu = window->property("menu").value(); + QVERIFY(menu); + menu->open(); + QVERIFY(menu->isVisible()); + + const QStringList texts = {"dynamic_0", "static_1", "repeated_2", "repeated_3", "static_4", "dynamic_5", "dynamic_6"}; + + for (int i = 0; i < texts.count(); ++i) { + QQuickItem *item = menu->itemAt(i); + QVERIFY(item); + QCOMPARE(item->property("text").toString(), texts.at(i)); + } +} + +QTEST_MAIN(tst_QQuickMenu) + +#include "tst_qquickmenu.moc" -- cgit v1.2.3