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

Unified Diff: chromeos/disks/disk_mount_manager_unittest.cc

Issue 2247263002: Prevent formatting a device being mounted in read-only mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix indent to preserve existing style. 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
« no previous file with comments | « chromeos/disks/disk_mount_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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,
« no previous file with comments | « chromeos/disks/disk_mount_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698