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

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: Rebase Created 7 years, 6 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/memory/scoped_nsobject.h" 12 #include "base/memory/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"
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::RemoveSingleton();
189 chrome::test::TestStorageMonitor* monitor =
190 new chrome::test::TestStorageMonitor();
191 TestingBrowserProcess::GetGlobal()->SetStorageMonitor(monitor);
192 manager_.SetNotifications(monitor->receiver());
188 193
189 camera_ = [MockMTPICCameraDevice alloc]; 194 camera_ = [MockMTPICCameraDevice alloc];
190 id<ICDeviceBrowserDelegate> delegate = manager_.device_browser(); 195 id<ICDeviceBrowserDelegate> delegate = manager_.device_browser();
191 [delegate deviceBrowser:nil didAddDevice:camera_ moreComing:NO]; 196 [delegate deviceBrowser:nil didAddDevice:camera_ moreComing:NO];
192 197
193 delegate_ = new chrome::MTPDeviceDelegateImplMac(kDeviceId, kDevicePath); 198 delegate_ = new chrome::MTPDeviceDelegateImplMac(kDeviceId, kDevicePath);
194 } 199 }
195 200
196 void OnError(base::WaitableEvent* event, base::PlatformFileError error) { 201 void OnError(base::WaitableEvent* event, base::PlatformFileError error) {
197 error_ = error; 202 error_ = error;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 io_thread_->Stop(); 302 io_thread_->Stop();
298 } 303 }
299 304
300 protected: 305 protected:
301 base::MessageLoopForUI message_loop_; 306 base::MessageLoopForUI message_loop_;
302 // Note: threads must be made in this order: UI > FILE > IO 307 // Note: threads must be made in this order: UI > FILE > IO
303 scoped_ptr<content::TestBrowserThread> ui_thread_; 308 scoped_ptr<content::TestBrowserThread> ui_thread_;
304 scoped_ptr<content::TestBrowserThread> file_thread_; 309 scoped_ptr<content::TestBrowserThread> file_thread_;
305 scoped_ptr<content::TestBrowserThread> io_thread_; 310 scoped_ptr<content::TestBrowserThread> io_thread_;
306 base::ScopedTempDir temp_dir_; 311 base::ScopedTempDir temp_dir_;
307 chrome::test::TestStorageMonitor monitor_;
308 chrome::ImageCaptureDeviceManager manager_; 312 chrome::ImageCaptureDeviceManager manager_;
309 MockMTPICCameraDevice* camera_; 313 MockMTPICCameraDevice* camera_;
310 314
311 // This object needs special deletion inside the above |task_runner_|. 315 // This object needs special deletion inside the above |task_runner_|.
312 chrome::MTPDeviceDelegateImplMac* delegate_; 316 chrome::MTPDeviceDelegateImplMac* delegate_;
313 317
314 base::PlatformFileError error_; 318 base::PlatformFileError error_;
315 base::PlatformFileInfo info_; 319 base::PlatformFileInfo info_;
316 fileapi::AsyncFileUtil::EntryList file_list_; 320 fileapi::AsyncFileUtil::EntryList file_list_;
317 321
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 temp_dir_.path().Append("target"))); 566 temp_dir_.path().Append("target")));
563 567
564 EXPECT_EQ(base::PLATFORM_FILE_OK, 568 EXPECT_EQ(base::PLATFORM_FILE_OK,
565 DownloadFile(base::FilePath("/ic:id/filename"), 569 DownloadFile(base::FilePath("/ic:id/filename"),
566 temp_dir_.path().Append("target"))); 570 temp_dir_.path().Append("target")));
567 std::string contents; 571 std::string contents;
568 EXPECT_TRUE(file_util::ReadFileToString(temp_dir_.path().Append("target"), 572 EXPECT_TRUE(file_util::ReadFileToString(temp_dir_.path().Append("target"),
569 &contents)); 573 &contents));
570 EXPECT_EQ(kTestFileContents, contents); 574 EXPECT_EQ(kTestFileContents, contents);
571 } 575 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698