update_engine: Re-introduce RefreshDevicePolicy() before computing update params. The update_manager refreshes the policy for its own usage, but the code that still remains outside the update_manager and depends on device policy settings has to reload the policy manually. This patch re-introduces the call to RefreshDevicePolicy() from CalculateUpdateParams() that was removed in CL:209101 since some code still requires it. BUG=chromium:425827 TEST=delopyed this patch on R39 and tested that the scattering value from the policy is used. TEST=Changed UpdateAttempterTest.UpdateTest to check this. Verified it fails without the change on update_attempter.cc Change-Id: I051382987b507752e52a0af87d869a8845f3db6f Reviewed-on: https://chromium-review.googlesource.com/224808 Commit-Queue: Alex Deymo <[email protected]> Tested-by: Alex Deymo <[email protected]> Reviewed-by: Gaurav Shah <[email protected]>
diff --git a/update_attempter_unittest.cc b/update_attempter_unittest.cc index 0bfc31d..31b1452 100644 --- a/update_attempter_unittest.cc +++ b/update_attempter_unittest.cc
@@ -430,13 +430,23 @@ void UpdateAttempterTest::UpdateTestStart() { attempter_.set_http_response_code(200); - InSequence s; - for (size_t i = 0; i < arraysize(kUpdateActionTypes); ++i) { - EXPECT_CALL(*processor_, - EnqueueAction(Property(&AbstractAction::Type, - kUpdateActionTypes[i]))).Times(1); + + // Expect that the device policy is loaded by the UpdateAttempter at some + // point by calling RefreshDevicePolicy. + policy::MockDevicePolicy* device_policy = new policy::MockDevicePolicy(); + attempter_.policy_provider_.reset(new policy::PolicyProvider(device_policy)); + EXPECT_CALL(*device_policy, LoadPolicy()) + .Times(testing::AtLeast(1)).WillRepeatedly(Return(true)); + + { + InSequence s; + for (size_t i = 0; i < arraysize(kUpdateActionTypes); ++i) { + EXPECT_CALL(*processor_, + EnqueueAction(Property(&AbstractAction::Type, + kUpdateActionTypes[i]))).Times(1); + } + EXPECT_CALL(*processor_, StartProcessing()).Times(1); } - EXPECT_CALL(*processor_, StartProcessing()).Times(1); attempter_.Update("", "", "", "", false, false); g_idle_add(&StaticUpdateTestVerify, this);