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.
4
5 #include "chromeos/dbus/fake_update_engine_client.h"
6
7 namespace chromeos {
8
FakeUpdateEngineClient()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) {
15 }
16
~FakeUpdateEngineClient()17 FakeUpdateEngineClient::~FakeUpdateEngineClient() {
18 }
19
Init(dbus::Bus * bus)20 void FakeUpdateEngineClient::Init(dbus::Bus* bus) {
21 }
22
AddObserver(Observer * observer)23 void FakeUpdateEngineClient::AddObserver(Observer* observer) {
24 observers_.AddObserver(observer);
25 }
26
RemoveObserver(Observer * observer)27 void FakeUpdateEngineClient::RemoveObserver(Observer* observer) {
28 observers_.RemoveObserver(observer);
29 }
30
HasObserver(Observer * observer)31 bool FakeUpdateEngineClient::HasObserver(Observer* observer) {
32 return false;
33 }
34
RequestUpdateCheck(const UpdateCheckCallback & callback)35 void FakeUpdateEngineClient::RequestUpdateCheck(
36 const UpdateCheckCallback& callback) {
37 callback.Run(update_check_result_);
38 }
39
Rollback()40 void FakeUpdateEngineClient::Rollback() {
41 rollback_call_count_++;
42 }
43
CanRollbackCheck(const RollbackCheckCallback & callback)44 void FakeUpdateEngineClient::CanRollbackCheck(
45 const RollbackCheckCallback& callback) {
46 can_rollback_call_count_++;
47 callback.Run(can_rollback_stub_result_);
48 }
49
RebootAfterUpdate()50 void FakeUpdateEngineClient::RebootAfterUpdate() {
51 reboot_after_update_call_count_++;
52 }
53
GetLastStatus()54 UpdateEngineClient::Status FakeUpdateEngineClient::GetLastStatus() {
55 if (status_queue_.empty())
56 return default_status_;
57
58 UpdateEngineClient::Status last_status = status_queue_.front();
59 status_queue_.pop();
60 return last_status;
61 }
62
NotifyObserversThatStatusChanged(const UpdateEngineClient::Status & status)63 void FakeUpdateEngineClient::NotifyObserversThatStatusChanged(
64 const UpdateEngineClient::Status& status) {
65 FOR_EACH_OBSERVER(Observer, observers_, UpdateStatusChanged(status));
66 }
67
SetChannel(const std::string & target_channel,bool is_powerwash_allowed)68 void FakeUpdateEngineClient::SetChannel(const std::string& target_channel,
69 bool is_powerwash_allowed) {
70 }
71
GetChannel(bool get_current_channel,const GetChannelCallback & callback)72 void FakeUpdateEngineClient::GetChannel(bool get_current_channel,
73 const GetChannelCallback& callback) {
74 }
75
set_default_status(const UpdateEngineClient::Status & status)76 void FakeUpdateEngineClient::set_default_status(
77 const UpdateEngineClient::Status& status) {
78 default_status_ = status;
79 }
80
set_update_check_result(const UpdateEngineClient::UpdateCheckResult & result)81 void FakeUpdateEngineClient::set_update_check_result(
82 const UpdateEngineClient::UpdateCheckResult& result) {
83 update_check_result_ = result;
84 }
85
86 } // namespace chromeos
87