From a060012ecef7ecc60f5518b6718136b22a10dc6b Mon Sep 17 00:00:00 2001 From: Balazs Egedi Date: Wed, 16 Jun 2021 14:55:18 +0200 Subject: Remove Quick Controls 1 UIDelegates and introduce UIDelegates test - Renamed Controls2Delegates to ControlsDelegates - Removed option to use Quick Controls 1 delegates - Added test to check if controls are shown Task-number: QTBUG-93666 Change-Id: Iccca948615309285db7fc57d14fb1cdcdef28051 Reviewed-by: Qt CI Bot Reviewed-by: Peter Varga (cherry picked from commit 4fe808a8c0ecd143199781e9644a46e4b1b90653) Reviewed-by: Allan Sandfeld Jensen --- tests/auto/quick/CMakeLists.txt | 1 + .../QtWebEngine/Controls1Delegates/qmldir | 1 - .../QtWebEngine/Controls2Delegates/AlertDialog.qml | 30 --- .../Controls2Delegates/ConfirmDialog.qml | 49 ---- .../QtWebEngine/Controls2Delegates/FilePicker.qml | 49 ---- .../QtWebEngine/Controls2Delegates/Menu.qml | 54 ----- .../QtWebEngine/Controls2Delegates/MenuItem.qml | 44 ---- .../Controls2Delegates/PromptDialog.qml | 52 ----- .../QtWebEngine/Controls2Delegates/qmldir | 1 - .../QtWebEngine/ControlsDelegates/AlertDialog.qml | 30 +++ .../ControlsDelegates/ConfirmDialog.qml | 49 ++++ .../QtWebEngine/ControlsDelegates/FilePicker.qml | 49 ++++ .../QtWebEngine/ControlsDelegates/Menu.qml | 54 +++++ .../QtWebEngine/ControlsDelegates/MenuItem.qml | 44 ++++ .../QtWebEngine/ControlsDelegates/PromptDialog.qml | 52 +++++ tests/auto/quick/qmltests/qmltests.pro | 14 +- tests/auto/quick/qmltests/tst_qmltests.cpp | 2 - tests/auto/quick/uidelegates/CMakeLists.txt | 14 ++ tests/auto/quick/uidelegates/tst_uidelegates.cpp | 256 +++++++++++++++++++++ 19 files changed, 555 insertions(+), 290 deletions(-) delete mode 100644 tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/qmldir delete mode 100644 tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/AlertDialog.qml delete mode 100644 tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/ConfirmDialog.qml delete mode 100644 tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/FilePicker.qml delete mode 100644 tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/Menu.qml delete mode 100644 tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/MenuItem.qml delete mode 100644 tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/PromptDialog.qml delete mode 100644 tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/qmldir create mode 100644 tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/AlertDialog.qml create mode 100644 tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/ConfirmDialog.qml create mode 100644 tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/FilePicker.qml create mode 100644 tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/Menu.qml create mode 100644 tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/MenuItem.qml create mode 100644 tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/PromptDialog.qml create mode 100644 tests/auto/quick/uidelegates/CMakeLists.txt create mode 100644 tests/auto/quick/uidelegates/tst_uidelegates.cpp (limited to 'tests/auto/quick') diff --git a/tests/auto/quick/CMakeLists.txt b/tests/auto/quick/CMakeLists.txt index 1d38470b3..88cf8a3be 100644 --- a/tests/auto/quick/CMakeLists.txt +++ b/tests/auto/quick/CMakeLists.txt @@ -5,6 +5,7 @@ add_subdirectory(qtbug-70248) add_subdirectory(inspectorserver) add_subdirectory(qmltests) add_subdirectory(qquickwebengineview) +add_subdirectory(uidelegates) if(QT_FEATURE_webenginequick_testsupport) add_subdirectory(qquickwebengineviewgraphics) endif() diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/qmldir b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/qmldir deleted file mode 100644 index f0d8f33b7..000000000 --- a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls1Delegates/qmldir +++ /dev/null @@ -1 +0,0 @@ -module QtWebEngine.Controls1Delegates diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/AlertDialog.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/AlertDialog.qml deleted file mode 100644 index 252678754..000000000 --- a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/AlertDialog.qml +++ /dev/null @@ -1,30 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -// Both dialogs are basically expected to behave in the same way from an API point of view -ConfirmDialog { } diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/ConfirmDialog.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/ConfirmDialog.qml deleted file mode 100644 index c4d3dd183..000000000 --- a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/ConfirmDialog.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQml -import QtTest -import "../../TestParams" - -QtObject { - property string text - property string title - signal accepted() - signal rejected() - - function open() { - JSDialogParams.dialogTitle = title; - JSDialogParams.dialogMessage = text; - JSDialogParams.dialogCount++; - if (JSDialogParams.shouldAcceptDialog) - accepted(); - else - rejected(); - } -} - diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/FilePicker.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/FilePicker.qml deleted file mode 100644 index 0ba92f5ce..000000000 --- a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/FilePicker.qml +++ /dev/null @@ -1,49 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick -import "../../TestParams" - -QtObject { - property bool selectMultiple: false - property bool selectExisting: false - property bool selectFolder: false - property var nameFilters: [] - - signal filesSelected(var fileList) - signal rejected() - - function open() { - FilePickerParams.filePickerOpened = true; - FilePickerParams.nameFilters = nameFilters; - if (FilePickerParams.selectFiles) - filesSelected(FilePickerParams.selectedFilesUrl); - else - rejected(); - } -} diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/Menu.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/Menu.qml deleted file mode 100644 index aa03a9d30..000000000 --- a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/Menu.qml +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** 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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQml -import "../../TestParams" - -QtObject { - id: menu - property string linkText: "" - property var mediaType: null - property string selectedText: "" - - signal done() - - function open() { - MenuParams.isMenuOpened = true; - } -} diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/MenuItem.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/MenuItem.qml deleted file mode 100644 index dcc1ca4b6..000000000 --- a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/MenuItem.qml +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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. -** -** 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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQml - -QtObject { - signal triggered() -} diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/PromptDialog.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/PromptDialog.qml deleted file mode 100644 index 800481797..000000000 --- a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/PromptDialog.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** 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. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQml -import QtTest -import "../../TestParams" - -QtObject { - property string text - property string title - signal accepted() - signal rejected() - signal input(string text) - signal closing() - - function open() { - JSDialogParams.dialogTitle = title; - JSDialogParams.dialogMessage = text; - JSDialogParams.dialogCount++; - if (JSDialogParams.shouldAcceptDialog) { - input(JSDialogParams.inputForPrompt) - accepted(); - } else { - rejected(); - } - } -} diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/qmldir b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/qmldir deleted file mode 100644 index 5542aba58..000000000 --- a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/Controls2Delegates/qmldir +++ /dev/null @@ -1 +0,0 @@ -module QtWebEngine.Controls2Delegates diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/AlertDialog.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/AlertDialog.qml new file mode 100644 index 000000000..252678754 --- /dev/null +++ b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/AlertDialog.qml @@ -0,0 +1,30 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// Both dialogs are basically expected to behave in the same way from an API point of view +ConfirmDialog { } diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/ConfirmDialog.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/ConfirmDialog.qml new file mode 100644 index 000000000..c4d3dd183 --- /dev/null +++ b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/ConfirmDialog.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQml +import QtTest +import "../../TestParams" + +QtObject { + property string text + property string title + signal accepted() + signal rejected() + + function open() { + JSDialogParams.dialogTitle = title; + JSDialogParams.dialogMessage = text; + JSDialogParams.dialogCount++; + if (JSDialogParams.shouldAcceptDialog) + accepted(); + else + rejected(); + } +} + diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/FilePicker.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/FilePicker.qml new file mode 100644 index 000000000..0ba92f5ce --- /dev/null +++ b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/FilePicker.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick +import "../../TestParams" + +QtObject { + property bool selectMultiple: false + property bool selectExisting: false + property bool selectFolder: false + property var nameFilters: [] + + signal filesSelected(var fileList) + signal rejected() + + function open() { + FilePickerParams.filePickerOpened = true; + FilePickerParams.nameFilters = nameFilters; + if (FilePickerParams.selectFiles) + filesSelected(FilePickerParams.selectedFilesUrl); + else + rejected(); + } +} diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/Menu.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/Menu.qml new file mode 100644 index 000000000..aa03a9d30 --- /dev/null +++ b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/Menu.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** 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.LGPL3 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-3.0.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 (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQml +import "../../TestParams" + +QtObject { + id: menu + property string linkText: "" + property var mediaType: null + property string selectedText: "" + + signal done() + + function open() { + MenuParams.isMenuOpened = true; + } +} diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/MenuItem.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/MenuItem.qml new file mode 100644 index 000000000..dcc1ca4b6 --- /dev/null +++ b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/MenuItem.qml @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** 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. +** +** 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.LGPL3 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-3.0.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 (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQml + +QtObject { + signal triggered() +} diff --git a/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/PromptDialog.qml b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/PromptDialog.qml new file mode 100644 index 000000000..800481797 --- /dev/null +++ b/tests/auto/quick/qmltests/mock-delegates/QtWebEngine/ControlsDelegates/PromptDialog.qml @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQml +import QtTest +import "../../TestParams" + +QtObject { + property string text + property string title + signal accepted() + signal rejected() + signal input(string text) + signal closing() + + function open() { + JSDialogParams.dialogTitle = title; + JSDialogParams.dialogMessage = text; + JSDialogParams.dialogCount++; + if (JSDialogParams.shouldAcceptDialog) { + input(JSDialogParams.inputForPrompt) + accepted(); + } else { + rejected(); + } + } +} diff --git a/tests/auto/quick/qmltests/qmltests.pro b/tests/auto/quick/qmltests/qmltests.pro index c5755e46a..bc034790e 100644 --- a/tests/auto/quick/qmltests/qmltests.pro +++ b/tests/auto/quick/qmltests/qmltests.pro @@ -134,17 +134,15 @@ OTHER_FILES += \ $$PWD/data/icons/qt32.ico \ $$PWD/data/icons/qtmulti.ico \ $$PWD/data/icons/small-favicon.png \ - $$PWD/mock-delegates/QtWebEngine/Controls1Delegates/qmldir \ $$PWD/mock-delegates/TestParams/FilePickerParams.qml \ $$PWD/mock-delegates/TestParams/JSDialogParams.qml \ $$PWD/mock-delegates/TestParams/qmldir \ - $$PWD/mock-delegates/QtWebEngine/Controls2Delegates/AlertDialog.qml \ - $$PWD/mock-delegates/QtWebEngine/Controls2Delegates/ConfirmDialog.qml \ - $$PWD/mock-delegates/QtWebEngine/Controls2Delegates/FilePicker.qml \ - $$PWD/mock-delegates/QtWebEngine/Controls2Delegates/Menu.qml \ - $$PWD/mock-delegates/QtWebEngine/Controls2Delegates/MenuItem.qml \ - $$PWD/mock-delegates/QtWebEngine/Controls2Delegates/PromptDialog.qml \ - $$PWD/mock-delegates/QtWebEngine/Controls2Delegates/qmldir + $$PWD/mock-delegates/QtWebEngine/ControlsDelegates/AlertDialog.qml \ + $$PWD/mock-delegates/QtWebEngine/ControlsDelegates/ConfirmDialog.qml \ + $$PWD/mock-delegates/QtWebEngine/ControlsDelegates/FilePicker.qml \ + $$PWD/mock-delegates/QtWebEngine/ControlsDelegates/Menu.qml \ + $$PWD/mock-delegates/QtWebEngine/ControlsDelegates/MenuItem.qml \ + $$PWD/mock-delegates/QtWebEngine/ControlsDelegates/PromptDialog.qml OTHER_FILES += $$QML_TESTS diff --git a/tests/auto/quick/qmltests/tst_qmltests.cpp b/tests/auto/quick/qmltests/tst_qmltests.cpp index 653972dfd..a60994f85 100644 --- a/tests/auto/quick/qmltests/tst_qmltests.cpp +++ b/tests/auto/quick/qmltests/tst_qmltests.cpp @@ -153,8 +153,6 @@ int main(int argc, char **argv) sigaction(SIGSEGV, &sigAction, 0); #endif - // TODO: temporary solution. Remove when Quick Controls 1 is removed. - qputenv("QTWEBENGINE_DIALOG_SET", QByteArray("QtQuickControls2")); QScopedPointer app; // Force to use English language for testing due to error message checks QLocale::setDefault(QLocale("en")); diff --git a/tests/auto/quick/uidelegates/CMakeLists.txt b/tests/auto/quick/uidelegates/CMakeLists.txt new file mode 100644 index 000000000..d8699ccfc --- /dev/null +++ b/tests/auto/quick/uidelegates/CMakeLists.txt @@ -0,0 +1,14 @@ +include(../../httpserver/httpserver.cmake) +include(../../util/util.cmake) + +qt_internal_add_test(tst_uidelegates + SOURCES + tst_uidelegates.cpp + LIBRARIES + Qt::WebEngineCorePrivate + Qt::WebEngineQuick + Qt::GuiPrivate + Qt::WebEngineQuickPrivate + Test::HttpServer + Test::Util +) diff --git a/tests/auto/quick/uidelegates/tst_uidelegates.cpp b/tests/auto/quick/uidelegates/tst_uidelegates.cpp new file mode 100644 index 000000000..95f083f12 --- /dev/null +++ b/tests/auto/quick/uidelegates/tst_uidelegates.cpp @@ -0,0 +1,256 @@ +/**************************************************************************** +** +** Copyright (C) 2021 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:GPL-EXCEPT$ +** 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. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "testwindow.h" +#include "quickutil.h" + +#include +#include +#include +#include +#include +#include +#include + +class tst_UIDelegates : public QObject +{ + Q_OBJECT +public: + tst_UIDelegates(); + +private Q_SLOTS: + void init(); + void initTestCase(); + void cleanup(); + void javaScriptDialog(); + void javaScriptDialog_data(); + void fileDialog(); + void contextMenu(); + void tooltip(); + void colorDialog(); + void authenticationDialog_data(); + void authenticationDialog(); + +private: + inline QQuickWebEngineView *newWebEngineView(); + inline QQuickWebEngineView *webEngineView() const; + void runJavaScript(const QString &script); + QScopedPointer m_window; + QScopedPointer m_component; +}; + +tst_UIDelegates::tst_UIDelegates() +{ + QtWebEngineQuick::initialize(); + static QQmlEngine *engine = new QQmlEngine(this); + m_component.reset(new QQmlComponent(engine, this)); + m_component->setData(QByteArrayLiteral("import QtQuick\n" + "import QtWebEngine\n" + "WebEngineView {}"), + QUrl()); +} + +QQuickWebEngineView *tst_UIDelegates::newWebEngineView() +{ + QObject *viewInstance = m_component->create(); + QQuickWebEngineView *webEngineView = qobject_cast(viewInstance); + return webEngineView; +} + +void tst_UIDelegates::init() +{ + m_window.reset(new TestWindow(newWebEngineView())); +} + +void tst_UIDelegates::initTestCase() +{ + QNetworkProxy proxy; + proxy.setType(QNetworkProxy::HttpProxy); + proxy.setHostName("localhost"); + proxy.setPort(5555); + QNetworkProxy::setApplicationProxy(proxy); +} + +void tst_UIDelegates::cleanup() +{ + m_window.reset(); +} + +inline QQuickWebEngineView *tst_UIDelegates::webEngineView() const +{ + return static_cast(m_window->webEngineView.data()); +} + +void tst_UIDelegates::runJavaScript(const QString &script) +{ + webEngineView()->runJavaScript(script); +} + +void tst_UIDelegates::javaScriptDialog_data() +{ + QTest::addColumn("javaScriptCode"); + QTest::addColumn("expectedObjectName"); + + QTest::newRow("AlertDialog") << QString("alert('This is the Alert Dialog!');") + << QString("alertDialog"); + QTest::newRow("ConfirmDialog") << QString("confirm('This is the Confirm Dialog.');") + << QString("confirmDialog"); + QTest::newRow("PromptDialog") << QString("prompt('Is this the Prompt Dialog?', 'Yes');") + << QString("promptDialog"); +} + +void tst_UIDelegates::javaScriptDialog() +{ + QFETCH(QString, javaScriptCode); + QFETCH(QString, expectedObjectName); + + m_window->show(); + QTRY_VERIFY(qApp->focusObject()); + QQuickWebEngineView *view = webEngineView(); + + view->loadHtml("" + ""); + QVERIFY(waitForLoadSucceeded(view)); + + runJavaScript(javaScriptCode); + QTRY_VERIFY(view->findChild(expectedObjectName)); +} + +void tst_UIDelegates::fileDialog() +{ + QSKIP("There is no FilePicker Control in Quick Controls 2."); + m_window->show(); + QTRY_VERIFY(qApp->focusObject()); + QQuickWebEngineView *view = webEngineView(); + + view->loadHtml("" + "" + ""); + QVERIFY(waitForLoadSucceeded(view)); + QString filePickerStr = QStringLiteral("filePicker"); + + QPoint filePickerCenter = elementCenter(view, filePickerStr); + QTest::mouseClick(view->window(), Qt::LeftButton, {}, filePickerCenter); + QTRY_VERIFY(view->findChild(filePickerStr)); +} + +void tst_UIDelegates::contextMenu() +{ + m_window->show(); + QTRY_VERIFY(qApp->focusObject()); + QQuickWebEngineView *view = webEngineView(); + + view->loadHtml("" + ""); + QVERIFY(waitForLoadSucceeded(view)); + + QTest::mouseClick(view->window(), Qt::RightButton); + QTRY_VERIFY(view->findChild(QStringLiteral("menu"))); +} + +void tst_UIDelegates::tooltip() +{ + m_window->show(); + QTRY_VERIFY(qApp->focusObject()); + QQuickWebEngineView *view = webEngineView(); + + view->loadHtml("" + "

