1 /****************************************************************************
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: Nokia Corporation (qt-info@nokia.com)
7 ** This file is part of the test suite of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** No Commercial Usage
11 ** This file contains pre-release code and may not be distributed.
12 ** You may use this file in accordance with the terms and conditions
13 ** contained in the Technology Preview License Agreement accompanying
16 ** GNU Lesser General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU Lesser
18 ** General Public License version 2.1 as published by the Free Software
19 ** Foundation and appearing in the file LICENSE.LGPL included in the
20 ** packaging of this file. Please review the following information to
21 ** ensure the GNU Lesser General Public License version 2.1 requirements
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 ** In addition, as a special exception, Nokia gives you certain additional
25 ** rights. These rights are described in the Nokia Qt LGPL Exception
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
40 ****************************************************************************/
43 #include <QDomDocument>
45 #include <qtcpserver.h>
46 #include <qtcpsocket.h>
47 #include <QtTest/QtTest>
52 #include "parser/parser.h"
54 static const char *const inputString
= "<!DOCTYPE inferno [<!ELEMENT inferno (circle+)><!ELEMENT circle (#PCDATA)>]><inferno><circle /><circle /></inferno>";
55 static const char *const refString
= "setDocumentLocator(locator={columnNumber=1, lineNumber=1})\nstartDocument()\nstartDTD(name=\"inferno\", publicId=\"\", systemId=\"\")\nendDTD()\nstartElement(namespaceURI=\"\", localName=\"inferno\", qName=\"inferno\", atts=[])\nstartElement(namespaceURI=\"\", localName=\"circle\", qName=\"circle\", atts=[])\nendElement(namespaceURI=\"\", localName=\"circle\", qName=\"circle\")\nstartElement(namespaceURI=\"\", localName=\"circle\", qName=\"circle\", atts=[])\nendElement(namespaceURI=\"\", localName=\"circle\", qName=\"circle\")\nendElement(namespaceURI=\"\", localName=\"inferno\", qName=\"inferno\")\nendDocument()\n";
60 #define TEST_PORT 1088
62 class XmlServer
: public QThread
73 XmlServer::XmlServer()
84 if (!srv
.listen(QHostAddress::Any
, TEST_PORT
))
88 srv
.waitForNewConnection(100);
90 if (QTcpSocket
*sock
= srv
.nextPendingConnection()) {
94 if (sock
->getChar(&c
)) {
99 if (!sock
->waitForReadyRead(-1))
104 QFile
file(QString::fromLocal8Bit(fileName
));
105 if (!file
.open(QIODevice::ReadOnly
)) {
106 qWarning() << "XmlServer::run(): could not open" << fileName
;
112 QByteArray data
= file
.readAll();
113 for (int i
= 0; i
< data
.size();) {
114 // sock->putChar(data.at(i));
115 int cnt
= qMin(CHUNK_SIZE
, data
.size() - i
);
116 sock
->write(data
.constData() + i
, cnt
);
127 sock
->disconnectFromHost();
138 class tst_QXmlSimpleReader
: public QObject
143 tst_QXmlSimpleReader();
144 ~tst_QXmlSimpleReader();
148 void testGoodXmlFile();
149 void testGoodXmlFile_data();
150 void testBadXmlFile();
151 void testBadXmlFile_data();
152 void testIncrementalParsing();
153 void testIncrementalParsing_data();
154 void setDataQString();
155 void inputFromQIODevice();
156 void inputFromString();
157 void inputFromSocket_data();
158 void inputFromSocket();
160 void idsInParseException1();
161 void idsInParseException2();
162 void preserveCharacterReferences() const;
163 void reportNamespace() const;
164 void reportNamespace_data() const;
165 void roundtripWithNamespaces() const;
168 static QDomDocument
fromByteArray(const QString
&title
, const QByteArray
&ba
);
172 tst_QXmlSimpleReader::tst_QXmlSimpleReader()
174 server
= new XmlServer();
175 server
->setParent(this);
180 tst_QXmlSimpleReader::~tst_QXmlSimpleReader()
182 server
->quit_soon
= true;
186 class MyErrorHandler
: public QXmlErrorHandler
192 virtual bool error(const QXmlParseException
&)
197 virtual QString
errorString() const
202 virtual bool fatalError(const QXmlParseException
&exception
)
204 publicId
= exception
.publicId();
205 systemId
= exception
.systemId();
209 virtual bool warning(const QXmlParseException
&)
216 void tst_QXmlSimpleReader::idsInParseException1()
218 MyErrorHandler handler
;
219 QXmlSimpleReader reader
;
221 reader
.setErrorHandler(&handler
);
223 /* A non-wellformed XML document with PUBLIC and SYSTEM. */
224 QByteArray
input("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" "
225 "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
226 "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">"
231 QBuffer
buff(&input
);
232 QXmlInputSource
source(&buff
);
234 /* Yes, parsing should be reported as a failure. */
235 QVERIFY(!reader
.parse(source
));
237 QCOMPARE(handler
.publicId
, QString::fromLatin1("-//W3C//DTD XHTML 1.0 Strict//EN"));
238 QCOMPARE(handler
.systemId
, QString::fromLatin1("http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"));
241 void tst_QXmlSimpleReader::idsInParseException2()
243 MyErrorHandler handler
;
244 QXmlSimpleReader reader
;
246 reader
.setErrorHandler(&handler
);
248 /* A non-wellformed XML document with only SYSTEM. */
249 QByteArray
input("<!DOCTYPE html SYSTEM \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"
250 "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">"
255 QBuffer
buff(&input
);
256 QXmlInputSource
source(&buff
);
258 /* Yes, parsing should be reported as a failure. */
259 QVERIFY(!reader
.parse(source
));
261 QCOMPARE(handler
.publicId
, QString());
262 QCOMPARE(handler
.systemId
, QString::fromLatin1("http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"));
265 static QStringList
findXmlFiles(QString dir_name
)
270 QFileInfoList file_list
= dir
.entryInfoList(QStringList("*.xml"), QDir::Files
, QDir::Name
);
272 QFileInfoList::const_iterator it
= file_list
.begin();
273 for (; it
!= file_list
.end(); ++it
) {
274 const QFileInfo
&file_info
= *it
;
275 result
.append(file_info
.filePath());
282 void tst_QXmlSimpleReader::testGoodXmlFile_data()
284 const char * const good_data_dirs
[] = {
286 "xmldocs/valid/not-sa",
287 "xmldocs/valid/ext-sa",
290 const char * const *d
= good_data_dirs
;
292 QStringList good_file_list
;
294 good_file_list
+= findXmlFiles(*d
);
296 QTest::addColumn
<QString
>("file_name");
297 QStringList::const_iterator it
= good_file_list
.begin();
298 for (; it
!= good_file_list
.end(); ++it
)
299 QTest::newRow((*it
).toLatin1()) << *it
;
302 void tst_QXmlSimpleReader::testGoodXmlFile()
304 QFETCH(QString
, file_name
);
305 QFile
file(file_name
);
306 QVERIFY(file
.open(QIODevice::ReadOnly
));
307 QString content
= file
.readAll();
309 QVERIFY(file
.open(QIODevice::ReadOnly
));
313 // qWarning("Test nr: " + QString::number(i)); ++i;
314 QEXPECT_FAIL("xmldocs/valid/sa/089.xml", "", Continue
);
315 QVERIFY(parser
.parseFile(&file
));
317 QFile
ref_file(file_name
+ ".ref");
318 QVERIFY(ref_file
.open(QIODevice::ReadOnly
| QIODevice::Text
));
319 QTextStream
ref_stream(&ref_file
);
320 ref_stream
.setCodec("UTF-8");
321 QString ref_file_contents
= ref_stream
.readAll();
323 QEXPECT_FAIL("xmldocs/valid/sa/089.xml", "", Continue
);
324 QCOMPARE(parser
.result(), ref_file_contents
);
327 void tst_QXmlSimpleReader::testBadXmlFile_data()
329 const char * const bad_data_dirs
[] = {
333 const char * const *d
= bad_data_dirs
;
335 QStringList bad_file_list
;
337 bad_file_list
+= findXmlFiles(*d
);
339 QTest::addColumn
<QString
>("file_name");
340 QStringList::const_iterator it
= bad_file_list
.begin();
341 for (; it
!= bad_file_list
.end(); ++it
)
342 QTest::newRow((*it
).toLatin1()) << *it
;
345 void tst_QXmlSimpleReader::testBadXmlFile()
347 QFETCH(QString
, file_name
);
348 QFile
file(file_name
);
349 QVERIFY(file
.open(QIODevice::ReadOnly
));
353 // qWarning("Test nr: " + QString::number(++i));
354 QEXPECT_FAIL("xmldocs/not-wf/sa/030.xml", "", Continue
);
355 QEXPECT_FAIL("xmldocs/not-wf/sa/031.xml", "", Continue
);
356 QEXPECT_FAIL("xmldocs/not-wf/sa/032.xml", "", Continue
);
357 QEXPECT_FAIL("xmldocs/not-wf/sa/033.xml", "", Continue
);
358 QEXPECT_FAIL("xmldocs/not-wf/sa/038.xml", "", Continue
);
359 QEXPECT_FAIL("xmldocs/not-wf/sa/072.xml", "", Continue
);
360 QEXPECT_FAIL("xmldocs/not-wf/sa/073.xml", "", Continue
);
361 QEXPECT_FAIL("xmldocs/not-wf/sa/074.xml", "", Continue
);
362 QEXPECT_FAIL("xmldocs/not-wf/sa/076.xml", "", Continue
);
363 QEXPECT_FAIL("xmldocs/not-wf/sa/077.xml", "", Continue
);
364 QEXPECT_FAIL("xmldocs/not-wf/sa/078.xml", "", Continue
);
365 QEXPECT_FAIL("xmldocs/not-wf/sa/085.xml", "", Continue
);
366 QEXPECT_FAIL("xmldocs/not-wf/sa/086.xml", "", Continue
);
367 QEXPECT_FAIL("xmldocs/not-wf/sa/087.xml", "", Continue
);
368 QEXPECT_FAIL("xmldocs/not-wf/sa/101.xml", "", Continue
);
369 QEXPECT_FAIL("xmldocs/not-wf/sa/102.xml", "", Continue
);
370 QEXPECT_FAIL("xmldocs/not-wf/sa/104.xml", "", Continue
);
371 QEXPECT_FAIL("xmldocs/not-wf/sa/116.xml", "", Continue
);
372 QEXPECT_FAIL("xmldocs/not-wf/sa/117.xml", "", Continue
);
373 QEXPECT_FAIL("xmldocs/not-wf/sa/119.xml", "", Continue
);
374 QEXPECT_FAIL("xmldocs/not-wf/sa/122.xml", "", Continue
);
375 QEXPECT_FAIL("xmldocs/not-wf/sa/132.xml", "", Continue
);
376 QEXPECT_FAIL("xmldocs/not-wf/sa/142.xml", "", Continue
);
377 QEXPECT_FAIL("xmldocs/not-wf/sa/143.xml", "", Continue
);
378 QEXPECT_FAIL("xmldocs/not-wf/sa/144.xml", "", Continue
);
379 QEXPECT_FAIL("xmldocs/not-wf/sa/145.xml", "", Continue
);
380 QEXPECT_FAIL("xmldocs/not-wf/sa/146.xml", "", Abort
);
381 QEXPECT_FAIL("xmldocs/not-wf/sa/160.xml", "", Continue
);
382 QEXPECT_FAIL("xmldocs/not-wf/sa/162.xml", "", Continue
);
383 QEXPECT_FAIL("xmldocs/not-wf/sa/166.xml", "", Continue
);
384 QEXPECT_FAIL("xmldocs/not-wf/sa/167.xml", "", Continue
);
385 QEXPECT_FAIL("xmldocs/not-wf/sa/168.xml", "", Continue
);
386 QEXPECT_FAIL("xmldocs/not-wf/sa/169.xml", "", Continue
);
387 QEXPECT_FAIL("xmldocs/not-wf/sa/170.xml", "", Continue
);
388 QEXPECT_FAIL("xmldocs/not-wf/sa/171.xml", "", Abort
);
389 QEXPECT_FAIL("xmldocs/not-wf/sa/172.xml", "", Abort
);
390 QEXPECT_FAIL("xmldocs/not-wf/sa/173.xml", "", Abort
);
391 QEXPECT_FAIL("xmldocs/not-wf/sa/174.xml", "", Abort
);
392 QEXPECT_FAIL("xmldocs/not-wf/sa/175.xml", "", Abort
);
393 QEXPECT_FAIL("xmldocs/not-wf/sa/177.xml", "", Abort
);
394 QEXPECT_FAIL("xmldocs/not-wf/sa/180.xml", "", Continue
);
395 QEXPECT_FAIL("xmldocs/not-wf/sa/181.xml", "", Continue
);
396 QEXPECT_FAIL("xmldocs/not-wf/sa/182.xml", "", Continue
);
397 QEXPECT_FAIL("xmldocs/not-wf/sa/185.xml", "", Continue
);
398 QEXPECT_FAIL("xmldocs/not-wf/sa/186.xml", "", Continue
);
400 QVERIFY(!parser
.parseFile(&file
));
402 QFile
ref_file(file_name
+ ".ref");
403 QVERIFY(ref_file
.open(QIODevice::ReadOnly
| QIODevice::Text
));
404 QTextStream
ref_stream(&ref_file
);
405 ref_stream
.setCodec("UTF-8");
406 QString ref_file_contents
= ref_stream
.readAll();
408 QEXPECT_FAIL("xmldocs/not-wf/sa/144.xml", "", Continue
);
409 QEXPECT_FAIL("xmldocs/not-wf/sa/145.xml", "", Continue
);
410 QEXPECT_FAIL("xmldocs/not-wf/sa/146.xml", "", Continue
);
411 QEXPECT_FAIL("xmldocs/not-wf/sa/167.xml", "", Continue
);
412 QEXPECT_FAIL("xmldocs/not-wf/sa/166.xml", "", Continue
);
413 QEXPECT_FAIL("xmldocs/not-wf/sa/170.xml", "", Continue
);
415 QCOMPARE(parser
.result(), ref_file_contents
);
418 void tst_QXmlSimpleReader::testIncrementalParsing_data()
420 QTest::addColumn
<QString
>("file_name");
421 QTest::addColumn
<int>("chunkSize");
423 const char * const good_data_dirs
[] = {
425 "xmldocs/valid/not-sa",
426 "xmldocs/valid/ext-sa",
429 const char * const *d
= good_data_dirs
;
431 QStringList good_file_list
;
433 good_file_list
+= findXmlFiles(*d
);
435 for (int i
=1; i
<10; ++i
) {
436 QStringList::const_iterator it
= good_file_list
.begin();
437 for (; it
!= good_file_list
.end(); ++it
) {
438 if ( *it
== "xmldocs/valid/sa/089.xml" )
439 continue;// TODO: fails at the moment -- don't bother
441 *it
== "xmldocs/valid/sa/049.xml" ||
442 *it
== "xmldocs/valid/sa/050.xml" ||
443 *it
== "xmldocs/valid/sa/051.xml" ||
444 *it
== "xmldocs/valid/sa/052.xml" ) ) {
445 continue; // TODO: fails at the moment -- don't bother
447 QTest::newRow(QString("%1 %2").arg(*it
).arg(i
).toLatin1()) << *it
<< i
;
452 void tst_QXmlSimpleReader::testIncrementalParsing()
454 QFETCH(QString
, file_name
);
455 QFETCH(int, chunkSize
);
457 QFile
file(file_name
);
458 QVERIFY(file
.open(QIODevice::ReadOnly
));
461 QXmlInputSource source
;
463 while (!file
.atEnd()) {
464 source
.setData(file
.read(chunkSize
));
466 QVERIFY(parser
.parse(&source
, true));
469 QVERIFY(parser
.parseContinue());
472 // detect end of document
473 QVERIFY(parser
.parseContinue());
474 // parsing should fail after the end of the document was reached
475 QVERIFY(!parser
.parseContinue());
477 QFile
ref_file(file_name
+ ".ref");
478 QVERIFY(ref_file
.open(QIODevice::ReadOnly
| QIODevice::Text
));
479 QTextStream
ref_stream(&ref_file
);
480 ref_stream
.setCodec("UTF-8");
481 QString ref_file_contents
= ref_stream
.readAll();
483 QCOMPARE(parser
.result(), ref_file_contents
);
486 void tst_QXmlSimpleReader::setDataQString()
488 QString input
= inputString
;
489 QString ref
= refString
;
491 QXmlInputSource source
;
494 source
.setData(input
);
495 QVERIFY(parser
.parse(&source
,false));
497 QBuffer resultBuffer
;
498 resultBuffer
.setData(parser
.result().toLatin1());
501 refBuffer
.setData(ref
.toLatin1());
503 resultBuffer
.open(QIODevice::ReadOnly
);
504 refBuffer
.open(QIODevice::ReadOnly
);
507 while (resultBuffer
.canReadLine()) {
508 if (!refBuffer
.canReadLine()) {
509 success
= false; break ;
511 if (resultBuffer
.readLine().simplified() != refBuffer
.readLine().simplified()) {
512 success
= false; break ;
518 void tst_QXmlSimpleReader::inputFromQIODevice()
521 inputBuffer
.setData(inputString
);
523 QXmlInputSource
source(&inputBuffer
);
526 QVERIFY(parser
.parse(&source
,false));
528 QBuffer resultBuffer
;
529 resultBuffer
.setData(parser
.result().toLatin1());
532 refBuffer
.setData(refString
);
534 resultBuffer
.open(QIODevice::ReadOnly
);
535 refBuffer
.open(QIODevice::ReadOnly
);
538 while (resultBuffer
.canReadLine()) {
539 if (!refBuffer
.canReadLine()) {
540 success
= false; break ;
542 if (resultBuffer
.readLine().simplified() != refBuffer
.readLine().simplified()) {
543 success
= false; break ;
549 void tst_QXmlSimpleReader::inputFromString()
551 QString str
= "<foo><bar>kake</bar><bar>ja</bar></foo>";
553 buff
.setData((char*)str
.utf16(), str
.size()*sizeof(ushort
));
555 QXmlInputSource
input(&buff
);
557 QXmlSimpleReader reader
;
558 QXmlDefaultHandler handler
;
559 reader
.setContentHandler(&handler
);
561 QVERIFY(reader
.parse(&input
));
564 void tst_QXmlSimpleReader::inputFromSocket_data()
566 QStringList files
= findXmlFiles(QLatin1String("encodings"));
567 QVERIFY(files
.count() > 0);
569 QTest::addColumn
<QString
>("file_name");
571 foreach (const QString
&file_name
, files
)
572 QTest::newRow(file_name
.toLatin1()) << file_name
;
575 void tst_QXmlSimpleReader::inputFromSocket()
577 QFETCH(QString
, file_name
);
579 #if defined(Q_OS_SYMBIAN)
580 QSKIP("Symbian: Skipped due to problems in Open C and QtNetwork", SkipAll
);
583 #if defined(Q_OS_WIN32) && (defined(Q_CC_INTEL) || defined(Q_CC_MINGW) || defined(Q_CC_MSVC_NET))
584 QSKIP("Regression caused by QHOstInfo change 294548, see task 202231.", SkipAll
);
587 sock
.connectToHost(QHostAddress::LocalHost
, TEST_PORT
);
589 const bool connectionSuccess
= sock
.waitForConnected();
590 if(!connectionSuccess
) {
591 QTextStream
out(stderr
);
592 out
<< "QTcpSocket::errorString()" << sock
.errorString();
595 QVERIFY(connectionSuccess
);
597 sock
.write(file_name
.toLocal8Bit() + "\n");
598 QVERIFY(sock
.waitForBytesWritten());
600 QXmlInputSource
input(&sock
);
602 QXmlSimpleReader reader
;
603 QXmlDefaultHandler handler
;
604 reader
.setContentHandler(&handler
);
606 QVERIFY(reader
.parse(&input
));
608 // qDebug() << "tst_QXmlSimpleReader::inputFromSocket(): success" << file_name;
611 void tst_QXmlSimpleReader::preserveCharacterReferences() const
613 class Handler
: public QXmlDefaultHandler
616 virtual bool characters(const QString
&chars
)
626 QByteArray
input("<e>A    A</e>");
628 QBuffer
buff(&input
);
629 QXmlInputSource
source(&buff
);
632 QXmlSimpleReader reader
;
633 reader
.setContentHandler(&h
);
634 QVERIFY(reader
.parse(&source
, false));
636 QCOMPARE(h
.received
, QLatin1Char('A') + QString(4, QChar(160)) + QLatin1Char('A'));
640 QByteArray
input("<e>    </e>");
642 QBuffer
buff(&input
);
643 QXmlInputSource
source(&buff
);
646 QXmlSimpleReader reader
;
647 reader
.setContentHandler(&h
);
648 QVERIFY(reader
.parse(&source
, false));
650 QCOMPARE(h
.received
, QString(4, QChar(160)));
654 void tst_QXmlSimpleReader::reportNamespace() const
656 class Handler
: public QXmlDefaultHandler
659 virtual bool startElement(const QString
&namespaceURI
,
660 const QString
&localName
,
661 const QString
&qName
,
662 const QXmlAttributes
&)
664 startNamespaceURI
= namespaceURI
;
665 startLocalName
= localName
;
671 virtual bool endElement(const QString
&namespaceURI
,
672 const QString
&localName
,
673 const QString
&qName
)
675 endNamespaceURI
= namespaceURI
;
676 endLocalName
= localName
;
682 QString startLocalName
;
684 QString startNamespaceURI
;
685 QString endLocalName
;
687 QString endNamespaceURI
;
690 QXmlSimpleReader reader
;
692 reader
.setContentHandler(&handler
);
694 QFETCH(QByteArray
, input
);
696 QBuffer
buffer(&input
);
697 QVERIFY(buffer
.open(QIODevice::ReadOnly
));
699 QXmlInputSource
source(&buffer
);
700 QVERIFY(reader
.parse(source
));
702 QFETCH(QString
, expectedQName
);
703 QFETCH(QString
, expectedLocalName
);
704 QFETCH(QString
, expectedNamespace
);
706 QCOMPARE(handler
.startNamespaceURI
, expectedNamespace
);
707 QCOMPARE(handler
.startLocalName
, expectedLocalName
);
708 QCOMPARE(handler
.startQName
, expectedQName
);
710 QCOMPARE(handler
.endNamespaceURI
, expectedNamespace
);
711 QCOMPARE(handler
.endLocalName
, expectedLocalName
);
712 QCOMPARE(handler
.endQName
, expectedQName
);
715 void tst_QXmlSimpleReader::reportNamespace_data() const
717 QTest::addColumn
<QByteArray
>("input");
718 QTest::addColumn
<QString
>("expectedQName");
719 QTest::addColumn
<QString
>("expectedLocalName");
720 QTest::addColumn
<QString
>("expectedNamespace");
722 QTest::newRow("default ns") << QByteArray("<element xmlns='http://example.com/'/>")
723 << QString("element")
724 << QString("element")
725 << QString("http://example.com/");
727 QTest::newRow("with prefix") << QByteArray("<p:element xmlns:p='http://example.com/'/>")
728 << QString("p:element")
729 << QString("element")
730 << QString("http://example.com/");
733 QDomDocument
tst_QXmlSimpleReader::fromByteArray(const QString
&title
, const QByteArray
&ba
)
735 QDomDocument
doc(title
);
736 const bool ret
= doc
.setContent(ba
, true);
741 void tst_QXmlSimpleReader::roundtripWithNamespaces() const
743 QEXPECT_FAIL("", "Known problem, see 154573. The fix happens to break uic.", Abort
);
745 const char *const expected
= "<element b:attr=\"value\" xmlns:a=\"http://www.example.com/A\" xmlns:b=\"http://www.example.com/B\" />\n";
748 const char *const xml
= "<element xmlns:b=\"http://www.example.com/B\" b:attr=\"value\" xmlns:a=\"http://www.example.com/A\"/>";
750 const QDomDocument
one(fromByteArray("document", xml
));
751 const QDomDocument
two(fromByteArray("document2", one
.toByteArray(2)));
753 QCOMPARE(expected
, one
.toByteArray().constData());
754 QCOMPARE(one
.toByteArray(2).constData(), two
.toByteArray(2).constData());
755 QCOMPARE(two
.toByteArray(2).constData(), two
.toByteArray(2).constData());
759 const char *const xml
= "<element b:attr=\"value\" xmlns:b=\"http://www.example.com/B\" xmlns:a=\"http://www.example.com/A\"/>";
761 const QDomDocument
one(fromByteArray("document", xml
));
762 const QDomDocument
two(fromByteArray("document2", one
.toByteArray(2)));
764 QCOMPARE(expected
, one
.toByteArray().constData());
765 QCOMPARE(one
.toByteArray(2).constData(), two
.toByteArray(2).constData());
766 QCOMPARE(two
.toByteArray(2).constData(), two
.toByteArray(2).constData());
770 QTEST_MAIN(tst_QXmlSimpleReader
)
771 #include "tst_qxmlsimplereader.moc"