aboutsummaryrefslogtreecommitdiffstats
path: root/tests/ephy-history.c
diff options
context:
space:
mode:
authorClaudio Saavedra <csaavedra@igalia.com>2012-01-11 01:19:20 +0800
committerXan Lopez <xan@igalia.com>2012-03-07 04:49:44 +0800
commit434b543fc0a8338cea33520cd29f0c6a1d06796d (patch)
treee0999c861da6a36ff234e789771bc49da71e548e /tests/ephy-history.c
parentbc31a416164021b133cf5403c53042cd3e94c7e6 (diff)
downloadgsoc2013-epiphany-434b543fc0a8338cea33520cd29f0c6a1d06796d.tar
gsoc2013-epiphany-434b543fc0a8338cea33520cd29f0c6a1d06796d.tar.gz
gsoc2013-epiphany-434b543fc0a8338cea33520cd29f0c6a1d06796d.tar.bz2
gsoc2013-epiphany-434b543fc0a8338cea33520cd29f0c6a1d06796d.tar.lz
gsoc2013-epiphany-434b543fc0a8338cea33520cd29f0c6a1d06796d.tar.xz
gsoc2013-epiphany-434b543fc0a8338cea33520cd29f0c6a1d06796d.tar.zst
gsoc2013-epiphany-434b543fc0a8338cea33520cd29f0c6a1d06796d.zip
tests: add a test for complex EphyHistoryQuery queries
Diffstat (limited to 'tests/ephy-history.c')
-rw-r--r--tests/ephy-history.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/ephy-history.c b/tests/ephy-history.c
index 0f2d2822c..89c9df038 100644
--- a/tests/ephy-history.c
+++ b/tests/ephy-history.c
@@ -305,6 +305,76 @@ test_get_url_not_existent (void)
test_get_url_helper (FALSE);
}
+static void
+verify_complex_url_query (EphyHistoryService *service,
+ gboolean success,
+ gpointer result_data,
+ gpointer user_data)
+{
+ EphyHistoryURL *url, *baseline;
+ GList *urls = (GList*) result_data;
+
+ /* Only one result expected. */
+ g_assert_cmpint (g_list_length (urls), ==, 1);
+
+ url = (EphyHistoryURL *) urls->data;
+ baseline = (EphyHistoryURL *) user_data;
+
+ g_assert_cmpstr (url->url, ==, baseline->url);
+ g_assert_cmpuint (url->visit_count, ==, baseline->visit_count);
+
+ g_object_unref (service);
+
+ gtk_main_quit();
+}
+
+static void
+perform_complex_url_query (EphyHistoryService *service,
+ gboolean success,
+ gpointer result_data,
+ gpointer user_data)
+{
+ EphyHistoryQuery *query;
+ EphyHistoryURL *url;
+
+ g_assert (success == TRUE);
+
+ /* Get the most visited site that contains 'k'. */
+ query = ephy_history_query_new ();
+ query->substring_list = g_list_prepend (query->substring_list, "k");
+ query->limit = 1;
+ query->sort_type = EPHY_HISTORY_SORT_MV;
+
+ /* The expected result. */
+ url = ephy_history_url_new ("http://www.wikipedia.org",
+ "Wikipedia",
+ 30, 30, 0, 1);
+
+ ephy_history_service_query_urls (service, query, verify_complex_url_query, url);
+}
+
+static void
+test_complex_url_query (void)
+{
+ gchar *temporary_file = g_build_filename (g_get_tmp_dir (), "epiphany-history-test.db", NULL);
+ EphyHistoryService *service = ensure_empty_history(temporary_file);
+ GList *visits = NULL;
+ int i;
+
+ for (i = 0; i < 10; i++)
+ visits = g_list_append (visits, ephy_history_page_visit_new ("http://www.gnome.org", 10 * i, EPHY_PAGE_VISIT_TYPED));
+ for (i = 0; i < 30; i++)
+ visits = g_list_append (visits, ephy_history_page_visit_new ("http://www.wikipedia.org", 10 * i, EPHY_PAGE_VISIT_TYPED));
+ for (i = 0; i < 20; i++)
+ visits = g_list_append (visits, ephy_history_page_visit_new ("http://www.freedesktop.org", 10 * i, EPHY_PAGE_VISIT_TYPED));
+ for (i = 0; i < 5; i++)
+ visits = g_list_append (visits, ephy_history_page_visit_new ("http://www.musicbrainz.org", 10 * i, EPHY_PAGE_VISIT_TYPED));
+
+ ephy_history_service_add_visits (service, visits, perform_complex_url_query, NULL);
+
+ gtk_main ();
+}
+
int
main (int argc, char *argv[])
{
@@ -319,6 +389,7 @@ main (int argc, char *argv[])
g_test_add_func ("/embed/history/test_set_url_title_url_not_existent", test_set_url_title_url_not_existent);
g_test_add_func ("/embed/history/test_get_url", test_get_url);
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);
return g_test_run ();
}