[gxml] Fixed GomObject.get_attribute(). Simplified GomProperty



commit 8975803cb5f2e2b5d6b9292eab99df43d861c6d8
Author: Daniel Espinosa <esodan gmail com>
Date:   Tue Jan 31 11:08:15 2017 -0600

    Fixed GomObject.get_attribute(). Simplified GomProperty
    
    Removed from GomProperty unused/unnecesary properties and methods
    
    Removed more warnings and debug messages

 gxml/GomElement.vala           |    2 +
 gxml/GomObject.vala            |  150 ++++++++++++++++++++--------------------
 gxml/GomProperty.vala          |   30 +--------
 gxml/XParser.vala              |   38 ++++-------
 test/DomGDocumentTest.vala     |   44 ++++++++++--
 test/GomDocumentTest.vala      |   24 ++++++-
 test/GomSerializationTest.vala |   23 +++++--
 7 files changed, 167 insertions(+), 144 deletions(-)
---
diff --git a/gxml/GomElement.vala b/gxml/GomElement.vala
index a8fadf7..1572ae9 100644
--- a/gxml/GomElement.vala
+++ b/gxml/GomElement.vala
@@ -473,7 +473,9 @@ public class GXml.GomElement : GomNode,
   }
   public DomNamedNodeMap attributes { owned get { return (DomNamedNodeMap) _attributes; } }
   public string? get_attribute (string name) {
+    message ("Searching attribute: "+name);
     string s = (this as GomObject).get_attribute (name);
+    message ("Found as GomProperty?: "+(s != null).to_string ());
     if (s != null) return s;
     return _attributes.get (name);
   }
diff --git a/gxml/GomObject.vala b/gxml/GomObject.vala
index 62dc379..eb75b03 100644
--- a/gxml/GomObject.vala
+++ b/gxml/GomObject.vala
@@ -41,31 +41,16 @@ public interface GXml.GomObject : GLib.Object,
   public virtual bool use_nick_name () { return true; }
 
   /**
-   * Returns a list with all properties nick with "::" prefix. Nick name,
-   * without "::" will be used on serialization to an attribute's name.
+   * Returns a list with all properties' nick with "::" prefix. Nick name,
+   * with "::" prefix will be used on serialization to an attribute's name.
    */
