[libgdata] [atom] Added test cases for the Atom elements with classes



commit 33be5a3f48f400611132c3a85e8f1b17fd5f383e
Author: Philip Withnall <philip tecnocode co uk>
Date:   Mon Jun 29 01:05:08 2009 +0100

    [atom] Added test cases for the Atom elements with classes
    
    Added test cases for all the Atom elements represented in gdata/atom. A few
    bugs in GDataParsable, GDataGenerator and GDataLink were fixed as a result.
    Most notably, gdata_link_get_uri will now always return a valid IRI.

 HACKING                      |   10 ++-
 gdata/atom/gdata-generator.c |   21 +++-
 gdata/atom/gdata-link.c      |   39 +++++--
 gdata/gdata-parsable.c       |    9 ++-
 gdata/tests/calendar.c       |    6 +-
 gdata/tests/contacts.c       |    4 +-
 gdata/tests/general.c        |  239 +++++++++++++++++++++++++++++++++++++++++-
 gdata/tests/youtube.c        |   20 ++--
 8 files changed, 309 insertions(+), 39 deletions(-)
---
diff --git a/HACKING b/HACKING
index b35fa38..f3a901f 100644
--- a/HACKING
+++ b/HACKING
@@ -123,16 +123,24 @@ The short explanation of a commit should always be prefixed by a tag to describe
 
  - [core] â?? for the core code in the gdata directory, such as GDataEntry.
 
+ - [atom] â?? for the Atom-namespaced code in the gdata/atom directory.
+
+ - [gd] â?? for the GData-namespaced code in the gdata/gd directory.
+
+ - [media] â?? for the Media RSS-namespaced code in the gdata/media directory.
+
  - [build] â?? for build changes and releases.
 
  - [docs] â?? for documentation changes which are not specific to a service, such as updates to the docs directory, NEWS, README, this file, etc.
 
- - [tests] â?? for changes to the test code in gdata/tests which are not specific to a service.
+ - [tests] â?? for changes to the test code in gdata/tests which are not specific to a service or namespace.
 
  - [calendar] â?? for the Google Calendar code in gdata/services/calendar.
 
  - [contacts] â?? for the Google Contacts code in gdata/services/contacts.
 
+ - [picasaweb] â?? for the PicasaWeb code in gdata/services/picasaweb.
+
  - [youtube] â?? for the YouTube code in gdata/services/youtube.
 
 The only commits which should not have a tag are translation commits, touching only the po directory.
