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

Unified Diff: chromeos/disks/disk_mount_manager_unittest.cc

Issue 2230713003: Store correct read-only flag of mounted disks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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 bc9d1f6b6554ee5627f2ccad582e245ccafc257e..e8c25943e5129ede9a0880443f7c30e4dedaf60d 100644
--- a/chromeos/disks/disk_mount_manager_unittest.cc
+++ b/chromeos/disks/disk_mount_manager_unittest.cc
@@ -57,28 +57,50 @@ struct TestMountPointInfo {
// List of disks held in DiskMountManager at the begining of the test.
const TestDiskInfo kTestDisks[] = {
- {
- "/device/source_path",
- "/device/mount_path",
- "/device/prefix/system_path",
- "/device/file_path",
- "/device/device_label",
- "/device/drive_label",
- "/device/vendor_id",
- "/device/vendor_name",
- "/device/product_id",
- "/device/product_name",
- "/device/fs_uuid",
- "/device/prefix",
- chromeos::DEVICE_TYPE_USB,
- 1073741824, // size in bytes
- false, // is parent
- false, // is read only
- true, // has media
- false, // is on boot device
- true, // is on removable device
- false // is hidden
- },
+ {
+ "/device/source_path",
+ "/device/mount_path",
+ "/device/prefix/system_path",
+ "/device/file_path",
+ "/device/device_label",
+ "/device/drive_label",
+ "/device/vendor_id",
+ "/device/vendor_name",
+ "/device/product_id",
+ "/device/product_name",
+ "/device/fs_uuid",
+ "/device/prefix",
+ chromeos::DEVICE_TYPE_USB,
+ 1073741824, // size in bytes
+ false, // is parent
+ false, // is read only
+ true, // has media
+ false, // is on boot device
+ true, // is on removable device
+ false // is hidden
+ },
+ {
+ "/device/source_path2",
+ "/device/mount_path2",
+ "/device/prefix/system_path2",
+ "/device/file_path2",
+ "/device/device_label2",
+ "/device/drive_label2",
+ "/device/vendor_id2",
+ "/device/vendor_name2",
+ "/device/product_id2",
+ "/device/product_name2",
+ "/device/fs_uuid2",
+ "/device/prefix2",
+ chromeos::DEVICE_TYPE_SD,
+ 1073741824, // size in bytes
+ false, // is parent
+ false, // is read only
+ true, // has media
+ false, // is on boot device
+ true, // is on removable device
+ false // is hidden
+ },
};
// List of mount points held in DiskMountManager at the begining of the test.
@@ -578,4 +600,33 @@ TEST_F(DiskMountManagerTest, Format_ConsecutiveFormatCalls) {
chromeos::FORMAT_ERROR_NONE, "/device/source_path");
}
+TEST_F(DiskMountManagerTest, MountPath_RecordAccessMode) {
+ DiskMountManager* manager = DiskMountManager::GetInstance();
+ const std::string kSourcePath1 = "/device/source_path";
+ const std::string kSourcePath2 = "/device/source_path2";
+ const std::string kSourceFormat = "";
+ const std::string kMountLabel1 = "/device/mount_path1";
+ const std::string kMountLabel2 = "/device/mount_path2";
+
+ manager->MountPath(kSourcePath1, kSourceFormat, kMountLabel1,
+ chromeos::MOUNT_TYPE_DEVICE,
+ chromeos::MOUNT_ACCESS_MODE_READ_WRITE);
+ manager->MountPath(kSourcePath2, kSourceFormat, kMountLabel2,
+ chromeos::MOUNT_TYPE_DEVICE,
+ chromeos::MOUNT_ACCESS_MODE_READ_ONLY);
+ // Simulate cros_disks reporting mount completed.
+ fake_cros_disks_client_->SendMountCompletedEvent(
+ chromeos::MOUNT_ERROR_NONE, kSourcePath1, chromeos::MOUNT_TYPE_DEVICE,
+ kMountLabel1);
+ fake_cros_disks_client_->SendMountCompletedEvent(
+ chromeos::MOUNT_ERROR_NONE, kSourcePath2, chromeos::MOUNT_TYPE_DEVICE,
+ kMountLabel2);
+
+ const DiskMountManager::DiskMap& disks = manager->disks();
+ ASSERT_FALSE(disks.find(kSourcePath1) == disks.end());
satorux1 2016/08/12 02:47:52 how about: ASSERT_GT(disks.count(kSourcePath1), 0
yamaguchi 2016/08/15 15:32:48 Done.
+ EXPECT_FALSE(disks.find(kSourcePath1)->second->is_read_only());
+ ASSERT_FALSE(disks.find(kSourcePath2) == disks.end());
satorux1 2016/08/12 02:47:52 ditto
yamaguchi 2016/08/15 15:32:48 Done.
+ EXPECT_TRUE(disks.find(kSourcePath2)->second->is_read_only());
+}
+
} // namespace
« chromeos/disks/disk_mount_manager.cc ('K') | « chromeos/disks/disk_mount_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698