tests/auto/qdom/tst_qdom.cpp
changeset 7 f7bc934e204c
parent 3 41300fa6a67c
--- a/tests/auto/qdom/tst_qdom.cpp	Tue Feb 02 00:43:10 2010 +0200
+++ b/tests/auto/qdom/tst_qdom.cpp	Wed Mar 31 11:06:36 2010 +0300
@@ -1,6 +1,6 @@
 /****************************************************************************
 **
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
 ** All rights reserved.
 ** Contact: Nokia Corporation (qt-info@nokia.com)
 **
@@ -131,6 +131,7 @@
     void setContentWhitespace_data() const;
 
     void taskQTBUG4595_dontAssertWhenDocumentSpecifiesUnknownEncoding() const;
+    void cloneDTD_QTBUG8398() const;
 
     void cleanupTestCase() const;
 
@@ -1912,5 +1913,29 @@
     QVERIFY(true);
 }
 
+void tst_QDom::cloneDTD_QTBUG8398() const
+{
+    QString dtd("<?xml version='1.0' encoding='UTF-8'?>\n"
+                   "<!DOCTYPE first [\n"
+                   "<!ENTITY secondFile SYSTEM 'second.xml'>\n"
+                   "<!ENTITY thirdFile SYSTEM 'third.xml'>\n"
+                   "]>\n"
+                   "<first/>\n");
+    QDomDocument domDocument;
+    QVERIFY(domDocument.setContent(dtd));
+    QDomDocument domDocument2 = domDocument.cloneNode(true).toDocument();
+
+    // for some reason, our DOM implementation reverts the order of entities
+    QString expected("<?xml version='1.0' encoding='UTF-8'?>\n"
+                   "<!DOCTYPE first [\n"
+                   "<!ENTITY thirdFile SYSTEM 'third.xml'>\n"
+                   "<!ENTITY secondFile SYSTEM 'second.xml'>\n"
+                   "]>\n"
+                   "<first/>\n");
+    QString output;
+    QTextStream stream(&output);
+    domDocument2.save(stream, 0);
+    QCOMPARE(output, expected);
+}
 QTEST_MAIN(tst_QDom)
 #include "tst_qdom.moc"