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