equal
deleted
inserted
replaced
55 //TESTED_CLASS=QXmlStreamReader QXmlStreamWriter |
55 //TESTED_CLASS=QXmlStreamReader QXmlStreamWriter |
56 //TESTED_FILES=corelib/xml/stream/qxmlutils.cpp corelib/xml/stream/qxmlstream.cpp corelib/xml/stream/qxmlstream_p.h |
56 //TESTED_FILES=corelib/xml/stream/qxmlutils.cpp corelib/xml/stream/qxmlstream.cpp corelib/xml/stream/qxmlstream_p.h |
57 |
57 |
58 Q_DECLARE_METATYPE(QXmlStreamReader::ReadElementTextBehaviour) |
58 Q_DECLARE_METATYPE(QXmlStreamReader::ReadElementTextBehaviour) |
59 |
59 |
60 static const char *const catalogFile = "XML-Test-Suite/xmlconf/finalCatalog.xml"; |
60 static const char *const catalogFile = SRCDIR "XML-Test-Suite/xmlconf/finalCatalog.xml"; |
61 static const int expectedRunCount = 1646; |
61 static const int expectedRunCount = 1646; |
62 static const int expectedSkipCount = 532; |
62 static const int expectedSkipCount = 532; |
63 |
63 |
64 static inline int best(int a, int b) |
64 static inline int best(int a, int b) |
65 { |
65 { |
525 |
525 |
526 class tst_QXmlStream: public QObject |
526 class tst_QXmlStream: public QObject |
527 { |
527 { |
528 Q_OBJECT |
528 Q_OBJECT |
529 public: |
529 public: |
530 tst_QXmlStream() : m_handler(QUrl::fromLocalFile(QDir::currentPath() + QLatin1Char('/')) |
530 tst_QXmlStream() : m_handler(QUrl::fromLocalFile(QLatin1String(catalogFile))) |
531 .resolved(QUrl(QLatin1String(catalogFile)))) |
|
532 { |
531 { |
533 } |
532 } |
534 |
533 |
535 private slots: |
534 private slots: |
536 void initTestCase(); |
535 void initTestCase(); |
544 void reportSuccess_data() const; |
543 void reportSuccess_data() const; |
545 void parseXSLTTestSuite() const; |
544 void parseXSLTTestSuite() const; |
546 void writerHangs() const; |
545 void writerHangs() const; |
547 void writerAutoFormattingWithComments() const; |
546 void writerAutoFormattingWithComments() const; |
548 void writerAutoFormattingWithTabs() const; |
547 void writerAutoFormattingWithTabs() const; |
|
548 void writerAutoFormattingWithProcessingInstructions() const; |
549 void writerAutoEmptyTags() const; |
549 void writerAutoEmptyTags() const; |
550 void writeAttributesWithSpace() const; |
550 void writeAttributesWithSpace() const; |
551 void addExtraNamespaceDeclarations(); |
551 void addExtraNamespaceDeclarations(); |
552 void setEntityResolver(); |
552 void setEntityResolver(); |
553 void readFromQBuffer() const; |
553 void readFromQBuffer() const; |
803 void tst_QXmlStream::testReader_data() const |
803 void tst_QXmlStream::testReader_data() const |
804 { |
804 { |
805 QTest::addColumn<QString>("xml"); |
805 QTest::addColumn<QString>("xml"); |
806 QTest::addColumn<QString>("ref"); |
806 QTest::addColumn<QString>("ref"); |
807 QDir dir; |
807 QDir dir; |
808 dir.cd("data/"); |
808 dir.cd(SRCDIR "data/"); |
809 foreach(QString filename , dir.entryList(QStringList() << "*.xml")) { |
809 foreach(QString filename , dir.entryList(QStringList() << "*.xml")) { |
810 QString reference = QFileInfo(filename).baseName() + ".ref"; |
810 QString reference = QFileInfo(filename).baseName() + ".ref"; |
811 QTest::newRow(dir.filePath(filename).toLatin1().data()) << dir.filePath(filename) << dir.filePath(reference); |
811 QTest::newRow(dir.filePath(filename).toLatin1().data()) << dir.filePath(filename) << dir.filePath(reference); |
812 } |
812 } |
813 } |
813 } |
1028 writer.writeEndDocument(); |
1028 writer.writeEndDocument(); |
1029 const char *str = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<A>\n\t<B/>\n</A>\n"; |
1029 const char *str = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<A>\n\t<B/>\n</A>\n"; |
1030 QCOMPARE(buffer.buffer().data(), str); |
1030 QCOMPARE(buffer.buffer().data(), str); |
1031 } |
1031 } |
1032 |
1032 |
|
1033 void tst_QXmlStream::writerAutoFormattingWithProcessingInstructions() const |
|
1034 { |
|
1035 QBuffer buffer; |
|
1036 buffer.open(QIODevice::WriteOnly); |
|
1037 |
|
1038 QXmlStreamWriter writer(&buffer); |
|
1039 writer.setAutoFormatting(true); |
|
1040 writer.writeStartDocument(); |
|
1041 writer.writeProcessingInstruction("B", "C"); |
|
1042 writer.writeStartElement("A"); |
|
1043 writer.writeEndElement(); |
|
1044 writer.writeEndDocument(); |
|
1045 const char *str = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<?B C?>\n<A/>\n"; |
|
1046 QCOMPARE(buffer.buffer().data(), str); |
|
1047 } |
|
1048 |
1033 /*! |
1049 /*! |
1034 Task 204822 |
1050 Task 204822 |
1035 */ |
1051 */ |
1036 void tst_QXmlStream::writeAttributesWithSpace() const |
1052 void tst_QXmlStream::writeAttributesWithSpace() const |
1037 { |
1053 { |
1182 void tst_QXmlStream::crashInUTF16Codec() const |
1198 void tst_QXmlStream::crashInUTF16Codec() const |
1183 { |
1199 { |
1184 QEventLoop eventLoop; |
1200 QEventLoop eventLoop; |
1185 |
1201 |
1186 QNetworkAccessManager networkManager; |
1202 QNetworkAccessManager networkManager; |
1187 QNetworkRequest request(QUrl::fromLocalFile(QLatin1String("data/051reduced.xml"))); |
1203 QNetworkRequest request(QUrl::fromLocalFile(QLatin1String(SRCDIR "data/051reduced.xml"))); |
1188 QNetworkReply *const reply = networkManager.get(request); |
1204 QNetworkReply *const reply = networkManager.get(request); |
1189 eventLoop.connect(reply, SIGNAL(finished()), SLOT(quit())); |
1205 eventLoop.connect(reply, SIGNAL(finished()), SLOT(quit())); |
1190 |
1206 |
1191 QCOMPARE(eventLoop.exec(), 0); |
1207 QCOMPARE(eventLoop.exec(), 0); |
1192 |
1208 |