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

Side by Side Diff: chrome/browser/media_galleries/mac/mtp_device_delegate_impl_mac_unittest.mm

Issue 16703025: [StorageMonitor] Move StorageMonitor ownership to BrowserProcessImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Set storage monitor in browser process for unit tests. etc. Created 7 years, 5 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
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 #import <Foundation/Foundation.h> 5 #import <Foundation/Foundation.h>
6 #import <ImageCaptureCore/ImageCaptureCore.h> 6 #import <ImageCaptureCore/ImageCaptureCore.h>
7 7
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/files/scoped_temp_dir.h" 9 #include "base/files/scoped_temp_dir.h"
10 #include "base/mac/cocoa_protocols.h" 10 #include "base/mac/cocoa_protocols.h"
11 #include "base/mac/foundation_util.h" 11 #include "base/mac/foundation_util.h"
12 #include "base/mac/scoped_nsobject.h" 12 #include "base/mac/scoped_nsobject.h"
13 #include "base/message_loop.h" 13 #include "base/message_loop.h"
14 #include "base/run_loop.h" 14 #include "base/run_loop.h"
15 #include "base/strings/sys_string_conversions.h" 15 #include "base/strings/sys_string_conversions.h"
16 #include "base/synchronization/waitable_event.h" 16 #include "base/synchronization/waitable_event.h"
17 #include "base/test/sequenced_worker_pool_owner.h" 17 #include "base/test/sequenced_worker_pool_owner.h"
18 #include "base/threading/sequenced_worker_pool.h" 18 #include "base/threading/sequenced_worker_pool.h"
19 #include "chrome/browser/media_galleries/mac/mtp_device_delegate_impl_mac.h" 19 #include "chrome/browser/media_galleries/mac/mtp_device_delegate_impl_mac.h"
20 #include "chrome/browser/storage_monitor/image_capture_device_manager.h" 20 #include "chrome/browser/storage_monitor/image_capture_device_manager.h"
21 #include "chrome/browser/storage_monitor/test_storage_monitor.h" 21 #include "chrome/browser/storage_monitor/test_storage_monitor.h"
22 #include "chrome/test/base/testing_browser_process.h"
vandebo (ex-Chrome) 2013/07/09 15:38:12 Needed?
Greg Billock 2013/07/09 17:35:21 nope
22 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
23 #include "content/public/test/test_browser_thread.h" 24 #include "content/public/test/test_browser_thread.h"
24 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
25 #include "webkit/browser/fileapi/file_system_file_util.h" 26 #include "webkit/browser/fileapi/file_system_file_util.h"
26 27
27 #if !defined(MAC_OS_X_VERSION_10_7) || \ 28 #if !defined(MAC_OS_X_VERSION_10_7) || \
28 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7 29 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
29 30
30 @interface NSObject (ICCameraDeviceDelegateLionAPI) 31 @interface NSObject (ICCameraDeviceDelegateLionAPI)
31 - (void)deviceDidBecomeReadyWithCompleteContentCatalog:(ICDevice*)device; 32 - (void)deviceDidBecomeReadyWithCompleteContentCatalog:(ICDevice*)device;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 178
178 virtual void SetUp() OVERRIDE { 179 virtual void SetUp() OVERRIDE {
179 ui_thread_.reset(new content::TestBrowserThread( 180 ui_thread_.reset(new content::TestBrowserThread(
180 content::BrowserThread::UI, &message_loop_)); 181 content::BrowserThread::UI, &message_loop_));
181 file_thread_.reset(new content::TestBrowserThread( 182 file_thread_.reset(new content::TestBrowserThread(
182 content::BrowserThread::FILE, &message_loop_)); 183 content::BrowserThread::FILE, &message_loop_));
183 io_thread_.reset(new content::TestBrowserThread( 184 io_thread_.reset(new content::TestBrowserThread(
184 content::BrowserThread::IO)); 185 content::BrowserThread::IO));
185 ASSERT_TRUE(io_thread_->Start()); 186 ASSERT_TRUE(io_thread_->Start());
186 187
187 manager_.SetNotifications(monitor_.receiver()); 188 chrome::test::TestStorageMonitor* monitor =
189 chrome::test::TestStorageMonitor::Create();
190 manager_.SetNotifications(monitor->receiver());
188 191
189 camera_ = [MockMTPICCameraDevice alloc]; 192 camera_ = [MockMTPICCameraDevice alloc];
190 id<ICDeviceBrowserDelegate> delegate = manager_.device_browser(); 193 id<ICDeviceBrowserDelegate> delegate = manager_.device_browser();
191 [delegate deviceBrowser:nil didAddDevice:camera_ moreComing:NO]; 194 [delegate deviceBrowser:nil didAddDevice:camera_ moreComing:NO];
192 195
193 delegate_ = new chrome::MTPDeviceDelegateImplMac(kDeviceId, kDevicePath); 196 delegate_ = new chrome::MTPDeviceDelegateImplMac(kDeviceId, kDevicePath);
194 } 197 }
195 198
196 void OnError(base::WaitableEvent* event, base::PlatformFileError error) { 199 void OnError(base::WaitableEvent* event, base::PlatformFileError error) {
197 error_ = error; 200 error_ = error;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 io_thread_->Stop(); 300 io_thread_->Stop();
298 } 301 }
299 302
300 protected: 303 protected:
301 base::MessageLoopForUI message_loop_; 304 base::MessageLoopForUI message_loop_;
302 // Note: threads must be made in this order: UI > FILE > IO 305 // Note: threads must be made in this order: UI > FILE > IO
303 scoped_ptr<content::TestBrowserThread> ui_thread_; 306 scoped_ptr<content::TestBrowserThread> ui_thread_;
304 scoped_ptr<content::TestBrowserThread> file_thread_; 307 scoped_ptr<content::TestBrowserThread> file_thread_;
305 scoped_ptr<content::TestBrowserThread> io_thread_; 308 scoped_ptr<content::TestBrowserThread> io_thread_;
306 base::ScopedTempDir temp_dir_; 309 base::ScopedTempDir temp_dir_;
307 chrome::test::TestStorageMonitor monitor_;
308 chrome::ImageCaptureDeviceManager manager_; 310 chrome::ImageCaptureDeviceManager manager_;
309 MockMTPICCameraDevice* camera_; 311 MockMTPICCameraDevice* camera_;
310 312
311 // This object needs special deletion inside the above |task_runner_|. 313 // This object needs special deletion inside the above |task_runner_|.
312 chrome::MTPDeviceDelegateImplMac* delegate_; 314 chrome::MTPDeviceDelegateImplMac* delegate_;
313 315
314 base::PlatformFileError error_; 316 base::PlatformFileError error_;
315 base::PlatformFileInfo info_; 317 base::PlatformFileInfo info_;
316 fileapi::AsyncFileUtil::EntryList file_list_; 318 fileapi::AsyncFileUtil::EntryList file_list_;
317 319
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 temp_dir_.path().Append("target"))); 564 temp_dir_.path().Append("target")));
563 565
564 EXPECT_EQ(base::PLATFORM_FILE_OK, 566 EXPECT_EQ(base::PLATFORM_FILE_OK,
565 DownloadFile(base::FilePath("/ic:id/filename"), 567 DownloadFile(base::FilePath("/ic:id/filename"),
566 temp_dir_.path().Append("target"))); 568 temp_dir_.path().Append("target")));
567 std::string contents; 569 std::string contents;
568 EXPECT_TRUE(file_util::ReadFileToString(temp_dir_.path().Append("target"), 570 EXPECT_TRUE(file_util::ReadFileToString(temp_dir_.path().Append("target"),
569 &contents)); 571 &contents));
570 EXPECT_EQ(kTestFileContents, contents); 572 EXPECT_EQ(kTestFileContents, contents);
571 } 573 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698