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() |
| 62 : scoped_task_environment_( |
| 63 base::test::ScopedTaskEnvironment::MainThreadType::UI) {} |
62 | 64 |
63 void SetUp() override { | 65 void SetUp() override { |
64 ASSERT_TRUE(test_nssdb_.is_open()); | 66 ASSERT_TRUE(test_nssdb_.is_open()); |
65 | 67 |
66 // Use the same DB for public and private slot. | 68 // Use the same DB for public and private slot. |
67 test_nsscertdb_.reset(new net::NSSCertDatabaseChromeOS( | 69 test_nsscertdb_.reset(new net::NSSCertDatabaseChromeOS( |
68 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())), | 70 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())), |
69 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())))); | 71 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())))); |
70 test_nsscertdb_->SetSlowTaskRunnerForTest(message_loop_.task_runner()); | 72 test_nsscertdb_->SetSlowTaskRunnerForTest( |
| 73 base::ThreadTaskRunnerHandle::Get()); |
71 | 74 |
72 CertLoader::Initialize(); | 75 CertLoader::Initialize(); |
73 CertLoader::ForceHardwareBackedForTesting(); | 76 CertLoader::ForceHardwareBackedForTesting(); |
74 | 77 |
75 DBusThreadManager::Initialize(); | 78 DBusThreadManager::Initialize(); |
76 | 79 |
77 NetworkStateTest::SetUp(); | 80 NetworkStateTest::SetUp(); |
78 | 81 |
79 LoginState::Initialize(); | 82 LoginState::Initialize(); |
80 | 83 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 } | 193 } |
191 | 194 |
192 std::unique_ptr<AutoConnectHandler> auto_connect_handler_; | 195 std::unique_ptr<AutoConnectHandler> auto_connect_handler_; |
193 std::unique_ptr<ClientCertResolver> client_cert_resolver_; | 196 std::unique_ptr<ClientCertResolver> client_cert_resolver_; |
194 std::unique_ptr<NetworkConfigurationHandler> network_config_handler_; | 197 std::unique_ptr<NetworkConfigurationHandler> network_config_handler_; |
195 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl> | 198 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl> |
196 managed_config_handler_; | 199 managed_config_handler_; |
197 std::unique_ptr<NetworkProfileHandler> network_profile_handler_; | 200 std::unique_ptr<NetworkProfileHandler> network_profile_handler_; |
198 crypto::ScopedTestNSSDB test_nssdb_; | 201 crypto::ScopedTestNSSDB test_nssdb_; |
199 std::unique_ptr<net::NSSCertDatabaseChromeOS> test_nsscertdb_; | 202 std::unique_ptr<net::NSSCertDatabaseChromeOS> test_nsscertdb_; |
200 base::MessageLoopForUI message_loop_; | |
201 | 203 |
202 private: | 204 private: |
203 base::test::ScopedTaskScheduler scoped_task_scheduler_; | 205 base::test::ScopedTaskEnvironment scoped_task_environment_; |
204 | 206 |
205 DISALLOW_COPY_AND_ASSIGN(AutoConnectHandlerTest); | 207 DISALLOW_COPY_AND_ASSIGN(AutoConnectHandlerTest); |
206 }; | 208 }; |
207 | 209 |
208 namespace { | 210 namespace { |
209 | 211 |
210 const char* kConfigUnmanagedSharedConnected = | 212 const char* kConfigUnmanagedSharedConnected = |
211 "{ \"GUID\": \"wifi0\", \"Type\": \"wifi\", \"State\": \"online\", " | 213 "{ \"GUID\": \"wifi0\", \"Type\": \"wifi\", \"State\": \"online\", " |
212 " \"Security\": \"wpa\" }"; | 214 " \"Security\": \"wpa\" }"; |
213 const char* kConfigManagedSharedConnectable = | 215 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 | 454 // Applying the user policy after login would usually trigger connecting to |
453 // the 'best' network. But the manual connect prevents this. | 455 // the 'best' network. But the manual connect prevents this. |
454 SetupPolicy(std::string(), // no network configs | 456 SetupPolicy(std::string(), // no network configs |
455 base::DictionaryValue(), // no global config | 457 base::DictionaryValue(), // no global config |
456 true); // load as user policy | 458 true); // load as user policy |
457 EXPECT_EQ(shill::kStateOnline, GetServiceState("wifi0")); | 459 EXPECT_EQ(shill::kStateOnline, GetServiceState("wifi0")); |
458 EXPECT_EQ(shill::kStateIdle, GetServiceState("wifi1")); | 460 EXPECT_EQ(shill::kStateIdle, GetServiceState("wifi1")); |
459 } | 461 } |
460 | 462 |
461 } // namespace chromeos | 463 } // namespace chromeos |
OLD | NEW |