diff options
author | Gustavo Noronha Silva <gns@gnome.org> | 2013-02-23 02:38:01 +0800 |
---|---|---|
committer | Gustavo Noronha Silva <gns@gnome.org> | 2013-02-24 04:41:13 +0800 |
commit | b45047739e9ebc02200267a52295f24adf4ca668 (patch) | |
tree | 743bfd4c0aa63703286947707252b3f366d4a7cb | |
parent | 1bf2e792d47a41ee9117ffae1c699419d211644a (diff) | |
download | gsoc2013-epiphany-b45047739e9ebc02200267a52295f24adf4ca668.tar gsoc2013-epiphany-b45047739e9ebc02200267a52295f24adf4ca668.tar.gz gsoc2013-epiphany-b45047739e9ebc02200267a52295f24adf4ca668.tar.bz2 gsoc2013-epiphany-b45047739e9ebc02200267a52295f24adf4ca668.tar.lz gsoc2013-epiphany-b45047739e9ebc02200267a52295f24adf4ca668.tar.xz gsoc2013-epiphany-b45047739e9ebc02200267a52295f24adf4ca668.tar.zst gsoc2013-epiphany-b45047739e9ebc02200267a52295f24adf4ca668.zip |
Add setting for delayed tab loading, and use it to fix the session tests
The session tests were broken by the delayed tab loading feature - the restored
embeds would not finish loading and thus the expectations for the URIs were not
met. This change adds a setting that is now used by those tests to disable the
feature temporarily.
Also revert "ephy-session-test: make tests pass", which is no longer necessary.
This reverts commit 75da5fff3f4489dacf4ded6f012daa06af306709.
https://bugzilla.gnome.org/show_bug.cgi?id=694470
-rw-r--r-- | data/org.gnome.epiphany.gschema.xml | 5 | ||||
-rw-r--r-- | lib/ephy-prefs.h | 1 | ||||
-rw-r--r-- | src/ephy-session.c | 21 | ||||
-rw-r--r-- | tests/ephy-session-test.c | 43 |
4 files changed, 64 insertions, 6 deletions
diff --git a/data/org.gnome.epiphany.gschema.xml b/data/org.gnome.epiphany.gschema.xml index becb0a23d..b815635cc 100644 --- a/data/org.gnome.epiphany.gschema.xml +++ b/data/org.gnome.epiphany.gschema.xml @@ -54,6 +54,11 @@ <summary>Whether to automatically restore the last session</summary> <description>Defines how the session will be restored during startup. Allowed values are 'always' (the previous state of the application is always restored), 'crashed' (the session is only restored if the application crashes) and 'never' (the homepage is always shown).</description> </key> + <key type="b" name="restore-session-delaying-loads"> + <default>true</default> + <summary>Whether to delay loading of tabs that are not immediately visible on session restore</summary> + <description>When this option is set to true, tabs will not start loading until the user switches to them, upon session restore.</description> + </key> </schema> <schema path="/org/gnome/epiphany/ui/" id="org.gnome.Epiphany.ui"> <key type="b" name="show-toolbars"> diff --git a/lib/ephy-prefs.h b/lib/ephy-prefs.h index c390e37a1..7fe2aeebd 100644 --- a/lib/ephy-prefs.h +++ b/lib/ephy-prefs.h @@ -123,6 +123,7 @@ typedef enum #define EPHY_PREFS_ENABLE_CARET_BROWSING "enable-caret-browsing" #define EPHY_PREFS_INTERNAL_VIEW_SOURCE "internal-view-source" #define EPHY_PREFS_RESTORE_SESSION_POLICY "restore-session-policy" +#define EPHY_PREFS_RESTORE_SESSION_DELAYING_LOADS "restore-session-delaying-loads" #define EPHY_PREFS_LOCKDOWN_SCHEMA "org.gnome.Epiphany.lockdown" #define EPHY_PREFS_LOCKDOWN_FULLSCREEN "disable-fullscreen" diff --git a/src/ephy-session.c b/src/ephy-session.c index 82ecf4149..1099cddbb 100644 --- a/src/ephy-session.c +++ b/src/ephy-session.c @@ -1105,16 +1105,31 @@ session_parse_embed (SessionParserContext *context, EphyNewTabFlags flags; EphyEmbed *embed; EphyWebView *web_view; + gboolean delay_loading; + + delay_loading = g_settings_get_boolean (EPHY_SETTINGS_MAIN, + EPHY_PREFS_RESTORE_SESSION_DELAYING_LOADS); flags = EPHY_NEW_TAB_IN_EXISTING_WINDOW; flags |= EPHY_NEW_TAB_APPEND_LAST; - flags |= EPHY_NEW_TAB_DELAYED_OPEN_PAGE; + + if (delay_loading) + { + flags |= EPHY_NEW_TAB_DELAYED_OPEN_PAGE; + } + else + { + flags |= EPHY_NEW_TAB_OPEN_PAGE; + } embed = ephy_shell_new_tab (ephy_shell_get_default (), context->window, NULL, url, flags); - web_view = ephy_embed_get_web_view (embed); - ephy_web_view_set_placeholder (web_view, url, title); + if (delay_loading) + { + web_view = ephy_embed_get_web_view (embed); + ephy_web_view_set_placeholder (web_view, url, title); + } } else if (was_loading && url != NULL) { diff --git a/tests/ephy-session-test.c b/tests/ephy-session-test.c index 01d10aa62..eda9ab497 100644 --- a/tests/ephy-session-test.c +++ b/tests/ephy-session-test.c @@ -25,6 +25,7 @@ #include "ephy-embed-private.h" #include "ephy-file-helpers.h" #include "ephy-private.h" +#include "ephy-settings.h" #include "ephy-shell.h" #include "ephy-session.h" @@ -72,6 +73,22 @@ load_session_from_string (EphySession *session, } static void +enable_delayed_loading (void) +{ + g_settings_set_boolean (EPHY_SETTINGS_MAIN, + EPHY_PREFS_RESTORE_SESSION_DELAYING_LOADS, + TRUE); +} + +static void +disable_delayed_loading (void) +{ + g_settings_set_boolean (EPHY_SETTINGS_MAIN, + EPHY_PREFS_RESTORE_SESSION_DELAYING_LOADS, + FALSE); +} + +static void test_ephy_session_load (void) { EphySession *session; @@ -80,6 +97,8 @@ test_ephy_session_load (void) EphyEmbed *embed; EphyWebView *view; + disable_delayed_loading (); + session = ephy_shell_get_session (ephy_shell_get_default ()); g_assert (session); @@ -94,9 +113,11 @@ test_ephy_session_load (void) g_assert (embed); view = ephy_embed_get_web_view (embed); g_assert (view); - g_assert_cmpstr (ephy_web_view_get_address (view), ==, "about:memory"); + g_assert_cmpstr (ephy_web_view_get_address (view), ==, "ephy-about:memory"); ephy_session_clear (session); + + enable_delayed_loading (); } const char *session_data_many_windows = @@ -116,6 +137,8 @@ test_ephy_session_clear (void) EphySession *session; GList *l; + disable_delayed_loading (); + session = EPHY_SESSION (ephy_shell_get_session (ephy_shell_get_default ())); load_session_from_string (session, session_data_many_windows); @@ -140,6 +163,8 @@ test_ephy_session_load_empty_session (void) EphyEmbed *embed; EphyWebView *view; + disable_delayed_loading (); + session = ephy_shell_get_session (ephy_shell_get_default ()); g_assert (session); @@ -163,6 +188,7 @@ test_ephy_session_load_empty_session (void) g_assert (view); g_assert_cmpstr (ephy_web_view_get_address (view), ==, "ephy-about:overview"); + enable_delayed_loading (); ephy_session_clear (session); } @@ -175,6 +201,8 @@ test_ephy_session_load_many_windows (void) EphyEmbed *embed; EphyWebView *view; + disable_delayed_loading (); + session = ephy_shell_get_session (ephy_shell_get_default ()); g_assert (session); @@ -190,9 +218,10 @@ test_ephy_session_load_many_windows (void) g_assert (embed); view = ephy_embed_get_web_view (embed); g_assert (view); - g_assert_cmpstr (ephy_web_view_get_address (view), ==, "about:epiphany"); + g_assert_cmpstr (ephy_web_view_get_address (view), ==, "ephy-about:epiphany"); } + enable_delayed_loading (); ephy_session_clear (session); } @@ -206,6 +235,8 @@ open_uris_after_loading_session (const char** uris, int final_num_windows) EphyWebView *view; guint32 user_time; + disable_delayed_loading (); + session = ephy_shell_get_session (ephy_shell_get_default ()); g_assert (session); @@ -224,7 +255,7 @@ open_uris_after_loading_session (const char** uris, int final_num_windows) g_assert (embed); view = ephy_embed_get_web_view (embed); g_assert (view); - g_assert_cmpstr (ephy_web_view_get_address (view), ==, "about:epiphany"); + g_assert_cmpstr (ephy_web_view_get_address (view), ==, "ephy-about:epiphany"); } /* Causing a session load here should not create new windows, since we @@ -258,6 +289,7 @@ open_uris_after_loading_session (const char** uris, int final_num_windows) g_assert (l); g_assert_cmpint (g_list_length (l), ==, final_num_windows); + enable_delayed_loading (); ephy_session_clear (session); } @@ -289,6 +321,8 @@ test_ephy_session_restore_tabs (void) int n_windows; EphyEmbed *embed; + disable_delayed_loading (); + /* Nothing to restore. */ g_assert (ephy_session_get_can_undo_tab_closed (session) == FALSE); @@ -340,6 +374,7 @@ test_ephy_session_restore_tabs (void) /* We have the same amount of windows than before destroying one. */ g_assert_cmpint (n_windows, ==, g_list_length (gtk_application_get_windows (GTK_APPLICATION (ephy_shell_get_default())))); + enable_delayed_loading (); ephy_session_clear (session); } @@ -348,6 +383,8 @@ main (int argc, char *argv[]) { int ret; + setenv ("GSETTINGS_BACKEND", "memory", TRUE); + gtk_test_init (&argc, &argv); ephy_debug_init (); |