| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/shill_property_handler.h" | 5 #include "chromeos/network/shill_property_handler.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/bind.h" | 14 #include "base/bind.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/message_loop/message_loop.h" | |
| 17 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 17 #include "base/test/scoped_task_environment.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "chromeos/dbus/dbus_thread_manager.h" | 19 #include "chromeos/dbus/dbus_thread_manager.h" |
| 20 #include "chromeos/dbus/shill_device_client.h" | 20 #include "chromeos/dbus/shill_device_client.h" |
| 21 #include "chromeos/dbus/shill_ipconfig_client.h" | 21 #include "chromeos/dbus/shill_ipconfig_client.h" |
| 22 #include "chromeos/dbus/shill_manager_client.h" | 22 #include "chromeos/dbus/shill_manager_client.h" |
| 23 #include "chromeos/dbus/shill_profile_client.h" | 23 #include "chromeos/dbus/shill_profile_client.h" |
| 24 #include "chromeos/dbus/shill_service_client.h" | 24 #include "chromeos/dbus/shill_service_client.h" |
| 25 #include "dbus/object_path.h" | 25 #include "dbus/object_path.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 27 #include "third_party/cros_system_api/dbus/service_constants.h" | 27 #include "third_party/cros_system_api/dbus/service_constants.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 std::map<std::string, int > list_updates_; | 156 std::map<std::string, int > list_updates_; |
| 157 int technology_list_updates_; | 157 int technology_list_updates_; |
| 158 int errors_; | 158 int errors_; |
| 159 }; | 159 }; |
| 160 | 160 |
| 161 } // namespace | 161 } // namespace |
| 162 | 162 |
| 163 class ShillPropertyHandlerTest : public testing::Test { | 163 class ShillPropertyHandlerTest : public testing::Test { |
| 164 public: | 164 public: |
| 165 ShillPropertyHandlerTest() | 165 ShillPropertyHandlerTest() |
| 166 : manager_test_(NULL), | 166 : scoped_task_environment_( |
| 167 base::test::ScopedTaskEnvironment::MainThreadType::UI), |
| 168 manager_test_(NULL), |
| 167 device_test_(NULL), | 169 device_test_(NULL), |
| 168 service_test_(NULL), | 170 service_test_(NULL), |
| 169 profile_test_(NULL) { | 171 profile_test_(NULL) {} |
| 170 } | |
| 171 ~ShillPropertyHandlerTest() override {} | 172 ~ShillPropertyHandlerTest() override {} |
| 172 | 173 |
| 173 void SetUp() override { | 174 void SetUp() override { |
| 174 // Initialize DBusThreadManager with a stub implementation. | 175 // Initialize DBusThreadManager with a stub implementation. |
| 175 DBusThreadManager::Initialize(); | 176 DBusThreadManager::Initialize(); |
| 176 // Get the test interface for manager / device / service and clear the | 177 // Get the test interface for manager / device / service and clear the |
| 177 // default stub properties. | 178 // default stub properties. |
| 178 manager_test_ = | 179 manager_test_ = |
| 179 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface(); | 180 DBusThreadManager::Get()->GetShillManagerClient()->GetTestInterface(); |
| 180 ASSERT_TRUE(manager_test_); | 181 ASSERT_TRUE(manager_test_); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 device_test_->ClearDevices(); | 279 device_test_->ClearDevices(); |
| 279 AddDevice(shill::kTypeWifi, "stub_wifi_device1"); | 280 AddDevice(shill::kTypeWifi, "stub_wifi_device1"); |
| 280 AddDevice(shill::kTypeCellular, "stub_cellular_device1"); | 281 AddDevice(shill::kTypeCellular, "stub_cellular_device1"); |
| 281 service_test_->ClearServices(); | 282 service_test_->ClearServices(); |
| 282 AddService(shill::kTypeEthernet, "stub_ethernet", shill::kStateOnline); | 283 AddService(shill::kTypeEthernet, "stub_ethernet", shill::kStateOnline); |
| 283 AddService(shill::kTypeWifi, "stub_wifi1", shill::kStateOnline); | 284 AddService(shill::kTypeWifi, "stub_wifi1", shill::kStateOnline); |
| 284 AddService(shill::kTypeWifi, "stub_wifi2", shill::kStateIdle); | 285 AddService(shill::kTypeWifi, "stub_wifi2", shill::kStateIdle); |
| 285 AddService(shill::kTypeCellular, "stub_cellular1", shill::kStateIdle); | 286 AddService(shill::kTypeCellular, "stub_cellular1", shill::kStateIdle); |
| 286 } | 287 } |
| 287 | 288 |
| 288 base::MessageLoopForUI message_loop_; | 289 base::test::ScopedTaskEnvironment scoped_task_environment_; |
| 289 std::unique_ptr<TestListener> listener_; | 290 std::unique_ptr<TestListener> listener_; |
| 290 std::unique_ptr<internal::ShillPropertyHandler> shill_property_handler_; | 291 std::unique_ptr<internal::ShillPropertyHandler> shill_property_handler_; |
| 291 ShillManagerClient::TestInterface* manager_test_; | 292 ShillManagerClient::TestInterface* manager_test_; |
| 292 ShillDeviceClient::TestInterface* device_test_; | 293 ShillDeviceClient::TestInterface* device_test_; |
| 293 ShillServiceClient::TestInterface* service_test_; | 294 ShillServiceClient::TestInterface* service_test_; |
| 294 ShillProfileClient::TestInterface* profile_test_; | 295 ShillProfileClient::TestInterface* profile_test_; |
| 295 | 296 |
| 296 private: | 297 private: |
| 297 DISALLOW_COPY_AND_ASSIGN(ShillPropertyHandlerTest); | 298 DISALLOW_COPY_AND_ASSIGN(ShillPropertyHandlerTest); |
| 298 }; | 299 }; |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 shill_property_handler_->SetProhibitedTechnologies( | 528 shill_property_handler_->SetProhibitedTechnologies( |
| 528 prohibited_technologies, network_handler::ErrorCallback()); | 529 prohibited_technologies, network_handler::ErrorCallback()); |
| 529 shill_property_handler_->SetTechnologyEnabled( | 530 shill_property_handler_->SetTechnologyEnabled( |
| 530 shill::kTypeEthernet, true, network_handler::ErrorCallback()); | 531 shill::kTypeEthernet, true, network_handler::ErrorCallback()); |
| 531 base::RunLoop().RunUntilIdle(); | 532 base::RunLoop().RunUntilIdle(); |
| 532 EXPECT_TRUE( | 533 EXPECT_TRUE( |
| 533 shill_property_handler_->IsTechnologyEnabled(shill::kTypeEthernet)); | 534 shill_property_handler_->IsTechnologyEnabled(shill::kTypeEthernet)); |
| 534 } | 535 } |
| 535 | 536 |
| 536 } // namespace chromeos | 537 } // namespace chromeos |
| OLD | NEW |