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

Side by Side Diff: chrome/browser/media_gallery/media_device_notifications_linux_unittest.cc

Issue 10069007: Media Gallery: Move MediaDeviceNotificationsLinux from content to chrome. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: clang Created 8 years, 8 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
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 // MediaDeviceNotificationsLinux unit tests. 5 // MediaDeviceNotificationsLinux unit tests.
6 6
7 #include "content/browser/media_device_notifications_linux.h" 7 #include "chrome/browser/media_gallery/media_device_notifications_linux.h"
8 8
9 #include <mntent.h> 9 #include <mntent.h>
10 #include <stdio.h> 10 #include <stdio.h>
11 11
12 #include <string> 12 #include <string>
13 13
14 #include "base/file_util.h" 14 #include "base/file_util.h"
15 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/message_loop.h" 17 #include "base/message_loop.h"
18 #include "base/scoped_temp_dir.h" 18 #include "base/scoped_temp_dir.h"
19 #include "base/system_monitor/system_monitor.h" 19 #include "base/system_monitor/system_monitor.h"
20 #include "base/test/mock_devices_changed_observer.h" 20 #include "base/test/mock_devices_changed_observer.h"
21 #include "content/browser/browser_thread_impl.h" 21 #include "content/test/test_browser_thread.h"
22 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
23 23
24 namespace content { 24 namespace chrome {
25 25
26 namespace { 26 namespace {
27 27
28 using testing::_; 28 using testing::_;
29 29
30 const char kValidFS[] = "vfat"; 30 const char kValidFS[] = "vfat";
31 const char kInvalidFS[] = "invalidfs"; 31 const char kInvalidFS[] = "invalidfs";
32 32
33 const char kInvalidPath[] = "invalid path does not exist"; 33 const char kInvalidPath[] = "invalid path does not exist";
34 34
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 mount_type(mount_type) { 88 mount_type(mount_type) {
89 } 89 }
90 90
91 const std::string mount_device; 91 const std::string mount_device;
92 const std::string mount_point; 92 const std::string mount_point;
93 const std::string mount_type; 93 const std::string mount_type;
94 }; 94 };
95 95
96 MediaDeviceNotificationsLinuxTest() 96 MediaDeviceNotificationsLinuxTest()
97 : message_loop_(MessageLoop::TYPE_IO), 97 : message_loop_(MessageLoop::TYPE_IO),
98 file_thread_(BrowserThread::FILE, &message_loop_) { 98 file_thread_(content::BrowserThread::FILE, &message_loop_) {
99 } 99 }
100 virtual ~MediaDeviceNotificationsLinuxTest() {} 100 virtual ~MediaDeviceNotificationsLinuxTest() {}
101 101
102 protected: 102 protected:
103 virtual void SetUp() { 103 virtual void SetUp() {
104 mock_devices_changed_observer_.reset(new base::MockDevicesChangedObserver); 104 mock_devices_changed_observer_.reset(new base::MockDevicesChangedObserver);
105 system_monitor_.AddDevicesChangedObserver( 105 system_monitor_.AddDevicesChangedObserver(
106 mock_devices_changed_observer_.get()); 106 mock_devices_changed_observer_.get());
107 107
108 // Create and set up a temp dir with files for the test. 108 // Create and set up a temp dir with files for the test.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 entry.mnt_fsname = mount_device.get(); 210 entry.mnt_fsname = mount_device.get();
211 entry.mnt_dir = mount_point.get(); 211 entry.mnt_dir = mount_point.get();
212 entry.mnt_type = mount_type.get(); 212 entry.mnt_type = mount_type.get();
213 ASSERT_EQ(0, addmntent(file, &entry)); 213 ASSERT_EQ(0, addmntent(file, &entry));
214 } 214 }
215 ASSERT_EQ(1, endmntent(file)); 215 ASSERT_EQ(1, endmntent(file));
216 } 216 }
217 217
218 // The message loop and file thread to run tests on. 218 // The message loop and file thread to run tests on.
219 MessageLoop message_loop_; 219 MessageLoop message_loop_;
220 BrowserThreadImpl file_thread_; 220 content::TestBrowserThread file_thread_;
221 221
222 // SystemMonitor and DevicesChangedObserver to hook together to test. 222 // SystemMonitor and DevicesChangedObserver to hook together to test.
223 base::SystemMonitor system_monitor_; 223 base::SystemMonitor system_monitor_;
224 scoped_ptr<base::MockDevicesChangedObserver> mock_devices_changed_observer_; 224 scoped_ptr<base::MockDevicesChangedObserver> mock_devices_changed_observer_;
225 225
226 // Temporary directory for created test data. 226 // Temporary directory for created test data.
227 ScopedTempDir scoped_temp_dir_; 227 ScopedTempDir scoped_temp_dir_;
228 // Path to the test mtab file. 228 // Path to the test mtab file.
229 FilePath mtab_file_; 229 FilePath mtab_file_;
230 230
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 AppendToMtabAndRunLoop(test_data2, arraysize(test_data2)); 386 AppendToMtabAndRunLoop(test_data2, arraysize(test_data2));
387 387
388 // Detach all devices. 388 // Detach all devices.
389 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(0); 389 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(0);
390 EXPECT_CALL(observer(), OnMediaDeviceDetached(1)).Times(1); 390 EXPECT_CALL(observer(), OnMediaDeviceDetached(1)).Times(1);
391 WriteEmptyMtabAndRunLoop(); 391 WriteEmptyMtabAndRunLoop();
392 } 392 }
393 393
394 } // namespace 394 } // namespace
395 395
396 } // namespace content 396 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/media_gallery/media_device_notifications_linux.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698