Index: omaha_request_action_unittest.cc |
diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc |
index 4ac2b745f149298093e90518516c4cbc88ead765..dd0068e8562f8a966b6e6c3f62fa0232ccfbb5c3 100755 |
--- a/omaha_request_action_unittest.cc |
+++ b/omaha_request_action_unittest.cc |
@@ -198,7 +198,8 @@ bool TestUpdateCheck(PrefsInterface* prefs, |
void TestEvent(const OmahaRequestParams& params, |
OmahaEvent* event, |
const string& http_response, |
- vector<char>* out_post_data) { |
+ vector<char>* out_post_data, |
+ int expected_http_response_code) { |
GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE); |
MockHttpFetcher* fetcher = new MockHttpFetcher(http_response.data(), |
http_response.size(), |
@@ -206,6 +207,12 @@ void TestEvent(const OmahaRequestParams& params, |
NiceMock<PrefsMock> prefs; |
OmahaRequestAction action(&prefs, params, event, fetcher); |
OmahaRequestActionTestProcessorDelegate delegate; |
+ if (expected_http_response_code < 200 || expected_http_response_code > 299) { |
+ fetcher->FailTransfer(expected_http_response_code); |
+ delegate.expected_code_ = |
+ static_cast<ActionExitCode>(kActionCodeOmahaRequestHTTPResponseBase + |
+ expected_http_response_code); |
+ } |
delegate.loop_ = loop; |
ActionProcessor processor; |
processor.set_delegate(&delegate); |
@@ -576,7 +583,8 @@ TEST(OmahaRequestActionTest, FormatSuccessEventOutputTest) { |
TestEvent(kDefaultTestParams, |
new OmahaEvent(OmahaEvent::kTypeUpdateDownloadStarted), |
"invalid xml>", |
- &post_data); |
+ &post_data, |
+ 200); |
// convert post_data to string |
string post_str(&post_data[0], post_data.size()); |
string expected_event = StringPrintf( |
@@ -595,7 +603,8 @@ TEST(OmahaRequestActionTest, FormatErrorEventOutputTest) { |
OmahaEvent::kResultError, |
kActionCodeError), |
"invalid xml>", |
- &post_data); |
+ &post_data, |
+ 200); |
// convert post_data to string |
string post_str(&post_data[0], post_data.size()); |
string expected_event = StringPrintf( |
@@ -615,7 +624,8 @@ TEST(OmahaRequestActionTest, FormatEventOutputTest) { |
OmahaEvent::kResultError, |
kActionCodeError), |
"invalid xml>", |
- &post_data); |
+ &post_data, |
+ 200); |
// convert post_data to string |
string post_str(&post_data[0], post_data.size()); |
string expected_event = StringPrintf( |
@@ -628,6 +638,15 @@ TEST(OmahaRequestActionTest, FormatEventOutputTest) { |
EXPECT_EQ(post_str.find("o:updatecheck"), string::npos); |
} |
+TEST(OmahaRequestActionTest, EventFailureTest) { |
+ vector<char> post_data; |
+ TestEvent(kDefaultTestParams, |
+ new OmahaEvent(OmahaEvent::kTypeUpdateDownloadStarted), |
+ "foo", |
+ NULL, |
+ 500); |
+} |
+ |
TEST(OmahaRequestActionTest, IsEventTest) { |
string http_response("doesn't matter"); |
NiceMock<PrefsMock> prefs; |