diff options
author | Friedemann Kleint <Friedemann.Kleint@nokia.com> | 2011-12-21 16:54:05 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-22 10:50:32 +0100 |
commit | d8370adf6bed002f53692f36db8e47f3a8fb7555 (patch) | |
tree | 7984c400d6cf62a52cc422e6d32b63125846dbea /tests/auto/qabstractxmlnodemodel | |
parent | bfac7b0e29198e537a57991b517080fe4ac5f23f (diff) | |
download | qtxmlpatterns-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>
Diffstat (limited to 'tests/auto/qabstractxmlnodemodel')
-rw-r--r-- | tests/auto/qabstractxmlnodemodel/tst_qabstractxmlnodemodel.cpp | 12 |
1 files changed, 11 insertions, 1 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()); |