Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 1073741824, // size in bytes | 86 1073741824, // size in bytes |
| 87 false, // is parent | 87 false, // is parent |
| 88 false, // is read only | 88 false, // is read only |
| 89 true, // has media | 89 true, // has media |
| 90 false, // is on boot device | 90 false, // is on boot device |
| 91 true, // is on removable device | 91 true, // is on removable device |
| 92 false // is hidden | 92 false // is hidden |
| 93 }, | 93 }, |
| 94 { | 94 { |
| 95 kDevice2SourcePath, | 95 kDevice2SourcePath, |
| 96 kDevice2MountPath, | 96 kDevice2MountPath, |
|
yamaguchi
2016/10/27 06:34:55
This should be an empty string, because there is n
| |
| 97 false, // write_disabled_by_policy | 97 false, // write_disabled_by_policy |
| 98 "/device/prefix/system_path2", | 98 "/device/prefix/system_path2", |
| 99 "/device/file_path2", | 99 "/device/file_path2", |
| 100 "/device/device_label2", | 100 "/device/device_label2", |
| 101 "/device/drive_label2", | 101 "/device/drive_label2", |
| 102 "/device/vendor_id2", | 102 "/device/vendor_id2", |
| 103 "/device/vendor_name2", | 103 "/device/vendor_name2", |
| 104 "/device/product_id2", | 104 "/device/product_id2", |
| 105 "/device/product_name2", | 105 "/device/product_name2", |
| 106 "/device/fs_uuid2", | 106 "/device/fs_uuid2", |
| (...skipping 781 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 888 // Event handlers of observers should be called. | 888 // Event handlers of observers should be called. |
| 889 ASSERT_EQ(1U, observer_->GetEventCount()); | 889 ASSERT_EQ(1U, observer_->GetEventCount()); |
| 890 VerifyMountEvent(observer_->GetMountEvent(0), DiskMountManager::MOUNTING, | 890 VerifyMountEvent(observer_->GetMountEvent(0), DiskMountManager::MOUNTING, |
| 891 chromeos::MOUNT_ERROR_NONE, kReadOnlyDeviceMountPath); | 891 chromeos::MOUNT_ERROR_NONE, kReadOnlyDeviceMountPath); |
| 892 const DiskMountManager::DiskMap& disks = manager->disks(); | 892 const DiskMountManager::DiskMap& disks = manager->disks(); |
| 893 ASSERT_GT(disks.count(kReadOnlyDeviceSourcePath), 0U); | 893 ASSERT_GT(disks.count(kReadOnlyDeviceSourcePath), 0U); |
| 894 // The mounted disk should preserve the read-only flag of the block device. | 894 // The mounted disk should preserve the read-only flag of the block device. |
| 895 EXPECT_TRUE(disks.find(kReadOnlyDeviceSourcePath)->second->is_read_only()); | 895 EXPECT_TRUE(disks.find(kReadOnlyDeviceSourcePath)->second->is_read_only()); |
| 896 } | 896 } |
| 897 | 897 |
| 898 TEST_F(DiskMountManagerTest, RemountRemovableDrives) { | |
| 899 DiskMountManager* manager = DiskMountManager::GetInstance(); | |
| 900 manager->RemountAllRemovableDrives(chromeos::MOUNT_ACCESS_MODE_READ_ONLY); | |
| 901 | |
| 902 // Simulate cros_disks reporting mount completed. | |
| 903 fake_cros_disks_client_->SendMountCompletedEvent( | |
| 904 chromeos::MOUNT_ERROR_NONE, kDevice1SourcePath, | |
| 905 chromeos::MOUNT_TYPE_DEVICE, kDevice1MountPath); | |
| 906 | |
| 907 // Should remount all devices but read-only hardwares. | |
| 908 ASSERT_EQ(1U, observer_->GetEventCount()); | |
| 909 VerifyMountEvent(observer_->GetMountEvent(0), DiskMountManager::MOUNTING, | |
| 910 chromeos::MOUNT_ERROR_NONE, kDevice1MountPath); | |
| 911 // The device is remounted in read-only mode. | |
| 912 EXPECT_TRUE( | |
| 913 manager->FindDiskBySourcePath(kDevice1SourcePath)->is_read_only()); | |
| 914 // Remounted disk should also appear as read-only to observers. | |
| 915 EXPECT_TRUE(observer_->GetMountEvent(0).disk->is_read_only()); | |
| 916 | |
| 917 // Remount in read-write mode again. | |
| 918 manager->RemountAllRemovableDrives(chromeos::MOUNT_ACCESS_MODE_READ_WRITE); | |
| 919 | |
| 920 // Simulate cros_disks reporting mount completed. | |
| 921 fake_cros_disks_client_->SendMountCompletedEvent( | |
| 922 chromeos::MOUNT_ERROR_NONE, kDevice1SourcePath, | |
| 923 chromeos::MOUNT_TYPE_DEVICE, kDevice1MountPath); | |
| 924 // Event handlers of observers should be called. | |
| 925 ASSERT_EQ(2U, observer_->GetEventCount()); | |
| 926 VerifyMountEvent(observer_->GetMountEvent(1), DiskMountManager::MOUNTING, | |
| 927 chromeos::MOUNT_ERROR_NONE, kDevice1MountPath); | |
| 928 // The read-write device should be remounted in read-write mode. | |
| 929 EXPECT_FALSE( | |
| 930 manager->FindDiskBySourcePath(kDevice1SourcePath)->is_read_only()); | |
| 931 // Remounted disk should also appear as writable to observers. | |
| 932 EXPECT_FALSE(observer_->GetMountEvent(1).disk->is_read_only()); | |
| 933 } | |
| 934 | |
| 898 } // namespace | 935 } // namespace |
| OLD | NEW |