From bedd043d37b158d420790b8e4b5d4ea8517a4dca Mon Sep 17 00:00:00 2001 From: Peter Varga Date: Tue, 4 Aug 2015 16:36:40 +0200 Subject: Add QML test for form validation feature Change-Id: I508aabbdd6a33e7ed8edcd7438e71297d4c0e895 Reviewed-by: Szabolcs David Reviewed-by: Andras Becsi --- tests/auto/quick/qmltests/data/forms.html | 40 +++++++ .../quick/qmltests/data/tst_formValidation.qml | 124 +++++++++++++++++++++ tests/auto/quick/qmltests/qmltests.pro | 2 + 3 files changed, 166 insertions(+) create mode 100644 tests/auto/quick/qmltests/data/forms.html create mode 100644 tests/auto/quick/qmltests/data/tst_formValidation.qml (limited to 'tests/auto/quick') diff --git a/tests/auto/quick/qmltests/data/forms.html b/tests/auto/quick/qmltests/data/forms.html new file mode 100644 index 000000000..8dc3472f2 --- /dev/null +++ b/tests/auto/quick/qmltests/data/forms.html @@ -0,0 +1,40 @@ + + + Forms + + + +
+ + +
+
+ + +
+
+ + +
+ +
+ + +
+
+ + +
+
+ + +
+ + diff --git a/tests/auto/quick/qmltests/data/tst_formValidation.qml b/tests/auto/quick/qmltests/data/tst_formValidation.qml new file mode 100644 index 000000000..4acb7ce63 --- /dev/null +++ b/tests/auto/quick/qmltests/data/tst_formValidation.qml @@ -0,0 +1,124 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://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 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 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 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 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.0 +import QtTest 1.0 +import QtWebEngine 1.2 +import QtWebEngine.testsupport 1.0 + +TestWebEngineView { + id: webEngineView + width: 400 + height: 300 + + testSupport: WebEngineTestSupport { + id: testSupportAPI + } + + SignalSpy { + id: showSpy + target: testSupportAPI + signalName: "validationMessageShown" + } + + TestCase { + name: "WebEngineViewFormValidation" + when: windowShown + + function init() { + webEngineView.url = Qt.resolvedUrl("about:blank") + verify(webEngineView.waitForLoadSucceeded()) + showSpy.clear() + } + + function test_urlForm() { + webEngineView.url = Qt.resolvedUrl("forms.html#url_empty") + verify(webEngineView.waitForLoadSucceeded()) + keyPress(Qt.Key_Enter) + showSpy.wait() + compare(showSpy.signalArguments[0][0], "Please fill out this field.") + + webEngineView.url = Qt.resolvedUrl("about:blank") + verify(webEngineView.waitForLoadSucceeded()) + + webEngineView.url = Qt.resolvedUrl("forms.html#url_invalid") + verify(webEngineView.waitForLoadSucceeded()) + keyPress(Qt.Key_Enter) + showSpy.wait() + compare(showSpy.signalArguments[1][0], "Please enter a URL.") + + webEngineView.url = Qt.resolvedUrl("about:blank") + verify(webEngineView.waitForLoadSucceeded()) + + webEngineView.url = Qt.resolvedUrl("forms.html#url_title") + verify(webEngineView.waitForLoadSucceeded()) + keyPress(Qt.Key_Enter) + showSpy.wait() + compare(showSpy.signalArguments[2][1], "url_title") + } + + function test_emailForm() { + webEngineView.url = Qt.resolvedUrl("forms.html#email_empty") + verify(webEngineView.waitForLoadSucceeded()) + keyPress(Qt.Key_Enter) + showSpy.wait() + compare(showSpy.signalArguments[0][0], "Please fill out this field.") + + webEngineView.url = Qt.resolvedUrl("about:blank") + verify(webEngineView.waitForLoadSucceeded()) + + webEngineView.url = Qt.resolvedUrl("forms.html#email_invalid") + verify(webEngineView.waitForLoadSucceeded()) + keyPress(Qt.Key_Enter) + showSpy.wait() + compare(showSpy.signalArguments[1][0], "Please include an '@' in the email address. 'invalid' is missing an '@'.") + + webEngineView.url = Qt.resolvedUrl("about:blank") + verify(webEngineView.waitForLoadSucceeded()) + + webEngineView.url = Qt.resolvedUrl("forms.html#email_title") + verify(webEngineView.waitForLoadSucceeded()) + keyPress(Qt.Key_Enter) + showSpy.wait() + compare(showSpy.signalArguments[2][1], "email_title") + } + } +} diff --git a/tests/auto/quick/qmltests/qmltests.pro b/tests/auto/quick/qmltests/qmltests.pro index af6600931..6776c1aa6 100644 --- a/tests/auto/quick/qmltests/qmltests.pro +++ b/tests/auto/quick/qmltests/qmltests.pro @@ -15,6 +15,7 @@ OTHER_FILES += \ $$PWD/data/favicon.html \ $$PWD/data/favicon.png \ $$PWD/data/favicon2.html \ + $$PWD/data/forms.html \ $$PWD/data/javascript.html \ $$PWD/data/link.html \ $$PWD/data/prompt.html \ @@ -31,6 +32,7 @@ OTHER_FILES += \ $$PWD/data/tst_desktopBehaviorLoadHtml.qml \ $$PWD/data/tst_favIconLoad.qml \ $$PWD/data/tst_filePicker.qml \ + $$PWD/data/tst_formValidation.qml \ $$PWD/data/tst_javaScriptDialogs.qml \ $$PWD/data/tst_linkHovered.qml \ $$PWD/data/tst_loadFail.qml \ -- cgit v1.2.3