Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(256)

Side by Side Diff: chrome/browser/chromeos/cros/mock_mount_library.cc

Issue 1238006: Adding new test for mount observer. Also changing the usb mounter to only rel... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2009 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 #include "chrome/browser/chromeos/cros/mock_mount_library.h"
6
7 #include "base/message_loop.h"
8 #include "base/string_util.h"
9 #include "chrome/browser/chrome_thread.h"
10 #include "chrome/browser/chromeos/cros/cros_library.h"
11
12 namespace chromeos {
13
14 using testing::_;
15 using testing::Invoke;
16
17 const char* kTestSystemPath = "/this/system/path";
18 const char* kTestDevicePath = "/this/device/path";
19 const char* kTestMountPath = "/media/foofoo";
20
21 void MockMountLibrary::AddObserverInternal(MountLibrary::Observer* observer) {
22 observers_.AddObserver(observer);
23 }
24
25 void MockMountLibrary::RemoveObserverInternal(MountLibrary::Observer* observer) {
26 observers_.RemoveObserver(observer);
27 }
28
29 MockMountLibrary::MockMountLibrary() {
30 ON_CALL(*this, AddObserver(_))
31 .WillByDefault(Invoke(this, &MockMountLibrary::AddObserverInternal));
32 ON_CALL(*this, RemoveObserver(_))
33 .WillByDefault(Invoke(this, &MockMountLibrary::RemoveObserverInternal));
34 ON_CALL(*this, disks())
35 .WillByDefault(Invoke(this, &MockMountLibrary::disksInternal));
36 }
37
38 MockMountLibrary::~MockMountLibrary() {
39
40 }
41
42 void MockMountLibrary::FireDeviceInsertEvents() {
43
44 disks_.clear();
45
46 disks_.push_back(Disk(kTestDevicePath, "", kTestSystemPath));
47
48 // Device Added
49 chromeos::MountEventType evt;
50 evt = chromeos::DEVICE_ADDED;
51 UpdateMountStatus(evt, kTestSystemPath);
52
53 // Disk Added
54 evt = chromeos::DISK_ADDED;
55 UpdateMountStatus(evt, kTestDevicePath);
56
57 // Disk Changed
58 disks_.clear();
59 disks_.push_back(Disk(kTestDevicePath, kTestMountPath, kTestSystemPath));
60 evt = chromeos::DISK_CHANGED;
61 UpdateMountStatus(evt, kTestDevicePath);
62 }
63
64 void MockMountLibrary::FireDeviceRemoveEvents() {
65 disks_.clear();
66 chromeos::MountEventType evt;
67 evt = chromeos::DISK_REMOVED;
68 UpdateMountStatus(evt, kTestDevicePath);
69 }
70
71 void MockMountLibrary::UpdateMountStatus(MountEventType evt,
72 const std::string& path) {
73 // Make sure we run on UI thread.
74 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
75
76 FOR_EACH_OBSERVER(Observer, observers_, MountChanged(this, evt, path));
77 }
78
79 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/cros/mock_mount_library.h ('k') | chrome/browser/chromeos/usb_mount_observer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698