summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2016-11-08 16:18:15 +0100
committerPeter Varga <pvarga@inf.u-szeged.hu>2016-11-16 14:50:54 +0000
commite3378e1968d7740eb077562bea251759adf1d97e (patch)
treed5631010d440bb7654b5191954a47400e4711058 /tests
parent983ae112927c600867377ac46f6e4b65856bacbf (diff)
Wait for focus before key press in NewViewRequest::test_jsWindowOpen
This patch is intended to fix flaky failure and factors focus related test functions out to TestWebEngineView. Task-number: QTBUG-56540 Change-Id: Id7e17c08a4a9e863389ae991c9cadc00379377db Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/quick/qmltests/BLACKLIST3
-rw-r--r--tests/auto/quick/qmltests/data/TestWebEngineView.qml22
-rw-r--r--tests/auto/quick/qmltests/data/tst_focusOnNavigation.qml22
-rw-r--r--tests/auto/quick/qmltests/data/tst_keyboardEvents.qml20
-rw-r--r--tests/auto/quick/qmltests/data/tst_newViewRequest.qml1
5 files changed, 23 insertions, 45 deletions
diff --git a/tests/auto/quick/qmltests/BLACKLIST b/tests/auto/quick/qmltests/BLACKLIST
index dea9f3ca1..035e49a83 100644
--- a/tests/auto/quick/qmltests/BLACKLIST
+++ b/tests/auto/quick/qmltests/BLACKLIST
@@ -1,9 +1,6 @@
[DesktopWebEngineViewLinkHovered::test_linkHovered]
*
-[NewViewRequest::test_jsWindowOpen]
-*
-
[WebViewGeopermission::test_deniedGeolocationByUser]
osx
diff --git a/tests/auto/quick/qmltests/data/TestWebEngineView.qml b/tests/auto/quick/qmltests/data/TestWebEngineView.qml
index 0d2a34645..aa1f77942 100644
--- a/tests/auto/quick/qmltests/data/TestWebEngineView.qml
+++ b/tests/auto/quick/qmltests/data/TestWebEngineView.qml
@@ -27,7 +27,7 @@
****************************************************************************/
import QtQuick 2.0
-import QtTest 1.0
+import QtTest 1.1
import QtWebEngine 1.3
WebEngineView {
@@ -62,7 +62,27 @@ WebEngineView {
return predicate()
}
+ function getActiveElementId() {
+ var activeElementId;
+ runJavaScript("document.activeElement.id", function(result) {
+ activeElementId = result;
+ });
+ testCase.tryVerify(function() { return activeElementId != undefined });
+ return activeElementId;
+ }
+
+ function verifyElementHasFocus(element) {
+ testCase.tryVerify(function() { return getActiveElementId() == element; }, 5000,
+ "Element \"" + element + "\" has focus");
+ }
+
+ function setFocusToElement(element) {
+ runJavaScript("document.getElementById('" + element + "').focus()");
+ verifyElementHasFocus(element);
+ }
+
TestResult { id: testResult }
+ TestCase { id: testCase }
onLoadingChanged: {
loadStatus = loadRequest.status
diff --git a/tests/auto/quick/qmltests/data/tst_focusOnNavigation.qml b/tests/auto/quick/qmltests/data/tst_focusOnNavigation.qml
index 15ec320a4..93410a727 100644
--- a/tests/auto/quick/qmltests/data/tst_focusOnNavigation.qml
+++ b/tests/auto/quick/qmltests/data/tst_focusOnNavigation.qml
@@ -77,29 +77,9 @@ Item {
]
}
- function getActiveElementId() {
- var activeElementId;
- webView.runJavaScript("document.activeElement.id", function(result) {
- activeElementId = result;
- });
- tryVerify(function() { return activeElementId != undefined });
- return activeElementId;
- }
-
- function verifyElementHasFocus(element) {
- tryVerify(function() { return getActiveElementId() == element; }, 5000,
- "Element \"" + element + "\" has focus");
-
- }
-
- function setFocusToElement(element) {
- webView.runJavaScript("document.getElementById('" + element + "').focus()");
- verifyElementHasFocus(element);
- }
-
function loadAndTriggerFocusAndCompare(data) {
verify(webView.waitForLoadSucceeded());
- setFocusToElement("input");
+ webView.setFocusToElement("input");
compare(webView.activeFocus, data.viewReceivedFocus);
}
diff --git a/tests/auto/quick/qmltests/data/tst_keyboardEvents.qml b/tests/auto/quick/qmltests/data/tst_keyboardEvents.qml
index 7007a85ac..677727632 100644
--- a/tests/auto/quick/qmltests/data/tst_keyboardEvents.qml
+++ b/tests/auto/quick/qmltests/data/tst_keyboardEvents.qml
@@ -39,26 +39,6 @@ TestWebEngineView {
name: "WebEngineViewKeyboardEvents"
when: windowShown
- function getActiveElementId() {
- var activeElementId;
- runJavaScript("document.activeElement.id", function(result) {
- activeElementId = result;
- });
- tryVerify(function() { return activeElementId != undefined });
- return activeElementId;
- }
-
- function verifyElementHasFocus(element) {
- tryVerify(function() { return getActiveElementId() == element; }, 5000,
- "Element \"" + element + "\" has focus");
-
- }
-
- function setFocusToElement(element) {
- runJavaScript("document.getElementById('" + element + "').focus()");
- verifyElementHasFocus(element);
- }
-
function isElementChecked(element) {
var elementChecked;
runJavaScript("document.getElementById('" + element + "').checked", function(result) {
diff --git a/tests/auto/quick/qmltests/data/tst_newViewRequest.qml b/tests/auto/quick/qmltests/data/tst_newViewRequest.qml
index be56f3251..754a9e018 100644
--- a/tests/auto/quick/qmltests/data/tst_newViewRequest.qml
+++ b/tests/auto/quick/qmltests/data/tst_newViewRequest.qml
@@ -122,6 +122,7 @@ TestWebEngineView {
" <button id='popupButton' onclick='popup()'>Pop Up!</button>" +
"</body></html>");
verify(webEngineView.waitForLoadSucceeded());
+ verifyElementHasFocus("popupButton");
keyPress(Qt.Key_Enter);
tryCompare(newViewRequestedSpy, "count", 1);