OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/message_loop/message_loop.h" | |
10 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/test/scoped_task_environment.h" | |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chromeos/dbus/dbus_thread_manager.h" | 12 #include "chromeos/dbus/dbus_thread_manager.h" |
13 #include "chromeos/dbus/fake_shill_device_client.h" | 13 #include "chromeos/dbus/fake_shill_device_client.h" |
14 #include "chromeos/dbus/fake_shill_manager_client.h" | 14 #include "chromeos/dbus/fake_shill_manager_client.h" |
15 #include "chromeos/network/network_device_handler_impl.h" | 15 #include "chromeos/network/network_device_handler_impl.h" |
16 #include "chromeos/network/network_state_handler.h" | 16 #include "chromeos/network/network_state_handler.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "third_party/cros_system_api/dbus/service_constants.h" | 18 #include "third_party/cros_system_api/dbus/service_constants.h" |
19 | 19 |
20 namespace chromeos { | 20 namespace chromeos { |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 const char kDefaultCellularDevicePath[] = "stub_cellular_device"; | 24 const char kDefaultCellularDevicePath[] = "stub_cellular_device"; |
25 const char kUnknownCellularDevicePath[] = "unknown_cellular_device"; | 25 const char kUnknownCellularDevicePath[] = "unknown_cellular_device"; |
26 const char kDefaultWifiDevicePath[] = "stub_wifi_device"; | 26 const char kDefaultWifiDevicePath[] = "stub_wifi_device"; |
27 const char kResultSuccess[] = "success"; | 27 const char kResultSuccess[] = "success"; |
28 const char kDefaultPin[] = "1111"; | 28 const char kDefaultPin[] = "1111"; |
29 | 29 |
30 } // namespace | 30 } // namespace |
31 | 31 |
32 class NetworkDeviceHandlerTest : public testing::Test { | 32 class NetworkDeviceHandlerTest : public testing::Test { |
33 public: | 33 public: |
34 NetworkDeviceHandlerTest() : fake_device_client_(NULL) {} | 34 NetworkDeviceHandlerTest() |
35 : scoped_task_environment_( | |
36 base::test::ScopedTaskEnvironment::MainThreadType::UI), | |
37 fake_device_client_(NULL) {} | |
stevenjb
2017/04/27 18:39:10
nit: nullptr
fdoray
2017/04/27 20:35:03
Done.
| |
35 ~NetworkDeviceHandlerTest() override {} | 38 ~NetworkDeviceHandlerTest() override {} |
36 | 39 |
37 void SetUp() override { | 40 void SetUp() override { |
38 fake_device_client_ = new FakeShillDeviceClient; | 41 fake_device_client_ = new FakeShillDeviceClient; |
39 DBusThreadManager::GetSetterForTesting()->SetShillDeviceClient( | 42 DBusThreadManager::GetSetterForTesting()->SetShillDeviceClient( |
40 std::unique_ptr<ShillDeviceClient>(fake_device_client_)); | 43 std::unique_ptr<ShillDeviceClient>(fake_device_client_)); |
41 | 44 |
42 success_callback_ = base::Bind(&NetworkDeviceHandlerTest::SuccessCallback, | 45 success_callback_ = base::Bind(&NetworkDeviceHandlerTest::SuccessCallback, |
43 base::Unretained(this)); | 46 base::Unretained(this)); |
44 properties_success_callback_ = | 47 properties_success_callback_ = |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 VLOG(1) << "StringSuccessCallback: " << result; | 100 VLOG(1) << "StringSuccessCallback: " << result; |
98 result_ = result; | 101 result_ = result; |
99 } | 102 } |
100 | 103 |
101 protected: | 104 protected: |
102 std::string result_; | 105 std::string result_; |
103 | 106 |
104 FakeShillDeviceClient* fake_device_client_; | 107 FakeShillDeviceClient* fake_device_client_; |
105 std::unique_ptr<NetworkDeviceHandler> network_device_handler_; | 108 std::unique_ptr<NetworkDeviceHandler> network_device_handler_; |
106 std::unique_ptr<NetworkStateHandler> network_state_handler_; | 109 std::unique_ptr<NetworkStateHandler> network_state_handler_; |
107 base::MessageLoopForUI message_loop_; | 110 base::test::ScopedTaskEnvironment scoped_task_environment_; |
108 base::Closure success_callback_; | 111 base::Closure success_callback_; |
109 network_handler::DictionaryResultCallback properties_success_callback_; | 112 network_handler::DictionaryResultCallback properties_success_callback_; |
110 network_handler::StringResultCallback string_success_callback_; | 113 network_handler::StringResultCallback string_success_callback_; |
111 network_handler::ErrorCallback error_callback_; | 114 network_handler::ErrorCallback error_callback_; |
112 std::unique_ptr<base::DictionaryValue> properties_; | 115 std::unique_ptr<base::DictionaryValue> properties_; |
113 | 116 |
114 private: | 117 private: |
115 DISALLOW_COPY_AND_ASSIGN(NetworkDeviceHandlerTest); | 118 DISALLOW_COPY_AND_ASSIGN(NetworkDeviceHandlerTest); |
116 }; | 119 }; |
117 | 120 |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
382 | 385 |
383 // Test that the shill error propagates to the error callback. | 386 // Test that the shill error propagates to the error callback. |
384 network_device_handler_->ChangePin(kDefaultCellularDevicePath, kIncorrectPin, | 387 network_device_handler_->ChangePin(kDefaultCellularDevicePath, kIncorrectPin, |
385 kNewPin, success_callback_, | 388 kNewPin, success_callback_, |
386 error_callback_); | 389 error_callback_); |
387 base::RunLoop().RunUntilIdle(); | 390 base::RunLoop().RunUntilIdle(); |
388 EXPECT_EQ(NetworkDeviceHandler::kErrorIncorrectPin, result_); | 391 EXPECT_EQ(NetworkDeviceHandler::kErrorIncorrectPin, result_); |
389 } | 392 } |
390 | 393 |
391 } // namespace chromeos | 394 } // namespace chromeos |
OLD | NEW |