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/fake_cros_disks_client.h" | 8 #include "chromeos/dbus/fake_cros_disks_client.h" |
8 #include "chromeos/dbus/fake_dbus_thread_manager.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" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 using chromeos::disks::DiskMountManager; | 13 using chromeos::disks::DiskMountManager; |
14 using chromeos::CrosDisksClient; | 14 using chromeos::CrosDisksClient; |
15 using chromeos::DBusThreadManager; | 15 using chromeos::DBusThreadManager; |
16 using chromeos::FakeCrosDisksClient; | 16 using chromeos::FakeCrosDisksClient; |
17 using chromeos::FakeDBusThreadManager; | |
18 using testing::_; | 17 using testing::_; |
19 using testing::Field; | 18 using testing::Field; |
20 using testing::InSequence; | 19 using testing::InSequence; |
21 | 20 |
22 namespace { | 21 namespace { |
23 | 22 |
24 // Holds information needed to create a DiskMountManager::Disk instance. | 23 // Holds information needed to create a DiskMountManager::Disk instance. |
25 struct TestDiskInfo { | 24 struct TestDiskInfo { |
26 const char* source_path; | 25 const char* source_path; |
27 const char* mount_path; | 26 const char* mount_path; |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 115 |
117 class DiskMountManagerTest : public testing::Test { | 116 class DiskMountManagerTest : public testing::Test { |
118 public: | 117 public: |
119 DiskMountManagerTest() {} | 118 DiskMountManagerTest() {} |
120 virtual ~DiskMountManagerTest() {} | 119 virtual ~DiskMountManagerTest() {} |
121 | 120 |
122 // Sets up test dbus tread manager and disks mount manager. | 121 // Sets up test dbus tread manager and disks mount manager. |
123 // Initializes disk mount manager disks and mount points. | 122 // Initializes disk mount manager disks and mount points. |
124 // Adds a test observer to the disk mount manager. | 123 // Adds a test observer to the disk mount manager. |
125 virtual void SetUp() { | 124 virtual void SetUp() { |
126 FakeDBusThreadManager* fake_thread_manager = new FakeDBusThreadManager(); | |
127 fake_cros_disks_client_ = new FakeCrosDisksClient; | 125 fake_cros_disks_client_ = new FakeCrosDisksClient; |
128 fake_thread_manager->SetCrosDisksClient( | 126 DBusThreadManager::GetDBusThreadManagerTestHelper()->SetCrosDisksClient( |
129 scoped_ptr<CrosDisksClient>(fake_cros_disks_client_)); | 127 scoped_ptr<CrosDisksClient>(fake_cros_disks_client_)); |
130 | 128 |
131 DBusThreadManager::InitializeForTesting(fake_thread_manager); | |
132 | |
133 DiskMountManager::Initialize(); | 129 DiskMountManager::Initialize(); |
134 | 130 |
135 InitDisksAndMountPoints(); | 131 InitDisksAndMountPoints(); |
136 | 132 |
137 DiskMountManager::GetInstance()->AddObserver(&observer_); | 133 DiskMountManager::GetInstance()->AddObserver(&observer_); |
138 } | 134 } |
139 | 135 |
140 // 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. |
141 virtual void TearDown() { | 137 virtual void TearDown() { |
142 DiskMountManager::GetInstance()->RemoveObserver(&observer_); | 138 DiskMountManager::GetInstance()->RemoveObserver(&observer_); |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 EXPECT_EQ("/device/source_path", | 569 EXPECT_EQ("/device/source_path", |
574 fake_cros_disks_client_->last_format_device_path()); | 570 fake_cros_disks_client_->last_format_device_path()); |
575 EXPECT_EQ("vfat", fake_cros_disks_client_->last_format_filesystem()); | 571 EXPECT_EQ("vfat", fake_cros_disks_client_->last_format_filesystem()); |
576 | 572 |
577 // Simulate cros_disks reporting success. | 573 // Simulate cros_disks reporting success. |
578 fake_cros_disks_client_->SendFormatCompletedEvent( | 574 fake_cros_disks_client_->SendFormatCompletedEvent( |
579 chromeos::FORMAT_ERROR_NONE, "/device/source_path"); | 575 chromeos::FORMAT_ERROR_NONE, "/device/source_path"); |
580 } | 576 } |
581 | 577 |
582 } // namespace | 578 } // namespace |
OLD | NEW |