tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 02 Sep 2010 21:20:32 +0300
changeset 34 a33bf25e6f72
parent 30 5dc02b23752f
permissions -rw-r--r--
Revision: 201033 Kit: 201035

import Qt 4.7

QtObject {
    property bool xmlTest: false
    property bool dataOK: false

    function checkText(text, whitespacetext)
    {
        if (text == null)
            return;

        if (text.nodeName != "#text")
            return;

        if (text.nodeValue != "Hello world!")
            return;

        if (text.nodeType != 3)
            return;

        if (text.parentNode.nodeName != "item")
            return;

        if (text.childNodes.length != 0)
            return;

        if (text.firstChild != null)
            return;

        if (text.lastChild != null)
            return;

        if (text.previousSibling != null)
            return;

        if (text.nextSibling != null)
            return;

        if (text.attributes != null)
            return;

        if (text.wholeText != "Hello world!")
            return;

        if (text.data != "Hello world!")
            return;

        if (text.length != 12)
            return;

        if (text.isElementContentWhitespace != false)
            return;

        if (whitespacetext.nodeName != "#text")
            return;

        if (whitespacetext.nodeValue != "   ")
            return;

        if (whitespacetext.nodeType != 3)
            return;

        if (whitespacetext.parentNode.nodeName != "item")
            return;

        if (whitespacetext.childNodes.length != 0)
            return;

        if (whitespacetext.firstChild != null)
            return;

        if (whitespacetext.lastChild != null)
            return;

        if (whitespacetext.previousSibling != null)
            return;

        if (whitespacetext.nextSibling != null)
            return;

        if (whitespacetext.attributes != null)
            return;

        if (whitespacetext.wholeText != "   ")
            return;

        if (whitespacetext.data != "   ")
            return;

        if (whitespacetext.length != 3)
            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()
    }
}