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