diff options
Diffstat (limited to 'tests/auto/declarative/qdeclarativexmlhttprequest')
3 files changed, 53 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.qml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.qml new file mode 100644 index 0000000..63165ab --- /dev/null +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.qml @@ -0,0 +1,28 @@ +import Qt 4.6 + +QtObject { + property bool dataOK: false + + property string responseText + property string responseXmlRootNodeValue + + Component.onCompleted: { + var x = new XMLHttpRequest; + + x.open("GET", "utf16.xml"); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + + responseText = x.responseText + if (x.responseXML) + responseXmlRootNodeValue = x.responseXML.documentElement.childNodes[0].nodeValue + + dataOK = true; + } + } + x.send() + } +} + diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.xml b/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.xml Binary files differnew file mode 100644 index 0000000..0fbb126 --- /dev/null +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/data/utf16.xml diff --git a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp index 01f07ab..13ed959 100644 --- a/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp +++ b/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp @@ -104,6 +104,7 @@ private slots: void responseXML_invalid(); void invalidMethodUsage(); void redirects(); + void nonUtf8(); // Attributes void document(); @@ -917,6 +918,30 @@ void tst_qdeclarativexmlhttprequest::responseText_data() QTest::newRow("Not Found") << TEST_FILE("status.404.reply") << TEST_FILE("testdocument.html") << ""; } +void tst_qdeclarativexmlhttprequest::nonUtf8() +{ + QDeclarativeComponent component(&engine, TEST_FILE("utf16.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QString uc; + uc.resize(3); + uc[0] = QChar(0x10e3); + uc[1] = QChar(' '); + uc[2] = QChar(0x03a3); + QString xml = "<?xml version=\"1.0\" encoding=\"UTF-16\" standalone='yes'?>\n<root>\n" + uc + "\n</root>\n"; + + TRY_WAIT(object->property("dataOK").toBool() == true); + + QString responseText = object->property("responseText").toString(); + QCOMPARE(responseText, xml); + + QString responseXmlText = object->property("responseXmlRootNodeValue").toString(); + QCOMPARE(responseXmlText, '\n' + uc + '\n'); + + delete object; +} + // Test that calling hte XMLHttpRequest methods on a non-XMLHttpRequest object // throws an exception void tst_qdeclarativexmlhttprequest::invalidMethodUsage() |