summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets/qtextbrowser
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2019-05-28 16:41:49 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2019-06-03 15:14:42 +0200
commite4079eca49adce16e31dac2a18d49d7a55817891 (patch)
tree1dfb960ec1115b1f552afe8a013058542389505e /tests/auto/widgets/widgets/qtextbrowser
parentf32a6cfb6b6236533508901f114ab57396da8ff3 (diff)
parentec6dc5f78453048c4f0604655a34c6c20c79d819 (diff)
Merge remote-tracking branch 'origin/dev' into wip/cmake
Diffstat (limited to 'tests/auto/widgets/widgets/qtextbrowser')
-rw-r--r--tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp
index 8a1b228c71..1f95032165 100644
--- a/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp
+++ b/tests/auto/widgets/widgets/qtextbrowser/tst_qtextbrowser.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2019 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the test suite of the Qt Toolkit.
@@ -38,7 +38,7 @@
class TestBrowser : public QTextBrowser
{
public:
- inline TestBrowser() : htmlLoadAttempts(0) {
+ inline TestBrowser() {
show();
QApplication::setActiveWindow(this);
activateWindow();
@@ -47,11 +47,12 @@ public:
QVERIFY(hasFocus());
}
- virtual QVariant loadResource(int type, const QUrl &name);
+ QVariant loadResource(int type, const QUrl &name) override;
- int htmlLoadAttempts;
+ int htmlLoadAttempts = 0;
QUrl lastResource;
QUrl sourceInsideLoadResource;
+ QUrl baseInsideLoadResource;
};
QVariant TestBrowser::loadResource(int type, const QUrl &name)
@@ -60,6 +61,7 @@ QVariant TestBrowser::loadResource(int type, const QUrl &name)
htmlLoadAttempts++;
lastResource = name;
sourceInsideLoadResource = source();
+ baseInsideLoadResource = document()->baseUrl();
return QTextBrowser::loadResource(type, name);
}
@@ -108,7 +110,7 @@ void tst_QTextBrowser::init()
void tst_QTextBrowser::cleanup()
{
delete browser;
- browser = 0;
+ browser = nullptr;
}
void tst_QTextBrowser::noReloadOnAnchorJump()
@@ -428,11 +430,18 @@ void tst_QTextBrowser::sourceInsideLoadResource()
#ifdef Q_OS_WINRT
QSKIP("Paths cannot be compared if applications are sandboxed.");
#endif
- QUrl url = QUrl::fromLocalFile("pagewithimage.html");
+ QUrl url = QUrl::fromLocalFile("pagewithimage.html"); // "file://pagewithimage.html"
browser->setSource(url);
QCOMPARE(browser->lastResource, QUrl::fromLocalFile(QDir::current().filePath("foobar.png")));
+ // baseUrl was not set because the source URL was a relative one
+ QCOMPARE(browser->baseInsideLoadResource, QUrl());
QEXPECT_FAIL("", "This is currently not supported", Continue);
QCOMPARE(browser->sourceInsideLoadResource.toString(), url.toString());
+ url = QUrl::fromLocalFile(QDir::current().filePath("pagewithimage.html")); // "file:///home/user/path/to/pagewithimage.html"
+ browser->setSource(url);
+ QCOMPARE(browser->lastResource, QUrl::fromLocalFile(QDir::current().filePath("foobar.png")));
+ // baseUrl has the full path, and that's where relative-path resources come from
+ QCOMPARE(browser->baseInsideLoadResource, QUrl::fromLocalFile(QDir::currentPath() + QLatin1Char('/')));
}
void tst_QTextBrowser::textInteractionFlags_vs_readOnly()