OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chromeos/network/network_connect.h" | 5 #include "chromeos/network/network_connect.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 | 329 |
330 base::RunLoop().RunUntilIdle(); | 330 base::RunLoop().RunUntilIdle(); |
331 | 331 |
332 NetworkConnect::Get()->SetTechnologyEnabled(NetworkTypePattern::Cellular(), | 332 NetworkConnect::Get()->SetTechnologyEnabled(NetworkTypePattern::Cellular(), |
333 true); | 333 true); |
334 } | 334 } |
335 | 335 |
336 TEST_F(NetworkConnectTest, ConnectToTetherNetwork) { | 336 TEST_F(NetworkConnectTest, ConnectToTetherNetwork) { |
337 EXPECT_CALL(*mock_tether_delegate_, ConnectToNetwork(kTether1Guid)); | 337 EXPECT_CALL(*mock_tether_delegate_, ConnectToNetwork(kTether1Guid)); |
338 | 338 |
| 339 NetworkHandler::Get()->network_state_handler()->SetTetherTechnologyState( |
| 340 NetworkStateHandler::TECHNOLOGY_ENABLED); |
| 341 |
339 NetworkHandler::Get()->network_state_handler()->AddTetherNetworkState( | 342 NetworkHandler::Get()->network_state_handler()->AddTetherNetworkState( |
340 kTether1Guid, "TetherNetwork", "Carrier", 100 /* battery_percentage */, | 343 kTether1Guid, "TetherNetwork", "Carrier", 100 /* battery_percentage */, |
341 100 /* signal_strength */); | 344 100 /* signal_strength */); |
342 | 345 |
343 NetworkConnect::Get()->SetTetherDelegate(mock_tether_delegate_.get()); | 346 NetworkConnect::Get()->SetTetherDelegate(mock_tether_delegate_.get()); |
344 NetworkConnect::Get()->ConnectToNetworkId(kTether1Guid); | 347 NetworkConnect::Get()->ConnectToNetworkId(kTether1Guid); |
345 } | 348 } |
346 | 349 |
347 TEST_F(NetworkConnectTest, ConnectToTetherNetwork_TetherNetworkDoesNotExist) { | 350 TEST_F(NetworkConnectTest, ConnectToTetherNetwork_TetherNetworkDoesNotExist) { |
348 EXPECT_CALL(*mock_tether_delegate_, ConnectToNetwork(_)).Times(0); | 351 EXPECT_CALL(*mock_tether_delegate_, ConnectToNetwork(_)).Times(0); |
349 | 352 |
| 353 NetworkHandler::Get()->network_state_handler()->SetTetherTechnologyState( |
| 354 NetworkStateHandler::TECHNOLOGY_ENABLED); |
| 355 |
350 NetworkConnect::Get()->SetTetherDelegate(mock_tether_delegate_.get()); | 356 NetworkConnect::Get()->SetTetherDelegate(mock_tether_delegate_.get()); |
351 NetworkConnect::Get()->ConnectToNetworkId(kTether1Guid); | 357 NetworkConnect::Get()->ConnectToNetworkId(kTether1Guid); |
352 } | 358 } |
353 | 359 |
354 TEST_F(NetworkConnectTest, ConnectToTetherNetwork_TetherDelegateNotSet) { | 360 TEST_F(NetworkConnectTest, ConnectToTetherNetwork_TetherDelegateNotSet) { |
355 EXPECT_CALL(*mock_tether_delegate_, ConnectToNetwork(_)).Times(0); | 361 EXPECT_CALL(*mock_tether_delegate_, ConnectToNetwork(_)).Times(0); |
356 | 362 |
| 363 NetworkHandler::Get()->network_state_handler()->SetTetherTechnologyState( |
| 364 NetworkStateHandler::TECHNOLOGY_ENABLED); |
| 365 |
357 NetworkHandler::Get()->network_state_handler()->AddTetherNetworkState( | 366 NetworkHandler::Get()->network_state_handler()->AddTetherNetworkState( |
358 kTether1Guid, "TetherNetwork", "Carrier", 100 /* battery_percentage */, | 367 kTether1Guid, "TetherNetwork", "Carrier", 100 /* battery_percentage */, |
359 100 /* signal_strength */); | 368 100 /* signal_strength */); |
360 | 369 |
361 NetworkConnect::Get()->ConnectToNetworkId(kTether1Guid); | 370 NetworkConnect::Get()->ConnectToNetworkId(kTether1Guid); |
362 } | 371 } |
363 | 372 |
364 } // namespace chromeos | 373 } // namespace chromeos |
OLD | NEW |