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 bc9d1f6b6554ee5627f2ccad582e245ccafc257e..fa5518698a9f32ab1985e8ef65b0e3bc529f66a6 100644 |
| --- a/chromeos/disks/disk_mount_manager_unittest.cc |
| +++ b/chromeos/disks/disk_mount_manager_unittest.cc |
| @@ -23,6 +23,9 @@ using testing::InSequence; |
| namespace { |
| +const char kReadOnlyMountpath[] = "/device/read_only_mount_path"; |
| +const char kReadOnlyDeviceSource[] = "/device/read_only_source_path"; |
| + |
| // Holds information needed to create a DiskMountManager::Disk instance. |
| struct TestDiskInfo { |
| const char* source_path; |
| @@ -57,44 +60,72 @@ 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 |
| - }, |
| + { |
|
satorux1
2016/08/16 20:24:04
Is this indentation change necessary? Maybe done b
yamaguchi
2016/08/17 04:06:17
It was done by clang-format.
Reverted some changes
|
| + "/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 |
| + }, |
| + { |
| + kReadOnlyDeviceSource, |
| + kReadOnlyMountpath, |
| + "/device/prefix/system_path_2", |
| + "/device/file_path_2", |
| + "/device/device_label_2", |
| + "/device/drive_label_2", |
| + "/device/vendor_id_2", |
| + "/device/vendor_name_2", |
| + "/device/product_id_2", |
| + "/device/product_name_2", |
| + "/device/fs_uuid_2", |
| + "/device/prefix", |
| + chromeos::DEVICE_TYPE_USB, |
| + 1073741824, // size in bytes |
| + false, // is parent |
| + true, // 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. |
| const TestMountPointInfo kTestMountPoints[] = { |
| - { |
| - "/archive/source_path", |
| - "/archive/mount_path", |
| - chromeos::MOUNT_TYPE_ARCHIVE, |
| - chromeos::disks::MOUNT_CONDITION_NONE |
| - }, |
| - { |
| - "/device/source_path", |
| - "/device/mount_path", |
| - chromeos::MOUNT_TYPE_DEVICE, |
| - chromeos::disks::MOUNT_CONDITION_NONE |
| - }, |
| + { |
| + "/archive/source_path", |
| + "/archive/mount_path", |
| + chromeos::MOUNT_TYPE_ARCHIVE, |
| + chromeos::disks::MOUNT_CONDITION_NONE |
| + }, |
| + { |
| + "/device/source_path", |
| + "/device/mount_path", |
| + chromeos::MOUNT_TYPE_DEVICE, |
| + chromeos::disks::MOUNT_CONDITION_NONE |
| + }, |
| + { |
| + kReadOnlyDeviceSource, |
| + kReadOnlyMountpath, |
| + chromeos::MOUNT_TYPE_DEVICE, |
| + chromeos::disks::MOUNT_CONDITION_NONE |
| + }, |
| }; |
| // Mocks DiskMountManager observer. |
| @@ -216,6 +247,17 @@ TEST_F(DiskMountManagerTest, Format_NotMounted) { |
| DiskMountManager::GetInstance()->FormatMountedDevice("/mount/non_existent"); |
| } |
| +// Tests that the observer gets notified on attempt to format read-only mount |
| +// point. |
| +TEST_F(DiskMountManagerTest, Format_ReadOnly) { |
| + EXPECT_CALL(observer_, |
| + OnFormatEvent(DiskMountManager::FORMAT_COMPLETED, |
| + chromeos::FORMAT_ERROR_DEVICE_NOT_ALLOWED, |
| + kReadOnlyMountpath)) |
| + .Times(1); |
| + DiskMountManager::GetInstance()->FormatMountedDevice(kReadOnlyMountpath); |
| +} |
| + |
| // Tests that it is not possible to format archive mount point. |
| TEST_F(DiskMountManagerTest, Format_Archive) { |
| EXPECT_CALL(observer_, OnFormatEvent(DiskMountManager::FORMAT_COMPLETED, |