Chromium Code Reviews| Index: chromeos/disks/disk_mount_manager_unittest.cc |
| diff --git a/chromeos/disks/disk_mount_manager_unittest.cc b/chromeos/disks/disk_mount_manager_unittest.cc |
| index ac68206428ee754f489c51ef8f1211c0b019c82f..a2e339c666069f4d73f1a069f9eca3afb159405b 100644 |
| --- a/chromeos/disks/disk_mount_manager_unittest.cc |
| +++ b/chromeos/disks/disk_mount_manager_unittest.cc |
| @@ -29,7 +29,6 @@ namespace { |
| const char kDevice1SourcePath[] = "/device/source_path"; |
| const char kDevice1MountPath[] = "/device/mount_path"; |
| const char kDevice2SourcePath[] = "/device/source_path2"; |
| -const char kDevice2MountPath[] = "/device/mount_path2"; |
| const char kReadOnlyDeviceMountPath[] = "/device/read_only_mount_path"; |
| const char kReadOnlyDeviceSourcePath[] = "/device/read_only_source_path"; |
| @@ -93,7 +92,7 @@ const TestDiskInfo kTestDisks[] = { |
| }, |
| { |
| kDevice2SourcePath, |
| - kDevice2MountPath, |
| + "", // not mounted initially |
| false, // write_disabled_by_policy |
| "/device/prefix/system_path2", |
| "/device/file_path2", |
| @@ -895,4 +894,41 @@ TEST_F(DiskMountManagerTest, MountPath_ReadOnlyDevice) { |
| EXPECT_TRUE(disks.find(kReadOnlyDeviceSourcePath)->second->is_read_only()); |
| } |
| +TEST_F(DiskMountManagerTest, RemountRemovableDrives) { |
| + DiskMountManager* manager = DiskMountManager::GetInstance(); |
| + manager->RemountAllRemovableDrives(chromeos::MOUNT_ACCESS_MODE_READ_ONLY); |
| + |
| + // Simulate cros_disks reporting mount completed. |
| + fake_cros_disks_client_->SendMountCompletedEvent( |
| + chromeos::MOUNT_ERROR_NONE, kDevice1SourcePath, |
| + chromeos::MOUNT_TYPE_DEVICE, kDevice1MountPath); |
| + |
| + // Should remount all devices but read-only hardwares. |
|
hashimoto
2016/10/27 08:31:52
"but read-only hardwares" what this mean?
It seems
yamaguchi
2016/10/27 09:52:41
It means that "all volumes should be remounted, bu
|
| + ASSERT_EQ(1U, observer_->GetEventCount()); |
| + VerifyMountEvent(observer_->GetMountEvent(0), DiskMountManager::MOUNTING, |
| + chromeos::MOUNT_ERROR_NONE, kDevice1MountPath); |
| + // The device is remounted in read-only mode. |
| + EXPECT_TRUE( |
| + manager->FindDiskBySourcePath(kDevice1SourcePath)->is_read_only()); |
| + // Remounted disk should also appear as read-only to observers. |
| + EXPECT_TRUE(observer_->GetMountEvent(0).disk->is_read_only()); |
| + |
| + // Remount in read-write mode again. |
| + manager->RemountAllRemovableDrives(chromeos::MOUNT_ACCESS_MODE_READ_WRITE); |
| + |
| + // Simulate cros_disks reporting mount completed. |
| + fake_cros_disks_client_->SendMountCompletedEvent( |
| + chromeos::MOUNT_ERROR_NONE, kDevice1SourcePath, |
| + chromeos::MOUNT_TYPE_DEVICE, kDevice1MountPath); |
| + // Event handlers of observers should be called. |
| + ASSERT_EQ(2U, observer_->GetEventCount()); |
| + VerifyMountEvent(observer_->GetMountEvent(1), DiskMountManager::MOUNTING, |
| + chromeos::MOUNT_ERROR_NONE, kDevice1MountPath); |
| + // The read-write device should be remounted in read-write mode. |
| + EXPECT_FALSE( |
| + manager->FindDiskBySourcePath(kDevice1SourcePath)->is_read_only()); |
| + // Remounted disk should also appear as writable to observers. |
| + EXPECT_FALSE(observer_->GetMountEvent(1).disk->is_read_only()); |
| +} |
| + |
| } // namespace |