summaryrefslogtreecommitdiffstats
path: root/tests/auto/xmlpatternssdk
diff options
context:
space:
mode:
authorHonglei Zhang <honglei.zhang@nokia.com>2011-08-22 14:42:41 +0300
committerHonglei Zhang <honglei.zhang@nokia.com>2011-08-24 14:20:20 +0300
commit33f65993866e3eb2a80001f1b53f38dbfc7017ce (patch)
treea55a42043aca2435a80f5270331e0c2c1ed94495 /tests/auto/xmlpatternssdk
parent49dd6e2978759a3fc46016d82a46d8ee8b609221 (diff)
Enable running of XQuery test suite
Some xmlpatterns auto test cases are still using old script. And some small bugs in test driver prevent the XQuery test suite testing. This commit updated the out-of-date scripts and fixes couple of bugs in test driver. Task-number: QTBUG-16028 Reviewed-by: Dmitry Trofimov
Diffstat (limited to 'tests/auto/xmlpatternssdk')
-rw-r--r--tests/auto/xmlpatternssdk/TestSuite.cpp1
-rw-r--r--tests/auto/xmlpatternssdk/TestSuiteHandler.cpp17
-rw-r--r--tests/auto/xmlpatternssdk/TestSuiteHandler.h4
-rw-r--r--tests/auto/xmlpatternssdk/Worker.cpp2
-rw-r--r--tests/auto/xmlpatternssdk/XSDTestSuiteHandler.cpp1
5 files changed, 24 insertions, 1 deletions
diff --git a/tests/auto/xmlpatternssdk/TestSuite.cpp b/tests/auto/xmlpatternssdk/TestSuite.cpp
index e24786ac3d..db94f25f7d 100644
--- a/tests/auto/xmlpatternssdk/TestSuite.cpp
+++ b/tests/auto/xmlpatternssdk/TestSuite.cpp
@@ -151,6 +151,7 @@ TestSuite *TestSuite::openCatalog(QIODevice *input,
}
reader.setContentHandler(loader.data());
+ reader.setEntityResolver(loader.data());
QXmlInputSource source(input);
diff --git a/tests/auto/xmlpatternssdk/TestSuiteHandler.cpp b/tests/auto/xmlpatternssdk/TestSuiteHandler.cpp
index 74a6082ce1..c46350a2e3 100644
--- a/tests/auto/xmlpatternssdk/TestSuiteHandler.cpp
+++ b/tests/auto/xmlpatternssdk/TestSuiteHandler.cpp
@@ -40,6 +40,7 @@
****************************************************************************/
#include <QtDebug>
+#include <QDir>
#include "qacceltreeresourceloader_p.h"
#include "qnetworkaccessdelegator_p.h"
@@ -308,5 +309,21 @@ TestSuite *TestSuiteHandler::testSuite() const
return m_ts;
}
+bool TestSuiteHandler::resolveEntity(const QString& publicId,
+ const QString& systemId,
+ QXmlInputSource*& ret)
+{
+ QFileInfo catFileName(m_catalogFile.path());
+ QFileInfo externalFileName(catFileName.absolutePath(), systemId);
+ QFile *file = new QFile(externalFileName.absoluteFilePath());
+ if (file->open(QIODevice::ReadOnly | QIODevice::Text)) {
+ ret = new QXmlInputSource(file);
+ return true;
+ }
+ return false;
+ //return QXmlDefaultHandler::resolveEntity(publicId, systemId, ret);
+}
+
+
// vim: et:ts=4:sw=4:sts=4
diff --git a/tests/auto/xmlpatternssdk/TestSuiteHandler.h b/tests/auto/xmlpatternssdk/TestSuiteHandler.h
index 7a46145271..2d6a22f285 100644
--- a/tests/auto/xmlpatternssdk/TestSuiteHandler.h
+++ b/tests/auto/xmlpatternssdk/TestSuiteHandler.h
@@ -94,6 +94,10 @@ namespace QPatternistSDK
const QString &qName,
const QXmlAttributes &atts);
+ virtual bool resolveEntity(const QString& publicId,
+ const QString& systemId,
+ QXmlInputSource*& ret);
+
virtual TestSuite *testSuite() const;
private:
diff --git a/tests/auto/xmlpatternssdk/Worker.cpp b/tests/auto/xmlpatternssdk/Worker.cpp
index f2051cc3a8..4fb7da7b39 100644
--- a/tests/auto/xmlpatternssdk/Worker.cpp
+++ b/tests/auto/xmlpatternssdk/Worker.cpp
@@ -183,7 +183,7 @@ void Worker::threadFinished()
const int totPass = count(m_result, TestResult::Pass);
const int total = resultCount;
const int notTested = m_notTested.count();
- const int percentage = int((static_cast<double>(totPass) / total) * 100);
+ const int percentage = total==0 ? 0 : int((static_cast<double>(totPass) / total) * 100);
Q_ASSERT_X(percentage >= 0 && percentage <= 100, Q_FUNC_INFO,
qPrintable(QString(QLatin1String("Percentage was: %1")).arg(percentage)));
diff --git a/tests/auto/xmlpatternssdk/XSDTestSuiteHandler.cpp b/tests/auto/xmlpatternssdk/XSDTestSuiteHandler.cpp
index 5b6fb9060b..9036dadddc 100644
--- a/tests/auto/xmlpatternssdk/XSDTestSuiteHandler.cpp
+++ b/tests/auto/xmlpatternssdk/XSDTestSuiteHandler.cpp
@@ -793,6 +793,7 @@ XSDTestSuiteHandler::XSDTestSuiteHandler(const QUrl &catalogFile) : m_ts(0)
<< QLatin1String("schZ012_a")
<< QLatin1String("stZ041")
<< QLatin1String("wildZ010");
+
}
bool XSDTestSuiteHandler::startElement(const QString &namespaceURI,