Permalink
Browse files

Merge branch 'timob-4563' of github.com:billdawson/titanium_mobile in…

…to appcelerator_master

Conflicts:
	drillbit/tests/xml/xml.js
  • Loading branch information...
2 parents d768839 + 8f46fe8 commit 329729bba54453c04176c6c275422d58fdee3783 @marshall marshall committed Jul 18, 2011
Showing with 46 additions and 1 deletion.
  1. +46 −1 drillbit/tests/xml/xml.js
View
47 drillbit/tests/xml/xml.js
@@ -201,6 +201,7 @@ describe("Ti.XML tests", {
matchXmlTrees(a, b);
}
},
+
xmlNodeListElementsByTagName : function() {
var xml = Ti.XML.parseString(this.testSource["nodes.xml"]);
valueOf(xml).shouldNotBeNull();
@@ -220,6 +221,7 @@ describe("Ti.XML tests", {
valueOf(n).shouldNotBeNull();
valueOf(n.getAttribute("id")).shouldBe("node 2");
},
+
xmlNodeListChildren : function() {
var xml = Ti.XML.parseString(this.testSource["nodes.xml"]);
valueOf(xml).shouldNotBeNull();
@@ -238,12 +240,55 @@ describe("Ti.XML tests", {
}
valueOf(count).shouldBe(1);
},
+
xmlNodeListRange : function() {
var xml = Ti.XML.parseString(this.testSource["nodes.xml"]);
valueOf(xml).shouldNotBeNull();
var nodes = xml.getElementsByTagName("node");
valueOf(nodes.item(nodes.length)).shouldBeNull();
valueOf(nodes.item(100)).shouldBeNull();
+ },
+
+ apiXmlAttr: function() {
+ var doc = Ti.XML.parseString(this.testSource["nodes.xml"]);
+ var node = doc.getElementsByTagName("node").item(0);
+ var attr;
+ // First a known attribute
+ valueOf(function(){
+ attr = node.attributes.item(0);
+ }).shouldNotThrowException();
+ valueOf(attr).shouldNotBeUndefined();
+ valueOf(attr).shouldNotBeNull();
+ valueOf(attr).shouldBeObject();
+ valueOf(attr.name).shouldBeString();
+ valueOf(attr.name).shouldBe("id");
+ valueOf(attr.ownerElement).shouldBeObject();
+ valueOf(attr.ownerElement).shouldBe(node); // For some reason this doesn't work on android TIMOB-4703
+ valueOf(attr.specified).shouldBeBoolean();
+ valueOf(attr.specified).shouldBeTrue();
+ valueOf(attr.value).shouldBeString();
+ valueOf(attr.value).shouldBe("node 1");
+ // Now new attribute
+ valueOf(function(){
+ attr = doc.createAttribute("newattr");
+ }).shouldNotThrowException();
+ valueOf(attr).shouldNotBeUndefined();
+ valueOf(attr).shouldNotBeNull();
+ valueOf(attr).shouldBeObject();
+ valueOf(attr.name).shouldBeString();
+ valueOf(attr.name).shouldBe("newattr");
+ valueOf(attr.specified).shouldBeBoolean();
+ var addedAttr = node.setAttributeNode(attr); // NPE for some reason in Android. TIMOB-4704
+ valueOf(addedAttr).shouldNotBeNull();
+ valueOf(addedAttr).shouldBeObject();
+ valueOf(addedAttr).shouldBe(attr);
+ valueOf(attr.ownerElement).shouldNotBeNull();
+ valueOf(attr.ownerElement).shouldBe(node); // For some reason this doesn't work on android TIMOB-4703
+ valueOf(attr.specified).shouldBeFalse();
+ valueOf(attr.value).shouldBeNull();
+ attr.value = "new value";
+ valueOf(attr.value).shouldBe("new value");
+ valueOf(attr.specified).shouldBeTrue();
}
-});
+});

0 comments on commit 329729b

Please sign in to comment.