1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chromeos/dbus/fake_update_engine_client.h"
9 FakeUpdateEngineClient::FakeUpdateEngineClient()
10 : update_check_result_(UpdateEngineClient::UPDATE_RESULT_SUCCESS
),
11 can_rollback_stub_result_(false),
12 reboot_after_update_call_count_(0),
13 rollback_call_count_(0),
14 can_rollback_call_count_(0) {
17 FakeUpdateEngineClient::~FakeUpdateEngineClient() {
20 void FakeUpdateEngineClient::Init(dbus::Bus
* bus
) {
23 void FakeUpdateEngineClient::AddObserver(Observer
* observer
) {
24 observers_
.AddObserver(observer
);
27 void FakeUpdateEngineClient::RemoveObserver(Observer
* observer
) {
28 observers_
.RemoveObserver(observer
);
31 bool FakeUpdateEngineClient::HasObserver(Observer
* observer
) {
35 void FakeUpdateEngineClient::RequestUpdateCheck(
36 const UpdateCheckCallback
& callback
) {
37 callback
.Run(update_check_result_
);
40 void FakeUpdateEngineClient::Rollback() {
41 rollback_call_count_
++;
44 void FakeUpdateEngineClient::CanRollbackCheck(
45 const RollbackCheckCallback
& callback
) {
46 can_rollback_call_count_
++;
47 callback
.Run(can_rollback_stub_result_
);
50 void FakeUpdateEngineClient::RebootAfterUpdate() {
51 reboot_after_update_call_count_
++;
54 UpdateEngineClient::Status
FakeUpdateEngineClient::GetLastStatus() {
55 if (status_queue_
.empty())
56 return default_status_
;
58 UpdateEngineClient::Status last_status
= status_queue_
.front();
63 void FakeUpdateEngineClient::NotifyObserversThatStatusChanged(
64 const UpdateEngineClient::Status
& status
) {
65 FOR_EACH_OBSERVER(Observer
, observers_
, UpdateStatusChanged(status
));
68 void FakeUpdateEngineClient::SetChannel(const std::string
& target_channel
,
69 bool is_powerwash_allowed
) {
72 void FakeUpdateEngineClient::GetChannel(bool get_current_channel
,
73 const GetChannelCallback
& callback
) {
76 void FakeUpdateEngineClient::set_default_status(
77 const UpdateEngineClient::Status
& status
) {
78 default_status_
= status
;
81 void FakeUpdateEngineClient::set_update_check_result(
82 const UpdateEngineClient::UpdateCheckResult
& result
) {
83 update_check_result_
= result
;
86 } // namespace chromeos