diff --git a/gdata/atom/gdata-generator.c b/gdata/atom/gdata-generator.c
index bc1df18..5eafb2a 100644
--- a/gdata/atom/gdata-generator.c
+++ b/gdata/atom/gdata-generator.c
@@ -162,8 +162,16 @@ gdata_generator_get_property (GObject *object, guint property_id, GValue *value,
 static gboolean
 pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
 {
+	xmlChar *name;
 	GDataGeneratorPrivate *priv = GDATA_GENERATOR (parsable)->priv;
 
+	name = xmlNodeListGetString (doc, root_node->children, TRUE);
+	if (name != NULL && *name == '\0') {
+		xmlFree (name);
+		return gdata_parser_error_required_content_missing (root_node, error);
+	}
+
+	priv->name = (gchar*) name;
 	priv->uri = (gchar*) xmlGetProp (root_node, (xmlChar*) "uri");
 	priv->version = (gchar*) xmlGetProp (root_node, (xmlChar*) "version");
 
@@ -173,13 +181,14 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
 static gboolean
 parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error)
 {
-	xmlChar *name = xmlNodeListGetString (doc, node->children, TRUE);
-	if (name != NULL && *name == '\0') {
-		xmlFree (name);
-		return gdata_parser_error_required_content_missing (node, error);
-	}
+	/* Textual content's handled in pre_parse_xml */
+	if (node->type != XML_ELEMENT_NODE)
+		return TRUE;
 
-	GDATA_GENERATOR (parsable)->priv->name = (gchar*) name;
+	if (GDATA_PARSABLE_CLASS (gdata_generator_parent_class)->parse_xml (parsable, doc, node, user_data, error) == FALSE) {
+		/* Error! */
+		return FALSE;
+	}
 
 	return TRUE;
 }
diff --git a/gdata/atom/gdata-link.c b/gdata/atom/gdata-link.c
index 61da25e..6eab0a5 100644
--- a/gdata/atom/gdata-link.c
+++ b/gdata/atom/gdata-link.c
@@ -29,6 +29,7 @@
 
 #include <glib.h>
 #include <libxml/parser.h>
+#include <string.h>
 
 #include "gdata-link.h"
 #include "gdata-parsable.h"
@@ -275,26 +276,29 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
 
 	/* rel */
 	relation_type = xmlGetProp (root_node, (xmlChar*) "rel");
-	if (relation_type != NULL && *relation_type == '\0')
+	if (relation_type != NULL && *relation_type == '\0') {
+		xmlFree (relation_type);
 		return gdata_parser_error_required_property_missing (root_node, "rel", error);
+	}
 
-	if (relation_type == NULL)
-		self->priv->relation_type = g_strdup ("alternate");
-	else
-		self->priv->relation_type = g_strdup ((gchar*) relation_type);
+	gdata_link_set_relation_type (self, (const gchar*) relation_type);
 	xmlFree (relation_type);
 
 	/* type */
 	content_type = xmlGetProp (root_node, (xmlChar*) "type");
-	if (content_type != NULL && *content_type == '\0')
+	if (content_type != NULL && *content_type == '\0') {
+		xmlFree (content_type);
 		return gdata_parser_error_required_property_missing (root_node, "type", error);
+	}
 	self->priv->content_type = g_strdup ((gchar*) content_type);
 	xmlFree (content_type);
 
 	/* hreflang */
 	language = xmlGetProp (root_node, (xmlChar*) "hreflang");
-	if (language != NULL && *language == '\0')
+	if (language != NULL && *language == '\0') {
+		xmlFree (language);
 		return gdata_parser_error_required_property_missing (root_node, "hreflang", error);
+	}
 	self->priv->language = g_strdup ((gchar*) language);
 	xmlFree (language);
 
@@ -386,7 +390,12 @@ gdata_link_compare (const GDataLink *a, const GDataLink *b)
  * gdata_link_get_uri:
  * @self: a #GDataLink
  *
- * Gets the #GDataLink:uri property.
+ * Gets the #GDataLink:uri property. The return value is guaranteed to be a valid IRI, as
+ * specified by the Atom protocol. Common relationship values such as <literal>alternate</literal>
+ * are returned as <literal>http://www.iana.org/assignments/relation/alternate</literal>.
+ *
+ * For more information, see the <ulink type="http" uri="http://www.atomenabled.org/developers/syndication/atom-format-spec.php#rel_attribute";>
+ * Atom specification</ulink>.
  *
  * Return value: the link's URI
  *
@@ -453,12 +462,18 @@ gdata_link_set_relation_type (GDataLink *self, const gchar *relation_type)
 	g_return_if_fail (GDATA_IS_LINK (self));
 	g_return_if_fail (relation_type == NULL || *relation_type != '\0');
 
-	/* "If the "rel" attribute is not present, the link element MUST be interpreted as if the link relation type is "alternate"." */
+	/* If the relation type is unset, use the default "alternate" relation type. If it's set, and isn't an IRI, turn it into an IRI
+	 * by appending it to "http://www.iana.org/assignments/relation/";. If it's set and is an IRI, just use the IRI.
+	 * See: http://www.atomenabled.org/developers/syndication/atom-format-spec.php#rel_attribute
+	 */
+	g_free (self->priv->relation_type);
 	if (relation_type == NULL)
-		relation_type = "alternate";
+		self->priv->relation_type = g_strdup ("http://www.iana.org/assignments/relation/alternate";);
+	else if (strchr ((char*) relation_type, ':') == NULL)
+		self->priv->relation_type = g_strconcat ("http://www.iana.org/assignments/relation/";, (const gchar*) relation_type, NULL);
+	else
+		self->priv->relation_type = g_strdup ((gchar*) relation_type);
 
-	g_free (self->priv->relation_type);
-	self->priv->relation_type = g_strdup (relation_type);
 	g_object_notify (G_OBJECT (self), "relation-type");
 }
 
