Darin Petkov | c64fe5e | 2012-01-11 12:46:13 +0100 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 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 Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 7 | #include <base/bind.h> |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 8 | #include <chromeos/dbus/service_constants.h> |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 9 | #include <gtest/gtest.h> |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 10 | #include <mm/mm-modem.h> |
Darin Petkov | 1272a43 | 2011-11-10 15:53:37 +0100 | [diff] [blame] | 11 | #include <mobile_provider.h> |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 12 | |
| 13 | #include "shill/cellular.h" |
Darin Petkov | 3e50924 | 2011-11-10 14:46:44 +0100 | [diff] [blame] | 14 | #include "shill/cellular_service.h" |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 15 | #include "shill/error.h" |
| 16 | #include "shill/event_dispatcher.h" |
Darin Petkov | 3cfbf21 | 2011-11-21 16:02:09 +0100 | [diff] [blame] | 17 | #include "shill/mock_adaptors.h" |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 18 | #include "shill/mock_metrics.h" |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 19 | #include "shill/mock_modem_gsm_card_proxy.h" |
Darin Petkov | 3e50924 | 2011-11-10 14:46:44 +0100 | [diff] [blame] | 20 | #include "shill/mock_modem_gsm_network_proxy.h" |
Thieu Le | 923006b | 2012-04-05 16:32:58 -0700 | [diff] [blame] | 21 | #include "shill/mock_modem_proxy.h" |
| 22 | #include "shill/mock_modem_simple_proxy.h" |
Eric Shienbrood | 30bc0ec | 2012-03-21 18:19:46 -0400 | [diff] [blame] | 23 | #include "shill/mock_profile.h" |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 24 | #include "shill/nice_mock_control.h" |
Thieu Le | 923006b | 2012-04-05 16:32:58 -0700 | [diff] [blame] | 25 | #include "shill/proxy_factory.h" |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 26 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 27 | using base::Bind; |
| 28 | using base::Unretained; |
Darin Petkov | 3133241 | 2012-01-28 01:50:02 +0100 | [diff] [blame] | 29 | using std::string; |
Darin Petkov | e5bc2cb | 2011-12-07 14:47:32 +0100 | [diff] [blame] | 30 | using testing::_; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 31 | using testing::Invoke; |
Darin Petkov | 3cfbf21 | 2011-11-21 16:02:09 +0100 | [diff] [blame] | 32 | using testing::NiceMock; |
Darin Petkov | cb54773 | 2011-11-09 13:55:26 +0100 | [diff] [blame] | 33 | using testing::Return; |
| 34 | |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 35 | namespace shill { |
| 36 | |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 37 | MATCHER(IsSuccess, "") { |
| 38 | return arg.IsSuccess(); |
| 39 | } |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 40 | |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 41 | class CellularCapabilityGSMTest : public testing::Test { |
| 42 | public: |
| 43 | CellularCapabilityGSMTest() |
| 44 | : cellular_(new Cellular(&control_, |
| 45 | &dispatcher_, |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 46 | &metrics_, |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 47 | NULL, |
| 48 | "", |
Darin Petkov | 3133241 | 2012-01-28 01:50:02 +0100 | [diff] [blame] | 49 | kAddress, |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 50 | 0, |
| 51 | Cellular::kTypeGSM, |
| 52 | "", |
| 53 | "", |
| 54 | NULL)), |
Thieu Le | 923006b | 2012-04-05 16:32:58 -0700 | [diff] [blame] | 55 | proxy_(new MockModemProxy()), |
| 56 | simple_proxy_(new MockModemSimpleProxy()), |
Darin Petkov | cb54773 | 2011-11-09 13:55:26 +0100 | [diff] [blame] | 57 | card_proxy_(new MockModemGSMCardProxy()), |
Darin Petkov | 3e50924 | 2011-11-10 14:46:44 +0100 | [diff] [blame] | 58 | network_proxy_(new MockModemGSMNetworkProxy()), |
Thieu Le | 923006b | 2012-04-05 16:32:58 -0700 | [diff] [blame] | 59 | proxy_factory_(this), |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 60 | capability_(NULL), |
Darin Petkov | 3cfbf21 | 2011-11-21 16:02:09 +0100 | [diff] [blame] | 61 | device_adaptor_(NULL), |
Darin Petkov | 1272a43 | 2011-11-10 15:53:37 +0100 | [diff] [blame] | 62 | provider_db_(NULL) {} |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 63 | |
Darin Petkov | 3e50924 | 2011-11-10 14:46:44 +0100 | [diff] [blame] | 64 | virtual ~CellularCapabilityGSMTest() { |
| 65 | cellular_->service_ = NULL; |
Darin Petkov | 1272a43 | 2011-11-10 15:53:37 +0100 | [diff] [blame] | 66 | mobile_provider_close_db(provider_db_); |
| 67 | provider_db_ = NULL; |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 68 | capability_ = NULL; |
Darin Petkov | 3cfbf21 | 2011-11-21 16:02:09 +0100 | [diff] [blame] | 69 | device_adaptor_ = NULL; |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | virtual void SetUp() { |
| 73 | capability_ = |
| 74 | dynamic_cast<CellularCapabilityGSM *>(cellular_->capability_.get()); |
Darin Petkov | 3cfbf21 | 2011-11-21 16:02:09 +0100 | [diff] [blame] | 75 | device_adaptor_ = |
| 76 | dynamic_cast<NiceMock<DeviceMockAdaptor> *>(cellular_->adaptor()); |
Darin Petkov | 3e50924 | 2011-11-10 14:46:44 +0100 | [diff] [blame] | 77 | } |
| 78 | |
Thieu Le | 923006b | 2012-04-05 16:32:58 -0700 | [diff] [blame] | 79 | void InvokeEnable(bool enable, Error *error, |
| 80 | const ResultCallback &callback, int timeout) { |
| 81 | callback.Run(Error()); |
| 82 | } |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 83 | void InvokeGetIMEI(Error *error, const GSMIdentifierCallback &callback, |
| 84 | int timeout) { |
| 85 | callback.Run(kIMEI, Error()); |
| 86 | } |
| 87 | void InvokeGetIMSI(Error *error, const GSMIdentifierCallback &callback, |
| 88 | int timeout) { |
| 89 | callback.Run(kIMSI, Error()); |
| 90 | } |
| 91 | void InvokeGetIMSI2(Error *error, const GSMIdentifierCallback &callback, |
| 92 | int timeout) { |
| 93 | callback.Run("310240123456789", Error()); |
| 94 | } |
| 95 | void InvokeGetMSISDN(Error *error, const GSMIdentifierCallback &callback, |
| 96 | int timeout) { |
| 97 | callback.Run(kMSISDN, Error()); |
| 98 | } |
Thieu Le | 923006b | 2012-04-05 16:32:58 -0700 | [diff] [blame] | 99 | void InvokeGetMSISDNFail(Error *error, const GSMIdentifierCallback &callback, |
| 100 | int timeout) { |
| 101 | callback.Run("", Error(Error::kOperationFailed)); |
| 102 | } |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 103 | void InvokeGetSPN(Error *error, const GSMIdentifierCallback &callback, |
| 104 | int timeout) { |
| 105 | callback.Run(kTestCarrier, Error()); |
| 106 | } |
Thieu Le | 923006b | 2012-04-05 16:32:58 -0700 | [diff] [blame] | 107 | void InvokeGetSPNFail(Error *error, const GSMIdentifierCallback &callback, |
| 108 | int timeout) { |
| 109 | callback.Run("", Error(Error::kOperationFailed)); |
| 110 | } |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 111 | void InvokeGetSignalQuality(Error *error, |
| 112 | const SignalQualityCallback &callback, |
| 113 | int timeout) { |
| 114 | callback.Run(kStrength, Error()); |
| 115 | } |
| 116 | void InvokeGetRegistrationInfo(Error *error, |
| 117 | const RegistrationInfoCallback &callback, |
| 118 | int timeout) { |
| 119 | callback.Run(MM_MODEM_GSM_NETWORK_REG_STATUS_HOME, |
| 120 | kTestNetwork, kTestCarrier, Error()); |
| 121 | } |
| 122 | void InvokeRegister(const string &network_id, |
| 123 | Error *error, |
| 124 | const ResultCallback &callback, |
| 125 | int timeout) { |
| 126 | callback.Run(Error()); |
| 127 | } |
| 128 | void InvokeEnablePIN(const string &pin, bool enable, |
| 129 | Error *error, const ResultCallback &callback, |
| 130 | int timeout) { |
| 131 | callback.Run(Error()); |
| 132 | } |
| 133 | void InvokeSendPIN(const string &pin, Error *error, |
| 134 | const ResultCallback &callback, int timeout) { |
| 135 | callback.Run(Error()); |
| 136 | } |
| 137 | void InvokeSendPUK(const string &puk, const string &pin, Error *error, |
| 138 | const ResultCallback &callback, int timeout) { |
| 139 | callback.Run(Error()); |
| 140 | } |
| 141 | void InvokeChangePIN(const string &old_pin, const string &pin, Error *error, |
| 142 | const ResultCallback &callback, int timeout) { |
| 143 | callback.Run(Error()); |
| 144 | } |
| 145 | void InvokeScan(Error *error, const ScanResultsCallback &callback, |
| 146 | int timeout) { |
| 147 | GSMScanResults results; |
| 148 | results.push_back(GSMScanResult()); |
| 149 | results[0][CellularCapabilityGSM::kNetworkPropertyID] = kScanID0; |
| 150 | results.push_back(GSMScanResult()); |
| 151 | results[1][CellularCapabilityGSM::kNetworkPropertyID] = kScanID1; |
| 152 | callback.Run(results, Error()); |
| 153 | } |
Thieu Le | 923006b | 2012-04-05 16:32:58 -0700 | [diff] [blame] | 154 | void InvokeGetModemStatus(Error *error, |
| 155 | const DBusPropertyMapCallback &callback, |
| 156 | int timeout) { |
| 157 | DBusPropertiesMap props; |
| 158 | callback.Run(props, Error()); |
| 159 | } |
| 160 | void InvokeGetModemInfo(Error *error, const ModemInfoCallback &callback, |
| 161 | int timeout) { |
| 162 | ModemHardwareInfo info; |
| 163 | callback.Run(info, Error()); |
| 164 | } |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 165 | |
| 166 | MOCK_METHOD1(TestCallback, void(const Error &error)); |
| 167 | |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 168 | protected: |
Darin Petkov | 3133241 | 2012-01-28 01:50:02 +0100 | [diff] [blame] | 169 | static const char kAddress[]; |
Darin Petkov | 1272a43 | 2011-11-10 15:53:37 +0100 | [diff] [blame] | 170 | static const char kTestMobileProviderDBPath[]; |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 171 | static const char kTestNetwork[]; |
Darin Petkov | cb54773 | 2011-11-09 13:55:26 +0100 | [diff] [blame] | 172 | static const char kTestCarrier[]; |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 173 | static const char kPIN[]; |
| 174 | static const char kPUK[]; |
Darin Petkov | cb54773 | 2011-11-09 13:55:26 +0100 | [diff] [blame] | 175 | static const char kIMEI[]; |
| 176 | static const char kIMSI[]; |
| 177 | static const char kMSISDN[]; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 178 | static const char kScanID0[]; |
| 179 | static const char kScanID1[]; |
| 180 | static const int kStrength; |
Darin Petkov | cb54773 | 2011-11-09 13:55:26 +0100 | [diff] [blame] | 181 | |
Thieu Le | 923006b | 2012-04-05 16:32:58 -0700 | [diff] [blame] | 182 | class TestProxyFactory : public ProxyFactory { |
| 183 | public: |
| 184 | explicit TestProxyFactory(CellularCapabilityGSMTest *test) : test_(test) {} |
| 185 | |
| 186 | virtual ModemProxyInterface *CreateModemProxy( |
| 187 | const string &/*path*/, |
| 188 | const string &/*service*/) { |
| 189 | return test_->proxy_.release(); |
| 190 | } |
| 191 | |
| 192 | virtual ModemSimpleProxyInterface *CreateModemSimpleProxy( |
| 193 | const string &/*path*/, |
| 194 | const string &/*service*/) { |
| 195 | return test_->simple_proxy_.release(); |
| 196 | } |
| 197 | |
| 198 | virtual ModemGSMCardProxyInterface *CreateModemGSMCardProxy( |
| 199 | const string &/*path*/, |
| 200 | const string &/*service*/) { |
| 201 | return test_->card_proxy_.release(); |
| 202 | } |
| 203 | |
| 204 | virtual ModemGSMNetworkProxyInterface *CreateModemGSMNetworkProxy( |
| 205 | const string &/*path*/, |
| 206 | const string &/*service*/) { |
| 207 | return test_->network_proxy_.release(); |
| 208 | } |
| 209 | |
| 210 | private: |
| 211 | CellularCapabilityGSMTest *test_; |
| 212 | }; |
| 213 | |
| 214 | void SetProxy() { |
| 215 | capability_->proxy_.reset(proxy_.release()); |
| 216 | } |
| 217 | |
Darin Petkov | cb54773 | 2011-11-09 13:55:26 +0100 | [diff] [blame] | 218 | void SetCardProxy() { |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 219 | capability_->card_proxy_.reset(card_proxy_.release()); |
Darin Petkov | cb54773 | 2011-11-09 13:55:26 +0100 | [diff] [blame] | 220 | } |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 221 | |
Darin Petkov | 1272a43 | 2011-11-10 15:53:37 +0100 | [diff] [blame] | 222 | void SetNetworkProxy() { |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 223 | capability_->network_proxy_.reset(network_proxy_.release()); |
Darin Petkov | 1272a43 | 2011-11-10 15:53:37 +0100 | [diff] [blame] | 224 | } |
| 225 | |
Thieu Le | 923006b | 2012-04-05 16:32:58 -0700 | [diff] [blame] | 226 | void SetProxyFactory() { |
| 227 | capability_->proxy_factory_ = &proxy_factory_; |
| 228 | } |
| 229 | |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 230 | void SetAccessTechnology(uint32 technology) { |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 231 | capability_->access_technology_ = technology; |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | void SetRegistrationState(uint32 state) { |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 235 | capability_->registration_state_ = state; |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 236 | } |
| 237 | |
Darin Petkov | 3e50924 | 2011-11-10 14:46:44 +0100 | [diff] [blame] | 238 | void SetService() { |
| 239 | cellular_->service_ = new CellularService( |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 240 | &control_, &dispatcher_, &metrics_, NULL, cellular_); |
Darin Petkov | 3e50924 | 2011-11-10 14:46:44 +0100 | [diff] [blame] | 241 | } |
| 242 | |
Darin Petkov | 1272a43 | 2011-11-10 15:53:37 +0100 | [diff] [blame] | 243 | void InitProviderDB() { |
| 244 | provider_db_ = mobile_provider_open_db(kTestMobileProviderDBPath); |
| 245 | ASSERT_TRUE(provider_db_); |
| 246 | cellular_->provider_db_ = provider_db_; |
| 247 | } |
| 248 | |
Thieu Le | 923006b | 2012-04-05 16:32:58 -0700 | [diff] [blame] | 249 | void SetupCommonStartModemExpectations() { |
| 250 | EXPECT_CALL(*proxy_, set_state_changed_callback(_)); |
| 251 | EXPECT_CALL(*network_proxy_, set_signal_quality_callback(_)); |
| 252 | EXPECT_CALL(*network_proxy_, set_network_mode_callback(_)); |
| 253 | EXPECT_CALL(*network_proxy_, set_registration_info_callback(_)); |
| 254 | |
| 255 | EXPECT_CALL(*proxy_, Enable(_, _, _, CellularCapability::kTimeoutEnable)) |
| 256 | .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeEnable)); |
| 257 | EXPECT_CALL(*network_proxy_, |
| 258 | Register(_, _, _, CellularCapabilityGSM::kTimeoutRegister)) |
| 259 | .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeRegister)); |
| 260 | EXPECT_CALL(*simple_proxy_, |
| 261 | GetModemStatus(_, _, CellularCapability::kTimeoutDefault)) |
| 262 | .WillOnce(Invoke(this, |
| 263 | &CellularCapabilityGSMTest::InvokeGetModemStatus)); |
| 264 | EXPECT_CALL(*card_proxy_, |
| 265 | GetIMEI(_, _, CellularCapability::kTimeoutDefault)) |
| 266 | .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeGetIMEI)); |
| 267 | EXPECT_CALL(*card_proxy_, |
| 268 | GetIMSI(_, _, CellularCapability::kTimeoutDefault)) |
| 269 | .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeGetIMSI)); |
| 270 | EXPECT_CALL(*network_proxy_, AccessTechnology()); |
| 271 | EXPECT_CALL(*card_proxy_, EnabledFacilityLocks()); |
| 272 | EXPECT_CALL(*proxy_, |
| 273 | GetModemInfo(_, _, CellularCapability::kTimeoutDefault)) |
| 274 | .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeGetModemInfo)); |
| 275 | EXPECT_CALL(*network_proxy_, |
| 276 | GetRegistrationInfo(_, _, CellularCapability::kTimeoutDefault)); |
| 277 | EXPECT_CALL(*network_proxy_, |
| 278 | GetSignalQuality(_, _, CellularCapability::kTimeoutDefault)); |
| 279 | EXPECT_CALL(*this, TestCallback(IsSuccess())); |
| 280 | } |
| 281 | |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 282 | NiceMockControl control_; |
| 283 | EventDispatcher dispatcher_; |
Thieu Le | 3426c8f | 2012-01-11 17:35:11 -0800 | [diff] [blame] | 284 | MockMetrics metrics_; |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 285 | CellularRefPtr cellular_; |
Thieu Le | 923006b | 2012-04-05 16:32:58 -0700 | [diff] [blame] | 286 | scoped_ptr<MockModemProxy> proxy_; |
| 287 | scoped_ptr<MockModemSimpleProxy> simple_proxy_; |
Darin Petkov | cb54773 | 2011-11-09 13:55:26 +0100 | [diff] [blame] | 288 | scoped_ptr<MockModemGSMCardProxy> card_proxy_; |
Darin Petkov | 3e50924 | 2011-11-10 14:46:44 +0100 | [diff] [blame] | 289 | scoped_ptr<MockModemGSMNetworkProxy> network_proxy_; |
Thieu Le | 923006b | 2012-04-05 16:32:58 -0700 | [diff] [blame] | 290 | TestProxyFactory proxy_factory_; |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 291 | CellularCapabilityGSM *capability_; // Owned by |cellular_|. |
Darin Petkov | 3cfbf21 | 2011-11-21 16:02:09 +0100 | [diff] [blame] | 292 | NiceMock<DeviceMockAdaptor> *device_adaptor_; // Owned by |cellular_|. |
Darin Petkov | 1272a43 | 2011-11-10 15:53:37 +0100 | [diff] [blame] | 293 | mobile_provider_db *provider_db_; |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 294 | }; |
| 295 | |
Darin Petkov | 3133241 | 2012-01-28 01:50:02 +0100 | [diff] [blame] | 296 | const char CellularCapabilityGSMTest::kAddress[] = "1122334455"; |
Darin Petkov | 1272a43 | 2011-11-10 15:53:37 +0100 | [diff] [blame] | 297 | const char CellularCapabilityGSMTest::kTestMobileProviderDBPath[] = |
| 298 | "provider_db_unittest.bfd"; |
Darin Petkov | cb54773 | 2011-11-09 13:55:26 +0100 | [diff] [blame] | 299 | const char CellularCapabilityGSMTest::kTestCarrier[] = "The Cellular Carrier"; |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 300 | const char CellularCapabilityGSMTest::kTestNetwork[] = "310555"; |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 301 | const char CellularCapabilityGSMTest::kPIN[] = "9876"; |
| 302 | const char CellularCapabilityGSMTest::kPUK[] = "8765"; |
Darin Petkov | cb54773 | 2011-11-09 13:55:26 +0100 | [diff] [blame] | 303 | const char CellularCapabilityGSMTest::kIMEI[] = "987654321098765"; |
Darin Petkov | 0a4dfeb | 2011-11-18 19:36:13 +0100 | [diff] [blame] | 304 | const char CellularCapabilityGSMTest::kIMSI[] = "310150123456789"; |
Darin Petkov | cb54773 | 2011-11-09 13:55:26 +0100 | [diff] [blame] | 305 | const char CellularCapabilityGSMTest::kMSISDN[] = "12345678901"; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 306 | const char CellularCapabilityGSMTest::kScanID0[] = "123"; |
| 307 | const char CellularCapabilityGSMTest::kScanID1[] = "456"; |
| 308 | const int CellularCapabilityGSMTest::kStrength = 80; |
Darin Petkov | cb54773 | 2011-11-09 13:55:26 +0100 | [diff] [blame] | 309 | |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 310 | TEST_F(CellularCapabilityGSMTest, PropertyStore) { |
| 311 | EXPECT_TRUE(cellular_->store().Contains(flimflam::kSIMLockStatusProperty)); |
| 312 | } |
| 313 | |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 314 | TEST_F(CellularCapabilityGSMTest, GetIMEI) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 315 | EXPECT_CALL(*card_proxy_, GetIMEI(_, _, CellularCapability::kTimeoutDefault)) |
| 316 | .WillOnce(Invoke(this, |
| 317 | &CellularCapabilityGSMTest::InvokeGetIMEI)); |
| 318 | EXPECT_CALL(*this, TestCallback(IsSuccess())); |
Darin Petkov | cb54773 | 2011-11-09 13:55:26 +0100 | [diff] [blame] | 319 | SetCardProxy(); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 320 | ASSERT_TRUE(capability_->imei_.empty()); |
| 321 | capability_->GetIMEI(Bind(&CellularCapabilityGSMTest::TestCallback, |
| 322 | Unretained(this))); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 323 | EXPECT_EQ(kIMEI, capability_->imei_); |
| 324 | } |
| 325 | |
| 326 | TEST_F(CellularCapabilityGSMTest, GetIMSI) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 327 | EXPECT_CALL(*card_proxy_, GetIMSI(_, _, CellularCapability::kTimeoutDefault)) |
| 328 | .WillOnce(Invoke(this, |
| 329 | &CellularCapabilityGSMTest::InvokeGetIMSI)) |
| 330 | .WillOnce(Invoke(this, |
| 331 | &CellularCapabilityGSMTest::InvokeGetIMSI2)); |
| 332 | EXPECT_CALL(*this, TestCallback(IsSuccess())).Times(2); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 333 | SetCardProxy(); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 334 | ResultCallback callback = Bind(&CellularCapabilityGSMTest::TestCallback, |
| 335 | Unretained(this)); |
| 336 | ASSERT_TRUE(capability_->imsi_.empty()); |
| 337 | capability_->GetIMSI(callback); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 338 | EXPECT_EQ(kIMSI, capability_->imsi_); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 339 | capability_->imsi_.clear(); |
Darin Petkov | 0a4dfeb | 2011-11-18 19:36:13 +0100 | [diff] [blame] | 340 | InitProviderDB(); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 341 | capability_->GetIMSI(callback); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 342 | EXPECT_EQ("T-Mobile", cellular_->home_provider().GetName()); |
| 343 | } |
| 344 | |
| 345 | TEST_F(CellularCapabilityGSMTest, GetMSISDN) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 346 | EXPECT_CALL(*card_proxy_, GetMSISDN(_, _, |
| 347 | CellularCapability::kTimeoutDefault)) |
| 348 | .WillOnce(Invoke(this, |
| 349 | &CellularCapabilityGSMTest::InvokeGetMSISDN)); |
| 350 | EXPECT_CALL(*this, TestCallback(IsSuccess())); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 351 | SetCardProxy(); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 352 | ASSERT_TRUE(capability_->mdn_.empty()); |
| 353 | capability_->GetMSISDN(Bind(&CellularCapabilityGSMTest::TestCallback, |
| 354 | Unretained(this))); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 355 | EXPECT_EQ(kMSISDN, capability_->mdn_); |
| 356 | } |
| 357 | |
| 358 | TEST_F(CellularCapabilityGSMTest, GetSPN) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 359 | EXPECT_CALL(*card_proxy_, GetSPN(_, _, CellularCapability::kTimeoutDefault)) |
| 360 | .WillOnce(Invoke(this, |
| 361 | &CellularCapabilityGSMTest::InvokeGetSPN)); |
| 362 | EXPECT_CALL(*this, TestCallback(IsSuccess())); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 363 | SetCardProxy(); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 364 | ASSERT_TRUE(capability_->spn_.empty()); |
| 365 | capability_->GetSPN(Bind(&CellularCapabilityGSMTest::TestCallback, |
| 366 | Unretained(this))); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 367 | EXPECT_EQ(kTestCarrier, capability_->spn_); |
Darin Petkov | cb54773 | 2011-11-09 13:55:26 +0100 | [diff] [blame] | 368 | } |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 369 | |
Darin Petkov | 3e50924 | 2011-11-10 14:46:44 +0100 | [diff] [blame] | 370 | TEST_F(CellularCapabilityGSMTest, GetSignalQuality) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 371 | EXPECT_CALL(*network_proxy_, |
| 372 | GetSignalQuality(_, _, CellularCapability::kTimeoutDefault)) |
| 373 | .WillOnce(Invoke(this, |
| 374 | &CellularCapabilityGSMTest::InvokeGetSignalQuality)); |
Darin Petkov | 3e50924 | 2011-11-10 14:46:44 +0100 | [diff] [blame] | 375 | SetNetworkProxy(); |
| 376 | SetService(); |
| 377 | EXPECT_EQ(0, cellular_->service()->strength()); |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 378 | capability_->GetSignalQuality(); |
Darin Petkov | 3e50924 | 2011-11-10 14:46:44 +0100 | [diff] [blame] | 379 | EXPECT_EQ(kStrength, cellular_->service()->strength()); |
| 380 | } |
| 381 | |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 382 | TEST_F(CellularCapabilityGSMTest, RegisterOnNetwork) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 383 | EXPECT_CALL(*network_proxy_, Register(kTestNetwork, _, _, |
| 384 | CellularCapability::kTimeoutRegister)) |
| 385 | .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeRegister)); |
| 386 | EXPECT_CALL(*this, TestCallback(IsSuccess())); |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 387 | SetNetworkProxy(); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 388 | Error error; |
| 389 | capability_->RegisterOnNetwork(kTestNetwork, &error, |
| 390 | Bind(&CellularCapabilityGSMTest::TestCallback, |
| 391 | Unretained(this))); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 392 | EXPECT_EQ(kTestNetwork, capability_->selected_network_); |
Darin Petkov | 184c54e | 2011-11-15 12:44:39 +0100 | [diff] [blame] | 393 | } |
| 394 | |
Darin Petkov | b72cf40 | 2011-11-22 14:51:39 +0100 | [diff] [blame] | 395 | TEST_F(CellularCapabilityGSMTest, IsRegistered) { |
| 396 | EXPECT_FALSE(capability_->IsRegistered()); |
| 397 | SetRegistrationState(MM_MODEM_GSM_NETWORK_REG_STATUS_IDLE); |
| 398 | EXPECT_FALSE(capability_->IsRegistered()); |
| 399 | SetRegistrationState(MM_MODEM_GSM_NETWORK_REG_STATUS_HOME); |
| 400 | EXPECT_TRUE(capability_->IsRegistered()); |
| 401 | SetRegistrationState(MM_MODEM_GSM_NETWORK_REG_STATUS_SEARCHING); |
| 402 | EXPECT_FALSE(capability_->IsRegistered()); |
| 403 | SetRegistrationState(MM_MODEM_GSM_NETWORK_REG_STATUS_DENIED); |
| 404 | EXPECT_FALSE(capability_->IsRegistered()); |
| 405 | SetRegistrationState(MM_MODEM_GSM_NETWORK_REG_STATUS_UNKNOWN); |
| 406 | EXPECT_FALSE(capability_->IsRegistered()); |
| 407 | SetRegistrationState(MM_MODEM_GSM_NETWORK_REG_STATUS_ROAMING); |
| 408 | EXPECT_TRUE(capability_->IsRegistered()); |
| 409 | } |
| 410 | |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 411 | TEST_F(CellularCapabilityGSMTest, GetRegistrationState) { |
| 412 | ASSERT_FALSE(capability_->IsRegistered()); |
| 413 | EXPECT_CALL(*network_proxy_, |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 414 | GetRegistrationInfo(_, _, CellularCapability::kTimeoutDefault)) |
| 415 | .WillOnce(Invoke(this, |
| 416 | &CellularCapabilityGSMTest::InvokeGetRegistrationInfo)); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 417 | SetNetworkProxy(); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 418 | capability_->GetRegistrationState(); |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 419 | EXPECT_TRUE(capability_->IsRegistered()); |
| 420 | EXPECT_EQ(MM_MODEM_GSM_NETWORK_REG_STATUS_HOME, |
| 421 | capability_->registration_state_); |
| 422 | } |
| 423 | |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 424 | TEST_F(CellularCapabilityGSMTest, RequirePIN) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 425 | EXPECT_CALL(*card_proxy_, EnablePIN(kPIN, true, _, _, |
| 426 | CellularCapability::kTimeoutDefault)) |
| 427 | .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeEnablePIN)); |
| 428 | EXPECT_CALL(*this, TestCallback(IsSuccess())); |
Darin Petkov | cb54773 | 2011-11-09 13:55:26 +0100 | [diff] [blame] | 429 | SetCardProxy(); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 430 | Error error; |
| 431 | capability_->RequirePIN(kPIN, true, &error, |
| 432 | Bind(&CellularCapabilityGSMTest::TestCallback, |
| 433 | Unretained(this))); |
| 434 | EXPECT_TRUE(error.IsSuccess()); |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 435 | } |
| 436 | |
| 437 | TEST_F(CellularCapabilityGSMTest, EnterPIN) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 438 | EXPECT_CALL(*card_proxy_, SendPIN(kPIN, _, _, |
| 439 | CellularCapability::kTimeoutDefault)) |
| 440 | .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeSendPIN)); |
| 441 | EXPECT_CALL(*this, TestCallback(IsSuccess())); |
Darin Petkov | cb54773 | 2011-11-09 13:55:26 +0100 | [diff] [blame] | 442 | SetCardProxy(); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 443 | Error error; |
| 444 | capability_->EnterPIN(kPIN, &error, |
| 445 | Bind(&CellularCapabilityGSMTest::TestCallback, |
| 446 | Unretained(this))); |
| 447 | EXPECT_TRUE(error.IsSuccess()); |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 448 | } |
| 449 | |
| 450 | TEST_F(CellularCapabilityGSMTest, UnblockPIN) { |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 451 | EXPECT_CALL(*card_proxy_, SendPUK(kPUK, kPIN, _, _, |
| 452 | CellularCapability::kTimeoutDefault)) |
| 453 | .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeSendPUK)); |
| 454 | EXPECT_CALL(*this, TestCallback(IsSuccess())); |
Darin Petkov | cb54773 | 2011-11-09 13:55:26 +0100 | [diff] [blame] | 455 | SetCardProxy(); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 456 | Error error; |
| 457 | capability_->UnblockPIN(kPUK, kPIN, &error, |
| 458 | Bind(&CellularCapabilityGSMTest::TestCallback, |
| 459 | Unretained(this))); |
| 460 | EXPECT_TRUE(error.IsSuccess()); |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 461 | } |
| 462 | |
| 463 | TEST_F(CellularCapabilityGSMTest, ChangePIN) { |
| 464 | static const char kOldPIN[] = "1111"; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 465 | EXPECT_CALL(*card_proxy_, ChangePIN(kOldPIN, kPIN, _, _, |
| 466 | CellularCapability::kTimeoutDefault)) |
| 467 | .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeChangePIN)); |
| 468 | EXPECT_CALL(*this, TestCallback(IsSuccess())); |
Darin Petkov | cb54773 | 2011-11-09 13:55:26 +0100 | [diff] [blame] | 469 | SetCardProxy(); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 470 | Error error; |
| 471 | capability_->ChangePIN(kOldPIN, kPIN, &error, |
| 472 | Bind(&CellularCapabilityGSMTest::TestCallback, |
| 473 | Unretained(this))); |
| 474 | EXPECT_TRUE(error.IsSuccess()); |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 475 | } |
| 476 | |
Darin Petkov | b7828b0 | 2012-02-03 12:34:30 +0100 | [diff] [blame] | 477 | namespace { |
| 478 | |
| 479 | MATCHER(SizeIs2, "") { |
| 480 | return arg.size() == 2; |
| 481 | } |
| 482 | |
| 483 | } // namespace |
| 484 | |
Darin Petkov | 1272a43 | 2011-11-10 15:53:37 +0100 | [diff] [blame] | 485 | TEST_F(CellularCapabilityGSMTest, Scan) { |
Darin Petkov | 1272a43 | 2011-11-10 15:53:37 +0100 | [diff] [blame] | 486 | Error error; |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 487 | EXPECT_CALL(*network_proxy_, Scan(_, _, CellularCapability::kTimeoutScan)) |
| 488 | .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeScan)); |
| 489 | EXPECT_CALL(*this, TestCallback(IsSuccess())); |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 490 | capability_->found_networks_.resize(3, Stringmap()); |
Darin Petkov | b7828b0 | 2012-02-03 12:34:30 +0100 | [diff] [blame] | 491 | EXPECT_CALL(*device_adaptor_, |
| 492 | EmitStringmapsChanged(flimflam::kFoundNetworksProperty, |
| 493 | SizeIs2())); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 494 | SetNetworkProxy(); |
| 495 | capability_->Scan(&error, Bind(&CellularCapabilityGSMTest::TestCallback, |
| 496 | Unretained(this))); |
| 497 | EXPECT_TRUE(error.IsSuccess()); |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 498 | EXPECT_EQ(2, capability_->found_networks_.size()); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 499 | EXPECT_EQ(kScanID0, |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 500 | capability_->found_networks_[0][flimflam::kNetworkIdProperty]); |
Eric Shienbrood | 9a24553 | 2012-03-07 14:20:39 -0500 | [diff] [blame] | 501 | EXPECT_EQ(kScanID1, |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 502 | capability_->found_networks_[1][flimflam::kNetworkIdProperty]); |
Darin Petkov | 1272a43 | 2011-11-10 15:53:37 +0100 | [diff] [blame] | 503 | } |
| 504 | |
| 505 | TEST_F(CellularCapabilityGSMTest, ParseScanResult) { |
| 506 | static const char kID[] = "123"; |
| 507 | static const char kLongName[] = "long name"; |
| 508 | static const char kShortName[] = "short name"; |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 509 | GSMScanResult result; |
Darin Petkov | 1272a43 | 2011-11-10 15:53:37 +0100 | [diff] [blame] | 510 | result[CellularCapabilityGSM::kNetworkPropertyStatus] = "1"; |
| 511 | result[CellularCapabilityGSM::kNetworkPropertyID] = kID; |
| 512 | result[CellularCapabilityGSM::kNetworkPropertyLongName] = kLongName; |
| 513 | result[CellularCapabilityGSM::kNetworkPropertyShortName] = kShortName; |
| 514 | result[CellularCapabilityGSM::kNetworkPropertyAccessTechnology] = "3"; |
| 515 | result["unknown property"] = "random value"; |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 516 | Stringmap parsed = capability_->ParseScanResult(result); |
Darin Petkov | 1272a43 | 2011-11-10 15:53:37 +0100 | [diff] [blame] | 517 | EXPECT_EQ(5, parsed.size()); |
| 518 | EXPECT_EQ("available", parsed[flimflam::kStatusProperty]); |
| 519 | EXPECT_EQ(kID, parsed[flimflam::kNetworkIdProperty]); |
| 520 | EXPECT_EQ(kLongName, parsed[flimflam::kLongNameProperty]); |
| 521 | EXPECT_EQ(kShortName, parsed[flimflam::kShortNameProperty]); |
| 522 | EXPECT_EQ(flimflam::kNetworkTechnologyEdge, |
| 523 | parsed[flimflam::kTechnologyProperty]); |
| 524 | } |
| 525 | |
| 526 | TEST_F(CellularCapabilityGSMTest, ParseScanResultProviderLookup) { |
| 527 | InitProviderDB(); |
| 528 | static const char kID[] = "310210"; |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 529 | GSMScanResult result; |
Darin Petkov | 1272a43 | 2011-11-10 15:53:37 +0100 | [diff] [blame] | 530 | result[CellularCapabilityGSM::kNetworkPropertyID] = kID; |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 531 | Stringmap parsed = capability_->ParseScanResult(result); |
Darin Petkov | 1272a43 | 2011-11-10 15:53:37 +0100 | [diff] [blame] | 532 | EXPECT_EQ(2, parsed.size()); |
| 533 | EXPECT_EQ(kID, parsed[flimflam::kNetworkIdProperty]); |
| 534 | EXPECT_EQ("T-Mobile", parsed[flimflam::kLongNameProperty]); |
| 535 | } |
| 536 | |
Darin Petkov | ae0c64e | 2011-11-15 15:50:27 +0100 | [diff] [blame] | 537 | TEST_F(CellularCapabilityGSMTest, SetAccessTechnology) { |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 538 | capability_->SetAccessTechnology(MM_MODEM_GSM_ACCESS_TECH_GSM); |
| 539 | EXPECT_EQ(MM_MODEM_GSM_ACCESS_TECH_GSM, capability_->access_technology_); |
Darin Petkov | ae0c64e | 2011-11-15 15:50:27 +0100 | [diff] [blame] | 540 | SetService(); |
Darin Petkov | b72cf40 | 2011-11-22 14:51:39 +0100 | [diff] [blame] | 541 | SetRegistrationState(MM_MODEM_GSM_NETWORK_REG_STATUS_HOME); |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 542 | capability_->SetAccessTechnology(MM_MODEM_GSM_ACCESS_TECH_GPRS); |
| 543 | EXPECT_EQ(MM_MODEM_GSM_ACCESS_TECH_GPRS, capability_->access_technology_); |
Darin Petkov | ae0c64e | 2011-11-15 15:50:27 +0100 | [diff] [blame] | 544 | EXPECT_EQ(flimflam::kNetworkTechnologyGprs, |
Darin Petkov | b72cf40 | 2011-11-22 14:51:39 +0100 | [diff] [blame] | 545 | cellular_->service()->network_technology()); |
Darin Petkov | ae0c64e | 2011-11-15 15:50:27 +0100 | [diff] [blame] | 546 | } |
| 547 | |
| 548 | TEST_F(CellularCapabilityGSMTest, UpdateOperatorInfo) { |
| 549 | static const char kOperatorName[] = "Swisscom"; |
| 550 | InitProviderDB(); |
Darin Petkov | 0a4dfeb | 2011-11-18 19:36:13 +0100 | [diff] [blame] | 551 | capability_->serving_operator_.SetCode("22801"); |
Darin Petkov | ae0c64e | 2011-11-15 15:50:27 +0100 | [diff] [blame] | 552 | SetService(); |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 553 | capability_->UpdateOperatorInfo(); |
Darin Petkov | 0a4dfeb | 2011-11-18 19:36:13 +0100 | [diff] [blame] | 554 | EXPECT_EQ(kOperatorName, capability_->serving_operator_.GetName()); |
| 555 | EXPECT_EQ("ch", capability_->serving_operator_.GetCountry()); |
Darin Petkov | ae0c64e | 2011-11-15 15:50:27 +0100 | [diff] [blame] | 556 | EXPECT_EQ(kOperatorName, cellular_->service()->serving_operator().GetName()); |
| 557 | } |
| 558 | |
Darin Petkov | 0a4dfeb | 2011-11-18 19:36:13 +0100 | [diff] [blame] | 559 | TEST_F(CellularCapabilityGSMTest, UpdateStatus) { |
| 560 | InitProviderDB(); |
| 561 | DBusPropertiesMap props; |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 562 | capability_->imsi_ = "310240123456789"; |
| 563 | props[CellularCapability::kPropertyIMSI].writer().append_string(""); |
Darin Petkov | 0a4dfeb | 2011-11-18 19:36:13 +0100 | [diff] [blame] | 564 | capability_->UpdateStatus(props); |
| 565 | EXPECT_EQ("T-Mobile", cellular_->home_provider().GetName()); |
| 566 | } |
| 567 | |
| 568 | TEST_F(CellularCapabilityGSMTest, SetHomeProvider) { |
| 569 | static const char kCountry[] = "us"; |
| 570 | static const char kCode[] = "310160"; |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 571 | capability_->imsi_ = "310240123456789"; |
Darin Petkov | 0a4dfeb | 2011-11-18 19:36:13 +0100 | [diff] [blame] | 572 | |
| 573 | capability_->SetHomeProvider(); // No mobile provider DB available. |
| 574 | EXPECT_TRUE(cellular_->home_provider().GetName().empty()); |
| 575 | EXPECT_TRUE(cellular_->home_provider().GetCountry().empty()); |
| 576 | EXPECT_TRUE(cellular_->home_provider().GetCode().empty()); |
| 577 | |
| 578 | InitProviderDB(); |
| 579 | capability_->SetHomeProvider(); |
| 580 | EXPECT_EQ("T-Mobile", cellular_->home_provider().GetName()); |
| 581 | EXPECT_EQ(kCountry, cellular_->home_provider().GetCountry()); |
| 582 | EXPECT_EQ(kCode, cellular_->home_provider().GetCode()); |
Darin Petkov | 3cfbf21 | 2011-11-21 16:02:09 +0100 | [diff] [blame] | 583 | EXPECT_EQ(4, capability_->apn_list_.size()); |
Darin Petkov | 0a4dfeb | 2011-11-18 19:36:13 +0100 | [diff] [blame] | 584 | |
| 585 | Cellular::Operator oper; |
| 586 | cellular_->set_home_provider(oper); |
| 587 | capability_->spn_ = kTestCarrier; |
| 588 | capability_->SetHomeProvider(); |
| 589 | EXPECT_EQ(kTestCarrier, cellular_->home_provider().GetName()); |
| 590 | EXPECT_EQ(kCountry, cellular_->home_provider().GetCountry()); |
| 591 | EXPECT_EQ(kCode, cellular_->home_provider().GetCode()); |
| 592 | } |
| 593 | |
Darin Petkov | 3cfbf21 | 2011-11-21 16:02:09 +0100 | [diff] [blame] | 594 | namespace { |
| 595 | |
| 596 | MATCHER(SizeIs4, "") { |
| 597 | return arg.size() == 4; |
| 598 | } |
| 599 | |
| 600 | } // namespace |
| 601 | |
| 602 | TEST_F(CellularCapabilityGSMTest, InitAPNList) { |
| 603 | InitProviderDB(); |
| 604 | capability_->home_provider_ = |
| 605 | mobile_provider_lookup_by_name(cellular_->provider_db(), "T-Mobile"); |
| 606 | ASSERT_TRUE(capability_->home_provider_); |
| 607 | EXPECT_EQ(0, capability_->apn_list_.size()); |
| 608 | EXPECT_CALL(*device_adaptor_, |
| 609 | EmitStringmapsChanged(flimflam::kCellularApnListProperty, |
| 610 | SizeIs4())); |
| 611 | capability_->InitAPNList(); |
| 612 | EXPECT_EQ(4, capability_->apn_list_.size()); |
| 613 | EXPECT_EQ("wap.voicestream.com", |
| 614 | capability_->apn_list_[1][flimflam::kApnProperty]); |
| 615 | EXPECT_EQ("Web2Go/t-zones", |
| 616 | capability_->apn_list_[1][flimflam::kApnNameProperty]); |
| 617 | } |
| 618 | |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 619 | TEST_F(CellularCapabilityGSMTest, GetNetworkTechnologyString) { |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 620 | EXPECT_EQ("", capability_->GetNetworkTechnologyString()); |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 621 | SetAccessTechnology(MM_MODEM_GSM_ACCESS_TECH_GSM); |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 622 | EXPECT_EQ(flimflam::kNetworkTechnologyGsm, |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 623 | capability_->GetNetworkTechnologyString()); |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 624 | SetAccessTechnology(MM_MODEM_GSM_ACCESS_TECH_GSM_COMPACT); |
| 625 | EXPECT_EQ(flimflam::kNetworkTechnologyGsm, |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 626 | capability_->GetNetworkTechnologyString()); |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 627 | SetAccessTechnology(MM_MODEM_GSM_ACCESS_TECH_GPRS); |
| 628 | EXPECT_EQ(flimflam::kNetworkTechnologyGprs, |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 629 | capability_->GetNetworkTechnologyString()); |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 630 | SetAccessTechnology(MM_MODEM_GSM_ACCESS_TECH_EDGE); |
| 631 | EXPECT_EQ(flimflam::kNetworkTechnologyEdge, |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 632 | capability_->GetNetworkTechnologyString()); |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 633 | SetAccessTechnology(MM_MODEM_GSM_ACCESS_TECH_UMTS); |
| 634 | EXPECT_EQ(flimflam::kNetworkTechnologyUmts, |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 635 | capability_->GetNetworkTechnologyString()); |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 636 | SetAccessTechnology(MM_MODEM_GSM_ACCESS_TECH_HSDPA); |
| 637 | EXPECT_EQ(flimflam::kNetworkTechnologyHspa, |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 638 | capability_->GetNetworkTechnologyString()); |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 639 | SetAccessTechnology(MM_MODEM_GSM_ACCESS_TECH_HSUPA); |
| 640 | EXPECT_EQ(flimflam::kNetworkTechnologyHspa, |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 641 | capability_->GetNetworkTechnologyString()); |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 642 | SetAccessTechnology(MM_MODEM_GSM_ACCESS_TECH_HSPA); |
| 643 | EXPECT_EQ(flimflam::kNetworkTechnologyHspa, |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 644 | capability_->GetNetworkTechnologyString()); |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 645 | SetAccessTechnology(MM_MODEM_GSM_ACCESS_TECH_HSPA_PLUS); |
| 646 | EXPECT_EQ(flimflam::kNetworkTechnologyHspaPlus, |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 647 | capability_->GetNetworkTechnologyString()); |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 648 | } |
| 649 | |
| 650 | TEST_F(CellularCapabilityGSMTest, GetRoamingStateString) { |
| 651 | EXPECT_EQ(flimflam::kRoamingStateUnknown, |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 652 | capability_->GetRoamingStateString()); |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 653 | SetRegistrationState(MM_MODEM_GSM_NETWORK_REG_STATUS_HOME); |
| 654 | EXPECT_EQ(flimflam::kRoamingStateHome, |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 655 | capability_->GetRoamingStateString()); |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 656 | SetRegistrationState(MM_MODEM_GSM_NETWORK_REG_STATUS_ROAMING); |
| 657 | EXPECT_EQ(flimflam::kRoamingStateRoaming, |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 658 | capability_->GetRoamingStateString()); |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 659 | SetRegistrationState(MM_MODEM_GSM_NETWORK_REG_STATUS_SEARCHING); |
| 660 | EXPECT_EQ(flimflam::kRoamingStateUnknown, |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 661 | capability_->GetRoamingStateString()); |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 662 | SetRegistrationState(MM_MODEM_GSM_NETWORK_REG_STATUS_DENIED); |
| 663 | EXPECT_EQ(flimflam::kRoamingStateUnknown, |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 664 | capability_->GetRoamingStateString()); |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 665 | SetRegistrationState(MM_MODEM_GSM_NETWORK_REG_STATUS_IDLE); |
| 666 | EXPECT_EQ(flimflam::kRoamingStateUnknown, |
Darin Petkov | 721ac93 | 2011-11-16 15:43:09 +0100 | [diff] [blame] | 667 | capability_->GetRoamingStateString()); |
Darin Petkov | 20c13ec | 2011-11-09 15:07:15 +0100 | [diff] [blame] | 668 | } |
| 669 | |
Darin Petkov | ac635a8 | 2012-01-10 16:51:58 +0100 | [diff] [blame] | 670 | TEST_F(CellularCapabilityGSMTest, CreateFriendlyServiceName) { |
| 671 | CellularCapabilityGSM::friendly_service_name_id_ = 0; |
| 672 | EXPECT_EQ("GSMNetwork0", capability_->CreateFriendlyServiceName()); |
| 673 | EXPECT_EQ("GSMNetwork1", capability_->CreateFriendlyServiceName()); |
| 674 | capability_->serving_operator_.SetCode("1234"); |
| 675 | EXPECT_EQ("cellular_1234", capability_->CreateFriendlyServiceName()); |
| 676 | static const char kTestCarrier[] = "A GSM Carrier"; |
Eric Shienbrood | 5de44ab | 2011-12-05 10:46:27 -0500 | [diff] [blame] | 677 | capability_->carrier_ = kTestCarrier; |
Darin Petkov | ac635a8 | 2012-01-10 16:51:58 +0100 | [diff] [blame] | 678 | EXPECT_EQ(kTestCarrier, capability_->CreateFriendlyServiceName()); |
| 679 | static const char kTestOperator[] = "A GSM Operator"; |
| 680 | capability_->serving_operator_.SetName(kTestOperator); |
| 681 | EXPECT_EQ(kTestOperator, capability_->CreateFriendlyServiceName()); |
| 682 | static const char kHomeProvider[] = "The GSM Home Provider"; |
| 683 | cellular_->home_provider_.SetName(kHomeProvider); |
| 684 | EXPECT_EQ(kTestOperator, capability_->CreateFriendlyServiceName()); |
| 685 | capability_->registration_state_ = MM_MODEM_GSM_NETWORK_REG_STATUS_HOME; |
| 686 | EXPECT_EQ(kHomeProvider, capability_->CreateFriendlyServiceName()); |
| 687 | } |
| 688 | |
Darin Petkov | 3133241 | 2012-01-28 01:50:02 +0100 | [diff] [blame] | 689 | TEST_F(CellularCapabilityGSMTest, SetStorageIdentifier) { |
| 690 | SetService(); |
| 691 | capability_->OnServiceCreated(); |
Darin Petkov | dd3e866 | 2012-02-03 13:16:20 +0100 | [diff] [blame] | 692 | EXPECT_EQ(string(flimflam::kTypeCellular) + "_" + kAddress + "_" + |
Darin Petkov | 3133241 | 2012-01-28 01:50:02 +0100 | [diff] [blame] | 693 | cellular_->service()->friendly_name(), |
| 694 | cellular_->service()->GetStorageIdentifier()); |
| 695 | capability_->imsi_ = kIMSI; |
| 696 | capability_->OnServiceCreated(); |
Darin Petkov | dd3e866 | 2012-02-03 13:16:20 +0100 | [diff] [blame] | 697 | EXPECT_EQ(string(flimflam::kTypeCellular) + "_" + kAddress + "_" + kIMSI, |
Darin Petkov | 3133241 | 2012-01-28 01:50:02 +0100 | [diff] [blame] | 698 | cellular_->service()->GetStorageIdentifier()); |
| 699 | } |
| 700 | |
Darin Petkov | 63138a9 | 2012-02-06 14:09:15 +0100 | [diff] [blame] | 701 | TEST_F(CellularCapabilityGSMTest, OnModemManagerPropertiesChanged) { |
| 702 | EXPECT_EQ(MM_MODEM_GSM_ACCESS_TECH_UNKNOWN, capability_->access_technology_); |
| 703 | EXPECT_FALSE(capability_->sim_lock_status_.enabled); |
| 704 | EXPECT_EQ("", capability_->sim_lock_status_.lock_type); |
| 705 | EXPECT_EQ(0, capability_->sim_lock_status_.retries_left); |
| 706 | DBusPropertiesMap props; |
| 707 | static const char kLockType[] = "sim-pin"; |
| 708 | const int kRetries = 3; |
| 709 | props[CellularCapabilityGSM::kPropertyAccessTechnology].writer(). |
| 710 | append_uint32(MM_MODEM_GSM_ACCESS_TECH_EDGE); |
| 711 | props[CellularCapabilityGSM::kPropertyEnabledFacilityLocks].writer(). |
| 712 | append_uint32(MM_MODEM_GSM_FACILITY_SIM); |
| 713 | props[CellularCapabilityGSM::kPropertyUnlockRequired].writer().append_string( |
| 714 | kLockType); |
| 715 | props[CellularCapabilityGSM::kPropertyUnlockRetries].writer().append_uint32( |
| 716 | kRetries); |
| 717 | EXPECT_CALL(*device_adaptor_, |
| 718 | EmitKeyValueStoreChanged(flimflam::kSIMLockStatusProperty, _)); |
| 719 | capability_->OnModemManagerPropertiesChanged(props); |
| 720 | EXPECT_EQ(MM_MODEM_GSM_ACCESS_TECH_EDGE, capability_->access_technology_); |
| 721 | EXPECT_TRUE(capability_->sim_lock_status_.enabled); |
| 722 | EXPECT_EQ(kLockType, capability_->sim_lock_status_.lock_type); |
| 723 | EXPECT_EQ(kRetries, capability_->sim_lock_status_.retries_left); |
| 724 | } |
| 725 | |
Eric Shienbrood | 30bc0ec | 2012-03-21 18:19:46 -0400 | [diff] [blame] | 726 | TEST_F(CellularCapabilityGSMTest, SetupApnTryList) { |
| 727 | static const string kTmobileApn("epc.tmobile.com"); |
| 728 | static const string kLastGoodApn("remembered.apn"); |
| 729 | static const string kLastGoodUsername("remembered.user"); |
| 730 | static const string kSuppliedApn("my.apn"); |
| 731 | |
| 732 | SetService(); |
| 733 | capability_->imsi_ = "310240123456789"; |
| 734 | InitProviderDB(); |
| 735 | capability_->SetHomeProvider(); |
| 736 | DBusPropertiesMap props; |
| 737 | capability_->SetupConnectProperties(&props); |
| 738 | EXPECT_FALSE(props.find(flimflam::kApnProperty) == props.end()); |
| 739 | EXPECT_EQ(kTmobileApn, props[flimflam::kApnProperty].reader().get_string()); |
| 740 | |
| 741 | ProfileRefPtr profile(new NiceMock<MockProfile>( |
| 742 | &control_, reinterpret_cast<Manager *>(NULL))); |
| 743 | cellular_->service()->set_profile(profile); |
| 744 | Stringmap apn_info; |
| 745 | apn_info[flimflam::kApnProperty] = kLastGoodApn; |
| 746 | apn_info[flimflam::kApnUsernameProperty] = kLastGoodUsername; |
| 747 | cellular_->service()->SetLastGoodApn(apn_info); |
| 748 | props.clear(); |
| 749 | EXPECT_TRUE(props.find(flimflam::kApnProperty) == props.end()); |
| 750 | capability_->SetupConnectProperties(&props); |
| 751 | // We expect the list to contain the last good APN, plus |
| 752 | // the 4 APNs from the mobile provider info database. |
| 753 | EXPECT_EQ(5, capability_->apn_try_list_.size()); |
| 754 | EXPECT_FALSE(props.find(flimflam::kApnProperty) == props.end()); |
| 755 | EXPECT_EQ(kLastGoodApn, props[flimflam::kApnProperty].reader().get_string()); |
| 756 | EXPECT_FALSE(props.find(flimflam::kApnUsernameProperty) == props.end()); |
| 757 | EXPECT_EQ(kLastGoodUsername, |
| 758 | props[flimflam::kApnUsernameProperty].reader().get_string()); |
| 759 | |
| 760 | Error error; |
| 761 | apn_info.clear(); |
| 762 | props.clear(); |
| 763 | apn_info[flimflam::kApnProperty] = kSuppliedApn; |
| 764 | // Setting the APN has the side effect of clearing the LastGoodApn, |
| 765 | // so the try list will have 5 elements, with the first one being |
| 766 | // the supplied APN. |
| 767 | cellular_->service()->SetApn(apn_info, &error); |
| 768 | EXPECT_TRUE(props.find(flimflam::kApnProperty) == props.end()); |
| 769 | capability_->SetupConnectProperties(&props); |
| 770 | EXPECT_EQ(5, capability_->apn_try_list_.size()); |
| 771 | EXPECT_FALSE(props.find(flimflam::kApnProperty) == props.end()); |
| 772 | EXPECT_EQ(kSuppliedApn, props[flimflam::kApnProperty].reader().get_string()); |
| 773 | |
| 774 | apn_info.clear(); |
| 775 | props.clear(); |
| 776 | apn_info[flimflam::kApnProperty] = kLastGoodApn; |
| 777 | apn_info[flimflam::kApnUsernameProperty] = kLastGoodUsername; |
| 778 | // Now when LastGoodAPN is set, it will be the one selected. |
| 779 | cellular_->service()->SetLastGoodApn(apn_info); |
| 780 | EXPECT_TRUE(props.find(flimflam::kApnProperty) == props.end()); |
| 781 | capability_->SetupConnectProperties(&props); |
| 782 | // We expect the list to contain the last good APN, plus |
| 783 | // the user-supplied APN, plus the 4 APNs from the mobile |
| 784 | // provider info database. |
| 785 | EXPECT_EQ(6, capability_->apn_try_list_.size()); |
| 786 | EXPECT_FALSE(props.find(flimflam::kApnProperty) == props.end()); |
| 787 | EXPECT_EQ(kLastGoodApn, props[flimflam::kApnProperty].reader().get_string()); |
| 788 | EXPECT_FALSE(props.find(flimflam::kApnUsernameProperty) == props.end()); |
| 789 | EXPECT_EQ(kLastGoodUsername, |
| 790 | props[flimflam::kApnUsernameProperty].reader().get_string()); |
| 791 | } |
| 792 | |
Thieu Le | 923006b | 2012-04-05 16:32:58 -0700 | [diff] [blame] | 793 | TEST_F(CellularCapabilityGSMTest, StartModemSuccess) { |
| 794 | SetupCommonStartModemExpectations(); |
| 795 | EXPECT_CALL(*card_proxy_, |
| 796 | GetSPN(_, _, CellularCapability::kTimeoutDefault)) |
| 797 | .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeGetSPN)); |
| 798 | EXPECT_CALL(*card_proxy_, |
| 799 | GetMSISDN(_, _, CellularCapability::kTimeoutDefault)) |
| 800 | .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeGetMSISDN)); |
| 801 | SetProxyFactory(); |
| 802 | |
| 803 | Error error; |
| 804 | capability_->StartModem( |
| 805 | &error, Bind(&CellularCapabilityGSMTest::TestCallback, Unretained(this))); |
| 806 | dispatcher_.DispatchPendingEvents(); |
| 807 | } |
| 808 | |
| 809 | TEST_F(CellularCapabilityGSMTest, StartModemGetSPNFail) { |
| 810 | SetupCommonStartModemExpectations(); |
| 811 | EXPECT_CALL(*card_proxy_, |
| 812 | GetSPN(_, _, CellularCapability::kTimeoutDefault)) |
| 813 | .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeGetSPNFail)); |
| 814 | EXPECT_CALL(*card_proxy_, |
| 815 | GetMSISDN(_, _, CellularCapability::kTimeoutDefault)) |
| 816 | .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeGetMSISDN)); |
| 817 | SetProxyFactory(); |
| 818 | |
| 819 | Error error; |
| 820 | capability_->StartModem( |
| 821 | &error, Bind(&CellularCapabilityGSMTest::TestCallback, Unretained(this))); |
| 822 | dispatcher_.DispatchPendingEvents(); |
| 823 | } |
| 824 | |
| 825 | TEST_F(CellularCapabilityGSMTest, StartModemGetMSISDNFail) { |
| 826 | SetupCommonStartModemExpectations(); |
| 827 | EXPECT_CALL(*card_proxy_, |
| 828 | GetSPN(_, _, CellularCapability::kTimeoutDefault)) |
| 829 | .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeGetSPN)); |
| 830 | EXPECT_CALL(*card_proxy_, |
| 831 | GetMSISDN(_, _, CellularCapability::kTimeoutDefault)) |
| 832 | .WillOnce(Invoke(this, &CellularCapabilityGSMTest::InvokeGetMSISDNFail)); |
| 833 | SetProxyFactory(); |
| 834 | |
| 835 | Error error; |
| 836 | capability_->StartModem( |
| 837 | &error, Bind(&CellularCapabilityGSMTest::TestCallback, Unretained(this))); |
| 838 | dispatcher_.DispatchPendingEvents(); |
| 839 | } |
| 840 | |
Darin Petkov | b05315f | 2011-11-07 10:14:25 +0100 | [diff] [blame] | 841 | } // namespace shill |