blob: a02d7ef56531d428324025b42b17c7c8d4e8de11 [file] [log] [blame]
Alex Deymoaea4c1c2015-08-19 20:24:43 -07001//
2// Copyright (C) 2014 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
Alex Deymoc705cc82014-02-19 11:15:00 -080016
Alex Deymoaab50e32014-11-10 19:55:35 -080017#include "update_engine/update_manager/update_manager.h"
18
Gilad Arnoldf9f85d62014-06-19 18:07:01 -070019#include <unistd.h>
20
Alex Deymo7b948f02014-03-10 17:01:10 -070021#include <algorithm>
Ben Chan02f7c1d2014-10-18 15:18:02 -070022#include <memory>
Alex Deymo7b948f02014-03-10 17:01:10 -070023#include <string>
Gilad Arnolddc4bb262014-07-23 10:45:19 -070024#include <tuple>
Alex Deymo94c06162014-03-21 20:34:46 -070025#include <utility>
Alex Deymo7b948f02014-03-10 17:01:10 -070026#include <vector>
27
28#include <base/bind.h>
Alex Deymo509dd532015-06-10 14:11:05 -070029#include <base/test/simple_test_clock.h>
Gilad Arnoldf62a4b82014-05-01 07:41:07 -070030#include <base/time/time.h>
Alex Vakulenko3f39d5c2015-10-13 09:27:13 -070031#include <brillo/message_loops/fake_message_loop.h>
32#include <brillo/message_loops/message_loop.h>
33#include <brillo/message_loops/message_loop_utils.h>
Alex Deymoc705cc82014-02-19 11:15:00 -080034#include <gmock/gmock.h>
Alex Deymo1f012912014-04-24 19:08:04 -070035#include <gtest/gtest.h>
Alex Deymoc705cc82014-02-19 11:15:00 -080036
Amin Hassani0468a762020-11-17 23:53:48 -080037#include "update_engine/cros/fake_system_state.h"
Alex Deymo63784a52014-05-28 10:46:14 -070038#include "update_engine/update_manager/default_policy.h"
39#include "update_engine/update_manager/fake_state.h"
40#include "update_engine/update_manager/mock_policy.h"
41#include "update_engine/update_manager/umtest_utils.h"
Alex Deymoc705cc82014-02-19 11:15:00 -080042
Alex Deymo7b948f02014-03-10 17:01:10 -070043using base::Bind;
44using base::Callback;
Gilad Arnoldf62a4b82014-05-01 07:41:07 -070045using base::Time;
46using base::TimeDelta;
Alex Vakulenko3f39d5c2015-10-13 09:27:13 -070047using brillo::MessageLoop;
48using brillo::MessageLoopRunMaxIterations;
Gilad Arnoldb3b05442014-05-30 14:25:05 -070049using chromeos_update_engine::ErrorCode;
Alex Deymo41a75a72014-04-15 15:36:22 -070050using chromeos_update_engine::FakeClock;
Amin Hassani0468a762020-11-17 23:53:48 -080051using chromeos_update_engine::FakeSystemState;
Alex Deymo7b948f02014-03-10 17:01:10 -070052using std::pair;
Alex Deymoc705cc82014-02-19 11:15:00 -080053using std::string;
Gilad Arnolddc4bb262014-07-23 10:45:19 -070054using std::tuple;
Ben Chan02f7c1d2014-10-18 15:18:02 -070055using std::unique_ptr;
Alex Deymo7b948f02014-03-10 17:01:10 -070056using std::vector;
Gilad Arnold5ef9c482014-03-03 13:51:02 -080057
Gilad Arnoldf62a4b82014-05-01 07:41:07 -070058namespace {
59
60// Generates a fixed timestamp for use in faking the current time.
61Time FixedTime() {
62 Time::Exploded now_exp;
63 now_exp.year = 2014;
64 now_exp.month = 3;
65 now_exp.day_of_week = 2;
66 now_exp.day_of_month = 18;
67 now_exp.hour = 8;
68 now_exp.minute = 5;
69 now_exp.second = 33;
70 now_exp.millisecond = 675;
Hidehiko Abeeab915e2018-09-23 16:54:06 +090071 Time time;
72 ignore_result(Time::FromLocalExploded(now_exp, &time));
73 return time;
Gilad Arnoldf62a4b82014-05-01 07:41:07 -070074}
75
76} // namespace
77
Alex Deymo63784a52014-05-28 10:46:14 -070078namespace chromeos_update_manager {
Alex Deymoc705cc82014-02-19 11:15:00 -080079
Alex Deymo63784a52014-05-28 10:46:14 -070080class UmUpdateManagerTest : public ::testing::Test {
Alex Deymoc705cc82014-02-19 11:15:00 -080081 protected:
Alex Vakulenko157fe302014-08-11 15:59:58 -070082 void SetUp() override {
Alex Deymo509dd532015-06-10 14:11:05 -070083 loop_.SetAsCurrent();
Amin Hassani0468a762020-11-17 23:53:48 -080084 FakeSystemState::CreateInstance();
Alex Deymo42c30c32014-04-24 18:41:18 -070085 fake_state_ = new FakeState();
Amin Hassani0468a762020-11-17 23:53:48 -080086 umut_.reset(new UpdateManager(
87 TimeDelta::FromSeconds(5), TimeDelta::FromSeconds(1), fake_state_));
Alex Deymoc705cc82014-02-19 11:15:00 -080088 }
89
Amin Hassani4b717432019-01-14 16:24:20 -080090 void TearDown() override { EXPECT_FALSE(loop_.PendingTasks()); }
Alex Deymo509dd532015-06-10 14:11:05 -070091
92 base::SimpleTestClock test_clock_;
Alex Vakulenko3f39d5c2015-10-13 09:27:13 -070093 brillo::FakeMessageLoop loop_{&test_clock_};
Alex Deymo63784a52014-05-28 10:46:14 -070094 FakeState* fake_state_; // Owned by the umut_.
Ben Chan02f7c1d2014-10-18 15:18:02 -070095 unique_ptr<UpdateManager> umut_;
Alex Deymoc705cc82014-02-19 11:15:00 -080096};
97
98// The FailingPolicy implements a single method and make it always fail. This
99// class extends the DefaultPolicy class to allow extensions of the Policy
100// class without extending nor changing this test.
101class FailingPolicy : public DefaultPolicy {
Gilad Arnoldf9f85d62014-06-19 18:07:01 -0700102 public:
103 explicit FailingPolicy(int* num_called_p) : num_called_p_(num_called_p) {}
104 FailingPolicy() : FailingPolicy(nullptr) {}
Amin Hassani4b717432019-01-14 16:24:20 -0800105 EvalStatus UpdateCheckAllowed(EvaluationContext* ec,
106 State* state,
Alex Vakulenko157fe302014-08-11 15:59:58 -0700107 string* error,
108 UpdateCheckParams* result) const override {
Gilad Arnoldf9f85d62014-06-19 18:07:01 -0700109 if (num_called_p_)
110 (*num_called_p_)++;
Alex Deymoc705cc82014-02-19 11:15:00 -0800111 *error = "FailingPolicy failed.";
Alex Deymoe636c3c2014-03-11 19:02:08 -0700112 return EvalStatus::kFailed;
Alex Deymoc705cc82014-02-19 11:15:00 -0800113 }
Gilad Arnoldf9f85d62014-06-19 18:07:01 -0700114
115 protected:
Alex Deymof329b932014-10-30 01:37:48 -0700116 string PolicyName() const override { return "FailingPolicy"; }
Gilad Arnoldf9f85d62014-06-19 18:07:01 -0700117
118 private:
119 int* num_called_p_;
Alex Deymoc705cc82014-02-19 11:15:00 -0800120};
121
Alex Deymo7b948f02014-03-10 17:01:10 -0700122// The LazyPolicy always returns EvalStatus::kAskMeAgainLater.
Alex Deymoc705cc82014-02-19 11:15:00 -0800123class LazyPolicy : public DefaultPolicy {
Amin Hassani4b717432019-01-14 16:24:20 -0800124 EvalStatus UpdateCheckAllowed(EvaluationContext* ec,
125 State* state,
Alex Vakulenko157fe302014-08-11 15:59:58 -0700126 string* error,
127 UpdateCheckParams* result) const override {
Alex Deymoe636c3c2014-03-11 19:02:08 -0700128 return EvalStatus::kAskMeAgainLater;
Alex Deymoc705cc82014-02-19 11:15:00 -0800129 }
Gilad Arnoldf9f85d62014-06-19 18:07:01 -0700130
131 protected:
Alex Deymof329b932014-10-30 01:37:48 -0700132 string PolicyName() const override { return "LazyPolicy"; }
Gilad Arnoldf9f85d62014-06-19 18:07:01 -0700133};
134
Gilad Arnoldfd45a732014-08-07 15:53:46 -0700135// A policy that sleeps for a predetermined amount of time, then checks for a
136// wallclock-based time threshold (if given) and returns
137// EvalStatus::kAskMeAgainLater if not passed; otherwise, returns
138// EvalStatus::kSucceeded. Increments a counter every time it is being queried,
139// if a pointer to it is provided.
Gilad Arnoldf9f85d62014-06-19 18:07:01 -0700140class DelayPolicy : public DefaultPolicy {
141 public:
Gilad Arnoldfd45a732014-08-07 15:53:46 -0700142 DelayPolicy(int sleep_secs, Time time_threshold, int* num_called_p)
Amin Hassani4b717432019-01-14 16:24:20 -0800143 : sleep_secs_(sleep_secs),
144 time_threshold_(time_threshold),
Gilad Arnoldf9f85d62014-06-19 18:07:01 -0700145 num_called_p_(num_called_p) {}
Amin Hassani4b717432019-01-14 16:24:20 -0800146 EvalStatus UpdateCheckAllowed(EvaluationContext* ec,
147 State* state,
Alex Vakulenko157fe302014-08-11 15:59:58 -0700148 string* error,
149 UpdateCheckParams* result) const override {
Gilad Arnoldf9f85d62014-06-19 18:07:01 -0700150 if (num_called_p_)
151 (*num_called_p_)++;
Gilad Arnoldfd45a732014-08-07 15:53:46 -0700152
153 // Sleep for a predetermined amount of time.
154 if (sleep_secs_ > 0)
155 sleep(sleep_secs_);
156
157 // Check for a time threshold. This can be used to ensure that the policy
158 // has some non-constant dependency.
159 if (time_threshold_ < Time::Max() &&
160 ec->IsWallclockTimeGreaterThan(time_threshold_))
161 return EvalStatus::kSucceeded;
162
Gilad Arnoldf9f85d62014-06-19 18:07:01 -0700163 return EvalStatus::kAskMeAgainLater;
164 }
165
166 protected:
Alex Deymof329b932014-10-30 01:37:48 -0700167 string PolicyName() const override { return "DelayPolicy"; }
Gilad Arnoldf9f85d62014-06-19 18:07:01 -0700168
169 private:
170 int sleep_secs_;
Gilad Arnoldfd45a732014-08-07 15:53:46 -0700171 Time time_threshold_;
Gilad Arnoldf9f85d62014-06-19 18:07:01 -0700172 int* num_called_p_;
Alex Deymoc705cc82014-02-19 11:15:00 -0800173};
174
Alex Deymo7b948f02014-03-10 17:01:10 -0700175// AccumulateCallsCallback() adds to the passed |acc| accumulator vector pairs
176// of EvalStatus and T instances. This allows to create a callback that keeps
177// track of when it is called and the arguments passed to it, to be used with
Alex Deymo63784a52014-05-28 10:46:14 -0700178// the UpdateManager::AsyncPolicyRequest().
Amin Hassani4b717432019-01-14 16:24:20 -0800179template <typename T>
Alex Deymo7b948f02014-03-10 17:01:10 -0700180static void AccumulateCallsCallback(vector<pair<EvalStatus, T>>* acc,
Amin Hassani4b717432019-01-14 16:24:20 -0800181 EvalStatus status,
182 const T& result) {
Alex Deymo7b948f02014-03-10 17:01:10 -0700183 acc->push_back(std::make_pair(status, result));
184}
185
Alex Deymo0d11c602014-04-23 20:12:20 -0700186// Tests that policy requests are completed successfully. It is important that
187// this tests cover all policy requests as defined in Policy.
Alex Deymo63784a52014-05-28 10:46:14 -0700188TEST_F(UmUpdateManagerTest, PolicyRequestCallUpdateCheckAllowed) {
Alex Deymo0d11c602014-04-23 20:12:20 -0700189 UpdateCheckParams result;
Amin Hassani4b717432019-01-14 16:24:20 -0800190 EXPECT_EQ(EvalStatus::kSucceeded,
191 umut_->PolicyRequest(&Policy::UpdateCheckAllowed, &result));
Alex Deymoc705cc82014-02-19 11:15:00 -0800192}
193
Alex Deymo63784a52014-05-28 10:46:14 -0700194TEST_F(UmUpdateManagerTest, PolicyRequestCallUpdateCanStart) {
Gilad Arnolddc4bb262014-07-23 10:45:19 -0700195 UpdateState update_state = UpdateState();
Amin Hassanied37d682018-04-06 13:22:00 -0700196 update_state.interactive = true;
Gilad Arnolddc4bb262014-07-23 10:45:19 -0700197 update_state.is_delta_payload = false;
198 update_state.first_seen = FixedTime();
199 update_state.num_checks = 1;
200 update_state.num_failures = 0;
201 update_state.failures_last_updated = Time();
202 update_state.download_urls = vector<string>{"http://fake/url/"};
203 update_state.download_errors_max = 10;
Gilad Arnold78ecbfc2014-10-22 14:38:25 -0700204 update_state.p2p_downloading_disabled = false;
205 update_state.p2p_sharing_disabled = false;
Gilad Arnold349ac832014-10-06 14:20:28 -0700206 update_state.p2p_num_attempts = 0;
207 update_state.p2p_first_attempted = Time();
Gilad Arnolddc4bb262014-07-23 10:45:19 -0700208 update_state.last_download_url_idx = -1;
209 update_state.last_download_url_num_errors = 0;
210 update_state.download_errors = vector<tuple<int, ErrorCode, Time>>();
211 update_state.backoff_expiry = Time();
212 update_state.is_backoff_disabled = false;
213 update_state.scatter_wait_period = TimeDelta::FromSeconds(15);
214 update_state.scatter_check_threshold = 4;
215 update_state.scatter_wait_period_max = TimeDelta::FromSeconds(60);
216 update_state.scatter_check_threshold_min = 2;
217 update_state.scatter_check_threshold_max = 8;
218
Gilad Arnold42f253b2014-06-25 12:39:17 -0700219 UpdateDownloadParams result;
Amin Hassani4b717432019-01-14 16:24:20 -0800220 EXPECT_EQ(
221 EvalStatus::kSucceeded,
222 umut_->PolicyRequest(&Policy::UpdateCanStart, &result, update_state));
Gilad Arnoldf62a4b82014-05-01 07:41:07 -0700223}
224
Alex Deymo63784a52014-05-28 10:46:14 -0700225TEST_F(UmUpdateManagerTest, PolicyRequestCallsDefaultOnError) {
226 umut_->set_policy(new FailingPolicy());
Alex Deymoc705cc82014-02-19 11:15:00 -0800227
228 // Tests that the DefaultPolicy instance is called when the method fails,
229 // which will set this as true.
Alex Deymo0d11c602014-04-23 20:12:20 -0700230 UpdateCheckParams result;
231 result.updates_enabled = false;
Amin Hassani4b717432019-01-14 16:24:20 -0800232 EvalStatus status =
233 umut_->PolicyRequest(&Policy::UpdateCheckAllowed, &result);
Gilad Arnoldaf2f6ae2014-04-28 14:14:52 -0700234 EXPECT_EQ(EvalStatus::kSucceeded, status);
Alex Deymo0d11c602014-04-23 20:12:20 -0700235 EXPECT_TRUE(result.updates_enabled);
Alex Deymoc705cc82014-02-19 11:15:00 -0800236}
237
Gilad Arnold897b5e52014-05-21 09:37:18 -0700238// This test only applies to debug builds where DCHECK is enabled.
239#if DCHECK_IS_ON
240TEST_F(UmUpdateManagerTest, PolicyRequestDoesntBlockDeathTest) {
241 // The update manager should die (DCHECK) if a policy called synchronously
242 // returns a kAskMeAgainLater value.
Alex Deymo0d11c602014-04-23 20:12:20 -0700243 UpdateCheckParams result;
Alex Deymo63784a52014-05-28 10:46:14 -0700244 umut_->set_policy(new LazyPolicy());
Gilad Arnold897b5e52014-05-21 09:37:18 -0700245 EXPECT_DEATH(umut_->PolicyRequest(&Policy::UpdateCheckAllowed, &result), "");
Alex Deymoc705cc82014-02-19 11:15:00 -0800246}
Gilad Arnold897b5e52014-05-21 09:37:18 -0700247#endif // DCHECK_IS_ON
Alex Deymoc705cc82014-02-19 11:15:00 -0800248
Alex Deymo63784a52014-05-28 10:46:14 -0700249TEST_F(UmUpdateManagerTest, AsyncPolicyRequestDelaysEvaluation) {
Alex Deymo7b948f02014-03-10 17:01:10 -0700250 // To avoid differences in code execution order between an AsyncPolicyRequest
251 // call on a policy that returns AskMeAgainLater the first time and one that
252 // succeeds the first time, we ensure that the passed callback is called from
253 // the main loop in both cases even when we could evaluate it right now.
Alex Deymo63784a52014-05-28 10:46:14 -0700254 umut_->set_policy(new FailingPolicy());
Alex Deymo7b948f02014-03-10 17:01:10 -0700255
Alex Deymo0d11c602014-04-23 20:12:20 -0700256 vector<pair<EvalStatus, UpdateCheckParams>> calls;
Amin Hassani4b717432019-01-14 16:24:20 -0800257 Callback<void(EvalStatus, const UpdateCheckParams&)> callback =
258 Bind(AccumulateCallsCallback<UpdateCheckParams>, &calls);
Alex Deymo7b948f02014-03-10 17:01:10 -0700259
Gilad Arnoldfd45a732014-08-07 15:53:46 -0700260 umut_->AsyncPolicyRequest(callback, &Policy::UpdateCheckAllowed);
Alex Deymo7b948f02014-03-10 17:01:10 -0700261 // The callback should wait until we run the main loop for it to be executed.
Alex Deymo80f70ff2016-02-10 16:08:11 -0800262 EXPECT_EQ(0U, calls.size());
Alex Deymo509dd532015-06-10 14:11:05 -0700263 MessageLoopRunMaxIterations(MessageLoop::current(), 100);
Alex Deymo80f70ff2016-02-10 16:08:11 -0800264 EXPECT_EQ(1U, calls.size());
Alex Deymo7b948f02014-03-10 17:01:10 -0700265}
266
Gilad Arnoldfd45a732014-08-07 15:53:46 -0700267TEST_F(UmUpdateManagerTest, AsyncPolicyRequestTimeoutDoesNotFire) {
Gilad Arnoldf9f85d62014-06-19 18:07:01 -0700268 // Set up an async policy call to return immediately, then wait a little and
269 // ensure that the timeout event does not fire.
270 int num_called = 0;
271 umut_->set_policy(new FailingPolicy(&num_called));
272
273 vector<pair<EvalStatus, UpdateCheckParams>> calls;
274 Callback<void(EvalStatus, const UpdateCheckParams&)> callback =
275 Bind(AccumulateCallsCallback<UpdateCheckParams>, &calls);
276
Gilad Arnoldfd45a732014-08-07 15:53:46 -0700277 umut_->AsyncPolicyRequest(callback, &Policy::UpdateCheckAllowed);
Gilad Arnoldf9f85d62014-06-19 18:07:01 -0700278 // Run the main loop, ensure that policy was attempted once before deferring
279 // to the default.
Alex Deymo509dd532015-06-10 14:11:05 -0700280 MessageLoopRunMaxIterations(MessageLoop::current(), 100);
Gilad Arnoldf9f85d62014-06-19 18:07:01 -0700281 EXPECT_EQ(1, num_called);
Alex Deymo80f70ff2016-02-10 16:08:11 -0800282 ASSERT_EQ(1U, calls.size());
Gilad Arnoldf9f85d62014-06-19 18:07:01 -0700283 EXPECT_EQ(EvalStatus::kSucceeded, calls[0].first);
284 // Wait for the timeout to expire, run the main loop again, ensure that
285 // nothing happened.
Alex Deymo509dd532015-06-10 14:11:05 -0700286 test_clock_.Advance(TimeDelta::FromSeconds(2));
287 MessageLoopRunMaxIterations(MessageLoop::current(), 10);
Gilad Arnoldf9f85d62014-06-19 18:07:01 -0700288 EXPECT_EQ(1, num_called);
Alex Deymo80f70ff2016-02-10 16:08:11 -0800289 EXPECT_EQ(1U, calls.size());
Gilad Arnoldf9f85d62014-06-19 18:07:01 -0700290}
291
292TEST_F(UmUpdateManagerTest, AsyncPolicyRequestTimesOut) {
Amin Hassani0468a762020-11-17 23:53:48 -0800293 auto* fake_clock = FakeSystemState::Get()->fake_clock();
Gilad Arnoldfd45a732014-08-07 15:53:46 -0700294 // Set up an async policy call to exceed its expiration timeout, make sure
295 // that the default policy was not used (no callback) and that evaluation is
296 // reattempted.
Gilad Arnoldf9f85d62014-06-19 18:07:01 -0700297 int num_called = 0;
298 umut_->set_policy(new DelayPolicy(
Amin Hassani4b717432019-01-14 16:24:20 -0800299 0,
Amin Hassani0468a762020-11-17 23:53:48 -0800300 fake_clock->GetWallclockTime() + TimeDelta::FromSeconds(3),
Amin Hassani4b717432019-01-14 16:24:20 -0800301 &num_called));
Gilad Arnoldf9f85d62014-06-19 18:07:01 -0700302
303 vector<pair<EvalStatus, UpdateCheckParams>> calls;
304 Callback<void(EvalStatus, const UpdateCheckParams&)> callback =
305 Bind(AccumulateCallsCallback<UpdateCheckParams>, &calls);
306
Gilad Arnoldfd45a732014-08-07 15:53:46 -0700307 umut_->AsyncPolicyRequest(callback, &Policy::UpdateCheckAllowed);
Gilad Arnoldf9f85d62014-06-19 18:07:01 -0700308 // Run the main loop, ensure that policy was attempted once but the callback
309 // was not invoked.
Alex Deymo509dd532015-06-10 14:11:05 -0700310 MessageLoopRunMaxIterations(MessageLoop::current(), 100);
Gilad Arnoldf9f85d62014-06-19 18:07:01 -0700311 EXPECT_EQ(1, num_called);
Alex Deymo80f70ff2016-02-10 16:08:11 -0800312 EXPECT_EQ(0U, calls.size());
Gilad Arnoldfd45a732014-08-07 15:53:46 -0700313 // Wait for the expiration timeout to expire, run the main loop again,
314 // ensure that reevaluation occurred but callback was not invoked (i.e.
315 // default policy was not consulted).
Alex Deymo509dd532015-06-10 14:11:05 -0700316 test_clock_.Advance(TimeDelta::FromSeconds(2));
Amin Hassani0468a762020-11-17 23:53:48 -0800317 fake_clock->SetWallclockTime(fake_clock->GetWallclockTime() +
Gilad Arnoldfd45a732014-08-07 15:53:46 -0700318 TimeDelta::FromSeconds(2));
Alex Deymo509dd532015-06-10 14:11:05 -0700319 MessageLoopRunMaxIterations(MessageLoop::current(), 10);
Gilad Arnoldfd45a732014-08-07 15:53:46 -0700320 EXPECT_EQ(2, num_called);
Alex Deymo80f70ff2016-02-10 16:08:11 -0800321 EXPECT_EQ(0U, calls.size());
Gilad Arnoldfd45a732014-08-07 15:53:46 -0700322 // Wait for reevaluation due to delay to happen, ensure that it occurs and
323 // that the callback is invoked.
Alex Deymo509dd532015-06-10 14:11:05 -0700324 test_clock_.Advance(TimeDelta::FromSeconds(2));
Amin Hassani0468a762020-11-17 23:53:48 -0800325 fake_clock->SetWallclockTime(fake_clock->GetWallclockTime() +
Gilad Arnoldfd45a732014-08-07 15:53:46 -0700326 TimeDelta::FromSeconds(2));
Alex Deymo509dd532015-06-10 14:11:05 -0700327 MessageLoopRunMaxIterations(MessageLoop::current(), 10);
Gilad Arnoldfd45a732014-08-07 15:53:46 -0700328 EXPECT_EQ(3, num_called);
Alex Deymo80f70ff2016-02-10 16:08:11 -0800329 ASSERT_EQ(1U, calls.size());
Gilad Arnoldf9f85d62014-06-19 18:07:01 -0700330 EXPECT_EQ(EvalStatus::kSucceeded, calls[0].first);
Gilad Arnoldf9f85d62014-06-19 18:07:01 -0700331}
332
Alex Deymo63784a52014-05-28 10:46:14 -0700333} // namespace chromeos_update_manager