summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSergio Villar Senin <svillar@igalia.com>2013-02-15 21:15:08 +0100
committerSergio Villar Senin <svillar@igalia.com>2013-02-18 11:03:15 +0100
commit3f294a7b6661df7d8dfad3dff175f8807b257c44 (patch)
treedaa43778ef03daf44d9756da6b67df5e7a7f829b /tests
parent89a3db7081798ffe0cab1a8c3a173a6c0a61297c (diff)
downloadlibsoup-3f294a7b6661df7d8dfad3dff175f8807b257c44.tar.gz
libsoup-3f294a7b6661df7d8dfad3dff175f8807b257c44.tar.bz2
libsoup-3f294a7b6661df7d8dfad3dff175f8807b257c44.zip
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
Diffstat (limited to 'tests')
-rw-r--r--tests/cache-test.c13
-rw-r--r--tests/misc-test.c2
-rw-r--r--tests/test-utils.c3
-rw-r--r--tests/test-utils.h3
4 files changed, 14 insertions, 7 deletions
diff --git a/tests/cache-test.c b/tests/cache-test.c
index ed8ca453..9469dc12 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 d434e9bd..c0701f3d 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 cc9aa8e1..754b84a9 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 22a4a163..e7782ee4 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, ...);