Home | History | Annotate | Download | only in dbus
      1 // Copyright (c) 2013 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_power_manager_client.h"
      6 
      7 #include "base/bind.h"
      8 #include "base/bind_helpers.h"
      9 #include "base/time/time.h"
     10 #include "chromeos/dbus/power_manager/policy.pb.h"
     11 
     12 namespace chromeos {
     13 
     14 FakePowerManagerClient::FakePowerManagerClient()
     15     : num_request_restart_calls_(0),
     16       num_request_shutdown_calls_(0),
     17       num_set_policy_calls_(0),
     18       num_set_is_projecting_calls_(0),
     19       num_pending_suspend_readiness_callbacks_(0),
     20       is_projecting_(false) {
     21 }
     22 
     23 FakePowerManagerClient::~FakePowerManagerClient() {
     24 }
     25 
     26 void FakePowerManagerClient::Init(dbus::Bus* bus) {
     27 }
     28 
     29 void FakePowerManagerClient::AddObserver(Observer* observer) {
     30   observers_.AddObserver(observer);
     31 }
     32 
     33 void FakePowerManagerClient::RemoveObserver(Observer* observer) {
     34   observers_.RemoveObserver(observer);
     35 }
     36 
     37 bool FakePowerManagerClient::HasObserver(Observer* observer) {
     38   return false;
     39 }
     40 
     41 void FakePowerManagerClient::DecreaseScreenBrightness(bool allow_off) {
     42 }
     43 
     44 void FakePowerManagerClient::IncreaseScreenBrightness() {
     45 }
     46 
     47 void FakePowerManagerClient::SetScreenBrightnessPercent(double percent,
     48                                                         bool gradual) {
     49 }
     50 
     51 void FakePowerManagerClient::GetScreenBrightnessPercent(
     52     const GetScreenBrightnessPercentCallback& callback) {
     53 }
     54 
     55 void FakePowerManagerClient::DecreaseKeyboardBrightness() {
     56 }
     57 
     58 void FakePowerManagerClient::IncreaseKeyboardBrightness() {
     59 }
     60 
     61 void FakePowerManagerClient::RequestStatusUpdate() {
     62 }
     63 
     64 void FakePowerManagerClient::RequestSuspend() {
     65 }
     66 
     67 void FakePowerManagerClient::RequestRestart() {
     68   ++num_request_restart_calls_;
     69 }
     70 
     71 void FakePowerManagerClient::RequestShutdown() {
     72   ++num_request_shutdown_calls_;
     73 }
     74 
     75 void FakePowerManagerClient::NotifyUserActivity(
     76     power_manager::UserActivityType type) {
     77 }
     78 
     79 void FakePowerManagerClient::NotifyVideoActivity(bool is_fullscreen) {
     80 }
     81 
     82 void FakePowerManagerClient::SetPolicy(
     83     const power_manager::PowerManagementPolicy& policy) {
     84   policy_ = policy;
     85   ++num_set_policy_calls_;
     86 }
     87 
     88 void FakePowerManagerClient::SetIsProjecting(bool is_projecting) {
     89   ++num_set_is_projecting_calls_;
     90   is_projecting_ = is_projecting;
     91 }
     92 
     93 base::Closure FakePowerManagerClient::GetSuspendReadinessCallback() {
     94   ++num_pending_suspend_readiness_callbacks_;
     95 
     96   return base::Bind(&FakePowerManagerClient::HandleSuspendReadiness,
     97                     base::Unretained(this));
     98 }
     99 
    100 int FakePowerManagerClient::GetNumPendingSuspendReadinessCallbacks() {
    101   return num_pending_suspend_readiness_callbacks_;
    102 }
    103 
    104 void FakePowerManagerClient::SendSuspendImminent() {
    105   FOR_EACH_OBSERVER(Observer, observers_, SuspendImminent());
    106 }
    107 
    108 void FakePowerManagerClient::SendSuspendDone() {
    109   FOR_EACH_OBSERVER(Observer, observers_, SuspendDone(base::TimeDelta()));
    110 }
    111 
    112 void FakePowerManagerClient::SendDarkSuspendImminent() {
    113   FOR_EACH_OBSERVER(Observer, observers_, DarkSuspendImminent());
    114 }
    115 
    116 void FakePowerManagerClient::SendPowerButtonEvent(
    117     bool down,
    118     const base::TimeTicks& timestamp) {
    119   FOR_EACH_OBSERVER(Observer, observers_,
    120                     PowerButtonEventReceived(down, timestamp));
    121 }
    122 
    123 void FakePowerManagerClient::HandleSuspendReadiness() {
    124   CHECK(num_pending_suspend_readiness_callbacks_ > 0);
    125 
    126   --num_pending_suspend_readiness_callbacks_;
    127 }
    128 
    129 } // namespace chromeos
    130