[gxml/serialization] Added documentation to Serializable.unknown_serializable_property
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gxml/serialization] Added documentation to Serializable.unknown_serializable_property
- Date: Fri, 1 Nov 2013 20:01:38 +0000 (UTC)
commit 2c08a5ee90b54472a9f527c28ce9de5e692c7a13
Author: Daniel Espinosa <esodan gmail com>
Date: Thu Oct 31 19:00:51 2013 -0600
Added documentation to Serializable.unknown_serializable_property
* Added test case for unknown property saved to
Serializable.unknown_serializable_property
gxml/Serializable.vala | 4 ++-
test/SerializableObjectModelTest.vala | 53 +++++++++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 1 deletions(-)
---
diff --git a/gxml/Serializable.vala b/gxml/Serializable.vala
index 0b5b110..4f5d43a 100644
--- a/gxml/Serializable.vala
+++ b/gxml/Serializable.vala
@@ -101,9 +101,11 @@ namespace GXml {
*/
public abstract HashTable<string,GLib.ParamSpec> ignored_serializable_properties { get;
protected set; }
/**
- * On deserialization stores any { link Node} not used on this
+ * On deserialization stores any { link GXml.Node} not used on this
* object, but exists in current XML file.
*
+ * Node's name is used as key to find stored { link GXml.Node}.
+ *
* This property is ignored on serialisation.
*/
public abstract HashTable<string,GXml.Node> unknown_serializable_property { get; protected
set; }
diff --git a/test/SerializableObjectModelTest.vala b/test/SerializableObjectModelTest.vala
index e4be236..6f92139 100644
--- a/test/SerializableObjectModelTest.vala
+++ b/test/SerializableObjectModelTest.vala
@@ -251,6 +251,11 @@ class Configuration : ObjectModel
}
}
+class UnknownAttribute : ObjectModel
+{
+ public string name { get; set; default = ""; }
+}
+
class SerializableObjectModelTest : GXmlTest
{
public static void add_tests ()
@@ -726,6 +731,54 @@ class SerializableObjectModelTest : GXmlTest
assert_not_reached ();
}
});
+ Test.add_func ("/gxml/serializable/object_model/unknown_property",
+ () => {
+ var doc = new Document.from_string ("""<?xml version="1.0"?>
+ <UnknownAttribute ignore="true" ignore2="test">
+ <UnknownNode toignore = "true" />
+ </UnknownAttribute>""");
+ var unknown_property = new UnknownAttribute ();
+ try {
+ unknown_property.deserialize (doc);
+ if (unknown_property.unknown_serializable_property.size () != 4) {
+ stdout.printf (@"ERROR: UNKNOWN_ATTRIBUTE: size
$(unknown_property.unknown_serializable_property.size ().to_string ())\n");
+ foreach (string s in
unknown_property.unknown_serializable_property.get_keys ()) {
+ stdout.printf (@"Saved unknown property: $(s)\n");
+ }
+ assert_not_reached ();
+ }
+ if (!unknown_property.unknown_serializable_property.contains ("ignore")) {
+ stdout.printf (@"ERROR: UNKNOWN_ATTRIBUTE: ignore not found");
+ assert_not_reached ();
+ }
+ var ignore = unknown_property.unknown_serializable_property.get ("ignore");
+ if (!(ignore is Attr)) {
+ stdout.printf (@"ERROR: UNKNOWN_ATTRIBUTE: ignore is not an
GXml.Attr");
+ assert_not_reached ();
+ }
+ if (!unknown_property.unknown_serializable_property.contains ("ignore2")) {
+ stdout.printf (@"ERROR: UNKNOWN_ATTRIBUTE: ignore not found");
+ assert_not_reached ();
+ }
+ var ignore2 = unknown_property.unknown_serializable_property.get ("ignore2");
+ if (!(ignore2 is Attr)) {
+ stdout.printf (@"ERROR: UNKNOWN_ATTRIBUTE: ignore2 is not an
GXml.Attr");
+ assert_not_reached ();
+ }
+ if (!unknown_property.unknown_serializable_property.contains ("UnknownNode"))
{
+ stdout.printf (@"ERROR: UNKNOWN_ATTRIBUTE: node UnknownNode not
found");
+ assert_not_reached ();
+ }var unknown_node = unknown_property.unknown_serializable_property.get
("UnknownNode");
+ if (!(unknown_node is Element)) {
+ stdout.printf (@"ERROR: UNKNOWN_ATTRIBUTE: unknown node is not an
GXml.Element");
+ assert_not_reached ();
+ }
+ }
+ catch (GLib.Error e) {
+ stdout.printf (@"Error: $(e.message)");
+ assert_not_reached ();
+ }
+ });
}
static void serialize_manual_check (Element element, Manual manual)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]