diff --git a/gdata/gdata-parsable.c b/gdata/gdata-parsable.c
index 8fdd912..171ec12 100644
--- a/gdata/gdata-parsable.c
+++ b/gdata/gdata-parsable.c
@@ -101,6 +101,9 @@ real_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer us
 
 	/* Get the namespaces */
 	namespaces = xmlGetNsList (doc, node);
+	if (namespaces == NULL)
+		return TRUE;
+
 	for (namespace = namespaces; *namespace != NULL; namespace++) {
 		if ((*namespace)->prefix != NULL) {
 			g_hash_table_insert (parsable->priv->extra_namespaces,
@@ -300,8 +303,10 @@ _gdata_parsable_get_xml (GDataParsable *self, gboolean declare_namespaces)
 	/* We only include the normal namespaces if we're not at the top level of XML building */
 	if (declare_namespaces == TRUE) {
 		g_string_append (xml_string, " xmlns='http://www.w3.org/2005/Atom'");
-		g_hash_table_foreach (namespaces, (GHFunc) build_namespaces_cb, xml_string);
-		g_hash_table_destroy (namespaces);
+		if (namespaces != NULL) {
+			g_hash_table_foreach (namespaces, (GHFunc) build_namespaces_cb, xml_string);
+			g_hash_table_destroy (namespaces);
+		}
 	}
 
 	g_hash_table_foreach (self->priv->extra_namespaces, (GHFunc) build_namespaces_cb, xml_string);
diff --git a/gdata/tests/calendar.c b/gdata/tests/calendar.c
index dd4a305..4ac976d 100644
--- a/gdata/tests/calendar.c
+++ b/gdata/tests/calendar.c
@@ -414,9 +414,9 @@ test_xml_recurrence (void)
 			"<category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'/>"
 			"<title>Test daily instance event</title>"
 			"<content></content>"
-			"<link rel='alternate' type='text/html' href='http://www.google.com/calendar/event?eid=ZzU5MjhlODJycmNoOTViMjVmOHVkMGRsc2dfMjAwOTA0MjlUMTUzMDAwWiBsaWJnZGF0YS50ZXN0QGdvb2dsZW1haWwuY29t' title='alternate'/>"
-			"<link rel='self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/libgdata test googlemail com/private/full/g5928e82rrch95b25f8ud0dlsg_20090429T153000Z'/>"
-			"<link rel='edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/libgdata test googlemail com/private/full/g5928e82rrch95b25f8ud0dlsg_20090429T153000Z'/>"
+			"<link rel='http://www.iana.org/assignments/relation/alternate' type='text/html' href='http://www.google.com/calendar/event?eid=ZzU5MjhlODJycmNoOTViMjVmOHVkMGRsc2dfMjAwOTA0MjlUMTUzMDAwWiBsaWJnZGF0YS50ZXN0QGdvb2dsZW1haWwuY29t' title='alternate'/>"
+			"<link rel='http://www.iana.org/assignments/relation/self' type='application/atom+xml' href='http://www.google.com/calendar/feeds/libgdata test googlemail com/private/full/g5928e82rrch95b25f8ud0dlsg_20090429T153000Z'/>"
+			"<link rel='http://www.iana.org/assignments/relation/edit' type='application/atom+xml' href='http://www.google.com/calendar/feeds/libgdata test googlemail com/private/full/g5928e82rrch95b25f8ud0dlsg_20090429T153000Z'/>"
 			"<author>"
 				"<name>GData Test</name>"
 				"<email>libgdata test googlemail com</email>"
diff --git a/gdata/tests/contacts.c b/gdata/tests/contacts.c
index b3cc5eb..b845a42 100644
--- a/gdata/tests/contacts.c
+++ b/gdata/tests/contacts.c
@@ -259,8 +259,8 @@ test_parser_minimal (void)
 			"<category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/contact/2008#contact'/>"
 			"<title></title>" /* Here's where it all went wrong */
 			"<link rel='http://schemas.google.com/contacts/2008/rel#photo' type='image/*' href='http://www.google.com/m8/feeds/photos/media/libgdata test googlemail com/1b46cdd20bfbee3b'/>"
-			"<link rel='self' type='application/atom+xml' href='http://www.google.com/m8/feeds/contacts/libgdata test googlemail com/full/1b46cdd20bfbee3b'/>"
-			"<link rel='edit' type='application/atom+xml' href='http://www.google.com/m8/feeds/contacts/libgdata test googlemail com/full/1b46cdd20bfbee3b'/>"
+			"<link rel='http://www.iana.org/assignments/relation/self' type='application/atom+xml' href='http://www.google.com/m8/feeds/contacts/libgdata test googlemail com/full/1b46cdd20bfbee3b'/>"
+			"<link rel='http://www.iana.org/assignments/relation/edit' type='application/atom+xml' href='http://www.google.com/m8/feeds/contacts/libgdata test googlemail com/full/1b46cdd20bfbee3b'/>"
 			"<gd:email rel='http://schemas.google.com/g/2005#other' address='bob example com'/>"
 		"</entry>", -1, &error));
 	g_assert_no_error (error);
diff --git a/gdata/tests/general.c b/gdata/tests/general.c
index 34297ce..51c5bc6 100644
--- a/gdata/tests/general.c
+++ b/gdata/tests/general.c
@@ -92,9 +92,9 @@ test_entry_get_xml (void)
 				 "<category term='Film' scheme='http://gdata.youtube.com/schemas/2007/categories.cat' label='Film &amp; Animation'/>"
 				 "<category term='example' label='Example stuff'/>"
 				 "<category term='test'/>"
-				 "<link href='http://test.mn/' title='A treatise on Mongolian test websites &amp; other stuff.' rel='related' type='text/html' hreflang='mn' length='5010'/>"
-				 "<link href='http://example.com/' rel='alternate'/>"
-				 "<link href='http://test.com/' rel='self' type='application/atom+xml'/>"
+				 "<link href='http://test.mn/' title='A treatise on Mongolian test websites &amp; other stuff.' rel='http://www.iana.org/assignments/relation/related' type='text/html' hreflang='mn' length='5010'/>"
+				 "<link href='http://example.com/' rel='http://www.iana.org/assignments/relation/alternate'/>"
+				 "<link href='http://test.com/' rel='http://www.iana.org/assignments/relation/self' type='application/atom+xml'/>"
 				 "<author><name>F. Barr\330\237</name></author>"
 				 "<author><name>John Smith</name><email>smith john example com</email></author>"
 				 "<author><name>Joe Bloggs</name><uri>http://example.com/</uri><email>joe example com</email></author>"
@@ -268,6 +268,235 @@ test_media_thumbnail_parse_time (const gchar *locale)
 	setlocale (LC_ALL, "");
 }*/
 
