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

Side by Side Diff: chromeos/components/tether/network_connection_handler_tether_delegate_unittest.cc

Issue 2858943003: [CrOS Tether] Add disconnect handling to NetworkConnectionHandler::TetherDelegate. (Closed)
Patch Set: Rebased. Created 3 years, 7 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/components/tether/network_connection_handler_tether_delegate. h" 5 #include "chromeos/components/tether/network_connection_handler_tether_delegate. h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "chromeos/components/tether/tether_connector.h" 9 #include "chromeos/components/tether/tether_connector.h"
10 #include "chromeos/components/tether/tether_disconnector.h" 10 #include "chromeos/components/tether/tether_disconnector.h"
(...skipping 15 matching lines...) Expand all
26 TestNetworkConnectionHandler() : NetworkConnectionHandler() {} 26 TestNetworkConnectionHandler() : NetworkConnectionHandler() {}
27 ~TestNetworkConnectionHandler() override {} 27 ~TestNetworkConnectionHandler() override {}
28 28
29 void CallTetherConnect(const std::string& tether_network_guid, 29 void CallTetherConnect(const std::string& tether_network_guid,
30 const base::Closure& success_callback, 30 const base::Closure& success_callback,
31 const network_handler::ErrorCallback& error_callback) { 31 const network_handler::ErrorCallback& error_callback) {
32 InitiateTetherNetworkConnection(tether_network_guid, success_callback, 32 InitiateTetherNetworkConnection(tether_network_guid, success_callback,
33 error_callback); 33 error_callback);
34 } 34 }
35 35
36 void CallTetherDisconnect(
37 const std::string& tether_network_guid,
38 const base::Closure& success_callback,
39 const network_handler::ErrorCallback& error_callback) {
40 InitiateTetherNetworkDisconnection(tether_network_guid, success_callback,
41 error_callback);
42 }
43
36 // NetworkConnectionHandler: 44 // NetworkConnectionHandler:
37 void ConnectToNetwork(const std::string& service_path, 45 void ConnectToNetwork(const std::string& service_path,
38 const base::Closure& success_callback, 46 const base::Closure& success_callback,
39 const network_handler::ErrorCallback& error_callback, 47 const network_handler::ErrorCallback& error_callback,
40 bool check_error_state) override {} 48 bool check_error_state) override {}
41 49
42 void DisconnectNetwork( 50 void DisconnectNetwork(
43 const std::string& service_path, 51 const std::string& service_path,
44 const base::Closure& success_callback, 52 const base::Closure& success_callback,
45 const network_handler::ErrorCallback& error_callback) override {} 53 const network_handler::ErrorCallback& error_callback) override {}
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 nullptr /* network_state_handler */, 90 nullptr /* network_state_handler */,
83 nullptr /* active_host */, 91 nullptr /* active_host */,
84 nullptr /* ble_connection_manager */, 92 nullptr /* ble_connection_manager */,
85 nullptr /* network_configuration_remover */, 93 nullptr /* network_configuration_remover */,
86 nullptr /* tether_connector */, 94 nullptr /* tether_connector */,
87 nullptr /* device_id_tether_network_guid_map */, 95 nullptr /* device_id_tether_network_guid_map */,
88 nullptr /* tether_host_fetcher */) {} 96 nullptr /* tether_host_fetcher */) {}
89 ~MockTetherDisconnector() override {} 97 ~MockTetherDisconnector() override {}
90 98
91 MOCK_METHOD3( 99 MOCK_METHOD3(
92 DisconnectFomNetwork, 100 DisconnectFromNetwork,
93 void(const std::string& tether_network_guid, 101 void(const std::string& tether_network_guid,
94 const base::Closure& success_callback, 102 const base::Closure& success_callback,
95 const network_handler::StringResultCallback& error_callback)); 103 const network_handler::StringResultCallback& error_callback));
96 }; 104 };
97 105
98 } // namespace 106 } // namespace
99 107
100 // TODO(khorimoto): Also write a test for disconnection. This is part of a
101 // follow-up CL.
102 class NetworkConnectionHandlerTetherDelegateTest : public testing::Test { 108 class NetworkConnectionHandlerTetherDelegateTest : public testing::Test {
103 protected: 109 protected:
104 NetworkConnectionHandlerTetherDelegateTest() {} 110 NetworkConnectionHandlerTetherDelegateTest() {}
105 111
106 void SetUp() override { 112 void SetUp() override {
107 test_network_connection_handler_ = 113 test_network_connection_handler_ =
108 base::WrapUnique(new TestNetworkConnectionHandler()); 114 base::WrapUnique(new TestNetworkConnectionHandler());
109 mock_tether_connector_ = 115 mock_tether_connector_ =
110 base::WrapUnique(new NiceMock<MockTetherConnector>()); 116 base::WrapUnique(new NiceMock<MockTetherConnector>());
111 mock_tether_disconnector_ = 117 mock_tether_disconnector_ =
(...skipping 15 matching lines...) Expand all
127 DISALLOW_COPY_AND_ASSIGN(NetworkConnectionHandlerTetherDelegateTest); 133 DISALLOW_COPY_AND_ASSIGN(NetworkConnectionHandlerTetherDelegateTest);
128 }; 134 };
129 135
130 TEST_F(NetworkConnectionHandlerTetherDelegateTest, TestConnect) { 136 TEST_F(NetworkConnectionHandlerTetherDelegateTest, TestConnect) {
131 EXPECT_CALL(*mock_tether_connector_, ConnectToNetwork(_, _, _)); 137 EXPECT_CALL(*mock_tether_connector_, ConnectToNetwork(_, _, _));
132 138
133 test_network_connection_handler_->CallTetherConnect( 139 test_network_connection_handler_->CallTetherConnect(
134 "tetherNetworkGuid", base::Closure(), network_handler::ErrorCallback()); 140 "tetherNetworkGuid", base::Closure(), network_handler::ErrorCallback());
135 } 141 }
136 142
143 TEST_F(NetworkConnectionHandlerTetherDelegateTest, TestDisconnect) {
144 EXPECT_CALL(*mock_tether_disconnector_, DisconnectFromNetwork(_, _, _));
145
146 test_network_connection_handler_->CallTetherDisconnect(
147 "tetherNetworkGuid", base::Closure(), network_handler::ErrorCallback());
148 }
149
137 } // namespace tether 150 } // namespace tether
138 151
139 } // namespace cryptauth 152 } // namespace cryptauth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698