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