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

Unified Diff: omaha_request_action_unittest.cc

Issue 5993007: AU: Send a previous version event after reboot following an update. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git@master
Patch Set: GetString appends to the string Created 9 years, 12 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') | prefs.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 8fe24822c16e9d86baad5a3d09cc618ff55a3f3c..4ac2b745f149298093e90518516c4cbc88ead765 100755
--- a/omaha_request_action_unittest.cc
+++ b/omaha_request_action_unittest.cc
@@ -521,7 +521,11 @@ TEST(OmahaRequestActionTest, ParseIntTest) {
TEST(OmahaRequestActionTest, FormatUpdateCheckOutputTest) {
vector<char> post_data;
- ASSERT_FALSE(TestUpdateCheck(NULL, // prefs
+ NiceMock<PrefsMock> prefs;
+ EXPECT_CALL(prefs, GetString(kPrefsPreviousVersion, _))
+ .WillOnce(DoAll(SetArgumentPointee<1>(string("")), Return(true)));
+ EXPECT_CALL(prefs, SetString(kPrefsPreviousVersion, _)).Times(0);
+ ASSERT_FALSE(TestUpdateCheck(&prefs,
kDefaultTestParams,
"invalid xml>",
-1,
@@ -538,6 +542,35 @@ TEST(OmahaRequestActionTest, FormatUpdateCheckOutputTest) {
EXPECT_EQ(post_str.find("o:event"), string::npos);
}
+TEST(OmahaRequestActionTest, FormatUpdateCheckPrevVersionOutputTest) {
+ vector<char> post_data;
+ NiceMock<PrefsMock> prefs;
+ EXPECT_CALL(prefs, GetString(kPrefsPreviousVersion, _))
+ .WillOnce(DoAll(SetArgumentPointee<1>(string("1.2.3.4")), Return(true)));
+ EXPECT_CALL(prefs, SetString(kPrefsPreviousVersion, ""))
+ .WillOnce(Return(true));
+ ASSERT_FALSE(TestUpdateCheck(&prefs,
+ kDefaultTestParams,
+ "invalid xml>",
+ -1,
+ kActionCodeOmahaRequestXMLParseError,
+ NULL, // response
+ &post_data));
+ // convert post_data to string
+ string post_str(&post_data[0], post_data.size());
+ EXPECT_NE(post_str.find(" <o:ping a=\"-1\" r=\"-1\"></o:ping>\n"
+ " <o:updatecheck></o:updatecheck>\n"),
+ string::npos);
+ EXPECT_NE(post_str.find("hardware_class=\"OEM MODEL 09235 7471\""),
+ string::npos);
+ string prev_version_event = StringPrintf(
+ " <o:event eventtype=\"%d\" eventresult=\"%d\" "
+ "previousversion=\"1.2.3.4\"></o:event>\n",
+ OmahaEvent::kTypeUpdateComplete,
+ OmahaEvent::kResultSuccessReboot);
+ EXPECT_NE(post_str.find(prev_version_event), string::npos);
+}
+
TEST(OmahaRequestActionTest, FormatSuccessEventOutputTest) {
vector<char> post_data;
TestEvent(kDefaultTestParams,
« no previous file with comments | « omaha_request_action.cc ('k') | prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698