pidgin: fdc5dbea: jabber: Start adding some caps tests
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Fri Jul 9 18:15:41 EDT 2010
----------------------------------------------------------------------
Revision: fdc5dbeafbce28333163f1d850ec53d53a692149
Parent: 50f72cecab1bd2bb5de26966b3c15dc3a32f75ca
Author: darkrain42 at pidgin.im
Date: 07/09/10 18:14:03
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/fdc5dbeafbce28333163f1d850ec53d53a692149
Changelog:
jabber: Start adding some caps tests
Changes against parent 50f72cecab1bd2bb5de26966b3c15dc3a32f75ca
added libpurple/tests/test_jabber_caps.c
patched libpurple/protocols/jabber/caps.c
patched libpurple/protocols/jabber/caps.h
patched libpurple/tests/Makefile.am
patched libpurple/tests/check_libpurple.c
patched libpurple/tests/tests.h
-------------- next part --------------
============================================================
--- libpurple/tests/Makefile.am f1d2e70bf4e78d3cd817bfd0873e92f3d7ab173c
+++ libpurple/tests/Makefile.am fa9fea1ab00102fa5cf81bc4e2f41cc350fcffb7
@@ -10,6 +10,7 @@ check_libpurple_SOURCES=\
check_libpurple.c \
tests.h \
test_cipher.c \
+ test_jabber_caps.c \
test_jabber_jutil.c \
test_jabber_scram.c \
test_qq.c \
============================================================
--- libpurple/tests/check_libpurple.c 97460d422d7fb0246559c2d34f8569251e4bab75
+++ libpurple/tests/check_libpurple.c 044a5ca539a834dab33d525b24471d738cafaf35
@@ -84,6 +84,7 @@ int main(void)
sr = srunner_create (master_suite());
srunner_add_suite(sr, cipher_suite());
+ srunner_add_suite(sr, jabber_caps_suite());
srunner_add_suite(sr, jabber_jutil_suite());
srunner_add_suite(sr, jabber_scram_suite());
srunner_add_suite(sr, qq_suite());
============================================================
--- libpurple/tests/tests.h b67480467fef71c532caac0d2644cb1b9f0b3e3d
+++ libpurple/tests/tests.h 22617c5e913e74696b8e448991b84242d0fd8f3c
@@ -9,6 +9,7 @@ Suite * cipher_suite(void);
/* remember to add the suite to the runner in check_libpurple.c */
Suite * master_suite(void);
Suite * cipher_suite(void);
+Suite * jabber_caps_suite(void);
Suite * jabber_jutil_suite(void);
Suite * jabber_scram_suite(void);
Suite * qq_suite(void);
============================================================
--- libpurple/protocols/jabber/caps.c 000c6161f8fc2c9a26cb3aba3e29a2674177e3ff
+++ libpurple/protocols/jabber/caps.c f48da1befffa10a258acea51fdbd778491b2cdc9
@@ -41,14 +41,6 @@ static guint save_timer = 0;
static GHashTable *nodetable = NULL; /* char *node -> JabberCapsNodeExts */
static guint save_timer = 0;
-/**
- * Processes a query-node and returns a JabberCapsClientInfo object with all relevant info.
- *
- * @param query A query object.
- * @return A JabberCapsClientInfo object.
- */
-static JabberCapsClientInfo *jabber_caps_parse_client_info(xmlnode *query);
-
/* Free a GList of allocated char* */
static void
free_string_glist(GList *list)
@@ -764,13 +756,14 @@ jabber_xdata_compare(gconstpointer a, gc
return result;
}
-static JabberCapsClientInfo *jabber_caps_parse_client_info(xmlnode *query)
+JabberCapsClientInfo *jabber_caps_parse_client_info(xmlnode *query)
{
xmlnode *child;
JabberCapsClientInfo *info;
- if (!query || strcmp(query->xmlns, NS_DISCO_INFO))
- return 0;
+ if (!query || !g_str_equal(query->name, "query") ||
+ !purple_strequal(query->xmlns, NS_DISCO_INFO))
+ return NULL;
info = g_new0(JabberCapsClientInfo, 1);
============================================================
--- libpurple/protocols/jabber/caps.h 5c0a69912220ce4d1c8e0da5e6b09aadc8f7e0b7
+++ libpurple/protocols/jabber/caps.h 3f1bdbc20e0dd78467f6dc0d815b01ae5f918f36
@@ -115,4 +115,15 @@ void jabber_caps_broadcast_change(void);
*/
void jabber_caps_broadcast_change(void);
+/**
+ * Parse the <query/> element from an IQ stanza into a JabberCapsClientInfo
+ * struct.
+ *
+ * Exposed for tests
+ *
+ * @param query The 'query' element from an IQ reply stanza.
+ * @returns A JabberCapsClientInfo struct, or NULL on error
+ */
+JabberCapsClientInfo *jabber_caps_parse_client_info(xmlnode *query);
+
#endif /* PURPLE_JABBER_CAPS_H_ */
============================================================
--- /dev/null
+++ libpurple/tests/test_jabber_caps.c 95427bb48ee20a114aab45f65dd980cbbaf27130
@@ -0,0 +1,36 @@
+#include <string.h>
+
+#include "tests.h"
+#include "../xmlnode.h"
+#include "../protocols/jabber/caps.h"
+
+START_TEST(test_parse_invalid)
+{
+ xmlnode *query;
+
+ fail_unless(NULL == jabber_caps_parse_client_info(NULL));
+
+ /* Something other than a disco#info query */
+ query = xmlnode_new("foo");
+ fail_unless(NULL == jabber_caps_parse_client_info(query));
+ xmlnode_free(query);
+
+ query = xmlnode_new("query");
+ fail_unless(NULL == jabber_caps_parse_client_info(query));
+ xmlnode_set_namespace(query, "jabber:iq:last");
+ fail_unless(NULL == jabber_caps_parse_client_info(query));
+ xmlnode_free(query);
+}
+END_TEST
+
+Suite *
+jabber_caps_suite(void)
+{
+ Suite *s = suite_create("Jabber Caps Functions");
+
+ TCase *tc = tcase_create("Parsing invalid ndoes");
+ tcase_add_test(tc, test_parse_invalid);
+ suite_add_tcase(s, tc);
+
+ return s;
+}
More information about the Commits
mailing list