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

Unified Diff: omaha_request_action_unittest.cc

Issue 3035007: Switch OmahaEvent's error_code to ActionExitCode. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: explicit single argument ctor Created 10 years, 5 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 | « omaha_request_action.cc ('k') | update_attempter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: omaha_request_action_unittest.cc
diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc
index 05ec1b83d9f55cf758d7fbeed386b5c2e98eb29c..a4ecb2917d4ce997973a75a6e152ccadc7261ead 100755
--- a/omaha_request_action_unittest.cc
+++ b/omaha_request_action_unittest.cc
@@ -597,6 +597,66 @@ TEST(OmahaRequestActionTest, FormatUpdateCheckOutputTest) {
EXPECT_EQ(post_str.find("o:event"), string::npos);
}
+TEST(OmahaRequestActionTest, FormatSuccessEventOutputTest) {
+ vector<char> post_data;
+ OmahaRequestParams params("machine_id",
+ "user_id",
+ OmahaRequestParams::kOsPlatform,
+ OmahaRequestParams::kOsVersion,
+ "service_pack",
+ "x86-generic",
+ OmahaRequestParams::kAppId,
+ "0.1.0.0",
+ "en-US",
+ "unittest_track",
+ false, // delta okay
+ "http://url");
+ TestEvent(params,
+ new OmahaEvent(OmahaEvent::kTypeUpdateDownloadStarted),
+ "invalid xml>",
+ &post_data);
+ // convert post_data to string
+ string post_str(&post_data[0], post_data.size());
+ string expected_event = StringPrintf(
+ " <o:event eventtype=\"%d\" eventresult=\"%d\"></o:event>\n",
+ OmahaEvent::kTypeUpdateDownloadStarted,
+ OmahaEvent::kResultSuccess);
+ EXPECT_NE(post_str.find(expected_event), string::npos);
+ EXPECT_EQ(post_str.find("o:updatecheck"), string::npos);
+}
+
+TEST(OmahaRequestActionTest, FormatErrorEventOutputTest) {
+ vector<char> post_data;
+ OmahaRequestParams params("machine_id",
+ "user_id",
+ OmahaRequestParams::kOsPlatform,
+ OmahaRequestParams::kOsVersion,
+ "service_pack",
+ "x86-generic",
+ OmahaRequestParams::kAppId,
+ "0.1.0.0",
+ "en-US",
+ "unittest_track",
+ false, // delta okay
+ "http://url");
+ TestEvent(params,
+ new OmahaEvent(OmahaEvent::kTypeDownloadComplete,
+ OmahaEvent::kResultError,
+ kActionCodeError),
+ "invalid xml>",
+ &post_data);
+ // convert post_data to string
+ string post_str(&post_data[0], post_data.size());
+ string expected_event = StringPrintf(
+ " <o:event eventtype=\"%d\" eventresult=\"%d\" "
+ "errorcode=\"%d\"></o:event>\n",
+ OmahaEvent::kTypeDownloadComplete,
+ OmahaEvent::kResultError,
+ kActionCodeError);
+ EXPECT_NE(post_str.find(expected_event), string::npos);
+ EXPECT_EQ(post_str.find("o:updatecheck"), string::npos);
+}
+
TEST(OmahaRequestActionTest, FormatEventOutputTest) {
vector<char> post_data;
OmahaRequestParams params("machine_id",
@@ -614,7 +674,7 @@ TEST(OmahaRequestActionTest, FormatEventOutputTest) {
TestEvent(params,
new OmahaEvent(OmahaEvent::kTypeDownloadComplete,
OmahaEvent::kResultError,
- 5),
+ kActionCodeError),
"invalid xml>",
&post_data);
// convert post_data to string
@@ -624,7 +684,7 @@ TEST(OmahaRequestActionTest, FormatEventOutputTest) {
"errorcode=\"%d\"></o:event>\n",
OmahaEvent::kTypeDownloadComplete,
OmahaEvent::kResultError,
- 5);
+ kActionCodeError);
EXPECT_NE(post_str.find(expected_event), string::npos);
EXPECT_EQ(post_str.find("o:updatecheck"), string::npos);
}
@@ -653,9 +713,7 @@ TEST(OmahaRequestActionTest, IsEventTest) {
OmahaRequestAction event_action(
params,
- new OmahaEvent(OmahaEvent::kTypeInstallComplete,
- OmahaEvent::kResultError,
- 0),
+ new OmahaEvent(OmahaEvent::kTypeUpdateComplete),
new MockHttpFetcher(http_response.data(),
http_response.size()));
EXPECT_TRUE(event_action.IsEvent());
@@ -691,4 +749,23 @@ TEST(OmahaRequestActionTest, FormatDeltaOkayOutputTest) {
}
}
+TEST(OmahaRequestActionTest, OmahaEventTest) {
+ OmahaEvent default_event;
+ EXPECT_EQ(OmahaEvent::kTypeUnknown, default_event.type);
+ EXPECT_EQ(OmahaEvent::kResultError, default_event.result);
+ EXPECT_EQ(kActionCodeError, default_event.error_code);
+
+ OmahaEvent success_event(OmahaEvent::kTypeUpdateDownloadStarted);
+ EXPECT_EQ(OmahaEvent::kTypeUpdateDownloadStarted, success_event.type);
+ EXPECT_EQ(OmahaEvent::kResultSuccess, success_event.result);
+ EXPECT_EQ(kActionCodeSuccess, success_event.error_code);
+
+ OmahaEvent error_event(OmahaEvent::kTypeUpdateDownloadFinished,
+ OmahaEvent::kResultError,
+ kActionCodeError);
+ EXPECT_EQ(OmahaEvent::kTypeUpdateDownloadFinished, error_event.type);
+ EXPECT_EQ(OmahaEvent::kResultError, error_event.result);
+ EXPECT_EQ(kActionCodeError, error_event.error_code);
+}
+
} // namespace chromeos_update_engine
« no previous file with comments | « omaha_request_action.cc ('k') | update_attempter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698