[epiphany] tests: add a test for ephy_history_service_clear
- From: Xan Lopez <xan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] tests: add a test for ephy_history_service_clear
- Date: Tue, 6 Mar 2012 20:54:13 +0000 (UTC)
commit 0228d9597432c72f587b3f1c6f863a9e9f1d6a2b
Author: Xan Lopez <xan igalia com>
Date: Mon Mar 5 19:38:25 2012 +0100
tests: add a test for ephy_history_service_clear
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 8197cd1..8cdc575 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 ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]