From 5a4853c420f53929340b1948bbdab0156726c015 Mon Sep 17 00:00:00 2001 From: Diego Escalante Urrelo Date: Thu, 16 Dec 2010 14:44:40 -0500 Subject: tests: clean up filenames Make filenames readable and tab-completion friendly. --- .gitignore | 10 +- tests/Makefile.am | 30 ++-- tests/ephy-embed-persist.c | 315 ++++++++++++++++++++++++++++++++++++++++++ tests/ephy-embed-single.c | 125 +++++++++++++++++ tests/ephy-location-entry.c | 165 ++++++++++++++++++++++ tests/ephy-search-entry.c | 74 ++++++++++ tests/ephy-zoom-control.c | 78 +++++++++++ tests/testephyembedpersist.c | 315 ------------------------------------------ tests/testephyembedsingle.c | 125 ----------------- tests/testephylocationentry.c | 165 ---------------------- tests/testephysearchentry.c | 74 ---------- tests/testephyzoomcontrol.c | 78 ----------- 12 files changed, 777 insertions(+), 777 deletions(-) create mode 100644 tests/ephy-embed-persist.c create mode 100644 tests/ephy-embed-single.c create mode 100644 tests/ephy-location-entry.c create mode 100644 tests/ephy-search-entry.c create mode 100644 tests/ephy-zoom-control.c delete mode 100644 tests/testephyembedpersist.c delete mode 100644 tests/testephyembedsingle.c delete mode 100644 tests/testephylocationentry.c delete mode 100644 tests/testephysearchentry.c delete mode 100644 tests/testephyzoomcontrol.c diff --git a/.gitignore b/.gitignore index 3fb8d0256..83a9fbd8b 100644 --- a/.gitignore +++ b/.gitignore @@ -64,8 +64,8 @@ src/ephy-dbus-server-bindings.h src/epiphany src/epiphany.h -tests/testephyembedpersist -tests/testephyembedsingle -tests/testephylocationentry -tests/testephysearchentry -tests/testephyzoomcontrol +tests/test-ephy-embed-persist +tests/test-ephy-embed-single +tests/test-ephy-location-entry +tests/test-ephy-search-entry +tests/test-ephy-zoom-control diff --git a/tests/Makefile.am b/tests/Makefile.am index c4dd1384c..8cba75725 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,9 +1,9 @@ noinst_PROGRAMS = \ - testephyembedpersist \ - testephysearchentry \ - testephylocationentry \ - testephyzoomcontrol \ - testephyembedsingle + test-ephy-embed-persist \ + test-ephy-embed-single \ + test-ephy-location-entry \ + test-ephy-search-entry \ + test-ephy-zoom-control INCLUDES = \ -I$(top_srcdir)/embed \ @@ -33,17 +33,17 @@ LDADD += \ $(SEED_LIBS) endif -testephyembedpersist_SOURCES = \ - testephyembedpersist.c +test_ephy_embed_persist_SOURCES = \ + ephy-embed-persist.c -testephyembedsingle_SOURCES = \ - testephyembedsingle.c +test_ephy_embed_single_SOURCES = \ + ephy-embed-single.c -testephysearchentry_SOURCES = \ - testephysearchentry.c +test_ephy_location_entry_SOURCES = \ + ephy-location-entry.c -testephylocationentry_SOURCES = \ - testephylocationentry.c +test_ephy_search_entry_SOURCES = \ + ephy-search-entry.c -testephyzoomcontrol_SOURCES = \ - testephyzoomcontrol.c +test_ephy_zoom_control_SOURCES = \ + ephy-zoom-control.c diff --git a/tests/ephy-embed-persist.c b/tests/ephy-embed-persist.c new file mode 100644 index 000000000..971c3577d --- /dev/null +++ b/tests/ephy-embed-persist.c @@ -0,0 +1,315 @@ +/* vim: set sw=2 ts=2 sts=2 et: */ +/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* + * ephy-embed-persist.c + * This file is part of Epiphany + * + * Copyright © 2009, 2010 - Gustavo Noronha Silva + * 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-persist.h" +#include "ephy-embed-prefs.h" +#include "ephy-file-helpers.h" +#include "ephy-shell.h" +#include "ephy-stock-icons.h" +#include +#include +#include +#include +#include + +#define HTML_STRING "testing-embed-persist" +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; + EphyEmbedPersist *embed; + char *destination; +} PersistFixture; + +static void +persist_fixture_setup (PersistFixture *fixture, + gconstpointer data) +{ + char *tmp_filename; + char *uri_string; + + tmp_filename = ephy_file_tmp_filename ("embed-persist-save-XXXXXX", NULL); + fixture->destination = g_build_filename (ephy_file_tmp_dir (), tmp_filename, NULL); + + fixture->loop = g_main_loop_new (NULL, TRUE); + fixture->embed = EPHY_EMBED_PERSIST (g_object_new (EPHY_TYPE_EMBED_PERSIST, NULL)); + + uri_string = get_uri_for_path ("/default"); + + ephy_embed_persist_set_source (fixture->embed, uri_string); + ephy_embed_persist_set_dest (fixture->embed, fixture->destination); + ephy_embed_persist_set_flags (fixture->embed, EPHY_EMBED_PERSIST_NO_VIEW); + + g_free (tmp_filename); + g_free (uri_string); +} + +static void +persist_fixture_teardown (PersistFixture *fixture, + gconstpointer data) +{ + g_unlink (fixture->destination); + g_free (fixture->destination); + + if (fixture->embed != NULL) + g_object_unref (fixture->embed); + + g_main_loop_unref (fixture->loop); +} + +static void +test_embed_persist_new (PersistFixture *fixture, + gconstpointer data) +{ + g_assert (EPHY_IS_EMBED_PERSIST (fixture->embed)); +} + +static void +test_embed_persist_set_dest (PersistFixture *fixture, + gconstpointer data) +{ + const char *dest_value = NULL; + char *read_value; + + ephy_embed_persist_set_dest (fixture->embed, dest_value); + g_object_get (G_OBJECT (fixture->embed), "dest", &read_value, NULL); + + g_assert_cmpstr (dest_value, ==, read_value); + + g_free (read_value); +} + +static void +test_embed_persist_set_embed (PersistFixture *fixture, + gconstpointer data) +{ + EphyEmbed *orig_value; + EphyEmbed *fail_value; + EphyEmbed *read_value; + + orig_value = EPHY_EMBED (g_object_new (EPHY_TYPE_EMBED, NULL)); + fail_value = EPHY_EMBED (g_object_new (EPHY_TYPE_EMBED, NULL)); + + ephy_embed_persist_set_embed (fixture->embed, orig_value); + g_object_get (G_OBJECT (fixture->embed), "embed", &read_value, NULL); + + g_assert (read_value == orig_value); + g_assert (read_value != fail_value); + + g_object_unref (read_value); + g_object_ref_sink (fail_value); + g_object_unref (fail_value); +} + +static void +test_embed_persist_save_empty_dest (PersistFixture *fixture, + gconstpointer data) +{ + ephy_embed_persist_set_source (fixture->embed, "ficticious-source"); + + /* No dest is set and no EPHY_EMBED_PERSIST_ASK_DESTINATION flag, + so the destination will be downloads folder with the suggested filename. */ + g_assert (ephy_embed_persist_save (fixture->embed) == TRUE); + + /* Otherwise the reference from ephy_embed_persist_save () is never unref'd */ + ephy_embed_persist_cancel (fixture->embed); +} + +static void +test_embed_persist_save (PersistFixture *fixture, + gconstpointer data) +{ + /* Source and dest set, should return TRUE */ + g_assert (ephy_embed_persist_save (fixture->embed) == TRUE); + + /* Otherwise the reference from ephy_embed_persist_save () is never unref'd */ + ephy_embed_persist_cancel (fixture->embed); +} + +static void +test_embed_persist_cancel (PersistFixture *fixture, + gconstpointer data) +{ + ephy_embed_persist_cancel (fixture->embed); + /* This is the only case where the embed unrefs itself */ + fixture->embed = NULL; +} + +static void +completed_cb (EphyEmbedPersist *persist, + PersistFixture *fixture) +{ + g_main_loop_quit (fixture->loop); +} + +static void +test_embed_persist_save_completed (PersistFixture *fixture, + gconstpointer userdata) +{ + g_signal_connect (G_OBJECT (fixture->embed), "completed", + G_CALLBACK (completed_cb), fixture); + + ephy_embed_persist_save (fixture->embed); + + g_main_loop_run (fixture->loop); + + g_assert (g_file_test (fixture->destination, G_FILE_TEST_EXISTS)); +} + +static void +cancelled_cb (EphyEmbedPersist *persist, + PersistFixture *fixture) +{ + g_main_loop_quit (fixture->loop); +} + +static void +test_embed_persist_cancelled (PersistFixture *fixture, + gconstpointer userdata) +{ + char *uri_string; + + g_signal_connect (G_OBJECT (fixture->embed), "cancelled", + G_CALLBACK (cancelled_cb), fixture); + + uri_string = get_uri_for_path ("/cancelled"); + ephy_embed_persist_set_source (fixture->embed, uri_string); + g_free (uri_string); + + g_assert (ephy_embed_persist_save (fixture->embed)); + + g_main_loop_run (fixture->loop); +} + +int +main (int argc, char *argv[]) +{ + int ret; + SoupServer *server; + + gtk_test_init (&argc, &argv); + g_thread_init (NULL); + + ephy_debug_init (); + ephy_embed_prefs_init (); + _ephy_shell_create_instance (); + + 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-embed-persist/new", + PersistFixture, NULL, + persist_fixture_setup, + test_embed_persist_new, + persist_fixture_teardown); + g_test_add ("/embed/ephy-embed-persist/set_dest", + PersistFixture, NULL, + persist_fixture_setup, + test_embed_persist_set_dest, + persist_fixture_teardown); + g_test_add ("/embed/ephy-embed-persist/set_embed", + PersistFixture, NULL, + persist_fixture_setup, + test_embed_persist_set_embed, + persist_fixture_teardown); + g_test_add ("/embed/ephy-embed-persist/save_empty_dest", + PersistFixture, NULL, + persist_fixture_setup, + test_embed_persist_save_empty_dest, + persist_fixture_teardown); + + g_test_add ("/embed/ephy-embed-persist/save", + PersistFixture, NULL, + persist_fixture_setup, + test_embed_persist_save, + persist_fixture_teardown); + g_test_add ("/embed/ephy-embed-persist/cancel", + PersistFixture, NULL, + persist_fixture_setup, + test_embed_persist_cancel, + persist_fixture_teardown); + + g_test_add ("/embed/ephy-embed-persist/save_completed", + PersistFixture, NULL, + persist_fixture_setup, + test_embed_persist_save_completed, + persist_fixture_teardown); + g_test_add ("/embed/ephy-embed-persist/cancelled", + PersistFixture, NULL, + persist_fixture_setup, + test_embed_persist_cancelled, + persist_fixture_teardown); + + ret = g_test_run (); + + g_object_unref (ephy_shell); + ephy_file_helpers_shutdown (); + + return ret; +} diff --git a/tests/ephy-embed-single.c b/tests/ephy-embed-single.c new file mode 100644 index 000000000..200a2fd2d --- /dev/null +++ b/tests/ephy-embed-single.c @@ -0,0 +1,125 @@ +/* -*- 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 "ephy-stock-icons.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); + g_thread_init (NULL); + + ephy_debug_init (); + ephy_embed_prefs_init (); + _ephy_shell_create_instance (); + + 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-location-entry.c b/tests/ephy-location-entry.c new file mode 100644 index 000000000..bac969e0f --- /dev/null +++ b/tests/ephy-location-entry.c @@ -0,0 +1,165 @@ +/* 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 (ephy_location_entry_get_entry (entry))); +} + +static void +test_entry_set_location (void) +{ + const char *set = "test"; + const char *null; + const char *get; + + EphyLocationEntry *entry; + entry = EPHY_LOCATION_ENTRY (ephy_location_entry_new ()); + + null = ephy_location_entry_get_location (entry); + + 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 (ephy_location_entry_get_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.c b/tests/ephy-search-entry.c new file mode 100644 index 000000000..3cc8ce552 --- /dev/null +++ b/tests/ephy-search-entry.c @@ -0,0 +1,74 @@ +/* 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 (); +} diff --git a/tests/ephy-zoom-control.c b/tests/ephy-zoom-control.c new file mode 100644 index 000000000..b02ec2847 --- /dev/null +++ b/tests/ephy-zoom-control.c @@ -0,0 +1,78 @@ +/* vim: set sw=2 ts=2 sts=2 et: */ +/* + * ephy-zoom-control.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-zoom-control.h" +#include +#include + +static void +test_new (void) +{ + EphyZoomControl *control; + control = g_object_new (EPHY_TYPE_ZOOM_CONTROL, "zoom", 1.0, NULL); + + g_assert (GTK_IS_WIDGET (control)); + g_assert (GTK_IS_TOOL_ITEM (control)); + g_assert (EPHY_IS_ZOOM_CONTROL (control)); +} + +static void +test_set_zoom_level (void) +{ + EphyZoomControl *control; + float get = 1.0; + control = g_object_new (EPHY_TYPE_ZOOM_CONTROL, "zoom", 2.0, NULL); + + ephy_zoom_control_set_zoom_level (control, 4.0); + + g_object_get (control, "zoom", &get, NULL); + g_assert_cmpfloat (4.0, ==, get); +} + +static void +test_get_zoom_level (void) +{ + EphyZoomControl *control; + float get = 1.0; + control = g_object_new (EPHY_TYPE_ZOOM_CONTROL, "zoom", 2.0, NULL); + + get = ephy_zoom_control_get_zoom_level (control); + + g_assert_cmpfloat (2.0, ==, get); +} + +int +main (int argc, char *argv[]) +{ + gtk_test_init (&argc, &argv); + + g_test_add_func ("/lib/widgets/ephy-zoom-control/new", + test_new); + g_test_add_func ("/lib/widgets/ephy-zoom-control/set_zoom_level", + test_set_zoom_level); + g_test_add_func ("/lib/widgets/ephy-zoom-control/get_zoom_level", + test_get_zoom_level); + + return g_test_run (); +} diff --git a/tests/testephyembedpersist.c b/tests/testephyembedpersist.c deleted file mode 100644 index 21b6c4c51..000000000 --- a/tests/testephyembedpersist.c +++ /dev/null @@ -1,315 +0,0 @@ -/* vim: set sw=2 ts=2 sts=2 et: */ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* - * testephyembedpersist.c - * This file is part of Epiphany - * - * Copyright © 2009, 2010 - Gustavo Noronha Silva - * 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-persist.h" -#include "ephy-embed-prefs.h" -#include "ephy-file-helpers.h" -#include "ephy-shell.h" -#include "ephy-stock-icons.h" -#include -#include -#include -#include -#include - -#define HTML_STRING "testing-embed-persist" -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; - EphyEmbedPersist *embed; - char *destination; -} PersistFixture; - -static void -persist_fixture_setup (PersistFixture *fixture, - gconstpointer data) -{ - char *tmp_filename; - char *uri_string; - - tmp_filename = ephy_file_tmp_filename ("embed-persist-save-XXXXXX", NULL); - fixture->destination = g_build_filename (ephy_file_tmp_dir (), tmp_filename, NULL); - - fixture->loop = g_main_loop_new (NULL, TRUE); - fixture->embed = EPHY_EMBED_PERSIST (g_object_new (EPHY_TYPE_EMBED_PERSIST, NULL)); - - uri_string = get_uri_for_path ("/default"); - - ephy_embed_persist_set_source (fixture->embed, uri_string); - ephy_embed_persist_set_dest (fixture->embed, fixture->destination); - ephy_embed_persist_set_flags (fixture->embed, EPHY_EMBED_PERSIST_NO_VIEW); - - g_free (tmp_filename); - g_free (uri_string); -} - -static void -persist_fixture_teardown (PersistFixture *fixture, - gconstpointer data) -{ - g_unlink (fixture->destination); - g_free (fixture->destination); - - if (fixture->embed != NULL) - g_object_unref (fixture->embed); - - g_main_loop_unref (fixture->loop); -} - -static void -test_embed_persist_new (PersistFixture *fixture, - gconstpointer data) -{ - g_assert (EPHY_IS_EMBED_PERSIST (fixture->embed)); -} - -static void -test_embed_persist_set_dest (PersistFixture *fixture, - gconstpointer data) -{ - const char *dest_value = NULL; - char *read_value; - - ephy_embed_persist_set_dest (fixture->embed, dest_value); - g_object_get (G_OBJECT (fixture->embed), "dest", &read_value, NULL); - - g_assert_cmpstr (dest_value, ==, read_value); - - g_free (read_value); -} - -static void -test_embed_persist_set_embed (PersistFixture *fixture, - gconstpointer data) -{ - EphyEmbed *orig_value; - EphyEmbed *fail_value; - EphyEmbed *read_value; - - orig_value = EPHY_EMBED (g_object_new (EPHY_TYPE_EMBED, NULL)); - fail_value = EPHY_EMBED (g_object_new (EPHY_TYPE_EMBED, NULL)); - - ephy_embed_persist_set_embed (fixture->embed, orig_value); - g_object_get (G_OBJECT (fixture->embed), "embed", &read_value, NULL); - - g_assert (read_value == orig_value); - g_assert (read_value != fail_value); - - g_object_unref (read_value); - g_object_ref_sink (fail_value); - g_object_unref (fail_value); -} - -static void -test_embed_persist_save_empty_dest (PersistFixture *fixture, - gconstpointer data) -{ - ephy_embed_persist_set_source (fixture->embed, "ficticious-source"); - - /* No dest is set and no EPHY_EMBED_PERSIST_ASK_DESTINATION flag, - so the destination will be downloads folder with the suggested filename. */ - g_assert (ephy_embed_persist_save (fixture->embed) == TRUE); - - /* Otherwise the reference from ephy_embed_persist_save () is never unref'd */ - ephy_embed_persist_cancel (fixture->embed); -} - -static void -test_embed_persist_save (PersistFixture *fixture, - gconstpointer data) -{ - /* Source and dest set, should return TRUE */ - g_assert (ephy_embed_persist_save (fixture->embed) == TRUE); - - /* Otherwise the reference from ephy_embed_persist_save () is never unref'd */ - ephy_embed_persist_cancel (fixture->embed); -} - -static void -test_embed_persist_cancel (PersistFixture *fixture, - gconstpointer data) -{ - ephy_embed_persist_cancel (fixture->embed); - /* This is the only case where the embed unrefs itself */ - fixture->embed = NULL; -} - -static void -completed_cb (EphyEmbedPersist *persist, - PersistFixture *fixture) -{ - g_main_loop_quit (fixture->loop); -} - -static void -test_embed_persist_save_completed (PersistFixture *fixture, - gconstpointer userdata) -{ - g_signal_connect (G_OBJECT (fixture->embed), "completed", - G_CALLBACK (completed_cb), fixture); - - ephy_embed_persist_save (fixture->embed); - - g_main_loop_run (fixture->loop); - - g_assert (g_file_test (fixture->destination, G_FILE_TEST_EXISTS)); -} - -static void -cancelled_cb (EphyEmbedPersist *persist, - PersistFixture *fixture) -{ - g_main_loop_quit (fixture->loop); -} - -static void -test_embed_persist_cancelled (PersistFixture *fixture, - gconstpointer userdata) -{ - char *uri_string; - - g_signal_connect (G_OBJECT (fixture->embed), "cancelled", - G_CALLBACK (cancelled_cb), fixture); - - uri_string = get_uri_for_path ("/cancelled"); - ephy_embed_persist_set_source (fixture->embed, uri_string); - g_free (uri_string); - - g_assert (ephy_embed_persist_save (fixture->embed)); - - g_main_loop_run (fixture->loop); -} - -int -main (int argc, char *argv[]) -{ - int ret; - SoupServer *server; - - gtk_test_init (&argc, &argv); - g_thread_init (NULL); - - ephy_debug_init (); - ephy_embed_prefs_init (); - _ephy_shell_create_instance (); - - 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-embed-persist/new", - PersistFixture, NULL, - persist_fixture_setup, - test_embed_persist_new, - persist_fixture_teardown); - g_test_add ("/embed/ephy-embed-persist/set_dest", - PersistFixture, NULL, - persist_fixture_setup, - test_embed_persist_set_dest, - persist_fixture_teardown); - g_test_add ("/embed/ephy-embed-persist/set_embed", - PersistFixture, NULL, - persist_fixture_setup, - test_embed_persist_set_embed, - persist_fixture_teardown); - g_test_add ("/embed/ephy-embed-persist/save_empty_dest", - PersistFixture, NULL, - persist_fixture_setup, - test_embed_persist_save_empty_dest, - persist_fixture_teardown); - - g_test_add ("/embed/ephy-embed-persist/save", - PersistFixture, NULL, - persist_fixture_setup, - test_embed_persist_save, - persist_fixture_teardown); - g_test_add ("/embed/ephy-embed-persist/cancel", - PersistFixture, NULL, - persist_fixture_setup, - test_embed_persist_cancel, - persist_fixture_teardown); - - g_test_add ("/embed/ephy-embed-persist/save_completed", - PersistFixture, NULL, - persist_fixture_setup, - test_embed_persist_save_completed, - persist_fixture_teardown); - g_test_add ("/embed/ephy-embed-persist/cancelled", - PersistFixture, NULL, - persist_fixture_setup, - test_embed_persist_cancelled, - persist_fixture_teardown); - - ret = g_test_run (); - - g_object_unref (ephy_shell); - ephy_file_helpers_shutdown (); - - return ret; -} diff --git a/tests/testephyembedsingle.c b/tests/testephyembedsingle.c deleted file mode 100644 index b92dfd005..000000000 --- a/tests/testephyembedsingle.c +++ /dev/null @@ -1,125 +0,0 @@ -/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set sw=2 ts=2 sts=2 et: */ -/* - * testephyembedpersist.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 "ephy-stock-icons.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); - g_thread_init (NULL); - - ephy_debug_init (); - ephy_embed_prefs_init (); - _ephy_shell_create_instance (); - - 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/testephylocationentry.c b/tests/testephylocationentry.c deleted file mode 100644 index ca370e411..000000000 --- a/tests/testephylocationentry.c +++ /dev/null @@ -1,165 +0,0 @@ -/* vim: set sw=2 ts=2 sts=2 et: */ -/* - * testephylocationentry.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 (ephy_location_entry_get_entry (entry))); -} - -static void -test_entry_set_location (void) -{ - const char *set = "test"; - const char *null; - const char *get; - - EphyLocationEntry *entry; - entry = EPHY_LOCATION_ENTRY (ephy_location_entry_new ()); - - null = ephy_location_entry_get_location (entry); - - 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 (ephy_location_entry_get_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/testephysearchentry.c b/tests/testephysearchentry.c deleted file mode 100644 index 2ed4e72ca..000000000 --- a/tests/testephysearchentry.c +++ /dev/null @@ -1,74 +0,0 @@ -/* vim: set sw=2 ts=2 sts=2 et: */ -/* - * testephysearchentry.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/testephyzoomcontrol.c b/tests/testephyzoomcontrol.c deleted file mode 100644 index 02c628d0f..000000000 --- a/tests/testephyzoomcontrol.c +++ /dev/null @@ -1,78 +0,0 @@ -/* vim: set sw=2 ts=2 sts=2 et: */ -/* - * testephyzoomcontrol.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-zoom-control.h" -#include -#include - -static void -test_new (void) -{ - EphyZoomControl *control; - control = g_object_new (EPHY_TYPE_ZOOM_CONTROL, "zoom", 1.0, NULL); - - g_assert (GTK_IS_WIDGET (control)); - g_assert (GTK_IS_TOOL_ITEM (control)); - g_assert (EPHY_IS_ZOOM_CONTROL (control)); -} - -static void -test_set_zoom_level (void) -{ - EphyZoomControl *control; - float get = 1.0; - control = g_object_new (EPHY_TYPE_ZOOM_CONTROL, "zoom", 2.0, NULL); - - ephy_zoom_control_set_zoom_level (control, 4.0); - - g_object_get (control, "zoom", &get, NULL); - g_assert_cmpfloat (4.0, ==, get); -} - -static void -test_get_zoom_level (void) -{ - EphyZoomControl *control; - float get = 1.0; - control = g_object_new (EPHY_TYPE_ZOOM_CONTROL, "zoom", 2.0, NULL); - - get = ephy_zoom_control_get_zoom_level (control); - - g_assert_cmpfloat (2.0, ==, get); -} - -int -main (int argc, char *argv[]) -{ - gtk_test_init (&argc, &argv); - - g_test_add_func ("/lib/widgets/ephy-zoom-control/new", - test_new); - g_test_add_func ("/lib/widgets/ephy-zoom-control/set_zoom_level", - test_set_zoom_level); - g_test_add_func ("/lib/widgets/ephy-zoom-control/get_zoom_level", - test_get_zoom_level); - - return g_test_run (); -} -- cgit v1.2.3