| 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..56a285668fd34a25e5f65f2785d77526bafad38d 100644
|
| --- a/chromeos/disks/disk_mount_manager_unittest.cc
|
| +++ b/chromeos/disks/disk_mount_manager_unittest.cc
|
| @@ -895,4 +895,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.
|
| + 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
|
|
|