Change code to ignore ping Omaha requests that are empty
BUG=chromium-os:15498
TEST=Unit tests, manually applied update and ensure we are ignoring
empty pings
Change-Id: I49223098a3dbc0b12504f3561c9feb1a02a1dbe3
Reviewed-on: http://gerrit.chromium.org/gerrit/2184
Tested-by: Thieu Le <thieule@chromium.org>
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc
index d18dd6c..7a0d796 100644
--- a/omaha_request_action_unittest.cc
+++ b/omaha_request_action_unittest.cc
@@ -836,6 +836,29 @@
EXPECT_EQ(post_str.find("o:ping"), string::npos);
}
+TEST(OmahaRequestActionTest, IgnoreEmptyPingTest) {
+ // This test ensures that we ignore empty ping only requests.
+ NiceMock<PrefsMock> prefs;
+ int64_t now = Time::Now().ToInternalValue();
+ EXPECT_CALL(prefs, GetInt64(kPrefsLastActivePingDay, _))
+ .WillOnce(DoAll(SetArgumentPointee<1>(now), Return(true)));
+ EXPECT_CALL(prefs, GetInt64(kPrefsLastRollCallPingDay, _))
+ .WillOnce(DoAll(SetArgumentPointee<1>(now), Return(true)));
+ EXPECT_CALL(prefs, SetInt64(kPrefsLastActivePingDay, _)).Times(0);
+ EXPECT_CALL(prefs, SetInt64(kPrefsLastRollCallPingDay, _)).Times(0);
+ vector<char> post_data;
+ EXPECT_TRUE(
+ TestUpdateCheck(&prefs,
+ kDefaultTestParams,
+ GetNoUpdateResponse(OmahaRequestParams::kAppId),
+ -1,
+ true, // ping_only
+ kActionCodeSuccess,
+ NULL,
+ &post_data));
+ EXPECT_EQ(post_data.size(), 0);
+}
+
TEST(OmahaRequestActionTest, BackInTimePingTest) {
NiceMock<PrefsMock> prefs;
int64_t future =