Hover this text to display a tooltip

" + ""); + QVERIFY(waitForLoadSucceeded(view)); + QString toolTipStr = QStringLiteral("toolTip"); + + QPoint tooltipCenter = elementCenter(view, toolTipStr); + QPoint windowCenter = QPoint(view->window()->width() / 2, view->window()->height() / 2); + QVERIFY(tooltipCenter.x() == windowCenter.x()); + + int distance = windowCenter.y() - tooltipCenter.y(); + for (int i = 3; i > 0; i--) { + QTest::mouseMove(view->window(), QPoint(windowCenter.x(), windowCenter.y() - distance / i)); + } + QTRY_VERIFY(view->findChild(toolTipStr)); +} + +void tst_UIDelegates::colorDialog() +{ + QSKIP("There is no ColorPicker Control in Quick Controls 2."); + m_window->show(); + QTRY_VERIFY(qApp->focusObject()); + QQuickWebEngineView *view = webEngineView(); + + view->loadHtml("" + "" + ""); + QVERIFY(waitForLoadSucceeded(view)); + + QPoint filePickerCenter = elementCenter(view, QStringLiteral("colorPicker")); + QTest::mouseClick(view->window(), Qt::LeftButton, {}, filePickerCenter); + QTRY_VERIFY(view->findChild(QStringLiteral("colorDialog"))); +} + +void tst_UIDelegates::authenticationDialog_data() +{ + QTest::addColumn("url"); + QTest::addColumn("response"); + + QTest::newRow("Http Authentication Dialog") + << QUrl("http://localhost:5555/") + << QByteArrayLiteral("HTTP/1.1 401 Unauthorized\nWWW-Authenticate: " + "Basic realm=\"Very Restricted Area\"\r\n\r\n"); + QTest::newRow("Proxy Authentication Dialog") + << QUrl("http://qt.io/") + << QByteArrayLiteral("HTTP/1.1 407 Proxy Auth Required\nProxy-Authenticate: " + "Basic realm=\"Proxy requires authentication\"\r\n" + "content-length: 0\r\n\r\n"); +} + +void tst_UIDelegates::authenticationDialog() +{ + QFETCH(QUrl, url); + QFETCH(QByteArray, response); + + HttpServer server(QHostAddress::LocalHost, 5555); + connect(&server, &HttpServer::newRequest, + [url, response](HttpReqRep *rr) { rr->sendResponse(response); }); + QVERIFY(server.start()); + + m_window->show(); + QTRY_VERIFY(qApp->focusObject()); + QQuickWebEngineView *view = webEngineView(); + view->loadHtml("" + ""); + QVERIFY(waitForLoadSucceeded(view)); + + view->setUrl(url); + QTRY_VERIFY(view->findChild(QStringLiteral("authenticationDialog"))); + QVERIFY(server.stop()); +} + +QTEST_MAIN(tst_UIDelegates) +#include "tst_uidelegates.moc" +#include "moc_quickutil.cpp" -- cgit v1.2.3