[gxml] Ported SerializableObjectModel to GXml.Attribute
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml] Ported SerializableObjectModel to GXml.Attribute
- Date: Thu, 7 May 2015 18:15:27 +0000 (UTC)
commit b51c9a3198595341baeca91318319fff352fc26d
Author: Daniel Espinosa <esodan gmail com>
Date: Thu May 7 11:24:25 2015 -0500
Ported SerializableObjectModel to GXml.Attribute
* SerializableObjectModel.deserialize_property() checks for
GXml.Attribute no old GXml.Attr
* SerializableArrayList Unit tests serialize to TwDocument
* Added more DEBUG information
gxml/SerializableGeeArrayList.vala | 2 +-
gxml/SerializableObjectModel.vala | 8 ++++-
test/SerializableGeeArrayListTest.vala | 43 +++++++++++++------------------
3 files changed, 25 insertions(+), 28 deletions(-)
---
diff --git a/gxml/SerializableGeeArrayList.vala b/gxml/SerializableGeeArrayList.vala
index faad648..c02d34f 100644
--- a/gxml/SerializableGeeArrayList.vala
+++ b/gxml/SerializableGeeArrayList.vala
@@ -131,7 +131,7 @@ public class GXml.SerializableArrayList<G> : Gee.ArrayList<G>, Serializable, Ser
foreach (GXml.Node n in node.childs) {
if (n is Element) {
#if DEBUG
- GLib.message (@"Cheking Node $(n.name) on ArrayList in Element: $(node.name)");
+ GLib.message (@"Checking Node $(n.name) on ArrayList in Element: $(node.name)");
#endif
var obj = (Serializable) Object.new (element_type);
#if DEBUG
diff --git a/gxml/SerializableObjectModel.vala b/gxml/SerializableObjectModel.vala
index f999f00..4eaac7f 100644
--- a/gxml/SerializableObjectModel.vala
+++ b/gxml/SerializableObjectModel.vala
@@ -203,8 +203,12 @@ public abstract class GXml.SerializableObjectModel : Object, Serializable
attr_name = prop.get_name ();
var attr = element.get_attr (attr_name);
if (attr == null) {
- if (val != null)
+ if (val != null) {
+#if DEBUG
+ GLib.message (@"Setting attribute: '$(attr_name)' : val: '$(val)' to node: '$(element.name)'");
+#endif
element.set_attr (attr_name, val);
+ }
}
else
attr.value = val;
@@ -350,7 +354,7 @@ public abstract class GXml.SerializableObjectModel : Object, Serializable
val = Value (typeof (int));
else
val = Value (prop.value_type);
- if (property_node is GXml.Attr)
+ if (property_node is GXml.Attribute)
{
if (prop.value_type.is_a (Type.ENUM)) {
EnumValue env;
diff --git a/test/SerializableGeeArrayListTest.vala b/test/SerializableGeeArrayListTest.vala
index 6210c8f..b93e20b 100644
--- a/test/SerializableGeeArrayListTest.vala
+++ b/test/SerializableGeeArrayListTest.vala
@@ -72,10 +72,10 @@ class SerializableGeeArrayListTest : GXmlTest
var o2 = new AElement.named ("Small");
c.add (o1);
c.add (o2);
- var doc = new xDocument ();
+ var doc = new TwDocument ("/tmp/diieiw81!");
var root = doc.create_element ("root");
doc.childs.add (root);
- c.serialize ((xNode) root);
+ c.serialize (root);
assert (root.childs.size == 2);
bool found1 = false;
bool found2 = false;
@@ -145,35 +145,28 @@ class SerializableGeeArrayListTest : GXmlTest
var iroot = idoc.document_element;
var ic = new SerializableArrayList<AElement> ();
ic.deserialize (iroot);
- var doc = new xDocument.from_string ("""<?xml version="1.0"?><root />""");
- var root = doc.document_element;
+ var doc = new TwDocument ("/tmp/diieiw81!");
+ var root = doc.create_element ("root");
+ doc.childs.add (root);
ic.serialize (root);
var c = new SerializableArrayList<AElement> ();
c.deserialize (root);
- if (c.size != 3) {
- stdout.printf (@"ERROR: incorrect counted. Expected 3, got $(c.size)");
- assert_not_reached ();
- }
- int i = 0;
+ assert (c.size == 3);
+ int count_elements = 0;
foreach (AElement e in c)
- i++;
- if (i != 3) {
- stdout.printf (@"ERROR: incorrect counted. Expected 3, got $i");
- assert_not_reached ();
- }
+ count_elements++;
+ assert (count_elements == 3);
string[] s = {"Big","Small","Wall"};
+#if DEBUG
+ GLib.message ("Dump deserialized from document...");
+ for (int k = 0; k < c.size; k++) {
+ string str = "";
+ if (c.get (k).name != null) str = c.get (k).name;
+ GLib.message (@"Expected name = $(s[k]) got: $(str)");
+ }
+#endif
for (int j = 0; j < c.size; j++) {
- var e = c.get (j);
- if (s[j] != e.name) {
- stdout.printf (@"ERROR: incorrect name. Expected $(s[j]), got: $(c.get (j))");
- assert_not_reached ();
- }
- if (e.name == "Wall") {
- if (e.serialized_xml_node_value != null) {
- stdout.printf (@"ERROR: incorrect node '$(e.name)' content. Expected '', got:
'$(e.serialized_xml_node_value)'");
- assert_not_reached ();
- }
- }
+ assert (s[j] == c.get (j).name);
}
}
catch (GLib.Error e) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]