OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include <string> | 5 #include <string> |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 // Verify mounted device type. | 36 // Verify mounted device type. |
37 void CheckDCIMDeviceType(const base::FilePath& mount_point) { | 37 void CheckDCIMDeviceType(const base::FilePath& mount_point) { |
38 EXPECT_TRUE(MediaStorageUtil::HasDcim(mount_point)); | 38 EXPECT_TRUE(MediaStorageUtil::HasDcim(mount_point)); |
39 } | 39 } |
40 | 40 |
41 void CheckNonDCIMDeviceType(const base::FilePath& mount_point) { | 41 void CheckNonDCIMDeviceType(const base::FilePath& mount_point) { |
42 EXPECT_FALSE(MediaStorageUtil::HasDcim(mount_point)); | 42 EXPECT_FALSE(MediaStorageUtil::HasDcim(mount_point)); |
43 } | 43 } |
44 | 44 |
45 void ProcessAttach(const std::string& id, | 45 void ProcessAttach(const std::string& id, |
46 const base::string16& name, | |
47 const base::FilePath::StringType& location) { | 46 const base::FilePath::StringType& location) { |
48 StorageInfo info(id, name, location, base::string16(), base::string16(), | 47 StorageInfo info(id, location, base::string16(), base::string16(), |
49 base::string16(), 0); | 48 base::string16(), 0); |
50 monitor_->receiver()->ProcessAttach(info); | 49 monitor_->receiver()->ProcessAttach(info); |
51 } | 50 } |
52 | 51 |
53 protected: | 52 protected: |
54 // Create mount point for the test device. | 53 // Create mount point for the test device. |
55 base::FilePath CreateMountPoint(bool create_dcim_dir) { | 54 base::FilePath CreateMountPoint(bool create_dcim_dir) { |
56 base::FilePath path(scoped_temp_dir_.path()); | 55 base::FilePath path(scoped_temp_dir_.path()); |
57 if (create_dcim_dir) | 56 if (create_dcim_dir) |
58 path = path.Append(kDCIMDirectoryName); | 57 path = path.Append(kDCIMDirectoryName); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event)); | 133 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&event)); |
135 | 134 |
136 // We need signal_event to be executed on the FILE thread, as the test thread | 135 // We need signal_event to be executed on the FILE thread, as the test thread |
137 // is blocked. Therefore, we invoke FilterAttachedDevices on the FILE thread. | 136 // is blocked. Therefore, we invoke FilterAttachedDevices on the FILE thread. |
138 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 137 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
139 base::Bind(&MediaStorageUtil::FilterAttachedDevices, | 138 base::Bind(&MediaStorageUtil::FilterAttachedDevices, |
140 base::Unretained(&devices), signal_event)); | 139 base::Unretained(&devices), signal_event)); |
141 event.Wait(); | 140 event.Wait(); |
142 EXPECT_FALSE(devices.find(kImageCaptureDeviceId) != devices.end()); | 141 EXPECT_FALSE(devices.find(kImageCaptureDeviceId) != devices.end()); |
143 | 142 |
144 ProcessAttach(kImageCaptureDeviceId, base::ASCIIToUTF16("name"), | 143 ProcessAttach(kImageCaptureDeviceId, FILE_PATH_LITERAL("/location")); |
145 FILE_PATH_LITERAL("/location")); | |
146 devices.insert(kImageCaptureDeviceId); | 144 devices.insert(kImageCaptureDeviceId); |
147 event.Reset(); | 145 event.Reset(); |
148 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 146 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
149 base::Bind(&MediaStorageUtil::FilterAttachedDevices, | 147 base::Bind(&MediaStorageUtil::FilterAttachedDevices, |
150 base::Unretained(&devices), signal_event)); | 148 base::Unretained(&devices), signal_event)); |
151 event.Wait(); | 149 event.Wait(); |
152 | 150 |
153 EXPECT_TRUE(devices.find(kImageCaptureDeviceId) != devices.end()); | 151 EXPECT_TRUE(devices.find(kImageCaptureDeviceId) != devices.end()); |
154 } | 152 } |
155 | 153 |
156 } // namespace storage_monitor | 154 } // namespace storage_monitor |
OLD | NEW |