[epiphany] tests: add a simple test for EphyEncodings



commit 174d04e8e9d530d8b19eb47af23e1fcfb8f26a5c
Author: Xan Lopez <xan igalia com>
Date:   Tue Jul 31 15:15:41 2012 +0200

    tests: add a simple test for EphyEncodings

 tests/Makefile.am           |    4 ++
 tests/ephy-encodings-test.c |   86 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 6ee0c7b..abaa936 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -4,6 +4,7 @@ noinst_PROGRAMS = \
 	test-ephy-download \
 	test-ephy-embed-single \
 	test-ephy-embed-utils \
+	test-ephy-encodings \
 	test-ephy-file-helpers \
 	test-ephy-history \
 	test-ephy-location-entry \
@@ -126,6 +127,9 @@ test_ephy_embed_single_SOURCES = \
 test_ephy_embed_utils_SOURCES = \
 	ephy-embed-utils-test.c
 
+test_ephy_encodings_SOURCES = \
+	ephy-encodings-test.c
+
 test_ephy_file_helpers_SOURCES = \
 	ephy-file-helpers-test.c
 test_ephy_file_helpers_CPPFLAGS = \
diff --git a/tests/ephy-encodings-test.c b/tests/ephy-encodings-test.c
new file mode 100644
index 0000000..d89c7b9
--- /dev/null
+++ b/tests/ephy-encodings-test.c
@@ -0,0 +1,86 @@
+/* -*- 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-debug.h"
+#include "ephy-embed-prefs.h"
+#include "ephy-encodings.h"
+#include "ephy-file-helpers.h"
+#include "ephy-private.h"
+#include "ephy-shell.h"
+
+#include <gtk/gtk.h>
+
+/* TODO: don't hardcode the number of encodings in ephy-encodings.c here! */
+#define NUM_ENCODINGS 78
+
+static void
+test_ephy_encodings_get ()
+{
+  EphyEncodings *encodings;
+  GList *all, *p;
+
+  encodings = EPHY_ENCODINGS (ephy_embed_shell_get_encodings (embed_shell));
+  g_assert (encodings);
+
+  all = ephy_encodings_get_all (encodings);
+  g_assert (all);
+  g_assert_cmpint (g_list_length (all), ==, NUM_ENCODINGS);
+
+  for (p = all; p; p = p->next) {
+    EphyEncoding *encoding = EPHY_ENCODING (p->data);
+    g_assert (encoding);
+    g_assert (EPHY_IS_ENCODING (encoding));
+  }
+
+  g_list_free (all);
+}
+
+int
+main (int argc, char *argv[])
+{
+  int 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_TEST);
+  g_assert (ephy_shell);
+
+  g_test_add_func ("/src/ephy-encodings/get",
+                   test_ephy_encodings_get);
+
+  ret = g_test_run ();
+
+  ephy_file_helpers_shutdown ();
+  g_object_unref (ephy_shell);
+
+  return ret;
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]