diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-05-30 10:19:31 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-05-30 10:19:38 +0200 |
commit | d4cb1d15ae8cf57b931b021490b0776cc70f0b32 (patch) | |
tree | 86282a3ed6a2ada1905c00a5b695bfc0bfb525a2 /tests | |
parent | b0324c5e020b98cbc0caf8176bbdfc5cd80b545e (diff) | |
parent | 95ca17c45aea718cade487640edc63e08bc23820 (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Change-Id: I962033871a1ef624807a4e1869fe869406aa73f7
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/core/core.pro | 3 | ||||
-rw-r--r-- | tests/auto/quick/qmltests/data/tst_newViewRequest.qml | 6 | ||||
-rw-r--r-- | tests/auto/quick/quick.pro | 3 | ||||
-rw-r--r-- | tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp | 8 | ||||
-rw-r--r-- | tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp | 95 | ||||
-rw-r--r-- | tests/auto/widgets/widgets.pro | 5 |
6 files changed, 114 insertions, 6 deletions
diff --git a/tests/auto/core/core.pro b/tests/auto/core/core.pro index 09b0dd69d..c1b2147bd 100644 --- a/tests/auto/core/core.pro +++ b/tests/auto/core/core.pro @@ -3,3 +3,6 @@ TEMPLATE = subdirs SUBDIRS += \ qwebenginecookiestore \ qwebengineurlrequestinterceptor \ + +# QTBUG-60268 +boot2qt: SUBDIRS = "" diff --git a/tests/auto/quick/qmltests/data/tst_newViewRequest.qml b/tests/auto/quick/qmltests/data/tst_newViewRequest.qml index 754a9e018..7a04d5f5b 100644 --- a/tests/auto/quick/qmltests/data/tst_newViewRequest.qml +++ b/tests/auto/quick/qmltests/data/tst_newViewRequest.qml @@ -93,7 +93,7 @@ TestWebEngineView { compare(newViewRequest.destination, WebEngineView.NewViewInTab); verify(!newViewRequest.userInitiated); - verify(dialog.webEngineView.waitForLoadSucceeded); + verify(dialog.webEngineView.waitForLoadSucceeded()); compare(dialog.webEngineView.url, ""); newViewRequestedSpy.clear(); dialog.destroy(); @@ -109,7 +109,7 @@ TestWebEngineView { compare(newViewRequest.destination, WebEngineView.NewViewInDialog); verify(!newViewRequest.userInitiated); - verify(dialog.webEngineView.waitForLoadSucceeded); + verify(dialog.webEngineView.waitForLoadSucceeded()); newViewRequestedSpy.clear(); dialog.destroy(); @@ -128,7 +128,7 @@ TestWebEngineView { compare(newViewRequest.destination, WebEngineView.NewViewInDialog); verify(newViewRequest.userInitiated); - verify(dialog.webEngineView.waitForLoadSucceeded); + verify(dialog.webEngineView.waitForLoadSucceeded()); newViewRequestedSpy.clear(); dialog.destroy(); } diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro index d220348ab..8733ccac1 100644 --- a/tests/auto/quick/quick.pro +++ b/tests/auto/quick/quick.pro @@ -11,3 +11,6 @@ isQMLTestSupportApiEnabled() { qmltests \ qquickwebengineviewgraphics } + +# QTBUG-60268 +boot2qt: SUBDIRS -= inspectorserver qquickwebenginedefaultsurfaceformat qquickwebengineview diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index b03418aea..bef77d3f1 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -3025,7 +3025,13 @@ void tst_QWebEnginePage::progressSignal() int previousValue = -1; for (QSignalSpy::ConstIterator it = progressSpy.begin(); it < progressSpy.end(); ++it) { int current = (*it).first().toInt(); - QVERIFY(current >= previousValue); + // verbose output for faulty condition + if (!(current >= previousValue)) { + qDebug() << "faulty progress values:"; + for (QSignalSpy::ConstIterator it2 = progressSpy.begin(); it2 < progressSpy.end(); ++it2) + qDebug() << (*it2).first().toInt(); + QVERIFY(current >= previousValue); + } previousValue = current; } diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp index 32a518ad8..37c7ae881 100644 --- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp +++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp @@ -100,7 +100,8 @@ private Q_SLOTS: void softwareInputPanel(); void inputMethods(); - void textSelection(); + void textSelectionInInputField(); + void textSelectionOutOfInputField(); void hiddenText(); void emptyInputMethodEvent(); void imeComposition(); @@ -1584,7 +1585,7 @@ void tst_QWebEngineView::inputMethods() QCOMPARE(view.focusProxy()->inputMethodQuery(Qt::ImSurroundingText).toString(), QString("QtWebEngine")); } -void tst_QWebEngineView::textSelection() +void tst_QWebEngineView::textSelectionInInputField() { QWebEngineView view; view.show(); @@ -1662,6 +1663,96 @@ void tst_QWebEngineView::textSelection() QCOMPARE(view.focusProxy()->inputMethodQuery(Qt::ImCurrentSelection).toString(), QString("QtWebEngi")); } +void tst_QWebEngineView::textSelectionOutOfInputField() +{ + QWebEngineView view; + view.show(); + + QSignalSpy selectionChangedSpy(&view, SIGNAL(selectionChanged())); + QSignalSpy loadFinishedSpy(&view, SIGNAL(loadFinished(bool))); + view.setHtml("<html><body>" + " This is a text" + "</body></html>"); + QVERIFY(loadFinishedSpy.wait()); + + QCOMPARE(selectionChangedSpy.count(), 0); + QVERIFY(!view.hasSelection()); + QVERIFY(view.page()->selectedText().isEmpty()); + + // Simple click should not update text selection, however it updates selection bounds in Chromium + QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, view.geometry().center()); + QCOMPARE(selectionChangedSpy.count(), 0); + QVERIFY(!view.hasSelection()); + QVERIFY(view.page()->selectedText().isEmpty()); + + // Workaround for macOS: press ctrl+a without key text + QKeyEvent keyPressCtrlA(QEvent::KeyPress, Qt::Key_A, Qt::ControlModifier); + QKeyEvent keyReleaseCtrlA(QEvent::KeyRelease, Qt::Key_A, Qt::ControlModifier); + + // Select text by ctrl+a + QApplication::sendEvent(view.focusProxy(), &keyPressCtrlA); + QApplication::sendEvent(view.focusProxy(), &keyReleaseCtrlA); + QVERIFY(selectionChangedSpy.wait()); + QCOMPARE(selectionChangedSpy.count(), 1); + QVERIFY(view.hasSelection()); + QCOMPARE(view.page()->selectedText(), QString("This is a text")); + + // Deselect text by mouse click + QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, view.geometry().center()); + QVERIFY(selectionChangedSpy.wait()); + QCOMPARE(selectionChangedSpy.count(), 2); + QVERIFY(!view.hasSelection()); + QVERIFY(view.page()->selectedText().isEmpty()); + + selectionChangedSpy.clear(); + view.setHtml("<html><body>" + " This is a text" + " <br>" + " <input type='text' id='input1' value='QtWebEngine' size='50'/>" + "</body></html>"); + QVERIFY(loadFinishedSpy.wait()); + + QCOMPARE(selectionChangedSpy.count(), 0); + QVERIFY(!view.hasSelection()); + QVERIFY(view.page()->selectedText().isEmpty()); + + // Make sure the input field does not have the focus + evaluateJavaScriptSync(view.page(), "document.getElementById('input1').blur()"); + QTRY_VERIFY(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString().isEmpty()); + + // Select the whole page by ctrl+a + QApplication::sendEvent(view.focusProxy(), &keyPressCtrlA); + QApplication::sendEvent(view.focusProxy(), &keyReleaseCtrlA); + QVERIFY(selectionChangedSpy.wait()); + QCOMPARE(selectionChangedSpy.count(), 1); + QVERIFY(view.hasSelection()); + QVERIFY(view.page()->selectedText().startsWith(QString("This is a text"))); + + // Remove selection by clicking into an input field + QPoint textInputCenter = elementCenter(view.page(), "input1"); + QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, textInputCenter); + QVERIFY(selectionChangedSpy.wait()); + QCOMPARE(evaluateJavaScriptSync(view.page(), "document.activeElement.id").toString(), QStringLiteral("input1")); + QCOMPARE(selectionChangedSpy.count(), 2); + QVERIFY(!view.hasSelection()); + QVERIFY(view.page()->selectedText().isEmpty()); + + // Select the content of the input field by ctrl+a + QApplication::sendEvent(view.focusProxy(), &keyPressCtrlA); + QApplication::sendEvent(view.focusProxy(), &keyReleaseCtrlA); + QVERIFY(selectionChangedSpy.wait()); + QCOMPARE(selectionChangedSpy.count(), 3); + QVERIFY(view.hasSelection()); + QCOMPARE(view.page()->selectedText(), QString("QtWebEngine")); + + // Deselect input field's text by mouse click + QTest::mouseClick(view.focusProxy(), Qt::LeftButton, 0, view.geometry().center()); + QVERIFY(selectionChangedSpy.wait()); + QCOMPARE(selectionChangedSpy.count(), 4); + QVERIFY(!view.hasSelection()); + QVERIFY(view.page()->selectedText().isEmpty()); +} + void tst_QWebEngineView::hiddenText() { QWebEngineView view; diff --git a/tests/auto/widgets/widgets.pro b/tests/auto/widgets/widgets.pro index de00e5f07..90352310e 100644 --- a/tests/auto/widgets/widgets.pro +++ b/tests/auto/widgets/widgets.pro @@ -20,3 +20,8 @@ contains(WEBENGINE_CONFIG, use_spellchecker):!cross_compile { message("Spellcheck test will not be built because it depends on usage of Hunspell dictionaries.") } } + +# QTBUG-60268 +boot2qt: SUBDIRS -= qwebengineaccessibility qwebenginedefaultsurfaceformat \ + qwebenginefaviconmanager qwebenginepage qwebenginehistory \ + qwebengineprofile qwebenginescript qwebengineview |