OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "chromeos/components/tether/initializer.h" | 5 #include "chromeos/components/tether/initializer.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
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" |
11 #include "base/test/scoped_task_environment.h" | 11 #include "base/test/scoped_task_environment.h" |
12 #include "chromeos/components/tether/active_host.h" | 12 #include "chromeos/components/tether/active_host.h" |
13 #include "chromeos/components/tether/fake_notification_presenter.h" | 13 #include "chromeos/components/tether/fake_notification_presenter.h" |
14 #include "chromeos/components/tether/host_scan_device_prioritizer.h" | 14 #include "chromeos/components/tether/host_scan_device_prioritizer.h" |
15 #include "chromeos/dbus/dbus_thread_manager.h" | 15 #include "chromeos/dbus/dbus_thread_manager.h" |
| 16 #include "chromeos/network/managed_network_configuration_handler.h" |
| 17 #include "chromeos/network/mock_managed_network_configuration_handler.h" |
16 #include "chromeos/network/network_connect.h" | 18 #include "chromeos/network/network_connect.h" |
17 #include "chromeos/network/network_handler.h" | 19 #include "chromeos/network/network_handler.h" |
18 #include "chromeos/network/network_state_test.h" | 20 #include "chromeos/network/network_state_test.h" |
19 #include "components/cryptauth/cryptauth_device_manager.h" | 21 #include "components/cryptauth/cryptauth_device_manager.h" |
20 #include "components/cryptauth/cryptauth_enroller.h" | 22 #include "components/cryptauth/cryptauth_enroller.h" |
21 #include "components/cryptauth/cryptauth_enrollment_manager.h" | 23 #include "components/cryptauth/cryptauth_enrollment_manager.h" |
22 #include "components/cryptauth/fake_cryptauth_gcm_manager.h" | 24 #include "components/cryptauth/fake_cryptauth_gcm_manager.h" |
23 #include "components/cryptauth/fake_cryptauth_service.h" | 25 #include "components/cryptauth/fake_cryptauth_service.h" |
24 #include "components/cryptauth/proto/cryptauth_api.pb.h" | 26 #include "components/cryptauth/proto/cryptauth_api.pb.h" |
25 #include "components/cryptauth/secure_message_delegate.h" | 27 #include "components/cryptauth/secure_message_delegate.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 NetworkStateTest::TearDown(); | 106 NetworkStateTest::TearDown(); |
105 DBusThreadManager::Shutdown(); | 107 DBusThreadManager::Shutdown(); |
106 } | 108 } |
107 | 109 |
108 void InitializeAndDestroy( | 110 void InitializeAndDestroy( |
109 cryptauth::CryptAuthService* cryptauth_service, | 111 cryptauth::CryptAuthService* cryptauth_service, |
110 std::unique_ptr<NotificationPresenter> notification_presenter, | 112 std::unique_ptr<NotificationPresenter> notification_presenter, |
111 PrefService* pref_service, | 113 PrefService* pref_service, |
112 ProfileOAuth2TokenService* token_service, | 114 ProfileOAuth2TokenService* token_service, |
113 NetworkStateHandler* network_state_handler, | 115 NetworkStateHandler* network_state_handler, |
| 116 ManagedNetworkConfigurationHandler* managed_network_configuration_handler, |
114 NetworkConnect* network_connect, | 117 NetworkConnect* network_connect, |
115 scoped_refptr<device::BluetoothAdapter> adapter) { | 118 scoped_refptr<device::BluetoothAdapter> adapter) { |
116 Initializer* initializer = new Initializer( | 119 Initializer* initializer = |
117 cryptauth_service, std::move(notification_presenter), pref_service, | 120 new Initializer(cryptauth_service, std::move(notification_presenter), |
118 token_service, network_state_handler, network_connect); | 121 pref_service, token_service, network_state_handler, |
| 122 managed_network_configuration_handler, network_connect); |
119 initializer->OnBluetoothAdapterAdvertisingIntervalSet(adapter); | 123 initializer->OnBluetoothAdapterAdvertisingIntervalSet(adapter); |
120 delete initializer; | 124 delete initializer; |
121 } | 125 } |
122 | 126 |
123 base::test::ScopedTaskEnvironment scoped_task_environment_; | 127 base::test::ScopedTaskEnvironment scoped_task_environment_; |
124 | 128 |
125 std::unique_ptr<TestingPrefServiceSimple> test_pref_service_; | 129 std::unique_ptr<TestingPrefServiceSimple> test_pref_service_; |
126 | 130 |
127 private: | 131 private: |
128 DISALLOW_COPY_AND_ASSIGN(InitializerTest); | 132 DISALLOW_COPY_AND_ASSIGN(InitializerTest); |
(...skipping 22 matching lines...) Expand all Loading... |
151 mock_device_manager.get()); | 155 mock_device_manager.get()); |
152 fake_cryptauth_service->set_cryptauth_enrollment_manager( | 156 fake_cryptauth_service->set_cryptauth_enrollment_manager( |
153 mock_enrollment_manager.get()); | 157 mock_enrollment_manager.get()); |
154 | 158 |
155 std::unique_ptr<TestingPrefServiceSimple> test_pref_service = | 159 std::unique_ptr<TestingPrefServiceSimple> test_pref_service = |
156 base::MakeUnique<TestingPrefServiceSimple>(); | 160 base::MakeUnique<TestingPrefServiceSimple>(); |
157 | 161 |
158 std::unique_ptr<FakeProfileOAuth2TokenService> fake_token_service = | 162 std::unique_ptr<FakeProfileOAuth2TokenService> fake_token_service = |
159 base::MakeUnique<FakeProfileOAuth2TokenService>(); | 163 base::MakeUnique<FakeProfileOAuth2TokenService>(); |
160 | 164 |
| 165 std::unique_ptr<ManagedNetworkConfigurationHandler> |
| 166 managed_network_configuration_handler = base::WrapUnique( |
| 167 new NiceMock<MockManagedNetworkConfigurationHandler>); |
| 168 |
161 std::unique_ptr<MockNetworkConnect> mock_network_connect = | 169 std::unique_ptr<MockNetworkConnect> mock_network_connect = |
162 base::WrapUnique(new NiceMock<MockNetworkConnect>); | 170 base::WrapUnique(new NiceMock<MockNetworkConnect>); |
163 | 171 |
164 scoped_refptr<NiceMock<device::MockBluetoothAdapter>> mock_adapter = | 172 scoped_refptr<NiceMock<device::MockBluetoothAdapter>> mock_adapter = |
165 make_scoped_refptr(new NiceMock<device::MockBluetoothAdapter>()); | 173 make_scoped_refptr(new NiceMock<device::MockBluetoothAdapter>()); |
166 | 174 |
167 // Call an instance method of the test instead of initializing and destroying | 175 // Call an instance method of the test instead of initializing and destroying |
168 // here because the friend relationship between Initializer and | 176 // here because the friend relationship between Initializer and |
169 // InitializerTest only applies to the class itself, not these test functions. | 177 // InitializerTest only applies to the class itself, not these test functions. |
170 InitializeAndDestroy(fake_cryptauth_service.get(), | 178 InitializeAndDestroy(fake_cryptauth_service.get(), |
171 base::MakeUnique<FakeNotificationPresenter>(), | 179 base::MakeUnique<FakeNotificationPresenter>(), |
172 test_pref_service_.get(), fake_token_service.get(), | 180 test_pref_service_.get(), fake_token_service.get(), |
173 network_state_handler(), mock_network_connect.get(), | 181 network_state_handler(), |
174 mock_adapter); | 182 managed_network_configuration_handler.get(), |
| 183 mock_network_connect.get(), mock_adapter); |
175 } | 184 } |
176 | 185 |
177 } // namespace tether | 186 } // namespace tether |
178 | 187 |
179 } // namespace chromeos | 188 } // namespace chromeos |
OLD | NEW |