Chromium Code Reviews| Index: chrome/browser/system_monitor/removable_device_notifications_linux_unittest.cc |
| diff --git a/chrome/browser/system_monitor/removable_device_notifications_linux_unittest.cc b/chrome/browser/system_monitor/removable_device_notifications_linux_unittest.cc |
| index c0cacf6a939d2776de34674143952625d73a80a3..7733100214144586841dd3e10aaac02c83f0a4c5 100644 |
| --- a/chrome/browser/system_monitor/removable_device_notifications_linux_unittest.cc |
| +++ b/chrome/browser/system_monitor/removable_device_notifications_linux_unittest.cc |
| @@ -16,12 +16,12 @@ |
| #include "base/logging.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/message_loop.h" |
| -#include "base/system_monitor/system_monitor.h" |
| -#include "base/test/mock_devices_changed_observer.h" |
| #include "base/utf_string_conversions.h" |
| #include "chrome/browser/system_monitor/media_device_notifications_utils.h" |
| #include "chrome/browser/system_monitor/media_storage_util.h" |
| +#include "chrome/browser/system_monitor/mock_removable_storage_observer.h" |
| #include "chrome/browser/system_monitor/removable_device_constants.h" |
| +#include "chrome/browser/system_monitor/removable_storage_notifications.h" |
| #include "content/public/test/test_browser_thread.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| @@ -29,8 +29,6 @@ namespace chrome { |
| namespace { |
| -using testing::_; |
| - |
| const char kValidFS[] = "vfat"; |
| const char kInvalidFS[] = "invalidfs"; |
| @@ -185,10 +183,6 @@ class RemovableDeviceNotificationLinuxTest : public testing::Test { |
| protected: |
| virtual void SetUp() OVERRIDE { |
| - mock_devices_changed_observer_.reset(new base::MockDevicesChangedObserver); |
| - system_monitor_.AddDevicesChangedObserver( |
| - mock_devices_changed_observer_.get()); |
| - |
| // Create and set up a temp dir with files for the test. |
| ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); |
| FilePath test_dir = scoped_temp_dir_.path().AppendASCII("test_etc"); |
| @@ -206,13 +200,15 @@ class RemovableDeviceNotificationLinuxTest : public testing::Test { |
| mtab_file_, &message_loop_); |
| notifications_->Init(); |
| message_loop_.RunUntilIdle(); |
| + |
| + mock_storage_observer_.reset(new MockRemovableStorageObserver); |
|
vandebo (ex-Chrome)
2013/01/24 19:19:10
move the observer to line 201 so it will get notif
Greg Billock
2013/01/24 20:46:03
Those vary by test, so I think adding if after mak
vandebo (ex-Chrome)
2013/01/24 23:39:01
Previously it was set before and the tests worked
Greg Billock
2013/01/25 20:01:21
Done. I was thinking I'd have to change a lot of t
|
| + notifications_->AddObserver(mock_storage_observer_.get()); |
| } |
| virtual void TearDown() OVERRIDE { |
| message_loop_.RunUntilIdle(); |
| + notifications_->RemoveObserver(mock_storage_observer_.get()); |
| notifications_ = NULL; |
| - system_monitor_.RemoveDevicesChangedObserver( |
| - mock_devices_changed_observer_.get()); |
| } |
| // Append mtab entries from the |data| array of size |data_size| to the mtab |
| @@ -256,8 +252,8 @@ class RemovableDeviceNotificationLinuxTest : public testing::Test { |
| file_util::Delete(dcim, false); |
| } |
| - base::MockDevicesChangedObserver& observer() { |
| - return *mock_devices_changed_observer_; |
| + MockRemovableStorageObserver& observer() { |
| + return *mock_storage_observer_; |
| } |
| RemovableDeviceNotificationsLinux* notifier() { |
| @@ -318,9 +314,7 @@ class RemovableDeviceNotificationLinuxTest : public testing::Test { |
| MessageLoop message_loop_; |
| content::TestBrowserThread file_thread_; |
| - // SystemMonitor and DevicesChangedObserver to hook together to test. |
| - base::SystemMonitor system_monitor_; |
| - scoped_ptr<base::MockDevicesChangedObserver> mock_devices_changed_observer_; |
| + scoped_ptr<MockRemovableStorageObserver> mock_storage_observer_; |
| // Temporary directory for created test data. |
| base::ScopedTempDir scoped_temp_dir_; |
| @@ -334,7 +328,6 @@ class RemovableDeviceNotificationLinuxTest : public testing::Test { |
| // Simple test case where we attach and detach a media device. |
| TEST_F(RemovableDeviceNotificationLinuxTest, BasicAttachDetach) { |
| - testing::Sequence mock_sequence; |
| FilePath test_path = CreateMountPointWithDCIMDir(kMountPointA); |
| ASSERT_FALSE(test_path.empty()); |
| MtabTestData test_data[] = { |
| @@ -343,37 +336,38 @@ TEST_F(RemovableDeviceNotificationLinuxTest, BasicAttachDetach) { |
| }; |
| // Only |kDeviceDCIM2| should be attached, since |kDeviceFixed| has a bad |
| // path. |
| - EXPECT_CALL(observer(), |
| - OnRemovableStorageAttached( |
| - GetDeviceId(kDeviceDCIM2), |
| - GetDeviceNameWithSizeDetails(kDeviceDCIM2), |
| - test_path.value())) |
| - .InSequence(mock_sequence); |
| AppendToMtabAndRunLoop(test_data, arraysize(test_data)); |
| + EXPECT_EQ(1, observer().attach_calls()); |
|
vandebo (ex-Chrome)
2013/01/24 19:19:10
nit: detach count
Greg Billock
2013/01/24 20:46:03
Done.
|
| + EXPECT_EQ(GetDeviceId(kDeviceDCIM2), observer().last_attached().device_id); |
| + EXPECT_EQ(GetDeviceNameWithSizeDetails(kDeviceDCIM2), |
| + observer().last_attached().name); |
| + EXPECT_EQ(test_path.value(), |
| + observer().last_attached().location); |
| + |
| // |kDeviceDCIM2| should be detached here. |
| - EXPECT_CALL(observer(), OnRemovableStorageDetached(GetDeviceId(kDeviceDCIM2))) |
| - .InSequence(mock_sequence); |
| WriteEmptyMtabAndRunLoop(); |
| + EXPECT_EQ(1, observer().detach_calls()); |
|
vandebo (ex-Chrome)
2013/01/24 19:19:10
nit: attach count
Greg Billock
2013/01/24 20:46:03
Done.
|
| + EXPECT_EQ(GetDeviceId(kDeviceDCIM2), observer().last_detached().device_id); |
| } |
| // Only removable devices are recognized. |
| TEST_F(RemovableDeviceNotificationLinuxTest, Removable) { |
| - testing::Sequence mock_sequence; |
| FilePath test_path_a = CreateMountPointWithDCIMDir(kMountPointA); |
| ASSERT_FALSE(test_path_a.empty()); |
| MtabTestData test_data1[] = { |
| MtabTestData(kDeviceDCIM1, test_path_a.value(), kValidFS), |
| }; |
| // |kDeviceDCIM1| should be attached as expected. |
| - EXPECT_CALL(observer(), |
| - OnRemovableStorageAttached( |
| - GetDeviceId(kDeviceDCIM1), |
| - GetDeviceNameWithSizeDetails(kDeviceDCIM1), |
| - test_path_a.value())) |
| - .InSequence(mock_sequence); |
| AppendToMtabAndRunLoop(test_data1, arraysize(test_data1)); |
| + EXPECT_EQ(1, observer().attach_calls()); |
| + EXPECT_EQ(GetDeviceId(kDeviceDCIM1), observer().last_attached().device_id); |
| + EXPECT_EQ(GetDeviceNameWithSizeDetails(kDeviceDCIM1), |
| + observer().last_attached().name); |
| + EXPECT_EQ(test_path_a.value(), |
| + observer().last_attached().location); |
| + |
| // This should do nothing, since |kDeviceFixed| is not removable. |
| FilePath test_path_b = CreateMountPointWithoutDCIMDir(kMountPointB); |
| ASSERT_FALSE(test_path_b.empty()); |
| @@ -381,29 +375,29 @@ TEST_F(RemovableDeviceNotificationLinuxTest, Removable) { |
| MtabTestData(kDeviceFixed, test_path_b.value(), kValidFS), |
| }; |
| AppendToMtabAndRunLoop(test_data2, arraysize(test_data2)); |
| + EXPECT_EQ(1, observer().attach_calls()); |
|
vandebo (ex-Chrome)
2013/01/24 19:19:10
nit: detach count
Greg Billock
2013/01/24 20:46:03
Done.
|
| // |kDeviceDCIM1| should be detached as expected. |
| - EXPECT_CALL(observer(), OnRemovableStorageDetached(GetDeviceId(kDeviceDCIM1))) |
| - .InSequence(mock_sequence); |
| WriteEmptyMtabAndRunLoop(); |
| + EXPECT_EQ(1, observer().detach_calls()); |
|
vandebo (ex-Chrome)
2013/01/24 19:19:10
nit: attach count
Greg Billock
2013/01/24 20:46:03
Done.
|
| + EXPECT_EQ(GetDeviceId(kDeviceDCIM1), observer().last_detached().device_id); |
| // |kDeviceNoDCIM| should be attached as expected. |
| - EXPECT_CALL(observer(), |
| - OnRemovableStorageAttached( |
| - GetDeviceId(kDeviceNoDCIM), |
| - GetDeviceNameWithSizeDetails(kDeviceNoDCIM), |
| - test_path_b.value())) |
| - .InSequence(mock_sequence); |
| MtabTestData test_data3[] = { |
| MtabTestData(kDeviceNoDCIM, test_path_b.value(), kValidFS), |
| }; |
| AppendToMtabAndRunLoop(test_data3, arraysize(test_data3)); |
| + EXPECT_EQ(2, observer().attach_calls()); |
|
vandebo (ex-Chrome)
2013/01/24 19:19:10
nit: detach count
Greg Billock
2013/01/24 20:46:03
Done.
|
| + EXPECT_EQ(GetDeviceId(kDeviceNoDCIM), observer().last_attached().device_id); |
| + EXPECT_EQ(GetDeviceNameWithSizeDetails(kDeviceNoDCIM), |
| + observer().last_attached().name); |
| + EXPECT_EQ(test_path_b.value(), |
| + observer().last_attached().location); |
| // |kDeviceNoDCIM| should be detached as expected. |
| - EXPECT_CALL(observer(), |
| - OnRemovableStorageDetached(GetDeviceId(kDeviceNoDCIM))) |
| - .InSequence(mock_sequence); |
| WriteEmptyMtabAndRunLoop(); |
| + EXPECT_EQ(2, observer().detach_calls()); |
|
vandebo (ex-Chrome)
2013/01/24 19:19:10
nit: attach count
Greg Billock
2013/01/24 20:46:03
Done.
|
| + EXPECT_EQ(GetDeviceId(kDeviceNoDCIM), observer().last_detached().device_id); |
| } |
| // More complicated test case with multiple devices on multiple mount points. |
| @@ -413,16 +407,17 @@ TEST_F(RemovableDeviceNotificationLinuxTest, SwapMountPoints) { |
| ASSERT_FALSE(test_path_a.empty()); |
| ASSERT_FALSE(test_path_b.empty()); |
| - // Attach two devices. (*'d mounts are those SystemMonitor knows about.) |
| + // Attach two devices. |
| + // (*'d mounts are those RemovableStorageNotifications knows about.) |
| // kDeviceDCIM1 -> kMountPointA * |
| // kDeviceDCIM2 -> kMountPointB * |
| MtabTestData test_data1[] = { |
| MtabTestData(kDeviceDCIM1, test_path_a.value(), kValidFS), |
| MtabTestData(kDeviceDCIM2, test_path_b.value(), kValidFS), |
| }; |
| - EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(2); |
| - EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(0); |
| AppendToMtabAndRunLoop(test_data1, arraysize(test_data1)); |
| + EXPECT_EQ(2, observer().attach_calls()); |
| + EXPECT_EQ(0, observer().detach_calls()); |
| // Detach two devices from old mount points and attach the devices at new |
| // mount points. |
| @@ -432,14 +427,14 @@ TEST_F(RemovableDeviceNotificationLinuxTest, SwapMountPoints) { |
| MtabTestData(kDeviceDCIM1, test_path_b.value(), kValidFS), |
| MtabTestData(kDeviceDCIM2, test_path_a.value(), kValidFS), |
| }; |
| - EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(2); |
| - EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(2); |
| OverwriteMtabAndRunLoop(test_data2, arraysize(test_data2)); |
| + EXPECT_EQ(4, observer().attach_calls()); |
| + EXPECT_EQ(2, observer().detach_calls()); |
| // Detach all devices. |
| - EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0); |
| - EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(2); |
| WriteEmptyMtabAndRunLoop(); |
| + EXPECT_EQ(4, observer().attach_calls()); |
| + EXPECT_EQ(4, observer().detach_calls()); |
| } |
| // More complicated test case with multiple devices on multiple mount points. |
| @@ -449,16 +444,17 @@ TEST_F(RemovableDeviceNotificationLinuxTest, MultiDevicesMultiMountPoints) { |
| ASSERT_FALSE(test_path_a.empty()); |
| ASSERT_FALSE(test_path_b.empty()); |
| - // Attach two devices. (*'d mounts are those SystemMonitor knows about.) |
| + // Attach two devices. |
| + // (*'d mounts are those RemovableStorageNotifications knows about.) |
| // kDeviceDCIM1 -> kMountPointA * |
| // kDeviceDCIM2 -> kMountPointB * |
| MtabTestData test_data1[] = { |
| MtabTestData(kDeviceDCIM1, test_path_a.value(), kValidFS), |
| MtabTestData(kDeviceDCIM2, test_path_b.value(), kValidFS), |
| }; |
| - EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(2); |
| - EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(0); |
| AppendToMtabAndRunLoop(test_data1, arraysize(test_data1)); |
| + EXPECT_EQ(2, observer().attach_calls()); |
| + EXPECT_EQ(0, observer().detach_calls()); |
| // Attach |kDeviceDCIM1| to |kMountPointB|. |
| // |kDeviceDCIM2| is inaccessible, so it is detached. |kDeviceDCIM1| has been |
| @@ -469,9 +465,9 @@ TEST_F(RemovableDeviceNotificationLinuxTest, MultiDevicesMultiMountPoints) { |
| MtabTestData test_data2[] = { |
| MtabTestData(kDeviceDCIM1, test_path_b.value(), kValidFS), |
| }; |
| - EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0); |
| - EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(1); |
| AppendToMtabAndRunLoop(test_data2, arraysize(test_data2)); |
| + EXPECT_EQ(2, observer().attach_calls()); |
| + EXPECT_EQ(1, observer().detach_calls()); |
| // Detach |kDeviceDCIM1| from |kMountPointA|, causing a detach and attach |
| // event. |
| @@ -481,9 +477,9 @@ TEST_F(RemovableDeviceNotificationLinuxTest, MultiDevicesMultiMountPoints) { |
| MtabTestData(kDeviceDCIM2, test_path_b.value(), kValidFS), |
| MtabTestData(kDeviceDCIM1, test_path_b.value(), kValidFS), |
| }; |
| - EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(1); |
| - EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(1); |
| OverwriteMtabAndRunLoop(test_data3, arraysize(test_data3)); |
| + EXPECT_EQ(3, observer().attach_calls()); |
| + EXPECT_EQ(2, observer().detach_calls()); |
| // Attach |kDeviceDCIM1| to |kMountPointA|. |
| // kDeviceDCIM2 -> kMountPointB |
| @@ -492,21 +488,21 @@ TEST_F(RemovableDeviceNotificationLinuxTest, MultiDevicesMultiMountPoints) { |
| MtabTestData test_data4[] = { |
| MtabTestData(kDeviceDCIM1, test_path_a.value(), kValidFS), |
| }; |
| - EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0); |
| - EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(0); |
| AppendToMtabAndRunLoop(test_data4, arraysize(test_data4)); |
| + EXPECT_EQ(3, observer().attach_calls()); |
| + EXPECT_EQ(2, observer().detach_calls()); |
| // Detach |kDeviceDCIM1| from |kMountPointB|. |
| // kDeviceDCIM1 -> kMountPointA * |
| // kDeviceDCIM2 -> kMountPointB * |
| - EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(2); |
| - EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(1); |
| OverwriteMtabAndRunLoop(test_data1, arraysize(test_data1)); |
| + EXPECT_EQ(5, observer().attach_calls()); |
| + EXPECT_EQ(3, observer().detach_calls()); |
| // Detach all devices. |
| - EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0); |
| - EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(2); |
| WriteEmptyMtabAndRunLoop(); |
| + EXPECT_EQ(5, observer().attach_calls()); |
| + EXPECT_EQ(5, observer().detach_calls()); |
| } |
| TEST_F(RemovableDeviceNotificationLinuxTest, |
| @@ -516,14 +512,15 @@ TEST_F(RemovableDeviceNotificationLinuxTest, |
| ASSERT_FALSE(test_path_a.empty()); |
| ASSERT_FALSE(test_path_b.empty()); |
| - // Attach to one first. (*'d mounts are those SystemMonitor knows about.) |
| + // Attach to one first. |
| + // (*'d mounts are those RemovableStorageNotifications knows about.) |
| // kDeviceDCIM1 -> kMountPointA * |
| MtabTestData test_data1[] = { |
| MtabTestData(kDeviceDCIM1, test_path_a.value(), kValidFS), |
| }; |
| - EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(1); |
| - EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(0); |
| AppendToMtabAndRunLoop(test_data1, arraysize(test_data1)); |
| + EXPECT_EQ(1, observer().attach_calls()); |
| + EXPECT_EQ(0, observer().detach_calls()); |
| // Attach |kDeviceDCIM1| to |kMountPointB|. |
| // kDeviceDCIM1 -> kMountPointA * |
| @@ -531,9 +528,9 @@ TEST_F(RemovableDeviceNotificationLinuxTest, |
| MtabTestData test_data2[] = { |
| MtabTestData(kDeviceDCIM1, test_path_b.value(), kValidFS), |
| }; |
| - EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0); |
| - EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(0); |
| AppendToMtabAndRunLoop(test_data2, arraysize(test_data2)); |
| + EXPECT_EQ(1, observer().attach_calls()); |
| + EXPECT_EQ(0, observer().detach_calls()); |
| // Attach |kDeviceFixed| (a non-removable device) to |kMountPointA|. |
| // kDeviceDCIM1 -> kMountPointA |
| @@ -542,10 +539,10 @@ TEST_F(RemovableDeviceNotificationLinuxTest, |
| MtabTestData test_data3[] = { |
| MtabTestData(kDeviceFixed, test_path_a.value(), kValidFS), |
| }; |
| - EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(1); |
| - EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(1); |
| RemoveDCIMDirFromMountPoint(kMountPointA); |
| AppendToMtabAndRunLoop(test_data3, arraysize(test_data3)); |
| + EXPECT_EQ(2, observer().attach_calls()); |
| + EXPECT_EQ(1, observer().detach_calls()); |
| // Detach |kDeviceFixed|. |
| // kDeviceDCIM1 -> kMountPointA |
| @@ -554,10 +551,10 @@ TEST_F(RemovableDeviceNotificationLinuxTest, |
| MtabTestData(kDeviceDCIM1, test_path_a.value(), kValidFS), |
| MtabTestData(kDeviceDCIM1, test_path_b.value(), kValidFS), |
| }; |
| - EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0); |
| - EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(0); |
| CreateMountPointWithDCIMDir(kMountPointA); |
| OverwriteMtabAndRunLoop(test_data4, arraysize(test_data4)); |
| + EXPECT_EQ(2, observer().attach_calls()); |
| + EXPECT_EQ(1, observer().detach_calls()); |
| // Attach |kDeviceNoDCIM| (a non-DCIM device) to |kMountPointB|. |
| // kDeviceDCIM1 -> kMountPointA * |
| @@ -566,10 +563,10 @@ TEST_F(RemovableDeviceNotificationLinuxTest, |
| MtabTestData test_data5[] = { |
| MtabTestData(kDeviceNoDCIM, test_path_b.value(), kValidFS), |
| }; |
| - EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(2); |
| - EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(1); |
| file_util::Delete(test_path_b.Append(kDCIMDirectoryName), false); |
| AppendToMtabAndRunLoop(test_data5, arraysize(test_data5)); |
| + EXPECT_EQ(4, observer().attach_calls()); |
| + EXPECT_EQ(2, observer().detach_calls()); |
| // Detach |kDeviceNoDCIM|. |
| // kDeviceDCIM1 -> kMountPointA * |
| @@ -578,21 +575,21 @@ TEST_F(RemovableDeviceNotificationLinuxTest, |
| MtabTestData(kDeviceDCIM1, test_path_a.value(), kValidFS), |
| MtabTestData(kDeviceDCIM1, test_path_b.value(), kValidFS), |
| }; |
| - EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0); |
| - EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(1); |
| CreateMountPointWithDCIMDir(kMountPointB); |
| OverwriteMtabAndRunLoop(test_data6, arraysize(test_data6)); |
| + EXPECT_EQ(4, observer().attach_calls()); |
| + EXPECT_EQ(3, observer().detach_calls()); |
| // Detach |kDeviceDCIM1| from |kMountPointB|. |
| // kDeviceDCIM1 -> kMountPointA * |
| - EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0); |
| - EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(0); |
| OverwriteMtabAndRunLoop(test_data1, arraysize(test_data1)); |
| + EXPECT_EQ(4, observer().attach_calls()); |
| + EXPECT_EQ(3, observer().detach_calls()); |
| // Detach all devices. |
| - EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0); |
| - EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(1); |
| WriteEmptyMtabAndRunLoop(); |
| + EXPECT_EQ(4, observer().attach_calls()); |
| + EXPECT_EQ(4, observer().detach_calls()); |
| } |
| TEST_F(RemovableDeviceNotificationLinuxTest, DeviceLookUp) { |
| @@ -603,7 +600,8 @@ TEST_F(RemovableDeviceNotificationLinuxTest, DeviceLookUp) { |
| ASSERT_FALSE(test_path_b.empty()); |
| ASSERT_FALSE(test_path_c.empty()); |
| - // Attach to one first. (*'d mounts are those SystemMonitor knows about.) |
| + // Attach to one first. |
| + // (*'d mounts are those RemovableStorageNotifications knows about.) |
| // kDeviceDCIM1 -> kMountPointA * |
| // kDeviceNoDCIM -> kMountPointB * |
| // kDeviceFixed -> kMountPointC |
| @@ -612,11 +610,11 @@ TEST_F(RemovableDeviceNotificationLinuxTest, DeviceLookUp) { |
| MtabTestData(kDeviceNoDCIM, test_path_b.value(), kValidFS), |
| MtabTestData(kDeviceFixed, test_path_c.value(), kValidFS), |
| }; |
| - EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(2); |
| - EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(0); |
| AppendToMtabAndRunLoop(test_data1, arraysize(test_data1)); |
| + EXPECT_EQ(2, observer().attach_calls()); |
| + EXPECT_EQ(0, observer().detach_calls()); |
| - base::SystemMonitor::RemovableStorageInfo device_info; |
| + RemovableStorageNotifications::StorageInfo device_info; |
| EXPECT_TRUE(notifier()->GetDeviceInfoForPath(test_path_a, &device_info)); |
| EXPECT_EQ(GetDeviceId(kDeviceDCIM1), device_info.device_id); |
| EXPECT_EQ(test_path_a.value(), device_info.location); |
| @@ -651,8 +649,6 @@ TEST_F(RemovableDeviceNotificationLinuxTest, DeviceLookUp) { |
| MtabTestData(kDeviceFixed, test_path_b.value(), kValidFS), |
| MtabTestData(kDeviceFixed, test_path_c.value(), kValidFS), |
| }; |
| - EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0); |
| - EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(1); |
| AppendToMtabAndRunLoop(test_data2, arraysize(test_data2)); |
| EXPECT_TRUE(notifier()->GetDeviceInfoForPath(test_path_a, &device_info)); |
| @@ -663,6 +659,9 @@ TEST_F(RemovableDeviceNotificationLinuxTest, DeviceLookUp) { |
| EXPECT_TRUE(notifier()->GetDeviceInfoForPath(test_path_c, &device_info)); |
| EXPECT_EQ(GetDeviceId(kDeviceFixed), device_info.device_id); |
| + |
| + EXPECT_EQ(2, observer().attach_calls()); |
| + EXPECT_EQ(1, observer().detach_calls()); |
| } |
| TEST_F(RemovableDeviceNotificationLinuxTest, DevicePartitionSize) { |
| @@ -676,9 +675,9 @@ TEST_F(RemovableDeviceNotificationLinuxTest, DevicePartitionSize) { |
| MtabTestData(kDeviceNoDCIM, test_path_b.value(), kValidFS), |
| MtabTestData(kDeviceFixed, kInvalidPath, kInvalidFS), |
| }; |
| - EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(2); |
| - EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(0); |
| AppendToMtabAndRunLoop(test_data1, arraysize(test_data1)); |
| + EXPECT_EQ(2, observer().attach_calls()); |
| + EXPECT_EQ(0, observer().detach_calls()); |
| EXPECT_EQ(GetDevicePartitionSize(kDeviceDCIM1), |
| notifier()->GetStorageSize(test_path_a.value())); |