-  public virtual List<string> get_properties_list () {
-    var l = new List<string> ();
+  public virtual List<ParamSpec> get_properties_list () {
+    var l = new List<ParamSpec> ();
     foreach (ParamSpec spec in this.get_class ().list_properties ()) {
       if ("::" in spec.get_nick ()) {
 #if DEBUG
         GLib.message ("Name: "+spec.name+ " Nick: "+spec.get_nick ());
 #endif
-        l.append (spec.get_nick ().replace ("::",""));
-      }
-    }
-    return l;
-  }
-  /**
-   * Returns a list with all object's {@link GomProperty} property names.
-   */
-  public virtual List<ParamSpec> get_object_properties_list () {
-    var l = new List<ParamSpec> ();
-    foreach (ParamSpec spec in this.get_class ().list_properties ()) {
-      if (spec.value_type.is_a (typeof (GomProperty))) {
-#if DEBUG
-          GLib.message ("GomProperty Name: "+spec.name);
-#endif
         l.append (spec);
       }
     }
@@ -75,19 +60,20 @@ public interface GXml.GomObject : GLib.Object,
    * Returns property's name based on given nick. This function is
    * case insensitive.
    */
-  public virtual string? find_property_name (string nick) {
+  public virtual ParamSpec? find_property_name (string pname) {
     foreach (ParamSpec spec in this.get_class ().list_properties ()) {
-      if (spec.value_type.is_a (typeof (GomProperty))) {
-        return spec.name;
-      } else {
-        if ("::" in spec.get_nick ()) {
-          string name = spec.get_nick ().replace ("::","");
-          if (name.down () == nick.down ()) {
+      string name = spec.get_nick ();
 #if DEBUG
-            GLib.message ("Name: "+spec.name+ " Nick: "+spec.get_nick ());
+          GLib.message ("Name: "+spec.name+ " Nick: "+spec.get_nick ()+" Type: "+spec.value_type.name());
 #endif
-            return spec.name;
-          }
+      if ("::" in name) {
+        name = name.replace ("::","");
+        if (name.down () == pname.down ()) {
+#if DEBUG
+          GLib.message ("Found Property: "+pname);
+          GLib.message ("Is GomProperty? : "+(spec.value_type.is_a (typeof(GomProperty)).to_string ()));
+#endif
+          return spec;
         }
       }
     }
@@ -111,12 +97,63 @@ public interface GXml.GomObject : GLib.Object,
     return l;
   }
   /**
+   * Returns an string representation of an Object's property.
+   */
+  public virtual string? get_property_string (ParamSpec prop) {
+    var v = Value(prop.value_type);
+    get_property (prop.name, ref v);
+    if (prop.value_type.is_a (typeof(GomProperty))) {
+#if DEBUG
+    GLib.message ("Getting GomProperty attribute: "+prop.name);
+#endif
+      GomProperty so = (Object) v as GomProperty;
+      if (so == null) {
+#if DEBUG
+        GLib.message ("GomProperty is Null");
+#endif
+        return null;
+      }
+#if DEBUG
+      if (so.value != null) {
+        message ("GomProperty Value: "+so.value);
+      } else {
+        message ("GomProperty Value Is Null");
+      }
+      return so.value;
+#endif
+    }
+    if (prop.value_type.is_a (typeof (string))) {
+      return (string) v;
+    }
+    if (prop.value_type.is_a (typeof (int))) {
+      return ((int) v).to_string ();
+    }
+    if (prop.value_type.is_a (typeof (uint))) {
+      return ((uint) v).to_string ();
+    }
+    if (prop.value_type.is_a (typeof (double))) {
+      return ((double) v).to_string ();
+    }
+    if (prop.value_type.is_a (typeof (bool))) {
+      return ((bool) v).to_string ();
+    }
+    if (prop.value_type.is_a (Type.ENUM)) {
+      var n = v.get_enum ();
+      try {
+        return Enumeration.get_string (prop.value_type, n, true, true);
+      } catch {
+        GLib.warning (_("Enumeration is out of range"));
+      }
+    }
+    return null;
+  }
+  /**
    * Search for properties in objects, it should be
    * an {@link GLib.Object}'s property. If found a
    * property with given name its value is returned
    * as string representation.
    *
-   * If property is a {@link SerializableProperty}
+   * If property is a {@link GomProperty}
    * returned value is a string representation according
    * with object implementation.
    *
@@ -128,51 +165,14 @@ public interface GXml.GomObject : GLib.Object,
    */
   public virtual string? get_attribute (string name) {
 #if DEBUG
-    GLib.message ("GomObject: attribute: "+name);
+    GLib.message ("Searching GomObject attribute: "+name);
 #endif
-    string pname = find_property_name (name);
-    if (pname == null) return null;
+    var prop = find_property_name (name);
+    if (prop == null) return null;
 #if DEBUG
-    GLib.message ("GomObject: found attribute: "+pname);
+    GLib.message ("Found GomObject attribute: "+prop.name);
 #endif
-    var prop = get_class ().find_property (pname);
-    if (prop != null) {
-#if DEBUG
-      GLib.message ("Found attribute: "+prop.name);
-#endif
-      var v = Value(prop.value_type);
-      get_property (prop.name, ref v);
-      if (prop.value_type == typeof(GomProperty)) {
-        GomProperty so = (Object) v as GomProperty;
-        if (so == null) return null;
-        return so.value;
-      }
-      if (prop.value_type.is_a (typeof (string))) {
-        return (string) v;
-      }
-      if (prop.value_type.is_a (typeof (int))) {
-        return ((int) v).to_string ();
-      }
-      if (prop.value_type.is_a (typeof (uint))) {
-        return ((uint) v).to_string ();
-      }
-      if (prop.value_type.is_a (typeof (double))) {
-        return ((double) v).to_string ();
-      }
-      if (prop.value_type.is_a (typeof (bool))) {
-        return ((bool) v).to_string ();
-      }
-      if (prop.value_type.is_a (Type.ENUM)) {
-        var n = v.get_enum ();
-        try {
-          return Enumeration.get_string (prop.value_type, n, true, true);
-        } catch {
-          GLib.warning (_("Enumeration is out of range"));
-        }
-        return null;
-      }
-    }
-    return null;
+    return get_property_string (prop);
   }
   /**
    * Search for a {@link GLib.Object} property with
@@ -187,15 +187,13 @@ public interface GXml.GomObject : GLib.Object,
 #if DEBUG
     GLib.message ("GomObject: searching attribute to set: "+name);
 #endif
-    string pname = find_property_name (name);
-    if (pname == null) return false;
+    var prop = find_property_name (name);
 #if DEBUG
     GLib.message ("GomObject: setting attribute: "+name);
 #endif
-    var prop = get_class ().find_property (pname);
     if (prop != null) {
       var v = Value (prop.value_type);
-      if (prop.value_type == typeof(GomProperty)) {
+      if (prop.value_type.is_a (typeof(GomProperty))) {
         get_property (prop.name, ref v);
         GomProperty so = (Object) v as GomProperty;
         if (so == null) return false;
diff --git a/gxml/GomProperty.vala b/gxml/GomProperty.vala
index e085eb3..747d90f 100644
--- a/gxml/GomProperty.vala
+++ b/gxml/GomProperty.vala
@@ -29,16 +29,6 @@
 public interface GXml.GomProperty : Object
 {
   /**
-   * Attribute's name in the parent {@link DomElement}.
-   */
-  public abstract string attribute_name { get; construct set; }
-  /**
-   * Validation rule.
-   *
-   * Is a regular expression, used to validate if values are valid.
-   */
-  public abstract string validation_rule { get; construct set; }
-  /**
    * Attribute's value in the parent {@link DomElement} using a string.
    *
    * Implementation should take care to validate value before to set or
@@ -46,7 +36,7 @@ public interface GXml.GomProperty : Object
    */
   public abstract string? value { owned get; set; }
   /**
-   * Takes a string and check if it can be validated using
+   * Takes a string and check if it is a valid value for property
    */
   public abstract bool validate_value (string val);
 }
@@ -55,22 +45,6 @@ public interface GXml.GomProperty : Object
  * Base class for properties implementing {@link GomProperty} interface.
  */
 public abstract class GXml.GomBaseProperty : Object, GXml.GomProperty {
-  protected string _attribute_name;
-  protected string _validation_rule = "";
-  /**
-   * {@inheritDoc}
-   */
-  public string attribute_name {
-    get { return _attribute_name; }
-    construct set { _attribute_name = value;}
-  }
-  /**
-   * {@inheritDoc}
-   */
-  public string validation_rule {
-    get { return _validation_rule; }
-    construct set { _validation_rule = value; } // TODO: Validate RegEx
-  }
   /**
    * {@inheritDoc}
    */
@@ -79,7 +53,7 @@ public abstract class GXml.GomBaseProperty : Object, GXml.GomProperty {
    * Takes a string and check if it can be validated using
    * {@link validation_rule}.
    */
-  public bool validate_value (string val) { return true; } // FIXME: Validate value
+  public virtual bool validate_value (string val) { return true; }
 }
 
 /**
diff --git a/gxml/XParser.vala b/gxml/XParser.vala
index 2cca983..1dca454 100644
--- a/gxml/XParser.vala
+++ b/gxml/XParser.vala
@@ -619,32 +619,20 @@ public class GXml.XParser : Object, GXml.Parser {
 
     // GomObject serialization
     var lp = (node as GomObject).get_properties_list ();
-    foreach (string pk in lp) {
-      string v = (node as GomObject).get_attribute (pk);
-      if (v == null) continue;
-      size += tw.write_attribute (pk, v);
-      size += tw.end_attribute ();
-      if (size > 1500)
-        tw.flush ();
-    }
-    // GomProperty serialization
-    var lps = (node as GomObject).get_object_properties_list ();
-    foreach (ParamSpec pspec in lps) {
-      Value v = Value (pspec.value_type);
-      node.get_property (pspec.name, ref v);
-      GomProperty gp = v.get_object () as GomProperty;
-      if (gp == null) continue;
-      if (gp.value == null) continue;
-      string attname = gp.attribute_name;
-      if (attname == null) {
-        if ("::" in pspec.get_nick ()) {
-          attname = pspec.get_nick ().replace ("::","");
-        } else {
-          warning (_("Invalid attribute name for Property: %s").printf (pspec.value_type.name ()));
-          attname = pspec.get_nick ();
-        }
+    foreach (ParamSpec pspec in lp) {
+      string attname = pspec.get_nick ().replace ("::","");
+      string val = null;
+      if (pspec.value_type.is_a (typeof (GomProperty))) {
+        Value v = Value (pspec.value_type);
+        node.get_property (pspec.name, ref v);
+        GomProperty gp = v.get_object () as GomProperty;
+        if (gp == null) continue;
+        val = gp.value;
+      } else {
+        val = (node as GomObject).get_property_string (pspec);
       }
-      size += tw.write_attribute (attname, gp.value);
+      if (val == null) continue;
+      size += tw.write_attribute (attname, val);
       size += tw.end_attribute ();
       if (size > 1500)
         tw.flush ();
diff --git a/test/DomGDocumentTest.vala b/test/DomGDocumentTest.vala
index c1e42a3..55f6e0d 100644
--- a/test/DomGDocumentTest.vala
+++ b/test/DomGDocumentTest.vala
@@ -147,7 +147,9 @@ const string XMLDOC ="<?xml version=\"1.0\"?>
                                assert (le[0].get_attribute ("class") == "black");
                                assert (le[1].get_attribute ("id") == "p01");
                                var lc = doc.document_element.get_elements_by_class_name ("black");
+#if DEBUG
                                GLib.message("size"+lc.size.to_string ());
+#endif
                                assert (lc.size == 2);
                                assert (lc[0].node_name == "p");
                                assert ("black" in lc[0].get_attribute ("class"));
@@ -164,7 +166,9 @@ const string XMLDOC ="<?xml version=\"1.0\"?>
                });
                Test.add_func ("/gxml/dom/node", () => {
                        try {
-                       Test.message ("Doc: "+HTMLDOC);
+#if DEBUG
+                       GLib.message ("Doc: "+HTMLDOC);
+#endif
                        var doc = new GDocument.from_string (HTMLDOC) as DomDocument;
                        assert (doc is DomDocument);
                        assert (doc.document_element.children.size == 1);
@@ -312,7 +316,9 @@ const string XMLDOC ="<?xml version=\"1.0\"?>
                        var lns = doc.document_element.get_elements_by_tag_name_ns 
("http://live.gnome.org/GXml";, "OtherNode");
                        assert (lns != null);
                        assert (lns is DomHTMLCollection);
+#if DEBUG
                        GLib.message ("Node with default ns: "+lns.length.to_string ());
+#endif
                        assert (lns.length == 1);
                        assert (lns.item (0) is DomElement);
                        assert (lns.item (0).node_name == "OtherNode");
@@ -331,7 +337,9 @@ const string XMLDOC ="<?xml version=\"1.0\"?>
                });
                Test.add_func ("/gxml/dom/element/api", () => {
                        try {
+#if DEBUG
                        GLib.message ("Doc: "+HTMLDOC);
+#endif
                        var doc = new GDocument.from_string (HTMLDOC) as DomDocument;
                        assert (doc is DomDocument);
                        assert (doc.document_element.children.size == 1);
@@ -368,9 +376,13 @@ const string XMLDOC ="<?xml version=\"1.0\"?>
                        var n2 = doc.create_element ("p");
                        doc.document_element.append_child (n2);
                        assert (doc.document_element.children.length == 3);
+#if DEBUG
                        GLib.message ("DOC:"+(doc.document_element as GXml.Node).to_string ());
+#endif
                        assert (n2.attributes.length == 0);
+#if DEBUG
                        GLib.message ("Setting nice NS");
+#endif
                        n2.set_attribute_ns ("http://devel.org/","dev:nice","good";);
                        assert (n2.attributes.length == 1);
                        assert (n2.has_attribute_ns ("http://devel.org/","nice";));
@@ -412,7 +424,9 @@ const string XMLDOC ="<?xml version=\"1.0\"?>
                                assert (lens.length == 1);
                                assert (lens.item (0) is DomElement);
                                assert (lens.item (0).node_name == "MyNode");
+#if DEBUG
                                GLib.message ("DOC: "+(doc.document_element as GXml.Node).to_string ());
+#endif
                                var lec = doc.get_elements_by_class_name ("node");
                                assert (lec.length == 4);
                                assert (lec.item (0) is DomElement);
@@ -460,11 +474,15 @@ const string XMLDOC ="<?xml version=\"1.0\"?>
                });
                Test.add_func ("/gxml/dom/document/import", () => {
                        try {
-                               Test.message ("Doc: "+XMLDOC);
+#if DEBUG
+                               GLib.message ("Doc: "+XMLDOC);
+#endif
                                var doc = new GDocument.from_string (XMLDOC) as DomDocument;
                                var doc2 = new GDocument.from_string (STRDOC) as DomDocument;
                                doc.import_node (doc2.document_element, false);
+#if DEBUG
                                GLib.message ("DOC: "+(doc.document_element as GXml.Node).to_string ());
+#endif
                                assert (doc.document_element.last_child is DomElement);
                                assert (doc.document_element.last_child.node_name == "Sentences");
                                assert (doc.document_element.last_child.child_nodes.length == 0);
@@ -476,12 +494,16 @@ const string XMLDOC ="<?xml version=\"1.0\"?>
                });
                Test.add_func ("/gxml/dom/document/adopt", () => {
                        try {
-                               Test.message ("Doc: "+XMLDOC);
+#if DEBUG
+                               GLib.message ("Doc: "+XMLDOC);
+#endif
                                var doc = new GDocument.from_string (XMLDOC) as DomDocument;
                                var doc2 = new GDocument.from_string (STRDOC) as DomDocument;
                                doc2.adopt_node (doc.document_element.children.last ());
+#if DEBUG
                                GLib.message ("DOC: "+(doc.document_element as GXml.Node).to_string ());
                                GLib.message ("DOC: "+(doc2.document_element as GXml.Node).to_string ());
+#endif
                                assert (doc.document_element.children.last ().node_name == "project");
                                assert (doc2.document_element.last_child is DomElement);
                                assert (doc2.document_element.last_child.node_name == "Author");
@@ -493,7 +515,9 @@ const string XMLDOC ="<?xml version=\"1.0\"?>
                });
                Test.add_func ("/gxml/dom/document/event", () => {
                        try {
-                               Test.message ("No implemented...Skiping");
+#if DEBUG
+                               GLib.message ("No implemented...Skiping");
+#endif
                                //TODO: implement
                        } catch (GLib.Error e) {
                                GLib.message ("Error: "+ e.message);
@@ -502,7 +526,9 @@ const string XMLDOC ="<?xml version=\"1.0\"?>
                });
                Test.add_func ("/gxml/dom/document/range", () => {
                        try {
-                               Test.message ("No implemented...Skiping");
+#if DEBUG
+                               GLib.message ("No implemented...Skiping");
+#endif
                                //TODO: implement
                        } catch (GLib.Error e) {
                                GLib.message ("Error: "+ e.message);
@@ -511,7 +537,9 @@ const string XMLDOC ="<?xml version=\"1.0\"?>
                });
                Test.add_func ("/gxml/dom/document/iterator", () => {
                        try {
-                               Test.message ("No implemented...Skiping");
+#if DEBUG
+                               GLib.message ("No implemented...Skiping");
+#endif
                                //TODO: implement
                        } catch (GLib.Error e) {
                                GLib.message ("Error: "+ e.message);
@@ -520,7 +548,9 @@ const string XMLDOC ="<?xml version=\"1.0\"?>
                });
                Test.add_func ("/gxml/dom/document/walker", () => {
                        try {
-                               Test.message ("No implemented...Skiping");
+#if DEBUG
+                               GLib.message ("No implemented...Skiping");
+#endif
                                //TODO: implement
                        } catch (GLib.Error e) {
                                GLib.message ("Error: "+ e.message);
diff --git a/test/GomDocumentTest.vala b/test/GomDocumentTest.vala
index 64b429a..b83a2ba 100644
--- a/test/GomDocumentTest.vala
+++ b/test/GomDocumentTest.vala
@@ -162,7 +162,9 @@ class GomDocumentTest : GXmlTest {
                                assert (d.document_element != null);
                                var parser = new XParser (d);
                                string s = parser.write_string ();
+#if DEBUG
                                GLib.message ("File read: "+s);
+#endif
                                assert ("<name xml:lang=\"en\">GXml</name>" in s);
                                assert ("<shortdesc xml:lang=\"en\">GObject XML and Serialization 
API</shortdesc>"
                                                                in s);
@@ -329,8 +331,10 @@ class GomDocumentTest : GXmlTest {
                                assert (instruction is DomProcessingInstruction);
                                assert (instruction.node_name == "target");
                                assert (instruction.node_value == "data");
+#if DEBUG
                                GLib.message ("Target:"+instruction.node_name);
                                GLib.message ("Dat:"+instruction.node_value);
+#endif
                                assert (instruction.data == "data");
                                assert (instruction.target != null);
                                assert (instruction.target == "target");
@@ -345,7 +349,9 @@ class GomDocumentTest : GXmlTest {
                                var parser = new XParser (doc);
                                //Test.message ("DOC:"+parser.write_string ());
                                var attr = ((DomElement) doc.document_element).get_attribute ("attrname");
-                               Test.message ("Attr value: "+attr);
+#if DEBUG
+                               GLib.message ("Attr value: "+attr);
+#endif
                                assert (attr != null);
                                assert (attr == "attrvalue");
                                //
@@ -360,9 +366,13 @@ class GomDocumentTest : GXmlTest {
                                var parser = new XParser (doc);
                                string s1 = parser.write_string ();
                                assert (s1 != null);
+#if DEBUG
                                GLib.message ("Document Read:"+s1);
+#endif
                                string[] cs1 = s1.split ("\n");
-                               Test.message (s1);
+#if DEBUG
+                               GLib.message (s1);
+#endif
                                assert (cs1[0] == "<?xml version=\"1.0\"?>");
                                assert (cs1[1] == "<Sentences><Sentence lang=\"en\">I like the colour 
blue.</Sentence><Sentence lang=\"de\">Ich liebe die 
T&#xFC;r.</Sentence><Authors><Author><Name>Fred</Name><Email>fweasley hogwarts co 
uk</Email></Author><Author><Name>George</Name><Email>gweasley hogwarts co 
uk</Email></Author></Authors></Sentences>");
                        } catch { assert_not_reached (); }
@@ -371,10 +381,14 @@ class GomDocumentTest : GXmlTest {
                        try {
                                var d = new GomDocument.from_path 
(GXmlTestConfig.TEST_DIR+"/gdocument-read.xml");
                                var parser = new XParser (d);
+#if DEBUG
                                GLib.message ("Document Read:"+parser.write_string ());
+#endif
                                assert (d.document_element != null);
                                assert (d.document_element.node_name == "DataTypeTemplates");
-                               Test.message (d.document_element.child_nodes.size.to_string ());
+#if DEBUG
+                               GLib.message (d.document_element.child_nodes.size.to_string ());
+#endif
                                assert (d.document_element.child_nodes[0] is GXml.DomText);
                                assert (d.document_element.child_nodes[1] is GXml.DomElement);
                                assert (d.document_element.child_nodes[2] is GXml.DomText);
@@ -412,7 +426,9 @@ class GomDocumentTest : GXmlTest {
                                assert (p != null);
                                assert (p == "val");
                                assert (doc.document_element.lookup_namespace_uri (null) != null);
+#if DEBUG
                                GLib.message ("NS default: "+doc.document_element.lookup_namespace_uri 
(null));
+#endif
                                assert (c.prefix == null);
                                assert (c.namespace_uri == null);
                                assert (c.lookup_namespace_uri (null) == "http://www.gnome.org/GXml";);
@@ -445,7 +461,9 @@ class GomDocumentTest : GXmlTest {
                                assert (doc.document_element.prefix == null);
                                var parser = new XParser (doc);
                                string str = parser.write_string ();
+#if DEBUG
                                message ("Read: "+str);
+#endif
                        } catch (GLib.Error e) {
                                GLib.message ("ERROR: "+ e.message);
                                assert_not_reached ();
diff --git a/test/GomSerializationTest.vala b/test/GomSerializationTest.vala
index dd1467d..a29f019 100644
--- a/test/GomSerializationTest.vala
+++ b/test/GomSerializationTest.vala
@@ -366,9 +366,9 @@ class GomSerializationTest : GXmlTest  {
       var t = new Taxes ();
       string s = t.to_string ();
       assert (s != null);
-#if DEBUG
+//#if DEBUG
       GLib.message ("DOC:"+s);
-#endif
+//#endif
       assert ("<Taxes " in s);
       assert ("monthRate=\"0\"" in s);
       assert ("Month=\"january\"" in s);
@@ -529,12 +529,23 @@ class GomSerializationTest : GXmlTest  {
 #endif
       assert ("<Motor On=\"false\" Torque=\"0.0000\"/>" in s);
       m.speed = new Motor.Speed ();
+      m.speed.set_double (1.0);
       s = m.to_string ();
       assert (s != null);
 #if DEBUG
       GLib.message ("DOC:"+s);
 #endif
-      assert ("<Motor On=\"false\" Torque=\"0.0000\" Speed=\"0.0000\"/>" in s);
+      assert ("<Motor On=\"false\" Torque=\"0.0000\" Speed=\"1.0000\"/>" in s);
+      assert (m.speed != null);
+      assert (m is GomObject);
+      assert (m.speed is GomProperty);
+      assert (m.speed.get_double () == 1.0);
+      assert (m.speed.value != null);
+      assert (m.speed.value == "1.0000");
+#if DEBUG
+      message ("Searching Element's attribute node: speed");
+#endif
+      assert (m.get_attribute ("speed") != null);
       assert (m.tension_type == null);
       m.tension_type = new Motor.TensionType ();
       s = m.to_string ();
@@ -542,14 +553,16 @@ class GomSerializationTest : GXmlTest  {
 #if DEBUG
       GLib.message ("DOC:"+s);
 #endif
-      assert ("<Motor On=\"false\" Torque=\"0.0000\" Speed=\"0.0000\" TensionType=\"ac\"/>" in s);
+      assert ("<Motor On=\"false\" Torque=\"0.0000\" Speed=\"1.0000\" TensionType=\"ac\"/>" in s);
+      assert (m.tension_type != null);
+      assert (m.tension_type.value == "ac");
       m.tension = new Motor.Tension ();
       s = m.to_string ();
       assert (s != null);
 #if DEBUG
       GLib.message ("DOC:"+s);
 #endif
-      assert ("<Motor On=\"false\" Torque=\"0.0000\" Speed=\"0.0000\" TensionType=\"ac\" Tension=\"0\"/>" in 
s);
+      assert ("<Motor On=\"false\" Torque=\"0.0000\" Speed=\"1.0000\" TensionType=\"ac\" Tension=\"0\"/>" in 
s);
       m.is_on.set_boolean (true);
       m.torque.set_double (3.1416);
       m.speed.set_float ((float) 3600.1011);


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