Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Unified Diff: chromeos/disks/disk_mount_manager_unittest.cc

Issue 2451603002: Add a method to remount all removable devices in DiskMountManager. (Closed)
Patch Set: Do not pass mount path as mount_label because it causes test failure on some platforms. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698