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 19 matching lines...) Expand all Loading... |
30 const char kDevice1MountPath[] = "/device/mount_path"; | 30 const char kDevice1MountPath[] = "/device/mount_path"; |
31 const char kDevice2SourcePath[] = "/device/source_path2"; | 31 const char kDevice2SourcePath[] = "/device/source_path2"; |
32 const char kDevice2MountPath[] = "/device/mount_path2"; | 32 const char kDevice2MountPath[] = "/device/mount_path2"; |
33 const char kReadOnlyDeviceMountPath[] = "/device/read_only_mount_path"; | 33 const char kReadOnlyDeviceMountPath[] = "/device/read_only_mount_path"; |
34 const char kReadOnlyDeviceSourcePath[] = "/device/read_only_source_path"; | 34 const char kReadOnlyDeviceSourcePath[] = "/device/read_only_source_path"; |
35 | 35 |
36 // Holds information needed to create a DiskMountManager::Disk instance. | 36 // Holds information needed to create a DiskMountManager::Disk instance. |
37 struct TestDiskInfo { | 37 struct TestDiskInfo { |
38 const char* source_path; | 38 const char* source_path; |
39 const char* mount_path; | 39 const char* mount_path; |
| 40 bool write_disabled_by_policy; |
40 const char* system_path; | 41 const char* system_path; |
41 const char* file_path; | 42 const char* file_path; |
42 const char* device_label; | 43 const char* device_label; |
43 const char* drive_label; | 44 const char* drive_label; |
44 const char* vendor_id; | 45 const char* vendor_id; |
45 const char* vendor_name; | 46 const char* vendor_name; |
46 const char* product_id; | 47 const char* product_id; |
47 const char* product_name; | 48 const char* product_name; |
48 const char* fs_uuid; | 49 const char* fs_uuid; |
49 const char* system_path_prefix; | 50 const char* system_path_prefix; |
(...skipping 13 matching lines...) Expand all Loading... |
63 const char* mount_path; | 64 const char* mount_path; |
64 chromeos::MountType mount_type; | 65 chromeos::MountType mount_type; |
65 chromeos::disks::MountCondition mount_condition; | 66 chromeos::disks::MountCondition mount_condition; |
66 }; | 67 }; |
67 | 68 |
68 // List of disks held in DiskMountManager at the begining of the test. | 69 // List of disks held in DiskMountManager at the begining of the test. |
69 const TestDiskInfo kTestDisks[] = { | 70 const TestDiskInfo kTestDisks[] = { |
70 { | 71 { |
71 kDevice1SourcePath, | 72 kDevice1SourcePath, |
72 kDevice1MountPath, | 73 kDevice1MountPath, |
| 74 false, // write_disabled_by_policy |
73 "/device/prefix/system_path", | 75 "/device/prefix/system_path", |
74 "/device/file_path", | 76 "/device/file_path", |
75 "/device/device_label", | 77 "/device/device_label", |
76 "/device/drive_label", | 78 "/device/drive_label", |
77 "/device/vendor_id", | 79 "/device/vendor_id", |
78 "/device/vendor_name", | 80 "/device/vendor_name", |
79 "/device/product_id", | 81 "/device/product_id", |
80 "/device/product_name", | 82 "/device/product_name", |
81 "/device/fs_uuid", | 83 "/device/fs_uuid", |
82 "/device/prefix", | 84 "/device/prefix", |
83 chromeos::DEVICE_TYPE_USB, | 85 chromeos::DEVICE_TYPE_USB, |
84 1073741824, // size in bytes | 86 1073741824, // size in bytes |
85 false, // is parent | 87 false, // is parent |
86 false, // is read only | 88 false, // is read only |
87 true, // has media | 89 true, // has media |
88 false, // is on boot device | 90 false, // is on boot device |
89 true, // is on removable device | 91 true, // is on removable device |
90 false // is hidden | 92 false // is hidden |
91 }, | 93 }, |
92 { | 94 { |
93 kDevice2SourcePath, | 95 kDevice2SourcePath, |
94 kDevice2MountPath, | 96 kDevice2MountPath, |
| 97 false, // write_disabled_by_policy |
95 "/device/prefix/system_path2", | 98 "/device/prefix/system_path2", |
96 "/device/file_path2", | 99 "/device/file_path2", |
97 "/device/device_label2", | 100 "/device/device_label2", |
98 "/device/drive_label2", | 101 "/device/drive_label2", |
99 "/device/vendor_id2", | 102 "/device/vendor_id2", |
100 "/device/vendor_name2", | 103 "/device/vendor_name2", |
101 "/device/product_id2", | 104 "/device/product_id2", |
102 "/device/product_name2", | 105 "/device/product_name2", |
103 "/device/fs_uuid2", | 106 "/device/fs_uuid2", |
104 "/device/prefix2", | 107 "/device/prefix2", |
105 chromeos::DEVICE_TYPE_SD, | 108 chromeos::DEVICE_TYPE_SD, |
106 1073741824, // size in bytes | 109 1073741824, // size in bytes |
107 false, // is parent | 110 false, // is parent |
108 false, // is read only | 111 false, // is read only |
109 true, // has media | 112 true, // has media |
110 false, // is on boot device | 113 false, // is on boot device |
111 true, // is on removable device | 114 true, // is on removable device |
112 false // is hidden | 115 false // is hidden |
113 }, | 116 }, |
114 { | 117 { |
115 kReadOnlyDeviceSourcePath, | 118 kReadOnlyDeviceSourcePath, |
116 kReadOnlyDeviceMountPath, | 119 kReadOnlyDeviceMountPath, |
| 120 false, // write_disabled_by_policy |
117 "/device/prefix/system_path_3", | 121 "/device/prefix/system_path_3", |
118 "/device/file_path_3", | 122 "/device/file_path_3", |
119 "/device/device_label_3", | 123 "/device/device_label_3", |
120 "/device/drive_label_3", | 124 "/device/drive_label_3", |
121 "/device/vendor_id_3", | 125 "/device/vendor_id_3", |
122 "/device/vendor_name_3", | 126 "/device/vendor_name_3", |
123 "/device/product_id_3", | 127 "/device/product_id_3", |
124 "/device/product_name_3", | 128 "/device/product_name_3", |
125 "/device/fs_uuid_3", | 129 "/device/fs_uuid_3", |
126 "/device/prefix", | 130 "/device/prefix", |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 const DiskMountManager::MountPointMap& mount_points = | 440 const DiskMountManager::MountPointMap& mount_points = |
437 DiskMountManager::GetInstance()->mount_points(); | 441 DiskMountManager::GetInstance()->mount_points(); |
438 return mount_points.find(mount_path) != mount_points.end(); | 442 return mount_points.find(mount_path) != mount_points.end(); |
439 } | 443 } |
440 | 444 |
441 private: | 445 private: |
442 // Adds a new disk to the disk mount manager. | 446 // Adds a new disk to the disk mount manager. |
443 void AddTestDisk(const TestDiskInfo& disk) { | 447 void AddTestDisk(const TestDiskInfo& disk) { |
444 EXPECT_TRUE(DiskMountManager::GetInstance()->AddDiskForTest( | 448 EXPECT_TRUE(DiskMountManager::GetInstance()->AddDiskForTest( |
445 base::MakeUnique<DiskMountManager::Disk>( | 449 base::MakeUnique<DiskMountManager::Disk>( |
446 disk.source_path, disk.mount_path, disk.system_path, disk.file_path, | 450 disk.source_path, disk.mount_path, disk.write_disabled_by_policy, |
447 disk.device_label, disk.drive_label, disk.vendor_id, | 451 disk.system_path, disk.file_path, disk.device_label, |
448 disk.vendor_name, disk.product_id, disk.product_name, disk.fs_uuid, | 452 disk.drive_label, disk.vendor_id, disk.vendor_name, disk.product_id, |
449 disk.system_path_prefix, disk.device_type, disk.size_in_bytes, | 453 disk.product_name, disk.fs_uuid, disk.system_path_prefix, |
450 disk.is_parent, disk.is_read_only, disk.has_media, | 454 disk.device_type, disk.size_in_bytes, disk.is_parent, |
451 disk.on_boot_device, disk.on_removable_device, disk.is_hidden))); | 455 disk.is_read_only, disk.has_media, disk.on_boot_device, |
| 456 disk.on_removable_device, disk.is_hidden))); |
452 } | 457 } |
453 | 458 |
454 // Adds a new mount point to the disk mount manager. | 459 // Adds a new mount point to the disk mount manager. |
455 // If the moutn point is a device mount point, disk with its source path | 460 // If the moutn point is a device mount point, disk with its source path |
456 // should already be added to the disk mount manager. | 461 // should already be added to the disk mount manager. |
457 void AddTestMountPoint(const TestMountPointInfo& mount_point) { | 462 void AddTestMountPoint(const TestMountPointInfo& mount_point) { |
458 EXPECT_TRUE(DiskMountManager::GetInstance()->AddMountPointForTest( | 463 EXPECT_TRUE(DiskMountManager::GetInstance()->AddMountPointForTest( |
459 DiskMountManager::MountPointInfo(mount_point.source_path, | 464 DiskMountManager::MountPointInfo(mount_point.source_path, |
460 mount_point.mount_path, | 465 mount_point.mount_path, |
461 mount_point.mount_type, | 466 mount_point.mount_type, |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 ASSERT_EQ(1U, observer_->GetEventCount()); | 889 ASSERT_EQ(1U, observer_->GetEventCount()); |
885 VerifyMountEvent(observer_->GetMountEvent(0), DiskMountManager::MOUNTING, | 890 VerifyMountEvent(observer_->GetMountEvent(0), DiskMountManager::MOUNTING, |
886 chromeos::MOUNT_ERROR_NONE, kReadOnlyDeviceMountPath); | 891 chromeos::MOUNT_ERROR_NONE, kReadOnlyDeviceMountPath); |
887 const DiskMountManager::DiskMap& disks = manager->disks(); | 892 const DiskMountManager::DiskMap& disks = manager->disks(); |
888 ASSERT_GT(disks.count(kReadOnlyDeviceSourcePath), 0U); | 893 ASSERT_GT(disks.count(kReadOnlyDeviceSourcePath), 0U); |
889 // 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. |
890 EXPECT_TRUE(disks.find(kReadOnlyDeviceSourcePath)->second->is_read_only()); | 895 EXPECT_TRUE(disks.find(kReadOnlyDeviceSourcePath)->second->is_read_only()); |
891 } | 896 } |
892 | 897 |
893 } // namespace | 898 } // namespace |
OLD | NEW |