Only fsync leveldb's directory when the manifest is being updated.
[chromium-blink-merge.git] / chromeos / dbus / fake_update_engine_client.h
blob46bbd5e965aa477d67e37c47fc6d68226527a25e
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 virtual ~FakeUpdateEngineClient();
24 // Overrides
25 virtual void AddObserver(Observer* observer) OVERRIDE;
26 virtual void RemoveObserver(Observer* observer) OVERRIDE;
27 virtual bool HasObserver(Observer* observer) OVERRIDE;
28 virtual void RequestUpdateCheck(const UpdateCheckCallback& callback) OVERRIDE;
29 virtual void RebootAfterUpdate() OVERRIDE;
30 virtual void SetReleaseTrack(const std::string& track) OVERRIDE;
31 virtual void GetReleaseTrack(const GetReleaseTrackCallback& callback)
32 OVERRIDE;
33 virtual Status GetLastStatus() OVERRIDE;
35 // Pushes UpdateEngineClient::Status in the queue to test changing status.
36 // GetLastStatus() returns the status set by this method in FIFO order.
37 // See set_default_status().
38 void PushLastStatus(const UpdateEngineClient::Status& status) {
39 status_queue_.push(status);
42 // Sets the default UpdateEngineClient::Status. GetLastStatus() returns the
43 // value set here if |status_queue_| is empty.
44 void set_default_status(const UpdateEngineClient::Status& status);
46 // Sets a value returned by RequestUpdateCheck().
47 void set_update_check_result(
48 const UpdateEngineClient::UpdateCheckResult& result);
50 // Returns how many times RebootAfterUpdate() is called.
51 int reboot_after_update_call_count() {
52 return reboot_after_update_call_count_;
55 private:
56 std::queue<UpdateEngineClient::Status> status_queue_;
57 UpdateEngineClient::Status default_status_;
58 UpdateEngineClient::UpdateCheckResult update_check_result_;
59 int reboot_after_update_call_count_;
62 } // namespace chromeos
64 #endif // CHROMEOS_DBUS_FAKE_UPDATE_ENGINE_CLIENT_H_