| 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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 // Pointer to the manager object to which this |Observer| is registered. | 385 // Pointer to the manager object to which this |Observer| is registered. |
| 386 const DiskMountManager* manager_; | 386 const DiskMountManager* manager_; |
| 387 | 387 |
| 388 // Records all invocations. | 388 // Records all invocations. |
| 389 std::vector<std::unique_ptr<ObserverEvent>> events_; | 389 std::vector<std::unique_ptr<ObserverEvent>> events_; |
| 390 }; | 390 }; |
| 391 | 391 |
| 392 // Shift operators of ostream. | 392 // Shift operators of ostream. |
| 393 // Needed to print values in case of EXPECT_* failure in gtest. | 393 // Needed to print values in case of EXPECT_* failure in gtest. |
| 394 std::ostream& operator<<(std::ostream& stream, | 394 std::ostream& operator<<(std::ostream& stream, |
| 395 const DeviceEvent& device_event) { | |
| 396 return stream << device_event.DebugString(); | |
| 397 } | |
| 398 | |
| 399 std::ostream& operator<<(std::ostream& stream, const DiskEvent& disk_event) { | |
| 400 return stream << disk_event.DebugString(); | |
| 401 } | |
| 402 | |
| 403 std::ostream& operator<<(std::ostream& stream, | |
| 404 const FormatEvent& format_event) { | 395 const FormatEvent& format_event) { |
| 405 return stream << format_event.DebugString(); | 396 return stream << format_event.DebugString(); |
| 406 } | 397 } |
| 407 | 398 |
| 408 std::ostream& operator<<(std::ostream& stream, const MountEvent& mount_event) { | |
| 409 return stream << mount_event.DebugString(); | |
| 410 } | |
| 411 | |
| 412 class DiskMountManagerTest : public testing::Test { | 399 class DiskMountManagerTest : public testing::Test { |
| 413 public: | 400 public: |
| 414 DiskMountManagerTest() {} | 401 DiskMountManagerTest() {} |
| 415 ~DiskMountManagerTest() override {} | 402 ~DiskMountManagerTest() override {} |
| 416 | 403 |
| 417 // Sets up test dbus tread manager and disks mount manager. | 404 // Sets up test dbus tread manager and disks mount manager. |
| 418 // Initializes disk mount manager disks and mount points. | 405 // Initializes disk mount manager disks and mount points. |
| 419 // Adds a test observer to the disk mount manager. | 406 // Adds a test observer to the disk mount manager. |
| 420 void SetUp() override { | 407 void SetUp() override { |
| 421 fake_cros_disks_client_ = new FakeCrosDisksClient; | 408 fake_cros_disks_client_ = new FakeCrosDisksClient; |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 907 ASSERT_EQ(1U, observer_->GetEventCount()); | 894 ASSERT_EQ(1U, observer_->GetEventCount()); |
| 908 VerifyMountEvent(observer_->GetMountEvent(0), DiskMountManager::MOUNTING, | 895 VerifyMountEvent(observer_->GetMountEvent(0), DiskMountManager::MOUNTING, |
| 909 chromeos::MOUNT_ERROR_NONE, kReadOnlyMountpath); | 896 chromeos::MOUNT_ERROR_NONE, kReadOnlyMountpath); |
| 910 const DiskMountManager::DiskMap& disks = manager->disks(); | 897 const DiskMountManager::DiskMap& disks = manager->disks(); |
| 911 ASSERT_GT(disks.count(kReadOnlyDeviceSource), 0U); | 898 ASSERT_GT(disks.count(kReadOnlyDeviceSource), 0U); |
| 912 // The mounted disk should preserve the read-only flag of the block device. | 899 // The mounted disk should preserve the read-only flag of the block device. |
| 913 EXPECT_TRUE(disks.find(kReadOnlyDeviceSource)->second->is_read_only()); | 900 EXPECT_TRUE(disks.find(kReadOnlyDeviceSource)->second->is_read_only()); |
| 914 } | 901 } |
| 915 | 902 |
| 916 } // namespace | 903 } // namespace |
| OLD | NEW |