- add sources.
[platform/framework/web/crosswalk.git] / src / chromeos / disks / mock_disk_mount_manager.h
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 #ifndef CHROMEOS_DISKS_MOCK_DISK_MOUNT_MANAGER_H_
6 #define CHROMEOS_DISKS_MOCK_DISK_MOUNT_MANAGER_H_
7
8 #include <string>
9
10 #include "base/observer_list.h"
11 #include "chromeos/dbus/cros_disks_client.h"
12 #include "chromeos/disks/disk_mount_manager.h"
13 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15
16 namespace chromeos {
17 namespace disks {
18
19 class MockDiskMountManager : public DiskMountManager {
20  public:
21   MockDiskMountManager();
22   virtual ~MockDiskMountManager();
23
24   // DiskMountManager override.
25   MOCK_METHOD0(Init, void(void));
26   MOCK_METHOD1(AddObserver, void(DiskMountManager::Observer*));
27   MOCK_METHOD1(RemoveObserver, void(DiskMountManager::Observer*));
28   MOCK_CONST_METHOD0(disks, const DiskMountManager::DiskMap&(void));
29   MOCK_CONST_METHOD1(FindDiskBySourcePath,
30                      const DiskMountManager::Disk*(const std::string&));
31   MOCK_CONST_METHOD0(mount_points,
32                      const DiskMountManager::MountPointMap&(void));
33   MOCK_METHOD0(RequestMountInfoRefresh, void(void));
34   MOCK_METHOD4(MountPath, void(const std::string&, const std::string&,
35                                const std::string&, MountType));
36   MOCK_METHOD3(UnmountPath, void(const std::string&,
37                                  UnmountOptions,
38                                  const DiskMountManager::UnmountPathCallback&));
39   MOCK_METHOD1(FormatMountedDevice, void(const std::string&));
40   MOCK_METHOD2(
41       UnmountDeviceRecursively,
42       void(const std::string&,
43            const DiskMountManager::UnmountDeviceRecursivelyCallbackType&));
44
45   // Invokes fake device insert events.
46   void NotifyDeviceInsertEvents();
47
48   // Invokes fake device remove events.
49   void NotifyDeviceRemoveEvents();
50
51   // Sets up default results for mock methods.
52   void SetupDefaultReplies();
53
54   // Creates a fake disk entry for the mounted device. This function is
55   // primarily for StorageMonitorTest.
56   void CreateDiskEntryForMountDevice(
57       const DiskMountManager::MountPointInfo& mount_info,
58       const std::string& device_id,
59       const std::string& device_label,
60       const std::string& vendor_name,
61       const std::string& product_name,
62       DeviceType device_type,
63       uint64 total_size_in_bytes);
64
65   // Removes the fake disk entry associated with the mounted device. This
66   // function is primarily for StorageMonitorTest.
67   void RemoveDiskEntryForMountDevice(
68       const DiskMountManager::MountPointInfo& mount_info);
69
70  private:
71   // Is used to implement AddObserver.
72   void AddObserverInternal(DiskMountManager::Observer* observer);
73
74   // Is used to implement RemoveObserver.
75   void RemoveObserverInternal(DiskMountManager::Observer* observer);
76
77   // Is used to implement disks.
78   const DiskMountManager::DiskMap& disksInternal() const { return disks_; }
79
80   const DiskMountManager::MountPointMap& mountPointsInternal() const;
81
82   // Returns Disk object associated with the |source_path| or NULL on failure.
83   const DiskMountManager::Disk* FindDiskBySourcePathInternal(
84       const std::string& source_path) const;
85
86   // Notifies observers about device status update.
87   void NotifyDeviceChanged(DeviceEvent event,
88                            const std::string& path);
89
90   // Notifies observers about disk status update.
91   void NotifyDiskChanged(DiskEvent event,
92                          const DiskMountManager::Disk* disk);
93
94   // The list of observers.
95   ObserverList<DiskMountManager::Observer> observers_;
96
97   // The list of disks found.
98   DiskMountManager::DiskMap disks_;
99
100   // The list of existing mount points.
101   DiskMountManager::MountPointMap mount_points_;
102
103   DISALLOW_COPY_AND_ASSIGN(MockDiskMountManager);
104 };
105
106 }  // namespace disks
107 }  // namespace chromeos
108
109 #endif  // CHROMEOS_DISKS_MOCK_DISK_MOUNT_MANAGER_H_