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

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

Issue 399303003: Eliminate use of sim unlock UI notifications (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 4 months 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 | Annotate | Revision Log
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 "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/fake_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 26
26 } // namespace 27 } // namespace
27 28
28 class NetworkDeviceHandlerTest : public testing::Test { 29 class NetworkDeviceHandlerTest : public testing::Test {
29 public: 30 public:
30 NetworkDeviceHandlerTest() : fake_device_client_(NULL) {} 31 NetworkDeviceHandlerTest() : fake_device_client_(NULL) {}
31 virtual ~NetworkDeviceHandlerTest() {} 32 virtual ~NetworkDeviceHandlerTest() {}
32 33
33 virtual void SetUp() OVERRIDE { 34 virtual void SetUp() OVERRIDE {
34 FakeDBusThreadManager* dbus_manager = new FakeDBusThreadManager; 35 FakeDBusThreadManager* dbus_manager = new FakeDBusThreadManager;
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 EXPECT_EQ(kResultSuccess, result_); 293 EXPECT_EQ(kResultSuccess, result_);
293 294
294 // Test that the shill error propagates to the error callback. 295 // Test that the shill error propagates to the error callback.
295 network_device_handler_->SetCarrier( 296 network_device_handler_->SetCarrier(
296 kUnknownCellularDevicePath, kCarrier, success_callback_, error_callback_); 297 kUnknownCellularDevicePath, kCarrier, success_callback_, error_callback_);
297 message_loop_.RunUntilIdle(); 298 message_loop_.RunUntilIdle();
298 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_); 299 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_);
299 } 300 }
300 301
301 TEST_F(NetworkDeviceHandlerTest, RequirePin) { 302 TEST_F(NetworkDeviceHandlerTest, RequirePin) {
302 const char kPin[] = "1234";
303
304 // Test that the success callback gets called. 303 // Test that the success callback gets called.
305 network_device_handler_->RequirePin(kDefaultCellularDevicePath, 304 network_device_handler_->RequirePin(kDefaultCellularDevicePath,
306 true, 305 true,
307 kPin, 306 kDefaultPin,
308 success_callback_, 307 success_callback_,
309 error_callback_); 308 error_callback_);
310 message_loop_.RunUntilIdle(); 309 message_loop_.RunUntilIdle();
311 EXPECT_EQ(kResultSuccess, result_); 310 EXPECT_EQ(kResultSuccess, result_);
312 311
313 // Test that the shill error propagates to the error callback. 312 // Test that the shill error propagates to the error callback.
314 network_device_handler_->RequirePin(kUnknownCellularDevicePath, 313 network_device_handler_->RequirePin(kUnknownCellularDevicePath,
315 true, 314 true,
316 kPin, 315 kDefaultPin,
317 success_callback_, 316 success_callback_,
318 error_callback_); 317 error_callback_);
319 message_loop_.RunUntilIdle(); 318 message_loop_.RunUntilIdle();
320 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_); 319 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_);
321 } 320 }
322 321
323 TEST_F(NetworkDeviceHandlerTest, EnterPin) { 322 TEST_F(NetworkDeviceHandlerTest, EnterPin) {
324 const char kPin[] = "1234";
325
326 // Test that the success callback gets called. 323 // Test that the success callback gets called.
327 network_device_handler_->EnterPin( 324 network_device_handler_->EnterPin(kDefaultCellularDevicePath,
328 kDefaultCellularDevicePath, kPin, success_callback_, error_callback_); 325 kDefaultPin,
326 success_callback_,
327 error_callback_);
329 message_loop_.RunUntilIdle(); 328 message_loop_.RunUntilIdle();
330 EXPECT_EQ(kResultSuccess, result_); 329 EXPECT_EQ(kResultSuccess, result_);
331 330
332 // Test that the shill error propagates to the error callback. 331 // Test that the shill error propagates to the error callback.
333 network_device_handler_->EnterPin( 332 network_device_handler_->EnterPin(kUnknownCellularDevicePath,
334 kUnknownCellularDevicePath, kPin, success_callback_, error_callback_); 333 kDefaultPin,
334 success_callback_,
335 error_callback_);
335 message_loop_.RunUntilIdle(); 336 message_loop_.RunUntilIdle();
336 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_); 337 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_);
337 } 338 }
338 339
339 TEST_F(NetworkDeviceHandlerTest, UnblockPin) { 340 TEST_F(NetworkDeviceHandlerTest, UnblockPin) {
340 const char kPuk[] = "12345678"; 341 const char kPuk[] = "12345678";
341 const char kPin[] = "1234"; 342 const char kPin[] = "1234";
342 343
343 // Test that the success callback gets called. 344 // Test that the success callback gets called.
344 network_device_handler_->UnblockPin(kDefaultCellularDevicePath, 345 network_device_handler_->UnblockPin(kDefaultCellularDevicePath,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 network_device_handler_->ChangePin(kUnknownCellularDevicePath, 377 network_device_handler_->ChangePin(kUnknownCellularDevicePath,
377 kOldPin, 378 kOldPin,
378 kNewPin, 379 kNewPin,
379 success_callback_, 380 success_callback_,
380 error_callback_); 381 error_callback_);
381 message_loop_.RunUntilIdle(); 382 message_loop_.RunUntilIdle();
382 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_); 383 EXPECT_EQ(NetworkDeviceHandler::kErrorDeviceMissing, result_);
383 } 384 }
384 385
385 } // namespace chromeos 386 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698