diff options
author | Xan Lopez <xan@igalia.com> | 2012-03-06 02:38:25 +0800 |
---|---|---|
committer | Xan Lopez <xan@igalia.com> | 2012-03-07 04:49:46 +0800 |
commit | 0228d9597432c72f587b3f1c6f863a9e9f1d6a2b (patch) | |
tree | e40f1bb37091ac89dfecd9ef621f4bb776b904b1 | |
parent | c6a4bd1fea0b15d25505bbe05883c3af104ee487 (diff) | |
download | gsoc2013-epiphany-0228d9597432c72f587b3f1c6f863a9e9f1d6a2b.tar gsoc2013-epiphany-0228d9597432c72f587b3f1c6f863a9e9f1d6a2b.tar.gz gsoc2013-epiphany-0228d9597432c72f587b3f1c6f863a9e9f1d6a2b.tar.bz2 gsoc2013-epiphany-0228d9597432c72f587b3f1c6f863a9e9f1d6a2b.tar.lz gsoc2013-epiphany-0228d9597432c72f587b3f1c6f863a9e9f1d6a2b.tar.xz gsoc2013-epiphany-0228d9597432c72f587b3f1c6f863a9e9f1d6a2b.tar.zst gsoc2013-epiphany-0228d9597432c72f587b3f1c6f863a9e9f1d6a2b.zip |
tests: add a test for ephy_history_service_clear
-rw-r--r-- | tests/ephy-history-test.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/ephy-history-test.c b/tests/ephy-history-test.c index 8197cd118..8cdc575c9 100644 --- a/tests/ephy-history-test.c +++ b/tests/ephy-history-test.c @@ -428,6 +428,54 @@ test_complex_url_query_with_time_range (void) gtk_main (); } +static void +verify_query_after_clear (EphyHistoryService *service, + gboolean success, + gpointer result_data, + gpointer user_data) +{ + GList *urls = (GList*)result_data; + + /* No results expected. */ + g_assert_cmpint (g_list_length (urls), ==, 0); + + g_object_unref (service); + + gtk_main_quit(); +} + +static void +perform_query_after_clear (EphyHistoryService *service, + gboolean success, + gpointer result_data, + gpointer user_data) +{ + EphyHistoryQuery *query; + + g_assert (success == TRUE); + + /* Get 10 random sites, the query should fail. */ + query = ephy_history_query_new (); + query->substring_list = g_list_prepend (query->substring_list, "gnome"); + query->limit = 10; + query->sort_type = EPHY_HISTORY_SORT_MV; + + ephy_history_service_query_urls (service, query, verify_query_after_clear, NULL); +} + +static void +test_clear () +{ + gchar *temporary_file = g_build_filename (g_get_tmp_dir (), "epiphany-history-test.db", NULL); + EphyHistoryService *service = ensure_empty_history (temporary_file); + GList *visits = create_test_page_visit_list (); + + ephy_history_service_add_visits (service, visits, NULL, NULL); + ephy_history_service_clear (service, perform_query_after_clear, NULL); + + gtk_main (); +} + int main (int argc, char *argv[]) { @@ -444,6 +492,7 @@ main (int argc, char *argv[]) g_test_add_func ("/embed/history/test_get_url_not_existent", test_get_url_not_existent); g_test_add_func ("/embed/history/test_complex_url_query", test_complex_url_query); g_test_add_func ("/embed/history/test_complex_url_query_with_time_range", test_complex_url_query_with_time_range); + g_test_add_func ("/embed/history/test_clear", test_clear); return g_test_run (); } |