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

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: Revert some more changes 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..3e9cdfecf8fc7a58096a34872c6c13441763772b 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;
@@ -74,6 +77,28 @@ const TestDiskInfo kTestDisks[] = {
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
@@ -95,6 +120,12 @@ const TestMountPointInfo kTestMountPoints[] = {
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