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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chromeos/dbus/fake_dbus_thread_manager.h" | 9 #include "chromeos/dbus/dbus_thread_manager.h" |
10 #include "chromeos/dbus/fake_shill_device_client.h" | 10 #include "chromeos/dbus/fake_shill_device_client.h" |
11 #include "chromeos/dbus/fake_shill_manager_client.h" | 11 #include "chromeos/dbus/fake_shill_manager_client.h" |
12 #include "chromeos/network/network_device_handler_impl.h" | 12 #include "chromeos/network/network_device_handler_impl.h" |
13 #include "chromeos/network/network_state_handler.h" | 13 #include "chromeos/network/network_state_handler.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "third_party/cros_system_api/dbus/service_constants.h" | 15 #include "third_party/cros_system_api/dbus/service_constants.h" |
16 | 16 |
17 namespace chromeos { | 17 namespace chromeos { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 const char kDefaultCellularDevicePath[] = "stub_cellular_device"; | 21 const char kDefaultCellularDevicePath[] = "stub_cellular_device"; |
22 const char kUnknownCellularDevicePath[] = "unknown_cellular_device"; | 22 const char kUnknownCellularDevicePath[] = "unknown_cellular_device"; |
23 const char kDefaultWifiDevicePath[] = "stub_wifi_device"; | 23 const char kDefaultWifiDevicePath[] = "stub_wifi_device"; |
24 const char kResultSuccess[] = "success"; | 24 const char kResultSuccess[] = "success"; |
25 const char kDefaultPin[] = "1111"; | 25 const char kDefaultPin[] = "1111"; |
26 | 26 |
27 } // namespace | 27 } // namespace |
28 | 28 |
29 class NetworkDeviceHandlerTest : public testing::Test { | 29 class NetworkDeviceHandlerTest : public testing::Test { |
30 public: | 30 public: |
31 NetworkDeviceHandlerTest() : fake_device_client_(NULL) {} | 31 NetworkDeviceHandlerTest() : fake_device_client_(NULL) {} |
32 virtual ~NetworkDeviceHandlerTest() {} | 32 virtual ~NetworkDeviceHandlerTest() {} |
33 | 33 |
34 virtual void SetUp() OVERRIDE { | 34 virtual void SetUp() OVERRIDE { |
35 FakeDBusThreadManager* dbus_manager = new FakeDBusThreadManager; | |
36 dbus_manager->SetFakeShillClients(); | |
37 | |
38 fake_device_client_ = new FakeShillDeviceClient; | 35 fake_device_client_ = new FakeShillDeviceClient; |
39 dbus_manager->SetShillDeviceClient( | 36 DBusThreadManager::GetSetterForTesting()->SetShillDeviceClient( |
40 scoped_ptr<ShillDeviceClient>(fake_device_client_)); | 37 scoped_ptr<ShillDeviceClient>(fake_device_client_)); |
41 DBusThreadManager::InitializeForTesting(dbus_manager); | |
42 | 38 |
43 success_callback_ = base::Bind(&NetworkDeviceHandlerTest::SuccessCallback, | 39 success_callback_ = base::Bind(&NetworkDeviceHandlerTest::SuccessCallback, |
44 base::Unretained(this)); | 40 base::Unretained(this)); |
45 properties_success_callback_ = | 41 properties_success_callback_ = |
46 base::Bind(&NetworkDeviceHandlerTest::PropertiesSuccessCallback, | 42 base::Bind(&NetworkDeviceHandlerTest::PropertiesSuccessCallback, |
47 base::Unretained(this)); | 43 base::Unretained(this)); |
48 string_success_callback_ = | 44 string_success_callback_ = |
49 base::Bind(&NetworkDeviceHandlerTest::StringSuccessCallback, | 45 base::Bind(&NetworkDeviceHandlerTest::StringSuccessCallback, |
50 base::Unretained(this)); | 46 base::Unretained(this)); |
51 error_callback_ = base::Bind(&NetworkDeviceHandlerTest::ErrorCallback, | 47 error_callback_ = base::Bind(&NetworkDeviceHandlerTest::ErrorCallback, |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 network_device_handler_->ChangePin(kUnknownCellularDevicePath, | 373 network_device_handler_->ChangePin(kUnknownCellularDevicePath, |
378 kOldPin, | 374 kOldPin, |
379 kNewPin, | 375 kNewPin, |
380 success_callback_, | 376 success_callback_, |
381 error_callback_); | 377 error_callback_); |
382 message_loop_.RunUntilIdle(); | 378 message_loop_.RunUntilIdle(); |
383 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_); | 379 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_); |
384 } | 380 } |
385 | 381 |
386 } // namespace chromeos | 382 } // namespace chromeos |
OLD | NEW |