From: Christian Dywan Date: Sat, 25 Apr 2009 14:03:10 +0000 (+0200) Subject: Unit test using a string_list setting X-Git-Url: https://spindle.queued.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=212ed7d80cb4636c749197c47f2dddb80c00fe81;p=midori Unit test using a string_list setting --- diff --git a/tests/extensions.c b/tests/extensions.c index aba3a41c..e71a353d 100644 --- a/tests/extensions.c +++ b/tests/extensions.c @@ -75,6 +75,21 @@ extension_mock_object (void) return extension; } +static void +katze_assert_cmpstrv (gchar** values1, + gsize length1, + gchar** values2, + gsize length2) +{ + gsize i; + + g_assert ((values1 && values2) || (!values1 && !values2)); + /* g_assert_cmpint (length1, ==, length2); */ + + for (i = 0; i < length1; i++) + g_assert_cmpstr (values1[i], ==, values2[i]); +} + static void extension_settings (void) { @@ -83,6 +98,9 @@ extension_settings (void) gboolean nihilist; gint age; const gchar* lastname; + gchar* pet_names[] = {"Tiger", "Bonzo", "Streuner", NULL}; + gchar** names; + gsize names_n; app = midori_app_new (); extension = extension_mock_object (); @@ -126,6 +144,27 @@ extension_settings (void) lastname = midori_extension_get_string (extension, "lastname"); g_assert_cmpstr (lastname, ==, "Theodor Fontane"); midori_extension_deactivate (extension); + + extension = extension_mock_object (); + midori_extension_install_string_list (extension, "pets", pet_names, 3); + names = midori_extension_get_string_list (extension, "pets", &names_n); + katze_assert_cmpstrv (NULL, 0, names, names_n); + g_strfreev (names); + g_signal_emit_by_name (extension, "activate", app); + names = midori_extension_get_string_list (extension, "pets", &names_n); + katze_assert_cmpstrv (pet_names, 3, names, names_n); + g_strfreev (names); + /* names = g_strsplit ("Carla,Fluffy,Goro,Kitty", ",", 0); + midori_extension_set_string_list (extension, "pets", names, G_MAXSIZE); + g_strfreev (names); + names = midori_extension_get_string_list (extension, "pets", &names_n); + g_assert_cmpint (names_n, ==, 4); */ + names = g_strsplit ("Carla,Fluffy,Goro,Kitty", ",", 0); + midori_extension_set_string_list (extension, "pets", names, 2); + g_strfreev (names); + names = midori_extension_get_string_list (extension, "pets", &names_n); + g_assert_cmpint (names_n, ==, 2); + midori_extension_deactivate (extension); } int