Index: chrome/browser/media_gallery/removable_device_notifications_linux_unittest.cc |
diff --git a/chrome/browser/media_gallery/removable_device_notifications_linux_unittest.cc b/chrome/browser/media_gallery/removable_device_notifications_linux_unittest.cc |
index 244560d66cf3396bdd7f9397b74c7c5f79ede100..4f290381ee8db73bccc0463c03d3f86126a83441 100644 |
--- a/chrome/browser/media_gallery/removable_device_notifications_linux_unittest.cc |
+++ b/chrome/browser/media_gallery/removable_device_notifications_linux_unittest.cc |
@@ -310,8 +310,8 @@ TEST_F(RemovableDeviceNotificationLinuxTest, BasicAttachDetach) { |
FilePath test_path = CreateMountPointWithDCIMDir(kMountPointA); |
ASSERT_FALSE(test_path.empty()); |
MtabTestData test_data[] = { |
- MtabTestData(kDevice1, kInvalidPath, kValidFS), |
MtabTestData(kDevice2, test_path.value(), kValidFS), |
+ MtabTestData(kDevice5, kInvalidPath, kValidFS), |
}; |
// Only |kDevice2| should be attached, since |kDevice1| has a bad path. |
kmadhusu
2012/08/29 01:12:02
nit: kDevice1 => kDevice5
vandebo (ex-Chrome)
2012/08/29 06:10:13
Done.
kmadhusu
2012/08/29 16:46:19
Only |kDevice2| should be attached, since |kDevice
vandebo (ex-Chrome)
2012/08/29 17:04:39
Oops, fixed.
|
EXPECT_CALL(observer(), OnRemovableStorageAttached(GetDeviceId(kDevice2), |
@@ -326,8 +326,8 @@ TEST_F(RemovableDeviceNotificationLinuxTest, BasicAttachDetach) { |
WriteEmptyMtabAndRunLoop(); |
} |
-// Only mount points with DCIM directories are recognized. |
-TEST_F(RemovableDeviceNotificationLinuxTest, DCIM) { |
+// 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()); |
@@ -341,11 +341,11 @@ TEST_F(RemovableDeviceNotificationLinuxTest, DCIM) { |
.InSequence(mock_sequence); |
AppendToMtabAndRunLoop(test_data1, arraysize(test_data1)); |
- // This should do nothing, since |kMountPointB| does not have a DCIM dir. |
+ // This should do nothing, since |kDevice5| is not removable. |
FilePath test_path_b = CreateMountPointWithoutDCIMDir(kMountPointB); |
ASSERT_FALSE(test_path_b.empty()); |
MtabTestData test_data2[] = { |
- MtabTestData(kDevice2, test_path_b.value(), kValidFS), |
+ MtabTestData(kDevice5, test_path_b.value(), kValidFS), |
}; |
AppendToMtabAndRunLoop(test_data2, arraysize(test_data2)); |
@@ -353,6 +353,21 @@ TEST_F(RemovableDeviceNotificationLinuxTest, DCIM) { |
EXPECT_CALL(observer(), OnRemovableStorageDetached(GetDeviceId(kDevice1))) |
.InSequence(mock_sequence); |
kmadhusu
2012/08/29 01:12:02
We will also receive an attach and detach for kDev
vandebo (ex-Chrome)
2012/08/29 06:10:13
No we won't, device5 is not removable.
kmadhusu
2012/08/29 16:46:19
For readability, we should have better names for t
vandebo (ex-Chrome)
2012/08/29 17:04:39
Done.
|
WriteEmptyMtabAndRunLoop(); |
+ |
+ // |kDevice4| should be attached as expected. |
+ EXPECT_CALL(observer(), OnRemovableStorageAttached(GetDeviceId(kDevice4), |
+ GetDeviceName(kDevice4), |
+ test_path_b.value())) |
+ .InSequence(mock_sequence); |
+ MtabTestData test_data3[] = { |
+ MtabTestData(kDevice4, test_path_b.value(), kValidFS), |
+ }; |
+ AppendToMtabAndRunLoop(test_data3, arraysize(test_data3)); |
+ |
+ // |kDevice4| should be detached as expected. |
+ EXPECT_CALL(observer(), OnRemovableStorageDetached(GetDeviceId(kDevice4))) |
+ .InSequence(mock_sequence); |
+ WriteEmptyMtabAndRunLoop(); |
} |
// More complicated test case with multiple devices on multiple mount points. |
@@ -363,8 +378,8 @@ TEST_F(RemovableDeviceNotificationLinuxTest, SwapMountPoints) { |
ASSERT_FALSE(test_path_b.empty()); |
// Attach two devices. |
- // kDevice1 -> kMountPointA |
- // kDevice2 -> kMountPointB |
+ // kDevice1 -> kMountPointA * |
+ // kDevice2 -> kMountPointB * |
kmadhusu
2012/08/29 16:46:19
nit: It took a while for me to understand what "*"
vandebo (ex-Chrome)
2012/08/29 17:04:39
Done.
|
MtabTestData test_data1[] = { |
MtabTestData(kDevice1, test_path_a.value(), kValidFS), |
MtabTestData(kDevice2, test_path_b.value(), kValidFS), |
@@ -375,8 +390,8 @@ TEST_F(RemovableDeviceNotificationLinuxTest, SwapMountPoints) { |
// Detach two devices from old mount points and attach the devices at new |
// mount points. |
- // kDevice1 -> kMountPointB |
- // kDevice2 -> kMountPointA |
+ // kDevice1 -> kMountPointB * |
+ // kDevice2 -> kMountPointA * |
MtabTestData test_data2[] = { |
MtabTestData(kDevice1, test_path_b.value(), kValidFS), |
MtabTestData(kDevice2, test_path_a.value(), kValidFS), |
@@ -483,19 +498,19 @@ TEST_F(RemovableDeviceNotificationLinuxTest, |
EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(0); |
AppendToMtabAndRunLoop(test_data2, arraysize(test_data2)); |
- // Attach |kDevice4| (a non-DCIM device) to |kMountPointA|. |
+ // Attach |kDevice5| (a non-removable device) to |kMountPointA|. |
// kDevice1 -> kMountPointA |
// kDevice1 -> kMountPointB * |
- // kDevice4 -> kMountPointA |
+ // kDevice5 -> kMountPointA |
MtabTestData test_data3[] = { |
- MtabTestData(kDevice4, test_path_a.value(), kValidFS), |
+ MtabTestData(kDevice5, 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)); |
- // Detach |kDevice4|. |
+ // Detach |kDevice5|. |
// kDevice1 -> kMountPointA |
// kDevice1 -> kMountPointB * |
MtabTestData test_data4[] = { |
@@ -504,13 +519,38 @@ TEST_F(RemovableDeviceNotificationLinuxTest, |
}; |
EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0); |
EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(0); |
+ CreateMountPointWithDCIMDir(kMountPointA); |
OverwriteMtabAndRunLoop(test_data4, arraysize(test_data4)); |
- // Detach |kDevice1| from |kMountPointA|. |
- // kDevice1 -> kMountPointB * |
+ // Attach |kDevice4| (a non-DCIM device) to |kMountPointB|. |
+ // kDevice1 -> kMountPointA * |
+ // kDevice1 -> kMountPointB |
+ // kDevice4 -> kMountPointB * |
+ MtabTestData test_data5[] = { |
+ MtabTestData(kDevice4, test_path_b.value(), kValidFS), |
+ }; |
+ EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(2); |
+ EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(1); |
+ file_util::Delete(test_path_b.Append("DCIM"), false); |
+ AppendToMtabAndRunLoop(test_data5, arraysize(test_data5)); |
+ |
+ // Detach |kDevice4|. |
+ // kDevice1 -> kMountPointA * |
+ // kDevice1 -> kMountPointB |
+ MtabTestData test_data6[] = { |
+ MtabTestData(kDevice1, test_path_a.value(), kValidFS), |
+ MtabTestData(kDevice1, 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)); |
+ |
+ // Detach |kDevice1| from |kMountPointB|. |
+ // kDevice1 -> kMountPointA * |
EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0); |
EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(0); |
- OverwriteMtabAndRunLoop(test_data2, arraysize(test_data2)); |
+ OverwriteMtabAndRunLoop(test_data1, arraysize(test_data1)); |
// Detach all devices. |
EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0); |
@@ -528,14 +568,14 @@ TEST_F(RemovableDeviceNotificationLinuxTest, MountLookUp) { |
// Attach to one first. |
// kDevice1 -> kMountPointA * |
- // kDevice4 -> kMountPointB |
+ // kDevice4 -> kMountPointB * |
// kDevice5 -> kMountPointC |
kmadhusu
2012/08/29 01:12:02
Why did you add a * in kMountPointB but not to kMo
vandebo (ex-Chrome)
2012/08/29 06:10:13
The mount points with *'s are the ones we've notif
|
MtabTestData test_data1[] = { |
MtabTestData(kDevice1, test_path_a.value(), kValidFS), |
MtabTestData(kDevice4, test_path_b.value(), kValidFS), |
MtabTestData(kDevice5, test_path_c.value(), kValidFS), |
}; |
- EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(1); |
+ EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(2); |
EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(0); |
AppendToMtabAndRunLoop(test_data1, arraysize(test_data1)); |
@@ -558,7 +598,7 @@ TEST_F(RemovableDeviceNotificationLinuxTest, MountLookUp) { |
MtabTestData(kDevice1, test_path_c.value(), kValidFS), |
}; |
EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0); |
- EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(0); |
+ EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(1); |
// Add DCIM dirs. |
CreateMountPointWithDCIMDir(kMountPointB); |
CreateMountPointWithDCIMDir(kMountPointC); |
@@ -614,14 +654,14 @@ TEST_F(RemovableDeviceNotificationLinuxTest, DeviceLookUp) { |
// Attach to one first. |
// kDevice1 -> kMountPointA * |
- // kDevice4 -> kMountPointB |
+ // kDevice4 -> kMountPointB * |
// kDevice5 -> kMountPointC |
kmadhusu
2012/08/29 01:12:02
nit: kMountPointC * ???
|
MtabTestData test_data1[] = { |
MtabTestData(kDevice1, test_path_a.value(), kValidFS), |
MtabTestData(kDevice4, test_path_b.value(), kValidFS), |
MtabTestData(kDevice5, test_path_c.value(), kValidFS), |
}; |
- EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(1); |
+ EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(2); |
EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(0); |
AppendToMtabAndRunLoop(test_data1, arraysize(test_data1)); |
@@ -654,7 +694,7 @@ TEST_F(RemovableDeviceNotificationLinuxTest, DeviceLookUp) { |
MtabTestData(kDevice5, test_path_c.value(), kValidFS), |
}; |
EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0); |
- EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(0); |
+ EXPECT_CALL(observer(), OnRemovableStorageDetached(_)).Times(1); |
AppendToMtabAndRunLoop(test_data2, arraysize(test_data2)); |
EXPECT_EQ(GetDeviceId(kDevice1), |