aboutsummaryrefslogtreecommitdiffstats
path: root/tests/ephy-session-test.c
diff options
context:
space:
mode:
authorClaudio Saavedra <csaavedra@igalia.com>2013-02-07 16:24:25 +0800
committerClaudio Saavedra <csaavedra@igalia.com>2013-02-08 06:01:59 +0800
commit0d728a011be9ff6f96c5296f5fe3b33564114a81 (patch)
treec4bb416b47dd9f8431a3ba78600aad4155e2cfd8 /tests/ephy-session-test.c
parent0129db9503f61333eb12a785c1b4d073aef83cce (diff)
downloadgsoc2013-epiphany-0d728a011be9ff6f96c5296f5fe3b33564114a81.tar
gsoc2013-epiphany-0d728a011be9ff6f96c5296f5fe3b33564114a81.tar.gz
gsoc2013-epiphany-0d728a011be9ff6f96c5296f5fe3b33564114a81.tar.bz2
gsoc2013-epiphany-0d728a011be9ff6f96c5296f5fe3b33564114a81.tar.lz
gsoc2013-epiphany-0d728a011be9ff6f96c5296f5fe3b33564114a81.tar.xz
gsoc2013-epiphany-0d728a011be9ff6f96c5296f5fe3b33564114a81.tar.zst
gsoc2013-epiphany-0d728a011be9ff6f96c5296f5fe3b33564114a81.zip
ephy-session-test: add tests for tab restoring API
https://bugzilla.gnome.org/show_bug.cgi?id=128184
Diffstat (limited to 'tests/ephy-session-test.c')
-rw-r--r--tests/ephy-session-test.c69
1 files changed, 69 insertions, 0 deletions
diff --git a/tests/ephy-session-test.c b/tests/ephy-session-test.c
index 8ba320335..fc425d068 100644
--- a/tests/ephy-session-test.c
+++ b/tests/ephy-session-test.c
@@ -276,6 +276,72 @@ test_ephy_session_open_empty_uri_forces_new_window (void)
open_uris_after_loading_session (uris, 3);
}
+static void
+test_ephy_session_restore_tabs (void)
+{
+ EphySession *session = EPHY_SESSION (ephy_shell_get_session (ephy_shell_get_default ()));
+ const char* uris[] = { "ephy-about:epiphany", "ephy-about:config", NULL };
+ guint32 user_time = gdk_x11_display_get_user_time (gdk_display_get_default ());
+ gboolean ret;
+ GList *l;
+ gchar *url;
+ int n_windows;
+ EphyEmbed *embed;
+
+ /* Nothing to restore. */
+ g_assert (ephy_session_get_can_undo_tab_closed (session) == FALSE);
+
+ ephy_shell_open_uris (ephy_shell_get_default(), uris, 0, user_time);
+ while (gtk_events_pending ())
+ gtk_main_iteration_do (FALSE);
+
+ /* Nothing to restore, again. */
+ g_assert (ephy_session_get_can_undo_tab_closed (session) == FALSE);
+
+ l = ephy_shell_get_windows (ephy_shell_get_default ());
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (l->data));
+ url = g_strdup (ephy_web_view_get_address (ephy_embed_get_web_view (embed)));
+ gtk_widget_destroy (GTK_WIDGET (embed));
+
+ /* There should be now at least one tab that can be restored. */
+ g_assert (ephy_session_get_can_undo_tab_closed (session) == TRUE);
+
+ ephy_session_undo_close_tab (session);
+ while (gtk_events_pending ())
+ gtk_main_iteration_do (FALSE);
+
+ /* Nothing to restore, again. */
+ g_assert (ephy_session_get_can_undo_tab_closed (session) == FALSE);
+
+ /* The active child should now be pointing to the restored tab,
+ whose address is the one we copied previously. */
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (l->data));
+ g_assert_cmpstr (ephy_web_view_get_address (ephy_embed_get_web_view (embed)),
+ ==, url);
+ g_free (url);
+
+ ephy_session_clear (session);
+
+ ret = load_session_from_string (session, session_data_many_windows);
+ g_assert (ret);
+
+ l = ephy_shell_get_windows (ephy_shell_get_default ());
+ n_windows = g_list_length (l);
+ /* We need more than one window for the next test to make sense. */
+ g_assert_cmpint (n_windows, >, 1);
+ gtk_widget_destroy (GTK_WIDGET (l->data));
+ /* One window is gone. */
+ g_assert_cmpint (n_windows, ==, g_list_length (ephy_shell_get_windows (ephy_shell_get_default())) + 1);
+ g_assert (ephy_session_get_can_undo_tab_closed (session) == TRUE);
+ ephy_session_undo_close_tab (session);
+ while (gtk_events_pending ())
+ gtk_main_iteration_do (FALSE);
+ /* We have the same amount of windows than before destroying one. */
+ g_assert_cmpint (n_windows, ==, g_list_length (ephy_shell_get_windows (ephy_shell_get_default())));
+
+ ephy_session_clear (session);
+}
+
int
main (int argc, char *argv[])
{
@@ -316,6 +382,9 @@ main (int argc, char *argv[])
g_test_add_func ("/src/ephy-session/open-empty-uri-forces-new-window",
test_ephy_session_open_empty_uri_forces_new_window);
+ g_test_add_func("/src/ephy-session/restore-tabs",
+ test_ephy_session_restore_tabs);
+
ret = g_test_run ();
g_object_unref (ephy_shell_get_default ());