blob: 3dd81e7c928318c79cba87d36ee24207822c5843 [file] [log] [blame]
Darin Petkovc64fe5e2012-01-11 12:46:13 +01001// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
Darin Petkovb05315f2011-11-07 10:14:25 +01002// 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
Jason Glasgow4c0724a2012-04-17 15:47:40 -04007#include <string>
8#include <vector>
9
Eric Shienbrood9a245532012-03-07 14:20:39 -050010#include <base/bind.h>
Darin Petkova4ca3c32012-08-17 16:05:24 +020011#include <base/stringprintf.h>
Darin Petkov20c13ec2011-11-09 15:07:15 +010012#include <chromeos/dbus/service_constants.h>
Darin Petkovb05315f2011-11-07 10:14:25 +010013#include <gtest/gtest.h>
Darin Petkov20c13ec2011-11-09 15:07:15 +010014#include <mm/mm-modem.h>
Darin Petkov1272a432011-11-10 15:53:37 +010015#include <mobile_provider.h>
Darin Petkovb05315f2011-11-07 10:14:25 +010016
17#include "shill/cellular.h"
Darin Petkov3e509242011-11-10 14:46:44 +010018#include "shill/cellular_service.h"
Darin Petkovb05315f2011-11-07 10:14:25 +010019#include "shill/error.h"
20#include "shill/event_dispatcher.h"
Darin Petkov3cfbf212011-11-21 16:02:09 +010021#include "shill/mock_adaptors.h"
Gary Morain82a31a02012-08-02 18:03:32 -070022#include "shill/mock_log.h"
Darin Petkovb05315f2011-11-07 10:14:25 +010023#include "shill/mock_modem_gsm_card_proxy.h"
Darin Petkov3e509242011-11-10 14:46:44 +010024#include "shill/mock_modem_gsm_network_proxy.h"
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070025#include "shill/mock_modem_info.h"
Thieu Le923006b2012-04-05 16:32:58 -070026#include "shill/mock_modem_proxy.h"
27#include "shill/mock_modem_simple_proxy.h"
Eric Shienbrood30bc0ec2012-03-21 18:19:46 -040028#include "shill/mock_profile.h"
Thieu Le923006b2012-04-05 16:32:58 -070029#include "shill/proxy_factory.h"
Darin Petkovb05315f2011-11-07 10:14:25 +010030
Eric Shienbrood9a245532012-03-07 14:20:39 -050031using base::Bind;
Darin Petkova4ca3c32012-08-17 16:05:24 +020032using base::StringPrintf;
Eric Shienbrood9a245532012-03-07 14:20:39 -050033using base::Unretained;
Darin Petkov31332412012-01-28 01:50:02 +010034using std::string;
Jason Glasgow4c0724a2012-04-17 15:47:40 -040035using std::vector;
Darin Petkove5bc2cb2011-12-07 14:47:32 +010036using testing::_;
Eric Shienbrood9a245532012-03-07 14:20:39 -050037using testing::Invoke;
Darin Petkov3cfbf212011-11-21 16:02:09 +010038using testing::NiceMock;
Darin Petkovcb547732011-11-09 13:55:26 +010039using testing::Return;
Jason Glasgowcd0349c2012-05-03 23:32:15 -040040using testing::SaveArg;
Paul Stewart1e5bad52012-08-04 17:13:19 -070041using testing::StrEq;
Darin Petkovcb547732011-11-09 13:55:26 +010042
Darin Petkovb05315f2011-11-07 10:14:25 +010043namespace shill {
44
Eric Shienbrood9a245532012-03-07 14:20:39 -050045MATCHER(IsSuccess, "") {
46 return arg.IsSuccess();
47}
Eric Shienbrood5de44ab2011-12-05 10:46:27 -050048
Thieu Leb5954a22012-05-18 10:37:34 -070049MATCHER(IsFailure, "") {
50 return arg.IsFailure();
51}
52
Darin Petkovb05315f2011-11-07 10:14:25 +010053class CellularCapabilityGSMTest : public testing::Test {
54 public:
55 CellularCapabilityGSMTest()
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070056 : modem_info_(NULL, &dispatcher_, NULL, NULL, NULL),
Thieu Le6c1e3bb2013-02-06 15:20:35 -080057 create_card_proxy_from_factory_(false),
Ben Chan3ecdf822012-08-06 12:29:23 -070058 proxy_(new MockModemProxy()),
59 simple_proxy_(new MockModemSimpleProxy()),
60 card_proxy_(new MockModemGSMCardProxy()),
61 network_proxy_(new MockModemGSMNetworkProxy()),
62 proxy_factory_(this),
63 capability_(NULL),
64 device_adaptor_(NULL),
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070065 cellular_(new Cellular(&modem_info_,
Darin Petkovb05315f2011-11-07 10:14:25 +010066 "",
Darin Petkov31332412012-01-28 01:50:02 +010067 kAddress,
Darin Petkovb05315f2011-11-07 10:14:25 +010068 0,
69 Cellular::kTypeGSM,
70 "",
71 "",
Jason Glasgowa585fc32012-06-06 11:04:09 -040072 "",
Thieu Lece4483e2013-01-23 15:12:03 -080073 &proxy_factory_)) {
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070074 modem_info_.metrics()->RegisterDevice(cellular_->interface_index(),
75 Technology::kCellular);
Thieu Lece4483e2013-01-23 15:12:03 -080076 }
Darin Petkovb05315f2011-11-07 10:14:25 +010077
Darin Petkov3e509242011-11-10 14:46:44 +010078 virtual ~CellularCapabilityGSMTest() {
79 cellular_->service_ = NULL;
Darin Petkov721ac932011-11-16 15:43:09 +010080 capability_ = NULL;
Darin Petkov3cfbf212011-11-21 16:02:09 +010081 device_adaptor_ = NULL;
Darin Petkov721ac932011-11-16 15:43:09 +010082 }
83
84 virtual void SetUp() {
85 capability_ =
86 dynamic_cast<CellularCapabilityGSM *>(cellular_->capability_.get());
Darin Petkov3cfbf212011-11-21 16:02:09 +010087 device_adaptor_ =
Prathmesh Prabhu27526f12013-03-25 19:42:18 -070088 dynamic_cast<DeviceMockAdaptor *>(cellular_->adaptor());
89 }
90
91 void InitProviderDB() {
92 modem_info_.SetProviderDB(kTestMobileProviderDBPath);
Darin Petkov3e509242011-11-10 14:46:44 +010093 }
94
Thieu Le923006b2012-04-05 16:32:58 -070095 void InvokeEnable(bool enable, Error *error,
96 const ResultCallback &callback, int timeout) {
97 callback.Run(Error());
98 }
Eric Shienbrood9a245532012-03-07 14:20:39 -050099 void InvokeGetIMEI(Error *error, const GSMIdentifierCallback &callback,
100 int timeout) {
101 callback.Run(kIMEI, Error());
102 }
103 void InvokeGetIMSI(Error *error, const GSMIdentifierCallback &callback,
104 int timeout) {
105 callback.Run(kIMSI, Error());
106 }
107 void InvokeGetIMSI2(Error *error, const GSMIdentifierCallback &callback,
108 int timeout) {
109 callback.Run("310240123456789", Error());
110 }
Gary Morain82a31a02012-08-02 18:03:32 -0700111 void InvokeGetIMSIFails(Error *error, const GSMIdentifierCallback &callback,
112 int timeout) {
113 callback.Run("", Error(Error::kOperationFailed));
114 }
Eric Shienbrood9a245532012-03-07 14:20:39 -0500115 void InvokeGetMSISDN(Error *error, const GSMIdentifierCallback &callback,
116 int timeout) {
117 callback.Run(kMSISDN, Error());
118 }
Thieu Le923006b2012-04-05 16:32:58 -0700119 void InvokeGetMSISDNFail(Error *error, const GSMIdentifierCallback &callback,
120 int timeout) {
121 callback.Run("", Error(Error::kOperationFailed));
122 }
Eric Shienbrood9a245532012-03-07 14:20:39 -0500123 void InvokeGetSPN(Error *error, const GSMIdentifierCallback &callback,
124 int timeout) {
125 callback.Run(kTestCarrier, Error());
126 }
Thieu Le923006b2012-04-05 16:32:58 -0700127 void InvokeGetSPNFail(Error *error, const GSMIdentifierCallback &callback,
128 int timeout) {
129 callback.Run("", Error(Error::kOperationFailed));
130 }
Eric Shienbrood9a245532012-03-07 14:20:39 -0500131 void InvokeGetSignalQuality(Error *error,
132 const SignalQualityCallback &callback,
133 int timeout) {
134 callback.Run(kStrength, Error());
135 }
136 void InvokeGetRegistrationInfo(Error *error,
137 const RegistrationInfoCallback &callback,
138 int timeout) {
139 callback.Run(MM_MODEM_GSM_NETWORK_REG_STATUS_HOME,
140 kTestNetwork, kTestCarrier, Error());
141 }
142 void InvokeRegister(const string &network_id,
143 Error *error,
144 const ResultCallback &callback,
145 int timeout) {
146 callback.Run(Error());
147 }
148 void InvokeEnablePIN(const string &pin, bool enable,
149 Error *error, const ResultCallback &callback,
150 int timeout) {
151 callback.Run(Error());
152 }
153 void InvokeSendPIN(const string &pin, Error *error,
154 const ResultCallback &callback, int timeout) {
155 callback.Run(Error());
156 }
157 void InvokeSendPUK(const string &puk, const string &pin, Error *error,
158 const ResultCallback &callback, int timeout) {
159 callback.Run(Error());
160 }
161 void InvokeChangePIN(const string &old_pin, const string &pin, Error *error,
162 const ResultCallback &callback, int timeout) {
163 callback.Run(Error());
164 }
Jason Glasgowcd0349c2012-05-03 23:32:15 -0400165 void InvokeScanReply() {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500166 GSMScanResults results;
167 results.push_back(GSMScanResult());
168 results[0][CellularCapabilityGSM::kNetworkPropertyID] = kScanID0;
169 results.push_back(GSMScanResult());
170 results[1][CellularCapabilityGSM::kNetworkPropertyID] = kScanID1;
Jason Glasgowcd0349c2012-05-03 23:32:15 -0400171 scan_callback_.Run(results, Error());
Eric Shienbrood9a245532012-03-07 14:20:39 -0500172 }
Thieu Le923006b2012-04-05 16:32:58 -0700173 void InvokeGetModemStatus(Error *error,
174 const DBusPropertyMapCallback &callback,
175 int timeout) {
176 DBusPropertiesMap props;
177 callback.Run(props, Error());
178 }
179 void InvokeGetModemInfo(Error *error, const ModemInfoCallback &callback,
180 int timeout) {
181 ModemHardwareInfo info;
182 callback.Run(info, Error());
183 }
Eric Shienbrood9a245532012-03-07 14:20:39 -0500184
Thieu Leb5954a22012-05-18 10:37:34 -0700185 void InvokeConnectFail(DBusPropertiesMap props, Error *error,
186 const ResultCallback &callback, int timeout) {
187 callback.Run(Error(Error::kOperationFailed));
188 }
189
Eric Shienbrood9a245532012-03-07 14:20:39 -0500190 MOCK_METHOD1(TestCallback, void(const Error &error));
191
Darin Petkovb05315f2011-11-07 10:14:25 +0100192 protected:
Darin Petkov31332412012-01-28 01:50:02 +0100193 static const char kAddress[];
Darin Petkov1272a432011-11-10 15:53:37 +0100194 static const char kTestMobileProviderDBPath[];
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500195 static const char kTestNetwork[];
Darin Petkovcb547732011-11-09 13:55:26 +0100196 static const char kTestCarrier[];
Darin Petkovb05315f2011-11-07 10:14:25 +0100197 static const char kPIN[];
198 static const char kPUK[];
Darin Petkovcb547732011-11-09 13:55:26 +0100199 static const char kIMEI[];
200 static const char kIMSI[];
201 static const char kMSISDN[];
Eric Shienbrood9a245532012-03-07 14:20:39 -0500202 static const char kScanID0[];
203 static const char kScanID1[];
204 static const int kStrength;
Darin Petkovcb547732011-11-09 13:55:26 +0100205
Thieu Le923006b2012-04-05 16:32:58 -0700206 class TestProxyFactory : public ProxyFactory {
207 public:
208 explicit TestProxyFactory(CellularCapabilityGSMTest *test) : test_(test) {}
209
210 virtual ModemProxyInterface *CreateModemProxy(
211 const string &/*path*/,
212 const string &/*service*/) {
213 return test_->proxy_.release();
214 }
215
216 virtual ModemSimpleProxyInterface *CreateModemSimpleProxy(
217 const string &/*path*/,
218 const string &/*service*/) {
219 return test_->simple_proxy_.release();
220 }
221
222 virtual ModemGSMCardProxyInterface *CreateModemGSMCardProxy(
223 const string &/*path*/,
224 const string &/*service*/) {
Ben Chan3ecdf822012-08-06 12:29:23 -0700225 // TODO(benchan): This code conditionally returns a NULL pointer to avoid
226 // CellularCapabilityGSM::InitProperties (and thus
227 // CellularCapabilityGSM::GetIMSI) from being called during the
228 // construction. Remove this workaround after refactoring the tests.
229 return test_->create_card_proxy_from_factory_ ?
230 test_->card_proxy_.release() : NULL;
Thieu Le923006b2012-04-05 16:32:58 -0700231 }
232
233 virtual ModemGSMNetworkProxyInterface *CreateModemGSMNetworkProxy(
234 const string &/*path*/,
235 const string &/*service*/) {
236 return test_->network_proxy_.release();
237 }
238
239 private:
240 CellularCapabilityGSMTest *test_;
241 };
242
243 void SetProxy() {
244 capability_->proxy_.reset(proxy_.release());
245 }
246
Darin Petkovcb547732011-11-09 13:55:26 +0100247 void SetCardProxy() {
Darin Petkov721ac932011-11-16 15:43:09 +0100248 capability_->card_proxy_.reset(card_proxy_.release());
Darin Petkovcb547732011-11-09 13:55:26 +0100249 }
Darin Petkovb05315f2011-11-07 10:14:25 +0100250
Darin Petkov1272a432011-11-10 15:53:37 +0100251 void SetNetworkProxy() {
Darin Petkov721ac932011-11-16 15:43:09 +0100252 capability_->network_proxy_.reset(network_proxy_.release());
Darin Petkov1272a432011-11-10 15:53:37 +0100253 }
254
Darin Petkov20c13ec2011-11-09 15:07:15 +0100255 void SetAccessTechnology(uint32 technology) {
Darin Petkov721ac932011-11-16 15:43:09 +0100256 capability_->access_technology_ = technology;
Darin Petkov20c13ec2011-11-09 15:07:15 +0100257 }
258
259 void SetRegistrationState(uint32 state) {
Darin Petkov721ac932011-11-16 15:43:09 +0100260 capability_->registration_state_ = state;
Darin Petkov20c13ec2011-11-09 15:07:15 +0100261 }
262
Darin Petkov3e509242011-11-10 14:46:44 +0100263 void SetService() {
Prathmesh Prabhu0d36b4f2013-04-01 11:45:54 -0700264 cellular_->service_ = new CellularService(&modem_info_, cellular_);
Darin Petkov1272a432011-11-10 15:53:37 +0100265 }
266
Thieu Leb5954a22012-05-18 10:37:34 -0700267 void SetupCommonProxiesExpectations() {
Thieu Le923006b2012-04-05 16:32:58 -0700268 EXPECT_CALL(*proxy_, set_state_changed_callback(_));
269 EXPECT_CALL(*network_proxy_, set_signal_quality_callback(_));
270 EXPECT_CALL(*network_proxy_, set_network_mode_callback(_));
271 EXPECT_CALL(*network_proxy_, set_registration_info_callback(_));
Thieu Leb5954a22012-05-18 10:37:34 -0700272 }
273
274 void SetupCommonStartModemExpectations() {
275 SetupCommonProxiesExpectations();
Thieu Le923006b2012-04-05 16:32:58 -0700276
277 EXPECT_CALL(*proxy_, Enable(_, _, _, CellularCapability::kTimeoutEnable))
278 .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeEnable));
Thieu Le923006b2012-04-05 16:32:58 -0700279 EXPECT_CALL(*card_proxy_,
280 GetIMEI(_, _, CellularCapability::kTimeoutDefault))
281 .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeGetIMEI));
282 EXPECT_CALL(*card_proxy_,
283 GetIMSI(_, _, CellularCapability::kTimeoutDefault))
284 .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeGetIMSI));
285 EXPECT_CALL(*network_proxy_, AccessTechnology());
286 EXPECT_CALL(*card_proxy_, EnabledFacilityLocks());
287 EXPECT_CALL(*proxy_,
288 GetModemInfo(_, _, CellularCapability::kTimeoutDefault))
289 .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeGetModemInfo));
290 EXPECT_CALL(*network_proxy_,
291 GetRegistrationInfo(_, _, CellularCapability::kTimeoutDefault));
292 EXPECT_CALL(*network_proxy_,
293 GetSignalQuality(_, _, CellularCapability::kTimeoutDefault));
294 EXPECT_CALL(*this, TestCallback(IsSuccess()));
295 }
296
Thieu Leb5954a22012-05-18 10:37:34 -0700297 void InitProxies() {
Ben Chan3ecdf822012-08-06 12:29:23 -0700298 AllowCreateCardProxyFromFactory();
Thieu Leb5954a22012-05-18 10:37:34 -0700299 capability_->InitProxies();
300 }
301
Ben Chan3ecdf822012-08-06 12:29:23 -0700302 void AllowCreateCardProxyFromFactory() {
303 create_card_proxy_from_factory_ = true;
304 }
305
Darin Petkovb05315f2011-11-07 10:14:25 +0100306 EventDispatcher dispatcher_;
Prathmesh Prabhu27526f12013-03-25 19:42:18 -0700307 MockModemInfo modem_info_;
Ben Chan3ecdf822012-08-06 12:29:23 -0700308 bool create_card_proxy_from_factory_;
Thieu Le923006b2012-04-05 16:32:58 -0700309 scoped_ptr<MockModemProxy> proxy_;
310 scoped_ptr<MockModemSimpleProxy> simple_proxy_;
Darin Petkovcb547732011-11-09 13:55:26 +0100311 scoped_ptr<MockModemGSMCardProxy> card_proxy_;
Darin Petkov3e509242011-11-10 14:46:44 +0100312 scoped_ptr<MockModemGSMNetworkProxy> network_proxy_;
Thieu Le923006b2012-04-05 16:32:58 -0700313 TestProxyFactory proxy_factory_;
Darin Petkov721ac932011-11-16 15:43:09 +0100314 CellularCapabilityGSM *capability_; // Owned by |cellular_|.
Prathmesh Prabhu27526f12013-03-25 19:42:18 -0700315 DeviceMockAdaptor *device_adaptor_; // Owned by |cellular_|.
Ben Chan3ecdf822012-08-06 12:29:23 -0700316 CellularRefPtr cellular_;
Jason Glasgowcd0349c2012-05-03 23:32:15 -0400317 ScanResultsCallback scan_callback_; // saved for testing scan operations
Darin Petkovb05315f2011-11-07 10:14:25 +0100318};
319
Darin Petkov31332412012-01-28 01:50:02 +0100320const char CellularCapabilityGSMTest::kAddress[] = "1122334455";
Darin Petkov1272a432011-11-10 15:53:37 +0100321const char CellularCapabilityGSMTest::kTestMobileProviderDBPath[] =
322 "provider_db_unittest.bfd";
Darin Petkovcb547732011-11-09 13:55:26 +0100323const char CellularCapabilityGSMTest::kTestCarrier[] = "The Cellular Carrier";
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500324const char CellularCapabilityGSMTest::kTestNetwork[] = "310555";
Darin Petkovb05315f2011-11-07 10:14:25 +0100325const char CellularCapabilityGSMTest::kPIN[] = "9876";
326const char CellularCapabilityGSMTest::kPUK[] = "8765";
Darin Petkovcb547732011-11-09 13:55:26 +0100327const char CellularCapabilityGSMTest::kIMEI[] = "987654321098765";
Darin Petkov0a4dfeb2011-11-18 19:36:13 +0100328const char CellularCapabilityGSMTest::kIMSI[] = "310150123456789";
Darin Petkovcb547732011-11-09 13:55:26 +0100329const char CellularCapabilityGSMTest::kMSISDN[] = "12345678901";
Eric Shienbrood9a245532012-03-07 14:20:39 -0500330const char CellularCapabilityGSMTest::kScanID0[] = "123";
331const char CellularCapabilityGSMTest::kScanID1[] = "456";
332const int CellularCapabilityGSMTest::kStrength = 80;
Darin Petkovcb547732011-11-09 13:55:26 +0100333
Darin Petkov721ac932011-11-16 15:43:09 +0100334TEST_F(CellularCapabilityGSMTest, PropertyStore) {
335 EXPECT_TRUE(cellular_->store().Contains(flimflam::kSIMLockStatusProperty));
336}
337
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500338TEST_F(CellularCapabilityGSMTest, GetIMEI) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500339 EXPECT_CALL(*card_proxy_, GetIMEI(_, _, CellularCapability::kTimeoutDefault))
340 .WillOnce(Invoke(this,
341 &CellularCapabilityGSMTest::InvokeGetIMEI));
342 EXPECT_CALL(*this, TestCallback(IsSuccess()));
Darin Petkovcb547732011-11-09 13:55:26 +0100343 SetCardProxy();
Eric Shienbrood9a245532012-03-07 14:20:39 -0500344 ASSERT_TRUE(capability_->imei_.empty());
345 capability_->GetIMEI(Bind(&CellularCapabilityGSMTest::TestCallback,
346 Unretained(this)));
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500347 EXPECT_EQ(kIMEI, capability_->imei_);
348}
349
350TEST_F(CellularCapabilityGSMTest, GetIMSI) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500351 EXPECT_CALL(*card_proxy_, GetIMSI(_, _, CellularCapability::kTimeoutDefault))
352 .WillOnce(Invoke(this,
353 &CellularCapabilityGSMTest::InvokeGetIMSI))
354 .WillOnce(Invoke(this,
355 &CellularCapabilityGSMTest::InvokeGetIMSI2));
356 EXPECT_CALL(*this, TestCallback(IsSuccess())).Times(2);
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500357 SetCardProxy();
Eric Shienbrood9a245532012-03-07 14:20:39 -0500358 ResultCallback callback = Bind(&CellularCapabilityGSMTest::TestCallback,
359 Unretained(this));
Gary Morain82a31a02012-08-02 18:03:32 -0700360 EXPECT_TRUE(capability_->imsi_.empty());
Ben Chanbd3aee82012-10-16 23:52:04 -0700361 EXPECT_FALSE(capability_->sim_present_);
Eric Shienbrood9a245532012-03-07 14:20:39 -0500362 capability_->GetIMSI(callback);
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500363 EXPECT_EQ(kIMSI, capability_->imsi_);
Ben Chanbd3aee82012-10-16 23:52:04 -0700364 EXPECT_TRUE(capability_->sim_present_);
Eric Shienbrood9a245532012-03-07 14:20:39 -0500365 capability_->imsi_.clear();
Darin Petkov0a4dfeb2011-11-18 19:36:13 +0100366 InitProviderDB();
Eric Shienbrood9a245532012-03-07 14:20:39 -0500367 capability_->GetIMSI(callback);
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500368 EXPECT_EQ("T-Mobile", cellular_->home_provider().GetName());
369}
370
Gary Morain82a31a02012-08-02 18:03:32 -0700371// In this test, the call to the proxy's GetIMSI() will always indicate failure,
372// which will cause the retry logic to call the proxy again a number of times.
373// Eventually, the retries expire.
374TEST_F(CellularCapabilityGSMTest, GetIMSIFails) {
375 ScopedMockLog log;
Paul Stewart1e5bad52012-08-04 17:13:19 -0700376 EXPECT_CALL(log, Log(logging::LOG_INFO, StrEq("cellular_capability_gsm.cc"),
Gary Morain82a31a02012-08-02 18:03:32 -0700377 ::testing::StartsWith("GetIMSI failed - ")));
378 EXPECT_CALL(*card_proxy_, GetIMSI(_, _, CellularCapability::kTimeoutDefault))
379 .Times(CellularCapabilityGSM::kGetIMSIRetryLimit + 1)
380 .WillRepeatedly(Invoke(this,
381 &CellularCapabilityGSMTest::InvokeGetIMSIFails));
382 EXPECT_CALL(*this, TestCallback(IsFailure()));
383 SetCardProxy();
384 ResultCallback callback = Bind(&CellularCapabilityGSMTest::TestCallback,
385 Unretained(this));
386 EXPECT_TRUE(capability_->imsi_.empty());
Ben Chanbd3aee82012-10-16 23:52:04 -0700387 EXPECT_FALSE(capability_->sim_present_);
Gary Morain82a31a02012-08-02 18:03:32 -0700388
389 capability_->get_imsi_retries_ = 0;
390 EXPECT_EQ(CellularCapabilityGSM::kGetIMSIRetryDelayMilliseconds,
391 capability_->get_imsi_retry_delay_milliseconds_);
392
393 // Set the delay to zero to speed up the test.
394 capability_->get_imsi_retry_delay_milliseconds_ = 0;
395 capability_->GetIMSI(callback);
396 for (int i = 0; i < CellularCapabilityGSM::kGetIMSIRetryLimit; ++i) {
397 dispatcher_.DispatchPendingEvents();
398 }
399 EXPECT_EQ(CellularCapabilityGSM::kGetIMSIRetryLimit + 1,
400 capability_->get_imsi_retries_);
401 EXPECT_TRUE(capability_->imsi_.empty());
Ben Chanbd3aee82012-10-16 23:52:04 -0700402 EXPECT_FALSE(capability_->sim_present_);
Gary Morain82a31a02012-08-02 18:03:32 -0700403}
404
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500405TEST_F(CellularCapabilityGSMTest, GetMSISDN) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500406 EXPECT_CALL(*card_proxy_, GetMSISDN(_, _,
407 CellularCapability::kTimeoutDefault))
408 .WillOnce(Invoke(this,
409 &CellularCapabilityGSMTest::InvokeGetMSISDN));
410 EXPECT_CALL(*this, TestCallback(IsSuccess()));
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500411 SetCardProxy();
Eric Shienbrood9a245532012-03-07 14:20:39 -0500412 ASSERT_TRUE(capability_->mdn_.empty());
413 capability_->GetMSISDN(Bind(&CellularCapabilityGSMTest::TestCallback,
414 Unretained(this)));
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500415 EXPECT_EQ(kMSISDN, capability_->mdn_);
416}
417
418TEST_F(CellularCapabilityGSMTest, GetSPN) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500419 EXPECT_CALL(*card_proxy_, GetSPN(_, _, CellularCapability::kTimeoutDefault))
420 .WillOnce(Invoke(this,
421 &CellularCapabilityGSMTest::InvokeGetSPN));
422 EXPECT_CALL(*this, TestCallback(IsSuccess()));
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500423 SetCardProxy();
Eric Shienbrood9a245532012-03-07 14:20:39 -0500424 ASSERT_TRUE(capability_->spn_.empty());
425 capability_->GetSPN(Bind(&CellularCapabilityGSMTest::TestCallback,
426 Unretained(this)));
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500427 EXPECT_EQ(kTestCarrier, capability_->spn_);
Darin Petkovcb547732011-11-09 13:55:26 +0100428}
Darin Petkovb05315f2011-11-07 10:14:25 +0100429
Darin Petkov3e509242011-11-10 14:46:44 +0100430TEST_F(CellularCapabilityGSMTest, GetSignalQuality) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500431 EXPECT_CALL(*network_proxy_,
432 GetSignalQuality(_, _, CellularCapability::kTimeoutDefault))
433 .WillOnce(Invoke(this,
434 &CellularCapabilityGSMTest::InvokeGetSignalQuality));
Darin Petkov3e509242011-11-10 14:46:44 +0100435 SetNetworkProxy();
436 SetService();
437 EXPECT_EQ(0, cellular_->service()->strength());
Darin Petkov721ac932011-11-16 15:43:09 +0100438 capability_->GetSignalQuality();
Darin Petkov3e509242011-11-10 14:46:44 +0100439 EXPECT_EQ(kStrength, cellular_->service()->strength());
440}
441
Darin Petkov184c54e2011-11-15 12:44:39 +0100442TEST_F(CellularCapabilityGSMTest, RegisterOnNetwork) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500443 EXPECT_CALL(*network_proxy_, Register(kTestNetwork, _, _,
444 CellularCapability::kTimeoutRegister))
445 .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeRegister));
446 EXPECT_CALL(*this, TestCallback(IsSuccess()));
Darin Petkov184c54e2011-11-15 12:44:39 +0100447 SetNetworkProxy();
Eric Shienbrood9a245532012-03-07 14:20:39 -0500448 Error error;
449 capability_->RegisterOnNetwork(kTestNetwork, &error,
450 Bind(&CellularCapabilityGSMTest::TestCallback,
451 Unretained(this)));
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500452 EXPECT_EQ(kTestNetwork, capability_->selected_network_);
Darin Petkov184c54e2011-11-15 12:44:39 +0100453}
454
Darin Petkovb72cf402011-11-22 14:51:39 +0100455TEST_F(CellularCapabilityGSMTest, IsRegistered) {
456 EXPECT_FALSE(capability_->IsRegistered());
457 SetRegistrationState(MM_MODEM_GSM_NETWORK_REG_STATUS_IDLE);
458 EXPECT_FALSE(capability_->IsRegistered());
459 SetRegistrationState(MM_MODEM_GSM_NETWORK_REG_STATUS_HOME);
460 EXPECT_TRUE(capability_->IsRegistered());
461 SetRegistrationState(MM_MODEM_GSM_NETWORK_REG_STATUS_SEARCHING);
462 EXPECT_FALSE(capability_->IsRegistered());
463 SetRegistrationState(MM_MODEM_GSM_NETWORK_REG_STATUS_DENIED);
464 EXPECT_FALSE(capability_->IsRegistered());
465 SetRegistrationState(MM_MODEM_GSM_NETWORK_REG_STATUS_UNKNOWN);
466 EXPECT_FALSE(capability_->IsRegistered());
467 SetRegistrationState(MM_MODEM_GSM_NETWORK_REG_STATUS_ROAMING);
468 EXPECT_TRUE(capability_->IsRegistered());
469}
470
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500471TEST_F(CellularCapabilityGSMTest, GetRegistrationState) {
472 ASSERT_FALSE(capability_->IsRegistered());
473 EXPECT_CALL(*network_proxy_,
Eric Shienbrood9a245532012-03-07 14:20:39 -0500474 GetRegistrationInfo(_, _, CellularCapability::kTimeoutDefault))
475 .WillOnce(Invoke(this,
476 &CellularCapabilityGSMTest::InvokeGetRegistrationInfo));
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500477 SetNetworkProxy();
Eric Shienbrood9a245532012-03-07 14:20:39 -0500478 capability_->GetRegistrationState();
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500479 EXPECT_TRUE(capability_->IsRegistered());
480 EXPECT_EQ(MM_MODEM_GSM_NETWORK_REG_STATUS_HOME,
481 capability_->registration_state_);
482}
483
Darin Petkovb05315f2011-11-07 10:14:25 +0100484TEST_F(CellularCapabilityGSMTest, RequirePIN) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500485 EXPECT_CALL(*card_proxy_, EnablePIN(kPIN, true, _, _,
486 CellularCapability::kTimeoutDefault))
487 .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeEnablePIN));
488 EXPECT_CALL(*this, TestCallback(IsSuccess()));
Darin Petkovcb547732011-11-09 13:55:26 +0100489 SetCardProxy();
Eric Shienbrood9a245532012-03-07 14:20:39 -0500490 Error error;
491 capability_->RequirePIN(kPIN, true, &error,
492 Bind(&CellularCapabilityGSMTest::TestCallback,
493 Unretained(this)));
494 EXPECT_TRUE(error.IsSuccess());
Darin Petkovb05315f2011-11-07 10:14:25 +0100495}
496
497TEST_F(CellularCapabilityGSMTest, EnterPIN) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500498 EXPECT_CALL(*card_proxy_, SendPIN(kPIN, _, _,
499 CellularCapability::kTimeoutDefault))
500 .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeSendPIN));
501 EXPECT_CALL(*this, TestCallback(IsSuccess()));
Darin Petkovcb547732011-11-09 13:55:26 +0100502 SetCardProxy();
Eric Shienbrood9a245532012-03-07 14:20:39 -0500503 Error error;
504 capability_->EnterPIN(kPIN, &error,
505 Bind(&CellularCapabilityGSMTest::TestCallback,
506 Unretained(this)));
507 EXPECT_TRUE(error.IsSuccess());
Darin Petkovb05315f2011-11-07 10:14:25 +0100508}
509
510TEST_F(CellularCapabilityGSMTest, UnblockPIN) {
Eric Shienbrood9a245532012-03-07 14:20:39 -0500511 EXPECT_CALL(*card_proxy_, SendPUK(kPUK, kPIN, _, _,
512 CellularCapability::kTimeoutDefault))
513 .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeSendPUK));
514 EXPECT_CALL(*this, TestCallback(IsSuccess()));
Darin Petkovcb547732011-11-09 13:55:26 +0100515 SetCardProxy();
Eric Shienbrood9a245532012-03-07 14:20:39 -0500516 Error error;
517 capability_->UnblockPIN(kPUK, kPIN, &error,
518 Bind(&CellularCapabilityGSMTest::TestCallback,
519 Unretained(this)));
520 EXPECT_TRUE(error.IsSuccess());
Darin Petkovb05315f2011-11-07 10:14:25 +0100521}
522
523TEST_F(CellularCapabilityGSMTest, ChangePIN) {
524 static const char kOldPIN[] = "1111";
Eric Shienbrood9a245532012-03-07 14:20:39 -0500525 EXPECT_CALL(*card_proxy_, ChangePIN(kOldPIN, kPIN, _, _,
526 CellularCapability::kTimeoutDefault))
527 .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeChangePIN));
528 EXPECT_CALL(*this, TestCallback(IsSuccess()));
Darin Petkovcb547732011-11-09 13:55:26 +0100529 SetCardProxy();
Eric Shienbrood9a245532012-03-07 14:20:39 -0500530 Error error;
531 capability_->ChangePIN(kOldPIN, kPIN, &error,
532 Bind(&CellularCapabilityGSMTest::TestCallback,
533 Unretained(this)));
534 EXPECT_TRUE(error.IsSuccess());
Darin Petkovb05315f2011-11-07 10:14:25 +0100535}
536
Darin Petkovb7828b02012-02-03 12:34:30 +0100537namespace {
538
539MATCHER(SizeIs2, "") {
540 return arg.size() == 2;
541}
542
543} // namespace
544
Darin Petkov1272a432011-11-10 15:53:37 +0100545TEST_F(CellularCapabilityGSMTest, Scan) {
Darin Petkov1272a432011-11-10 15:53:37 +0100546 Error error;
Eric Shienbrood9a245532012-03-07 14:20:39 -0500547 EXPECT_CALL(*network_proxy_, Scan(_, _, CellularCapability::kTimeoutScan))
Jason Glasgowcd0349c2012-05-03 23:32:15 -0400548 .WillOnce(SaveArg<1>(&scan_callback_));
Eric Shienbrood9a245532012-03-07 14:20:39 -0500549 EXPECT_CALL(*this, TestCallback(IsSuccess()));
Darin Petkov721ac932011-11-16 15:43:09 +0100550 capability_->found_networks_.resize(3, Stringmap());
Darin Petkovb7828b02012-02-03 12:34:30 +0100551 EXPECT_CALL(*device_adaptor_,
552 EmitStringmapsChanged(flimflam::kFoundNetworksProperty,
553 SizeIs2()));
Jason Glasgowcd0349c2012-05-03 23:32:15 -0400554 EXPECT_CALL(*device_adaptor_,
555 EmitBoolChanged(flimflam::kScanningProperty, true));
556 EXPECT_FALSE(capability_->scanning_);
557
Eric Shienbrood9a245532012-03-07 14:20:39 -0500558 SetNetworkProxy();
559 capability_->Scan(&error, Bind(&CellularCapabilityGSMTest::TestCallback,
560 Unretained(this)));
561 EXPECT_TRUE(error.IsSuccess());
Jason Glasgowcd0349c2012-05-03 23:32:15 -0400562 EXPECT_TRUE(capability_->scanning_);
563
564 // Simulate the completion of the scan...
565 EXPECT_CALL(*device_adaptor_,
566 EmitBoolChanged(flimflam::kScanningProperty, false));
567 InvokeScanReply();
568 EXPECT_FALSE(capability_->scanning_);
Darin Petkov721ac932011-11-16 15:43:09 +0100569 EXPECT_EQ(2, capability_->found_networks_.size());
Eric Shienbrood9a245532012-03-07 14:20:39 -0500570 EXPECT_EQ(kScanID0,
Darin Petkov721ac932011-11-16 15:43:09 +0100571 capability_->found_networks_[0][flimflam::kNetworkIdProperty]);
Eric Shienbrood9a245532012-03-07 14:20:39 -0500572 EXPECT_EQ(kScanID1,
Darin Petkov721ac932011-11-16 15:43:09 +0100573 capability_->found_networks_[1][flimflam::kNetworkIdProperty]);
Darin Petkov1272a432011-11-10 15:53:37 +0100574}
575
576TEST_F(CellularCapabilityGSMTest, ParseScanResult) {
577 static const char kID[] = "123";
578 static const char kLongName[] = "long name";
579 static const char kShortName[] = "short name";
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500580 GSMScanResult result;
Darin Petkov1272a432011-11-10 15:53:37 +0100581 result[CellularCapabilityGSM::kNetworkPropertyStatus] = "1";
582 result[CellularCapabilityGSM::kNetworkPropertyID] = kID;
583 result[CellularCapabilityGSM::kNetworkPropertyLongName] = kLongName;
584 result[CellularCapabilityGSM::kNetworkPropertyShortName] = kShortName;
585 result[CellularCapabilityGSM::kNetworkPropertyAccessTechnology] = "3";
586 result["unknown property"] = "random value";
Darin Petkov721ac932011-11-16 15:43:09 +0100587 Stringmap parsed = capability_->ParseScanResult(result);
Darin Petkov1272a432011-11-10 15:53:37 +0100588 EXPECT_EQ(5, parsed.size());
589 EXPECT_EQ("available", parsed[flimflam::kStatusProperty]);
590 EXPECT_EQ(kID, parsed[flimflam::kNetworkIdProperty]);
591 EXPECT_EQ(kLongName, parsed[flimflam::kLongNameProperty]);
592 EXPECT_EQ(kShortName, parsed[flimflam::kShortNameProperty]);
593 EXPECT_EQ(flimflam::kNetworkTechnologyEdge,
594 parsed[flimflam::kTechnologyProperty]);
595}
596
597TEST_F(CellularCapabilityGSMTest, ParseScanResultProviderLookup) {
598 InitProviderDB();
599 static const char kID[] = "310210";
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500600 GSMScanResult result;
Darin Petkov1272a432011-11-10 15:53:37 +0100601 result[CellularCapabilityGSM::kNetworkPropertyID] = kID;
Darin Petkov721ac932011-11-16 15:43:09 +0100602 Stringmap parsed = capability_->ParseScanResult(result);
Darin Petkov1272a432011-11-10 15:53:37 +0100603 EXPECT_EQ(2, parsed.size());
604 EXPECT_EQ(kID, parsed[flimflam::kNetworkIdProperty]);
605 EXPECT_EQ("T-Mobile", parsed[flimflam::kLongNameProperty]);
606}
607
Darin Petkovae0c64e2011-11-15 15:50:27 +0100608TEST_F(CellularCapabilityGSMTest, SetAccessTechnology) {
Darin Petkov721ac932011-11-16 15:43:09 +0100609 capability_->SetAccessTechnology(MM_MODEM_GSM_ACCESS_TECH_GSM);
610 EXPECT_EQ(MM_MODEM_GSM_ACCESS_TECH_GSM, capability_->access_technology_);
Darin Petkovae0c64e2011-11-15 15:50:27 +0100611 SetService();
Darin Petkovb72cf402011-11-22 14:51:39 +0100612 SetRegistrationState(MM_MODEM_GSM_NETWORK_REG_STATUS_HOME);
Darin Petkov721ac932011-11-16 15:43:09 +0100613 capability_->SetAccessTechnology(MM_MODEM_GSM_ACCESS_TECH_GPRS);
614 EXPECT_EQ(MM_MODEM_GSM_ACCESS_TECH_GPRS, capability_->access_technology_);
Darin Petkovae0c64e2011-11-15 15:50:27 +0100615 EXPECT_EQ(flimflam::kNetworkTechnologyGprs,
Darin Petkovb72cf402011-11-22 14:51:39 +0100616 cellular_->service()->network_technology());
Darin Petkovae0c64e2011-11-15 15:50:27 +0100617}
618
619TEST_F(CellularCapabilityGSMTest, UpdateOperatorInfo) {
620 static const char kOperatorName[] = "Swisscom";
621 InitProviderDB();
Darin Petkov0a4dfeb2011-11-18 19:36:13 +0100622 capability_->serving_operator_.SetCode("22801");
Darin Petkovae0c64e2011-11-15 15:50:27 +0100623 SetService();
Darin Petkov721ac932011-11-16 15:43:09 +0100624 capability_->UpdateOperatorInfo();
Darin Petkov0a4dfeb2011-11-18 19:36:13 +0100625 EXPECT_EQ(kOperatorName, capability_->serving_operator_.GetName());
626 EXPECT_EQ("ch", capability_->serving_operator_.GetCountry());
Darin Petkovae0c64e2011-11-15 15:50:27 +0100627 EXPECT_EQ(kOperatorName, cellular_->service()->serving_operator().GetName());
Darin Petkova4ca3c32012-08-17 16:05:24 +0200628
629 static const char kTestOperator[] = "Testcom";
630 capability_->serving_operator_.SetName(kTestOperator);
631 capability_->serving_operator_.SetCountry("");
632 capability_->UpdateOperatorInfo();
633 EXPECT_EQ(kTestOperator, capability_->serving_operator_.GetName());
634 EXPECT_EQ("ch", capability_->serving_operator_.GetCountry());
635 EXPECT_EQ(kTestOperator, cellular_->service()->serving_operator().GetName());
Darin Petkovae0c64e2011-11-15 15:50:27 +0100636}
637
Darin Petkov0a4dfeb2011-11-18 19:36:13 +0100638TEST_F(CellularCapabilityGSMTest, UpdateStatus) {
639 InitProviderDB();
640 DBusPropertiesMap props;
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500641 capability_->imsi_ = "310240123456789";
Eric Shienbrood7fce52c2012-04-13 19:11:02 -0400642 props[CellularCapability::kModemPropertyIMSI].writer().append_string("");
Darin Petkov0a4dfeb2011-11-18 19:36:13 +0100643 capability_->UpdateStatus(props);
644 EXPECT_EQ("T-Mobile", cellular_->home_provider().GetName());
645}
646
Darin Petkovf508c822012-09-21 13:43:17 +0200647TEST_F(CellularCapabilityGSMTest, AllowRoaming) {
648 EXPECT_FALSE(cellular_->allow_roaming_);
649 EXPECT_FALSE(capability_->provider_requires_roaming_);
650 EXPECT_FALSE(capability_->AllowRoaming());
651 capability_->provider_requires_roaming_ = true;
652 EXPECT_TRUE(capability_->AllowRoaming());
653 capability_->provider_requires_roaming_ = false;
654 cellular_->allow_roaming_ = true;
655 EXPECT_TRUE(capability_->AllowRoaming());
656}
657
Darin Petkov0a4dfeb2011-11-18 19:36:13 +0100658TEST_F(CellularCapabilityGSMTest, SetHomeProvider) {
659 static const char kCountry[] = "us";
660 static const char kCode[] = "310160";
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500661 capability_->imsi_ = "310240123456789";
Darin Petkov0a4dfeb2011-11-18 19:36:13 +0100662
Darin Petkovf508c822012-09-21 13:43:17 +0200663 EXPECT_FALSE(capability_->home_provider_);
664 EXPECT_FALSE(capability_->provider_requires_roaming_);
665
Darin Petkov0a4dfeb2011-11-18 19:36:13 +0100666 capability_->SetHomeProvider(); // No mobile provider DB available.
667 EXPECT_TRUE(cellular_->home_provider().GetName().empty());
668 EXPECT_TRUE(cellular_->home_provider().GetCountry().empty());
669 EXPECT_TRUE(cellular_->home_provider().GetCode().empty());
Darin Petkovf508c822012-09-21 13:43:17 +0200670 EXPECT_FALSE(capability_->provider_requires_roaming_);
Darin Petkov0a4dfeb2011-11-18 19:36:13 +0100671
672 InitProviderDB();
673 capability_->SetHomeProvider();
674 EXPECT_EQ("T-Mobile", cellular_->home_provider().GetName());
675 EXPECT_EQ(kCountry, cellular_->home_provider().GetCountry());
676 EXPECT_EQ(kCode, cellular_->home_provider().GetCode());
Darin Petkov3cfbf212011-11-21 16:02:09 +0100677 EXPECT_EQ(4, capability_->apn_list_.size());
Darin Petkovb4fccd22012-08-10 11:59:26 +0200678 ASSERT_TRUE(capability_->home_provider_);
Darin Petkovf508c822012-09-21 13:43:17 +0200679 EXPECT_FALSE(capability_->provider_requires_roaming_);
Darin Petkov0a4dfeb2011-11-18 19:36:13 +0100680
681 Cellular::Operator oper;
682 cellular_->set_home_provider(oper);
683 capability_->spn_ = kTestCarrier;
684 capability_->SetHomeProvider();
685 EXPECT_EQ(kTestCarrier, cellular_->home_provider().GetName());
686 EXPECT_EQ(kCountry, cellular_->home_provider().GetCountry());
687 EXPECT_EQ(kCode, cellular_->home_provider().GetCode());
Darin Petkovf508c822012-09-21 13:43:17 +0200688 EXPECT_FALSE(capability_->provider_requires_roaming_);
Darin Petkovb4fccd22012-08-10 11:59:26 +0200689
690 static const char kCubic[] = "Cubic";
691 capability_->spn_ = kCubic;
692 capability_->SetHomeProvider();
693 EXPECT_EQ(kCubic, cellular_->home_provider().GetName());
694 EXPECT_EQ("", cellular_->home_provider().GetCode());
695 ASSERT_TRUE(capability_->home_provider_);
Darin Petkovf508c822012-09-21 13:43:17 +0200696 EXPECT_TRUE(capability_->provider_requires_roaming_);
Darin Petkovb4fccd22012-08-10 11:59:26 +0200697
698 static const char kCUBIC[] = "CUBIC";
699 capability_->spn_ = kCUBIC;
700 capability_->home_provider_ = NULL;
701 capability_->SetHomeProvider();
702 EXPECT_EQ(kCUBIC, cellular_->home_provider().GetName());
703 EXPECT_EQ("", cellular_->home_provider().GetCode());
704 ASSERT_TRUE(capability_->home_provider_);
Darin Petkovf508c822012-09-21 13:43:17 +0200705 EXPECT_TRUE(capability_->provider_requires_roaming_);
Darin Petkov0a4dfeb2011-11-18 19:36:13 +0100706}
707
Darin Petkov3cfbf212011-11-21 16:02:09 +0100708namespace {
709
710MATCHER(SizeIs4, "") {
711 return arg.size() == 4;
712}
713
714} // namespace
715
716TEST_F(CellularCapabilityGSMTest, InitAPNList) {
717 InitProviderDB();
718 capability_->home_provider_ =
Prathmesh Prabhu27526f12013-03-25 19:42:18 -0700719 mobile_provider_lookup_by_name(modem_info_.provider_db(), "T-Mobile");
Darin Petkov3cfbf212011-11-21 16:02:09 +0100720 ASSERT_TRUE(capability_->home_provider_);
721 EXPECT_EQ(0, capability_->apn_list_.size());
722 EXPECT_CALL(*device_adaptor_,
723 EmitStringmapsChanged(flimflam::kCellularApnListProperty,
724 SizeIs4()));
725 capability_->InitAPNList();
726 EXPECT_EQ(4, capability_->apn_list_.size());
727 EXPECT_EQ("wap.voicestream.com",
728 capability_->apn_list_[1][flimflam::kApnProperty]);
729 EXPECT_EQ("Web2Go/t-zones",
730 capability_->apn_list_[1][flimflam::kApnNameProperty]);
731}
732
Darin Petkov20c13ec2011-11-09 15:07:15 +0100733TEST_F(CellularCapabilityGSMTest, GetNetworkTechnologyString) {
Darin Petkov721ac932011-11-16 15:43:09 +0100734 EXPECT_EQ("", capability_->GetNetworkTechnologyString());
Darin Petkov20c13ec2011-11-09 15:07:15 +0100735 SetAccessTechnology(MM_MODEM_GSM_ACCESS_TECH_GSM);
Darin Petkov20c13ec2011-11-09 15:07:15 +0100736 EXPECT_EQ(flimflam::kNetworkTechnologyGsm,
Darin Petkov721ac932011-11-16 15:43:09 +0100737 capability_->GetNetworkTechnologyString());
Darin Petkov20c13ec2011-11-09 15:07:15 +0100738 SetAccessTechnology(MM_MODEM_GSM_ACCESS_TECH_GSM_COMPACT);
739 EXPECT_EQ(flimflam::kNetworkTechnologyGsm,
Darin Petkov721ac932011-11-16 15:43:09 +0100740 capability_->GetNetworkTechnologyString());
Darin Petkov20c13ec2011-11-09 15:07:15 +0100741 SetAccessTechnology(MM_MODEM_GSM_ACCESS_TECH_GPRS);
742 EXPECT_EQ(flimflam::kNetworkTechnologyGprs,
Darin Petkov721ac932011-11-16 15:43:09 +0100743 capability_->GetNetworkTechnologyString());
Darin Petkov20c13ec2011-11-09 15:07:15 +0100744 SetAccessTechnology(MM_MODEM_GSM_ACCESS_TECH_EDGE);
745 EXPECT_EQ(flimflam::kNetworkTechnologyEdge,
Darin Petkov721ac932011-11-16 15:43:09 +0100746 capability_->GetNetworkTechnologyString());
Darin Petkov20c13ec2011-11-09 15:07:15 +0100747 SetAccessTechnology(MM_MODEM_GSM_ACCESS_TECH_UMTS);
748 EXPECT_EQ(flimflam::kNetworkTechnologyUmts,
Darin Petkov721ac932011-11-16 15:43:09 +0100749 capability_->GetNetworkTechnologyString());
Darin Petkov20c13ec2011-11-09 15:07:15 +0100750 SetAccessTechnology(MM_MODEM_GSM_ACCESS_TECH_HSDPA);
751 EXPECT_EQ(flimflam::kNetworkTechnologyHspa,
Darin Petkov721ac932011-11-16 15:43:09 +0100752 capability_->GetNetworkTechnologyString());
Darin Petkov20c13ec2011-11-09 15:07:15 +0100753 SetAccessTechnology(MM_MODEM_GSM_ACCESS_TECH_HSUPA);
754 EXPECT_EQ(flimflam::kNetworkTechnologyHspa,
Darin Petkov721ac932011-11-16 15:43:09 +0100755 capability_->GetNetworkTechnologyString());
Darin Petkov20c13ec2011-11-09 15:07:15 +0100756 SetAccessTechnology(MM_MODEM_GSM_ACCESS_TECH_HSPA);
757 EXPECT_EQ(flimflam::kNetworkTechnologyHspa,
Darin Petkov721ac932011-11-16 15:43:09 +0100758 capability_->GetNetworkTechnologyString());
Darin Petkov20c13ec2011-11-09 15:07:15 +0100759 SetAccessTechnology(MM_MODEM_GSM_ACCESS_TECH_HSPA_PLUS);
760 EXPECT_EQ(flimflam::kNetworkTechnologyHspaPlus,
Darin Petkov721ac932011-11-16 15:43:09 +0100761 capability_->GetNetworkTechnologyString());
Darin Petkov20c13ec2011-11-09 15:07:15 +0100762}
763
764TEST_F(CellularCapabilityGSMTest, GetRoamingStateString) {
765 EXPECT_EQ(flimflam::kRoamingStateUnknown,
Darin Petkov721ac932011-11-16 15:43:09 +0100766 capability_->GetRoamingStateString());
Darin Petkov20c13ec2011-11-09 15:07:15 +0100767 SetRegistrationState(MM_MODEM_GSM_NETWORK_REG_STATUS_HOME);
768 EXPECT_EQ(flimflam::kRoamingStateHome,
Darin Petkov721ac932011-11-16 15:43:09 +0100769 capability_->GetRoamingStateString());
Darin Petkov20c13ec2011-11-09 15:07:15 +0100770 SetRegistrationState(MM_MODEM_GSM_NETWORK_REG_STATUS_ROAMING);
771 EXPECT_EQ(flimflam::kRoamingStateRoaming,
Darin Petkov721ac932011-11-16 15:43:09 +0100772 capability_->GetRoamingStateString());
Darin Petkov20c13ec2011-11-09 15:07:15 +0100773 SetRegistrationState(MM_MODEM_GSM_NETWORK_REG_STATUS_SEARCHING);
774 EXPECT_EQ(flimflam::kRoamingStateUnknown,
Darin Petkov721ac932011-11-16 15:43:09 +0100775 capability_->GetRoamingStateString());
Darin Petkov20c13ec2011-11-09 15:07:15 +0100776 SetRegistrationState(MM_MODEM_GSM_NETWORK_REG_STATUS_DENIED);
777 EXPECT_EQ(flimflam::kRoamingStateUnknown,
Darin Petkov721ac932011-11-16 15:43:09 +0100778 capability_->GetRoamingStateString());
Darin Petkov20c13ec2011-11-09 15:07:15 +0100779 SetRegistrationState(MM_MODEM_GSM_NETWORK_REG_STATUS_IDLE);
780 EXPECT_EQ(flimflam::kRoamingStateUnknown,
Darin Petkov721ac932011-11-16 15:43:09 +0100781 capability_->GetRoamingStateString());
Darin Petkov20c13ec2011-11-09 15:07:15 +0100782}
783
Darin Petkovac635a82012-01-10 16:51:58 +0100784TEST_F(CellularCapabilityGSMTest, CreateFriendlyServiceName) {
785 CellularCapabilityGSM::friendly_service_name_id_ = 0;
786 EXPECT_EQ("GSMNetwork0", capability_->CreateFriendlyServiceName());
787 EXPECT_EQ("GSMNetwork1", capability_->CreateFriendlyServiceName());
Darin Petkova4ca3c32012-08-17 16:05:24 +0200788
Darin Petkovac635a82012-01-10 16:51:58 +0100789 capability_->serving_operator_.SetCode("1234");
790 EXPECT_EQ("cellular_1234", capability_->CreateFriendlyServiceName());
Darin Petkova4ca3c32012-08-17 16:05:24 +0200791
Darin Petkovac635a82012-01-10 16:51:58 +0100792 static const char kTestCarrier[] = "A GSM Carrier";
Eric Shienbrood5de44ab2011-12-05 10:46:27 -0500793 capability_->carrier_ = kTestCarrier;
Darin Petkovac635a82012-01-10 16:51:58 +0100794 EXPECT_EQ(kTestCarrier, capability_->CreateFriendlyServiceName());
Darin Petkova4ca3c32012-08-17 16:05:24 +0200795
796 static const char kHomeProvider[] = "The GSM Home Provider";
797 cellular_->home_provider_.SetName(kHomeProvider);
798 EXPECT_EQ(kTestCarrier, capability_->CreateFriendlyServiceName());
799 capability_->registration_state_ = MM_MODEM_GSM_NETWORK_REG_STATUS_HOME;
800 EXPECT_EQ(kHomeProvider, capability_->CreateFriendlyServiceName());
801
Darin Petkovac635a82012-01-10 16:51:58 +0100802 static const char kTestOperator[] = "A GSM Operator";
803 capability_->serving_operator_.SetName(kTestOperator);
804 EXPECT_EQ(kTestOperator, capability_->CreateFriendlyServiceName());
Darin Petkova4ca3c32012-08-17 16:05:24 +0200805
806 capability_->registration_state_ = MM_MODEM_GSM_NETWORK_REG_STATUS_ROAMING;
807 EXPECT_EQ(StringPrintf("%s | %s", kHomeProvider, kTestOperator),
808 capability_->CreateFriendlyServiceName());
Darin Petkovac635a82012-01-10 16:51:58 +0100809}
810
Darin Petkov31332412012-01-28 01:50:02 +0100811TEST_F(CellularCapabilityGSMTest, SetStorageIdentifier) {
812 SetService();
813 capability_->OnServiceCreated();
Darin Petkovdd3e8662012-02-03 13:16:20 +0100814 EXPECT_EQ(string(flimflam::kTypeCellular) + "_" + kAddress + "_" +
Darin Petkov31332412012-01-28 01:50:02 +0100815 cellular_->service()->friendly_name(),
816 cellular_->service()->GetStorageIdentifier());
817 capability_->imsi_ = kIMSI;
818 capability_->OnServiceCreated();
Darin Petkovdd3e8662012-02-03 13:16:20 +0100819 EXPECT_EQ(string(flimflam::kTypeCellular) + "_" + kAddress + "_" + kIMSI,
Darin Petkov31332412012-01-28 01:50:02 +0100820 cellular_->service()->GetStorageIdentifier());
821}
822
Gaurav Shah67808222013-03-27 13:29:36 -0700823MATCHER_P(KeyValueStoreEq, value, "") {
824 bool match = value.bool_properties() == arg.bool_properties() &&
825 value.int_properties() == arg.int_properties() &&
826 value.string_properties() == arg.string_properties() &&
827 value.uint_properties() == arg.uint_properties();
Gaurav Shah67808222013-03-27 13:29:36 -0700828 if (!match) {
829 *result_listener << "\nExpected KeyValueStore:\n"
830 << "\tbool_properties: "
831 << testing::PrintToString(value.bool_properties())
832 << "\n\tint_properties: "
833 << testing::PrintToString(value.int_properties())
834 << "\n\tstring_properties: "
835 << testing::PrintToString(value.string_properties())
836 << "\n\tint_properties: "
837 << testing::PrintToString(value.uint_properties())
838 << "\nGot KeyValueStore:\n"
839 << "\tbool_properties: "
840 << testing::PrintToString(arg.bool_properties())
841 << "\n\tint_properties: "
842 << testing::PrintToString(arg.int_properties())
843 << "\n\tstring_properties: "
844 << testing::PrintToString(arg.string_properties())
845 << "\n\tuint_properties: "
846 << testing::PrintToString(arg.uint_properties());
847 }
Gaurav Shah67808222013-03-27 13:29:36 -0700848 return match;
849}
850
Jason Glasgow4c0724a2012-04-17 15:47:40 -0400851TEST_F(CellularCapabilityGSMTest, OnDBusPropertiesChanged) {
Darin Petkov63138a92012-02-06 14:09:15 +0100852 EXPECT_EQ(MM_MODEM_GSM_ACCESS_TECH_UNKNOWN, capability_->access_technology_);
853 EXPECT_FALSE(capability_->sim_lock_status_.enabled);
854 EXPECT_EQ("", capability_->sim_lock_status_.lock_type);
855 EXPECT_EQ(0, capability_->sim_lock_status_.retries_left);
856 DBusPropertiesMap props;
857 static const char kLockType[] = "sim-pin";
858 const int kRetries = 3;
859 props[CellularCapabilityGSM::kPropertyAccessTechnology].writer().
860 append_uint32(MM_MODEM_GSM_ACCESS_TECH_EDGE);
861 props[CellularCapabilityGSM::kPropertyEnabledFacilityLocks].writer().
862 append_uint32(MM_MODEM_GSM_FACILITY_SIM);
863 props[CellularCapabilityGSM::kPropertyUnlockRequired].writer().append_string(
864 kLockType);
865 props[CellularCapabilityGSM::kPropertyUnlockRetries].writer().append_uint32(
866 kRetries);
Jason Glasgow4c0724a2012-04-17 15:47:40 -0400867 // Call with the 'wrong' interface and nothing should change.
868 capability_->OnDBusPropertiesChanged(MM_MODEM_GSM_INTERFACE, props,
869 vector<string>());
870 EXPECT_EQ(MM_MODEM_GSM_ACCESS_TECH_UNKNOWN, capability_->access_technology_);
871 EXPECT_FALSE(capability_->sim_lock_status_.enabled);
872 EXPECT_EQ("", capability_->sim_lock_status_.lock_type);
873 EXPECT_EQ(0, capability_->sim_lock_status_.retries_left);
874
Gary Morainbaeefdf2012-04-30 14:53:35 -0700875 // Call with the MM_MODEM_GSM_NETWORK_INTERFACE interface and expect a change
876 // to the enabled state of the SIM lock.
877 KeyValueStore lock_status;
878 lock_status.SetBool(flimflam::kSIMLockEnabledProperty, true);
879 lock_status.SetString(flimflam::kSIMLockTypeProperty, "");
880 lock_status.SetUint(flimflam::kSIMLockRetriesLeftProperty, 0);
881
882 EXPECT_CALL(*device_adaptor_, EmitKeyValueStoreChanged(
883 flimflam::kSIMLockStatusProperty,
884 KeyValueStoreEq(lock_status)));
885
Eric Shienbrood7fce52c2012-04-13 19:11:02 -0400886 capability_->OnDBusPropertiesChanged(MM_MODEM_GSM_NETWORK_INTERFACE, props,
Jason Glasgow4c0724a2012-04-17 15:47:40 -0400887 vector<string>());
Darin Petkov63138a92012-02-06 14:09:15 +0100888 EXPECT_EQ(MM_MODEM_GSM_ACCESS_TECH_EDGE, capability_->access_technology_);
Eric Shienbrood7fce52c2012-04-13 19:11:02 -0400889 capability_->OnDBusPropertiesChanged(MM_MODEM_GSM_CARD_INTERFACE, props,
890 vector<string>());
Darin Petkov63138a92012-02-06 14:09:15 +0100891 EXPECT_TRUE(capability_->sim_lock_status_.enabled);
Gary Morainbaeefdf2012-04-30 14:53:35 -0700892 EXPECT_TRUE(capability_->sim_lock_status_.lock_type.empty());
893 EXPECT_EQ(0, capability_->sim_lock_status_.retries_left);
894
895 // Some properties are sent on the MM_MODEM_INTERFACE.
896 capability_->sim_lock_status_.enabled = false;
897 capability_->sim_lock_status_.lock_type = "";
898 capability_->sim_lock_status_.retries_left = 0;
899 KeyValueStore lock_status2;
900 lock_status2.SetBool(flimflam::kSIMLockEnabledProperty, false);
901 lock_status2.SetString(flimflam::kSIMLockTypeProperty, kLockType);
902 lock_status2.SetUint(flimflam::kSIMLockRetriesLeftProperty, kRetries);
903 EXPECT_CALL(*device_adaptor_,
904 EmitKeyValueStoreChanged(flimflam::kSIMLockStatusProperty,
905 KeyValueStoreEq(lock_status2)));
906 capability_->OnDBusPropertiesChanged(MM_MODEM_INTERFACE, props,
907 vector<string>());
908 EXPECT_FALSE(capability_->sim_lock_status_.enabled);
Darin Petkov63138a92012-02-06 14:09:15 +0100909 EXPECT_EQ(kLockType, capability_->sim_lock_status_.lock_type);
910 EXPECT_EQ(kRetries, capability_->sim_lock_status_.retries_left);
911}
912
Eric Shienbrood30bc0ec2012-03-21 18:19:46 -0400913TEST_F(CellularCapabilityGSMTest, SetupApnTryList) {
914 static const string kTmobileApn("epc.tmobile.com");
915 static const string kLastGoodApn("remembered.apn");
916 static const string kLastGoodUsername("remembered.user");
917 static const string kSuppliedApn("my.apn");
918
919 SetService();
920 capability_->imsi_ = "310240123456789";
921 InitProviderDB();
922 capability_->SetHomeProvider();
923 DBusPropertiesMap props;
924 capability_->SetupConnectProperties(&props);
925 EXPECT_FALSE(props.find(flimflam::kApnProperty) == props.end());
926 EXPECT_EQ(kTmobileApn, props[flimflam::kApnProperty].reader().get_string());
927
928 ProfileRefPtr profile(new NiceMock<MockProfile>(
Prathmesh Prabhu27526f12013-03-25 19:42:18 -0700929 modem_info_.control_interface(), modem_info_.metrics(),
930 modem_info_.manager()));
Eric Shienbrood30bc0ec2012-03-21 18:19:46 -0400931 cellular_->service()->set_profile(profile);
932 Stringmap apn_info;
933 apn_info[flimflam::kApnProperty] = kLastGoodApn;
934 apn_info[flimflam::kApnUsernameProperty] = kLastGoodUsername;
935 cellular_->service()->SetLastGoodApn(apn_info);
936 props.clear();
937 EXPECT_TRUE(props.find(flimflam::kApnProperty) == props.end());
938 capability_->SetupConnectProperties(&props);
939 // We expect the list to contain the last good APN, plus
940 // the 4 APNs from the mobile provider info database.
941 EXPECT_EQ(5, capability_->apn_try_list_.size());
942 EXPECT_FALSE(props.find(flimflam::kApnProperty) == props.end());
943 EXPECT_EQ(kLastGoodApn, props[flimflam::kApnProperty].reader().get_string());
944 EXPECT_FALSE(props.find(flimflam::kApnUsernameProperty) == props.end());
945 EXPECT_EQ(kLastGoodUsername,
946 props[flimflam::kApnUsernameProperty].reader().get_string());
947
948 Error error;
949 apn_info.clear();
950 props.clear();
951 apn_info[flimflam::kApnProperty] = kSuppliedApn;
952 // Setting the APN has the side effect of clearing the LastGoodApn,
953 // so the try list will have 5 elements, with the first one being
954 // the supplied APN.
955 cellular_->service()->SetApn(apn_info, &error);
956 EXPECT_TRUE(props.find(flimflam::kApnProperty) == props.end());
957 capability_->SetupConnectProperties(&props);
958 EXPECT_EQ(5, capability_->apn_try_list_.size());
959 EXPECT_FALSE(props.find(flimflam::kApnProperty) == props.end());
960 EXPECT_EQ(kSuppliedApn, props[flimflam::kApnProperty].reader().get_string());
961
962 apn_info.clear();
963 props.clear();
964 apn_info[flimflam::kApnProperty] = kLastGoodApn;
965 apn_info[flimflam::kApnUsernameProperty] = kLastGoodUsername;
966 // Now when LastGoodAPN is set, it will be the one selected.
967 cellular_->service()->SetLastGoodApn(apn_info);
968 EXPECT_TRUE(props.find(flimflam::kApnProperty) == props.end());
969 capability_->SetupConnectProperties(&props);
970 // We expect the list to contain the last good APN, plus
971 // the user-supplied APN, plus the 4 APNs from the mobile
972 // provider info database.
973 EXPECT_EQ(6, capability_->apn_try_list_.size());
974 EXPECT_FALSE(props.find(flimflam::kApnProperty) == props.end());
975 EXPECT_EQ(kLastGoodApn, props[flimflam::kApnProperty].reader().get_string());
976 EXPECT_FALSE(props.find(flimflam::kApnUsernameProperty) == props.end());
977 EXPECT_EQ(kLastGoodUsername,
978 props[flimflam::kApnUsernameProperty].reader().get_string());
979}
980
Thieu Le923006b2012-04-05 16:32:58 -0700981TEST_F(CellularCapabilityGSMTest, StartModemSuccess) {
982 SetupCommonStartModemExpectations();
983 EXPECT_CALL(*card_proxy_,
984 GetSPN(_, _, CellularCapability::kTimeoutDefault))
985 .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeGetSPN));
986 EXPECT_CALL(*card_proxy_,
987 GetMSISDN(_, _, CellularCapability::kTimeoutDefault))
988 .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeGetMSISDN));
Ben Chan3ecdf822012-08-06 12:29:23 -0700989 AllowCreateCardProxyFromFactory();
Thieu Le923006b2012-04-05 16:32:58 -0700990
991 Error error;
992 capability_->StartModem(
993 &error, Bind(&CellularCapabilityGSMTest::TestCallback, Unretained(this)));
994 dispatcher_.DispatchPendingEvents();
995}
996
997TEST_F(CellularCapabilityGSMTest, StartModemGetSPNFail) {
998 SetupCommonStartModemExpectations();
999 EXPECT_CALL(*card_proxy_,
1000 GetSPN(_, _, CellularCapability::kTimeoutDefault))
1001 .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeGetSPNFail));
1002 EXPECT_CALL(*card_proxy_,
1003 GetMSISDN(_, _, CellularCapability::kTimeoutDefault))
1004 .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeGetMSISDN));
Ben Chan3ecdf822012-08-06 12:29:23 -07001005 AllowCreateCardProxyFromFactory();
Thieu Le923006b2012-04-05 16:32:58 -07001006
1007 Error error;
1008 capability_->StartModem(
1009 &error, Bind(&CellularCapabilityGSMTest::TestCallback, Unretained(this)));
1010 dispatcher_.DispatchPendingEvents();
1011}
1012
1013TEST_F(CellularCapabilityGSMTest, StartModemGetMSISDNFail) {
1014 SetupCommonStartModemExpectations();
1015 EXPECT_CALL(*card_proxy_,
1016 GetSPN(_, _, CellularCapability::kTimeoutDefault))
1017 .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeGetSPN));
1018 EXPECT_CALL(*card_proxy_,
1019 GetMSISDN(_, _, CellularCapability::kTimeoutDefault))
1020 .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeGetMSISDNFail));
Ben Chan3ecdf822012-08-06 12:29:23 -07001021 AllowCreateCardProxyFromFactory();
Thieu Le923006b2012-04-05 16:32:58 -07001022
1023 Error error;
1024 capability_->StartModem(
1025 &error, Bind(&CellularCapabilityGSMTest::TestCallback, Unretained(this)));
1026 dispatcher_.DispatchPendingEvents();
1027}
1028
Thieu Leb5954a22012-05-18 10:37:34 -07001029TEST_F(CellularCapabilityGSMTest, ConnectFailureNoService) {
1030 // Make sure we don't crash if the connect failed and there is no
1031 // CellularService object. This can happen if the modem is enabled and
1032 // then quickly disabled.
1033 SetupCommonProxiesExpectations();
1034 EXPECT_CALL(*simple_proxy_,
1035 Connect(_, _, _, CellularCapabilityGSM::kTimeoutConnect))
1036 .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeConnectFail));
1037 EXPECT_CALL(*this, TestCallback(IsFailure()));
Thieu Leb5954a22012-05-18 10:37:34 -07001038 InitProxies();
1039 EXPECT_FALSE(capability_->cellular()->service());
1040 Error error;
1041 DBusPropertiesMap props;
1042 capability_->Connect(props, &error,
1043 Bind(&CellularCapabilityGSMTest::TestCallback,
1044 Unretained(this)));
1045}
1046
Darin Petkovb05315f2011-11-07 10:14:25 +01001047} // namespace shill