summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/qwebenginepage
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2016-08-03 10:05:02 +0200
committerPeter Varga <pvarga@inf.u-szeged.hu>2016-08-03 09:36:30 +0000
commit3b2c6decf1ac59f6d9ebbb25e6009f9cb5febce2 (patch)
tree4759f373e95c04cac31077ad3219ea47af5590bc /tests/auto/widgets/qwebenginepage
parentc2e37028d388f7093cef2b8470e84d5ece1059a8 (diff)
Eliminate some qWait() calls from QWebEnginePage auto tests
The eliminated qWait() calls were used for waiting for a TestPage to create a new window. To avoid waiting for an arbitrary time these calls are replaced by waiting for Testpage::windowCreated() signal. Change-Id: I96a142f9b99c4a36f1bf36ecba06c7ef6be732ba Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'tests/auto/widgets/qwebenginepage')
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index 874581f1c..de13019d7 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -553,10 +553,15 @@ public:
virtual QWebEnginePage* createWindow(WebWindowType) {
TestPage* page = new TestPage(this);
createdWindows.append(page);
+ emit windowCreated();
return page;
}
QRect requestedGeometry;
+
+signals:
+ void windowCreated();
+
private Q_SLOTS:
void slotGeometryChangeRequested(const QRect& geom) {
requestedGeometry = geom;
@@ -602,6 +607,7 @@ void tst_QWebEnginePage::acceptNavigationRequestNavigationType()
void tst_QWebEnginePage::popupFormSubmission()
{
TestPage page;
+ QSignalSpy windowCreatedSpy(&page, SIGNAL(windowCreated()));
page.settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, true);
page.setHtml("<form name=form1 method=get action='' target=myNewWin>"\
"<input type=hidden name=foo value='bar'>"\
@@ -609,7 +615,7 @@ void tst_QWebEnginePage::popupFormSubmission()
page.runJavaScript("window.open('', 'myNewWin', 'width=500,height=300,toolbar=0')");
evaluateJavaScriptSync(&page, "document.form1.submit();");
- QTest::qWait(500);
+ QTRY_COMPARE(windowCreatedSpy.count(), 1);
// The number of popup created should be one.
QVERIFY(page.createdWindows.size() == 1);
@@ -3451,6 +3457,7 @@ void tst_QWebEnginePage::savePage()
void tst_QWebEnginePage::openWindowDefaultSize()
{
TestPage page;
+ QSignalSpy windowCreatedSpy(&page, SIGNAL(windowCreated()));
QWebEngineView view;
page.setView(&view);
view.show();
@@ -3458,11 +3465,11 @@ void tst_QWebEnginePage::openWindowDefaultSize()
page.settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, true);
// Open a default window.
page.runJavaScript("window.open()");
- QTest::qWait(200);
+ QTRY_COMPARE(windowCreatedSpy.count(), 1);
// Open a too small window.
evaluateJavaScriptSync(&page, "window.open('','about:blank','width=10,height=10')");
+ QTRY_COMPARE(windowCreatedSpy.count(), 2);
- QTest::qWait(200);
// The number of popups created should be two.
QCOMPARE(page.createdWindows.size(), 2);
@@ -4943,6 +4950,7 @@ void tst_QWebEnginePage::viewSource()
{
TestPage page;
QSignalSpy loadFinishedSpy(&page, SIGNAL(loadFinished(bool)));
+ QSignalSpy windowCreatedSpy(&page, SIGNAL(windowCreated()));
const QUrl url("qrc:/resources/test1.html");
page.load(url);
@@ -4951,8 +4959,8 @@ void tst_QWebEnginePage::viewSource()
QVERIFY(page.canViewSource());
page.viewSource();
- QTest::qWait(200);
- QTRY_COMPARE(page.createdWindows.size(), 1);
+ QTRY_COMPARE(windowCreatedSpy.count(), 1);
+ QCOMPARE(page.createdWindows.size(), 1);
QTRY_COMPARE(page.createdWindows[0]->url().toString(), QStringLiteral("view-source:%1").arg(url.toString()));
QTRY_COMPARE(page.createdWindows[0]->title(), QStringLiteral("view-source:%1").arg(url.toString()));