Index: chrome/browser/storage_monitor/storage_monitor_win_unittest.cc |
diff --git a/chrome/browser/storage_monitor/storage_monitor_win_unittest.cc b/chrome/browser/storage_monitor/storage_monitor_win_unittest.cc |
index 4e9ad7ec6ca10a8d69c4d6423a6c689ab4e1b44a..6ea1bda042c1044456081bc59a968e090ca93311 100644 |
--- a/chrome/browser/storage_monitor/storage_monitor_win_unittest.cc |
+++ b/chrome/browser/storage_monitor/storage_monitor_win_unittest.cc |
@@ -19,9 +19,11 @@ |
#include "chrome/browser/storage_monitor/storage_info.h" |
#include "chrome/browser/storage_monitor/storage_monitor_win.h" |
#include "chrome/browser/storage_monitor/test_portable_device_watcher_win.h" |
+#include "chrome/browser/storage_monitor/test_storage_monitor.h" |
#include "chrome/browser/storage_monitor/test_storage_monitor_win.h" |
#include "chrome/browser/storage_monitor/test_volume_mount_watcher_win.h" |
#include "chrome/browser/storage_monitor/volume_mount_watcher_win.h" |
+#include "chrome/test/base/testing_browser_process.h" |
#include "content/public/test/test_browser_thread.h" |
#include "testing/gtest/include/gtest/gtest.h" |
@@ -63,7 +65,8 @@ class StorageMonitorWinTest : public testing::Test { |
base::string16* pnp_device_id, |
base::string16* storage_object_id); |
- scoped_ptr<TestStorageMonitorWin> monitor_; |
+ // Pointer to the storage monitor. Owned by TestingBrowserProcess. |
+ TestStorageMonitorWin* monitor_; |
// Weak pointer; owned by the device notifications class. |
TestVolumeMountWatcherWin* volume_mount_watcher_; |
@@ -86,9 +89,14 @@ StorageMonitorWinTest::~StorageMonitorWinTest() { |
void StorageMonitorWinTest::SetUp() { |
ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ test::TestStorageMonitor::RemoveSingleton(); |
volume_mount_watcher_ = new TestVolumeMountWatcherWin; |
- monitor_.reset(new TestStorageMonitorWin(volume_mount_watcher_, |
- new TestPortableDeviceWatcherWin)); |
+ monitor_ = new TestStorageMonitorWin(volume_mount_watcher_, |
+ new TestPortableDeviceWatcherWin); |
+ TestingBrowserProcess* browser_process = TestingBrowserProcess::GetGlobal(); |
+ if (browser_process) |
vandebo (ex-Chrome)
2013/07/10 16:57:45
leak
Greg Billock
2013/07/10 21:57:17
Done.
|
+ browser_process->SetStorageMonitor(monitor_); |
+ |
monitor_->Init(); |
RunUntilIdle(); |
monitor_->AddObserver(&observer_); |
@@ -98,11 +106,16 @@ void StorageMonitorWinTest::TearDown() { |
RunUntilIdle(); |
monitor_->RemoveObserver(&observer_); |
volume_mount_watcher_->ShutdownWorkerPool(); |
- monitor_.reset(); |
+ monitor_ = NULL; |
+ |
+ // Windows storage monitor must be destroyed on the same thread |
+ // as construction. |
+ test::TestStorageMonitor::RemoveSingleton(); |
} |
void StorageMonitorWinTest::PreAttachDevices() { |
- monitor_.reset(); |
+ test::TestStorageMonitor::RemoveSingleton(); |
+ monitor_ = NULL; |
volume_mount_watcher_ = new TestVolumeMountWatcherWin; |
volume_mount_watcher_->SetAttachedDevicesFake(); |
@@ -117,8 +130,12 @@ void StorageMonitorWinTest::PreAttachDevices() { |
expect_attach_calls++; |
} |
- monitor_.reset(new TestStorageMonitorWin(volume_mount_watcher_, |
- new TestPortableDeviceWatcherWin)); |
+ monitor_ = new TestStorageMonitorWin(volume_mount_watcher_, |
+ new TestPortableDeviceWatcherWin); |
+ TestingBrowserProcess* browser_process = TestingBrowserProcess::GetGlobal(); |
+ if (browser_process) |
vandebo (ex-Chrome)
2013/07/10 16:57:45
leak
Greg Billock
2013/07/10 21:59:19
Done.
|
+ browser_process->SetStorageMonitor(monitor_); |
+ |
monitor_->AddObserver(&observer_); |
monitor_->Init(); |