aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudio Saavedra <csaavedra@igalia.com>2012-01-11 20:57:30 +0800
committerXan Lopez <xan@igalia.com>2012-03-07 04:49:44 +0800
commit994807b0751b2771dbbcd5881c78c10d29ba75b7 (patch)
treef39612ca4b2220d3b5fa32fe58f49183efd0f613
parent434b543fc0a8338cea33520cd29f0c6a1d06796d (diff)
downloadgsoc2013-epiphany-994807b0751b2771dbbcd5881c78c10d29ba75b7.tar
gsoc2013-epiphany-994807b0751b2771dbbcd5881c78c10d29ba75b7.tar.gz
gsoc2013-epiphany-994807b0751b2771dbbcd5881c78c10d29ba75b7.tar.bz2
gsoc2013-epiphany-994807b0751b2771dbbcd5881c78c10d29ba75b7.tar.lz
gsoc2013-epiphany-994807b0751b2771dbbcd5881c78c10d29ba75b7.tar.xz
gsoc2013-epiphany-994807b0751b2771dbbcd5881c78c10d29ba75b7.tar.zst
gsoc2013-epiphany-994807b0751b2771dbbcd5881c78c10d29ba75b7.zip
history-service: add a test for complex queries with visit time range
-rw-r--r--tests/ephy-history.c73
1 files changed, 63 insertions, 10 deletions
diff --git a/tests/ephy-history.c b/tests/ephy-history.c
index 89c9df038..1ff376741 100644
--- a/tests/ephy-history.c
+++ b/tests/ephy-history.c
@@ -305,6 +305,26 @@ test_get_url_not_existent (void)
test_get_url_helper (FALSE);
}
+static GList *
+create_visits_for_complex_tests (void)
+{
+ int i;
+ GList *visits = NULL;
+
+ 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));
+ for (i = 0; i < 2; i++)
+ visits = g_list_append (visits, ephy_history_page_visit_new ("http://www.webkitgtk.org", 1000 * i, EPHY_PAGE_VISIT_TYPED));
+
+ return visits;
+}
+
static void
verify_complex_url_query (EphyHistoryService *service,
gboolean success,
@@ -358,23 +378,55 @@ 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;
+ GList *visits;
- 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));
+ visits = create_visits_for_complex_tests ();
ephy_history_service_add_visits (service, visits, perform_complex_url_query, NULL);
gtk_main ();
}
+static void
+perform_complex_url_query_with_time_range (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' that was visited since timestamp 500. */
+ 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;
+ query->from = 500;
+
+ /* The expected result. */
+ url = ephy_history_url_new ("http://www.webkitgtk.org",
+ "WebKitGTK+",
+ 2, 2, 0, 1);
+
+ ephy_history_service_query_urls (service, query, verify_complex_url_query, url);
+}
+
+static void
+test_complex_url_query_with_time_range (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;
+
+ visits = create_visits_for_complex_tests ();
+
+ ephy_history_service_add_visits (service, visits, perform_complex_url_query_with_time_range, NULL);
+
+ gtk_main ();
+}
+
int
main (int argc, char *argv[])
{
@@ -390,6 +442,7 @@ main (int argc, char *argv[])
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);
+ g_test_add_func ("/embed/history/test_complex_url_query_with_time_range", test_complex_url_query_with_time_range);
return g_test_run ();
}