[epiphany/history-rewrite: 19/28] Add tests for EphyHistoryService::set_url_title()
- From: Claudio Saavedra <csaavedra src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/history-rewrite: 19/28] Add tests for EphyHistoryService::set_url_title()
- Date: Thu, 7 Jul 2011 11:43:14 +0000 (UTC)
commit 212c0167a75043192dd12f9b7545914cfa6bcb81
Author: Claudio Saavedra <csaavedra igalia com>
Date: Tue Jul 5 13:42:07 2011 +0300
Add tests for EphyHistoryService::set_url_title()
tests/ephy-history.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 83 insertions(+), 0 deletions(-)
---
diff --git a/tests/ephy-history.c b/tests/ephy-history.c
index 8a6b3eb..29af83a 100644
--- a/tests/ephy-history.c
+++ b/tests/ephy-history.c
@@ -167,6 +167,86 @@ test_create_history_entries (void)
gtk_main ();
}
+static void
+get_url (EphyHistoryService *service, gboolean success, gpointer result_data, gpointer user_data)
+{
+ EphyHistoryURL *url = (EphyHistoryURL *) result_data;
+
+ g_assert (success == TRUE);
+ g_assert (url != NULL);
+ g_assert_cmpstr (url->title, ==, "GNOME");
+
+ ephy_history_url_free (url);
+ g_object_unref (service);
+ gtk_main_quit();
+}
+
+static void
+set_url_title (EphyHistoryService *service, gboolean success, gpointer result_data, gpointer user_data)
+{
+ gboolean test_result = GPOINTER_TO_INT (user_data);
+ g_assert (success == TRUE);
+
+ if (test_result == FALSE) {
+ g_object_unref (service);
+ gtk_main_quit ();
+ } else {
+ ephy_history_service_get_url (service, "http://www.gnome.org";, get_url, NULL);
+ }
+}
+
+static void
+set_url_title_visit_created (EphyHistoryService *service, gboolean success, gpointer result_data, gpointer user_data)
+{
+ ephy_history_service_set_url_title (service, "http://www.gnome.org";, "GNOME", set_url_title, user_data);
+}
+
+static void
+test_set_url_title_helper (gboolean test_results)
+{
+ gchar *temporary_file = g_build_filename (g_get_tmp_dir (), "epiphany-history-test.db", NULL);
+ EphyHistoryService *service = ensure_empty_history(temporary_file);
+
+ EphyHistoryPageVisit *visit = ephy_history_page_visit_new ("http://www.gnome.org";, 0, EPHY_PAGE_VISIT_TYPED);
+ ephy_history_service_add_visit (service, visit, set_url_title_visit_created, GINT_TO_POINTER (test_results));
+ ephy_history_page_visit_free (visit);
+ g_free (temporary_file);
+
+ gtk_main ();
+}
+
+static void
+test_set_url_title (void)
+{
+ test_set_url_title_helper (FALSE);
+}
+
+static void
+test_set_url_title_is_correct (void)
+{
+ test_set_url_title_helper (TRUE);
+}
+
+static void
+set_url_title_url_not_existent (EphyHistoryService *service, gboolean success, gpointer result_data, gpointer user_data)
+{
+ g_assert (success == FALSE);
+ g_object_unref (service);
+ gtk_main_quit ();
+}
+
+static void
+test_set_url_title_url_not_existent (void)
+{
+ gchar *temporary_file = g_build_filename (g_get_tmp_dir (), "epiphany-history-test.db", NULL);
+ EphyHistoryService *service = ensure_empty_history(temporary_file);
+ g_free (temporary_file);
+
+ ephy_history_service_set_url_title (service, "http://www.gnome.org";, "GNOME", set_url_title_url_not_existent, NULL);
+
+ gtk_main();
+}
+
int
main (int argc, char *argv[])
{
@@ -177,6 +257,9 @@ main (int argc, char *argv[])
g_test_add_func ("/embed/history/test_create_history_service_and_destroy_later", test_create_history_service_and_destroy_later);
g_test_add_func ("/embed/history/test_create_history_entry", test_create_history_entry);
g_test_add_func ("/embed/history/test_create_history_entries", test_create_history_entries);
+ g_test_add_func ("/embed/history/test_set_url_title", test_set_url_title);
+ g_test_add_func ("/embed/history/test_set_url_title_is_correct", test_set_url_title_is_correct);
+ g_test_add_func ("/embed/history/test_set_url_title_url_not_existent", test_set_url_title_url_not_existent);
return g_test_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]