blob: 2b1f1e95b655b6c94c3fa2cd85ec20c9898bae2b [file] [log] [blame]
Eric Shienbrood5de44ab2011-12-05 10:46:27 -05001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "shill/cellular_capability_gsm.h"
6
Eric Shienbrood9a245532012-03-07 14:20:39 -05007#include <base/bind.h>
Eric Shienbrood5de44ab2011-12-05 10:46:27 -05008#include <chromeos/dbus/service_constants.h>
9#include <gtest/gtest.h>
10#include <mm/mm-modem.h>
11#include <mobile_provider.h>
12
13#include "shill/cellular.h"
14#include "shill/cellular_service.h"
15#include "shill/error.h"
16#include "shill/event_dispatcher.h"
17#include "shill/mock_adaptors.h"
Eric Shienbrood9a245532012-03-07 14:20:39 -050018#include "shill/mock_glib.h"
19#include "shill/mock_manager.h"
20#include "shill/mock_metrics.h"
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050021#include "shill/mock_modem_cdma_proxy.h"
22#include "shill/mock_modem_gsm_card_proxy.h"
23#include "shill/mock_modem_gsm_network_proxy.h"
24#include "shill/mock_modem_proxy.h"
25#include "shill/mock_modem_simple_proxy.h"
Eric Shienbrood30bc0ec2012-03-21 18:19:46 -040026#include "shill/mock_profile.h"
Eric Shienbrood9a245532012-03-07 14:20:39 -050027#include "shill/mock_rtnl_handler.h"
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050028#include "shill/nice_mock_control.h"
29#include "shill/proxy_factory.h"
30
Eric Shienbrood9a245532012-03-07 14:20:39 -050031using base::Bind;
32using base::Unretained;
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050033using std::string;
Darin Petkov9c1dcef2012-02-07 15:58:26 +010034using testing::InSequence;
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050035using testing::NiceMock;
Eric Shienbrood9a245532012-03-07 14:20:39 -050036using testing::_;
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050037
38namespace shill {
39
Eric Shienbrood9a245532012-03-07 14:20:39 -050040MATCHER(IsSuccess, "") {
41 return arg.IsSuccess();
42}
43MATCHER(IsFailure, "") {
44 return arg.IsFailure();
45}
46
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050047class CellularCapabilityTest : public testing::Test {
48 public:
49 CellularCapabilityTest()
Eric Shienbrood9a245532012-03-07 14:20:39 -050050 : manager_(&control_, &dispatcher_, &metrics_, &glib_),
51 cellular_(new Cellular(&control_,
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050052 &dispatcher_,
53 NULL,
Eric Shienbrood9a245532012-03-07 14:20:39 -050054 &manager_,
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050055 "",
56 "",
57 0,
58 Cellular::kTypeGSM,
59 "",
60 "",
61 NULL)),
62 proxy_(new MockModemProxy()),
63 simple_proxy_(new MockModemSimpleProxy()),
64 cdma_proxy_(new MockModemCDMAProxy()),
65 gsm_card_proxy_(new MockModemGSMCardProxy()),
66 gsm_network_proxy_(new MockModemGSMNetworkProxy()),
67 proxy_factory_(this),
68 capability_(NULL),
Eric Shienbrood30bc0ec2012-03-21 18:19:46 -040069 device_adaptor_(NULL),
70 provider_db_(NULL) {}
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050071
72 virtual ~CellularCapabilityTest() {
73 cellular_->service_ = NULL;
74 capability_ = NULL;
75 device_adaptor_ = NULL;
Eric Shienbrood30bc0ec2012-03-21 18:19:46 -040076 mobile_provider_close_db(provider_db_);
77 provider_db_ = NULL;
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050078 }
79
80 virtual void SetUp() {
Eric Shienbrood9a245532012-03-07 14:20:39 -050081 static_cast<Device *>(cellular_)->rtnl_handler_ = &rtnl_handler_;
Jason Glasgow82f9ab32012-04-04 14:27:19 -040082
83 capability_ = dynamic_cast<CellularCapabilityClassic *>(
84 cellular_->capability_.get());
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050085 device_adaptor_ =
86 dynamic_cast<NiceMock<DeviceMockAdaptor> *>(cellular_->adaptor());
87 }
88
89 virtual void TearDown() {
90 capability_->proxy_factory_ = NULL;
91 }
92
Eric Shienbrood30bc0ec2012-03-21 18:19:46 -040093 void InitProviderDB() {
94 provider_db_ = mobile_provider_open_db(kTestMobileProviderDBPath);
95 ASSERT_TRUE(provider_db_);
96 cellular_->provider_db_ = provider_db_;
97 }
98
99 void SetService() {
100 cellular_->service_ = new CellularService(
101 &control_, &dispatcher_, &metrics_, NULL, cellular_);
102 }
103
104 CellularCapabilityGSM *GetGsmCapability() {
105 return dynamic_cast<CellularCapabilityGSM *>(cellular_->capability_.get());
106 }
107
Eric Shienbrood9a245532012-03-07 14:20:39 -0500108 void InvokeEnable(bool enable, Error *error,
109 const ResultCallback &callback, int timeout) {
110 callback.Run(Error());
111 }
112 void InvokeEnableFail(bool enable, Error *error,
113 const ResultCallback &callback, int timeout) {
114 callback.Run(Error(Error::kOperationFailed));
115 }
116 void InvokeDisconnect(Error *error, const ResultCallback &callback,
117 int timeout) {
118 callback.Run(Error());
119 }
Thieu Le923006b2012-04-05 16:32:58 -0700120 void InvokeDisconnectFail(Error *error, const ResultCallback &callback,
121 int timeout) {
122 callback.Run(Error(Error::kOperationFailed));
123 }
Eric Shienbrood9a245532012-03-07 14:20:39 -0500124 void InvokeGetModemStatus(Error *error,
125 const DBusPropertyMapCallback &callback,
126 int timeout) {
127 DBusPropertiesMap props;
128 props["carrier"].writer().append_string(kTestCarrier);
129 props["unknown-property"].writer().append_string("irrelevant-value");
130 callback.Run(props, Error());
131 }
132 void InvokeGetModemInfo(Error *error, const ModemInfoCallback &callback,
133 int timeout) {
134 ModemHardwareInfo info;
135 info._1 = kManufacturer;
136 info._2 = kModelID;
137 info._3 = kHWRev;
138 callback.Run(info, Error());
139 }
140
141 MOCK_METHOD1(TestCallback, void(const Error &error));
142
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500143 protected:
Eric Shienbrood30bc0ec2012-03-21 18:19:46 -0400144 static const char kTestMobileProviderDBPath[];
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500145 static const char kTestCarrier[];
Eric Shienbrood9a245532012-03-07 14:20:39 -0500146 static const char kManufacturer[];
147 static const char kModelID[];
148 static const char kHWRev[];
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500149
150 class TestProxyFactory : public ProxyFactory {
151 public:
152 explicit TestProxyFactory(CellularCapabilityTest *test) : test_(test) {}
153
154 virtual ModemProxyInterface *CreateModemProxy(
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500155 const string &/*path*/,
156 const string &/*service*/) {
157 return test_->proxy_.release();
158 }
159
160 virtual ModemSimpleProxyInterface *CreateModemSimpleProxy(
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500161 const string &/*path*/,
162 const string &/*service*/) {
163 return test_->simple_proxy_.release();
164 }
165
166 virtual ModemCDMAProxyInterface *CreateModemCDMAProxy(
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500167 const string &/*path*/,
168 const string &/*service*/) {
169 return test_->cdma_proxy_.release();
170 }
171
172 virtual ModemGSMCardProxyInterface *CreateModemGSMCardProxy(
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500173 const string &/*path*/,
174 const string &/*service*/) {
175 return test_->gsm_card_proxy_.release();
176 }
177
178 virtual ModemGSMNetworkProxyInterface *CreateModemGSMNetworkProxy(
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500179 const string &/*path*/,
180 const string &/*service*/) {
181 return test_->gsm_network_proxy_.release();
182 }
183
184 private:
185 CellularCapabilityTest *test_;
186 };
187
188 void SetProxy() {
189 capability_->proxy_.reset(proxy_.release());
190 }
191
192 void SetSimpleProxy() {
193 capability_->simple_proxy_.reset(simple_proxy_.release());
194 }
195
Eric Shienbrood9a245532012-03-07 14:20:39 -0500196 void SetGSMNetworkProxy() {
197 CellularCapabilityGSM *gsm_capability =
198 dynamic_cast<CellularCapabilityGSM *>(cellular_->capability_.get());
199 gsm_capability->network_proxy_.reset(gsm_network_proxy_.release());
200 }
201
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500202 void SetCellularType(Cellular::Type type) {
203 cellular_->InitCapability(type, &proxy_factory_);
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400204 capability_ = dynamic_cast<CellularCapabilityClassic *>(
205 cellular_->capability_.get());
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500206 }
207
208 NiceMockControl control_;
209 EventDispatcher dispatcher_;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500210 MockMetrics metrics_;
211 MockGLib glib_;
212 MockManager manager_;
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500213 CellularRefPtr cellular_;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500214 MockRTNLHandler rtnl_handler_;
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500215 scoped_ptr<MockModemProxy> proxy_;
216 scoped_ptr<MockModemSimpleProxy> simple_proxy_;
217 scoped_ptr<MockModemCDMAProxy> cdma_proxy_;
218 scoped_ptr<MockModemGSMCardProxy> gsm_card_proxy_;
219 scoped_ptr<MockModemGSMNetworkProxy> gsm_network_proxy_;
220 TestProxyFactory proxy_factory_;
Jason Glasgow82f9ab32012-04-04 14:27:19 -0400221 CellularCapabilityClassic *capability_; // Owned by |cellular_|.
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500222 NiceMock<DeviceMockAdaptor> *device_adaptor_; // Owned by |cellular_|.
Eric Shienbrood30bc0ec2012-03-21 18:19:46 -0400223 mobile_provider_db *provider_db_;
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500224};
225
Eric Shienbrood30bc0ec2012-03-21 18:19:46 -0400226const char CellularCapabilityTest::kTestMobileProviderDBPath[] =
227 "provider_db_unittest.bfd";
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500228const char CellularCapabilityTest::kTestCarrier[] = "The Cellular Carrier";
Eric Shienbrood9a245532012-03-07 14:20:39 -0500229const char CellularCapabilityTest::kManufacturer[] = "Company";
230const char CellularCapabilityTest::kModelID[] = "Gobi 2000";
231const char CellularCapabilityTest::kHWRev[] = "A00B1234";
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500232
233TEST_F(CellularCapabilityTest, GetModemStatus) {
234 SetCellularType(Cellular::kTypeCDMA);
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500235 EXPECT_CALL(*simple_proxy_,
Eric Shienbrood9a245532012-03-07 14:20:39 -0500236 GetModemStatus(_, _, CellularCapability::kTimeoutDefault)).
237 WillOnce(Invoke(this, &CellularCapabilityTest::InvokeGetModemStatus));
238 EXPECT_CALL(*this, TestCallback(IsSuccess()));
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500239 SetSimpleProxy();
Eric Shienbrood9a245532012-03-07 14:20:39 -0500240 ResultCallback callback =
241 Bind(&CellularCapabilityTest::TestCallback, Unretained(this));
242 capability_->GetModemStatus(callback);
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500243 EXPECT_EQ(kTestCarrier, capability_->carrier_);
244 EXPECT_EQ(kTestCarrier, cellular_->home_provider_.GetName());
245}
246
247TEST_F(CellularCapabilityTest, GetModemInfo) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500248 EXPECT_CALL(*proxy_, GetModemInfo(_, _, CellularCapability::kTimeoutDefault))
249 .WillOnce(Invoke(this, &CellularCapabilityTest::InvokeGetModemInfo));
250 EXPECT_CALL(*this, TestCallback(IsSuccess()));
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500251 SetProxy();
Eric Shienbrood9a245532012-03-07 14:20:39 -0500252 ResultCallback callback =
253 Bind(&CellularCapabilityTest::TestCallback, Unretained(this));
254 capability_->GetModemInfo(callback);
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500255 EXPECT_EQ(kManufacturer, capability_->manufacturer_);
256 EXPECT_EQ(kModelID, capability_->model_id_);
257 EXPECT_EQ(kHWRev, capability_->hardware_revision_);
258}
259
260TEST_F(CellularCapabilityTest, EnableModemSucceed) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500261 EXPECT_CALL(*proxy_, Enable(true, _, _, CellularCapability::kTimeoutEnable))
262 .WillOnce(Invoke(this, &CellularCapabilityTest::InvokeEnable));
263 EXPECT_CALL(*this, TestCallback(IsSuccess()));
264 ResultCallback callback =
265 Bind(&CellularCapabilityTest::TestCallback, Unretained(this));
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500266 SetProxy();
Eric Shienbrood9a245532012-03-07 14:20:39 -0500267 capability_->EnableModem(callback);
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500268}
269
270TEST_F(CellularCapabilityTest, EnableModemFail) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500271 EXPECT_CALL(*proxy_, Enable(true, _, _, CellularCapability::kTimeoutEnable))
272 .WillOnce(Invoke(this, &CellularCapabilityTest::InvokeEnableFail));
273 EXPECT_CALL(*this, TestCallback(IsFailure()));
274 ResultCallback callback =
275 Bind(&CellularCapabilityTest::TestCallback, Unretained(this));
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500276 SetProxy();
Eric Shienbrood9a245532012-03-07 14:20:39 -0500277 capability_->EnableModem(callback);
278}
279
280TEST_F(CellularCapabilityTest, FinishEnable) {
281 EXPECT_CALL(*gsm_network_proxy_,
282 GetRegistrationInfo(NULL, _,
283 CellularCapability::kTimeoutDefault));
284 EXPECT_CALL(*gsm_network_proxy_,
285 GetSignalQuality(NULL, _, CellularCapability::kTimeoutDefault));
286 EXPECT_CALL(*this, TestCallback(IsSuccess()));
287 SetGSMNetworkProxy();
288 capability_->FinishEnable(
289 Bind(&CellularCapabilityTest::TestCallback, Unretained(this)));
290}
291
292TEST_F(CellularCapabilityTest, UnsupportedOperation) {
293 Error error;
294 EXPECT_CALL(*this, TestCallback(IsSuccess())).Times(0);
295 capability_->CellularCapability::Scan(&error,
296 Bind(&CellularCapabilityTest::TestCallback, Unretained(this)));
297 EXPECT_TRUE(error.IsFailure());
298 EXPECT_EQ(Error::kNotSupported, error.type());
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500299}
300
Darin Petkov9c1dcef2012-02-07 15:58:26 +0100301TEST_F(CellularCapabilityTest, AllowRoaming) {
302 EXPECT_FALSE(capability_->GetAllowRoaming(NULL));
303 capability_->SetAllowRoaming(false, NULL);
304 EXPECT_FALSE(capability_->GetAllowRoaming(NULL));
305
306 {
307 InSequence seq;
308 EXPECT_CALL(*device_adaptor_, EmitBoolChanged(
309 flimflam::kCellularAllowRoamingProperty, true));
310 EXPECT_CALL(*device_adaptor_, EmitBoolChanged(
311 flimflam::kCellularAllowRoamingProperty, false));
312 }
313
314 cellular_->state_ = Cellular::kStateConnected;
315 dynamic_cast<CellularCapabilityGSM *>(capability_)->registration_state_ =
316 MM_MODEM_GSM_NETWORK_REG_STATUS_ROAMING;
317 capability_->SetAllowRoaming(true, NULL);
318 EXPECT_TRUE(capability_->GetAllowRoaming(NULL));
319 EXPECT_EQ(Cellular::kStateConnected, cellular_->state_);
320
Eric Shienbrood9a245532012-03-07 14:20:39 -0500321 EXPECT_CALL(*proxy_, Disconnect(_, _, CellularCapability::kTimeoutDefault))
322 .WillOnce(Invoke(this, &CellularCapabilityTest::InvokeDisconnect));
Darin Petkov9c1dcef2012-02-07 15:58:26 +0100323 SetProxy();
324 cellular_->state_ = Cellular::kStateConnected;
325 capability_->SetAllowRoaming(false, NULL);
326 EXPECT_FALSE(capability_->GetAllowRoaming(NULL));
327 EXPECT_EQ(Cellular::kStateRegistered, cellular_->state_);
328}
329
Eric Shienbrood30bc0ec2012-03-21 18:19:46 -0400330MATCHER_P(HasApn, apn, "") {
331 DBusPropertiesMap::const_iterator it = arg.find(flimflam::kApnProperty);
332 return it != arg.end() && apn == it->second.reader().get_string();
333}
334
335MATCHER(HasNoApn, "") {
336 return arg.find(flimflam::kApnProperty) == arg.end();
337}
338
339TEST_F(CellularCapabilityTest, TryApns) {
340 static const string kLastGoodApn("remembered.apn");
341 static const string kSuppliedApn("my.apn");
342 static const string kTmobileApn1("epc.tmobile.com");
343 static const string kTmobileApn2("wap.voicestream.com");
344 static const string kTmobileApn3("internet2.voicestream.com");
345 static const string kTmobileApn4("internet3.voicestream.com");
346
347 using testing::InSequence;
348 {
349 InSequence dummy;
350 EXPECT_CALL(*simple_proxy_, Connect(HasApn(kLastGoodApn), _, _, _));
351 EXPECT_CALL(*simple_proxy_, Connect(HasApn(kSuppliedApn), _, _, _));
352 EXPECT_CALL(*simple_proxy_, Connect(HasApn(kTmobileApn1), _, _, _));
353 EXPECT_CALL(*simple_proxy_, Connect(HasApn(kTmobileApn2), _, _, _));
354 EXPECT_CALL(*simple_proxy_, Connect(HasApn(kTmobileApn3), _, _, _));
355 EXPECT_CALL(*simple_proxy_, Connect(HasApn(kTmobileApn4), _, _, _));
356 EXPECT_CALL(*simple_proxy_, Connect(HasNoApn(), _, _, _));
357 }
358 CellularCapabilityGSM *gsm_capability = GetGsmCapability();
359 SetService();
360 gsm_capability->imsi_ = "310240123456789";
361 InitProviderDB();
362 gsm_capability->SetHomeProvider();
363 ProfileRefPtr profile(new NiceMock<MockProfile>(
364 &control_, reinterpret_cast<Manager *>(NULL)));
365 cellular_->service()->set_profile(profile);
366
367 Error error;
368 Stringmap apn_info;
369 DBusPropertiesMap props;
370 apn_info[flimflam::kApnProperty] = kSuppliedApn;
371 cellular_->service()->SetApn(apn_info, &error);
372
373 apn_info.clear();
374 apn_info[flimflam::kApnProperty] = kLastGoodApn;
375 cellular_->service()->SetLastGoodApn(apn_info);
376
377 capability_->SetupConnectProperties(&props);
378 // We expect the list to contain the last good APN, plus
379 // the user-supplied APN, plus the 4 APNs from the mobile
380 // provider info database.
381 EXPECT_EQ(6, gsm_capability->apn_try_list_.size());
382 EXPECT_FALSE(props.find(flimflam::kApnProperty) == props.end());
383 EXPECT_EQ(kLastGoodApn, props[flimflam::kApnProperty].reader().get_string());
384
385 SetSimpleProxy();
386 capability_->Connect(props, &error, ResultCallback());
387 Error cerror(Error::kInvalidApn);
Nathan Williamsb54974f2012-04-19 11:16:30 -0400388 gsm_capability->OnConnectReply(ResultCallback(), cerror);
Eric Shienbrood30bc0ec2012-03-21 18:19:46 -0400389 EXPECT_EQ(5, gsm_capability->apn_try_list_.size());
Nathan Williamsb54974f2012-04-19 11:16:30 -0400390 gsm_capability->OnConnectReply(ResultCallback(), cerror);
Eric Shienbrood30bc0ec2012-03-21 18:19:46 -0400391 EXPECT_EQ(4, gsm_capability->apn_try_list_.size());
Nathan Williamsb54974f2012-04-19 11:16:30 -0400392 gsm_capability->OnConnectReply(ResultCallback(), cerror);
Eric Shienbrood30bc0ec2012-03-21 18:19:46 -0400393 EXPECT_EQ(3, gsm_capability->apn_try_list_.size());
Nathan Williamsb54974f2012-04-19 11:16:30 -0400394 gsm_capability->OnConnectReply(ResultCallback(), cerror);
Eric Shienbrood30bc0ec2012-03-21 18:19:46 -0400395 EXPECT_EQ(2, gsm_capability->apn_try_list_.size());
Nathan Williamsb54974f2012-04-19 11:16:30 -0400396 gsm_capability->OnConnectReply(ResultCallback(), cerror);
Eric Shienbrood30bc0ec2012-03-21 18:19:46 -0400397 EXPECT_EQ(1, gsm_capability->apn_try_list_.size());
Nathan Williamsb54974f2012-04-19 11:16:30 -0400398 gsm_capability->OnConnectReply(ResultCallback(), cerror);
Eric Shienbrood30bc0ec2012-03-21 18:19:46 -0400399 EXPECT_EQ(0, gsm_capability->apn_try_list_.size());
400}
401
Thieu Le923006b2012-04-05 16:32:58 -0700402TEST_F(CellularCapabilityTest, StopModemDisconnectSuccess) {
403 EXPECT_CALL(*proxy_, Disconnect(_, _, CellularCapability::kTimeoutDefault))
404 .WillOnce(Invoke(this,
405 &CellularCapabilityTest::InvokeDisconnect));
406 EXPECT_CALL(*proxy_, Enable(_, _, _, CellularCapability::kTimeoutDefault))
407 .WillOnce(Invoke(this,
408 &CellularCapabilityTest::InvokeEnable));
409 EXPECT_CALL(*this, TestCallback(IsSuccess()));
410 SetProxy();
411
412 Error error;
413 capability_->StopModem(
414 &error, Bind(&CellularCapabilityTest::TestCallback, Unretained(this)));
415 dispatcher_.DispatchPendingEvents();
416}
417
418TEST_F(CellularCapabilityTest, StopModemDisconnectFail) {
419 EXPECT_CALL(*proxy_, Disconnect(_, _, CellularCapability::kTimeoutDefault))
420 .WillOnce(Invoke(this,
421 &CellularCapabilityTest::InvokeDisconnectFail));
422 EXPECT_CALL(*proxy_, Enable(_, _, _, CellularCapability::kTimeoutDefault))
423 .WillOnce(Invoke(this,
424 &CellularCapabilityTest::InvokeEnable));
425 EXPECT_CALL(*this, TestCallback(IsSuccess()));
426 SetProxy();
427
428 Error error;
429 capability_->StopModem(
430 &error, Bind(&CellularCapabilityTest::TestCallback, Unretained(this)));
431 dispatcher_.DispatchPendingEvents();
432}
433
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500434} // namespace shill