From a64565af1e2d83665b8a0ece77750ac50555423a Mon Sep 17 00:00:00 2001 From: Tamas Zakor Date: Fri, 15 Feb 2019 11:18:47 +0100 Subject: Un-blacklist tst_QWebEnginePage combobox auto tests tst_QWebEnginePage::comboBoxPopupPositionAfterMove(): Fix moving view by changing coordinates according to the old view position instead of the screen position. tst_QWebEnginePage::comboBoxPopupPositionAfterChildMove(): Fix resizing spacer widget to change position of view properly. Task-number: QTBUG-55158 Change-Id: I62ebb06ee3f9dadd80888eae05d037e7129bcd69 Reviewed-by: Allan Sandfeld Jensen --- tests/auto/widgets/qwebenginepage/BLACKLIST | 6 ---- .../widgets/qwebenginepage/tst_qwebenginepage.cpp | 32 ++++++++++++++++++---- 2 files changed, 27 insertions(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/qwebenginepage/BLACKLIST b/tests/auto/widgets/qwebenginepage/BLACKLIST index 228efd61c..f3dc51fdd 100644 --- a/tests/auto/widgets/qwebenginepage/BLACKLIST +++ b/tests/auto/widgets/qwebenginepage/BLACKLIST @@ -1,9 +1,3 @@ -[comboBoxPopupPositionAfterMove] -* - -[comboBoxPopupPositionAfterChildMove] -* - [macCopyUnicodeToClipboard] osx diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index f4d0ad1a0..2cdefe27d 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -1009,9 +1009,8 @@ static QWindow *findNewTopLevelWindow(const QWindowList &oldTopLevelWindows) void tst_QWebEnginePage::comboBoxPopupPositionAfterMove() { - QScreen *screen = QGuiApplication::primaryScreen(); QWebEngineView view; - view.move(screen->availableGeometry().topLeft()); + view.move(QGuiApplication::primaryScreen()->availableGeometry().topLeft()); view.resize(640, 480); view.show(); @@ -1027,18 +1026,29 @@ void tst_QWebEnginePage::comboBoxPopupPositionAfterMove() QWindow *popup = nullptr; QTRY_VERIFY(popup = findNewTopLevelWindow(oldTlws)); + QTRY_VERIFY(QGuiApplication::topLevelWindows().contains(popup)); + QTRY_VERIFY(!popup->position().isNull()); QPoint popupPos = popup->position(); // Close the popup by clicking somewhere into the page. QTest::mouseClick(window, Qt::LeftButton, Qt::KeyboardModifiers(), QPoint(1, 1)); QTRY_VERIFY(!QGuiApplication::topLevelWindows().contains(popup)); + auto jsViewPosition = [&view]() { + QLatin1String script("(function() { return [window.screenX, window.screenY]; })()"); + QVariantList posList = evaluateJavaScriptSync(view.page(), script).toList(); + return QPoint(posList.at(0).toInt(), posList.at(1).toInt()); + }; + // Move the top-level QWebEngineView a little and check the popup's position. const QPoint offset(12, 13); - view.move(screen->availableGeometry().topLeft() + offset); + view.move(view.pos() + offset); + QTRY_COMPARE(jsViewPosition(), view.pos()); QTest::mouseClick(window, Qt::LeftButton, Qt::KeyboardModifiers(), elementCenter(view.page(), "foo")); QTRY_VERIFY(popup = findNewTopLevelWindow(oldTlws)); + QTRY_VERIFY(QGuiApplication::topLevelWindows().contains(popup)); + QTRY_VERIFY(!popup->position().isNull()); QCOMPARE(popupPos + offset, popup->position()); } @@ -1048,7 +1058,6 @@ void tst_QWebEnginePage::comboBoxPopupPositionAfterChildMove() mainWidget.setLayout(new QHBoxLayout); QWidget spacer; - spacer.setMinimumWidth(50); mainWidget.layout()->addWidget(&spacer); QWebEngineView view; @@ -1071,6 +1080,8 @@ void tst_QWebEnginePage::comboBoxPopupPositionAfterChildMove() QWindow *popup = nullptr; QTRY_VERIFY(popup = findNewTopLevelWindow(oldTlws)); + QTRY_VERIFY(QGuiApplication::topLevelWindows().contains(popup)); + QTRY_VERIFY(!popup->position().isNull()); QPoint popupPos = popup->position(); // Close the popup by clicking somewhere into the page. @@ -1078,11 +1089,22 @@ void tst_QWebEnginePage::comboBoxPopupPositionAfterChildMove() view.mapTo(view.window(), QPoint(1, 1))); QTRY_VERIFY(!QGuiApplication::topLevelWindows().contains(popup)); + int originalViewWidth = view.size().width(); + auto jsViewWidth = [&view]() { + QLatin1String script("(function() { return window.innerWidth; })()"); + int viewWidth = evaluateJavaScriptSync(view.page(), script).toInt(); + return viewWidth; + }; + // Resize the "spacer" widget, and implicitly change the global position of the QWebEngineView. - spacer.setMinimumWidth(100); + const int offset = 50; + spacer.setMinimumWidth(spacer.size().width() + offset); + QTRY_COMPARE(jsViewWidth(), originalViewWidth - offset); + QTest::mouseClick(window, Qt::LeftButton, Qt::KeyboardModifiers(), view.mapTo(view.window(), elementCenter(view.page(), "foo"))); QTRY_VERIFY(popup = findNewTopLevelWindow(oldTlws)); + QTRY_VERIFY(!popup->position().isNull()); QCOMPARE(popupPos + QPoint(50, 0), popup->position()); } -- cgit v1.2.3