diff options
author | Jüri Valdmann <juri.valdmann@qt.io> | 2017-11-08 17:23:48 +0100 |
---|---|---|
committer | Jüri Valdmann <juri.valdmann@qt.io> | 2017-11-10 14:44:06 +0000 |
commit | 2e54fc39cc49bd57541ac4a78a8622c37ef33769 (patch) | |
tree | 36f5765f76cb47c5ae83d32b8c13cf4a1b527c4a /tests | |
parent | 4de8486b6614896a2b84cc64b69606c7b3bd07e8 (diff) |
URLRequestQrcJobQt: remove ineffective URL formatting options
Remove strange options for call to QUrl::path and add test for "qrc" protocol.
Change-Id: I6528d858b7661832852c333a7f932d4714f953f2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'tests')
5 files changed, 42 insertions, 0 deletions
diff --git a/tests/auto/widgets/qwebenginepage/resources/bar.txt b/tests/auto/widgets/qwebenginepage/resources/bar.txt new file mode 100644 index 000000000..5716ca598 --- /dev/null +++ b/tests/auto/widgets/qwebenginepage/resources/bar.txt @@ -0,0 +1 @@ +bar diff --git a/tests/auto/widgets/qwebenginepage/resources/foo.txt b/tests/auto/widgets/qwebenginepage/resources/foo.txt new file mode 100644 index 000000000..257cc5642 --- /dev/null +++ b/tests/auto/widgets/qwebenginepage/resources/foo.txt @@ -0,0 +1 @@ +foo diff --git a/tests/auto/widgets/qwebenginepage/resources/path with spaces.txt b/tests/auto/widgets/qwebenginepage/resources/path with spaces.txt new file mode 100644 index 000000000..4f79cb0dd --- /dev/null +++ b/tests/auto/widgets/qwebenginepage/resources/path with spaces.txt @@ -0,0 +1 @@ +contents with spaces diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp index bef77d3f1..e3d6a7435 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp @@ -197,6 +197,7 @@ private Q_SLOTS: void loadFinishedAfterNotFoundError(); void loadInSignalHandlers_data(); void loadInSignalHandlers(); + void loadFromQrc(); void restoreHistory(); void toPlainTextLoadFinishedRace_data(); @@ -4037,6 +4038,41 @@ void tst_QWebEnginePage::loadInSignalHandlers() QCOMPARE(m_page->url(), urlForSetter); } +void tst_QWebEnginePage::loadFromQrc() +{ + QWebEnginePage page; + QSignalSpy spy(&page, &QWebEnginePage::loadFinished); + + // Standard case. + page.load(QStringLiteral("qrc:///resources/foo.txt")); + QTRY_COMPARE(spy.count(), 1); + QCOMPARE(spy.takeFirst().value(0).toBool(), true); + QCOMPARE(toPlainTextSync(&page), QStringLiteral("foo\n")); + + // Query and fragment parts are ignored. + page.load(QStringLiteral("qrc:///resources/bar.txt?foo=1#bar")); + QTRY_COMPARE(spy.count(), 1); + QCOMPARE(spy.takeFirst().value(0).toBool(), true); + QCOMPARE(toPlainTextSync(&page), QStringLiteral("bar\n")); + + // Literal spaces are OK. + page.load(QStringLiteral("qrc:///resources/path with spaces.txt")); + QTRY_COMPARE(spy.count(), 1); + QCOMPARE(spy.takeFirst().value(0).toBool(), true); + QCOMPARE(toPlainTextSync(&page), QStringLiteral("contents with spaces\n")); + + // Escaped spaces are OK too. + page.load(QStringLiteral("qrc:///resources/path%20with%20spaces.txt")); + QTRY_COMPARE(spy.count(), 1); + QCOMPARE(spy.takeFirst().value(0).toBool(), true); + QCOMPARE(toPlainTextSync(&page), QStringLiteral("contents with spaces\n")); + + // Resource not found, loading fails. + page.load(QStringLiteral("qrc:///nope")); + QTRY_COMPARE(spy.count(), 1); + QCOMPARE(spy.takeFirst().value(0).toBool(), false); +} + void tst_QWebEnginePage::restoreHistory() { QWebChannel channel; diff --git a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc index 91adeb694..1226e367d 100644 --- a/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc +++ b/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.qrc @@ -18,5 +18,8 @@ <file>resources/test2.html</file> <file>resources/testiframe.html</file> <file>resources/testiframe2.html</file> + <file>resources/foo.txt</file> + <file>resources/bar.txt</file> + <file>resources/path with spaces.txt</file> </qresource> </RCC> |