summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-09-24 12:03:59 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-09-24 13:03:43 +0200
commit52345f558f55e04ea68a8fa30d9862ca69131a18 (patch)
tree3bd9da3e6842af2d0b9c04b46693c66ab437fd2e /tests/auto
parent16192598a84eaf9ac9a50b7cca6ac5e4c21bb5e8 (diff)
parentd8fe250e542519012247952a034e78b0d492b730 (diff)
Merge remote-tracking branch 'origin/5.13' into 5.14
Conflicts: config.tests/glibc/glibc.cpp src/3rdparty src/core/configure.json src/core/profile_io_data_qt.cpp src/webengine/configure.json src/webenginewidgets/api/qwebenginepage.cpp tests/auto/widgets/qwebenginepage/BLACKLIST Change-Id: I3e1781048c3cb09bfbf7427dfc5dd1fec11a2b97
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/quick/qmltests/data/tst_filePicker.qml116
-rw-r--r--tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp14
-rw-r--r--tests/auto/widgets/proxypac/tst_proxypac.cpp4
-rw-r--r--tests/auto/widgets/qwebenginepage/BLACKLIST4
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp10
-rw-r--r--tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp34
6 files changed, 143 insertions, 39 deletions
diff --git a/tests/auto/quick/qmltests/data/tst_filePicker.qml b/tests/auto/quick/qmltests/data/tst_filePicker.qml
index 2f813b966..fad81273c 100644
--- a/tests/auto/quick/qmltests/data/tst_filePicker.qml
+++ b/tests/auto/quick/qmltests/data/tst_filePicker.qml
@@ -36,6 +36,12 @@ TestWebEngineView {
width: 400
height: 300
+ function driveLetter() {
+ if (Qt.platform.os !== "windows")
+ return "";
+ return "C:/";
+ }
+
SignalSpy {
id: titleSpy
target: webEngineView
@@ -72,27 +78,25 @@ TestWebEngineView {
function test_acceptSingleFileSelection_data() {
return [
- { tag: "/test.txt)", input: "/test.txt", passDefaultDialog: false, passCustomDialog: true },
- { tag: "/tést.txt", input: "/tést.txt", passDefaultDialog: false, passCustomDialog: true },
- { tag: "file:///test.txt", input: "file:///test.txt", passDefaultDialog: true, passCustomDialog: false },
- { tag: "file:///tést.txt", input: "file:///tést.txt", passDefaultDialog: true, passCustomDialog: false },
- { tag: "file:///t%C3%A9st.txt", input: "file:///t%C3%A9st.txt", passDefaultDialog: true, passCustomDialog: false },
- { tag: "file://test.txt", input: "file://test.txt", passDefaultDialog: false, passCustomDialog: false },
- { tag: "file:/test.txt", input: "file:/test.txt", passDefaultDialog: true, passCustomDialog: false },
- { tag: "file:test//test.txt", input: "file:test//test.txt", passDefaultDialog: false, passCustomDialog: false },
- { tag: "http://test.txt", input: "http://test.txt", passDefaultDialog: false, passCustomDialog: false },
- { tag: "qrc:/test.txt", input: "qrc:/test.txt", passDefaultDialog: false, passCustomDialog: false },
+ { tag: driveLetter() + "/test.txt", input: driveLetter() + "/test.txt", expected: "test.txt" },
+ { tag: driveLetter() + "test.txt", input: driveLetter() + "test.txt", expected: "Failed to Upload" },
+ { tag: driveLetter() + "/tést.txt", input: driveLetter() + "/tést.txt", expected: "tést.txt" },
+ { tag: driveLetter() + "/t%65st.txt", input: driveLetter() + "/t%65st.txt", expected: "t%65st.txt" },
+ { tag: "file:///" + driveLetter() + "test.txt", input: "file:///" + driveLetter() + "test.txt", expected: "test.txt" },
+ { tag: "file:///" + driveLetter() + "tést.txt", input: "file:///" + driveLetter() + "tést.txt", expected: "tést.txt" },
+ { tag: "file:///" + driveLetter() + "t%65st.txt", input: "file:///" + driveLetter() + "t%65st.txt", expected: "test.txt" },
+ { tag: "file://" + driveLetter() + "test.txt", input: "file://" + driveLetter() + "test.txt", expected: "test.txt" },
+ { tag: "file:/" + driveLetter() + "test.txt", input: "file:/" + driveLetter() + "test.txt", expected: "test.txt"},
+ { tag: "file:test//test.txt", input: "file:test//test.txt", expected: "Failed to Upload" },
+ { tag: "http://test.txt", input: "http://test.txt", expected: "Failed to Upload" },
+ { tag: "qrc:/test.txt", input: "qrc:/test.txt", expected: "Failed to Upload" },
];
}
function test_acceptSingleFileSelection(row) {
var expectedFileName;
- // Default dialog (expects URL).
- expectedFileName = "Failed to Upload";
- if (row.passDefaultDialog)
- expectedFileName = row.input.slice(row.input.lastIndexOf('/') + 1);
-
+ // Default dialog
webEngineView.url = Qt.resolvedUrl("singlefileupload.html");
verify(webEngineView.waitForLoadSucceeded());
@@ -101,16 +105,12 @@ TestWebEngineView {
keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog.
tryCompare(FilePickerParams, "filePickerOpened", true);
- tryCompare(webEngineView, "title", decodeURIComponent(expectedFileName));
+ tryCompare(webEngineView, "title", row.expected);
- // Custom dialog (expects absolute path).
+ // Custom dialog
var finished = false;
- expectedFileName = "Failed to Upload";
- if (row.passCustomDialog)
- expectedFileName = row.input.slice(row.input.lastIndexOf('/') + 1);
-
function acceptedFileHandler(request) {
request.accepted = true;
request.dialogAccept(row.input);
@@ -123,7 +123,7 @@ TestWebEngineView {
keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog.
tryVerify(function() { return finished; });
- tryCompare(webEngineView, "title", expectedFileName);
+ tryCompare(webEngineView, "title", row.expected);
webEngineView.fileDialogRequested.disconnect(acceptedFileHandler);
}
@@ -165,14 +165,14 @@ TestWebEngineView {
function test_acceptMultipleFilesWithCustomDialog_data() {
return [
- { tag: "path", input: ["/test1.txt", "/test2.txt"], expectedValueForDefaultDialog: "Failed to Upload", expectedValueForCustomDialog: "test1.txt,test2.txt" },
- { tag: "file", input: ["file:///test1.txt", "file:///test2.txt"], expectedValueForDefaultDialog: "test1.txt,test2.txt", expectedValueForCustomDialog: "Failed to Upload" },
- { tag: "mixed", input: ["file:///test1.txt", "/test2.txt"], expectedValueForDefaultDialog: "test1.txt", expectedValueForCustomDialog: "test2.txt" },
+ { tag: "path", input: [driveLetter() + "/test1.txt", driveLetter() + "/test2.txt"], expectedValue: "test1.txt,test2.txt" },
+ { tag: "file", input: ["file:///" + driveLetter() + "test1.txt", "file:/" + driveLetter() + "test2.txt"], expectedValue: "test1.txt,test2.txt" },
+ { tag: "mixed", input: ["file:///" + driveLetter() + "test1.txt", driveLetter() + "/test2.txt"], expectedValue: "test1.txt,test2.txt" },
];
}
function test_acceptMultipleFilesWithCustomDialog(row) {
- // Default dialog (expects URL).
+ // Default dialog
webEngineView.url = Qt.resolvedUrl("multifileupload.html");
verify(webEngineView.waitForLoadSucceeded());
@@ -181,10 +181,10 @@ TestWebEngineView {
keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog.
tryCompare(FilePickerParams, "filePickerOpened", true);
- tryCompare(webEngineView, "title", row.expectedValueForDefaultDialog);
+ tryCompare(webEngineView, "title", row.expectedValue);
- // Custom dialog (expects absolute path).
+ // Custom dialog
var finished = false;
function acceptedFileHandler(request) {
@@ -199,7 +199,65 @@ TestWebEngineView {
keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog.
tryVerify(function() { return finished; });
- tryCompare(webEngineView, "title", row.expectedValueForCustomDialog);
+ tryCompare(webEngineView, "title", row.expectedValue);
+ webEngineView.fileDialogRequested.disconnect(acceptedFileHandler);
+ }
+
+ function test_acceptFileOnWindows_data() {
+ return [
+ { tag: "C:test.txt", input: "C:test.txt", expected: "Failed to Upload"},
+ { tag: "C:test:txt", input: "C:test:txt", expected: "Failed to Upload"},
+ { tag: "C:/test.txt", input: "C:/test.txt", expected: "test.txt"},
+ { tag: "C:\\test.txt", input: "C:\\test.txt", expected: "test.txt"},
+ { tag: "C:\\Documents and Settings\\test\\test.txt", input: "C:\\Documents and Settings\\test\\test.txt", expected: "test.txt"},
+ { tag: "\\\\applib\\products\\a%2Db\\ abc%5F9\\t.est\\test.txt", input: "file://applib/products/a%2Db/ abc%5F9/4148.920a/media/test.txt", expected: "test.txt"},
+ { tag: "file://applib/products/a%2Db/ abc%5F9/t.est/test.txt", input: "file://applib/products/a%2Db/ abc%5F9/4148.920a/media/test.txt", expected: "test.txt"},
+ { tag: "file://applib/products/a-b/abc_1/t.est/test.txt", input: "file://applib/products/a-b/abc_1/t.est/test.txt", expected: "test.txt"},
+ { tag: "file:\\\\applib\\products\\a-b\\abc_1\\t:est\\test.txt", input: "file:\\\\applib\\products\\a-b\\abc_1\\t:est\\test.txt", expected: "test.txt"},
+ { tag: "file:C:/test.txt", input: "file:C:/test.txt", expected: "Failed to Upload"},
+ { tag: "file:/C:/test.txt", input: "file:/C:/test.txt", expected: "Failed to Upload"},
+ { tag: "file://C:/test.txt", input: "file://C:/test.txt", expected: "Failed to Upload"},
+ { tag: "file:///C:test.txt", input: "file:///C:test.txt", expected: "Failed to Upload"},
+ { tag: "file:///C:/test.txt", input: "file:///C:/test.txt", expected: "test.txt"},
+ { tag: "file:///C:\\test.txt", input: "file:///C:\\test.txt", expected: "test.txt"},
+ { tag: "file:\\//C:/test.txt", input: "file:\\//C:/test.txt", expected: "test.txt"},
+ { tag: "file:\\\\/C:\\test.txt", input: "file:\\\\/C:\\test.txt", expected: "test.txt"},
+ { tag: "\\\\?\\C:/test.txt", input: "\\\\?\\C:/test.txt", expected: "Failed to Upload"},
+ ];
+ }
+
+ function test_acceptFileOnWindows(row) {
+ if (Qt.platform.os !== "windows")
+ skip("Windows-only test");
+
+ // Default dialog
+ webEngineView.url = Qt.resolvedUrl("singlefileupload.html");
+ verify(webEngineView.waitForLoadSucceeded());
+
+ FilePickerParams.selectFiles = true;
+ FilePickerParams.selectedFilesUrl.push(row.input);
+
+ keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog.
+ tryCompare(FilePickerParams, "filePickerOpened", true);
+ tryCompare(webEngineView, "title", row.expected);
+
+
+ // Custom dialog
+ var finished = false;
+
+ function acceptedFileHandler(request) {
+ request.accepted = true;
+ request.dialogAccept(row.input);
+ finished = true;
+ }
+
+ webEngineView.fileDialogRequested.connect(acceptedFileHandler);
+ webEngineView.url = Qt.resolvedUrl("singlefileupload.html");
+ verify(webEngineView.waitForLoadSucceeded());
+
+ keyClick(Qt.Key_Enter); // Focus is on the button. Open FileDialog.
+ tryVerify(function() { return finished; });
+ tryCompare(webEngineView, "title", row.expected);
webEngineView.fileDialogRequested.disconnect(acceptedFileHandler);
}
}
diff --git a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
index 74c04635f..5572515a1 100644
--- a/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
+++ b/tests/auto/quick/qquickwebengineview/tst_qquickwebengineview.cpp
@@ -91,6 +91,7 @@ private Q_SLOTS:
void userScripts();
void javascriptClipboard_data();
void javascriptClipboard();
+ void setProfile();
private:
inline QQuickWebEngineView *newWebEngineView();
@@ -1148,5 +1149,18 @@ void tst_QQuickWebEngineView::javascriptClipboard()
QTRY_COMPARE(evaluateJavaScriptSync(view, "accessPrompt").toBool(), false);
}
+void tst_QQuickWebEngineView::setProfile() {
+ QSignalSpy loadSpy(webEngineView(), SIGNAL(loadingChanged(QQuickWebEngineLoadRequest*)));
+ webEngineView()->setUrl(urlFromTestPath("html/basic_page.html"));
+ QVERIFY(waitForLoadSucceeded(webEngineView()));
+ QCOMPARE(loadSpy.size(), 2);
+ webEngineView()->setUrl(urlFromTestPath("html/basic_page2.html"));
+ QVERIFY(waitForLoadSucceeded(webEngineView()));
+ QCOMPARE(loadSpy.size(), 4);
+ QQuickWebEngineProfile *profile = new QQuickWebEngineProfile();
+ webEngineView()->setProfile(profile);
+ QTRY_COMPARE(webEngineView()->url() ,urlFromTestPath("html/basic_page2.html"));
+}
+
QTEST_MAIN(tst_QQuickWebEngineView)
#include "tst_qquickwebengineview.moc"
diff --git a/tests/auto/widgets/proxypac/tst_proxypac.cpp b/tests/auto/widgets/proxypac/tst_proxypac.cpp
index f9340341b..934e23fde 100644
--- a/tests/auto/widgets/proxypac/tst_proxypac.cpp
+++ b/tests/auto/widgets/proxypac/tst_proxypac.cpp
@@ -46,6 +46,10 @@ private slots:
void tst_ProxyPac::proxypac()
{
+ const QString fromEnv = QString::fromLocal8Bit(qgetenv("QTWEBENGINE_CHROMIUM_FLAGS"));
+ if (!fromEnv.contains("--proxy-pac-url"))
+ qFatal("--proxy-pac-url argument is not passed.");
+
ProxyServer proxyServer1;
proxyServer1.setPort(5551);
proxyServer1.run();
diff --git a/tests/auto/widgets/qwebenginepage/BLACKLIST b/tests/auto/widgets/qwebenginepage/BLACKLIST
index e6fad8b20..7857ee818 100644
--- a/tests/auto/widgets/qwebenginepage/BLACKLIST
+++ b/tests/auto/widgets/qwebenginepage/BLACKLIST
@@ -4,9 +4,5 @@ osx
[mouseMovementProperties]
windows
-[runJavaScriptFromSlot]
-osx
-linux
-
[fullScreenRequested]
windows
diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
index dbb15ba10..5edd778e2 100644
--- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
+++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
@@ -1824,24 +1824,22 @@ void tst_QWebEnginePage::runJavaScriptFromSlot()
{
QWebEngineProfile profile;
QWebEnginePage page(&profile);
- page.settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, true);
QSignalSpy loadFinishedSpy(&page, &QWebEnginePage::loadFinished);
page.setHtml("<html><body>"
" <input type='text' id='input1' value='QtWebEngine' size='50' />"
"</body></html>");
QTRY_COMPARE(loadFinishedSpy.count(), 1);
- // Workaround for QTBUG-74718
- QTRY_VERIFY(page.action(QWebEnginePage::SelectAll)->isEnabled());
- QVariant result(-1);
+ bool done = false;
connect(&page, &QWebEnginePage::selectionChanged, [&]() {
- result = evaluateJavaScriptSync(&page, QStringLiteral("2+2"));
+ QTRY_COMPARE(evaluateJavaScriptSync(&page, QStringLiteral("2+2")), QVariant(4));
+ done = true;
});
evaluateJavaScriptSync(&page, QStringLiteral("const input = document.getElementById('input1');"
"input.focus();"
"input.select();"));
- QTRY_COMPARE(result, QVariant(4));
+ QTRY_VERIFY(done);
}
void tst_QWebEnginePage::fullScreenRequested()
diff --git a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
index 827ac2757..71c4aa9b5 100644
--- a/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
+++ b/tests/auto/widgets/qwebengineview/tst_qwebengineview.cpp
@@ -192,6 +192,8 @@ private Q_SLOTS:
void webUIURLs_data();
void webUIURLs();
void visibilityState();
+ void visibilityState2();
+ void visibilityState3();
void jsKeyboardEvent();
void deletePage();
void closeOpenerTab();
@@ -3140,6 +3142,38 @@ void tst_QWebEngineView::visibilityState()
QCOMPARE(evaluateJavaScriptSync(view.page(), "document.visibilityState").toString(), QStringLiteral("visible"));
}
+void tst_QWebEngineView::visibilityState2()
+{
+ QWebEngineView view;
+ QSignalSpy spy(&view, &QWebEngineView::loadFinished);
+ view.show();
+ view.load(QStringLiteral("about:blank"));
+ view.hide();
+ QVERIFY(spy.count() || spy.wait());
+ QVERIFY(spy.takeFirst().takeFirst().toBool());
+ QCOMPARE(evaluateJavaScriptSync(view.page(), "document.visibilityState").toString(), QStringLiteral("hidden"));
+}
+
+void tst_QWebEngineView::visibilityState3()
+{
+ QWebEnginePage page1;
+ QWebEnginePage page2;
+ QSignalSpy spy1(&page1, &QWebEnginePage::loadFinished);
+ QSignalSpy spy2(&page2, &QWebEnginePage::loadFinished);
+ page1.load(QStringLiteral("about:blank"));
+ page2.load(QStringLiteral("about:blank"));
+ QVERIFY(spy1.count() || spy1.wait());
+ QVERIFY(spy2.count() || spy2.wait());
+ QWebEngineView view;
+ view.setPage(&page1);
+ view.show();
+ QCOMPARE(evaluateJavaScriptSync(&page1, "document.visibilityState").toString(), QStringLiteral("visible"));
+ QCOMPARE(evaluateJavaScriptSync(&page2, "document.visibilityState").toString(), QStringLiteral("hidden"));
+ view.setPage(&page2);
+ QCOMPARE(evaluateJavaScriptSync(&page1, "document.visibilityState").toString(), QStringLiteral("hidden"));
+ QCOMPARE(evaluateJavaScriptSync(&page2, "document.visibilityState").toString(), QStringLiteral("visible"));
+}
+
void tst_QWebEngineView::jsKeyboardEvent()
{
QWebEngineView view;