Don't use the QRegExp methods that modify the object
[profile/ivi/qtxmlpatterns.git] / tests / auto / qxmlquery / tst_qxmlquery.cpp
index 024301e..1b5d424 100644 (file)
@@ -1,8 +1,7 @@
 /****************************************************************************
 **
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
 **
 ** This file is part of the test suite of the Qt Toolkit.
 **
@@ -35,6 +34,7 @@
 **
 **
 **
+**
 ** $QT_END_LICENSE$
 **
 ****************************************************************************/
@@ -42,8 +42,6 @@
 
 #include <QtTest/QtTest>
 
-#ifdef QTEST_XMLPATTERNS
-
 #include <QAbstractMessageHandler>
 #include <QFileInfo>
 #include <QNetworkReply>
 #include "TestFundament.h"
 #include "../network-settings.h"
 
-#if defined(Q_OS_SYMBIAN)
-#define SRCDIR ""
-#define XMLPATTERNSDIR "xmlpatterns"
-#else
 #define XMLPATTERNSDIR SRCDIR "../xmlpatterns"
-#endif
 
 /*!
  \class tst_QXmlQuery
@@ -95,10 +88,10 @@ public:
                            , m_pushTestsCount(0)
                            , m_testNetwork(true)
     {
-        Q_SET_DEFAULT_IAP
     }
 
 private Q_SLOTS:
+    void initTestCase();
     void defaultConstructor() const;
     void copyConstructor() const;
     void constructorQXmlNamePool() const;
@@ -260,6 +253,11 @@ private:
     const bool m_testNetwork;
 };
 
+void tst_QXmlQuery::initTestCase()
+{
+    QVERIFY(QtNetworkSettings::verifyTestNetworkSettings());
+}
+
 void tst_QXmlQuery::checkBaseURI(const QUrl &baseURI, const QString &candidate)
 {
     /* The use of QFileInfo::canonicalFilePath() takes into account that drive letters
@@ -1730,7 +1728,7 @@ void tst_QXmlQuery::messageXML() const
 
     query.setQuery(QLatin1String("1basicSyntaxError"));
 
-    const QRegExp removeFilename(QLatin1String("Location: file:.*\\#"));
+    QRegExp removeFilename(QLatin1String("Location: file:.*\\#"));
     QVERIFY(removeFilename.isValid());
 
     QVERIFY(messageValidator.success());
@@ -2001,7 +1999,7 @@ void tst_QXmlQuery::fnDocNetworkAccessSuccess() const
     QStringList testsToSkip;
     testsToSkip << "http scheme" << "ftp scheme";
     if (testsToSkip.contains(QTest::currentDataTag()))
-        QSKIP("Network tests are currently unsupported on Windows CE.", SkipSingle);
+        QSKIP("Network tests are currently unsupported on Windows CE.");
 #endif
 
     QFETCH(QUrl, uriToOpen);
@@ -2535,7 +2533,7 @@ void tst_QXmlQuery::setQueryQUrlSuccess() const
     QStringList testsToSkip;
     testsToSkip << "A valid query via the ftp scheme" << "A valid query via the http scheme";
     if (testsToSkip.contains(QTest::currentDataTag()))
-        QSKIP("Network tests are currently unsupported on Windows CE.", SkipSingle);
+        QSKIP("Network tests are currently unsupported on Windows CE.");
 #endif
 
     QFETCH(QUrl, queryURI);
@@ -2877,7 +2875,15 @@ void tst_QXmlQuery::useUriResolver() const
                              const QUrl &baseURI) const
         {
             Q_UNUSED(relative);
-            return baseURI.resolved(inputFile(QLatin1String(queriesDirectory) + QLatin1String("simpleDocument.xml")));
+            QString fixedInputFile = inputFile(QLatin1String(queriesDirectory) + QLatin1String("simpleDocument.xml"));
+#ifdef Q_OS_WIN
+            // A file path with drive letter is not a valid relative URI, so remove the drive letter.
+            // Note that can't just use inputFileAsURI() instead of inputFile() as that doesn't
+            // produce a relative URI either.
+            if (fixedInputFile.size() > 1 && fixedInputFile.at(1) == QLatin1Char(':'))
+                fixedInputFile.remove(0, 2);
+#endif
+            return baseURI.resolved(fixedInputFile);
         }
     };
 
@@ -3478,6 +3484,3 @@ void tst_QXmlQuery::identityConstraintFailure_data() const
 QTEST_MAIN(tst_QXmlQuery)
 
 #include "tst_qxmlquery.moc"
-#else //QTEST_XMLPATTERNS
-QTEST_NOOP_MAIN
-#endif