[libsoup/carlosgc/authenticate: 5/6] tests: stop using soup_session_pause/unpause_message in tests
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup/carlosgc/authenticate: 5/6] tests: stop using soup_session_pause/unpause_message in tests
- Date: Tue, 27 Oct 2020 12:58:54 +0000 (UTC)
commit 0eb17ab6484b9ba0dcd34864ef73dbbf26bc3113
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Tue Oct 27 13:50:01 2020 +0100
tests: stop using soup_session_pause/unpause_message in tests
Remove the tests checking old api that has already been removed.
libsoup/soup-message.c | 17 +---
tests/meson.build | 1 -
tests/misc-test.c | 104 --------------------
tests/pull-api-test.c | 256 -------------------------------------------------
tests/sniffing-test.c | 102 +++-----------------
5 files changed, 14 insertions(+), 466 deletions(-)
---
diff --git a/libsoup/soup-message.c b/libsoup/soup-message.c
index a9805aa6..039f872b 100644
--- a/libsoup/soup-message.c
+++ b/libsoup/soup-message.c
@@ -399,26 +399,13 @@ soup_message_class_init (SoupMessageClass *message_class)
* @type: the content type that we got from sniffing
* @params: (element-type utf8 utf8): a #GHashTable with the parameters
*
- * This signal is emitted after #SoupMessage::got-headers, and
- * before the first #SoupMessage::got-chunk. If content
- * sniffing is disabled, or no content sniffing will be
+ * This signal is emitted after #SoupMessage::got-headers.
+ * If content sniffing is disabled, or no content sniffing will be
* performed, due to the sniffer deciding to trust the
* Content-Type sent by the server, this signal is emitted
* immediately after #SoupMessage::got-headers, and @type is
* %NULL.
*
- * If the #SoupContentSniffer feature is enabled, and the
- * sniffer decided to perform sniffing, the first
- * #SoupMessage::got-chunk emission may be delayed, so that the
- * sniffer has enough data to correctly sniff the content. It
- * notified the library user that the content has been
- * sniffed, and allows it to change the header contents in the
- * message, if desired.
- *
- * After this signal is emitted, the data that was spooled so
- * that sniffing could be done is delivered on the first
- * emission of #SoupMessage::got-chunk.
- *
* Since: 2.28
**/
signals[CONTENT_SNIFFED] =
diff --git a/tests/meson.build b/tests/meson.build
index 1adeb167..c3346ed7 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -86,7 +86,6 @@ if have_apache
['connection', false, []],
['range', false, []],
['proxy', false, []],
- ['pull-api', false, []],
]
configure_file(output : 'httpd.conf',
diff --git a/tests/misc-test.c b/tests/misc-test.c
index 56f5ab44..39247ba5 100644
--- a/tests/misc-test.c
+++ b/tests/misc-test.c
@@ -662,108 +662,6 @@ do_aliases_test (void)
soup_test_session_abort_unref (session);
}
-static void
-do_pause_abort_test (void)
-{
- SoupSession *session;
- SoupMessage *msg;
- gpointer ptr;
-
- g_test_bug ("673905");
-
- g_test_skip ("FIXME: Session has 1 ref at the end, SessionAsync had a different clear_message
function with different semantics.");
- return;
-
- session = soup_test_session_new (SOUP_TYPE_SESSION, NULL);
-
- msg = soup_message_new_from_uri ("GET", base_uri);
- soup_session_send_async (session, msg, G_PRIORITY_DEFAULT, NULL, NULL, NULL);
- soup_session_pause_message (session, msg);
-
- g_object_add_weak_pointer (G_OBJECT (msg), &ptr);
- g_object_unref (msg);
- soup_test_session_abort_unref (session);
-
- g_assert_null (ptr);
-}
-
-static GMainLoop *pause_cancel_loop;
-
-static void
-pause_cancel_got_headers (SoupMessage *msg, gpointer user_data)
-{
- SoupSession *session = user_data;
-
- soup_session_pause_message (session, msg);
- g_main_loop_quit (pause_cancel_loop);
-}
-
-static gboolean
-idle_quit (gpointer loop)
-{
- g_main_loop_quit (loop);
- return FALSE;
-}
-
-static void
-pause_cancel_finished (SoupMessage *msg,
- gboolean *finished)
-{
- *finished = TRUE;
- /* Quit the main loop in the next iteration, because finished is emitted
- * right before the item is unqueued.
- */
- g_idle_add (idle_quit, pause_cancel_loop);
-}
-
-static gboolean
-pause_cancel_timeout (gpointer user_data)
-{
- gboolean *timed_out = user_data;
-
- *timed_out = TRUE;
- g_main_loop_quit (pause_cancel_loop);
- return FALSE;
-}
-
-static void
-do_pause_cancel_test (void)
-{
- SoupSession *session;
- SoupMessage *msg;
- gboolean finished = FALSE, timed_out = FALSE;
- guint timeout_id;
-
- g_test_bug ("745094");
-
- session = soup_test_session_new (SOUP_TYPE_SESSION, NULL);
- pause_cancel_loop = g_main_loop_new (NULL, FALSE);
-
- timeout_id = g_timeout_add_seconds (5, pause_cancel_timeout, &timed_out);
-
- msg = soup_message_new_from_uri ("GET", base_uri);
- g_signal_connect (msg, "got-headers",
- G_CALLBACK (pause_cancel_got_headers), session);
- g_signal_connect (msg, "finished",
- G_CALLBACK (pause_cancel_finished), &finished);
- soup_session_send_async (session, msg, G_PRIORITY_DEFAULT, NULL, NULL, NULL);
- g_main_loop_run (pause_cancel_loop);
- g_assert_false (finished);
-
- soup_session_cancel_message (session, msg, SOUP_STATUS_CANCELLED);
- g_main_loop_run (pause_cancel_loop);
- g_assert_true (finished);
- g_assert_false (timed_out);
-
- soup_test_assert_message_status (msg, SOUP_STATUS_CANCELLED);
- g_object_unref (msg);
-
- soup_test_session_abort_unref (session);
- g_main_loop_unref (pause_cancel_loop);
- if (!timed_out)
- g_source_remove (timeout_id);
-}
-
int
main (int argc, char **argv)
{
@@ -801,8 +699,6 @@ main (int argc, char **argv)
g_test_add_func ("/misc/cancel-while-reading/req/delayed", do_cancel_while_reading_delayed_req_test);
g_test_add_func ("/misc/cancel-while-reading/req/preemptive",
do_cancel_while_reading_preemptive_req_test);
g_test_add_func ("/misc/aliases", do_aliases_test);
- g_test_add_func ("/misc/pause-abort", do_pause_abort_test);
- g_test_add_func ("/misc/pause-cancel", do_pause_cancel_test);
ret = g_test_run ();
diff --git a/tests/sniffing-test.c b/tests/sniffing-test.c
index 19fc850d..03cfd874 100644
--- a/tests/sniffing-test.c
+++ b/tests/sniffing-test.c
@@ -7,7 +7,6 @@
SoupSession *session;
SoupURI *base_uri;
-SoupMessageBody *chunk_data;
static void
server_callback (SoupServer *server,
@@ -137,74 +136,32 @@ server_callback (SoupServer *server,
soup_message_body_complete (response_body);
}
-static gboolean
-unpause_msg (gpointer data)
-{
- SoupMessage *msg = (SoupMessage*)data;
- debug_printf (2, " unpause\n");
- soup_session_unpause_message (session, msg);
- return FALSE;
-}
-
-
static void
-content_sniffed (SoupMessage *msg, char *content_type, GHashTable *params, gpointer data)
+content_sniffed (SoupMessage *msg,
+ char *content_type,
+ GHashTable *params)
{
- gboolean should_pause = GPOINTER_TO_INT (data);
-
debug_printf (2, " content-sniffed -> %s\n", content_type);
soup_test_assert (g_object_get_data (G_OBJECT (msg), "got-chunk") == NULL,
"got-chunk got emitted before content-sniffed");
g_object_set_data (G_OBJECT (msg), "content-sniffed", GINT_TO_POINTER (TRUE));
-
- if (should_pause) {
- debug_printf (2, " pause\n");
- soup_session_pause_message (session, msg);
- g_idle_add (unpause_msg, msg);
- }
}
static void
-got_headers (SoupMessage *msg, gpointer data)
+got_headers (SoupMessage *msg)
{
- gboolean should_pause = GPOINTER_TO_INT (data);
-
debug_printf (2, " got-headers\n");
soup_test_assert (g_object_get_data (G_OBJECT (msg), "content-sniffed") == NULL,
"content-sniffed got emitted before got-headers");
g_object_set_data (G_OBJECT (msg), "got-headers", GINT_TO_POINTER (TRUE));
-
- if (should_pause) {
- debug_printf (2, " pause\n");
- soup_session_pause_message (session, msg);
- g_idle_add (unpause_msg, msg);
- }
-}
-
-static void
-got_chunk (SoupMessage *msg, GBytes *chunk, gpointer data)
-{
- gboolean should_accumulate = GPOINTER_TO_INT (data);
-
- debug_printf (2, " got-chunk\n");
-
- g_object_set_data (G_OBJECT (msg), "got-chunk", GINT_TO_POINTER (TRUE));
-
- if (!should_accumulate) {
- if (!chunk_data)
- chunk_data = soup_message_body_new ();
- soup_message_body_append_bytes (chunk_data, chunk);
- }
}
static void
do_signals_test (gboolean should_content_sniff,
- gboolean should_pause,
- gboolean should_accumulate,
gboolean chunked_encoding,
gboolean empty_response)
{
@@ -214,10 +171,8 @@ do_signals_test (gboolean should_content_sniff,
GError *error = NULL;
GBytes *body = NULL;
- debug_printf (1, "do_signals_test(%ssniff, %spause, %saccumulate, %schunked, %sempty)\n",
+ debug_printf (1, "do_signals_test(%ssniff, %schunked, %sempty)\n",
should_content_sniff ? "" : "!",
- should_pause ? "" : "!",
- should_accumulate ? "" : "!",
chunked_encoding ? "" : "!",
empty_response ? "" : "!");
@@ -235,19 +190,12 @@ do_signals_test (gboolean should_content_sniff,
soup_message_set_uri (msg, uri);
-#if 0
- soup_message_body_set_accumulate (msg->response_body, should_accumulate);
-#endif
-
g_object_connect (msg,
- "signal::got-headers", got_headers, GINT_TO_POINTER (should_pause),
- "signal::got-chunk", got_chunk, GINT_TO_POINTER (should_accumulate),
- "signal::content_sniffed", content_sniffed, GINT_TO_POINTER (should_pause),
+ "signal::got-headers", got_headers, NULL,
+ "signal::content_sniffed", content_sniffed, NULL,
NULL);
-#if 0
- soup_test_session_async_send_message (session, msg);
-#endif
+ body = soup_test_session_async_send (session, msg);
if (should_content_sniff) {
soup_test_assert (g_object_get_data (G_OBJECT (msg), "content-sniffed") != NULL,
@@ -264,13 +212,6 @@ do_signals_test (gboolean should_content_sniff,
g_assert_no_error (error);
}
- if (!should_accumulate && chunk_data)
- body = soup_message_body_flatten (chunk_data);
-#if 0
- else if (msg->response_body)
- body = soup_message_body_flatten (msg->response_body);
-#endif
-
if (body) {
//g_message ("|||body (%zu): %s", g_bytes_get_size (body), (char*)g_bytes_get_data (body,
NULL));
//g_message ("|||expected (%zu): %s", g_bytes_get_size (expected), (char*)g_bytes_get_data
(expected, NULL));
@@ -279,7 +220,6 @@ do_signals_test (gboolean should_content_sniff,
g_bytes_unref (expected);
g_bytes_unref (body);
- g_clear_pointer (&chunk_data, soup_message_body_free);
soup_uri_free (uri);
g_object_unref (msg);
}
@@ -289,35 +229,17 @@ do_signals_tests (gconstpointer data)
{
gboolean should_content_sniff = GPOINTER_TO_INT (data);
- g_test_skip ("FIXME");
- return;
-
if (!should_content_sniff)
soup_session_remove_feature_by_type (session, SOUP_TYPE_CONTENT_SNIFFER);
do_signals_test (should_content_sniff,
- FALSE, FALSE, FALSE, FALSE);
- do_signals_test (should_content_sniff,
- FALSE, FALSE, TRUE, FALSE);
+ FALSE, FALSE);
do_signals_test (should_content_sniff,
- FALSE, TRUE, FALSE, FALSE);
- do_signals_test (should_content_sniff,
- FALSE, TRUE, TRUE, FALSE);
-
- do_signals_test (should_content_sniff,
- TRUE, TRUE, FALSE, FALSE);
- do_signals_test (should_content_sniff,
- TRUE, TRUE, TRUE, FALSE);
- do_signals_test (should_content_sniff,
- TRUE, FALSE, FALSE, FALSE);
- do_signals_test (should_content_sniff,
- TRUE, FALSE, TRUE, FALSE);
-
- /* FIXME g_test_bug ("587907") */
+ TRUE, FALSE);
do_signals_test (should_content_sniff,
- TRUE, TRUE, FALSE, TRUE);
+ FALSE, TRUE);
do_signals_test (should_content_sniff,
- TRUE, TRUE, TRUE, TRUE);
+ TRUE, TRUE);
if (!should_content_sniff)
soup_session_add_feature_by_type (session, SOUP_TYPE_CONTENT_SNIFFER);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]