tests/auto/declarative/qdeclarativexmlhttprequest/data/attr.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 checkAttr(documentElement, attr)
       
     8     {
       
     9         if (attr == null)
       
    10             return;
       
    11 
       
    12         if (attr.name != "attr")
       
    13             return;
       
    14 
       
    15         if (attr.value != "myvalue")
       
    16             return;
       
    17 
       
    18         if (attr.ownerElement.tagName != documentElement.tagName)
       
    19             return;
       
    20 
       
    21         if (attr.nodeName != "attr")
       
    22             return;
       
    23 
       
    24         if (attr.nodeValue != "myvalue")
       
    25             return;
       
    26 
       
    27         if (attr.nodeType != 2)
       
    28             return;
       
    29 
       
    30         if (attr.childNodes.length != 0)
       
    31             return;
       
    32 
       
    33         if (attr.firstChild != null)
       
    34             return;
       
    35 
       
    36         if (attr.lastChild != null)
       
    37             return;
       
    38 
       
    39         if (attr.previousSibling != null)
       
    40             return;
       
    41 
       
    42         if (attr.nextSibling != null)
       
    43             return;
       
    44 
       
    45         if (attr.attributes != null)
       
    46             return;
       
    47 
       
    48         xmlTest = true;
       
    49     }
       
    50 
       
    51     function checkXML(document)
       
    52     {
       
    53         checkAttr(document.documentElement, document.documentElement.attributes[0]);
       
    54     }
       
    55 
       
    56     Component.onCompleted: {
       
    57         var x = new XMLHttpRequest;
       
    58 
       
    59         x.open("GET", "attr.xml");
       
    60 
       
    61         // Test to the end
       
    62         x.onreadystatechange = function() {
       
    63             if (x.readyState == XMLHttpRequest.DONE) {
       
    64 
       
    65                 dataOK = true;
       
    66 
       
    67                 if (x.responseXML != null)
       
    68                     checkXML(x.responseXML);
       
    69 
       
    70             }
       
    71         }
       
    72 
       
    73         x.send()
       
    74     }
       
    75 }
       
    76 
       
    77 
       
    78