aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXan Lopez <xan@igalia.com>2012-09-08 18:43:10 +0800
committerXan Lopez <xan@igalia.com>2012-09-08 18:43:10 +0800
commite882b5de8be76fe1bb645f133151290a7057e379 (patch)
treed014521c7412c312892b2bd79c1b8b1fb05cb2e7
parentedbe1a014af2331b587d4a84f91d0f87fe17f5c8 (diff)
downloadgsoc2013-epiphany-e882b5de8be76fe1bb645f133151290a7057e379.tar
gsoc2013-epiphany-e882b5de8be76fe1bb645f133151290a7057e379.tar.gz
gsoc2013-epiphany-e882b5de8be76fe1bb645f133151290a7057e379.tar.bz2
gsoc2013-epiphany-e882b5de8be76fe1bb645f133151290a7057e379.tar.lz
gsoc2013-epiphany-e882b5de8be76fe1bb645f133151290a7057e379.tar.xz
gsoc2013-epiphany-e882b5de8be76fe1bb645f133151290a7057e379.tar.zst
gsoc2013-epiphany-e882b5de8be76fe1bb645f133151290a7057e379.zip
tests: basic tests for EphyCompletionModel
-rw-r--r--tests/Makefile.am4
-rw-r--r--tests/ephy-completion-model-test.c102
2 files changed, 106 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5ce8c1b74..3fd1000ea 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -2,6 +2,7 @@ SUBDIRS = data
noinst_PROGRAMS = \
test-ephy-bookmarks \
+ test-ephy-completion-model \
test-ephy-download \
test-ephy-embed-single \
test-ephy-embed-utils \
@@ -119,6 +120,9 @@ LDADD = \
test_ephy_bookmarks_SOURCES = \
ephy-bookmarks-test.c
+test_ephy_completion_model_SOURCES = \
+ ephy-completion-model-test.c
+
test_ephy_download_SOURCES = \
ephy-download-test.c
diff --git a/tests/ephy-completion-model-test.c b/tests/ephy-completion-model-test.c
new file mode 100644
index 000000000..06c222e64
--- /dev/null
+++ b/tests/ephy-completion-model-test.c
@@ -0,0 +1,102 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * Copyright © 2012 Igalia S.L.
+ *
+ * Epiphany is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Epiphany is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Epiphany; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "ephy-completion-model.h"
+
+#include "ephy-debug.h"
+#include "ephy-embed-prefs.h"
+#include "ephy-file-helpers.h"
+#include "ephy-private.h"
+#include "ephy-shell.h"
+
+static void
+test_ephy_completion_model_create ()
+{
+ EphyCompletionModel *model;
+ model = ephy_completion_model_new ();
+ g_assert (model);
+ g_object_unref (model);
+}
+
+static void
+update_empty_cb (EphyHistoryService *service,
+ gboolean success,
+ gpointer result_data,
+ GMainLoop *loop)
+{
+ GList *results = (GList*)result_data;
+
+ g_assert (success);
+ g_assert (results == NULL);
+
+ g_main_loop_quit (loop);
+}
+
+static void
+test_ephy_completion_model_update_empty ()
+{
+ EphyCompletionModel *model;
+ GMainLoop *loop = NULL;
+
+ model = ephy_completion_model_new ();
+ g_assert (model);
+
+ loop = g_main_loop_new (NULL, FALSE);
+
+ ephy_completion_model_update_for_string (model, "hello",
+ (EphyHistoryJobCallback)update_empty_cb,
+ loop);
+
+ g_main_loop_run (loop);
+
+ g_object_unref (model);
+ g_main_loop_unref (loop);
+}
+
+int
+main (int argc, char *argv[])
+{
+ gboolean ret;
+
+ gtk_test_init (&argc, &argv);
+ ephy_debug_init ();
+ ephy_embed_prefs_init ();
+
+ if (!ephy_file_helpers_init (NULL,
+ EPHY_FILE_HELPERS_PRIVATE_PROFILE | EPHY_FILE_HELPERS_ENSURE_EXISTS,
+ NULL)) {
+ g_debug ("Something wrong happened with ephy_file_helpers_init()");
+ return -1;
+ }
+
+ _ephy_shell_create_instance (EPHY_EMBED_SHELL_MODE_PRIVATE);
+
+ g_test_add_func ("/src/ephy-completion-model/create",
+ test_ephy_completion_model_create);
+
+ g_test_add_func ("/src/ephy-completion-model/update_empty",
+ test_ephy_completion_model_update_empty);
+
+ ret = g_test_run ();
+
+ return ret;
+}
+