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

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

Issue 2775663005: Adds NetworkConnect::ConnectToNetworkId(), uses it in detailed VPN page (Closed)
Patch Set: Adds NetworkConnect::ConnectToNetworkId(), uses it in detailed VPN page (nits) Created 3 years, 9 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
« no previous file with comments | « chromeos/network/network_connect.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/run_loop.h" 11 #include "base/run_loop.h"
12 #include "chromeos/dbus/dbus_thread_manager.h" 12 #include "chromeos/dbus/dbus_thread_manager.h"
13 #include "chromeos/dbus/shill_device_client.h" 13 #include "chromeos/dbus/shill_device_client.h"
14 #include "chromeos/dbus/shill_service_client.h" 14 #include "chromeos/dbus/shill_service_client.h"
15 #include "chromeos/login/login_state.h" 15 #include "chromeos/login/login_state.h"
16 #include "chromeos/network/network_connect.h" 16 #include "chromeos/network/network_connect.h"
17 #include "chromeos/network/network_connection_handler.h" 17 #include "chromeos/network/network_connection_handler.h"
18 #include "chromeos/network/network_handler.h" 18 #include "chromeos/network/network_handler.h"
19 #include "chromeos/network/network_state.h"
19 #include "chromeos/network/network_state_handler.h" 20 #include "chromeos/network/network_state_handler.h"
20 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
22 #include "testing/platform_test.h" 23 #include "testing/platform_test.h"
23 #include "third_party/cros_system_api/dbus/service_constants.h" 24 #include "third_party/cros_system_api/dbus/service_constants.h"
24 25
25 using testing::_; 26 using testing::_;
26 using testing::AnyNumber; 27 using testing::AnyNumber;
27 using testing::NiceMock; 28 using testing::NiceMock;
28 using testing::Return; 29 using testing::Return;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 EXPECT_CALL(*mock_delegate_, ShowEnrollNetwork(_)).Times(AnyNumber()); 217 EXPECT_CALL(*mock_delegate_, ShowEnrollNetwork(_)).Times(AnyNumber());
217 EXPECT_CALL(*mock_delegate_, ShowNetworkConfigure(kWiFi1Guid)); 218 EXPECT_CALL(*mock_delegate_, ShowNetworkConfigure(kWiFi1Guid));
218 219
219 ON_CALL(*mock_delegate_, ShowEnrollNetwork(kWiFi1Guid)) 220 ON_CALL(*mock_delegate_, ShowEnrollNetwork(kWiFi1Guid))
220 .WillByDefault(Return(false)); 221 .WillByDefault(Return(false));
221 222
222 NetworkConnect::Get()->MaybeShowConfigureUI( 223 NetworkConnect::Get()->MaybeShowConfigureUI(
223 kWiFi1Guid, NetworkConnectionHandler::kErrorCertificateRequired); 224 kWiFi1Guid, NetworkConnectionHandler::kErrorCertificateRequired);
224 } 225 }
225 226
227 TEST_F(NetworkConnectTest, ConnectThenDisconnectWiFiNetwork) {
228 const NetworkState* network =
229 NetworkHandler::Get()->network_state_handler()->GetNetworkStateFromGuid(
230 kWiFi1Guid);
231
232 NetworkConnect::Get()->ConnectToNetworkId(kWiFi1Guid);
233 base::RunLoop().RunUntilIdle();
234 EXPECT_TRUE(network->IsConnectedState());
235
236 NetworkConnect::Get()->DisconnectFromNetworkId(kWiFi1Guid);
237 base::RunLoop().RunUntilIdle();
238 EXPECT_FALSE(network->IsConnectedState());
239 EXPECT_FALSE(network->IsConnectingState());
240 }
241
226 // ShowNetworkSettings only applies to cellular networks. 242 // ShowNetworkSettings only applies to cellular networks.
227 TEST_F(NetworkConnectTest, ShowNetworkSettings) { 243 TEST_F(NetworkConnectTest, ShowNetworkSettings) {
228 EXPECT_CALL(*mock_delegate_, ShowNetworkSettings(kCellular1Guid)); 244 EXPECT_CALL(*mock_delegate_, ShowNetworkSettings(kCellular1Guid));
229 245
230 NetworkConnect::Get()->MaybeShowConfigureUI( 246 NetworkConnect::Get()->MaybeShowConfigureUI(
231 kCellular1Guid, NetworkConnectionHandler::kErrorConnectFailed); 247 kCellular1Guid, NetworkConnectionHandler::kErrorConnectFailed);
232 } 248 }
233 249
234 TEST_F(NetworkConnectTest, ShowNetworkSettings_CellOutOfCredits) { 250 TEST_F(NetworkConnectTest, ShowNetworkSettings_CellOutOfCredits) {
235 EXPECT_CALL(*mock_delegate_, ShowNetworkSettings(kCellular1Guid)).Times(0); 251 EXPECT_CALL(*mock_delegate_, ShowNetworkSettings(kCellular1Guid)).Times(0);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 TEST_F(NetworkConnectTest, ConnectToTetherNetwork_TetherDelegateNotSet) { 352 TEST_F(NetworkConnectTest, ConnectToTetherNetwork_TetherDelegateNotSet) {
337 EXPECT_CALL(*mock_tether_delegate_, ConnectToNetwork(_)).Times(0); 353 EXPECT_CALL(*mock_tether_delegate_, ConnectToNetwork(_)).Times(0);
338 354
339 NetworkHandler::Get()->network_state_handler()->AddTetherNetworkState( 355 NetworkHandler::Get()->network_state_handler()->AddTetherNetworkState(
340 kTether1Guid, "TetherNetwork"); 356 kTether1Guid, "TetherNetwork");
341 357
342 NetworkConnect::Get()->ConnectToNetworkId(kTether1Guid); 358 NetworkConnect::Get()->ConnectToNetworkId(kTether1Guid);
343 } 359 }
344 360
345 } // namespace chromeos 361 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/network/network_connect.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698