OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // chromeos::StorageMonitorCros unit tests. | 5 // chromeos::StorageMonitorCros unit tests. |
6 | 6 |
7 #include "chrome/browser/storage_monitor/storage_monitor_chromeos.h" | 7 #include "chrome/browser/storage_monitor/storage_monitor_chromeos.h" |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // path on failure. | 126 // path on failure. |
127 base::FilePath CreateMountPoint(const std::string& dir, bool with_dcim_dir); | 127 base::FilePath CreateMountPoint(const std::string& dir, bool with_dcim_dir); |
128 | 128 |
129 static void PostQuitToUIThread(); | 129 static void PostQuitToUIThread(); |
130 static void WaitForFileThread(); | 130 static void WaitForFileThread(); |
131 | 131 |
132 chrome::MockRemovableStorageObserver& observer() { | 132 chrome::MockRemovableStorageObserver& observer() { |
133 return *mock_storage_observer_; | 133 return *mock_storage_observer_; |
134 } | 134 } |
135 | 135 |
136 MessageLoop ui_loop_; | 136 base::MessageLoop ui_loop_; |
137 | 137 |
138 scoped_ptr<TestStorageMonitorCros> monitor_; | 138 scoped_ptr<TestStorageMonitorCros> monitor_; |
139 | 139 |
140 // Owned by DiskMountManager. | 140 // Owned by DiskMountManager. |
141 disks::MockDiskMountManager* disk_mount_manager_mock_; | 141 disks::MockDiskMountManager* disk_mount_manager_mock_; |
142 | 142 |
143 chrome::StorageMonitor::EjectStatus status_; | 143 chrome::StorageMonitor::EjectStatus status_; |
144 | 144 |
145 private: | 145 private: |
146 content::TestBrowserThread ui_thread_; | 146 content::TestBrowserThread ui_thread_; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 if (with_dcim_dir) | 236 if (with_dcim_dir) |
237 path = path.Append(chrome::kDCIMDirectoryName); | 237 path = path.Append(chrome::kDCIMDirectoryName); |
238 if (!file_util::CreateDirectory(path)) | 238 if (!file_util::CreateDirectory(path)) |
239 return base::FilePath(); | 239 return base::FilePath(); |
240 return return_path; | 240 return return_path; |
241 } | 241 } |
242 | 242 |
243 // static | 243 // static |
244 void StorageMonitorCrosTest::PostQuitToUIThread() { | 244 void StorageMonitorCrosTest::PostQuitToUIThread() { |
245 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 245 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
246 MessageLoop::QuitClosure()); | 246 base::MessageLoop::QuitClosure()); |
247 } | 247 } |
248 | 248 |
249 // static | 249 // static |
250 void StorageMonitorCrosTest::WaitForFileThread() { | 250 void StorageMonitorCrosTest::WaitForFileThread() { |
251 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 251 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
252 base::Bind(&PostQuitToUIThread)); | 252 base::Bind(&PostQuitToUIThread)); |
253 MessageLoop::current()->Run(); | 253 base::MessageLoop::current()->Run(); |
254 } | 254 } |
255 | 255 |
256 void StorageMonitorCrosTest::EjectNotify( | 256 void StorageMonitorCrosTest::EjectNotify( |
257 chrome::StorageMonitor::EjectStatus status) { | 257 chrome::StorageMonitor::EjectStatus status) { |
258 status_ = status; | 258 status_ = status; |
259 } | 259 } |
260 | 260 |
261 // Simple test case where we attach and detach a media device. | 261 // Simple test case where we attach and detach a media device. |
262 TEST_F(StorageMonitorCrosTest, BasicAttachDetach) { | 262 TEST_F(StorageMonitorCrosTest, BasicAttachDetach) { |
263 base::FilePath mount_path1 = CreateMountPoint(kMountPointA, true); | 263 base::FilePath mount_path1 = CreateMountPoint(kMountPointA, true); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 base::Bind(&StorageMonitorCrosTest::EjectNotify, | 475 base::Bind(&StorageMonitorCrosTest::EjectNotify, |
476 base::Unretained(this))); | 476 base::Unretained(this))); |
477 ui_loop_.RunUntilIdle(); | 477 ui_loop_.RunUntilIdle(); |
478 | 478 |
479 EXPECT_EQ(chrome::StorageMonitor::EJECT_OK, status_); | 479 EXPECT_EQ(chrome::StorageMonitor::EJECT_OK, status_); |
480 } | 480 } |
481 | 481 |
482 } // namespace | 482 } // namespace |
483 | 483 |
484 } // namespace chromeos | 484 } // namespace chromeos |
OLD | NEW |