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