aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorCarlos Garcia Campos <cgarcia@igalia.com>2012-10-08 17:19:01 +0800
committerCarlos Garcia Campos <cgarcia@igalia.com>2013-01-09 00:38:01 +0800
commit12415ad405dc6a9bcc42bd693d22c9b857e9bab3 (patch)
tree16d65bfdc561fe20971de92b9ef8cc76b099a6d1 /tests
parentd7e638c985039dc4521273846bbbac7295564b87 (diff)
downloadgsoc2013-epiphany-12415ad405dc6a9bcc42bd693d22c9b857e9bab3.tar
gsoc2013-epiphany-12415ad405dc6a9bcc42bd693d22c9b857e9bab3.tar.gz
gsoc2013-epiphany-12415ad405dc6a9bcc42bd693d22c9b857e9bab3.tar.bz2
gsoc2013-epiphany-12415ad405dc6a9bcc42bd693d22c9b857e9bab3.tar.lz
gsoc2013-epiphany-12415ad405dc6a9bcc42bd693d22c9b857e9bab3.tar.xz
gsoc2013-epiphany-12415ad405dc6a9bcc42bd693d22c9b857e9bab3.tar.zst
gsoc2013-epiphany-12415ad405dc6a9bcc42bd693d22c9b857e9bab3.zip
ephy-session: Load the session asynchronously
Make ephy_session_load() asynchronous and add ephy_session_load_from_stream() to replace ephy_session_load_from_string(). Use a xml sax parser now that is fed from a GInputStream. https://bugzilla.gnome.org/show_bug.cgi?id=681782
Diffstat (limited to 'tests')
-rw-r--r--tests/ephy-session-test.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/tests/ephy-session-test.c b/tests/ephy-session-test.c
index b69403f85..c8d2dc792 100644
--- a/tests/ephy-session-test.c
+++ b/tests/ephy-session-test.c
@@ -42,6 +42,35 @@ const char *session_data =
"</window>"
"</session>";
+static gboolean load_stream_retval;
+
+static void
+load_from_stream_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ GMainLoop *loop = (GMainLoop *)user_data;
+
+ load_stream_retval = ephy_session_load_from_stream_finish (EPHY_SESSION (object), result, NULL);
+ g_main_loop_quit (loop);
+}
+
+static gboolean
+load_session_from_string (EphySession *session,
+ const char *data)
+{
+ GMainLoop *loop;
+ GInputStream *stream;
+
+ loop = g_main_loop_new (NULL, FALSE);
+ stream = g_memory_input_stream_new_from_data (data, -1, NULL);
+ ephy_session_load_from_stream (session, stream, 0, NULL, load_from_stream_cb, loop);
+ g_main_loop_run (loop);
+ g_main_loop_unref (loop);
+
+ return load_stream_retval;
+}
+
static void
test_ephy_session_load (void)
{
@@ -54,7 +83,7 @@ test_ephy_session_load (void)
session = EPHY_SESSION (ephy_shell_get_session (ephy_shell_get_default ()));
g_assert (session);
- ret = ephy_session_load_from_string (session, session_data, -1, 0);
+ ret = load_session_from_string (session, session_data);
g_assert (ret);
l = ephy_shell_get_windows (ephy_shell_get_default ());
@@ -89,7 +118,7 @@ test_ephy_session_load_empty_session (void)
session = EPHY_SESSION (ephy_shell_get_session (ephy_shell_get_default ()));
g_assert (session);
- ret = ephy_session_load_from_string (session, session_data_empty, -1, 0);
+ ret = load_session_from_string (session, session_data_empty);
g_assert (ret == FALSE);
/* Loading the session should have failed, but we should still get
@@ -139,7 +168,7 @@ test_ephy_session_load_many_windows (void)
session = EPHY_SESSION (ephy_shell_get_session (ephy_shell_get_default ()));
g_assert (session);
- ret = ephy_session_load_from_string (session, session_data_many_windows, -1, 0);
+ ret = load_session_from_string (session, session_data_many_windows);
g_assert (ret);
l = ephy_shell_get_windows (ephy_shell_get_default ());
@@ -174,7 +203,7 @@ open_uris_after_loading_session (const char** uris, int final_num_windows)
user_time = gdk_x11_display_get_user_time (gdk_display_get_default ());
- ret = ephy_session_load_from_string (session, session_data_many_windows, -1, 0);
+ ret = load_session_from_string (session, session_data_many_windows);
g_assert (ret);
l = ephy_shell_get_windows (ephy_shell_get_default ());