diff options
author | Peter Varga <pvarga@inf.u-szeged.hu> | 2016-11-08 16:18:15 +0100 |
---|---|---|
committer | Peter Varga <pvarga@inf.u-szeged.hu> | 2016-11-16 14:50:54 +0000 |
commit | e3378e1968d7740eb077562bea251759adf1d97e (patch) | |
tree | d5631010d440bb7654b5191954a47400e4711058 /tests/auto/quick/qmltests/data/TestWebEngineView.qml | |
parent | 983ae112927c600867377ac46f6e4b65856bacbf (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/auto/quick/qmltests/data/TestWebEngineView.qml')
-rw-r--r-- | tests/auto/quick/qmltests/data/TestWebEngineView.qml | 22 |
1 files changed, 21 insertions, 1 deletions
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 |