Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Unified Diff: http_fetcher_unittest.cc

Issue 3106038: AU: Expose the server's HTTP response code in HttpFetcher. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: rebase and add redirect response code checks Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « http_fetcher.h ('k') | libcurl_http_fetcher.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: http_fetcher_unittest.cc
diff --git a/http_fetcher_unittest.cc b/http_fetcher_unittest.cc
index f7dad8ea7b09fab781f879b2d8cce4ee5c32f3c6..d0962677224fec039016f1a05335a416fb26e2aa 100644
--- a/http_fetcher_unittest.cc
+++ b/http_fetcher_unittest.cc
@@ -161,6 +161,7 @@ class HttpFetcherTestDelegate : public HttpFetcherDelegate {
memcpy(str, bytes, length);
}
virtual void TransferComplete(HttpFetcher* fetcher, bool successful) {
+ EXPECT_EQ(200, fetcher->http_response_code());
g_main_loop_quit(loop_);
}
GMainLoop* loop_;
@@ -332,6 +333,7 @@ TYPED_TEST(HttpFetcherTest, AbortTest) {
g_main_loop_run(loop);
g_source_destroy(timeout_source_);
+ EXPECT_EQ(0, fetcher->http_response_code());
}
g_main_loop_unref(loop);
}
@@ -345,6 +347,7 @@ class FlakyHttpFetcherTestDelegate : public HttpFetcherDelegate {
}
virtual void TransferComplete(HttpFetcher* fetcher, bool successful) {
EXPECT_TRUE(successful);
+ EXPECT_EQ(206, fetcher->http_response_code());
g_main_loop_quit(loop_);
}
string data;
@@ -398,6 +401,7 @@ class FailureHttpFetcherTestDelegate : public HttpFetcherDelegate {
}
virtual void TransferComplete(HttpFetcher* fetcher, bool successful) {
EXPECT_FALSE(successful);
+ EXPECT_EQ(0, fetcher->http_response_code());
g_main_loop_quit(loop_);
}
GMainLoop* loop_;
@@ -466,6 +470,12 @@ class RedirectHttpFetcherTestDelegate : public HttpFetcherDelegate {
}
virtual void TransferComplete(HttpFetcher* fetcher, bool successful) {
EXPECT_EQ(expected_successful_, successful);
+ if (expected_successful_)
+ EXPECT_EQ(200, fetcher->http_response_code());
+ else {
+ EXPECT_GE(fetcher->http_response_code(), 301);
+ EXPECT_LE(fetcher->http_response_code(), 307);
+ }
g_main_loop_quit(loop_);
}
bool expected_successful_;
« no previous file with comments | « http_fetcher.h ('k') | libcurl_http_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698