Chromium Code Reviews| 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/message_loop/message_loop.h" |
| 16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 17 #include "base/test/scoped_task_scheduler.h" | |
| 17 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.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" |
| 25 #include "chromeos/network/managed_network_configuration_handler_impl.h" | 26 #include "chromeos/network/managed_network_configuration_handler_impl.h" |
| 26 #include "chromeos/network/network_configuration_handler.h" | 27 #include "chromeos/network/network_configuration_handler.h" |
| (...skipping 43 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_) {} | |
|
Ryan Sleevi
2017/01/27 00:51:59
It strikes me as profoundly surprising to see new
fdoray
2017/02/02 17:56:32
New ScopedTaskScheduler documentation addresses th
| |
| 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())))); |
| 89 test_nsscertdb_->SetSlowTaskRunnerForTest(message_loop_.task_runner()); | |
| 90 | 92 |
| 91 CertLoader::Initialize(); | 93 CertLoader::Initialize(); |
| 92 CertLoader::ForceHardwareBackedForTesting(); | 94 CertLoader::ForceHardwareBackedForTesting(); |
| 93 | 95 |
| 94 DBusThreadManager::Initialize(); | 96 DBusThreadManager::Initialize(); |
| 95 DBusThreadManager* dbus_manager = DBusThreadManager::Get(); | 97 DBusThreadManager* dbus_manager = DBusThreadManager::Get(); |
| 96 test_manager_client_ = | 98 test_manager_client_ = |
| 97 dbus_manager->GetShillManagerClient()->GetTestInterface(); | 99 dbus_manager->GetShillManagerClient()->GetTestInterface(); |
| 98 test_service_client_ = | 100 test_service_client_ = |
| 99 dbus_manager->GetShillServiceClient()->GetTestInterface(); | 101 dbus_manager->GetShillServiceClient()->GetTestInterface(); |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 121 managed_config_handler_.reset(new ManagedNetworkConfigurationHandlerImpl()); | 123 managed_config_handler_.reset(new ManagedNetworkConfigurationHandlerImpl()); |
| 122 managed_config_handler_->Init( | 124 managed_config_handler_->Init( |
| 123 network_state_handler_.get(), network_profile_handler_.get(), | 125 network_state_handler_.get(), network_profile_handler_.get(), |
| 124 network_config_handler_.get(), nullptr /* network_device_handler */, | 126 network_config_handler_.get(), nullptr /* network_device_handler */, |
| 125 nullptr /* prohibited_technologies_handler */); | 127 nullptr /* prohibited_technologies_handler */); |
| 126 | 128 |
| 127 client_cert_resolver_.reset(new ClientCertResolver()); | 129 client_cert_resolver_.reset(new ClientCertResolver()); |
| 128 client_cert_resolver_->Init(network_state_handler_.get(), | 130 client_cert_resolver_->Init(network_state_handler_.get(), |
| 129 managed_config_handler_.get()); | 131 managed_config_handler_.get()); |
| 130 client_cert_resolver_->SetSlowTaskRunnerForTest( | 132 client_cert_resolver_->SetSlowTaskRunnerForTest( |
| 131 message_loop_.task_runner()); | 133 message_loop_.task_runner()); |
|
stevenjb
2017/02/03 18:01:04
Can't we / shouldn't we be able to get rid of this
fdoray
2017/02/03 19:23:06
Was taken care of in another CL. Latest patch set
| |
| 132 | 134 |
| 133 auto_connect_handler_.reset(new AutoConnectHandler()); | 135 auto_connect_handler_.reset(new AutoConnectHandler()); |
| 134 auto_connect_handler_->Init(client_cert_resolver_.get(), | 136 auto_connect_handler_->Init(client_cert_resolver_.get(), |
| 135 nullptr, // no connection handler | 137 nullptr, // no connection handler |
| 136 network_state_handler_.get(), | 138 network_state_handler_.get(), |
| 137 managed_config_handler_.get()); | 139 managed_config_handler_.get()); |
| 138 | 140 |
| 139 base::RunLoop().RunUntilIdle(); | 141 base::RunLoop().RunUntilIdle(); |
| 140 } | 142 } |
| 141 | 143 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 std::unique_ptr<NetworkStateHandler> network_state_handler_; | 246 std::unique_ptr<NetworkStateHandler> network_state_handler_; |
| 245 std::unique_ptr<NetworkConfigurationHandler> network_config_handler_; | 247 std::unique_ptr<NetworkConfigurationHandler> network_config_handler_; |
| 246 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl> | 248 std::unique_ptr<ManagedNetworkConfigurationHandlerImpl> |
| 247 managed_config_handler_; | 249 managed_config_handler_; |
| 248 std::unique_ptr<NetworkProfileHandler> network_profile_handler_; | 250 std::unique_ptr<NetworkProfileHandler> network_profile_handler_; |
| 249 ShillManagerClient::TestInterface* test_manager_client_; | 251 ShillManagerClient::TestInterface* test_manager_client_; |
| 250 ShillServiceClient::TestInterface* test_service_client_; | 252 ShillServiceClient::TestInterface* test_service_client_; |
| 251 crypto::ScopedTestNSSDB test_nssdb_; | 253 crypto::ScopedTestNSSDB test_nssdb_; |
| 252 std::unique_ptr<net::NSSCertDatabaseChromeOS> test_nsscertdb_; | 254 std::unique_ptr<net::NSSCertDatabaseChromeOS> test_nsscertdb_; |
| 253 base::MessageLoopForUI message_loop_; | 255 base::MessageLoopForUI message_loop_; |
| 256 base::test::ScopedTaskScheduler scoped_task_scheduler_; | |
| 254 | 257 |
| 255 private: | 258 private: |
| 256 DISALLOW_COPY_AND_ASSIGN(AutoConnectHandlerTest); | 259 DISALLOW_COPY_AND_ASSIGN(AutoConnectHandlerTest); |
| 257 }; | 260 }; |
| 258 | 261 |
| 259 namespace { | 262 namespace { |
| 260 | 263 |
| 261 const char* kConfigUnmanagedSharedConnected = | 264 const char* kConfigUnmanagedSharedConnected = |
| 262 "{ \"GUID\": \"wifi0\", \"Type\": \"wifi\", \"State\": \"online\", " | 265 "{ \"GUID\": \"wifi0\", \"Type\": \"wifi\", \"State\": \"online\", " |
| 263 " \"Security\": \"wpa\" }"; | 266 " \"Security\": \"wpa\" }"; |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 503 // Applying the user policy after login would usually trigger connecting to | 506 // Applying the user policy after login would usually trigger connecting to |
| 504 // the 'best' network. But the manual connect prevents this. | 507 // the 'best' network. But the manual connect prevents this. |
| 505 SetupPolicy(std::string(), // no network configs | 508 SetupPolicy(std::string(), // no network configs |
| 506 base::DictionaryValue(), // no global config | 509 base::DictionaryValue(), // no global config |
| 507 true); // load as user policy | 510 true); // load as user policy |
| 508 EXPECT_EQ(shill::kStateOnline, GetServiceState("wifi0")); | 511 EXPECT_EQ(shill::kStateOnline, GetServiceState("wifi0")); |
| 509 EXPECT_EQ(shill::kStateIdle, GetServiceState("wifi1")); | 512 EXPECT_EQ(shill::kStateIdle, GetServiceState("wifi1")); |
| 510 } | 513 } |
| 511 | 514 |
| 512 } // namespace chromeos | 515 } // namespace chromeos |
| OLD | NEW |