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/bind.h" | 10 #include "base/bind.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
13 #include "base/json/json_reader.h" | 13 #include "base/json/json_reader.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/message_loop/message_loop.h" |
15 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
16 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
17 #include "base/test/scoped_task_scheduler.h" | 18 #include "base/test/scoped_task_scheduler.h" |
18 #include "chromeos/cert_loader.h" | 19 #include "chromeos/cert_loader.h" |
19 #include "chromeos/dbus/dbus_thread_manager.h" | 20 #include "chromeos/dbus/dbus_thread_manager.h" |
20 #include "chromeos/dbus/shill_device_client.h" | 21 #include "chromeos/dbus/shill_device_client.h" |
21 #include "chromeos/dbus/shill_manager_client.h" | 22 #include "chromeos/dbus/shill_manager_client.h" |
22 #include "chromeos/dbus/shill_profile_client.h" | 23 #include "chromeos/dbus/shill_profile_client.h" |
23 #include "chromeos/dbus/shill_service_client.h" | 24 #include "chromeos/dbus/shill_service_client.h" |
24 #include "chromeos/network/client_cert_resolver.h" | 25 #include "chromeos/network/client_cert_resolver.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 private: | 71 private: |
71 bool changed_network_properties_; | 72 bool changed_network_properties_; |
72 ClientCertResolver* cert_resolver_; | 73 ClientCertResolver* cert_resolver_; |
73 }; | 74 }; |
74 | 75 |
75 } // namespace | 76 } // namespace |
76 | 77 |
77 class AutoConnectHandlerTest : public testing::Test { | 78 class AutoConnectHandlerTest : public testing::Test { |
78 public: | 79 public: |
79 AutoConnectHandlerTest() | 80 AutoConnectHandlerTest() |
80 : test_manager_client_(nullptr), test_service_client_(nullptr) {} | 81 : test_manager_client_(nullptr), |
| 82 test_service_client_(nullptr), |
| 83 scoped_task_scheduler_(&message_loop_) {} |
81 | 84 |
82 void SetUp() override { | 85 void SetUp() override { |
83 ASSERT_TRUE(test_nssdb_.is_open()); | 86 ASSERT_TRUE(test_nssdb_.is_open()); |
84 | 87 |
85 // Use the same DB for public and private slot. | 88 // Use the same DB for public and private slot. |
86 test_nsscertdb_.reset(new net::NSSCertDatabaseChromeOS( | 89 test_nsscertdb_.reset(new net::NSSCertDatabaseChromeOS( |
87 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())), | 90 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())), |
88 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())))); | 91 crypto::ScopedPK11Slot(PK11_ReferenceSlot(test_nssdb_.slot())))); |
| 92 test_nsscertdb_->SetSlowTaskRunnerForTest(message_loop_.task_runner()); |
89 | 93 |
90 CertLoader::Initialize(); | 94 CertLoader::Initialize(); |
91 CertLoader::ForceHardwareBackedForTesting(); | 95 CertLoader::ForceHardwareBackedForTesting(); |
92 | 96 |
93 DBusThreadManager::Initialize(); | 97 DBusThreadManager::Initialize(); |
94 DBusThreadManager* dbus_manager = DBusThreadManager::Get(); | 98 DBusThreadManager* dbus_manager = DBusThreadManager::Get(); |
95 test_manager_client_ = | 99 test_manager_client_ = |
96 dbus_manager->GetShillManagerClient()->GetTestInterface(); | 100 dbus_manager->GetShillManagerClient()->GetTestInterface(); |
97 test_service_client_ = | 101 test_service_client_ = |
98 dbus_manager->GetShillServiceClient()->GetTestInterface(); | 102 dbus_manager->GetShillServiceClient()->GetTestInterface(); |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 std::unique_ptr<ClientCertResolver> client_cert_resolver_; | 245 std::unique_ptr<ClientCertResolver> client_cert_resolver_; |
242 std::unique_ptr<NetworkStateHandler> network_state_handler_; | 246 std::unique_ptr<NetworkStateHandler> network_state_handler_; |
243 std::unique_ptr<NetworkConfigurationHandler> network_config_handler_; | 247 std::unique_ptr<NetworkConfigurationHandler> network_config_handler_; |
244 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl> | 248 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl> |
245 managed_config_handler_; | 249 managed_config_handler_; |
246 std::unique_ptr<NetworkProfileHandler> network_profile_handler_; | 250 std::unique_ptr<NetworkProfileHandler> network_profile_handler_; |
247 ShillManagerClient::TestInterface* test_manager_client_; | 251 ShillManagerClient::TestInterface* test_manager_client_; |
248 ShillServiceClient::TestInterface* test_service_client_; | 252 ShillServiceClient::TestInterface* test_service_client_; |
249 crypto::ScopedTestNSSDB test_nssdb_; | 253 crypto::ScopedTestNSSDB test_nssdb_; |
250 std::unique_ptr<net::NSSCertDatabaseChromeOS> test_nsscertdb_; | 254 std::unique_ptr<net::NSSCertDatabaseChromeOS> test_nsscertdb_; |
| 255 base::MessageLoopForUI message_loop_; |
251 | 256 |
252 private: | 257 private: |
253 base::test::ScopedTaskScheduler scoped_task_scheduler_; | 258 base::test::ScopedTaskScheduler scoped_task_scheduler_; |
254 | 259 |
255 DISALLOW_COPY_AND_ASSIGN(AutoConnectHandlerTest); | 260 DISALLOW_COPY_AND_ASSIGN(AutoConnectHandlerTest); |
256 }; | 261 }; |
257 | 262 |
258 namespace { | 263 namespace { |
259 | 264 |
260 const char* kConfigUnmanagedSharedConnected = | 265 const char* kConfigUnmanagedSharedConnected = |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 // Applying the user policy after login would usually trigger connecting to | 507 // Applying the user policy after login would usually trigger connecting to |
503 // the 'best' network. But the manual connect prevents this. | 508 // the 'best' network. But the manual connect prevents this. |
504 SetupPolicy(std::string(), // no network configs | 509 SetupPolicy(std::string(), // no network configs |
505 base::DictionaryValue(), // no global config | 510 base::DictionaryValue(), // no global config |
506 true); // load as user policy | 511 true); // load as user policy |
507 EXPECT_EQ(shill::kStateOnline, GetServiceState("wifi0")); | 512 EXPECT_EQ(shill::kStateOnline, GetServiceState("wifi0")); |
508 EXPECT_EQ(shill::kStateIdle, GetServiceState("wifi1")); | 513 EXPECT_EQ(shill::kStateIdle, GetServiceState("wifi1")); |
509 } | 514 } |
510 | 515 |
511 } // namespace chromeos | 516 } // namespace chromeos |
OLD | NEW |