diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-11-13 00:44:15 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-11-13 00:44:15 (GMT) |
commit | 652e43ddbc4bf32b8c5f634a47a883f7029fd890 (patch) | |
tree | 759bdf8ad013eaa288060febf79c9d8438a770cc /tests/auto | |
parent | 588c7e44bcd724765b620e3b0c64af59d83c8ac5 (diff) | |
download | Qt-652e43ddbc4bf32b8c5f634a47a883f7029fd890.zip Qt-652e43ddbc4bf32b8c5f634a47a883f7029fd890.tar.gz Qt-652e43ddbc4bf32b8c5f634a47a883f7029fd890.tar.bz2 |
XMLHttpRequest tests
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/declarative/xmlhttprequest/data/text.qml | 56 | ||||
-rw-r--r-- | tests/auto/declarative/xmlhttprequest/data/text.xml | 1 | ||||
-rw-r--r-- | tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp | 14 |
3 files changed, 71 insertions, 0 deletions
diff --git a/tests/auto/declarative/xmlhttprequest/data/text.qml b/tests/auto/declarative/xmlhttprequest/data/text.qml new file mode 100644 index 0000000..b64f80b --- /dev/null +++ b/tests/auto/declarative/xmlhttprequest/data/text.qml @@ -0,0 +1,56 @@ +import Qt 4.6 + +Object { + property bool xmlTest: false + property bool dataOK: false + + Script { + function checkText(text, whitespacetext) + { + if (text.wholeText != "Hello world!") + return; + + if (text.isElementContentWhitespace != false) + return; + + if (whitespacetext.wholeText != " ") + return; + + if (whitespacetext.isElementContentWhitespace != true) + return; + + xmlTest = true; + } + + function checkXML(document) + { + checkText(document.documentElement.childNodes[0].childNodes[0], + document.documentElement.childNodes[1].childNodes[0]); + + } + } + + Component.onCompleted: { + var x = new XMLHttpRequest; + + x.open("GET", "text.xml"); + + // Test to the end + x.onreadystatechange = function() { + if (x.readyState == XMLHttpRequest.DONE) { + + dataOK = true; + + if (x.responseXML != null) + checkXML(x.responseXML); + + } + } + + x.send() + } +} + + + + diff --git a/tests/auto/declarative/xmlhttprequest/data/text.xml b/tests/auto/declarative/xmlhttprequest/data/text.xml new file mode 100644 index 0000000..e741688 --- /dev/null +++ b/tests/auto/declarative/xmlhttprequest/data/text.xml @@ -0,0 +1 @@ +<root><item>Hello world!</item><item> </item></root> diff --git a/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp b/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp index 0af7b18..cf1ffd3 100644 --- a/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp +++ b/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp @@ -88,6 +88,7 @@ private slots: void document(); void element(); void attr(); + void text(); // Crashes // void outstanding_request_at_shutdown(); @@ -1017,6 +1018,19 @@ void tst_xmlhttprequest::attr() delete object; } +void tst_xmlhttprequest::text() +{ + QmlComponent component(&engine, TEST_FILE("text.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + TRY_WAIT(object->property("dataOK").toBool() == true); + + QCOMPARE(object->property("xmlTest").toBool(), true); + + delete object; +} + QTEST_MAIN(tst_xmlhttprequest) #include "tst_xmlhttprequest.moc" |