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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "chromeos/dbus/dbus_thread_manager.h" | 7 #include "chromeos/dbus/dbus_thread_manager.h" |
8 #include "chromeos/dbus/fake_cros_disks_client.h" | 8 #include "chromeos/dbus/fake_cros_disks_client.h" |
9 #include "chromeos/disks/disk_mount_manager.h" | 9 #include "chromeos/disks/disk_mount_manager.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 const DiskMountManager::MountPointInfo& mount_point)); | 109 const DiskMountManager::MountPointInfo& mount_point)); |
110 MOCK_METHOD3(OnFormatEvent, | 110 MOCK_METHOD3(OnFormatEvent, |
111 void(DiskMountManager::FormatEvent event, | 111 void(DiskMountManager::FormatEvent event, |
112 chromeos::FormatError error_code, | 112 chromeos::FormatError error_code, |
113 const std::string& device_path)); | 113 const std::string& device_path)); |
114 }; | 114 }; |
115 | 115 |
116 class DiskMountManagerTest : public testing::Test { | 116 class DiskMountManagerTest : public testing::Test { |
117 public: | 117 public: |
118 DiskMountManagerTest() {} | 118 DiskMountManagerTest() {} |
119 virtual ~DiskMountManagerTest() {} | 119 ~DiskMountManagerTest() override {} |
120 | 120 |
121 // Sets up test dbus tread manager and disks mount manager. | 121 // Sets up test dbus tread manager and disks mount manager. |
122 // Initializes disk mount manager disks and mount points. | 122 // Initializes disk mount manager disks and mount points. |
123 // Adds a test observer to the disk mount manager. | 123 // Adds a test observer to the disk mount manager. |
124 virtual void SetUp() { | 124 void SetUp() override { |
125 fake_cros_disks_client_ = new FakeCrosDisksClient; | 125 fake_cros_disks_client_ = new FakeCrosDisksClient; |
126 DBusThreadManager::GetSetterForTesting()->SetCrosDisksClient( | 126 DBusThreadManager::GetSetterForTesting()->SetCrosDisksClient( |
127 scoped_ptr<CrosDisksClient>(fake_cros_disks_client_)); | 127 scoped_ptr<CrosDisksClient>(fake_cros_disks_client_)); |
128 | 128 |
129 DiskMountManager::Initialize(); | 129 DiskMountManager::Initialize(); |
130 | 130 |
131 InitDisksAndMountPoints(); | 131 InitDisksAndMountPoints(); |
132 | 132 |
133 DiskMountManager::GetInstance()->AddObserver(&observer_); | 133 DiskMountManager::GetInstance()->AddObserver(&observer_); |
134 } | 134 } |
135 | 135 |
136 // Shuts down dbus thread manager and disk moutn manager used in the test. | 136 // Shuts down dbus thread manager and disk moutn manager used in the test. |
137 virtual void TearDown() { | 137 void TearDown() override { |
138 DiskMountManager::GetInstance()->RemoveObserver(&observer_); | 138 DiskMountManager::GetInstance()->RemoveObserver(&observer_); |
139 DiskMountManager::Shutdown(); | 139 DiskMountManager::Shutdown(); |
140 DBusThreadManager::Shutdown(); | 140 DBusThreadManager::Shutdown(); |
141 } | 141 } |
142 | 142 |
143 protected: | 143 protected: |
144 // Checks if disk mount manager contains a mount point with specified moutn | 144 // Checks if disk mount manager contains a mount point with specified moutn |
145 // path. | 145 // path. |
146 bool HasMountPoint(const std::string& mount_path) { | 146 bool HasMountPoint(const std::string& mount_path) { |
147 const DiskMountManager::MountPointMap& mount_points = | 147 const DiskMountManager::MountPointMap& mount_points = |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 EXPECT_EQ("/device/source_path", | 569 EXPECT_EQ("/device/source_path", |
570 fake_cros_disks_client_->last_format_device_path()); | 570 fake_cros_disks_client_->last_format_device_path()); |
571 EXPECT_EQ("vfat", fake_cros_disks_client_->last_format_filesystem()); | 571 EXPECT_EQ("vfat", fake_cros_disks_client_->last_format_filesystem()); |
572 | 572 |
573 // Simulate cros_disks reporting success. | 573 // Simulate cros_disks reporting success. |
574 fake_cros_disks_client_->SendFormatCompletedEvent( | 574 fake_cros_disks_client_->SendFormatCompletedEvent( |
575 chromeos::FORMAT_ERROR_NONE, "/device/source_path"); | 575 chromeos::FORMAT_ERROR_NONE, "/device/source_path"); |
576 } | 576 } |
577 | 577 |
578 } // namespace | 578 } // namespace |
OLD | NEW |