Revert of Roll src/third_party/WebKit e0eac24:489c548 (svn 193311:193320) (patchset...
[chromium-blink-merge.git] / chromeos / dbus / fake_update_engine_client.cc
bloba594a3e1e6d712d11af0ed1a19ea2577e5688c8c
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"
7 namespace chromeos {
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 request_update_check_call_count_(0),
14 rollback_call_count_(0),
15 can_rollback_call_count_(0) {
18 FakeUpdateEngineClient::~FakeUpdateEngineClient() {
21 void FakeUpdateEngineClient::Init(dbus::Bus* bus) {
24 void FakeUpdateEngineClient::AddObserver(Observer* observer) {
25 observers_.AddObserver(observer);
28 void FakeUpdateEngineClient::RemoveObserver(Observer* observer) {
29 observers_.RemoveObserver(observer);
32 bool FakeUpdateEngineClient::HasObserver(const Observer* observer) const {
33 return observers_.HasObserver(observer);
36 void FakeUpdateEngineClient::RequestUpdateCheck(
37 const UpdateCheckCallback& callback) {
38 request_update_check_call_count_++;
39 callback.Run(update_check_result_);
42 void FakeUpdateEngineClient::Rollback() {
43 rollback_call_count_++;
46 void FakeUpdateEngineClient::CanRollbackCheck(
47 const RollbackCheckCallback& callback) {
48 can_rollback_call_count_++;
49 callback.Run(can_rollback_stub_result_);
52 void FakeUpdateEngineClient::RebootAfterUpdate() {
53 reboot_after_update_call_count_++;
56 UpdateEngineClient::Status FakeUpdateEngineClient::GetLastStatus() {
57 if (status_queue_.empty())
58 return default_status_;
60 UpdateEngineClient::Status last_status = status_queue_.front();
61 status_queue_.pop();
62 return last_status;
65 void FakeUpdateEngineClient::NotifyObserversThatStatusChanged(
66 const UpdateEngineClient::Status& status) {
67 FOR_EACH_OBSERVER(Observer, observers_, UpdateStatusChanged(status));
70 void FakeUpdateEngineClient::SetChannel(const std::string& target_channel,
71 bool is_powerwash_allowed) {
74 void FakeUpdateEngineClient::GetChannel(bool get_current_channel,
75 const GetChannelCallback& callback) {
78 void FakeUpdateEngineClient::set_default_status(
79 const UpdateEngineClient::Status& status) {
80 default_status_ = status;
83 void FakeUpdateEngineClient::set_update_check_result(
84 const UpdateEngineClient::UpdateCheckResult& result) {
85 update_check_result_ = result;
88 } // namespace chromeos