summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2010-03-05 06:08:26 (GMT)
committerBea Lam <bea.lam@nokia.com>2010-03-05 06:08:26 (GMT)
commit769a11719ca85e9cdac4c0f1d0fcffe6145d6972 (patch)
tree8cf89cdceff0e832ff2cdf9f7ee96ea230403125 /tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp
parent48fd47f64f3f73e82016161d82cdf67908a9c653 (diff)
downloadQt-769a11719ca85e9cdac4c0f1d0fcffe6145d6972.zip
Qt-769a11719ca85e9cdac4c0f1d0fcffe6145d6972.tar.gz
Qt-769a11719ca85e9cdac4c0f1d0fcffe6145d6972.tar.bz2
Don't assume documents are in UTF-8.
Task-number: QTBUG-7719
Diffstat (limited to 'tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp')
-rw-r--r--tests/auto/declarative/qdeclarativexmlhttprequest/tst_qdeclarativexmlhttprequest.cpp25
1 files changed, 25 insertions, 0 deletions
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()