OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/network/auto_connect_handler.h" | 5 #include "chromeos/network/auto_connect_handler.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
11 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/message_loop/message_loop.h" | |
14 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
15 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
16 #include "base/test/scoped_task_scheduler.h" | 15 #include "base/test/scoped_task_environment.h" |
16 #include "base/threading/thread_task_runner_handle.h" | |
17 #include "chromeos/cert_loader.h" | 17 #include "chromeos/cert_loader.h" |
18 #include "chromeos/dbus/dbus_thread_manager.h" | 18 #include "chromeos/dbus/dbus_thread_manager.h" |
19 #include "chromeos/network/client_cert_resolver.h" | 19 #include "chromeos/network/client_cert_resolver.h" |
20 #include "chromeos/network/managed_network_configuration_handler_impl.h" | 20 #include "chromeos/network/managed_network_configuration_handler_impl.h" |
21 #include "chromeos/network/network_configuration_handler.h" | 21 #include "chromeos/network/network_configuration_handler.h" |
22 #include "chromeos/network/network_profile_handler.h" | 22 #include "chromeos/network/network_profile_handler.h" |
23 #include "chromeos/network/network_state_test.h" | 23 #include "chromeos/network/network_state_test.h" |
24 #include "components/onc/onc_constants.h" | 24 #include "components/onc/onc_constants.h" |
25 #include "crypto/scoped_nss_types.h" | 25 #include "crypto/scoped_nss_types.h" |
26 #include "crypto/scoped_test_nss_db.h" | 26 #include "crypto/scoped_test_nss_db.h" |
(...skipping 24 matching lines...) Expand all Loading... | |
51 | 51 |
52 private: | 52 private: |
53 bool changed_network_properties_; | 53 bool changed_network_properties_; |
54 ClientCertResolver* cert_resolver_; | 54 ClientCertResolver* cert_resolver_; |
55 }; | 55 }; |
56 | 56 |
57 } // namespace | 57 } // namespace |
58 | 58 |
59 class AutoConnectHandlerTest : public NetworkStateTest { | 59 class AutoConnectHandlerTest : public NetworkStateTest { |
60 public: | 60 public: |
61 AutoConnectHandlerTest() : scoped_task_scheduler_(&message_loop_) {} | 61 AutoConnectHandlerTest() = default; |
62 | 62 |
63 void SetUp() override { | 63 void SetUp() override { |
64 ASSERT_TRUE(test_nssdb_.is_open()); | 64 ASSERT_TRUE(test_nssdb_.is_open()); |
65 | 65 |
66 // Use the same DB for public and private slot. | 66 // Use the same DB for public and private slot. |
67 test_nsscertdb_.reset(new net::NSSCertDatabaseChromeOS( | 67 test_nsscertdb_.reset(new net::NSSCertDatabaseChromeOS( |
68 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())), | 68 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())), |
69 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())))); | 69 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())))); |
70 test_nsscertdb_->SetSlowTaskRunnerForTest(message_loop_.task_runner()); | 70 test_nsscertdb_->SetSlowTaskRunnerForTest( |
71 base::ThreadTaskRunnerHandle::Get()); | |
71 | 72 |
72 CertLoader::Initialize(); | 73 CertLoader::Initialize(); |
73 CertLoader::ForceHardwareBackedForTesting(); | 74 CertLoader::ForceHardwareBackedForTesting(); |
74 | 75 |
75 DBusThreadManager::Initialize(); | 76 DBusThreadManager::Initialize(); |
76 | 77 |
77 NetworkStateTest::SetUp(); | 78 NetworkStateTest::SetUp(); |
78 | 79 |
79 LoginState::Initialize(); | 80 LoginState::Initialize(); |
80 | 81 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 } | 191 } |
191 | 192 |
192 std::unique_ptr<AutoConnectHandler> auto_connect_handler_; | 193 std::unique_ptr<AutoConnectHandler> auto_connect_handler_; |
193 std::unique_ptr<ClientCertResolver> client_cert_resolver_; | 194 std::unique_ptr<ClientCertResolver> client_cert_resolver_; |
194 std::unique_ptr<NetworkConfigurationHandler> network_config_handler_; | 195 std::unique_ptr<NetworkConfigurationHandler> network_config_handler_; |
195 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl> | 196 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl> |
196 managed_config_handler_; | 197 managed_config_handler_; |
197 std::unique_ptr<NetworkProfileHandler> network_profile_handler_; | 198 std::unique_ptr<NetworkProfileHandler> network_profile_handler_; |
198 crypto::ScopedTestNSSDB test_nssdb_; | 199 crypto::ScopedTestNSSDB test_nssdb_; |
199 std::unique_ptr<net::NSSCertDatabaseChromeOS> test_nsscertdb_; | 200 std::unique_ptr<net::NSSCertDatabaseChromeOS> test_nsscertdb_; |
200 base::MessageLoopForUI message_loop_; | |
gab
2017/05/01 19:05:03
ForUI?
fdoray
2017/05/03 17:38:14
Done.
| |
201 | 201 |
202 private: | 202 private: |
203 base::test::ScopedTaskScheduler scoped_task_scheduler_; | 203 base::test::ScopedTaskEnvironment scoped_task_environment_; |
204 | 204 |
205 DISALLOW_COPY_AND_ASSIGN(AutoConnectHandlerTest); | 205 DISALLOW_COPY_AND_ASSIGN(AutoConnectHandlerTest); |
206 }; | 206 }; |
207 | 207 |
208 namespace { | 208 namespace { |
209 | 209 |
210 const char* kConfigUnmanagedSharedConnected = | 210 const char* kConfigUnmanagedSharedConnected = |
211 "{ \"GUID\": \"wifi0\", \"Type\": \"wifi\", \"State\": \"online\", " | 211 "{ \"GUID\": \"wifi0\", \"Type\": \"wifi\", \"State\": \"online\", " |
212 " \"Security\": \"wpa\" }"; | 212 " \"Security\": \"wpa\" }"; |
213 const char* kConfigManagedSharedConnectable = | 213 const char* kConfigManagedSharedConnectable = |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
452 // Applying the user policy after login would usually trigger connecting to | 452 // Applying the user policy after login would usually trigger connecting to |
453 // the 'best' network. But the manual connect prevents this. | 453 // the 'best' network. But the manual connect prevents this. |
454 SetupPolicy(std::string(), // no network configs | 454 SetupPolicy(std::string(), // no network configs |
455 base::DictionaryValue(), // no global config | 455 base::DictionaryValue(), // no global config |
456 true); // load as user policy | 456 true); // load as user policy |
457 EXPECT_EQ(shill::kStateOnline, GetServiceState("wifi0")); | 457 EXPECT_EQ(shill::kStateOnline, GetServiceState("wifi0")); |
458 EXPECT_EQ(shill::kStateIdle, GetServiceState("wifi1")); | 458 EXPECT_EQ(shill::kStateIdle, GetServiceState("wifi1")); |
459 } | 459 } |
460 | 460 |
461 } // namespace chromeos | 461 } // namespace chromeos |
OLD | NEW |