Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: chromeos/network/network_device_handler_unittest.cc

Issue 2478573003: NetworkStateHandler::InitializeForTest() should return a std::unique_ptr. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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" 9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 base::Unretained(this)); 43 base::Unretained(this));
44 properties_success_callback_ = 44 properties_success_callback_ =
45 base::Bind(&NetworkDeviceHandlerTest::PropertiesSuccessCallback, 45 base::Bind(&NetworkDeviceHandlerTest::PropertiesSuccessCallback,
46 base::Unretained(this)); 46 base::Unretained(this));
47 string_success_callback_ = 47 string_success_callback_ =
48 base::Bind(&NetworkDeviceHandlerTest::StringSuccessCallback, 48 base::Bind(&NetworkDeviceHandlerTest::StringSuccessCallback,
49 base::Unretained(this)); 49 base::Unretained(this));
50 error_callback_ = base::Bind(&NetworkDeviceHandlerTest::ErrorCallback, 50 error_callback_ = base::Bind(&NetworkDeviceHandlerTest::ErrorCallback,
51 base::Unretained(this)); 51 base::Unretained(this));
52 52
53 network_state_handler_.reset(NetworkStateHandler::InitializeForTest()); 53 network_state_handler_ = NetworkStateHandler::InitializeForTest();
54 NetworkDeviceHandlerImpl* device_handler = new NetworkDeviceHandlerImpl; 54 NetworkDeviceHandlerImpl* device_handler = new NetworkDeviceHandlerImpl;
55 device_handler->Init(network_state_handler_.get()); 55 device_handler->Init(network_state_handler_.get());
56 network_device_handler_.reset(device_handler); 56 network_device_handler_.reset(device_handler);
57 57
58 // Add devices after handlers have been initialized. 58 // Add devices after handlers have been initialized.
59 ShillDeviceClient::TestInterface* device_test = 59 ShillDeviceClient::TestInterface* device_test =
60 fake_device_client_->GetTestInterface(); 60 fake_device_client_->GetTestInterface();
61 device_test->AddDevice( 61 device_test->AddDevice(
62 kDefaultCellularDevicePath, shill::kTypeCellular, "cellular1"); 62 kDefaultCellularDevicePath, shill::kTypeCellular, "cellular1");
63 device_test->AddDevice(kDefaultWifiDevicePath, shill::kTypeWifi, "wifi1"); 63 device_test->AddDevice(kDefaultWifiDevicePath, shill::kTypeWifi, "wifi1");
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 // Setting a owner-protected device property through SetDeviceProperty must 176 // Setting a owner-protected device property through SetDeviceProperty must
177 // fail. 177 // fail.
178 network_device_handler_->SetDeviceProperty( 178 network_device_handler_->SetDeviceProperty(
179 kDefaultCellularDevicePath, 179 kDefaultCellularDevicePath,
180 shill::kCellularAllowRoamingProperty, 180 shill::kCellularAllowRoamingProperty,
181 base::FundamentalValue(true), 181 base::FundamentalValue(true),
182 success_callback_, 182 success_callback_,
183 error_callback_); 183 error_callback_);
184 base::RunLoop().RunUntilIdle(); 184 base::RunLoop().RunUntilIdle();
185 EXPECT_NE(kResultSuccess, result_); 185 EXPECT_NE(kResultSuccess, result_);
186
187 } 186 }
188 187
189 TEST_F(NetworkDeviceHandlerTest, CellularAllowRoaming) { 188 TEST_F(NetworkDeviceHandlerTest, CellularAllowRoaming) {
190 // Start with disabled data roaming. 189 // Start with disabled data roaming.
191 ShillDeviceClient::TestInterface* device_test = 190 ShillDeviceClient::TestInterface* device_test =
192 fake_device_client_->GetTestInterface(); 191 fake_device_client_->GetTestInterface();
193 device_test->SetDeviceProperty(kDefaultCellularDevicePath, 192 device_test->SetDeviceProperty(kDefaultCellularDevicePath,
194 shill::kCellularAllowRoamingProperty, 193 shill::kCellularAllowRoamingProperty,
195 base::FundamentalValue(false)); 194 base::FundamentalValue(false));
196 195
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 390
392 // Test that the shill error propagates to the error callback. 391 // Test that the shill error propagates to the error callback.
393 network_device_handler_->ChangePin(kDefaultCellularDevicePath, kIncorrectPin, 392 network_device_handler_->ChangePin(kDefaultCellularDevicePath, kIncorrectPin,
394 kNewPin, success_callback_, 393 kNewPin, success_callback_,
395 error_callback_); 394 error_callback_);
396 base::RunLoop().RunUntilIdle(); 395 base::RunLoop().RunUntilIdle();
397 EXPECT_EQ(NetworkDeviceHandler::kErrorIncorrectPin, result_); 396 EXPECT_EQ(NetworkDeviceHandler::kErrorIncorrectPin, result_);
398 } 397 }
399 398
400 } // namespace chromeos 399 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698