[libsoup] test-utils: Added SOUP_TEST_REQUEST_CANCEL_IMMEDIATE flag
- From: Sergio Villar Senin <svillar src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libsoup] test-utils: Added SOUP_TEST_REQUEST_CANCEL_IMMEDIATE flag
- Date: Mon, 18 Feb 2013 10:20:17 +0000 (UTC)
commit 3f294a7b6661df7d8dfad3dff175f8807b257c44
Author: Sergio Villar Senin <svillar igalia com>
Date: Fri Feb 15 21:15:08 2013 +0100
test-utils: Added SOUP_TEST_REQUEST_CANCEL_IMMEDIATE flag
We were assuming that if the SOUP_TEST_REQUEST_CANCEL_SOON flag was not
present then we wanted an immediate cancelation. That worked but now we need
to add it to support more cancellation types.
https://bugzilla.gnome.org/show_bug.cgi?id=682527
tests/cache-test.c | 13 +++++++++----
tests/misc-test.c | 2 +-
tests/test-utils.c | 3 ++-
tests/test-utils.h | 3 ++-
4 files changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/tests/cache-test.c b/tests/cache-test.c
index ed8ca45..9469dc1 100644
--- a/tests/cache-test.c
+++ b/tests/cache-test.c
@@ -472,6 +472,7 @@ do_cancel_test (SoupURI *base_uri)
SoupCache *cache;
char *cache_dir;
char *body1, *body2;
+ guint flags;
debug_printf (1, "Cache cancel tests\n");
@@ -496,7 +497,8 @@ do_cancel_test (SoupURI *base_uri)
/* Check that messages are correctly processed on cancellations. */
debug_printf (1, " Cancel fresh resource with soup_session_message_cancel()\n");
- do_request_with_cancel (session, base_uri, "GET", "/1", SOUP_TEST_REQUEST_CANCEL_MESSAGE);
+ flags = SOUP_TEST_REQUEST_CANCEL_MESSAGE | SOUP_TEST_REQUEST_CANCEL_IMMEDIATE;
+ do_request_with_cancel (session, base_uri, "GET", "/1", flags);
if (cancelled_requests != 1) {
debug_printf (1, " invalid number of cancelled requests: %d (1 expected)\n",
cancelled_requests);
@@ -504,7 +506,8 @@ do_cancel_test (SoupURI *base_uri)
}
debug_printf (1, " Cancel fresh resource with g_cancellable_cancel()\n");
- do_request_with_cancel (session, base_uri, "GET", "/1", SOUP_TEST_REQUEST_CANCEL_CANCELLABLE);
+ flags = SOUP_TEST_REQUEST_CANCEL_CANCELLABLE | SOUP_TEST_REQUEST_CANCEL_IMMEDIATE;
+ do_request_with_cancel (session, base_uri, "GET", "/1", flags);
if (cancelled_requests != 1) {
debug_printf (1, " invalid number of cancelled requests: %d (1 expected)\n",
cancelled_requests);
@@ -522,7 +525,8 @@ do_cancel_test (SoupURI *base_uri)
/* Check that messages are correctly processed on cancellations. */
debug_printf (1, " Cancel a revalidating resource with soup_session_message_cancel()\n");
- do_request_with_cancel (session, base_uri, "GET", "/2", SOUP_TEST_REQUEST_CANCEL_MESSAGE);
+ flags = SOUP_TEST_REQUEST_CANCEL_MESSAGE | SOUP_TEST_REQUEST_CANCEL_IMMEDIATE;
+ do_request_with_cancel (session, base_uri, "GET", "/2", flags);
if (cancelled_requests != 2) {
debug_printf (1, " invalid number of cancelled requests: %d (2 expected)\n",
cancelled_requests);
@@ -530,7 +534,8 @@ do_cancel_test (SoupURI *base_uri)
}
debug_printf (1, " Cancel a revalidating resource with g_cancellable_cancel()\n");
- do_request_with_cancel (session, base_uri, "GET", "/2", SOUP_TEST_REQUEST_CANCEL_CANCELLABLE);
+ flags = SOUP_TEST_REQUEST_CANCEL_CANCELLABLE | SOUP_TEST_REQUEST_CANCEL_IMMEDIATE;
+ do_request_with_cancel (session, base_uri, "GET", "/2", flags);
if (cancelled_requests != 2) {
debug_printf (1, " invalid number of cancelled requests: %d (2 expected)\n",
cancelled_requests);
diff --git a/tests/misc-test.c b/tests/misc-test.c
index d434e9b..c0701f3 100644
--- a/tests/misc-test.c
+++ b/tests/misc-test.c
@@ -941,7 +941,7 @@ do_cancel_while_reading_req_test (void)
guint flags;
debug_printf (1, "\nCancelling (immediately) message while reading response (request api)\n");
- flags = SOUP_TEST_REQUEST_CANCEL_CANCELLABLE;
+ flags = SOUP_TEST_REQUEST_CANCEL_CANCELLABLE | SOUP_TEST_REQUEST_CANCEL_IMMEDIATE;
debug_printf (1, " Async session\n");
session = soup_test_session_new (SOUP_TYPE_SESSION_ASYNC,
diff --git a/tests/test-utils.c b/tests/test-utils.c
index cc9aa8e..754b84a 100644
--- a/tests/test-utils.c
+++ b/tests/test-utils.c
@@ -459,7 +459,8 @@ soup_test_request_send (SoupRequest *req,
}
data.loop = g_main_loop_new (g_main_context_get_thread_default (), FALSE);
- if (cancel_data) {
+ if (cancel_data &&
+ (flags & SOUP_TEST_REQUEST_CANCEL_SOON || flags & SOUP_TEST_REQUEST_CANCEL_IMMEDIATE)) {
guint interval = flags & SOUP_TEST_REQUEST_CANCEL_SOON ? 100 : 0;
g_timeout_add_full (G_PRIORITY_HIGH, interval, cancel_request_timeout, cancel_data, NULL);
}
diff --git a/tests/test-utils.h b/tests/test-utils.h
index 22a4a16..e7782ee 100644
--- a/tests/test-utils.h
+++ b/tests/test-utils.h
@@ -27,7 +27,8 @@ typedef enum {
SOUP_TEST_REQUEST_NONE = 0,
SOUP_TEST_REQUEST_CANCEL_MESSAGE = (1 << 0),
SOUP_TEST_REQUEST_CANCEL_CANCELLABLE = (1 << 1),
- SOUP_TEST_REQUEST_CANCEL_SOON = (1 << 2)
+ SOUP_TEST_REQUEST_CANCEL_SOON = (1 << 2),
+ SOUP_TEST_REQUEST_CANCEL_IMMEDIATE = (1 << 3)
} SoupTestRequestFlags;
SoupSession *soup_test_session_new (GType type, ...);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]