summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTamas Zakor <ztamas@inf.u-szeged.hu>2019-02-15 11:18:47 +0100
committerZakor Tamas <ztamas@inf.u-szeged.hu>2019-03-06 14:46:33 +0000
commita64565af1e2d83665b8a0ece77750ac50555423a (patch)
treec77b23a58718d0458931a73c8674a3c77ea52a10
parentcad0edfcfefba67e9f4dbb2fd44368dc036eef33 (diff)
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 <allan.jensen@qt.io>
-rw-r--r--tests/auto/widgets/qwebenginepage/BLACKLIST6
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp32
2 files changed, 27 insertions, 11 deletions
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());
}