• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2010 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 CHROME_BROWSER_CHROMEOS_CROS_MOCK_MOUNT_LIBRARY_H_
6 #define CHROME_BROWSER_CHROMEOS_CROS_MOCK_MOUNT_LIBRARY_H_
7 #pragma once
8 
9 #include <string>
10 
11 #include "base/observer_list.h"
12 #include "base/time.h"
13 #include "chrome/browser/chromeos/cros/mount_library.h"
14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h"
16 #include "third_party/cros/chromeos_mount.h"
17 
18 namespace chromeos {
19 
20 class MockMountLibrary : public MountLibrary {
21  public:
22   MockMountLibrary();
23   virtual ~MockMountLibrary();
24 
25   MOCK_METHOD1(AddObserver, void(MountLibrary::Observer*));
26   MOCK_METHOD1(RemoveObserver, void(MountLibrary::Observer*));
27   MOCK_CONST_METHOD0(disks, const MountLibrary::DiskMap&(void));
28 
29   MOCK_METHOD0(RequestMountInfoRefresh, void(void));
30   MOCK_METHOD1(MountPath, void(const char*));
31   MOCK_METHOD1(UnmountPath, void(const char*));
32 
33   void FireDeviceInsertEvents();
34   void FireDeviceRemoveEvents();
35 
36  private:
37   void AddObserverInternal(MountLibrary::Observer* observer);
38   void RemoveObserverInternal(MountLibrary::Observer* observer);
disksInternal()39   const MountLibrary::DiskMap& disksInternal() const { return disks_; }
40 
41 
42   void UpdateDeviceChanged(MountLibraryEventType evt,
43                            const std::string& path);
44   void UpdateDiskChanged(MountLibraryEventType evt,
45                          const MountLibrary::Disk* disk);
46 
47   ObserverList<MountLibrary::Observer> observers_;
48 
49   // The list of disks found.
50   MountLibrary::DiskMap disks_;
51 
52   DISALLOW_COPY_AND_ASSIGN(MockMountLibrary);
53 };
54 
55 }  // namespace chromeos
56 
57 #endif  // CHROME_BROWSER_CHROMEOS_CROS_MOCK_MOUNT_LIBRARY_H_
58