[gxml] * test dirtying of an element and its syncing of attributes



commit 075fc25f8b960ac78749cc0d6f69191d814b465f
Author: Richard Schwarting <aquarichy gmail com>
Date:   Tue Sep 20 16:20:49 2011 -0400

    * test dirtying of an element and its syncing of attributes

 test/ElementTest.vala |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)
---
diff --git a/test/ElementTest.vala b/test/ElementTest.vala
index f9516ec..49555ef 100644
--- a/test/ElementTest.vala
+++ b/test/ElementTest.vala
@@ -94,7 +94,7 @@ class ElementTest : GXmlTest  {
 				} catch (GXml.Dom.DomError e) {
 					GLib.warning ("%s", e.message);
 					assert (false);
-				}				
+				}
 			});
 		Test.add_func ("/gxml/element/local_name", () => {
 				try {
@@ -169,6 +169,25 @@ class ElementTest : GXmlTest  {
 					assert (false);
 				}
 			});
+		/* by accessing .attributes, the element is marked as
+		 * dirty, because it can't be sure whether we're
+		 * changing attributes independently in the obtained
+		 * HashTable, and the document will have to re-sync
+		 * before stringifying (or saving)*/
+		Test.add_func ("/gxml/element/syncing_of_dirty_elements", () => {
+				try {
+					Document doc = new Document.from_string ("<?xml version='1.0' encoding='UTF-8'?><entry><link rel='http://schemas.google.com/contacts/2008/rel#photo'/></entry>");
+					XNode root = doc.document_element;
+					foreach (XNode child in root.child_nodes) {
+						HashTable<string,GXml.Dom.Attr> attrs = child.attributes;
+					}
+
+					string str = doc.to_string ();
+				} catch (GXml.Dom.DomError e) {
+					GLib.warning ("%s", e.message);
+					assert (false);
+				}
+			});
 		Test.add_func ("/gxml/element/get_set_attribute", () => {
 				try {
 					Element elem = get_elem_new_doc ("student");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]