summaryrefslogtreecommitdiffstats
path: root/tests/auto/qxmlstream
diff options
context:
space:
mode:
authoraxis <qt-info@nokia.com>2009-08-19 09:24:04 (GMT)
committeraxis <qt-info@nokia.com>2009-08-19 09:24:04 (GMT)
commit2d1b49bd21b788ba3e35fc5c41bf3aab42cbda65 (patch)
tree24dae3a4532870d61282841f6bb186cb008ab747 /tests/auto/qxmlstream
parentb3a3652abbf1cb4ebba6c6257ecf47f8dc022d93 (diff)
parent20d2b7312456435e5e1a98dba7c2cc96b44fe83c (diff)
downloadQt-2d1b49bd21b788ba3e35fc5c41bf3aab42cbda65.zip
Qt-2d1b49bd21b788ba3e35fc5c41bf3aab42cbda65.tar.gz
Qt-2d1b49bd21b788ba3e35fc5c41bf3aab42cbda65.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt
Conflicts: tests/auto/auto.pro
Diffstat (limited to 'tests/auto/qxmlstream')
-rw-r--r--tests/auto/qxmlstream/tst_qxmlstream.cpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/auto/qxmlstream/tst_qxmlstream.cpp b/tests/auto/qxmlstream/tst_qxmlstream.cpp
index 375528c..04f990f 100644
--- a/tests/auto/qxmlstream/tst_qxmlstream.cpp
+++ b/tests/auto/qxmlstream/tst_qxmlstream.cpp
@@ -55,6 +55,8 @@
//TESTED_CLASS=QXmlStreamReader QXmlStreamWriter
//TESTED_FILES=corelib/xml/stream/qxmlutils.cpp corelib/xml/stream/qxmlstream.cpp corelib/xml/stream/qxmlstream_p.h
+Q_DECLARE_METATYPE(QXmlStreamReader::ReadElementTextBehaviour)
+
static const char *const catalogFile = "XML-Test-Suite/xmlconf/finalCatalog.xml";
static const int expectedRunCount = 1646;
static const int expectedSkipCount = 532;
@@ -550,6 +552,9 @@ private slots:
void setEntityResolver();
void readFromQBuffer() const;
void readFromQBufferInvalid() const;
+ void readNextStartElement() const;
+ void readElementText() const;
+ void readElementText_data() const;
void crashInUTF16Codec() const;
void hasAttributeSignature() const;
void hasAttribute() const;
@@ -1107,6 +1112,71 @@ void tst_QXmlStream::readFromQBufferInvalid() const
QVERIFY(reader.hasError());
}
+void tst_QXmlStream::readNextStartElement() const
+{
+ QLatin1String in("<?xml version=\"1.0\"?><A><!-- blah --><B><C/></B><B attr=\"value\"/>text</A>");
+ QXmlStreamReader reader(in);
+
+ QVERIFY(reader.readNextStartElement());
+ QVERIFY(reader.isStartElement() && reader.name() == "A");
+
+ int amountOfB = 0;
+ while (reader.readNextStartElement()) {
+ QVERIFY(reader.isStartElement() && reader.name() == "B");
+ ++amountOfB;
+ reader.skipCurrentElement();
+ }
+
+ QCOMPARE(amountOfB, 2);
+}
+
+void tst_QXmlStream::readElementText() const
+{
+ QFETCH(QXmlStreamReader::ReadElementTextBehaviour, behaviour);
+ QFETCH(QString, input);
+ QFETCH(QString, expected);
+
+ QXmlStreamReader reader(input);
+
+ QVERIFY(reader.readNextStartElement());
+ QCOMPARE(reader.readElementText(behaviour), expected);
+}
+
+void tst_QXmlStream::readElementText_data() const
+{
+ QTest::addColumn<QXmlStreamReader::ReadElementTextBehaviour>("behaviour");
+ QTest::addColumn<QString>("input");
+ QTest::addColumn<QString>("expected");
+
+ QString validInput("<p>He was <em>never</em> going to admit<!-- TODO: rephrase --> his mistake.</p>");
+ QString invalidInput("<p>invalid...<p>");
+ QString invalidOutput("invalid...");
+
+ QTest::newRow("ErrorOnUnexpectedElement")
+ << QXmlStreamReader::ErrorOnUnexpectedElement
+ << validInput << QString("He was ");
+
+ QTest::newRow("IncludeChildElements")
+ << QXmlStreamReader::IncludeChildElements
+ << validInput << QString("He was never going to admit his mistake.");
+
+ QTest::newRow("SkipChildElements")
+ << QXmlStreamReader::SkipChildElements
+ << validInput << QString("He was going to admit his mistake.");
+
+ QTest::newRow("ErrorOnUnexpectedElement Invalid")
+ << QXmlStreamReader::ErrorOnUnexpectedElement
+ << invalidInput << invalidOutput;
+
+ QTest::newRow("IncludeChildElements Invalid")
+ << QXmlStreamReader::IncludeChildElements
+ << invalidInput << invalidOutput;
+
+ QTest::newRow("SkipChildElements Invalid")
+ << QXmlStreamReader::SkipChildElements
+ << invalidInput << invalidOutput;
+}
+
void tst_QXmlStream::crashInUTF16Codec() const
{
QEventLoop eventLoop;