| 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 #import <Foundation/Foundation.h> | 5 #import <Foundation/Foundation.h> |
| 6 #import <ImageCaptureCore/ImageCaptureCore.h> | 6 #import <ImageCaptureCore/ImageCaptureCore.h> |
| 7 | 7 |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 : public ImageCaptureDeviceListener, | 201 : public ImageCaptureDeviceListener, |
| 202 public base::SupportsWeakPtr<TestCameraListener> { | 202 public base::SupportsWeakPtr<TestCameraListener> { |
| 203 public: | 203 public: |
| 204 TestCameraListener() | 204 TestCameraListener() |
| 205 : completed_(false), | 205 : completed_(false), |
| 206 removed_(false), | 206 removed_(false), |
| 207 last_error_(base::File::FILE_ERROR_INVALID_URL) {} | 207 last_error_(base::File::FILE_ERROR_INVALID_URL) {} |
| 208 virtual ~TestCameraListener() {} | 208 virtual ~TestCameraListener() {} |
| 209 | 209 |
| 210 virtual void ItemAdded(const std::string& name, | 210 virtual void ItemAdded(const std::string& name, |
| 211 const base::File::Info& info) OVERRIDE { | 211 const base::File::Info& info) override { |
| 212 items_.push_back(name); | 212 items_.push_back(name); |
| 213 } | 213 } |
| 214 | 214 |
| 215 virtual void NoMoreItems() OVERRIDE { | 215 virtual void NoMoreItems() override { |
| 216 completed_ = true; | 216 completed_ = true; |
| 217 } | 217 } |
| 218 | 218 |
| 219 virtual void DownloadedFile(const std::string& name, | 219 virtual void DownloadedFile(const std::string& name, |
| 220 base::File::Error error) OVERRIDE { | 220 base::File::Error error) override { |
| 221 EXPECT_TRUE(content::BrowserThread::CurrentlyOn( | 221 EXPECT_TRUE(content::BrowserThread::CurrentlyOn( |
| 222 content::BrowserThread::UI)); | 222 content::BrowserThread::UI)); |
| 223 downloads_.push_back(name); | 223 downloads_.push_back(name); |
| 224 last_error_ = error; | 224 last_error_ = error; |
| 225 } | 225 } |
| 226 | 226 |
| 227 virtual void DeviceRemoved() OVERRIDE { | 227 virtual void DeviceRemoved() override { |
| 228 removed_ = true; | 228 removed_ = true; |
| 229 } | 229 } |
| 230 | 230 |
| 231 std::vector<std::string> items() const { return items_; } | 231 std::vector<std::string> items() const { return items_; } |
| 232 std::vector<std::string> downloads() const { return downloads_; } | 232 std::vector<std::string> downloads() const { return downloads_; } |
| 233 bool completed() const { return completed_; } | 233 bool completed() const { return completed_; } |
| 234 bool removed() const { return removed_; } | 234 bool removed() const { return removed_; } |
| 235 base::File::Error last_error() const { return last_error_; } | 235 base::File::Error last_error() const { return last_error_; } |
| 236 | 236 |
| 237 private: | 237 private: |
| 238 std::vector<std::string> items_; | 238 std::vector<std::string> items_; |
| 239 std::vector<std::string> downloads_; | 239 std::vector<std::string> downloads_; |
| 240 bool completed_; | 240 bool completed_; |
| 241 bool removed_; | 241 bool removed_; |
| 242 base::File::Error last_error_; | 242 base::File::Error last_error_; |
| 243 }; | 243 }; |
| 244 | 244 |
| 245 class ImageCaptureDeviceManagerTest : public testing::Test { | 245 class ImageCaptureDeviceManagerTest : public testing::Test { |
| 246 public: | 246 public: |
| 247 virtual void SetUp() OVERRIDE { | 247 virtual void SetUp() override { |
| 248 monitor_ = TestStorageMonitor::CreateAndInstall(); | 248 monitor_ = TestStorageMonitor::CreateAndInstall(); |
| 249 } | 249 } |
| 250 | 250 |
| 251 virtual void TearDown() OVERRIDE { | 251 virtual void TearDown() override { |
| 252 TestStorageMonitor::Destroy(); | 252 TestStorageMonitor::Destroy(); |
| 253 } | 253 } |
| 254 | 254 |
| 255 MockICCameraDevice* AttachDevice(ImageCaptureDeviceManager* manager) { | 255 MockICCameraDevice* AttachDevice(ImageCaptureDeviceManager* manager) { |
| 256 // Ownership will be passed to the device browser delegate. | 256 // Ownership will be passed to the device browser delegate. |
| 257 base::scoped_nsobject<MockICCameraDevice> device( | 257 base::scoped_nsobject<MockICCameraDevice> device( |
| 258 [[MockICCameraDevice alloc] init]); | 258 [[MockICCameraDevice alloc] init]); |
| 259 id<ICDeviceBrowserDelegate> delegate = manager->device_browser(); | 259 id<ICDeviceBrowserDelegate> delegate = manager->device_browser(); |
| 260 [delegate deviceBrowser:nil didAddDevice:device moreComing:NO]; | 260 [delegate deviceBrowser:nil didAddDevice:device moreComing:NO]; |
| 261 return device.autorelease(); | 261 return device.autorelease(); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 char file_contents[5]; | 417 char file_contents[5]; |
| 418 ASSERT_EQ(4, base::ReadFile(temp_file, file_contents, | 418 ASSERT_EQ(4, base::ReadFile(temp_file, file_contents, |
| 419 strlen(kTestFileContents))); | 419 strlen(kTestFileContents))); |
| 420 EXPECT_EQ(kTestFileContents, | 420 EXPECT_EQ(kTestFileContents, |
| 421 std::string(file_contents, strlen(kTestFileContents))); | 421 std::string(file_contents, strlen(kTestFileContents))); |
| 422 | 422 |
| 423 [camera didRemoveDevice:device]; | 423 [camera didRemoveDevice:device]; |
| 424 } | 424 } |
| 425 | 425 |
| 426 } // namespace storage_monitor | 426 } // namespace storage_monitor |
| OLD | NEW |