| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <iostream> | 5 #include <iostream> |
| 6 #include <sstream> | 6 #include <sstream> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 14 #include "base/values.h" | 14 #include "base/values.h" |
| 15 #include "chromeos/dbus/dbus_thread_manager.h" | 15 #include "chromeos/dbus/dbus_thread_manager.h" |
| 16 #include "chromeos/dbus/mock_shill_manager_client.h" | 16 #include "chromeos/dbus/mock_shill_manager_client.h" |
| 17 #include "chromeos/dbus/mock_shill_profile_client.h" | 17 #include "chromeos/dbus/mock_shill_profile_client.h" |
| 18 #include "chromeos/dbus/mock_shill_service_client.h" | 18 #include "chromeos/dbus/mock_shill_service_client.h" |
| 19 #include "chromeos/dbus/shill_client_helper.h" | 19 #include "chromeos/dbus/shill_client_helper.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_policy_observer.h" | 22 #include "chromeos/network/network_policy_observer.h" |
| 23 #include "chromeos/network/network_profile_handler.h" | 23 #include "chromeos/network/network_profile_handler.h" |
| 24 #include "chromeos/network/network_state_handler.h" |
| 24 #include "chromeos/network/onc/onc_test_utils.h" | 25 #include "chromeos/network/onc/onc_test_utils.h" |
| 25 #include "chromeos/network/onc/onc_utils.h" | 26 #include "chromeos/network/onc/onc_utils.h" |
| 26 #include "dbus/object_path.h" | 27 #include "dbus/object_path.h" |
| 27 #include "testing/gmock/include/gmock/gmock.h" | 28 #include "testing/gmock/include/gmock/gmock.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| 29 #include "third_party/cros_system_api/dbus/service_constants.h" | 30 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 30 | 31 |
| 31 using ::testing::AnyNumber; | 32 using ::testing::AnyNumber; |
| 32 using ::testing::Invoke; | 33 using ::testing::Invoke; |
| 33 using ::testing::Mock; | 34 using ::testing::Mock; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 &ShillProfileTestClient::GetProperties)); | 235 &ShillProfileTestClient::GetProperties)); |
| 235 | 236 |
| 236 ON_CALL(*mock_profile_client_, GetEntry(_,_,_,_)) | 237 ON_CALL(*mock_profile_client_, GetEntry(_,_,_,_)) |
| 237 .WillByDefault(Invoke(&profiles_stub_, | 238 .WillByDefault(Invoke(&profiles_stub_, |
| 238 &ShillProfileTestClient::GetEntry)); | 239 &ShillProfileTestClient::GetEntry)); |
| 239 | 240 |
| 240 ON_CALL(*mock_service_client_, GetProperties(_,_)) | 241 ON_CALL(*mock_service_client_, GetProperties(_,_)) |
| 241 .WillByDefault(Invoke(&services_stub_, | 242 .WillByDefault(Invoke(&services_stub_, |
| 242 &ShillServiceTestClient::GetProperties)); | 243 &ShillServiceTestClient::GetProperties)); |
| 243 | 244 |
| 245 network_state_handler_.reset(NetworkStateHandler::InitializeForTest()); |
| 244 network_profile_handler_.reset(new TestNetworkProfileHandler()); | 246 network_profile_handler_.reset(new TestNetworkProfileHandler()); |
| 245 network_configuration_handler_.reset( | 247 network_configuration_handler_.reset( |
| 246 NetworkConfigurationHandler::InitializeForTest( | 248 NetworkConfigurationHandler::InitializeForTest( |
| 247 NULL /* no NetworkStateHandler */, | 249 network_state_handler_.get(), |
| 248 NULL /* no NetworkDeviceHandler */)); | 250 NULL /* no NetworkDeviceHandler */)); |
| 249 managed_network_configuration_handler_.reset( | 251 managed_network_configuration_handler_.reset( |
| 250 new ManagedNetworkConfigurationHandlerImpl()); | 252 new ManagedNetworkConfigurationHandlerImpl()); |
| 251 managed_network_configuration_handler_->Init( | 253 managed_network_configuration_handler_->Init( |
| 252 NULL /* no NetworkStateHandler */, | 254 network_state_handler_.get(), |
| 253 network_profile_handler_.get(), | 255 network_profile_handler_.get(), |
| 254 network_configuration_handler_.get(), | 256 network_configuration_handler_.get(), |
| 255 NULL /* no DeviceHandler */); | 257 NULL /* no DeviceHandler */); |
| 256 managed_network_configuration_handler_->AddObserver(&policy_observer_); | 258 managed_network_configuration_handler_->AddObserver(&policy_observer_); |
| 257 | 259 |
| 258 message_loop_.RunUntilIdle(); | 260 message_loop_.RunUntilIdle(); |
| 259 } | 261 } |
| 260 | 262 |
| 261 void TearDown() override { | 263 void TearDown() override { |
| 262 if (managed_network_configuration_handler_) | 264 if (managed_network_configuration_handler_) |
| 263 managed_network_configuration_handler_->RemoveObserver(&policy_observer_); | 265 managed_network_configuration_handler_->RemoveObserver(&policy_observer_); |
| 266 network_state_handler_.reset(); |
| 264 managed_network_configuration_handler_.reset(); | 267 managed_network_configuration_handler_.reset(); |
| 265 network_configuration_handler_.reset(); | 268 network_configuration_handler_.reset(); |
| 266 network_profile_handler_.reset(); | 269 network_profile_handler_.reset(); |
| 267 DBusThreadManager::Shutdown(); | 270 DBusThreadManager::Shutdown(); |
| 268 } | 271 } |
| 269 | 272 |
| 270 void VerifyAndClearExpectations() { | 273 void VerifyAndClearExpectations() { |
| 271 Mock::VerifyAndClearExpectations(mock_manager_client_); | 274 Mock::VerifyAndClearExpectations(mock_manager_client_); |
| 272 Mock::VerifyAndClearExpectations(mock_profile_client_); | 275 Mock::VerifyAndClearExpectations(mock_profile_client_); |
| 273 SetNetworkConfigurationHandlerExpectations(); | 276 SetNetworkConfigurationHandlerExpectations(); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 ASSERT_FALSE(true); | 356 ASSERT_FALSE(true); |
| 354 } | 357 } |
| 355 | 358 |
| 356 protected: | 359 protected: |
| 357 MockShillManagerClient* mock_manager_client_; | 360 MockShillManagerClient* mock_manager_client_; |
| 358 MockShillProfileClient* mock_profile_client_; | 361 MockShillProfileClient* mock_profile_client_; |
| 359 MockShillServiceClient* mock_service_client_; | 362 MockShillServiceClient* mock_service_client_; |
| 360 ShillProfileTestClient profiles_stub_; | 363 ShillProfileTestClient profiles_stub_; |
| 361 ShillServiceTestClient services_stub_; | 364 ShillServiceTestClient services_stub_; |
| 362 TestNetworkPolicyObserver policy_observer_; | 365 TestNetworkPolicyObserver policy_observer_; |
| 366 scoped_ptr<NetworkStateHandler> network_state_handler_; |
| 363 scoped_ptr<TestNetworkProfileHandler> network_profile_handler_; | 367 scoped_ptr<TestNetworkProfileHandler> network_profile_handler_; |
| 364 scoped_ptr<NetworkConfigurationHandler> network_configuration_handler_; | 368 scoped_ptr<NetworkConfigurationHandler> network_configuration_handler_; |
| 365 scoped_ptr<ManagedNetworkConfigurationHandlerImpl> | 369 scoped_ptr<ManagedNetworkConfigurationHandlerImpl> |
| 366 managed_network_configuration_handler_; | 370 managed_network_configuration_handler_; |
| 367 base::MessageLoop message_loop_; | 371 base::MessageLoop message_loop_; |
| 368 | 372 |
| 369 std::string get_properties_service_path_; | 373 std::string get_properties_service_path_; |
| 370 base::DictionaryValue get_properties_result_; | 374 base::DictionaryValue get_properties_result_; |
| 371 | 375 |
| 372 private: | 376 private: |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 959 EXPECT_CALL(*mock_profile_client_, | 963 EXPECT_CALL(*mock_profile_client_, |
| 960 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); | 964 GetProperties(dbus::ObjectPath(kUser1ProfilePath), _, _)); |
| 961 | 965 |
| 962 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); | 966 SetPolicy(::onc::ONC_SOURCE_USER_POLICY, kUser1, "policy/policy_wifi1.onc"); |
| 963 managed_network_configuration_handler_->RemoveObserver(&policy_observer_); | 967 managed_network_configuration_handler_->RemoveObserver(&policy_observer_); |
| 964 managed_network_configuration_handler_.reset(); | 968 managed_network_configuration_handler_.reset(); |
| 965 message_loop_.RunUntilIdle(); | 969 message_loop_.RunUntilIdle(); |
| 966 } | 970 } |
| 967 | 971 |
| 968 } // namespace chromeos | 972 } // namespace chromeos |
| OLD | NEW |