summaryrefslogtreecommitdiffstats
path: root/tests/auto/xml/dom/qdom/tst_qdom.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/xml/dom/qdom/tst_qdom.cpp')
-rw-r--r--tests/auto/xml/dom/qdom/tst_qdom.cpp119
1 files changed, 84 insertions, 35 deletions
diff --git a/tests/auto/xml/dom/qdom/tst_qdom.cpp b/tests/auto/xml/dom/qdom/tst_qdom.cpp
index 734d7b473b..b5dc2e6081 100644
--- a/tests/auto/xml/dom/qdom/tst_qdom.cpp
+++ b/tests/auto/xml/dom/qdom/tst_qdom.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
@@ -125,6 +125,8 @@ private slots:
void taskQTBUG4595_dontAssertWhenDocumentSpecifiesUnknownEncoding() const;
void cloneDTD_QTBUG8398() const;
+ void DTDNotationDecl();
+ void DTDEntityDecl();
void cleanupTestCase() const;
@@ -166,7 +168,7 @@ void tst_QDom::setContent_data()
QTest::addColumn<QStringList>("featuresFalse");
QTest::addColumn<QString>("res");
-/* QTest::newRow( "01" ) << doc01
+ QTest::newRow( "01" ) << doc01
<< QStringList()
<< QString("http://trolltech.com/xml/features/report-whitespace-only-CharData").split(' ')
<< QString("<!DOCTYPE a1>\n"
@@ -238,7 +240,7 @@ void tst_QDom::setContent_data()
" </b3>\n"
"</a1>\n");
- */ QTest::newRow("05") << QString("<message>\n"
+ QTest::newRow("05") << QString("<message>\n"
" <body>&lt;b&gt;foo&lt;/b&gt;>]]&gt;</body>\n"
"</message>\n")
<< QStringList() << QStringList()
@@ -261,11 +263,11 @@ void tst_QDom::setContent()
QStringList::Iterator it;
for ( it = featuresTrue.begin(); it != featuresTrue.end(); ++it ) {
QVERIFY( reader.hasFeature( *it ) );
- reader.setFeature( *it, TRUE );
+ reader.setFeature( *it, true );
}
for ( it = featuresFalse.begin(); it != featuresFalse.end(); ++it ) {
QVERIFY( reader.hasFeature( *it ) );
- reader.setFeature( *it, FALSE );
+ reader.setFeature( *it, false );
}
QDomDocument domDoc;
@@ -386,7 +388,7 @@ void tst_QDom::hasAttributes_data()
}
/*
- This function tests that QDomNode::hasAttributes() returns TRUE if and only
+ This function tests that QDomNode::hasAttributes() returns true if and only
if the node has attributes (i.e. QDomNode::attributes() returns a list with
attributes in it).
*/
@@ -588,13 +590,13 @@ void tst_QDom::cloneNode_data()
QTest::addColumn<QList<QVariant> >("pathToNode");
QTest::addColumn<bool>("deep");
- QTest::newRow( "noDeep_01" ) << doc01 << nodeB1 << (bool)FALSE;
- QTest::newRow( "noDeep_02" ) << doc01 << nodeC1 << (bool)FALSE;
- QTest::newRow( "noDeep_03" ) << doc01 << nodeC2 << (bool)FALSE;
+ QTest::newRow( "noDeep_01" ) << doc01 << nodeB1 << false;
+ QTest::newRow( "noDeep_02" ) << doc01 << nodeC1 << false;
+ QTest::newRow( "noDeep_03" ) << doc01 << nodeC2 << false;
- QTest::newRow( "deep_01" ) << doc01 << nodeB1 << (bool)TRUE;
- QTest::newRow( "deep_02" ) << doc01 << nodeC1 << (bool)TRUE;
- QTest::newRow( "deep_03" ) << doc01 << nodeC2 << (bool)TRUE;
+ QTest::newRow( "deep_01" ) << doc01 << nodeB1 << true;
+ QTest::newRow( "deep_02" ) << doc01 << nodeC1 << true;
+ QTest::newRow( "deep_03" ) << doc01 << nodeC2 << true;
}
void tst_QDom::cloneNode()
@@ -732,14 +734,14 @@ void tst_QDom::ownerDocumentTask27424_data()
QTest::addColumn<bool>("insertLevel2AfterCstr");
QTest::addColumn<bool>("insertLevel3AfterCstr");
- QTest::newRow( "000" ) << (bool)FALSE << (bool)FALSE << (bool)FALSE;
- QTest::newRow( "001" ) << (bool)FALSE << (bool)FALSE << (bool)TRUE;
- QTest::newRow( "010" ) << (bool)FALSE << (bool)TRUE << (bool)FALSE;
- QTest::newRow( "011" ) << (bool)FALSE << (bool)TRUE << (bool)TRUE;
- QTest::newRow( "100" ) << (bool)TRUE << (bool)FALSE << (bool)FALSE;
- QTest::newRow( "101" ) << (bool)TRUE << (bool)FALSE << (bool)TRUE;
- QTest::newRow( "110" ) << (bool)TRUE << (bool)TRUE << (bool)FALSE;
- QTest::newRow( "111" ) << (bool)TRUE << (bool)TRUE << (bool)TRUE;
+ QTest::newRow( "000" ) << false << false << false;
+ QTest::newRow( "001" ) << false << false << true;
+ QTest::newRow( "010" ) << false << true << false;
+ QTest::newRow( "011" ) << false << true << true;
+ QTest::newRow( "100" ) << true << false << false;
+ QTest::newRow( "101" ) << true << false << true;
+ QTest::newRow( "110" ) << true << true << false;
+ QTest::newRow( "111" ) << true << true << true;
}
void tst_QDom::ownerDocumentTask27424()
@@ -858,14 +860,14 @@ void tst_QDom::documentCreationTask27424_data()
QTest::addColumn<bool>("insertLevel2AfterCstr");
QTest::addColumn<bool>("insertLevel3AfterCstr");
- QTest::newRow( "000" ) << (bool)FALSE << (bool)FALSE << (bool)FALSE;
- QTest::newRow( "001" ) << (bool)FALSE << (bool)FALSE << (bool)TRUE;
- QTest::newRow( "010" ) << (bool)FALSE << (bool)TRUE << (bool)FALSE;
- QTest::newRow( "011" ) << (bool)FALSE << (bool)TRUE << (bool)TRUE;
- QTest::newRow( "100" ) << (bool)TRUE << (bool)FALSE << (bool)FALSE;
- QTest::newRow( "101" ) << (bool)TRUE << (bool)FALSE << (bool)TRUE;
- QTest::newRow( "110" ) << (bool)TRUE << (bool)TRUE << (bool)FALSE;
- QTest::newRow( "111" ) << (bool)TRUE << (bool)TRUE << (bool)TRUE;
+ QTest::newRow( "000" ) << false << false << false;
+ QTest::newRow( "001" ) << false << false << true;
+ QTest::newRow( "010" ) << false << true << false;
+ QTest::newRow( "011" ) << false << true << true;
+ QTest::newRow( "100" ) << true << false << false;
+ QTest::newRow( "101" ) << true << false << true;
+ QTest::newRow( "110" ) << true << true << false;
+ QTest::newRow( "111" ) << true << true << true;
}
void tst_QDom::documentCreationTask27424()
@@ -961,9 +963,9 @@ bool tst_QDom::isDeepEqual(const QDomNode &n1, const QDomNode &n2)
}
/*
- Returns TRUE if \a doc1 and \a doc2 represent the same XML document, i.e.
+ Returns true if \a doc1 and \a doc2 represent the same XML document, i.e.
they have the same informational content. Otherwise, this function returns
- FALSE.
+ false.
*/
bool tst_QDom::compareDocuments( const QDomDocument &doc1, const QDomDocument &doc2 )
{
@@ -971,12 +973,12 @@ bool tst_QDom::compareDocuments( const QDomDocument &doc1, const QDomDocument &d
}
/*
- Returns TRUE if \a node1 and \a node2 represent the same XML node, i.e.
+ Returns true if \a node1 and \a node2 represent the same XML node, i.e.
they have the same informational content. Otherwise, this function returns
- FALSE.
+ false.
- If \a deep is TRUE, children of the nodes are also tested. If \a deep is
- FALSE, only \a node1 and \a node 2 are compared.
+ If \a deep is true, children of the nodes are also tested. If \a deep is
+ false, only \a node1 and \a node 2 are compared.
*/
bool tst_QDom::compareNodes( const QDomNode &node1, const QDomNode &node2, bool deep )
{
@@ -995,7 +997,7 @@ bool tst_QDom::compareNodes( const QDomNode &node1, const QDomNode &node2, bool
}
if ( node1.isNull() && node2.isNull() )
- return TRUE;
+ return true;
// ### I am not sure if this test is complete
bool equal = node1.nodeName() == node2.nodeName();
equal = equal && node1.nodeType() == node2.nodeType();
@@ -1923,5 +1925,52 @@ void tst_QDom::cloneDTD_QTBUG8398() const
domDocument2.save(stream, 0);
QCOMPARE(output, expected);
}
+
+void tst_QDom::DTDNotationDecl()
+{
+ QString dtd("<?xml version='1.0' encoding='UTF-8'?>\n"
+ "<!DOCTYPE first [\n"
+ "<!NOTATION gif SYSTEM 'image/gif'>\n"
+ "<!NOTATION jpeg SYSTEM 'image/jpeg'>\n"
+ "]>\n"
+ "<first/>\n");
+
+ QDomDocument domDocument;
+ QVERIFY(domDocument.setContent(dtd));
+
+ const QDomDocumentType doctype = domDocument.doctype();
+ QCOMPARE(doctype.notations().size(), 2);
+
+ QVERIFY(doctype.namedItem(QString("gif")).isNotation());
+ QCOMPARE(doctype.namedItem(QString("gif")).toNotation().systemId(), QString("image/gif"));
+
+ QVERIFY(doctype.namedItem(QString("jpeg")).isNotation());
+ QCOMPARE(doctype.namedItem(QString("jpeg")).toNotation().systemId(), QString("image/jpeg"));
+}
+
+void tst_QDom::DTDEntityDecl()
+{
+ QString dtd("<?xml version='1.0' encoding='UTF-8'?>\n"
+ "<!DOCTYPE first [\n"
+ "<!ENTITY secondFile SYSTEM 'second.xml'>\n"
+ "<!ENTITY logo SYSTEM \"http://www.w3c.org/logo.gif\" NDATA gif>"
+ "]>\n"
+ "<first/>\n");
+
+ QDomDocument domDocument;
+ QVERIFY(domDocument.setContent(dtd));
+
+ const QDomDocumentType doctype = domDocument.doctype();
+ QCOMPARE(doctype.entities().count(), 2);
+
+ QVERIFY(doctype.namedItem(QString("secondFile")).isEntity());
+ QCOMPARE(doctype.namedItem(QString("secondFile")).toEntity().systemId(), QString("second.xml"));
+ QCOMPARE(doctype.namedItem(QString("secondFile")).toEntity().notationName(), QString());
+
+ QVERIFY(doctype.namedItem(QString("logo")).isEntity());
+ QCOMPARE(doctype.namedItem(QString("logo")).toEntity().systemId(), QString("http://www.w3c.org/logo.gif"));
+ QCOMPARE(doctype.namedItem(QString("logo")).toEntity().notationName(), QString("gif"));
+}
+
QTEST_MAIN(tst_QDom)
#include "tst_qdom.moc"