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

Unified Diff: chromeos/disks/disk_mount_manager_unittest.cc

Issue 2451603002: Add a method to remount all removable devices in DiskMountManager. (Closed)
Patch Set: Update comment. 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..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

Powered by Google App Engine
This is Rietveld 408576698