Changed qtextbrowser unittest to work from install directory

- Changed qtextbrowser unittest to use TESTDATA and QFINDTESTDATA

Change-Id: I0ac7c990640d492d5ec94f5824c022a2b5075103
Reviewed-by: Kurt Korbatits  <kurt.korbatits@nokia.com>
Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
bb10
Kurt Korbatits 2012-01-27 14:47:54 +10:00 committed by Qt by Nokia
parent c298c7b73b
commit 835c53490b
3 changed files with 14 additions and 19 deletions

View File

@ -1,14 +1,7 @@
CONFIG += testcase
TARGET = tst_qtextbrowser
SOURCES += tst_qtextbrowser.cpp
DEFINES += SRCDIR=\\\"$$PWD\\\"
QT += widgets testlib
wince* {
addFiles.files = *.html
addFiles.path = .
addDir.files = subdir/*
addDir.path = subdir
DEPLOYMENT += addFiles addDir
}
TESTDATA += *.html subdir/*

View File

@ -120,11 +120,13 @@ tst_QTextBrowser::tst_QTextBrowser()
tst_QTextBrowser::~tst_QTextBrowser()
{
}
void tst_QTextBrowser::init()
{
#if !defined(Q_OS_IRIX) && !defined(Q_OS_WINCE)
QDir::setCurrent(SRCDIR);
#endif
QString prefix = QFileInfo(QFINDTESTDATA("subdir")).absolutePath();
QVERIFY2(!prefix.isEmpty(), "Test data directory not found");
QDir::setCurrent(prefix);
browser = new TestBrowser;
browser->show();
}
@ -252,18 +254,18 @@ void tst_QTextBrowser::relativeLinks()
qRegisterMetaType<QUrl>("QUrl");
QSignalSpy sourceChangedSpy(browser, SIGNAL(sourceChanged(const QUrl &)));
browser->setSource(QUrl("../qtextbrowser.html"));
browser->setSource(QUrl("subdir/../qtextbrowser.html"));
QVERIFY(!browser->document()->isEmpty());
QVERIFY(sourceChangedSpy.count() == 1);
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("../qtextbrowser.html"));
browser->setSource(QUrl("qtextbrowser/subdir/index.html"));
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("subdir/../qtextbrowser.html"));
browser->setSource(QUrl("subdir/index.html"));
QVERIFY(!browser->document()->isEmpty());
QVERIFY(sourceChangedSpy.count() == 1);
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("qtextbrowser/subdir/index.html"));
browser->setSource(QUrl("../anchor.html"));
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("subdir/index.html"));
browser->setSource(QUrl("anchor.html"));
QVERIFY(!browser->document()->isEmpty());
QVERIFY(sourceChangedSpy.count() == 1);
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("../anchor.html"));
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("anchor.html"));
browser->setSource(QUrl("subdir/index.html"));
QVERIFY(!browser->document()->isEmpty());
QVERIFY(sourceChangedSpy.count() == 1);
@ -274,10 +276,10 @@ void tst_QTextBrowser::relativeLinks()
QVERIFY(!browser->document()->isEmpty());
QVERIFY(sourceChangedSpy.count() == 1);
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("file:anchor.html"));
browser->setSource(QUrl("../qtextbrowser.html"));
browser->setSource(QUrl("subdir/../qtextbrowser.html"));
QVERIFY(!browser->document()->isEmpty());
QVERIFY(sourceChangedSpy.count() == 1);
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("../qtextbrowser.html"));
QCOMPARE(sourceChangedSpy.takeFirst()[0].toUrl(), QUrl("subdir/../qtextbrowser.html"));
}
void tst_QTextBrowser::anchors()