Don't preload rarely seen large images
[chromium-blink-merge.git] / chromeos / dbus / fake_update_engine_client.h
blob68c0aa435182e40fcc1b254c32ea3eddfb46c635
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 #ifndef CHROMEOS_DBUS_FAKE_UPDATE_ENGINE_CLIENT_H_
6 #define CHROMEOS_DBUS_FAKE_UPDATE_ENGINE_CLIENT_H_
8 #include <queue>
9 #include <string>
11 #include "chromeos/dbus/update_engine_client.h"
13 namespace chromeos {
15 // A fake implementation of UpdateEngineClient. The user of this class can
16 // use set_update_engine_client_status() to set a fake last Status and
17 // GetLastStatus() returns the fake with no modification. Other methods do
18 // nothing.
19 class FakeUpdateEngineClient : public UpdateEngineClient {
20 public:
21 FakeUpdateEngineClient();
22 ~FakeUpdateEngineClient() override;
24 // UpdateEngineClient overrides
25 void Init(dbus::Bus* bus) override;
26 void AddObserver(Observer* observer) override;
27 void RemoveObserver(Observer* observer) override;
28 bool HasObserver(const Observer* observer) const override;
29 void RequestUpdateCheck(const UpdateCheckCallback& callback) override;
30 void RebootAfterUpdate() override;
31 void Rollback() override;
32 void CanRollbackCheck(const RollbackCheckCallback& callback) override;
33 Status GetLastStatus() override;
34 void SetChannel(const std::string& target_channel,
35 bool is_powerwash_allowed) override;
36 void GetChannel(bool get_current_channel,
37 const GetChannelCallback& callback) override;
39 // Pushes UpdateEngineClient::Status in the queue to test changing status.
40 // GetLastStatus() returns the status set by this method in FIFO order.
41 // See set_default_status().
42 void PushLastStatus(const UpdateEngineClient::Status& status) {
43 status_queue_.push(status);
46 // Sends status change notification.
47 void NotifyObserversThatStatusChanged(
48 const UpdateEngineClient::Status& status);
50 // Sets the default UpdateEngineClient::Status. GetLastStatus() returns the
51 // value set here if |status_queue_| is empty.
52 void set_default_status(const UpdateEngineClient::Status& status);
54 // Sets a value returned by RequestUpdateCheck().
55 void set_update_check_result(
56 const UpdateEngineClient::UpdateCheckResult& result);
58 void set_can_rollback_check_result(bool result) {
59 can_rollback_stub_result_ = result;
62 // Returns how many times RebootAfterUpdate() is called.
63 int reboot_after_update_call_count() const {
64 return reboot_after_update_call_count_;
67 // Returns how many times RequestUpdateCheck() is called.
68 int request_update_check_call_count() const {
69 return request_update_check_call_count_;
72 // Returns how many times Rollback() is called.
73 int rollback_call_count() const { return rollback_call_count_; }
75 // Returns how many times Rollback() is called.
76 int can_rollback_call_count() const { return can_rollback_call_count_; }
78 private:
79 base::ObserverList<Observer> observers_;
80 std::queue<UpdateEngineClient::Status> status_queue_;
81 UpdateEngineClient::Status default_status_;
82 UpdateEngineClient::UpdateCheckResult update_check_result_;
83 bool can_rollback_stub_result_;
84 int reboot_after_update_call_count_;
85 int request_update_check_call_count_;
86 int rollback_call_count_;
87 int can_rollback_call_count_;
90 } // namespace chromeos
92 #endif // CHROMEOS_DBUS_FAKE_UPDATE_ENGINE_CLIENT_H_