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

Unified Diff: omaha_request_action_unittest.cc

Issue 6154003: AU: Reduce instances of signalling the crash reporter. (Closed) Base URL: http://git.chromium.org/git/update_engine.git@master
Patch Set: Created 9 years, 11 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
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;
« omaha_request_action.cc ('K') | « omaha_request_action.cc ('k') | update_attempter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698