tests/auto/declarative/qdeclarativexmlhttprequest/data/text.qml
branchGCC_SURGE
changeset 31 5daf16870df6
parent 30 5dc02b23752f
equal deleted inserted replaced
27:93b982ccede2 31:5daf16870df6
       
     1 import Qt 4.7
       
     2 
       
     3 QtObject {
       
     4     property bool xmlTest: false
       
     5     property bool dataOK: false
       
     6 
       
     7     function checkText(text, whitespacetext)
       
     8     {
       
     9         if (text == null)
       
    10             return;
       
    11 
       
    12         if (text.nodeName != "#text")
       
    13             return;
       
    14 
       
    15         if (text.nodeValue != "Hello world!")
       
    16             return;
       
    17 
       
    18         if (text.nodeType != 3)
       
    19             return;
       
    20 
       
    21         if (text.parentNode.nodeName != "item")
       
    22             return;
       
    23 
       
    24         if (text.childNodes.length != 0)
       
    25             return;
       
    26 
       
    27         if (text.firstChild != null)
       
    28             return;
       
    29 
       
    30         if (text.lastChild != null)
       
    31             return;
       
    32 
       
    33         if (text.previousSibling != null)
       
    34             return;
       
    35 
       
    36         if (text.nextSibling != null)
       
    37             return;
       
    38 
       
    39         if (text.attributes != null)
       
    40             return;
       
    41 
       
    42         if (text.wholeText != "Hello world!")
       
    43             return;
       
    44 
       
    45         if (text.data != "Hello world!")
       
    46             return;
       
    47 
       
    48         if (text.length != 12)
       
    49             return;
       
    50 
       
    51         if (text.isElementContentWhitespace != false)
       
    52             return;
       
    53 
       
    54         if (whitespacetext.nodeName != "#text")
       
    55             return;
       
    56 
       
    57         if (whitespacetext.nodeValue != "   ")
       
    58             return;
       
    59 
       
    60         if (whitespacetext.nodeType != 3)
       
    61             return;
       
    62 
       
    63         if (whitespacetext.parentNode.nodeName != "item")
       
    64             return;
       
    65 
       
    66         if (whitespacetext.childNodes.length != 0)
       
    67             return;
       
    68 
       
    69         if (whitespacetext.firstChild != null)
       
    70             return;
       
    71 
       
    72         if (whitespacetext.lastChild != null)
       
    73             return;
       
    74 
       
    75         if (whitespacetext.previousSibling != null)
       
    76             return;
       
    77 
       
    78         if (whitespacetext.nextSibling != null)
       
    79             return;
       
    80 
       
    81         if (whitespacetext.attributes != null)
       
    82             return;
       
    83 
       
    84         if (whitespacetext.wholeText != "   ")
       
    85             return;
       
    86 
       
    87         if (whitespacetext.data != "   ")
       
    88             return;
       
    89 
       
    90         if (whitespacetext.length != 3)
       
    91             return;
       
    92 
       
    93         if (whitespacetext.isElementContentWhitespace != true)
       
    94             return;
       
    95 
       
    96         xmlTest = true;
       
    97     }
       
    98 
       
    99     function checkXML(document)
       
   100     {
       
   101         checkText(document.documentElement.childNodes[0].childNodes[0],
       
   102                   document.documentElement.childNodes[1].childNodes[0]);
       
   103 
       
   104     }
       
   105 
       
   106     Component.onCompleted: {
       
   107         var x = new XMLHttpRequest;
       
   108 
       
   109         x.open("GET", "text.xml");
       
   110 
       
   111         // Test to the end
       
   112         x.onreadystatechange = function() {
       
   113             if (x.readyState == XMLHttpRequest.DONE) {
       
   114 
       
   115                 dataOK = true;
       
   116 
       
   117                 if (x.responseXML != null)
       
   118                     checkXML(x.responseXML);
       
   119 
       
   120             }
       
   121         }
       
   122 
       
   123         x.send()
       
   124     }
       
   125 }
       
   126 
       
   127 
       
   128 
       
   129