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, |