From afcf0e11ff0a73874ca41bd0324e8292e695b28a Mon Sep 17 00:00:00 2001 From: Diego Escalante Urrelo Date: Tue, 7 Feb 2012 05:37:39 -0500 Subject: tests: rename files to avoid duplicate names Append -test to .c files in tests/ to avoid duplicating filenames in the repository. https://bugzilla.gnome.org/show_bug.cgi?id=669766 --- tests/Makefile.am | 10 +- tests/ephy-download-test.c | 212 +++++++++++++++++++++++++++++++++++++++ tests/ephy-download.c | 212 --------------------------------------- tests/ephy-embed-single-test.c | 123 +++++++++++++++++++++++ tests/ephy-embed-single.c | 123 ----------------------- tests/ephy-embed-utils-test.c | 152 ++++++++++++++++++++++++++++ tests/ephy-embed-utils.c | 152 ---------------------------- tests/ephy-location-entry-test.c | 162 ++++++++++++++++++++++++++++++ tests/ephy-location-entry.c | 162 ------------------------------ tests/ephy-search-entry-test.c | 74 ++++++++++++++ tests/ephy-search-entry.c | 74 -------------- 11 files changed, 728 insertions(+), 728 deletions(-) create mode 100644 tests/ephy-download-test.c delete mode 100644 tests/ephy-download.c create mode 100644 tests/ephy-embed-single-test.c delete mode 100644 tests/ephy-embed-single.c create mode 100644 tests/ephy-embed-utils-test.c delete mode 100644 tests/ephy-embed-utils.c create mode 100644 tests/ephy-location-entry-test.c delete mode 100644 tests/ephy-location-entry.c create mode 100644 tests/ephy-search-entry-test.c delete mode 100644 tests/ephy-search-entry.c (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index e51cf2121..73a08171e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -105,16 +105,16 @@ LDADD += \ endif test_ephy_download_SOURCES = \ - ephy-download.c + ephy-download-test.c test_ephy_embed_single_SOURCES = \ - ephy-embed-single.c + ephy-embed-single-test.c test_ephy_embed_utils_SOURCES = \ - ephy-embed-utils.c + ephy-embed-utils-test.c test_ephy_location_entry_SOURCES = \ - ephy-location-entry.c + ephy-location-entry-test.c test_ephy_search_entry_SOURCES = \ - ephy-search-entry.c + ephy-search-entry-test.c diff --git a/tests/ephy-download-test.c b/tests/ephy-download-test.c new file mode 100644 index 000000000..2ebb08a32 --- /dev/null +++ b/tests/ephy-download-test.c @@ -0,0 +1,212 @@ +/* vim: set sw=2 ts=2 sts=2 et: */ +/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * ephy-download-test.c + * This file is part of Epiphany + * + * Copyright © 2011 - 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-download.h" +#include "ephy-embed-prefs.h" +#include "ephy-file-helpers.h" +#include "ephy-shell.h" + +#include +#include +#include +#include + +#define HTML_STRING "testing-ephy-download" +SoupURI *base_uri; + +static char * +get_uri_for_path (const char *path) +{ + SoupURI *uri; + char *uri_string; + + uri = soup_uri_new_with_base (base_uri, path); + uri_string = soup_uri_to_string (uri, FALSE); + soup_uri_free (uri); + + return uri_string; +} + +static void +server_callback (SoupServer *server, + SoupMessage *msg, + const char *path, + GHashTable *query, + SoupClientContext *context, + gpointer data) +{ + soup_message_set_status (msg, SOUP_STATUS_OK); + + if (g_str_equal (path, "/cancelled")) + soup_message_set_status (msg, SOUP_STATUS_CANT_CONNECT); + + soup_message_body_append (msg->response_body, SOUP_MEMORY_STATIC, + HTML_STRING, strlen (HTML_STRING)); + + soup_message_body_complete (msg->response_body); +} + +typedef struct { + GMainLoop *loop; + EphyDownload *download; + char *destination; + char *source; +} Fixture; + +static void +fixture_setup (Fixture *fixture, gconstpointer data) +{ + char *tmp_filename; + char *dest_file; + + tmp_filename = ephy_file_tmp_filename ("ephy-download-XXXXXX", NULL); + dest_file = g_build_filename (ephy_file_tmp_dir (), tmp_filename, NULL); + + fixture->source = get_uri_for_path ("/default"); + fixture->download = ephy_download_new_for_uri (fixture->source); + fixture->destination = g_filename_to_uri (dest_file, NULL, NULL); + fixture->loop = g_main_loop_new (NULL, TRUE); + + ephy_download_set_destination_uri (fixture->download, fixture->destination); + + g_free (tmp_filename); + g_free (dest_file); +} + +static void +fixture_teardown (Fixture *fixture, gconstpointer data) +{ + g_free (fixture->destination); + g_free (fixture->source); + + g_object_unref (fixture->download); + + g_main_loop_unref (fixture->loop); +} + +static gboolean +test_file_was_downloaded (EphyDownload *download) +{ + char *filename; + gboolean ret; + + filename = g_filename_from_uri (ephy_download_get_destination_uri (download), + NULL, NULL); + + ret = g_file_test (filename, G_FILE_TEST_EXISTS); + g_free (filename); + + return ret; +} + +static void +completed_cb (EphyDownload *download, + Fixture *fixture) +{ + g_assert (test_file_was_downloaded (download)); + g_main_loop_quit (fixture->loop); +} + +static void +test_ephy_download_new (Fixture *fixture, gconstpointer data) +{ + g_assert (EPHY_IS_DOWNLOAD (fixture->download)); +} + +static void +test_ephy_download_new_for_uri (Fixture *fixture, gconstpointer data) +{ + EphyDownload *download; + + download = ephy_download_new_for_uri (fixture->source); + + g_assert (EPHY_IS_DOWNLOAD (download)); + + g_assert_cmpstr (fixture->source, ==, ephy_download_get_source_uri (download)); + + g_signal_connect (G_OBJECT (download), "completed", + G_CALLBACK (completed_cb), fixture); + + ephy_download_start (download); + + g_object_unref (fixture->download); + fixture->download = download; + + g_main_loop_run (fixture->loop); +} + +static void +test_ephy_download_start (Fixture *fixture, gconstpointer data) +{ + g_signal_connect (G_OBJECT (fixture->download), "completed", + G_CALLBACK (completed_cb), fixture); + + ephy_download_start (fixture->download); + g_main_loop_run (fixture->loop); +} + +int +main (int argc, char *argv[]) +{ + int ret; + SoupServer *server; + + gtk_test_init (&argc, &argv); + + ephy_debug_init (); + ephy_embed_prefs_init (); + _ephy_shell_create_instance (FALSE); + + if (!ephy_file_helpers_init (NULL, TRUE, FALSE, NULL)) { + g_debug ("Something wrong happened with ephy_file_helpers_init()"); + return -1; + } + + server = soup_server_new (SOUP_SERVER_PORT, 0, NULL); + soup_server_run_async (server); + + base_uri = soup_uri_new ("http://127.0.0.1/"); + soup_uri_set_port (base_uri, soup_server_get_port (server)); + + soup_server_add_handler (server, NULL, server_callback, NULL, NULL); + + g_test_add ("/embed/ephy-download/new", + Fixture, NULL, fixture_setup, + test_ephy_download_new, fixture_teardown); + g_test_add ("/embed/ephy-download/new_for_uri", + Fixture, NULL, fixture_setup, + test_ephy_download_new_for_uri, fixture_teardown); + g_test_add ("/embed/ephy-download/start", + Fixture, NULL, fixture_setup, + test_ephy_download_start, fixture_teardown); + + ret = g_test_run (); + + g_object_unref (ephy_shell); + ephy_file_helpers_shutdown (); + + return ret; +} diff --git a/tests/ephy-download.c b/tests/ephy-download.c deleted file mode 100644 index ac40927b9..000000000 --- a/tests/ephy-download.c +++ /dev/null @@ -1,212 +0,0 @@ -/* vim: set sw=2 ts=2 sts=2 et: */ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* - * ephy-download.c - * This file is part of Epiphany - * - * Copyright © 2011 - 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-download.h" -#include "ephy-embed-prefs.h" -#include "ephy-file-helpers.h" -#include "ephy-shell.h" - -#include -#include -#include -#include - -#define HTML_STRING "testing-ephy-download" -SoupURI *base_uri; - -static char * -get_uri_for_path (const char *path) -{ - SoupURI *uri; - char *uri_string; - - uri = soup_uri_new_with_base (base_uri, path); - uri_string = soup_uri_to_string (uri, FALSE); - soup_uri_free (uri); - - return uri_string; -} - -static void -server_callback (SoupServer *server, - SoupMessage *msg, - const char *path, - GHashTable *query, - SoupClientContext *context, - gpointer data) -{ - soup_message_set_status (msg, SOUP_STATUS_OK); - - if (g_str_equal (path, "/cancelled")) - soup_message_set_status (msg, SOUP_STATUS_CANT_CONNECT); - - soup_message_body_append (msg->response_body, SOUP_MEMORY_STATIC, - HTML_STRING, strlen (HTML_STRING)); - - soup_message_body_complete (msg->response_body); -} - -typedef struct { - GMainLoop *loop; - EphyDownload *download; - char *destination; - char *source; -} Fixture; - -static void -fixture_setup (Fixture *fixture, gconstpointer data) -{ - char *tmp_filename; - char *dest_file; - - tmp_filename = ephy_file_tmp_filename ("ephy-download-XXXXXX", NULL); - dest_file = g_build_filename (ephy_file_tmp_dir (), tmp_filename, NULL); - - fixture->source = get_uri_for_path ("/default"); - fixture->download = ephy_download_new_for_uri (fixture->source); - fixture->destination = g_filename_to_uri (dest_file, NULL, NULL); - fixture->loop = g_main_loop_new (NULL, TRUE); - - ephy_download_set_destination_uri (fixture->download, fixture->destination); - - g_free (tmp_filename); - g_free (dest_file); -} - -static void -fixture_teardown (Fixture *fixture, gconstpointer data) -{ - g_free (fixture->destination); - g_free (fixture->source); - - g_object_unref (fixture->download); - - g_main_loop_unref (fixture->loop); -} - -static gboolean -test_file_was_downloaded (EphyDownload *download) -{ - char *filename; - gboolean ret; - - filename = g_filename_from_uri (ephy_download_get_destination_uri (download), - NULL, NULL); - - ret = g_file_test (filename, G_FILE_TEST_EXISTS); - g_free (filename); - - return ret; -} - -static void -completed_cb (EphyDownload *download, - Fixture *fixture) -{ - g_assert (test_file_was_downloaded (download)); - g_main_loop_quit (fixture->loop); -} - -static void -test_ephy_download_new (Fixture *fixture, gconstpointer data) -{ - g_assert (EPHY_IS_DOWNLOAD (fixture->download)); -} - -static void -test_ephy_download_new_for_uri (Fixture *fixture, gconstpointer data) -{ - EphyDownload *download; - - download = ephy_download_new_for_uri (fixture->source); - - g_assert (EPHY_IS_DOWNLOAD (download)); - - g_assert_cmpstr (fixture->source, ==, ephy_download_get_source_uri (download)); - - g_signal_connect (G_OBJECT (download), "completed", - G_CALLBACK (completed_cb), fixture); - - ephy_download_start (download); - - g_object_unref (fixture->download); - fixture->download = download; - - g_main_loop_run (fixture->loop); -} - -static void -test_ephy_download_start (Fixture *fixture, gconstpointer data) -{ - g_signal_connect (G_OBJECT (fixture->download), "completed", - G_CALLBACK (completed_cb), fixture); - - ephy_download_start (fixture->download); - g_main_loop_run (fixture->loop); -} - -int -main (int argc, char *argv[]) -{ - int ret; - SoupServer *server; - - gtk_test_init (&argc, &argv); - - ephy_debug_init (); - ephy_embed_prefs_init (); - _ephy_shell_create_instance (FALSE); - - if (!ephy_file_helpers_init (NULL, TRUE, FALSE, NULL)) { - g_debug ("Something wrong happened with ephy_file_helpers_init()"); - return -1; - } - - server = soup_server_new (SOUP_SERVER_PORT, 0, NULL); - soup_server_run_async (server); - - base_uri = soup_uri_new ("http://127.0.0.1/"); - soup_uri_set_port (base_uri, soup_server_get_port (server)); - - soup_server_add_handler (server, NULL, server_callback, NULL, NULL); - - g_test_add ("/embed/ephy-download/new", - Fixture, NULL, fixture_setup, - test_ephy_download_new, fixture_teardown); - g_test_add ("/embed/ephy-download/new_for_uri", - Fixture, NULL, fixture_setup, - test_ephy_download_new_for_uri, fixture_teardown); - g_test_add ("/embed/ephy-download/start", - Fixture, NULL, fixture_setup, - test_ephy_download_start, fixture_teardown); - - ret = g_test_run (); - - g_object_unref (ephy_shell); - ephy_file_helpers_shutdown (); - - return ret; -} diff --git a/tests/ephy-embed-single-test.c b/tests/ephy-embed-single-test.c new file mode 100644 index 000000000..a433a40e7 --- /dev/null +++ b/tests/ephy-embed-single-test.c @@ -0,0 +1,123 @@ +/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set sw=2 ts=2 sts=2 et: */ +/* + * ephy-embed-single-test.c + * This file is part of Epiphany + * + * Copyright © 2010 - 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-single.h" +#include "ephy-embed-prefs.h" +#include "ephy-file-helpers.h" +#include "ephy-shell.h" +#include + +static void +test_embed_single_new () +{ + EphyEmbedSingle *single; + + single = EPHY_EMBED_SINGLE (g_object_new (EPHY_TYPE_EMBED_SINGLE, NULL)); + g_assert (EPHY_IS_EMBED_SINGLE (single)); + + g_object_unref (single); +} + +static void +test_embed_single_get_from_shell () +{ + EphyEmbedSingle *single; + + single = EPHY_EMBED_SINGLE (ephy_embed_shell_get_embed_single (embed_shell)); + g_assert (EPHY_IS_EMBED_SINGLE (single)); +} + +static void +test_embed_single_network_status () +{ + EphyEmbedSingle *single; + + single = EPHY_EMBED_SINGLE (ephy_embed_shell_get_embed_single (embed_shell)); + g_assert (EPHY_IS_EMBED_SINGLE (single)); + + /* Defaults to TRUE */ + g_assert (ephy_embed_single_get_network_status (single)); + + ephy_embed_single_set_network_status (single, FALSE); + g_assert (ephy_embed_single_get_network_status (single) == FALSE); +} + +static void +test_embed_single_form_auth () +{ + EphyEmbedSingle *single; + GSList *results = NULL; + + single = EPHY_EMBED_SINGLE (g_object_new (EPHY_TYPE_EMBED_SINGLE, NULL)); + g_assert (EPHY_IS_EMBED_SINGLE (single)); + + results = ephy_embed_single_get_form_auth (single, "gnome.org"); + g_assert_cmpint (g_slist_length (results), ==, 0); + + ephy_embed_single_add_form_auth (single, "gnome.org", + "form_username_field", "form_password_field", + "username"); + + results = ephy_embed_single_get_form_auth (single, "gnome.org"); + g_assert_cmpint (g_slist_length (results), ==, 1); + + results = ephy_embed_single_get_form_auth (single, "www.gnome.org"); + g_assert_cmpint (g_slist_length (results), ==, 0); + + g_object_unref (single); +} + +int +main (int argc, char *argv[]) +{ + int ret; + + gtk_test_init (&argc, &argv); + + ephy_debug_init (); + ephy_embed_prefs_init (); + _ephy_shell_create_instance (FALSE); + + if (!ephy_file_helpers_init (NULL, TRUE, FALSE, NULL)) { + g_debug ("Something wrong happened with ephy_file_helpers_init()"); + return -1; + } + + g_test_add_func ("/embed/ephy-embed-single/new", + test_embed_single_new); + g_test_add_func ("/embed/ephy-embed-single/get_from_shell", + test_embed_single_get_from_shell); + g_test_add_func ("/embed/ephy-embed-single/network_status", + test_embed_single_network_status); + g_test_add_func ("/embed/ephy-embed-single/form_auth", + test_embed_single_form_auth); + + ret = g_test_run (); + + ephy_file_helpers_shutdown (); + + return ret; +} diff --git a/tests/ephy-embed-single.c b/tests/ephy-embed-single.c deleted file mode 100644 index 03ad035cf..000000000 --- a/tests/ephy-embed-single.c +++ /dev/null @@ -1,123 +0,0 @@ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set sw=2 ts=2 sts=2 et: */ -/* - * ephy-embed-persist.c - * This file is part of Epiphany - * - * Copyright © 2010 - 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-single.h" -#include "ephy-embed-prefs.h" -#include "ephy-file-helpers.h" -#include "ephy-shell.h" -#include - -static void -test_embed_single_new () -{ - EphyEmbedSingle *single; - - single = EPHY_EMBED_SINGLE (g_object_new (EPHY_TYPE_EMBED_SINGLE, NULL)); - g_assert (EPHY_IS_EMBED_SINGLE (single)); - - g_object_unref (single); -} - -static void -test_embed_single_get_from_shell () -{ - EphyEmbedSingle *single; - - single = EPHY_EMBED_SINGLE (ephy_embed_shell_get_embed_single (embed_shell)); - g_assert (EPHY_IS_EMBED_SINGLE (single)); -} - -static void -test_embed_single_network_status () -{ - EphyEmbedSingle *single; - - single = EPHY_EMBED_SINGLE (ephy_embed_shell_get_embed_single (embed_shell)); - g_assert (EPHY_IS_EMBED_SINGLE (single)); - - /* Defaults to TRUE */ - g_assert (ephy_embed_single_get_network_status (single)); - - ephy_embed_single_set_network_status (single, FALSE); - g_assert (ephy_embed_single_get_network_status (single) == FALSE); -} - -static void -test_embed_single_form_auth () -{ - EphyEmbedSingle *single; - GSList *results = NULL; - - single = EPHY_EMBED_SINGLE (g_object_new (EPHY_TYPE_EMBED_SINGLE, NULL)); - g_assert (EPHY_IS_EMBED_SINGLE (single)); - - results = ephy_embed_single_get_form_auth (single, "gnome.org"); - g_assert_cmpint (g_slist_length (results), ==, 0); - - ephy_embed_single_add_form_auth (single, "gnome.org", - "form_username_field", "form_password_field", - "username"); - - results = ephy_embed_single_get_form_auth (single, "gnome.org"); - g_assert_cmpint (g_slist_length (results), ==, 1); - - results = ephy_embed_single_get_form_auth (single, "www.gnome.org"); - g_assert_cmpint (g_slist_length (results), ==, 0); - - g_object_unref (single); -} - -int -main (int argc, char *argv[]) -{ - int ret; - - gtk_test_init (&argc, &argv); - - ephy_debug_init (); - ephy_embed_prefs_init (); - _ephy_shell_create_instance (FALSE); - - if (!ephy_file_helpers_init (NULL, TRUE, FALSE, NULL)) { - g_debug ("Something wrong happened with ephy_file_helpers_init()"); - return -1; - } - - g_test_add_func ("/embed/ephy-embed-single/new", - test_embed_single_new); - g_test_add_func ("/embed/ephy-embed-single/get_from_shell", - test_embed_single_get_from_shell); - g_test_add_func ("/embed/ephy-embed-single/network_status", - test_embed_single_network_status); - g_test_add_func ("/embed/ephy-embed-single/form_auth", - test_embed_single_form_auth); - - ret = g_test_run (); - - ephy_file_helpers_shutdown (); - - return ret; -} diff --git a/tests/ephy-embed-utils-test.c b/tests/ephy-embed-utils-test.c new file mode 100644 index 000000000..122087f26 --- /dev/null +++ b/tests/ephy-embed-utils-test.c @@ -0,0 +1,152 @@ +/* vim: set sw=2 ts=2 sts=2 et: */ +/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * ephy-embed-utils-test.c + * This file is part of Epiphany + * + * 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-embed-utils.h" +#include +#include + +typedef struct { + const char *name; + const char *test; +} SchemeTest; + +typedef struct { + const char *name; + const char *test; + const char *result; +} NormalizeTest; + +static const SchemeTest tests_has_scheme[] = { + { "http", "http://www.gnome.org/" }, + { "http_with_port", "http://www.gnome.org:8080" }, + { "https", "https://www.gnome.org/" }, + { "http_caps", "HTTP://www.gnome.org/" }, + { "ftp_with_user", "ftp://rupert:bananas@ftp.gnome.org/epiphany/" }, + { "file", "file:///home/epiphany/code" }, + { "javascript", "javascript:var a=b;" }, + { "data", "data:\%20\%40" }, + { "about", "about:epiphany" }, + { "ephy-about", "ephy-about:memory" }, + { "gopher", "gopher://gnome.org/" }, +}; + +static const SchemeTest tests_no_scheme[] = { + { "mailto", "mailto:rupert@gnome.org" }, + { "hostname", "localhost" }, + { "hostname_with_port", "localhost:8080" }, + { "http_no_double_colon", "http//www.gnome.org/" }, +#if 0 + { "double_colon_first", ":var a=b;" }, +#endif + { "double_double_colon", "epip:hany-about:memory" }, + { "slashes_first", "//localhost:8080" }, + { "unknown_scheme", "pher://gnome.org/" }, + { "unknown_scheme_with_user", "whatever://rup:ert@gnome.org" }, + { "empty_string", "" }, +}; + +static const NormalizeTest tests_normalize[] = { + { "append_http_to_domain", "gnome.org", "http://gnome.org" }, + { "append_http_to_www", "www.gnome.org", "http://www.gnome.org" }, + { "append_http_to_domain_port", "gnome.org:80", "http://gnome.org:80" }, + { "append_http_to_hostname", "gnome", "http://gnome" }, + { "append_http_to_hostname_with_port", "localhost:8080", "http://localhost:8080" }, + { "convert_about_to_ephy_about", "about:epiphany", "ephy-about:epiphany" }, + { "untouched_http", "http://gnome.org", "http://gnome.org" }, +}; + +static void +test_address_no_web_scheme (const char *test) +{ + g_assert (ephy_embed_utils_address_has_web_scheme (test) == FALSE); +} + +static void +test_address_has_web_scheme (const char *test) +{ + g_assert (ephy_embed_utils_address_has_web_scheme (test) == TRUE); +} + +static void +test_normalize_address (const NormalizeTest *test) +{ + char *normalized; + + normalized = ephy_embed_utils_normalize_address (test->test); + + g_assert_cmpstr (test->result, ==, normalized); + g_free (normalized); +} + +int +main (int argc, char *argv[]) +{ + int i; + gtk_test_init (&argc, &argv); + + for (i = 0; i < G_N_ELEMENTS (tests_has_scheme); i++) { + SchemeTest test; + char *test_name; + + test = tests_has_scheme[i]; + test_name = g_strconcat ("/embed/ephy-embed-utils/has_web_scheme_", + test.name, NULL); + + g_test_add_data_func (test_name, test.test, + (GTestDataFunc) test_address_has_web_scheme); + + g_free (test_name); + } + + for (i = 0; i < G_N_ELEMENTS (tests_no_scheme); i++) { + SchemeTest test; + char *test_name; + + test = tests_no_scheme[i]; + test_name = g_strconcat ("/embed/ephy-embed-utils/no_web_scheme_", + test.name, NULL); + + g_test_add_data_func (test_name, test.test, + (GTestDataFunc) test_address_no_web_scheme); + + g_free (test_name); + } + + for (i = 0; i < G_N_ELEMENTS (tests_normalize); i++) { + NormalizeTest test; + char *test_name; + + test = tests_normalize[i]; + test_name = g_strconcat ("/embed/ephy-embed-utils/normalize_", + test.name, NULL); + + g_test_add_data_func (test_name, &test, + (GTestDataFunc) test_normalize_address); + + g_free (test_name); + } + + return g_test_run (); +} diff --git a/tests/ephy-embed-utils.c b/tests/ephy-embed-utils.c deleted file mode 100644 index c75b8edc3..000000000 --- a/tests/ephy-embed-utils.c +++ /dev/null @@ -1,152 +0,0 @@ -/* vim: set sw=2 ts=2 sts=2 et: */ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* - * ephy-embed-utils.c - * This file is part of Epiphany - * - * 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-embed-utils.h" -#include -#include - -typedef struct { - const char *name; - const char *test; -} SchemeTest; - -typedef struct { - const char *name; - const char *test; - const char *result; -} NormalizeTest; - -static const SchemeTest tests_has_scheme[] = { - { "http", "http://www.gnome.org/" }, - { "http_with_port", "http://www.gnome.org:8080" }, - { "https", "https://www.gnome.org/" }, - { "http_caps", "HTTP://www.gnome.org/" }, - { "ftp_with_user", "ftp://rupert:bananas@ftp.gnome.org/epiphany/" }, - { "file", "file:///home/epiphany/code" }, - { "javascript", "javascript:var a=b;" }, - { "data", "data:\%20\%40" }, - { "about", "about:epiphany" }, - { "ephy-about", "ephy-about:memory" }, - { "gopher", "gopher://gnome.org/" }, -}; - -static const SchemeTest tests_no_scheme[] = { - { "mailto", "mailto:rupert@gnome.org" }, - { "hostname", "localhost" }, - { "hostname_with_port", "localhost:8080" }, - { "http_no_double_colon", "http//www.gnome.org/" }, -#if 0 - { "double_colon_first", ":var a=b;" }, -#endif - { "double_double_colon", "epip:hany-about:memory" }, - { "slashes_first", "//localhost:8080" }, - { "unknown_scheme", "pher://gnome.org/" }, - { "unknown_scheme_with_user", "whatever://rup:ert@gnome.org" }, - { "empty_string", "" }, -}; - -static const NormalizeTest tests_normalize[] = { - { "append_http_to_domain", "gnome.org", "http://gnome.org" }, - { "append_http_to_www", "www.gnome.org", "http://www.gnome.org" }, - { "append_http_to_domain_port", "gnome.org:80", "http://gnome.org:80" }, - { "append_http_to_hostname", "gnome", "http://gnome" }, - { "append_http_to_hostname_with_port", "localhost:8080", "http://localhost:8080" }, - { "convert_about_to_ephy_about", "about:epiphany", "ephy-about:epiphany" }, - { "untouched_http", "http://gnome.org", "http://gnome.org" }, -}; - -static void -test_address_no_web_scheme (const char *test) -{ - g_assert (ephy_embed_utils_address_has_web_scheme (test) == FALSE); -} - -static void -test_address_has_web_scheme (const char *test) -{ - g_assert (ephy_embed_utils_address_has_web_scheme (test) == TRUE); -} - -static void -test_normalize_address (const NormalizeTest *test) -{ - char *normalized; - - normalized = ephy_embed_utils_normalize_address (test->test); - - g_assert_cmpstr (test->result, ==, normalized); - g_free (normalized); -} - -int -main (int argc, char *argv[]) -{ - int i; - gtk_test_init (&argc, &argv); - - for (i = 0; i < G_N_ELEMENTS (tests_has_scheme); i++) { - SchemeTest test; - char *test_name; - - test = tests_has_scheme[i]; - test_name = g_strconcat ("/embed/ephy-embed-utils/has_web_scheme_", - test.name, NULL); - - g_test_add_data_func (test_name, test.test, - (GTestDataFunc) test_address_has_web_scheme); - - g_free (test_name); - } - - for (i = 0; i < G_N_ELEMENTS (tests_no_scheme); i++) { - SchemeTest test; - char *test_name; - - test = tests_no_scheme[i]; - test_name = g_strconcat ("/embed/ephy-embed-utils/no_web_scheme_", - test.name, NULL); - - g_test_add_data_func (test_name, test.test, - (GTestDataFunc) test_address_no_web_scheme); - - g_free (test_name); - } - - for (i = 0; i < G_N_ELEMENTS (tests_normalize); i++) { - NormalizeTest test; - char *test_name; - - test = tests_normalize[i]; - test_name = g_strconcat ("/embed/ephy-embed-utils/normalize_", - test.name, NULL); - - g_test_add_data_func (test_name, &test, - (GTestDataFunc) test_normalize_address); - - g_free (test_name); - } - - return g_test_run (); -} diff --git a/tests/ephy-location-entry-test.c b/tests/ephy-location-entry-test.c new file mode 100644 index 000000000..d22034f34 --- /dev/null +++ b/tests/ephy-location-entry-test.c @@ -0,0 +1,162 @@ +/* vim: set sw=2 ts=2 sts=2 et: */ +/* + * ephy-location-entry-test.c + * This file is part of Epiphany + * + * Copyright © 2008 - Diego Escalante Urrelo + * + * 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-location-entry.h" +#include +#include + +static void +test_entry_new (void) +{ + GtkWidget *entry; + entry = ephy_location_entry_new (); + + g_assert (GTK_IS_WIDGET (entry)); + g_assert (EPHY_IS_LOCATION_ENTRY (entry)); +} + +static void +test_entry_get_entry (void) +{ + EphyLocationEntry *entry; + entry = EPHY_LOCATION_ENTRY (ephy_location_entry_new ()); + + g_assert (GTK_IS_ENTRY (entry)); +} + +static void +test_entry_set_location (void) +{ + const char *set = "test"; + const char *get; + + EphyLocationEntry *entry; + entry = EPHY_LOCATION_ENTRY (ephy_location_entry_new ()); + + ephy_location_entry_set_location (entry, set); + get = ephy_location_entry_get_location (entry); + g_assert_cmpstr (set, ==, get); +} + +static void +test_entry_set_location_null (void) +{ + const char *set = "test"; + const char *get; + + EphyLocationEntry *entry; + entry = EPHY_LOCATION_ENTRY (ephy_location_entry_new ()); + + ephy_location_entry_set_location (entry, NULL); + get = ephy_location_entry_get_location (entry); + g_assert_cmpstr (set, !=, get); +} + +static void +test_entry_get_location (void) +{ + const char *set = "test"; + const char *get; + + EphyLocationEntry *entry; + entry = EPHY_LOCATION_ENTRY (ephy_location_entry_new ()); + + ephy_location_entry_set_location (entry, set); + get = ephy_location_entry_get_location (entry); + g_assert_cmpstr (set, ==, get); +} + +static void +test_entry_get_location_empty (void) +{ + const char *get; + + EphyLocationEntry *entry; + entry = EPHY_LOCATION_ENTRY (ephy_location_entry_new ()); + + get = ephy_location_entry_get_location (entry); + g_assert_cmpstr ("", ==, get); +} + +static void +test_entry_can_undo (void) +{ + const char *test = "test"; + + EphyLocationEntry *entry; + entry = EPHY_LOCATION_ENTRY (ephy_location_entry_new ()); + + g_assert_cmpint (ephy_location_entry_get_can_undo (entry), ==, FALSE); + + /* Use gtk_* function or otherwise user_changed won't be correctly handled + * internally by the location entry (see editable_changed_cb and + * block_update) */ + gtk_entry_set_text (GTK_ENTRY (entry), test); + g_assert_cmpint (ephy_location_entry_get_can_undo (entry), ==, TRUE); +} + +static void +test_entry_can_redo (void) +{ + const char *test = "test"; + + EphyLocationEntry *entry; + entry = EPHY_LOCATION_ENTRY (ephy_location_entry_new ()); + g_assert_cmpint (ephy_location_entry_get_can_redo (entry), ==, FALSE); + + /* Can't redo, in this point we can undo */ + ephy_location_entry_set_location (entry, test); + g_assert_cmpint (ephy_location_entry_get_can_redo (entry), ==, FALSE); + + /* Reset should set redo to TRUE */ + ephy_location_entry_reset (entry); + g_assert_cmpint (ephy_location_entry_get_can_redo (entry), ==, TRUE); +} + +int +main (int argc, char *argv[]) +{ + gtk_test_init (&argc, &argv); + ephy_debug_init (); + + g_test_add_func ("/lib/widgets/ephy-location-entry/new", + test_entry_new); + g_test_add_func ("/lib/widgets/ephy-location-entry/get_entry", + test_entry_get_entry); + g_test_add_func ("/lib/widgets/ephy-location-entry/set_location", + test_entry_set_location); + g_test_add_func ("/lib/widgets/ephy-location-entry/get_location", + test_entry_get_location); + g_test_add_func ("/lib/widgets/ephy-location-entry/set_location_null", + test_entry_set_location_null); + g_test_add_func ("/lib/widgets/ephy-location-entry/get_location_empty", + test_entry_get_location_empty); + g_test_add_func ("/lib/widgets/ephy-location-entry/can_undo", + test_entry_can_undo); + g_test_add_func ("/lib/widgets/ephy-location-entry/can_redo", + test_entry_can_redo); + + return g_test_run (); +} diff --git a/tests/ephy-location-entry.c b/tests/ephy-location-entry.c deleted file mode 100644 index 159a7a49a..000000000 --- a/tests/ephy-location-entry.c +++ /dev/null @@ -1,162 +0,0 @@ -/* vim: set sw=2 ts=2 sts=2 et: */ -/* - * ephy-location-entry.c - * This file is part of Epiphany - * - * Copyright © 2008 - Diego Escalante Urrelo - * - * 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-location-entry.h" -#include -#include - -static void -test_entry_new (void) -{ - GtkWidget *entry; - entry = ephy_location_entry_new (); - - g_assert (GTK_IS_WIDGET (entry)); - g_assert (EPHY_IS_LOCATION_ENTRY (entry)); -} - -static void -test_entry_get_entry (void) -{ - EphyLocationEntry *entry; - entry = EPHY_LOCATION_ENTRY (ephy_location_entry_new ()); - - g_assert (GTK_IS_ENTRY (entry)); -} - -static void -test_entry_set_location (void) -{ - const char *set = "test"; - const char *get; - - EphyLocationEntry *entry; - entry = EPHY_LOCATION_ENTRY (ephy_location_entry_new ()); - - ephy_location_entry_set_location (entry, set); - get = ephy_location_entry_get_location (entry); - g_assert_cmpstr (set, ==, get); -} - -static void -test_entry_set_location_null (void) -{ - const char *set = "test"; - const char *get; - - EphyLocationEntry *entry; - entry = EPHY_LOCATION_ENTRY (ephy_location_entry_new ()); - - ephy_location_entry_set_location (entry, NULL); - get = ephy_location_entry_get_location (entry); - g_assert_cmpstr (set, !=, get); -} - -static void -test_entry_get_location (void) -{ - const char *set = "test"; - const char *get; - - EphyLocationEntry *entry; - entry = EPHY_LOCATION_ENTRY (ephy_location_entry_new ()); - - ephy_location_entry_set_location (entry, set); - get = ephy_location_entry_get_location (entry); - g_assert_cmpstr (set, ==, get); -} - -static void -test_entry_get_location_empty (void) -{ - const char *get; - - EphyLocationEntry *entry; - entry = EPHY_LOCATION_ENTRY (ephy_location_entry_new ()); - - get = ephy_location_entry_get_location (entry); - g_assert_cmpstr ("", ==, get); -} - -static void -test_entry_can_undo (void) -{ - const char *test = "test"; - - EphyLocationEntry *entry; - entry = EPHY_LOCATION_ENTRY (ephy_location_entry_new ()); - - g_assert_cmpint (ephy_location_entry_get_can_undo (entry), ==, FALSE); - - /* Use gtk_* function or otherwise user_changed won't be correctly handled - * internally by the location entry (see editable_changed_cb and - * block_update) */ - gtk_entry_set_text (GTK_ENTRY (entry), test); - g_assert_cmpint (ephy_location_entry_get_can_undo (entry), ==, TRUE); -} - -static void -test_entry_can_redo (void) -{ - const char *test = "test"; - - EphyLocationEntry *entry; - entry = EPHY_LOCATION_ENTRY (ephy_location_entry_new ()); - g_assert_cmpint (ephy_location_entry_get_can_redo (entry), ==, FALSE); - - /* Can't redo, in this point we can undo */ - ephy_location_entry_set_location (entry, test); - g_assert_cmpint (ephy_location_entry_get_can_redo (entry), ==, FALSE); - - /* Reset should set redo to TRUE */ - ephy_location_entry_reset (entry); - g_assert_cmpint (ephy_location_entry_get_can_redo (entry), ==, TRUE); -} - -int -main (int argc, char *argv[]) -{ - gtk_test_init (&argc, &argv); - ephy_debug_init (); - - g_test_add_func ("/lib/widgets/ephy-location-entry/new", - test_entry_new); - g_test_add_func ("/lib/widgets/ephy-location-entry/get_entry", - test_entry_get_entry); - g_test_add_func ("/lib/widgets/ephy-location-entry/set_location", - test_entry_set_location); - g_test_add_func ("/lib/widgets/ephy-location-entry/get_location", - test_entry_get_location); - g_test_add_func ("/lib/widgets/ephy-location-entry/set_location_null", - test_entry_set_location_null); - g_test_add_func ("/lib/widgets/ephy-location-entry/get_location_empty", - test_entry_get_location_empty); - g_test_add_func ("/lib/widgets/ephy-location-entry/can_undo", - test_entry_can_undo); - g_test_add_func ("/lib/widgets/ephy-location-entry/can_redo", - test_entry_can_redo); - - return g_test_run (); -} diff --git a/tests/ephy-search-entry-test.c b/tests/ephy-search-entry-test.c new file mode 100644 index 000000000..758ac7ae1 --- /dev/null +++ b/tests/ephy-search-entry-test.c @@ -0,0 +1,74 @@ +/* vim: set sw=2 ts=2 sts=2 et: */ +/* + * ephy-search-entry-test.c + * This file is part of Epiphany + * + * Copyright © 2008 - Diego Escalante Urrelo + * + * 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-search-entry.h" +#include +#include + +static void +test_entry_new (void) +{ + + EphySearchEntry *entry; + entry = EPHY_SEARCH_ENTRY (ephy_search_entry_new ()); + + g_assert (GTK_IS_WIDGET (entry)); + g_assert (GTK_IS_ENTRY (entry)); +} + +static void +test_entry_clear (void) +{ + const char *set = "test"; + const char *get = NULL; + + EphySearchEntry *entry; + entry = EPHY_SEARCH_ENTRY (ephy_search_entry_new ()); + + gtk_entry_set_text (GTK_ENTRY (entry), set); + get = gtk_entry_get_text (GTK_ENTRY (entry)); + + g_assert_cmpstr (set, ==, get); + + /* At this point, the text in the entry is either 'vanilla' or the + * contents of 'set' char* + */ + ephy_search_entry_clear (EPHY_SEARCH_ENTRY (entry)); + get = gtk_entry_get_text (GTK_ENTRY (entry)); + + g_assert_cmpstr ("", ==, get); +} + +int +main (int argc, char *argv[]) +{ + gtk_test_init (&argc, &argv); + + g_test_add_func ("/lib/widgets/ephy-search-entry/new", + test_entry_new); + g_test_add_func ("/lib/widgets/ephy-search-entry/clear", + test_entry_clear); + + return g_test_run (); +} diff --git a/tests/ephy-search-entry.c b/tests/ephy-search-entry.c deleted file mode 100644 index 3cc8ce552..000000000 --- a/tests/ephy-search-entry.c +++ /dev/null @@ -1,74 +0,0 @@ -/* vim: set sw=2 ts=2 sts=2 et: */ -/* - * ephy-search-entry.c - * This file is part of Epiphany - * - * Copyright © 2008 - Diego Escalante Urrelo - * - * 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-search-entry.h" -#include -#include - -static void -test_entry_new (void) -{ - - EphySearchEntry *entry; - entry = EPHY_SEARCH_ENTRY (ephy_search_entry_new ()); - - g_assert (GTK_IS_WIDGET (entry)); - g_assert (GTK_IS_ENTRY (entry)); -} - -static void -test_entry_clear (void) -{ - const char *set = "test"; - const char *get = NULL; - - EphySearchEntry *entry; - entry = EPHY_SEARCH_ENTRY (ephy_search_entry_new ()); - - gtk_entry_set_text (GTK_ENTRY (entry), set); - get = gtk_entry_get_text (GTK_ENTRY (entry)); - - g_assert_cmpstr (set, ==, get); - - /* At this point, the text in the entry is either 'vanilla' or the - * contents of 'set' char* - */ - ephy_search_entry_clear (EPHY_SEARCH_ENTRY (entry)); - get = gtk_entry_get_text (GTK_ENTRY (entry)); - - g_assert_cmpstr ("", ==, get); -} - -int -main (int argc, char *argv[]) -{ - gtk_test_init (&argc, &argv); - - g_test_add_func ("/lib/widgets/ephy-search-entry/new", - test_entry_new); - g_test_add_func ("/lib/widgets/ephy-search-entry/clear", - test_entry_clear); - - return g_test_run (); -} -- cgit v1.2.3