+static void
+test_atom_author (void)
+{
+	GDataAuthor *author, *author2;
+	gchar *xml;
+	GError *error = NULL;
+
+	author = GDATA_AUTHOR (gdata_parsable_new_from_xml (GDATA_TYPE_AUTHOR,
+		"<author>"
+			"<name>John Smöth</name>"
+			"<uri>http://example.com/</uri>"
+			"<email>john example com</email>"
+		"</author>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_AUTHOR (author));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert_cmpstr (gdata_author_get_name (author), ==, "John Smöth");
+	g_assert_cmpstr (gdata_author_get_uri (author), ==, "http://example.com/";);
+	g_assert_cmpstr (gdata_author_get_email_address (author), ==, "john example com");
+
+	/* Compare it against another identical author */
+	author2 = gdata_author_new ("John Smöth", "http://example.com/";, "john example com");
+	g_assert_cmpint (gdata_author_compare (author, author2), ==, 0);
+	g_object_unref (author2);
+
+	/* â?¦and a different author */
+	author2 = gdata_author_new ("Brian Blessed", NULL, NULL);
+	g_assert_cmpint (gdata_author_compare (author, author2), !=, 0);
+	g_object_unref (author2);
+
+	/* Check the outputted XML is the same */
+	xml = gdata_parsable_get_xml (GDATA_PARSABLE (author));
+	g_assert_cmpstr (xml, ==,
+			 "<author xmlns='http://www.w3.org/2005/Atom'>"
+				"<name>John Smöth</name>"
+				"<uri>http://example.com/</uri>"
+				"<email>john example com</email>"
+			 "</author>");
+	g_free (xml);
+	g_object_unref (author);
+
+	/* Now parse an author with little information available */
+	author = GDATA_AUTHOR (gdata_parsable_new_from_xml (GDATA_TYPE_AUTHOR,
+		"<author>"
+			"<name>James Johnson</name>"
+		"</author>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_AUTHOR (author));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert_cmpstr (gdata_author_get_name (author), ==, "James Johnson");
+	g_assert (gdata_author_get_uri (author) == NULL);
+	g_assert (gdata_author_get_email_address (author) == NULL);
+	g_object_unref (author);
+}
+
+static void
+test_atom_category (void)
+{
+	GDataCategory *category, *category2;
+	gchar *xml;
+	GError *error = NULL;
+
+	category = GDATA_CATEGORY (gdata_parsable_new_from_xml (GDATA_TYPE_CATEGORY,
+		"<category term='jokes' scheme='http://foobar.com#categories' label='Jokes &amp; Trivia'/>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_CATEGORY (category));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert_cmpstr (gdata_category_get_term (category), ==, "jokes");
+	g_assert_cmpstr (gdata_category_get_scheme (category), ==, "http://foobar.com#categories";);
+	g_assert_cmpstr (gdata_category_get_label (category), ==, "Jokes & Trivia");
+
+	/* Compare it against another identical category */
+	category2 = gdata_category_new ("jokes", "http://foobar.com#categories";, "Jokes & Trivia");
+	g_assert_cmpint (gdata_category_compare (category, category2), ==, 0);
+	g_object_unref (category2);
+
+	/* â?¦and a different category */
+	category2 = gdata_category_new ("sports", "http://foobar.com#categories";, NULL);
+	g_assert_cmpint (gdata_category_compare (category, category2), !=, 0);
+	g_object_unref (category2);
+
+	/* Check the outputted XML is the same */
+	xml = gdata_parsable_get_xml (GDATA_PARSABLE (category));
+	g_assert_cmpstr (xml, ==,
+			 "<category xmlns='http://www.w3.org/2005/Atom' "
+			 	"term='jokes' scheme='http://foobar.com#categories' label='Jokes &amp; Trivia'/>");
+	g_free (xml);
+	g_object_unref (category);
+
+	/* Now parse a category with less information available */
+	category = GDATA_CATEGORY (gdata_parsable_new_from_xml (GDATA_TYPE_CATEGORY,
+		"<category term='sports'/>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_CATEGORY (category));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert_cmpstr (gdata_category_get_term (category), ==, "sports");
+	g_assert (gdata_category_get_scheme (category) == NULL);
+	g_assert (gdata_category_get_label (category) == NULL);
+	g_object_unref (category);
+
+	/* Try a category with custom content */
+	category = GDATA_CATEGORY (gdata_parsable_new_from_xml (GDATA_TYPE_CATEGORY,
+		"<category term='documentary'>"
+			"<foobar/>"
+			"<shizzle/>"
+		"</category>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_CATEGORY (category));
+	g_clear_error (&error);
+
+	/* Check the outputted XML contains the unknown XML */
+	xml = gdata_parsable_get_xml (GDATA_PARSABLE (category));
+	g_assert_cmpstr (xml, ==,
+			 "<category xmlns='http://www.w3.org/2005/Atom' term='documentary'>"
+			 	"<foobar/>"
+			 	"<shizzle/>"
+			 "</category>");
+	g_free (xml);
+	g_object_unref (category);
+}
+
+static void
+test_atom_generator (void)
+{
+	GDataGenerator *generator;
+	GError *error = NULL;
+
+	generator = GDATA_GENERATOR (gdata_parsable_new_from_xml (GDATA_TYPE_GENERATOR,
+		"<generator uri='http://example.com/' version='15'>Bach &amp; Son's Generator</generator>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_GENERATOR (generator));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert_cmpstr (gdata_generator_get_name (generator), ==, "Bach & Son's Generator");
+	g_assert_cmpstr (gdata_generator_get_uri (generator), ==, "http://example.com/";);
+	g_assert_cmpstr (gdata_generator_get_version (generator), ==, "15");
+	g_object_unref (generator);
+
+	/* Now parse a generator with less information available */
+	generator = GDATA_GENERATOR (gdata_parsable_new_from_xml (GDATA_TYPE_GENERATOR,
+		"<generator/>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_GENERATOR (generator));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert (gdata_generator_get_name (generator) == NULL);
+	g_assert (gdata_generator_get_uri (generator) == NULL);
+	g_assert (gdata_generator_get_version (generator) == NULL);
+	g_object_unref (generator);
+}
+
+static void
+test_atom_link (void)
+{
+	GDataLink *link, *link2;
+	gchar *xml;
+	GError *error = NULL;
+
+	link = GDATA_LINK (gdata_parsable_new_from_xml (GDATA_TYPE_LINK,
+		"<link href='http://example.com/' rel='http://test.com#link-type' type='text/plain' hreflang='de' "
+			"title='All About Angle Brackets: &lt;, &gt;' length='2000'/>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_LINK (link));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert_cmpstr (gdata_link_get_uri (link), ==, "http://example.com/";);
+	g_assert_cmpstr (gdata_link_get_relation_type (link), ==, "http://test.com#link-type";);
+	g_assert_cmpstr (gdata_link_get_content_type (link), ==, "text/plain");
+	g_assert_cmpstr (gdata_link_get_language (link), ==, "de");
+	g_assert_cmpstr (gdata_link_get_title (link), ==, "All About Angle Brackets: <, >");
+	g_assert_cmpint (gdata_link_get_length (link), ==, 2000);
+
+	/* Compare it against another identical link */
+	link2 = gdata_link_new ("http://example.com/";, "http://test.com#link-type";);
+	g_assert_cmpint (gdata_link_compare (link, link2), ==, 0);
+	gdata_link_set_content_type (link2, "text/plain");
+	gdata_link_set_language (link2, "de");
+	gdata_link_set_title (link2, "All About Angle Brackets: <, >");
+	gdata_link_set_length (link2, 2000);
+	g_assert_cmpint (gdata_link_compare (link, link2), ==, 0);
+
+	/* Try with a dissimilar link */
+	gdata_link_set_uri (link2, "http://gnome.org/";);
+	g_assert_cmpint (gdata_link_compare (link, link2), !=, 0);
+	g_object_unref (link2);
+
+	/* Check the outputted XML is the same */
+	xml = gdata_parsable_get_xml (GDATA_PARSABLE (link));
+	g_assert_cmpstr (xml, ==,
+			 "<link xmlns='http://www.w3.org/2005/Atom' href='http://example.com/' title='All About Angle Brackets: &lt;, &gt;' "
+			 	"rel='http://test.com#link-type' type='text/plain' hreflang='de' length='2000'/>");
+	g_free (xml);
+	g_object_unref (link);
+
+	/* Now parse a link with less information available */
+	link = GDATA_LINK (gdata_parsable_new_from_xml (GDATA_TYPE_LINK,
+		"<link href='http://shizzle.com'>Test Content<foobar/></link>", -1, &error));
+	g_assert_no_error (error);
+	g_assert (GDATA_IS_LINK (link));
+	g_clear_error (&error);
+
+	/* Check the properties */
+	g_assert_cmpstr (gdata_link_get_uri (link), ==, "http://shizzle.com";);
+	g_assert_cmpstr (gdata_link_get_relation_type (link), ==, "http://www.iana.org/assignments/relation/alternate";);
+	g_assert (gdata_link_get_content_type (link) == NULL);
+	g_assert (gdata_link_get_language (link) == NULL);
+	g_assert (gdata_link_get_title (link) == NULL);
+	g_assert (gdata_link_get_length (link) == -1);
+
+	/* Check the outputted XML contains the unknown XML */
+	xml = gdata_parsable_get_xml (GDATA_PARSABLE (link));
+	g_assert_cmpstr (xml, ==,
+			 "<link xmlns='http://www.w3.org/2005/Atom' href='http://shizzle.com' rel='http://www.iana.org/assignments/relation/alternate'>"
+			 	"Test Content<foobar/></link>");
+	g_free (xml);
+	g_object_unref (link);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -280,6 +509,10 @@ main (int argc, char *argv[])
 	g_test_add_func ("/query/categories", test_query_categories);
 	g_test_add_func ("/color/parsing", test_color_parsing);
 	g_test_add_func ("/color/output", test_color_output);
+	g_test_add_func ("/atom/author", test_atom_author);
+	g_test_add_func ("/atom/category", test_atom_category);
+	g_test_add_func ("/atom/generator", test_atom_generator);
+	g_test_add_func ("/atom/link", test_atom_link);
 	/*g_test_add_data_func ("/media/thumbnail/parse_time", "", test_media_thumbnail_parse_time);
 	g_test_add_data_func ("/media/thumbnail/parse_time", "de_DE", test_media_thumbnail_parse_time);*/
 
diff --git a/gdata/tests/youtube.c b/gdata/tests/youtube.c
index d80c3cc..345eb89 100644
--- a/gdata/tests/youtube.c
+++ b/gdata/tests/youtube.c
@@ -170,10 +170,10 @@ get_video_for_related (void)
 			"<category scheme='http://gdata.youtube.com/schemas/2007/keywords.cat' term='half-life'/>"
 			"<title type='text'>Escape From City 17 - Part One</title>"
 			"<content type='text'>Directed by The Purchase Brothers. *snip*</content>"
-			"<link rel='alternate' type='text/html' href='http://www.youtube.com/watch?v=q1UPMEmCqZo'/>"
+			"<link rel='http://www.iana.org/assignments/relation/alternate' type='text/html' href='http://www.youtube.com/watch?v=q1UPMEmCqZo'/>"
 			"<link rel='http://gdata.youtube.com/schemas/2007#video.related' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/q1UPMEmCqZo/related'/>"
 			"<link rel='http://gdata.youtube.com/schemas/2007#mobile' type='text/html' href='http://m.youtube.com/details?v=q1UPMEmCqZo'/>"
-			"<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/standardfeeds/top_rated/v/q1UPMEmCqZo'/>"
+			"<link rel='http://www.iana.org/assignments/relation/self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/standardfeeds/top_rated/v/q1UPMEmCqZo'/>"
 			"<author>"
 				"<name>PurchaseBrothers</name>"
 				"<uri>http://gdata.youtube.com/feeds/api/users/purchasebrothers</uri>"
@@ -342,8 +342,8 @@ test_parsing_app_control (void)
 			"</app:control>"
 			"<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#video'/>"
 			"<title>Judas Priest - Painkiller</title>"
-			"<link rel='alternate' type='text/html' href='http://www.youtube.com/watch?v=JAagedeKdcQ'/>"
-			"<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/JAagedeKdcQ?client=ytapi-google-jsdemo'/>"
+			"<link rel='http://www.iana.org/assignments/relation/alternate' type='text/html' href='http://www.youtube.com/watch?v=JAagedeKdcQ'/>"
+			"<link rel='http://www.iana.org/assignments/relation/self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/JAagedeKdcQ?client=ytapi-google-jsdemo'/>"
 			"<author>"
 				"<name>eluves</name>"
 				"<uri>http://gdata.youtube.com/feeds/api/users/eluves</uri>"
@@ -391,8 +391,8 @@ test_parsing_yt_recorded (void)
 			"<updated>2009-03-23T12:46:58.000Z</updated>"
 			"<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#video'/>"
 			"<title>Judas Priest - Painkiller</title>"
-			"<link rel='alternate' type='text/html' href='http://www.youtube.com/watch?v=JAagedeKdcQ'/>"
-			"<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/JAagedeKdcQ?client=ytapi-google-jsdemo'/>"
+			"<link rel='http://www.iana.org/assignments/relation/alternate' type='text/html' href='http://www.youtube.com/watch?v=JAagedeKdcQ'/>"
+			"<link rel='http://www.iana.org/assignments/relation/self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/JAagedeKdcQ?client=ytapi-google-jsdemo'/>"
 			"<author>"
 				"<name>eluves</name>"
 				"<uri>http://gdata.youtube.com/feeds/api/users/eluves</uri>"
@@ -431,8 +431,8 @@ test_parsing_yt_recorded (void)
 				"<updated>2009-03-23T12:46:58Z</updated>"
 				"<published>2006-05-16T14:06:37Z</published>"
 				"<category term='http://gdata.youtube.com/schemas/2007#video' scheme='http://schemas.google.com/g/2005#kind'/>"
-				"<link href='http://www.youtube.com/watch?v=JAagedeKdcQ' rel='alternate' type='text/html'/>"
-				"<link href='http://gdata.youtube.com/feeds/api/videos/JAagedeKdcQ?client=ytapi-google-jsdemo' rel='self' type='application/atom+xml'/>"
+				"<link href='http://www.youtube.com/watch?v=JAagedeKdcQ' rel='http://www.iana.org/assignments/relation/alternate' type='text/html'/>"
+				"<link href='http://gdata.youtube.com/feeds/api/videos/JAagedeKdcQ?client=ytapi-google-jsdemo' rel='http://www.iana.org/assignments/relation/self' type='application/atom+xml'/>"
 				"<author>"
 					"<name>eluves</name>"
 					"<uri>http://gdata.youtube.com/feeds/api/users/eluves</uri>"
@@ -471,8 +471,8 @@ test_parsing_comments_feed_link (void)
 			"<updated>2009-03-23T12:46:58.000Z</updated>"
 			"<category scheme='http://schemas.google.com/g/2005#kind' term='http://gdata.youtube.com/schemas/2007#video'/>"
 			"<title>Judas Priest - Painkiller</title>"
-			"<link rel='alternate' type='text/html' href='http://www.youtube.com/watch?v=JAagedeKdcQ'/>"
-			"<link rel='self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/JAagedeKdcQ?client=ytapi-google-jsdemo'/>"
+			"<link rel='http://www.iana.org/assignments/relation/alternate' type='text/html' href='http://www.youtube.com/watch?v=JAagedeKdcQ'/>"
+			"<link rel='http://www.iana.org/assignments/relation/self' type='application/atom+xml' href='http://gdata.youtube.com/feeds/api/videos/JAagedeKdcQ?client=ytapi-google-jsdemo'/>"
 			"<author>"
 				"<name>eluves</name>"
 				"<uri>http://gdata.youtube.com/feeds/api/users/eluves</uri>"



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