summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp')
-rw-r--r--tests/auto/widgets/qwebenginepage/tst_qwebenginepage.cpp36
1 files changed, 36 insertions, 0 deletions
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;