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

Side by Side Diff: chromeos/disks/disk_mount_manager_unittest.cc

Issue 2311863002: Fix a bug where read-only volumes were recognized as read-write. (Closed)
Patch Set: Revise comment. Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « chromeos/disks/disk_mount_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« 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