| Index: chrome/browser/storage_monitor/storage_monitor_win_unittest.cc
|
| diff --git a/chrome/browser/storage_monitor/removable_device_notifications_window_win_unittest.cc b/chrome/browser/storage_monitor/storage_monitor_win_unittest.cc
|
| similarity index 84%
|
| rename from chrome/browser/storage_monitor/removable_device_notifications_window_win_unittest.cc
|
| rename to chrome/browser/storage_monitor/storage_monitor_win_unittest.cc
|
| index 5f40a80a68fbf56e7232950ace58e9439dd4b52e..e4d797308ee7db924b29e012b2ae71420d7c21dc 100644
|
| --- a/chrome/browser/storage_monitor/removable_device_notifications_window_win_unittest.cc
|
| +++ b/chrome/browser/storage_monitor/storage_monitor_win_unittest.cc
|
| @@ -17,9 +17,9 @@
|
| #include "chrome/browser/storage_monitor/mock_removable_storage_observer.h"
|
| #include "chrome/browser/storage_monitor/portable_device_watcher_win.h"
|
| #include "chrome/browser/storage_monitor/removable_device_constants.h"
|
| -#include "chrome/browser/storage_monitor/removable_device_notifications_window_win.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_removable_device_notifications_window_win.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 "content/public/test/test_browser_thread.h"
|
| @@ -32,12 +32,12 @@ using content::BrowserThread;
|
|
|
| typedef std::vector<int> DeviceIndices;
|
|
|
| -// RemovableDeviceNotificationsWindowWinTest -----------------------------------
|
| +// StorageMonitorWinTest ----------------------------------------------------
|
|
|
| -class RemovableDeviceNotificationsWindowWinTest : public testing::Test {
|
| +class StorageMonitorWinTest : public testing::Test {
|
| public:
|
| - RemovableDeviceNotificationsWindowWinTest();
|
| - virtual ~RemovableDeviceNotificationsWindowWinTest();
|
| + StorageMonitorWinTest();
|
| + virtual ~StorageMonitorWinTest();
|
|
|
| protected:
|
| // testing::Test:
|
| @@ -63,7 +63,7 @@ class RemovableDeviceNotificationsWindowWinTest : public testing::Test {
|
| string16* pnp_device_id,
|
| string16* storage_object_id);
|
|
|
| - scoped_ptr<TestRemovableDeviceNotificationsWindowWin> window_;
|
| + scoped_ptr<TestStorageMonitorWin> window_;
|
|
|
| // Weak pointer; owned by the device notifications class.
|
| TestVolumeMountWatcherWin* volume_mount_watcher_;
|
| @@ -76,32 +76,30 @@ class RemovableDeviceNotificationsWindowWinTest : public testing::Test {
|
| content::TestBrowserThread file_thread_;
|
| };
|
|
|
| -RemovableDeviceNotificationsWindowWinTest::
|
| - RemovableDeviceNotificationsWindowWinTest()
|
| - : ui_thread_(BrowserThread::UI, &message_loop_),
|
| - file_thread_(BrowserThread::FILE, &message_loop_) {
|
| +StorageMonitorWinTest::StorageMonitorWinTest()
|
| + : ui_thread_(BrowserThread::UI, &message_loop_),
|
| + file_thread_(BrowserThread::FILE, &message_loop_) {
|
| }
|
|
|
| -RemovableDeviceNotificationsWindowWinTest::
|
| - ~RemovableDeviceNotificationsWindowWinTest() {
|
| +StorageMonitorWinTest::~StorageMonitorWinTest() {
|
| }
|
|
|
| -void RemovableDeviceNotificationsWindowWinTest::SetUp() {
|
| +void StorageMonitorWinTest::SetUp() {
|
| ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| volume_mount_watcher_ = new TestVolumeMountWatcherWin;
|
| - window_.reset(new TestRemovableDeviceNotificationsWindowWin(
|
| - volume_mount_watcher_, new TestPortableDeviceWatcherWin));
|
| + window_.reset(new TestStorageMonitorWin(volume_mount_watcher_,
|
| + new TestPortableDeviceWatcherWin));
|
| window_->Init();
|
| RunUntilIdle();
|
| window_->AddObserver(&observer_);
|
| }
|
|
|
| -void RemovableDeviceNotificationsWindowWinTest::TearDown() {
|
| +void StorageMonitorWinTest::TearDown() {
|
| RunUntilIdle();
|
| window_->RemoveObserver(&observer_);
|
| }
|
|
|
| -void RemovableDeviceNotificationsWindowWinTest::PreAttachDevices() {
|
| +void StorageMonitorWinTest::PreAttachDevices() {
|
| window_.reset();
|
| volume_mount_watcher_ = new TestVolumeMountWatcherWin;
|
| volume_mount_watcher_->SetAttachedDevicesFake();
|
| @@ -120,8 +118,8 @@ void RemovableDeviceNotificationsWindowWinTest::PreAttachDevices() {
|
| expect_attach_calls++;
|
| }
|
|
|
| - window_.reset(new TestRemovableDeviceNotificationsWindowWin(
|
| - volume_mount_watcher_, new TestPortableDeviceWatcherWin));
|
| + window_.reset(new TestStorageMonitorWin(volume_mount_watcher_,
|
| + new TestPortableDeviceWatcherWin));
|
| window_->AddObserver(&observer_);
|
| window_->Init();
|
|
|
| @@ -141,13 +139,13 @@ void RemovableDeviceNotificationsWindowWinTest::PreAttachDevices() {
|
| EXPECT_EQ(0, observer_.detach_calls());
|
| }
|
|
|
| -void RemovableDeviceNotificationsWindowWinTest::RunUntilIdle() {
|
| +void StorageMonitorWinTest::RunUntilIdle() {
|
| volume_mount_watcher_->FlushWorkerPoolForTesting();
|
| message_loop_.RunUntilIdle();
|
| }
|
|
|
| -void RemovableDeviceNotificationsWindowWinTest::
|
| - DoMassStorageDeviceAttachedTest(const DeviceIndices& device_indices) {
|
| +void StorageMonitorWinTest::DoMassStorageDeviceAttachedTest(
|
| + const DeviceIndices& device_indices) {
|
| DEV_BROADCAST_VOLUME volume_broadcast;
|
| volume_broadcast.dbcv_size = sizeof(volume_broadcast);
|
| volume_broadcast.dbcv_devicetype = DBT_DEVTYP_VOLUME;
|
| @@ -176,8 +174,8 @@ void RemovableDeviceNotificationsWindowWinTest::
|
| EXPECT_EQ(0, observer_.detach_calls());
|
| }
|
|
|
| -void RemovableDeviceNotificationsWindowWinTest::
|
| - DoMassStorageDevicesDetachedTest(const DeviceIndices& device_indices) {
|
| +void StorageMonitorWinTest::DoMassStorageDevicesDetachedTest(
|
| + const DeviceIndices& device_indices) {
|
| DEV_BROADCAST_VOLUME volume_broadcast;
|
| volume_broadcast.dbcv_size = sizeof(volume_broadcast);
|
| volume_broadcast.dbcv_devicetype = DBT_DEVTYP_VOLUME;
|
| @@ -203,8 +201,8 @@ void RemovableDeviceNotificationsWindowWinTest::
|
| EXPECT_EQ(expect_detach_calls, observer_.detach_calls());
|
| }
|
|
|
| -void RemovableDeviceNotificationsWindowWinTest::DoMTPDeviceTest(
|
| - const string16& pnp_device_id, bool test_attach) {
|
| +void StorageMonitorWinTest::DoMTPDeviceTest(const string16& pnp_device_id,
|
| + bool test_attach) {
|
| GUID guidDevInterface = GUID_NULL;
|
| HRESULT hr = CLSIDFromString(kWPDDevInterfaceGUID, &guidDevInterface);
|
| if (FAILED(hr))
|
| @@ -249,7 +247,7 @@ void RemovableDeviceNotificationsWindowWinTest::DoMTPDeviceTest(
|
| EXPECT_EQ(expect_detach_calls, observer_.detach_calls());
|
| }
|
|
|
| -bool RemovableDeviceNotificationsWindowWinTest::GetMTPStorageInfo(
|
| +bool StorageMonitorWinTest::GetMTPStorageInfo(
|
| const std::string& storage_device_id,
|
| string16* pnp_device_id,
|
| string16* storage_object_id) {
|
| @@ -258,12 +256,12 @@ bool RemovableDeviceNotificationsWindowWinTest::GetMTPStorageInfo(
|
| storage_object_id);
|
| }
|
|
|
| -TEST_F(RemovableDeviceNotificationsWindowWinTest, RandomMessage) {
|
| +TEST_F(StorageMonitorWinTest, RandomMessage) {
|
| window_->InjectDeviceChange(DBT_DEVICEQUERYREMOVE, NULL);
|
| RunUntilIdle();
|
| }
|
|
|
| -TEST_F(RemovableDeviceNotificationsWindowWinTest, DevicesAttached) {
|
| +TEST_F(StorageMonitorWinTest, DevicesAttached) {
|
| DeviceIndices device_indices;
|
| device_indices.push_back(1); // B
|
| device_indices.push_back(5); // F
|
| @@ -298,21 +296,21 @@ TEST_F(RemovableDeviceNotificationsWindowWinTest, DevicesAttached) {
|
| EXPECT_EQ(ASCIIToUTF16("F:\\ Drive"), info2.name);
|
| }
|
|
|
| -TEST_F(RemovableDeviceNotificationsWindowWinTest, DevicesAttachedHighBoundary) {
|
| +TEST_F(StorageMonitorWinTest, DevicesAttachedHighBoundary) {
|
| DeviceIndices device_indices;
|
| device_indices.push_back(25);
|
|
|
| DoMassStorageDeviceAttachedTest(device_indices);
|
| }
|
|
|
| -TEST_F(RemovableDeviceNotificationsWindowWinTest, DevicesAttachedLowBoundary) {
|
| +TEST_F(StorageMonitorWinTest, DevicesAttachedLowBoundary) {
|
| DeviceIndices device_indices;
|
| device_indices.push_back(0);
|
|
|
| DoMassStorageDeviceAttachedTest(device_indices);
|
| }
|
|
|
| -TEST_F(RemovableDeviceNotificationsWindowWinTest, DevicesAttachedAdjacentBits) {
|
| +TEST_F(StorageMonitorWinTest, DevicesAttachedAdjacentBits) {
|
| DeviceIndices device_indices;
|
| device_indices.push_back(0);
|
| device_indices.push_back(1);
|
| @@ -322,7 +320,7 @@ TEST_F(RemovableDeviceNotificationsWindowWinTest, DevicesAttachedAdjacentBits) {
|
| DoMassStorageDeviceAttachedTest(device_indices);
|
| }
|
|
|
| -TEST_F(RemovableDeviceNotificationsWindowWinTest, DevicesDetached) {
|
| +TEST_F(StorageMonitorWinTest, DevicesDetached) {
|
| PreAttachDevices();
|
|
|
| DeviceIndices device_indices;
|
| @@ -334,8 +332,7 @@ TEST_F(RemovableDeviceNotificationsWindowWinTest, DevicesDetached) {
|
| DoMassStorageDevicesDetachedTest(device_indices);
|
| }
|
|
|
| -TEST_F(RemovableDeviceNotificationsWindowWinTest,
|
| - DevicesDetachedHighBoundary) {
|
| +TEST_F(StorageMonitorWinTest, DevicesDetachedHighBoundary) {
|
| PreAttachDevices();
|
|
|
| DeviceIndices device_indices;
|
| @@ -344,8 +341,7 @@ TEST_F(RemovableDeviceNotificationsWindowWinTest,
|
| DoMassStorageDevicesDetachedTest(device_indices);
|
| }
|
|
|
| -TEST_F(RemovableDeviceNotificationsWindowWinTest,
|
| - DevicesDetachedLowBoundary) {
|
| +TEST_F(StorageMonitorWinTest, DevicesDetachedLowBoundary) {
|
| PreAttachDevices();
|
|
|
| DeviceIndices device_indices;
|
| @@ -354,8 +350,7 @@ TEST_F(RemovableDeviceNotificationsWindowWinTest,
|
| DoMassStorageDevicesDetachedTest(device_indices);
|
| }
|
|
|
| -TEST_F(RemovableDeviceNotificationsWindowWinTest,
|
| - DevicesDetachedAdjacentBits) {
|
| +TEST_F(StorageMonitorWinTest, DevicesDetachedAdjacentBits) {
|
| PreAttachDevices();
|
|
|
| DeviceIndices device_indices;
|
| @@ -367,8 +362,7 @@ TEST_F(RemovableDeviceNotificationsWindowWinTest,
|
| DoMassStorageDevicesDetachedTest(device_indices);
|
| }
|
|
|
| -TEST_F(RemovableDeviceNotificationsWindowWinTest,
|
| - DuplicateAttachCheckSuppressed) {
|
| +TEST_F(StorageMonitorWinTest, DuplicateAttachCheckSuppressed) {
|
| volume_mount_watcher_->BlockDeviceCheckForTesting();
|
| base::FilePath kAttachedDevicePath =
|
| VolumeMountWatcherWin::DriveNumberToFilePath(8); // I:
|
| @@ -417,7 +411,7 @@ TEST_F(RemovableDeviceNotificationsWindowWinTest,
|
| EXPECT_EQ(kAttachedDevicePath, checked_devices[1]);
|
| }
|
|
|
| -TEST_F(RemovableDeviceNotificationsWindowWinTest, DeviceInfoForPath) {
|
| +TEST_F(StorageMonitorWinTest, DeviceInfoForPath) {
|
| PreAttachDevices();
|
|
|
| // An invalid path.
|
| @@ -463,7 +457,7 @@ TEST_F(RemovableDeviceNotificationsWindowWinTest, DeviceInfoForPath) {
|
| }
|
|
|
| // Test to verify basic MTP storage attach and detach notifications.
|
| -TEST_F(RemovableDeviceNotificationsWindowWinTest, MTPDeviceBasicAttachDetach) {
|
| +TEST_F(StorageMonitorWinTest, MTPDeviceBasicAttachDetach) {
|
| DoMTPDeviceTest(TestPortableDeviceWatcherWin::kMTPDeviceWithValidInfo, true);
|
| DoMTPDeviceTest(TestPortableDeviceWatcherWin::kMTPDeviceWithValidInfo, false);
|
| }
|
| @@ -471,7 +465,7 @@ TEST_F(RemovableDeviceNotificationsWindowWinTest, MTPDeviceBasicAttachDetach) {
|
| // When a MTP storage device with invalid storage label and id is
|
| // attached/detached, there should not be any device attach/detach
|
| // notifications.
|
| -TEST_F(RemovableDeviceNotificationsWindowWinTest, MTPDeviceWithInvalidInfo) {
|
| +TEST_F(StorageMonitorWinTest, MTPDeviceWithInvalidInfo) {
|
| DoMTPDeviceTest(TestPortableDeviceWatcherWin::kMTPDeviceWithInvalidInfo,
|
| true);
|
| DoMTPDeviceTest(TestPortableDeviceWatcherWin::kMTPDeviceWithInvalidInfo,
|
| @@ -480,15 +474,14 @@ TEST_F(RemovableDeviceNotificationsWindowWinTest, MTPDeviceWithInvalidInfo) {
|
|
|
| // Attach a device with two data partitions. Verify that attach/detach
|
| // notifications are sent out for each removable storage.
|
| -TEST_F(RemovableDeviceNotificationsWindowWinTest,
|
| - MTPDeviceWithMultipleStorageObjects) {
|
| +TEST_F(StorageMonitorWinTest, MTPDeviceWithMultipleStorageObjects) {
|
| DoMTPDeviceTest(TestPortableDeviceWatcherWin::kMTPDeviceWithMultipleStorages,
|
| true);
|
| DoMTPDeviceTest(TestPortableDeviceWatcherWin::kMTPDeviceWithMultipleStorages,
|
| false);
|
| }
|
|
|
| -TEST_F(RemovableDeviceNotificationsWindowWinTest, DriveNumberToFilePath) {
|
| +TEST_F(StorageMonitorWinTest, DriveNumberToFilePath) {
|
| EXPECT_EQ(L"A:\\", VolumeMountWatcherWin::DriveNumberToFilePath(0).value());
|
| EXPECT_EQ(L"Y:\\", VolumeMountWatcherWin::DriveNumberToFilePath(24).value());
|
| EXPECT_EQ(L"", VolumeMountWatcherWin::DriveNumberToFilePath(-1).value());
|
| @@ -497,8 +490,7 @@ TEST_F(RemovableDeviceNotificationsWindowWinTest, DriveNumberToFilePath) {
|
|
|
| // Given a MTP storage persistent id, GetMTPStorageInfo() should fetch the
|
| // device interface path and local storage object identifier.
|
| -TEST_F(RemovableDeviceNotificationsWindowWinTest,
|
| - GetMTPStorageInfoFromDeviceId) {
|
| +TEST_F(StorageMonitorWinTest, GetMTPStorageInfoFromDeviceId) {
|
| DoMTPDeviceTest(TestPortableDeviceWatcherWin::kMTPDeviceWithValidInfo, true);
|
| PortableDeviceWatcherWin::StorageObjects storage_objects =
|
| TestPortableDeviceWatcherWin::GetDeviceStorageObjects(
|
|
|