diff options
author | Peter Varga <pvarga@inf.u-szeged.hu> | 2016-10-07 11:37:34 +0200 |
---|---|---|
committer | Peter Varga <pvarga@inf.u-szeged.hu> | 2016-10-15 06:28:42 +0000 |
commit | b0474a665195abd94b5b5319a2eca04baff2b73b (patch) | |
tree | 00d20aa3a3ed662de66c390274eceaf2505cfcdd /tests/auto | |
parent | b86e78fca8b40a7db9243df159e555bf5497a315 (diff) |
Speculative stabilization of test_focusOnNavigation quick auto test
Reimplement setting focus on a HTML element in JavaScript.
Change-Id: I1db53bcb526fd52df1fa23527089f8186dfd0ea3
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/quick/qmltests/BLACKLIST | 3 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_focusOnNavigation.qml | 29 |
2 files changed, 19 insertions, 13 deletions
diff --git a/tests/auto/quick/qmltests/BLACKLIST b/tests/auto/quick/qmltests/BLACKLIST index f7eda413c..63d31c875 100644 --- a/tests/auto/quick/qmltests/BLACKLIST +++ b/tests/auto/quick/qmltests/BLACKLIST @@ -10,9 +10,6 @@ osx [WebViewGeopermission::test_geoPermissionRequest] osx -[WebEngineViewFocusOnNavigation::test_focusOnNavigation] -* - [WebEngineViewLoadUrl::test_urlProperty] windows diff --git a/tests/auto/quick/qmltests/data/tst_focusOnNavigation.qml b/tests/auto/quick/qmltests/data/tst_focusOnNavigation.qml index ce0fa2e31..15ec320a4 100644 --- a/tests/auto/quick/qmltests/data/tst_focusOnNavigation.qml +++ b/tests/auto/quick/qmltests/data/tst_focusOnNavigation.qml @@ -67,8 +67,6 @@ Item { TestCase { name: "WebEngineViewFocusOnNavigation" when: windowShown - function init() { - } function test_focusOnNavigation_data() { return [ @@ -79,18 +77,29 @@ Item { ] } - function triggerJavascriptFocus() { - var callbackCalled = false; - webView.runJavaScript("document.getElementById(\"input\").focus()", function(result) { - callbackCalled = true; - }); - wait(100); - verify(callbackCalled); + 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()); - triggerJavascriptFocus(); + setFocusToElement("input"); compare(webView.activeFocus, data.viewReceivedFocus); } |