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/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "chromeos/dbus/dbus_thread_manager.h" | 10 #include "chromeos/dbus/dbus_thread_manager.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 // Holds information to create a DiskMOuntManager::MountPointInfo instance. | 53 // Holds information to create a DiskMOuntManager::MountPointInfo instance. |
54 struct TestMountPointInfo { | 54 struct TestMountPointInfo { |
55 const char* source_path; | 55 const char* source_path; |
56 const char* mount_path; | 56 const char* mount_path; |
57 chromeos::MountType mount_type; | 57 chromeos::MountType mount_type; |
58 chromeos::disks::MountCondition mount_condition; | 58 chromeos::disks::MountCondition mount_condition; |
59 }; | 59 }; |
60 | 60 |
61 // List of disks held in DiskMountManager at the begining of the test. | 61 // List of disks held in DiskMountManager at the begining of the test. |
62 const TestDiskInfo kTestDisks[] = { | 62 const TestDiskInfo kTestDisks[] = { |
63 { | 63 { |
64 "/device/source_path", | 64 "/device/source_path", |
65 "/device/mount_path", | 65 "/device/mount_path", |
66 "/device/prefix/system_path", | 66 "/device/prefix/system_path", |
67 "/device/file_path", | 67 "/device/file_path", |
68 "/device/device_label", | 68 "/device/device_label", |
69 "/device/drive_label", | 69 "/device/drive_label", |
70 "/device/vendor_id", | 70 "/device/vendor_id", |
71 "/device/vendor_name", | 71 "/device/vendor_name", |
72 "/device/product_id", | 72 "/device/product_id", |
73 "/device/product_name", | 73 "/device/product_name", |
74 "/device/fs_uuid", | 74 "/device/fs_uuid", |
75 "/device/prefix", | 75 "/device/prefix", |
76 chromeos::DEVICE_TYPE_USB, | 76 chromeos::DEVICE_TYPE_USB, |
77 1073741824, // size in bytes | 77 1073741824, // size in bytes |
78 false, // is parent | 78 false, // is parent |
79 false, // is read only | 79 false, // is read only |
80 true, // has media | 80 true, // has media |
81 false, // is on boot device | 81 false, // is on boot device |
82 true, // is on removable device | 82 true, // is on removable device |
83 false // is hidden | 83 false // is hidden |
84 }, | 84 }, |
85 { | 85 { |
86 kReadOnlyDeviceSource, | 86 "/device/source_path2", |
87 kReadOnlyMountpath, | 87 "/device/mount_path2", |
88 "/device/prefix/system_path_2", | 88 "/device/prefix/system_path2", |
89 "/device/file_path_2", | 89 "/device/file_path2", |
90 "/device/device_label_2", | 90 "/device/device_label2", |
91 "/device/drive_label_2", | 91 "/device/drive_label2", |
92 "/device/vendor_id_2", | 92 "/device/vendor_id2", |
93 "/device/vendor_name_2", | 93 "/device/vendor_name2", |
94 "/device/product_id_2", | 94 "/device/product_id2", |
95 "/device/product_name_2", | 95 "/device/product_name2", |
96 "/device/fs_uuid_2", | 96 "/device/fs_uuid2", |
97 "/device/prefix", | 97 "/device/prefix2", |
98 chromeos::DEVICE_TYPE_USB, | 98 chromeos::DEVICE_TYPE_SD, |
99 1073741824, // size in bytes | 99 1073741824, // size in bytes |
100 false, // is parent | 100 false, // is parent |
101 true, // is read only | 101 false, // is read only |
102 true, // has media | 102 true, // has media |
103 false, // is on boot device | 103 false, // is on boot device |
104 true, // is on removable device | 104 true, // is on removable device |
105 false // is hidden | 105 false // is hidden |
106 }, | 106 }, |
| 107 { |
| 108 kReadOnlyDeviceSource, |
| 109 kReadOnlyMountpath, |
| 110 "/device/prefix/system_path_3", |
| 111 "/device/file_path_3", |
| 112 "/device/device_label_3", |
| 113 "/device/drive_label_3", |
| 114 "/device/vendor_id_3", |
| 115 "/device/vendor_name_3", |
| 116 "/device/product_id_3", |
| 117 "/device/product_name_3", |
| 118 "/device/fs_uuid_3", |
| 119 "/device/prefix", |
| 120 chromeos::DEVICE_TYPE_USB, |
| 121 1073741824, // size in bytes |
| 122 false, // is parent |
| 123 true, // is read only |
| 124 true, // has media |
| 125 false, // is on boot device |
| 126 true, // is on removable device |
| 127 false // is hidden |
| 128 }, |
107 }; | 129 }; |
108 | 130 |
109 // List of mount points held in DiskMountManager at the begining of the test. | 131 // List of mount points held in DiskMountManager at the begining of the test. |
110 const TestMountPointInfo kTestMountPoints[] = { | 132 const TestMountPointInfo kTestMountPoints[] = { |
111 { | 133 { |
112 "/archive/source_path", | 134 "/archive/source_path", |
113 "/archive/mount_path", | 135 "/archive/mount_path", |
114 chromeos::MOUNT_TYPE_ARCHIVE, | 136 chromeos::MOUNT_TYPE_ARCHIVE, |
115 chromeos::disks::MOUNT_CONDITION_NONE | 137 chromeos::disks::MOUNT_CONDITION_NONE |
116 }, | 138 }, |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
613 EXPECT_EQ(2, fake_cros_disks_client_->format_call_count()); | 635 EXPECT_EQ(2, fake_cros_disks_client_->format_call_count()); |
614 EXPECT_EQ("/device/source_path", | 636 EXPECT_EQ("/device/source_path", |
615 fake_cros_disks_client_->last_format_device_path()); | 637 fake_cros_disks_client_->last_format_device_path()); |
616 EXPECT_EQ("vfat", fake_cros_disks_client_->last_format_filesystem()); | 638 EXPECT_EQ("vfat", fake_cros_disks_client_->last_format_filesystem()); |
617 | 639 |
618 // Simulate cros_disks reporting success. | 640 // Simulate cros_disks reporting success. |
619 fake_cros_disks_client_->SendFormatCompletedEvent( | 641 fake_cros_disks_client_->SendFormatCompletedEvent( |
620 chromeos::FORMAT_ERROR_NONE, "/device/source_path"); | 642 chromeos::FORMAT_ERROR_NONE, "/device/source_path"); |
621 } | 643 } |
622 | 644 |
| 645 TEST_F(DiskMountManagerTest, MountPath_RecordAccessMode) { |
| 646 DiskMountManager* manager = DiskMountManager::GetInstance(); |
| 647 const std::string kSourcePath1 = "/device/source_path"; |
| 648 const std::string kSourcePath2 = "/device/source_path2"; |
| 649 const std::string kSourceFormat = std::string(); |
| 650 const std::string kMountLabel = std::string(); // N/A for MOUNT_TYPE_DEVICE |
| 651 // For MountCompleted. Must be non-empty strings. |
| 652 const std::string kMountPath1 = "/media/foo"; |
| 653 const std::string kMountPath2 = "/media/bar"; |
| 654 |
| 655 manager->MountPath(kSourcePath1, kSourceFormat, std::string(), |
| 656 chromeos::MOUNT_TYPE_DEVICE, |
| 657 chromeos::MOUNT_ACCESS_MODE_READ_WRITE); |
| 658 manager->MountPath(kSourcePath2, kSourceFormat, std::string(), |
| 659 chromeos::MOUNT_TYPE_DEVICE, |
| 660 chromeos::MOUNT_ACCESS_MODE_READ_ONLY); |
| 661 // Simulate cros_disks reporting mount completed. |
| 662 fake_cros_disks_client_->SendMountCompletedEvent( |
| 663 chromeos::MOUNT_ERROR_NONE, kSourcePath1, chromeos::MOUNT_TYPE_DEVICE, |
| 664 kMountPath1); |
| 665 fake_cros_disks_client_->SendMountCompletedEvent( |
| 666 chromeos::MOUNT_ERROR_NONE, kSourcePath2, chromeos::MOUNT_TYPE_DEVICE, |
| 667 kMountPath2); |
| 668 |
| 669 const DiskMountManager::DiskMap& disks = manager->disks(); |
| 670 ASSERT_GT(disks.count(kSourcePath1), 0U); |
| 671 EXPECT_FALSE(disks.find(kSourcePath1)->second->is_read_only()); |
| 672 ASSERT_GT(disks.count(kSourcePath2), 0U); |
| 673 EXPECT_TRUE(disks.find(kSourcePath2)->second->is_read_only()); |
| 674 } |
| 675 |
623 } // namespace | 676 } // namespace |
OLD | NEW |