summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>2011-12-21 16:54:05 +0100
committerQt by Nokia <qt-info@nokia.com>2011-12-22 10:50:32 +0100
commitd8370adf6bed002f53692f36db8e47f3a8fb7555 (patch)
tree7984c400d6cf62a52cc422e6d32b63125846dbea
parentbfac7b0e29198e537a57991b517080fe4ac5f23f (diff)
downloadqtxmlpatterns-d8370adf6bed002f53692f36db8e47f3a8fb7555.tar.gz
QtXmlPatterns-test: Use QFINDTESTDATA to locate test data.
Introduce QFINDTESTDATA and set the current directory of the process to the test directory such that it works indepently of the working directory of executable location. Change-Id: I8105ba0fa7d9da7ff920d10f3a083433e2590e9f Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Honglei Zhang <honglei.zhang@nokia.com>
-rw-r--r--tests/auto/qabstractxmlnodemodel/tst_qabstractxmlnodemodel.cpp12
-rw-r--r--tests/auto/xmlpatternsdiagnosticsts/tst_xmlpatternsdiagnosticsts.cpp10
-rw-r--r--tests/auto/xmlpatternsschemats/tst_xmlpatternsschemats.cpp10
-rw-r--r--tests/auto/xmlpatternsxslts/tst_xmlpatternsxslts.cpp10
4 files changed, 38 insertions, 4 deletions
diff --git a/tests/auto/qabstractxmlnodemodel/tst_qabstractxmlnodemodel.cpp b/tests/auto/qabstractxmlnodemodel/tst_qabstractxmlnodemodel.cpp
index 9da1c70..4940b26 100644
--- a/tests/auto/qabstractxmlnodemodel/tst_qabstractxmlnodemodel.cpp
+++ b/tests/auto/qabstractxmlnodemodel/tst_qabstractxmlnodemodel.cpp
@@ -49,6 +49,8 @@
#include <QXmlQuery>
#include <QXmlResultItems>
#include <QXmlSerializer>
+#include <QFileInfo>
+#include <QDir>
#include "TestNodeModel.h"
#include "LoadingModel.h"
@@ -87,8 +89,15 @@ private:
QXmlNodeModelIndex m_rootNode;
};
+const char testFileName[] = "tree.xml";
+
void tst_QAbstractXmlNodeModel::initTestCase()
{
+ const QString testFilePath = QFINDTESTDATA(testFileName);
+ QVERIFY2(!testFilePath.isEmpty(), "tree.xml not found");
+ const QString testDirectory = QFileInfo(testFilePath).absolutePath();
+ QVERIFY2(QDir::setCurrent(testDirectory), qPrintable(QStringLiteral("Could not chdir to ") + testDirectory));
+
m_nodeModel = LoadingModel::create(m_namePool);
QVERIFY(m_nodeModel);
m_rootNode = m_nodeModel->root(QXmlNodeModelIndex());
@@ -173,7 +182,8 @@ void tst_QAbstractXmlNodeModel::nextFromSimpleAxis()
/* Create the baseline. */
{
QXmlQuery openDoc(m_namePool);
- openDoc.bindVariable(QLatin1String("docURI"), QVariant(inputFile(QLatin1String("tree.xml"))));
+ const QString testFilePath = QDir::currentPath() + QLatin1Char('/') + QLatin1String(testFileName);
+ openDoc.bindVariable(QLatin1String("docURI"), QVariant(testFilePath));
openDoc.setQuery(QLatin1String("doc($docURI)"));
QXmlResultItems doc;
QVERIFY(openDoc.isValid());
diff --git a/tests/auto/xmlpatternsdiagnosticsts/tst_xmlpatternsdiagnosticsts.cpp b/tests/auto/xmlpatternsdiagnosticsts/tst_xmlpatternsdiagnosticsts.cpp
index cd0bd11..fddf264 100644
--- a/tests/auto/xmlpatternsdiagnosticsts/tst_xmlpatternsdiagnosticsts.cpp
+++ b/tests/auto/xmlpatternsdiagnosticsts/tst_xmlpatternsdiagnosticsts.cpp
@@ -41,6 +41,8 @@
#include <QtTest/QtTest>
+#include <QtCore/QDir>
+#include <QtCore/QFileInfo>
#include "tst_suitetest.h"
@@ -65,7 +67,13 @@ tst_XmlPatternsDiagnosticsTS::tst_XmlPatternsDiagnosticsTS() : tst_SuiteTest(tst
void tst_XmlPatternsDiagnosticsTS::catalogPath(QString &write) const
{
- write = QLatin1String("TestSuite/DiagnosticsCatalog.xml");
+ const char testSuite[] = "TestSuite";
+ const QString testSuitePath = QFINDTESTDATA(testSuite);
+ if (!testSuitePath.isEmpty()) {
+ const QString testDirectory = QFileInfo(testSuitePath).absolutePath();
+ QVERIFY2(QDir::setCurrent(testDirectory), qPrintable(QStringLiteral("Could not chdir to ") + testDirectory));
+ write = QLatin1String(testSuite) + QStringLiteral("/DiagnosticsCatalog.xml");
+ }
}
QTEST_MAIN(tst_XmlPatternsDiagnosticsTS)
diff --git a/tests/auto/xmlpatternsschemats/tst_xmlpatternsschemats.cpp b/tests/auto/xmlpatternsschemats/tst_xmlpatternsschemats.cpp
index 4be52e7..a57242c 100644
--- a/tests/auto/xmlpatternsschemats/tst_xmlpatternsschemats.cpp
+++ b/tests/auto/xmlpatternsschemats/tst_xmlpatternsschemats.cpp
@@ -40,6 +40,8 @@
****************************************************************************/
#include <QtTest/QtTest>
+#include <QtCore/QDir>
+#include <QtCore/QFileInfo>
#include "tst_suitetest.h"
@@ -63,7 +65,13 @@ tst_XmlPatternsSchemaTS::tst_XmlPatternsSchemaTS()
void tst_XmlPatternsSchemaTS::catalogPath(QString &write) const
{
- write = QLatin1String("TESTSUITE/testSuites.xml");
+ const char testSuite[] = "TESTSUITE";
+ const QString testSuitePath = QFINDTESTDATA(testSuite);
+ if (!testSuitePath.isEmpty()) {
+ const QString testDirectory = QFileInfo(testSuitePath).absolutePath();
+ QVERIFY2(QDir::setCurrent(testDirectory), qPrintable(QStringLiteral("Could not chdir to ") + testDirectory));
+ write = QLatin1String(testSuite) + QStringLiteral("/testSuites.xml");
+ }
}
QTEST_MAIN(tst_XmlPatternsSchemaTS)
diff --git a/tests/auto/xmlpatternsxslts/tst_xmlpatternsxslts.cpp b/tests/auto/xmlpatternsxslts/tst_xmlpatternsxslts.cpp
index 6c21f98..cf2ac7c 100644
--- a/tests/auto/xmlpatternsxslts/tst_xmlpatternsxslts.cpp
+++ b/tests/auto/xmlpatternsxslts/tst_xmlpatternsxslts.cpp
@@ -41,6 +41,8 @@
#include <QtTest/QtTest>
+#include <QtCore/QDir>
+#include <QtCore/QFileInfo>
#include "tst_suitetest.h"
@@ -65,7 +67,13 @@ tst_XmlPatternsXSLTS::tst_XmlPatternsXSLTS() : tst_SuiteTest(tst_SuiteTest::Xslt
void tst_XmlPatternsXSLTS::catalogPath(QString &write) const
{
- write = QLatin1String("XSLTS/catalogResolved.xml");
+ const char testSuite[] = "XSLTS";
+ const QString testSuitePath = QFINDTESTDATA(testSuite);
+ if (!testSuitePath.isEmpty()) {
+ const QString testDirectory = QFileInfo(testSuitePath).absolutePath();
+ QVERIFY2(QDir::setCurrent(testDirectory), qPrintable(QStringLiteral("Could not chdir to ") + testDirectory));
+ write = QLatin1String(testSuite) + QStringLiteral("/catalogResolved.xml");
+ }
}
QTEST_MAIN(tst_XmlPatternsXSLTS)