| 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 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 chromeos::MOUNT_ERROR_NONE, kSourcePath2, chromeos::MOUNT_TYPE_DEVICE, | 696 chromeos::MOUNT_ERROR_NONE, kSourcePath2, chromeos::MOUNT_TYPE_DEVICE, |
| 697 kMountPath2); | 697 kMountPath2); |
| 698 | 698 |
| 699 const DiskMountManager::DiskMap& disks = manager->disks(); | 699 const DiskMountManager::DiskMap& disks = manager->disks(); |
| 700 ASSERT_GT(disks.count(kSourcePath1), 0U); | 700 ASSERT_GT(disks.count(kSourcePath1), 0U); |
| 701 EXPECT_FALSE(disks.find(kSourcePath1)->second->is_read_only()); | 701 EXPECT_FALSE(disks.find(kSourcePath1)->second->is_read_only()); |
| 702 ASSERT_GT(disks.count(kSourcePath2), 0U); | 702 ASSERT_GT(disks.count(kSourcePath2), 0U); |
| 703 EXPECT_TRUE(disks.find(kSourcePath2)->second->is_read_only()); | 703 EXPECT_TRUE(disks.find(kSourcePath2)->second->is_read_only()); |
| 704 } | 704 } |
| 705 | 705 |
| 706 TEST_F(DiskMountManagerTest, MountPath_ReadOnlyDevice) { |
| 707 DiskMountManager* manager = DiskMountManager::GetInstance(); |
| 708 const std::string kSourceFormat = std::string(); |
| 709 const std::string kMountLabel = std::string(); // N/A for MOUNT_TYPE_DEVICE |
| 710 |
| 711 // Event handlers of observers should be called. |
| 712 EXPECT_CALL( |
| 713 observer_, |
| 714 OnMountEvent(DiskMountManager::MOUNTING, chromeos::MOUNT_ERROR_NONE, |
| 715 Field(&DiskMountManager::MountPointInfo::mount_path, |
| 716 kReadOnlyMountpath))); |
| 717 |
| 718 // Attempt to mount a read-only device in read-write mode. |
| 719 manager->MountPath(kReadOnlyDeviceSource, kSourceFormat, std::string(), |
| 720 chromeos::MOUNT_TYPE_DEVICE, |
| 721 chromeos::MOUNT_ACCESS_MODE_READ_WRITE); |
| 722 // Simulate cros_disks reporting mount completed. |
| 723 fake_cros_disks_client_->SendMountCompletedEvent( |
| 724 chromeos::MOUNT_ERROR_NONE, kReadOnlyDeviceSource, |
| 725 chromeos::MOUNT_TYPE_DEVICE, kReadOnlyMountpath); |
| 726 |
| 727 const DiskMountManager::DiskMap& disks = manager->disks(); |
| 728 ASSERT_GT(disks.count(kReadOnlyDeviceSource), 0U); |
| 729 // The mounted disk should preserve the read-only flag of the block device. |
| 730 EXPECT_TRUE(disks.find(kReadOnlyDeviceSource)->second->is_read_only()); |
| 731 } |
| 732 |
| 706 } // namespace | 733 } // namespace |
| OLD | NEW |