Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / chromeos / dbus / fake_cros_disks_client.h
blobf10d9c04778a100f2f624cf1f30d57bd1ec47831
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.
5 #ifndef CHROMEOS_DBUS_FAKE_CROS_DISKS_CLIENT_H_
6 #define CHROMEOS_DBUS_FAKE_CROS_DISKS_CLIENT_H_
8 #include <string>
10 #include "base/callback.h"
11 #include "chromeos/dbus/cros_disks_client.h"
13 namespace chromeos {
15 // A fake implementation of CrosDiskeClient. This class provides a fake behavior
16 // and the user of this class can raise a fake mouse events.
17 class FakeCrosDisksClient : public CrosDisksClient {
18 public:
19 FakeCrosDisksClient();
20 virtual ~FakeCrosDisksClient();
22 // CrosDisksClient overrides
23 virtual void Init(dbus::Bus* bus) OVERRIDE;
24 virtual void Mount(const std::string& source_path,
25 const std::string& source_format,
26 const std::string& mount_label,
27 const base::Closure& callback,
28 const base::Closure& error_callback) OVERRIDE;
29 virtual void Unmount(const std::string& device_path,
30 UnmountOptions options,
31 const base::Closure& callback,
32 const base::Closure& error_callback) OVERRIDE;
33 virtual void EnumerateAutoMountableDevices(
34 const EnumerateAutoMountableDevicesCallback& callback,
35 const base::Closure& error_callback) OVERRIDE;
36 virtual void EnumerateMountEntries(
37 const EnumerateMountEntriesCallback& callback,
38 const base::Closure& error_callback) OVERRIDE;
39 virtual void Format(const std::string& device_path,
40 const std::string& filesystem,
41 const base::Closure& callback,
42 const base::Closure& error_callback) OVERRIDE;
43 virtual void GetDeviceProperties(
44 const std::string& device_path,
45 const GetDevicePropertiesCallback& callback,
46 const base::Closure& error_callback) OVERRIDE;
47 virtual void SetMountEventHandler(
48 const MountEventHandler& mount_event_handler) OVERRIDE;
49 virtual void SetMountCompletedHandler(
50 const MountCompletedHandler& mount_completed_handler) OVERRIDE;
51 virtual void SetFormatCompletedHandler(
52 const FormatCompletedHandler& format_completed_handler) OVERRIDE;
54 // Used in tests to simulate signals sent by cros disks layer.
55 // Invokes handlers set in |SetMountEventHandler|, |SetMountCompletedHandler|,
56 // and |SetFormatCompletedHandler|.
57 bool SendMountEvent(MountEventType event, const std::string& path);
58 bool SendMountCompletedEvent(MountError error_code,
59 const std::string& source_path,
60 MountType mount_type,
61 const std::string& mount_path);
62 bool SendFormatCompletedEvent(FormatError error_code,
63 const std::string& device_path);
65 // Returns how many times Unmount() was called.
66 int unmount_call_count() const {
67 return unmount_call_count_;
70 // Returns the |device_path| parameter from the last invocation of Unmount().
71 const std::string& last_unmount_device_path() const {
72 return last_unmount_device_path_;
75 // Returns the |options| parameter from the last invocation of Unmount().
76 UnmountOptions last_unmount_options() const {
77 return last_unmount_options_;
80 // Makes the subsequent Unmount() calls fail. Unmount() succeeds by default.
81 void MakeUnmountFail() {
82 unmount_success_ = false;
85 // Sets a listener callbackif the following Unmount() call is success or not.
86 // Unmount() calls the corresponding callback given as a parameter.
87 void set_unmount_listener(base::Closure listener) {
88 unmount_listener_ = listener;
91 // Returns how many times Format() was called.
92 int format_call_count() const {
93 return format_call_count_;
96 // Returns the |device_path| parameter from the last invocation of Format().
97 const std::string& last_format_device_path() const {
98 return last_format_device_path_;
101 // Returns the |filesystem| parameter from the last invocation of Format().
102 const std::string& last_format_filesystem() const {
103 return last_format_filesystem_;
106 // Makes the subsequent Format() calls fail. Format() succeeds by default.
107 void MakeFormatFail() {
108 format_success_ = false;
111 private:
112 MountEventHandler mount_event_handler_;
113 MountCompletedHandler mount_completed_handler_;
114 FormatCompletedHandler format_completed_handler_;
116 int unmount_call_count_;
117 std::string last_unmount_device_path_;
118 UnmountOptions last_unmount_options_;
119 bool unmount_success_;
120 base::Closure unmount_listener_;
121 int format_call_count_;
122 std::string last_format_device_path_;
123 std::string last_format_filesystem_;
124 bool format_success_;
127 } // namespace chromeos
129 #endif // CHROMEOS_DBUS_FAKE_CROS_DISKS_CLIENT_H_