Arman Uguray | f4c6181 | 2013-01-10 18:58:39 -0800 | [diff] [blame] | 1 | // Copyright (c) 2013 The Chromium OS Authors. All rights reserved. |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [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_universal.h" |
| 6 | |
Nathan Williams | 4b7c2a8 | 2012-04-13 15:19:47 -0400 | [diff] [blame] | 7 | #include <string> |
| 8 | #include <vector> |
| 9 | |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 10 | #include <base/bind.h> |
Darin Petkov | a4ca3c3 | 2012-08-17 16:05:24 +0200 | [diff] [blame] | 11 | #include <base/stringprintf.h> |
Arman Uguray | c953357 | 2013-01-22 17:34:20 -0800 | [diff] [blame] | 12 | #include <base/string_util.h> |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 13 | #include <chromeos/dbus/service_constants.h> |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 14 | #include <gmock/gmock.h> |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 15 | #include <gtest/gtest.h> |
| 16 | #include <mobile_provider.h> |
Ben Chan | 5c853ef | 2012-10-05 00:05:37 -0700 | [diff] [blame] | 17 | #include <ModemManager/ModemManager.h> |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 18 | |
| 19 | #include "shill/cellular.h" |
| 20 | #include "shill/cellular_service.h" |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 21 | #include "shill/dbus_adaptor.h" |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 22 | #include "shill/error.h" |
| 23 | #include "shill/event_dispatcher.h" |
| 24 | #include "shill/mock_adaptors.h" |
Ben Chan | 1578603 | 2012-11-04 21:28:02 -0800 | [diff] [blame] | 25 | #include "shill/mock_cellular_operator_info.h" |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 26 | #include "shill/mock_cellular_service.h" |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 27 | #include "shill/mock_dbus_properties_proxy.h" |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 28 | #include "shill/mock_event_dispatcher.h" |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 29 | #include "shill/mock_mm1_modem_modem3gpp_proxy.h" |
| 30 | #include "shill/mock_mm1_modem_modemcdma_proxy.h" |
| 31 | #include "shill/mock_mm1_modem_proxy.h" |
| 32 | #include "shill/mock_mm1_modem_simple_proxy.h" |
| 33 | #include "shill/mock_mm1_sim_proxy.h" |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 34 | #include "shill/mock_modem_info.h" |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 35 | #include "shill/mock_pending_activation_store.h" |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 36 | #include "shill/mock_profile.h" |
| 37 | #include "shill/mock_rtnl_handler.h" |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 38 | #include "shill/proxy_factory.h" |
| 39 | |
| 40 | using base::Bind; |
Darin Petkov | a4ca3c3 | 2012-08-17 16:05:24 +0200 | [diff] [blame] | 41 | using base::StringPrintf; |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 42 | using base::Unretained; |
| 43 | using std::string; |
Nathan Williams | 4b7c2a8 | 2012-04-13 15:19:47 -0400 | [diff] [blame] | 44 | using std::vector; |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 45 | using testing::InSequence; |
Ben Chan | 6d0d1e7 | 2012-11-06 21:19:28 -0800 | [diff] [blame] | 46 | using testing::Invoke; |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 47 | using testing::InvokeWithoutArgs; |
Gary Morain | e285a84 | 2012-08-15 08:23:57 -0700 | [diff] [blame] | 48 | using testing::Mock; |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 49 | using testing::NiceMock; |
| 50 | using testing::Return; |
Jason Glasgow | cd0349c | 2012-05-03 23:32:15 -0400 | [diff] [blame] | 51 | using testing::SaveArg; |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 52 | using testing::_; |
| 53 | |
| 54 | namespace shill { |
| 55 | |
| 56 | MATCHER(IsSuccess, "") { |
| 57 | return arg.IsSuccess(); |
| 58 | } |
| 59 | MATCHER(IsFailure, "") { |
| 60 | return arg.IsFailure(); |
| 61 | } |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 62 | MATCHER_P(HasApn, expected_apn, "") { |
| 63 | string apn; |
| 64 | return (DBusProperties::GetString(arg, |
| 65 | CellularCapabilityUniversal::kConnectApn, |
| 66 | &apn) && |
| 67 | apn == expected_apn); |
| 68 | } |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 69 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 70 | class CellularCapabilityUniversalTest : public testing::TestWithParam<string> { |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 71 | public: |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 72 | CellularCapabilityUniversalTest(EventDispatcher *dispatcher) |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 73 | : modem_info_(NULL, dispatcher, NULL, NULL, NULL), |
Ben Chan | 3ecdf82 | 2012-08-06 12:29:23 -0700 | [diff] [blame] | 74 | modem_3gpp_proxy_(new mm1::MockModemModem3gppProxy()), |
| 75 | modem_cdma_proxy_(new mm1::MockModemModemCdmaProxy()), |
| 76 | modem_proxy_(new mm1::MockModemProxy()), |
| 77 | modem_simple_proxy_(new mm1::MockModemSimpleProxy()), |
| 78 | sim_proxy_(new mm1::MockSimProxy()), |
| 79 | properties_proxy_(new MockDBusPropertiesProxy()), |
| 80 | proxy_factory_(this), |
| 81 | capability_(NULL), |
| 82 | device_adaptor_(NULL), |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 83 | cellular_(new Cellular(&modem_info_, |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 84 | "", |
Arman Uguray | c953357 | 2013-01-22 17:34:20 -0800 | [diff] [blame] | 85 | kMachineAddress, |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 86 | 0, |
| 87 | Cellular::kTypeUniversal, |
| 88 | "", |
| 89 | "", |
Jason Glasgow | a585fc3 | 2012-06-06 11:04:09 -0400 | [diff] [blame] | 90 | "", |
Ben Chan | 3ecdf82 | 2012-08-06 12:29:23 -0700 | [diff] [blame] | 91 | &proxy_factory_)), |
Prathmesh Prabhu | 0d36b4f | 2013-04-01 11:45:54 -0700 | [diff] [blame] | 92 | service_(new MockCellularService(&modem_info_, cellular_)) { |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 93 | modem_info_.metrics()->RegisterDevice(cellular_->interface_index(), |
| 94 | Technology::kCellular); |
Thieu Le | ce4483e | 2013-01-23 15:12:03 -0800 | [diff] [blame] | 95 | } |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 96 | |
| 97 | virtual ~CellularCapabilityUniversalTest() { |
| 98 | cellular_->service_ = NULL; |
| 99 | capability_ = NULL; |
| 100 | device_adaptor_ = NULL; |
| 101 | } |
| 102 | |
| 103 | virtual void SetUp() { |
| 104 | capability_ = dynamic_cast<CellularCapabilityUniversal *>( |
| 105 | cellular_->capability_.get()); |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 106 | device_adaptor_ = |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 107 | dynamic_cast<DeviceMockAdaptor *>(cellular_->adaptor()); |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 108 | cellular_->service_ = service_; |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 109 | |
| 110 | // kStateUnknown leads to minimal extra work in maintaining |
| 111 | // activation state. |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 112 | ON_CALL(*modem_info_.mock_pending_activation_store(), |
| 113 | GetActivationState(PendingActivationStore::kIdentifierICCID, _)) |
| 114 | .WillByDefault(Return(PendingActivationStore::kStateUnknown)); |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | virtual void TearDown() { |
| 118 | capability_->proxy_factory_ = NULL; |
| 119 | } |
| 120 | |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 121 | void InitProviderDB() { |
| 122 | modem_info_.SetProviderDB(kTestMobileProviderDBPath); |
| 123 | } |
| 124 | |
Darin Petkov | a4ca3c3 | 2012-08-17 16:05:24 +0200 | [diff] [blame] | 125 | void SetService() { |
Prathmesh Prabhu | 0d36b4f | 2013-04-01 11:45:54 -0700 | [diff] [blame] | 126 | cellular_->service_ = new CellularService(&modem_info_, cellular_); |
Jason Glasgow | 4380f0d | 2012-05-03 18:05:04 -0400 | [diff] [blame] | 127 | } |
| 128 | |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 129 | void InvokeEnable(bool enable, Error *error, |
| 130 | const ResultCallback &callback, int timeout) { |
| 131 | callback.Run(Error()); |
| 132 | } |
| 133 | void InvokeEnableFail(bool enable, Error *error, |
| 134 | const ResultCallback &callback, int timeout) { |
| 135 | callback.Run(Error(Error::kOperationFailed)); |
| 136 | } |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 137 | void InvokeRegister(const string &operator_id, Error *error, |
| 138 | const ResultCallback &callback, int timeout) { |
| 139 | callback.Run(Error()); |
| 140 | } |
| 141 | |
Gary Morain | ceba6aa | 2012-05-03 10:28:26 -0700 | [diff] [blame] | 142 | void InvokeScan(Error *error, const DBusPropertyMapsCallback &callback, |
| 143 | int timeout) { |
| 144 | callback.Run(CellularCapabilityUniversal::ScanResults(), Error()); |
| 145 | } |
Jason Glasgow | cd0349c | 2012-05-03 23:32:15 -0400 | [diff] [blame] | 146 | void ScanError(Error *error, const DBusPropertyMapsCallback &callback, |
| 147 | int timeout) { |
| 148 | error->Populate(Error::kOperationFailed); |
| 149 | } |
Gary Morain | ceba6aa | 2012-05-03 10:28:26 -0700 | [diff] [blame] | 150 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 151 | bool InvokeScanningOrSearchingTimeout() { |
| 152 | capability_->OnScanningOrSearchingTimeout(); |
| 153 | return true; |
| 154 | } |
| 155 | |
Gary Morain | ceba6aa | 2012-05-03 10:28:26 -0700 | [diff] [blame] | 156 | void Set3gppProxy() { |
| 157 | capability_->modem_3gpp_proxy_.reset(modem_3gpp_proxy_.release()); |
| 158 | } |
| 159 | |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 160 | void SetSimpleProxy() { |
| 161 | capability_->modem_simple_proxy_.reset(modem_simple_proxy_.release()); |
| 162 | } |
| 163 | |
Thieu Le | 3d27539 | 2012-07-20 15:32:58 -0700 | [diff] [blame] | 164 | void ReleaseCapabilityProxies() { |
| 165 | capability_->ReleaseProxies(); |
| 166 | } |
| 167 | |
Prathmesh Prabhu | 8f6479f | 2013-05-15 12:56:13 -0700 | [diff] [blame] | 168 | void SetRegistrationDroppedUpdateTimeout(int64 timeout_milliseconds) { |
| 169 | capability_->registration_dropped_update_timeout_milliseconds_ = |
| 170 | timeout_milliseconds; |
| 171 | } |
| 172 | |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 173 | MOCK_METHOD1(TestCallback, void(const Error &error)); |
| 174 | |
Prathmesh Prabhu | 8f6479f | 2013-05-15 12:56:13 -0700 | [diff] [blame] | 175 | MOCK_METHOD0(DummyCallback, void(void)); |
| 176 | |
| 177 | void SetMockRegistrationDroppedUpdateCallback() { |
| 178 | capability_->registration_dropped_update_callback_.Reset( |
| 179 | Bind(&CellularCapabilityUniversalTest::DummyCallback, |
| 180 | Unretained(this))); |
| 181 | } |
| 182 | |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 183 | protected: |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 184 | static const char kActiveBearerPathPrefix[]; |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 185 | static const char kImei[]; |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 186 | static const char kInactiveBearerPathPrefix[]; |
Arman Uguray | c953357 | 2013-01-22 17:34:20 -0800 | [diff] [blame] | 187 | static const char kMachineAddress[]; |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 188 | static const char kSimPath[]; |
| 189 | static const uint32 kAccessTechnologies; |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 190 | static const char kTestMobileProviderDBPath[]; |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 191 | |
| 192 | class TestProxyFactory : public ProxyFactory { |
| 193 | public: |
| 194 | explicit TestProxyFactory(CellularCapabilityUniversalTest *test) : |
mukesh agrawal | 9da0777 | 2013-05-15 14:15:17 -0700 | [diff] [blame] | 195 | test_(test) { |
Ben Chan | 5db1969 | 2013-07-09 23:07:03 -0700 | [diff] [blame] | 196 | active_bearer_properties_[MM_BEARER_PROPERTY_CONNECTED].writer() |
| 197 | .append_bool(true); |
| 198 | active_bearer_properties_[MM_BEARER_PROPERTY_INTERFACE].writer() |
| 199 | .append_string("/dev/fake"); |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 200 | |
Ben Chan | 5db1969 | 2013-07-09 23:07:03 -0700 | [diff] [blame] | 201 | DBusPropertiesMap ip4config; |
| 202 | ip4config[CellularCapabilityUniversal::kIpConfigPropertyMethod].writer() |
| 203 | .append_uint32(MM_BEARER_IP_METHOD_DHCP); |
| 204 | DBus::MessageIter writer = |
| 205 | active_bearer_properties_[MM_BEARER_PROPERTY_IP4CONFIG].writer(); |
| 206 | writer << ip4config; |
| 207 | |
| 208 | inactive_bearer_properties_[MM_BEARER_PROPERTY_CONNECTED].writer() |
| 209 | .append_bool(false); |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 210 | } |
| 211 | |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 212 | virtual mm1::ModemModem3gppProxyInterface *CreateMM1ModemModem3gppProxy( |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 213 | const std::string &/*path*/, |
| 214 | const std::string &/*service*/) { |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 215 | return test_->modem_3gpp_proxy_.release(); |
| 216 | } |
| 217 | |
| 218 | virtual mm1::ModemModemCdmaProxyInterface *CreateMM1ModemModemCdmaProxy( |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 219 | const std::string &/*path*/, |
| 220 | const std::string &/*service*/) { |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 221 | return test_->modem_cdma_proxy_.release(); |
| 222 | } |
| 223 | |
| 224 | virtual mm1::ModemProxyInterface *CreateMM1ModemProxy( |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 225 | const std::string &/*path*/, |
| 226 | const std::string &/*service*/) { |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 227 | return test_->modem_proxy_.release(); |
| 228 | } |
| 229 | |
| 230 | virtual mm1::ModemSimpleProxyInterface *CreateMM1ModemSimpleProxy( |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 231 | const std::string &/*path*/, |
| 232 | const std::string &/*service*/) { |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 233 | return test_->modem_simple_proxy_.release(); |
| 234 | } |
| 235 | |
| 236 | virtual mm1::SimProxyInterface *CreateSimProxy( |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 237 | const std::string &/*path*/, |
| 238 | const std::string &/*service*/) { |
Arman Uguray | 6552f8c | 2013-02-12 15:33:18 -0800 | [diff] [blame] | 239 | mm1::MockSimProxy *sim_proxy = test_->sim_proxy_.release(); |
| 240 | test_->sim_proxy_.reset(new mm1::MockSimProxy()); |
| 241 | return sim_proxy; |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 242 | } |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 243 | virtual DBusPropertiesProxyInterface *CreateDBusPropertiesProxy( |
Ben Chan | 5db1969 | 2013-07-09 23:07:03 -0700 | [diff] [blame] | 244 | const std::string &path, |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 245 | const std::string &/*service*/) { |
Arman Uguray | 6552f8c | 2013-02-12 15:33:18 -0800 | [diff] [blame] | 246 | MockDBusPropertiesProxy *properties_proxy = |
| 247 | test_->properties_proxy_.release(); |
Ben Chan | 5db1969 | 2013-07-09 23:07:03 -0700 | [diff] [blame] | 248 | if (path.find(kActiveBearerPathPrefix) != std::string::npos) { |
| 249 | ON_CALL(*properties_proxy, GetAll(MM_DBUS_INTERFACE_BEARER)) |
| 250 | .WillByDefault(Return(active_bearer_properties_)); |
| 251 | } else { |
| 252 | ON_CALL(*properties_proxy, GetAll(MM_DBUS_INTERFACE_BEARER)) |
| 253 | .WillByDefault(Return(inactive_bearer_properties_)); |
| 254 | } |
Arman Uguray | 6552f8c | 2013-02-12 15:33:18 -0800 | [diff] [blame] | 255 | test_->properties_proxy_.reset(new MockDBusPropertiesProxy()); |
| 256 | return properties_proxy; |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 257 | } |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 258 | |
| 259 | private: |
Ben Chan | 5db1969 | 2013-07-09 23:07:03 -0700 | [diff] [blame] | 260 | DBusPropertiesMap GetActiveBearerProperties( |
| 261 | const string &/*interface_name*/) { |
| 262 | DBusPropertiesMap properties; |
| 263 | properties[MM_BEARER_PROPERTY_CONNECTED].writer().append_bool(true); |
| 264 | return properties; |
| 265 | } |
| 266 | |
| 267 | DBusPropertiesMap GetInactiveBearerProperties( |
| 268 | const string &/*interface_name*/) { |
| 269 | DBusPropertiesMap properties; |
| 270 | properties[MM_BEARER_PROPERTY_CONNECTED].writer().append_bool(false); |
| 271 | return properties; |
| 272 | } |
| 273 | |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 274 | CellularCapabilityUniversalTest *test_; |
Ben Chan | 5db1969 | 2013-07-09 23:07:03 -0700 | [diff] [blame] | 275 | DBusPropertiesMap active_bearer_properties_; |
| 276 | DBusPropertiesMap inactive_bearer_properties_; |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 277 | }; |
| 278 | |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 279 | MockModemInfo modem_info_; |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 280 | scoped_ptr<mm1::MockModemModem3gppProxy> modem_3gpp_proxy_; |
| 281 | scoped_ptr<mm1::MockModemModemCdmaProxy> modem_cdma_proxy_; |
| 282 | scoped_ptr<mm1::MockModemProxy> modem_proxy_; |
| 283 | scoped_ptr<mm1::MockModemSimpleProxy> modem_simple_proxy_; |
| 284 | scoped_ptr<mm1::MockSimProxy> sim_proxy_; |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 285 | scoped_ptr<MockDBusPropertiesProxy> properties_proxy_; |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 286 | TestProxyFactory proxy_factory_; |
| 287 | CellularCapabilityUniversal *capability_; // Owned by |cellular_|. |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 288 | DeviceMockAdaptor *device_adaptor_; // Owned by |cellular_|. |
Ben Chan | 3ecdf82 | 2012-08-06 12:29:23 -0700 | [diff] [blame] | 289 | CellularRefPtr cellular_; |
| 290 | MockCellularService *service_; // owned by cellular_ |
Jason Glasgow | cd0349c | 2012-05-03 23:32:15 -0400 | [diff] [blame] | 291 | DBusPropertyMapsCallback scan_callback_; // saved for testing scan operations |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 292 | DBusPathCallback connect_callback_; // saved for testing connect operations |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 293 | }; |
| 294 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 295 | // Most of our tests involve using a real EventDispatcher object. |
| 296 | class CellularCapabilityUniversalMainTest |
| 297 | : public CellularCapabilityUniversalTest { |
| 298 | public: |
| 299 | CellularCapabilityUniversalMainTest() : |
| 300 | CellularCapabilityUniversalTest(&dispatcher_) {} |
| 301 | |
| 302 | protected: |
| 303 | EventDispatcher dispatcher_; |
| 304 | }; |
| 305 | |
| 306 | // Tests that involve timers will (or may) use a mock of the event dispatcher |
| 307 | // instead of a real one. |
| 308 | class CellularCapabilityUniversalTimerTest |
| 309 | : public CellularCapabilityUniversalTest { |
| 310 | public: |
| 311 | CellularCapabilityUniversalTimerTest() |
| 312 | : CellularCapabilityUniversalTest(&mock_dispatcher_) {} |
| 313 | |
| 314 | protected: |
| 315 | ::testing::StrictMock<MockEventDispatcher> mock_dispatcher_; |
| 316 | }; |
| 317 | |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 318 | const char CellularCapabilityUniversalTest::kActiveBearerPathPrefix[] = |
| 319 | "/bearer/active"; |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 320 | const char CellularCapabilityUniversalTest::kImei[] = "999911110000"; |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 321 | const char CellularCapabilityUniversalTest::kInactiveBearerPathPrefix[] = |
| 322 | "/bearer/inactive"; |
Arman Uguray | c953357 | 2013-01-22 17:34:20 -0800 | [diff] [blame] | 323 | const char CellularCapabilityUniversalTest::kMachineAddress[] = |
| 324 | "TestMachineAddress"; |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 325 | const char CellularCapabilityUniversalTest::kSimPath[] = "/foo/sim"; |
| 326 | const uint32 CellularCapabilityUniversalTest::kAccessTechnologies = |
| 327 | MM_MODEM_ACCESS_TECHNOLOGY_LTE | |
| 328 | MM_MODEM_ACCESS_TECHNOLOGY_HSPA_PLUS; |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 329 | const char CellularCapabilityUniversalTest::kTestMobileProviderDBPath[] = |
| 330 | "provider_db_unittest.bfd"; |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 331 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 332 | TEST_F(CellularCapabilityUniversalMainTest, StartModem) { |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 333 | // Set up mock modem properties |
| 334 | DBusPropertiesMap modem_properties; |
| 335 | string operator_name = "TestOperator"; |
| 336 | string operator_code = "001400"; |
| 337 | |
| 338 | modem_properties[MM_MODEM_PROPERTY_ACCESSTECHNOLOGIES]. |
| 339 | writer().append_uint32(kAccessTechnologies); |
| 340 | |
| 341 | ::DBus::Variant v; |
| 342 | ::DBus::MessageIter writer = v.writer(); |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 343 | ::DBus::Struct< uint32_t, bool > quality; |
| 344 | quality._1 = 90; |
| 345 | quality._2 = true; |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 346 | writer << quality; |
| 347 | modem_properties[MM_MODEM_PROPERTY_SIGNALQUALITY] = v; |
| 348 | |
| 349 | // Set up mock modem 3gpp properties |
| 350 | DBusPropertiesMap modem3gpp_properties; |
| 351 | modem3gpp_properties[MM_MODEM_MODEM3GPP_PROPERTY_ENABLEDFACILITYLOCKS]. |
| 352 | writer().append_uint32(0); |
| 353 | modem3gpp_properties[MM_MODEM_MODEM3GPP_PROPERTY_IMEI]. |
| 354 | writer().append_string(kImei); |
| 355 | |
| 356 | EXPECT_CALL(*modem_proxy_, |
| 357 | Enable(true, _, _, CellularCapability::kTimeoutEnable)) |
| 358 | .WillOnce(Invoke(this, &CellularCapabilityUniversalTest::InvokeEnable)); |
| 359 | EXPECT_CALL(*properties_proxy_, |
| 360 | GetAll(MM_DBUS_INTERFACE_MODEM)) |
| 361 | .WillOnce(Return(modem_properties)); |
| 362 | EXPECT_CALL(*properties_proxy_, |
| 363 | GetAll(MM_DBUS_INTERFACE_MODEM_MODEM3GPP)) |
| 364 | .WillOnce(Return(modem3gpp_properties)); |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 365 | |
Gary Morain | e285a84 | 2012-08-15 08:23:57 -0700 | [diff] [blame] | 366 | // Let the modem report that it is initializing. StartModem() should defer |
| 367 | // enabling the modem until its state changes to disabled. |
| 368 | EXPECT_CALL(*modem_proxy_, State()) |
| 369 | .WillOnce(Return(Cellular::kModemStateInitializing)); |
| 370 | |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 371 | // After setup we lose pointers to the proxies, so it is hard to set |
| 372 | // expectations. |
| 373 | SetUp(); |
| 374 | |
| 375 | Error error; |
Gary Morain | e285a84 | 2012-08-15 08:23:57 -0700 | [diff] [blame] | 376 | EXPECT_CALL(*this, TestCallback(_)).Times(0); |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 377 | ResultCallback callback = |
| 378 | Bind(&CellularCapabilityUniversalTest::TestCallback, Unretained(this)); |
| 379 | capability_->StartModem(&error, callback); |
Gary Morain | e285a84 | 2012-08-15 08:23:57 -0700 | [diff] [blame] | 380 | |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 381 | // Verify that the modem has not been enabled. |
Gary Morain | e285a84 | 2012-08-15 08:23:57 -0700 | [diff] [blame] | 382 | EXPECT_TRUE(capability_->imei_.empty()); |
| 383 | EXPECT_EQ(0, capability_->access_technologies_); |
| 384 | Mock::VerifyAndClearExpectations(this); |
| 385 | |
| 386 | // Change the state to kModemStateDisabling and verify that it still has not |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 387 | // been enabled. |
Gary Morain | e285a84 | 2012-08-15 08:23:57 -0700 | [diff] [blame] | 388 | EXPECT_CALL(*this, TestCallback(_)).Times(0); |
| 389 | capability_->OnModemStateChangedSignal(Cellular::kModemStateInitializing, |
| 390 | Cellular::kModemStateDisabling, 0); |
| 391 | EXPECT_TRUE(capability_->imei_.empty()); |
| 392 | EXPECT_EQ(0, capability_->access_technologies_); |
| 393 | Mock::VerifyAndClearExpectations(this); |
| 394 | |
| 395 | // Change the state of the modem to disabled and verify that it gets enabled. |
| 396 | EXPECT_CALL(*this, TestCallback(IsSuccess())); |
| 397 | capability_->OnModemStateChangedSignal(Cellular::kModemStateDisabling, |
| 398 | Cellular::kModemStateDisabled, 0); |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 399 | EXPECT_TRUE(error.IsSuccess()); |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 400 | EXPECT_EQ(kImei, capability_->imei_); |
| 401 | EXPECT_EQ(kAccessTechnologies, capability_->access_technologies_); |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 402 | } |
| 403 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 404 | TEST_F(CellularCapabilityUniversalMainTest, StartModemFail) { |
Gary Morain | e285a84 | 2012-08-15 08:23:57 -0700 | [diff] [blame] | 405 | EXPECT_CALL(*modem_proxy_, State()) |
| 406 | .WillOnce(Return(Cellular::kModemStateDisabled)); |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 407 | EXPECT_CALL(*modem_proxy_, |
| 408 | Enable(true, _, _, CellularCapability::kTimeoutEnable)) |
| 409 | .WillOnce( |
| 410 | Invoke(this, &CellularCapabilityUniversalTest::InvokeEnableFail)); |
| 411 | EXPECT_CALL(*this, TestCallback(IsFailure())); |
| 412 | ResultCallback callback = |
| 413 | Bind(&CellularCapabilityUniversalTest::TestCallback, Unretained(this)); |
| 414 | SetUp(); |
| 415 | |
| 416 | Error error; |
| 417 | capability_->StartModem(&error, callback); |
Thieu Le | e3b3659 | 2012-08-30 17:50:26 -0700 | [diff] [blame] | 418 | EXPECT_TRUE(error.IsOngoing()); |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 419 | } |
| 420 | |
Thieu Le | b9c05e0 | 2013-03-04 14:09:32 -0800 | [diff] [blame] | 421 | TEST_F(CellularCapabilityUniversalMainTest, StartModemAlreadyEnabled) { |
| 422 | EXPECT_CALL(*modem_proxy_, State()) |
| 423 | .WillOnce(Return(Cellular::kModemStateEnabled)); |
| 424 | SetUp(); |
| 425 | capability_->cellular()->modem_state_ = Cellular::kModemStateConnected; |
| 426 | |
| 427 | // Make sure the call to StartModem() doesn't attempt to complete the |
| 428 | // request synchronously, else it will crash DBus-C++. |
| 429 | Error error(Error::kOperationInitiated); |
| 430 | capability_->StartModem(&error, ResultCallback()); |
| 431 | EXPECT_TRUE(error.IsOngoing()); |
| 432 | } |
| 433 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 434 | TEST_F(CellularCapabilityUniversalMainTest, StopModem) { |
Jason Glasgow | 02401cc | 2012-05-16 10:35:37 -0400 | [diff] [blame] | 435 | // Save pointers to proxies before they are lost by the call to InitProxies |
| 436 | mm1::MockModemProxy *modem_proxy = modem_proxy_.get(); |
| 437 | SetUp(); |
| 438 | EXPECT_CALL(*modem_proxy, set_state_changed_callback(_)); |
| 439 | capability_->InitProxies(); |
| 440 | |
| 441 | Error error; |
| 442 | ResultCallback callback = |
| 443 | Bind(&CellularCapabilityUniversalTest::TestCallback, Unretained(this)); |
| 444 | capability_->StopModem(&error, callback); |
| 445 | EXPECT_TRUE(error.IsSuccess()); |
| 446 | |
| 447 | ResultCallback disable_callback; |
| 448 | EXPECT_CALL(*modem_proxy, |
| 449 | Enable(false, _, _, CellularCapability::kTimeoutEnable)) |
| 450 | .WillOnce(SaveArg<2>(&disable_callback)); |
| 451 | dispatcher_.DispatchPendingEvents(); |
| 452 | |
Arman Uguray | ee464d3 | 2013-02-13 17:14:36 -0800 | [diff] [blame] | 453 | ResultCallback set_power_state_callback; |
Thieu Le | 2cac294 | 2013-03-05 18:41:08 -0800 | [diff] [blame] | 454 | EXPECT_CALL( |
| 455 | *modem_proxy, |
| 456 | SetPowerState( |
| 457 | MM_MODEM_POWER_STATE_LOW, _, _, |
| 458 | CellularCapabilityUniversal::kSetPowerStateTimeoutMilliseconds)) |
Arman Uguray | ee464d3 | 2013-02-13 17:14:36 -0800 | [diff] [blame] | 459 | .WillOnce(SaveArg<2>(&set_power_state_callback)); |
Jason Glasgow | 02401cc | 2012-05-16 10:35:37 -0400 | [diff] [blame] | 460 | disable_callback.Run(Error(Error::kSuccess)); |
Arman Uguray | ee464d3 | 2013-02-13 17:14:36 -0800 | [diff] [blame] | 461 | |
| 462 | EXPECT_CALL(*this, TestCallback(IsSuccess())); |
| 463 | set_power_state_callback.Run(Error(Error::kSuccess)); |
Prathmesh Prabhu | b5fde53 | 2013-03-19 17:36:09 -0700 | [diff] [blame] | 464 | Mock::VerifyAndClearExpectations(this); |
Arman Uguray | ee464d3 | 2013-02-13 17:14:36 -0800 | [diff] [blame] | 465 | |
| 466 | // TestCallback should get called with success even if the power state |
| 467 | // callback gets called with an error |
| 468 | EXPECT_CALL(*this, TestCallback(IsSuccess())); |
| 469 | set_power_state_callback.Run(Error(Error::kOperationFailed)); |
Jason Glasgow | 02401cc | 2012-05-16 10:35:37 -0400 | [diff] [blame] | 470 | } |
| 471 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 472 | TEST_F(CellularCapabilityUniversalMainTest, StopModemConnected) { |
Jason Glasgow | 02401cc | 2012-05-16 10:35:37 -0400 | [diff] [blame] | 473 | // Save pointers to proxies before they are lost by the call to InitProxies |
| 474 | mm1::MockModemProxy *modem_proxy = modem_proxy_.get(); |
| 475 | mm1::MockModemSimpleProxy *modem_simple_proxy = modem_simple_proxy_.get(); |
| 476 | SetUp(); |
| 477 | EXPECT_CALL(*modem_proxy, set_state_changed_callback(_)); |
| 478 | capability_->InitProxies(); |
| 479 | |
| 480 | ResultCallback disconnect_callback; |
| 481 | Error error; |
| 482 | ResultCallback callback = |
| 483 | Bind(&CellularCapabilityUniversalTest::TestCallback, Unretained(this)); |
| 484 | EXPECT_CALL(*modem_simple_proxy, |
| 485 | Disconnect(::DBus::Path("/"), _, _, |
Thieu Le | 049adb5 | 2012-11-12 17:14:51 -0800 | [diff] [blame] | 486 | CellularCapability::kTimeoutDisconnect)) |
Jason Glasgow | 02401cc | 2012-05-16 10:35:37 -0400 | [diff] [blame] | 487 | .WillOnce(SaveArg<2>(&disconnect_callback)); |
Thieu Le | d001205 | 2012-07-25 16:09:09 -0700 | [diff] [blame] | 488 | capability_->cellular()->modem_state_ = Cellular::kModemStateConnected; |
Jason Glasgow | 02401cc | 2012-05-16 10:35:37 -0400 | [diff] [blame] | 489 | capability_->StopModem(&error, callback); |
| 490 | EXPECT_TRUE(error.IsSuccess()); |
| 491 | |
| 492 | ResultCallback disable_callback; |
| 493 | EXPECT_CALL(*modem_proxy, |
| 494 | Enable(false, _, _, CellularCapability::kTimeoutEnable)) |
| 495 | .WillOnce(SaveArg<2>(&disable_callback)); |
| 496 | disconnect_callback.Run(Error(Error::kSuccess)); |
| 497 | |
Arman Uguray | ee464d3 | 2013-02-13 17:14:36 -0800 | [diff] [blame] | 498 | ResultCallback set_power_state_callback; |
Thieu Le | 2cac294 | 2013-03-05 18:41:08 -0800 | [diff] [blame] | 499 | EXPECT_CALL( |
| 500 | *modem_proxy, |
| 501 | SetPowerState( |
| 502 | MM_MODEM_POWER_STATE_LOW, _, _, |
| 503 | CellularCapabilityUniversal::kSetPowerStateTimeoutMilliseconds)) |
Arman Uguray | ee464d3 | 2013-02-13 17:14:36 -0800 | [diff] [blame] | 504 | .WillOnce(SaveArg<2>(&set_power_state_callback)); |
| 505 | |
Jason Glasgow | 02401cc | 2012-05-16 10:35:37 -0400 | [diff] [blame] | 506 | disable_callback.Run(Error(Error::kSuccess)); |
Arman Uguray | ee464d3 | 2013-02-13 17:14:36 -0800 | [diff] [blame] | 507 | |
| 508 | EXPECT_CALL(*this, TestCallback(IsSuccess())); |
| 509 | set_power_state_callback.Run(Error(Error::kSuccess)); |
Jason Glasgow | 02401cc | 2012-05-16 10:35:37 -0400 | [diff] [blame] | 510 | } |
| 511 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 512 | TEST_F(CellularCapabilityUniversalMainTest, DisconnectModemNoBearer) { |
Thieu Le | 5d6864a | 2012-07-20 11:43:51 -0700 | [diff] [blame] | 513 | Error error; |
| 514 | ResultCallback disconnect_callback; |
Thieu Le | 3d27539 | 2012-07-20 15:32:58 -0700 | [diff] [blame] | 515 | EXPECT_CALL(*modem_simple_proxy_, |
Thieu Le | 049adb5 | 2012-11-12 17:14:51 -0800 | [diff] [blame] | 516 | Disconnect(_, _, _, CellularCapability::kTimeoutDisconnect)) |
Thieu Le | 5d6864a | 2012-07-20 11:43:51 -0700 | [diff] [blame] | 517 | .Times(0); |
| 518 | capability_->Disconnect(&error, disconnect_callback); |
| 519 | } |
| 520 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 521 | TEST_F(CellularCapabilityUniversalMainTest, DisconnectNoProxy) { |
Thieu Le | 3d27539 | 2012-07-20 15:32:58 -0700 | [diff] [blame] | 522 | Error error; |
| 523 | ResultCallback disconnect_callback; |
| 524 | capability_->bearer_path_ = "/foo"; |
| 525 | EXPECT_CALL(*modem_simple_proxy_, |
Thieu Le | 049adb5 | 2012-11-12 17:14:51 -0800 | [diff] [blame] | 526 | Disconnect(_, _, _, CellularCapability::kTimeoutDisconnect)) |
Thieu Le | 3d27539 | 2012-07-20 15:32:58 -0700 | [diff] [blame] | 527 | .Times(0); |
| 528 | ReleaseCapabilityProxies(); |
| 529 | capability_->Disconnect(&error, disconnect_callback); |
| 530 | } |
| 531 | |
Prathmesh Prabhu | 8f6479f | 2013-05-15 12:56:13 -0700 | [diff] [blame] | 532 | TEST_F(CellularCapabilityUniversalMainTest, DisconnectWithDeferredCallback) { |
| 533 | Error error; |
| 534 | ResultCallback disconnect_callback; |
| 535 | capability_->bearer_path_ = "/foo"; |
| 536 | EXPECT_CALL(*modem_simple_proxy_, |
| 537 | Disconnect(_, _, _, CellularCapability::kTimeoutDisconnect)); |
| 538 | SetSimpleProxy(); |
| 539 | SetMockRegistrationDroppedUpdateCallback(); |
| 540 | EXPECT_CALL(*this, DummyCallback()); |
| 541 | capability_->Disconnect(&error, disconnect_callback); |
| 542 | } |
| 543 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 544 | TEST_F(CellularCapabilityUniversalMainTest, SimLockStatusChanged) { |
Arman Uguray | ab9364e | 2012-12-19 20:45:25 -0800 | [diff] [blame] | 545 | // Set up mock SIM properties |
| 546 | const char kImsi[] = "310100000001"; |
| 547 | const char kSimIdentifier[] = "9999888"; |
| 548 | const char kOperatorIdentifier[] = "310240"; |
| 549 | const char kOperatorName[] = "Custom SPN"; |
| 550 | DBusPropertiesMap sim_properties; |
| 551 | sim_properties[MM_SIM_PROPERTY_IMSI].writer().append_string(kImsi); |
| 552 | sim_properties[MM_SIM_PROPERTY_SIMIDENTIFIER].writer() |
| 553 | .append_string(kSimIdentifier); |
| 554 | sim_properties[MM_SIM_PROPERTY_OPERATORIDENTIFIER].writer() |
| 555 | .append_string(kOperatorIdentifier); |
| 556 | sim_properties[MM_SIM_PROPERTY_OPERATORNAME].writer() |
| 557 | .append_string(kOperatorName); |
| 558 | |
| 559 | EXPECT_CALL(*properties_proxy_, GetAll(MM_DBUS_INTERFACE_SIM)) |
| 560 | .WillOnce(Return(sim_properties)); |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 561 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 562 | GetActivationState(PendingActivationStore::kIdentifierICCID, _)) |
Prathmesh Prabhu | 97f317c | 2013-03-15 16:20:34 -0700 | [diff] [blame] | 563 | .Times(1); |
Arman Uguray | ab9364e | 2012-12-19 20:45:25 -0800 | [diff] [blame] | 564 | |
| 565 | SetUp(); |
| 566 | InitProviderDB(); |
| 567 | |
| 568 | EXPECT_FALSE(capability_->sim_present_); |
| 569 | EXPECT_TRUE(capability_->sim_proxy_ == NULL); |
| 570 | |
| 571 | capability_->OnSimPathChanged(kSimPath); |
| 572 | EXPECT_TRUE(capability_->sim_present_); |
| 573 | EXPECT_TRUE(capability_->sim_proxy_ != NULL); |
| 574 | EXPECT_EQ(kSimPath, capability_->sim_path_); |
| 575 | |
| 576 | capability_->imsi_ = ""; |
| 577 | capability_->sim_identifier_ = ""; |
| 578 | capability_->operator_id_ = ""; |
| 579 | capability_->spn_ = ""; |
| 580 | |
| 581 | // SIM is locked. |
Arman Uguray | c7e63af | 2013-06-13 17:07:32 -0700 | [diff] [blame] | 582 | capability_->sim_lock_status_.lock_type = MM_MODEM_LOCK_SIM_PIN; |
Arman Uguray | ab9364e | 2012-12-19 20:45:25 -0800 | [diff] [blame] | 583 | capability_->OnSimLockStatusChanged(); |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 584 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
Arman Uguray | ab9364e | 2012-12-19 20:45:25 -0800 | [diff] [blame] | 585 | |
| 586 | EXPECT_EQ("", capability_->imsi_); |
| 587 | EXPECT_EQ("", capability_->sim_identifier_); |
| 588 | EXPECT_EQ("", capability_->operator_id_); |
| 589 | EXPECT_EQ("", capability_->spn_); |
| 590 | |
| 591 | // SIM is unlocked. |
| 592 | properties_proxy_.reset(new MockDBusPropertiesProxy()); |
| 593 | EXPECT_CALL(*properties_proxy_, GetAll(MM_DBUS_INTERFACE_SIM)) |
| 594 | .WillOnce(Return(sim_properties)); |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 595 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 596 | GetActivationState(PendingActivationStore::kIdentifierICCID, _)) |
Prathmesh Prabhu | 97f317c | 2013-03-15 16:20:34 -0700 | [diff] [blame] | 597 | .Times(1); |
Arman Uguray | ab9364e | 2012-12-19 20:45:25 -0800 | [diff] [blame] | 598 | |
Arman Uguray | c7e63af | 2013-06-13 17:07:32 -0700 | [diff] [blame] | 599 | capability_->sim_lock_status_.lock_type = MM_MODEM_LOCK_NONE; |
Arman Uguray | ab9364e | 2012-12-19 20:45:25 -0800 | [diff] [blame] | 600 | capability_->OnSimLockStatusChanged(); |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 601 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
Arman Uguray | ab9364e | 2012-12-19 20:45:25 -0800 | [diff] [blame] | 602 | |
| 603 | EXPECT_EQ(kImsi, capability_->imsi_); |
| 604 | EXPECT_EQ(kSimIdentifier, capability_->sim_identifier_); |
| 605 | EXPECT_EQ(kOperatorIdentifier, capability_->operator_id_); |
| 606 | EXPECT_EQ(kOperatorName, capability_->spn_); |
Ben Chan | d3b1874 | 2013-07-12 00:30:25 -0700 | [diff] [blame] | 607 | |
| 608 | // SIM is missing and SIM path is "/". |
| 609 | capability_->OnSimPathChanged(CellularCapabilityUniversal::kRootPath); |
| 610 | EXPECT_FALSE(capability_->sim_present_); |
| 611 | EXPECT_TRUE(capability_->sim_proxy_ == NULL); |
| 612 | EXPECT_EQ(CellularCapabilityUniversal::kRootPath, capability_->sim_path_); |
| 613 | |
| 614 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 615 | GetActivationState(_, _)).Times(0); |
| 616 | capability_->OnSimLockStatusChanged(); |
| 617 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
| 618 | |
| 619 | EXPECT_EQ("", capability_->imsi_); |
| 620 | EXPECT_EQ("", capability_->sim_identifier_); |
| 621 | EXPECT_EQ("", capability_->operator_id_); |
| 622 | EXPECT_EQ("", capability_->spn_); |
| 623 | |
| 624 | // SIM is missing and SIM path is empty. |
| 625 | capability_->OnSimPathChanged(""); |
| 626 | EXPECT_FALSE(capability_->sim_present_); |
| 627 | EXPECT_TRUE(capability_->sim_proxy_ == NULL); |
| 628 | EXPECT_EQ("", capability_->sim_path_); |
| 629 | |
| 630 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 631 | GetActivationState(_, _)).Times(0); |
| 632 | capability_->OnSimLockStatusChanged(); |
| 633 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
| 634 | |
| 635 | EXPECT_EQ("", capability_->imsi_); |
| 636 | EXPECT_EQ("", capability_->sim_identifier_); |
| 637 | EXPECT_EQ("", capability_->operator_id_); |
| 638 | EXPECT_EQ("", capability_->spn_); |
Arman Uguray | ab9364e | 2012-12-19 20:45:25 -0800 | [diff] [blame] | 639 | } |
| 640 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 641 | TEST_F(CellularCapabilityUniversalMainTest, PropertiesChanged) { |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 642 | // Set up mock modem properties |
| 643 | DBusPropertiesMap modem_properties; |
| 644 | modem_properties[MM_MODEM_PROPERTY_ACCESSTECHNOLOGIES]. |
| 645 | writer().append_uint32(kAccessTechnologies); |
| 646 | modem_properties[MM_MODEM_PROPERTY_SIM]. |
| 647 | writer().append_path(kSimPath); |
| 648 | |
| 649 | // Set up mock modem 3gpp properties |
| 650 | DBusPropertiesMap modem3gpp_properties; |
| 651 | modem3gpp_properties[MM_MODEM_MODEM3GPP_PROPERTY_ENABLEDFACILITYLOCKS]. |
| 652 | writer().append_uint32(0); |
| 653 | modem3gpp_properties[MM_MODEM_MODEM3GPP_PROPERTY_IMEI]. |
| 654 | writer().append_string(kImei); |
| 655 | |
| 656 | // Set up mock modem sim properties |
| 657 | DBusPropertiesMap sim_properties; |
| 658 | |
| 659 | // After setup we lose pointers to the proxies, so it is hard to set |
| 660 | // expectations. |
| 661 | EXPECT_CALL(*properties_proxy_, |
| 662 | GetAll(MM_DBUS_INTERFACE_SIM)) |
| 663 | .WillOnce(Return(sim_properties)); |
| 664 | |
| 665 | SetUp(); |
| 666 | |
| 667 | EXPECT_EQ("", capability_->imei_); |
| 668 | EXPECT_EQ(MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN, |
| 669 | capability_->access_technologies_); |
| 670 | EXPECT_FALSE(capability_->sim_proxy_.get()); |
Jason Glasgow | bad114b | 2012-05-21 15:24:16 -0400 | [diff] [blame] | 671 | EXPECT_CALL(*device_adaptor_, EmitStringChanged( |
| 672 | flimflam::kTechnologyFamilyProperty, flimflam::kTechnologyFamilyGsm)); |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 673 | capability_->OnDBusPropertiesChanged(MM_DBUS_INTERFACE_MODEM, |
| 674 | modem_properties, vector<string>()); |
| 675 | EXPECT_EQ(kAccessTechnologies, capability_->access_technologies_); |
| 676 | EXPECT_EQ(kSimPath, capability_->sim_path_); |
| 677 | EXPECT_TRUE(capability_->sim_proxy_.get()); |
| 678 | |
| 679 | // Changing properties on wrong interface will not have an effect |
| 680 | capability_->OnDBusPropertiesChanged(MM_DBUS_INTERFACE_MODEM, |
| 681 | modem3gpp_properties, |
| 682 | vector<string>()); |
| 683 | EXPECT_EQ("", capability_->imei_); |
| 684 | |
| 685 | // Changing properties on the right interface gets reflected in the |
| 686 | // capabilities object |
| 687 | capability_->OnDBusPropertiesChanged(MM_DBUS_INTERFACE_MODEM_MODEM3GPP, |
| 688 | modem3gpp_properties, |
| 689 | vector<string>()); |
| 690 | EXPECT_EQ(kImei, capability_->imei_); |
Prathmesh Prabhu | b5fde53 | 2013-03-19 17:36:09 -0700 | [diff] [blame] | 691 | Mock::VerifyAndClearExpectations(device_adaptor_); |
Jason Glasgow | bad114b | 2012-05-21 15:24:16 -0400 | [diff] [blame] | 692 | |
| 693 | // Expect to see changes when the family changes |
| 694 | modem_properties.clear(); |
| 695 | modem_properties[MM_MODEM_PROPERTY_ACCESSTECHNOLOGIES]. |
| 696 | writer().append_uint32(MM_MODEM_ACCESS_TECHNOLOGY_1XRTT); |
| 697 | EXPECT_CALL(*device_adaptor_, EmitStringChanged( |
| 698 | flimflam::kTechnologyFamilyProperty, flimflam::kTechnologyFamilyCdma)). |
| 699 | Times(1); |
| 700 | capability_->OnDBusPropertiesChanged(MM_DBUS_INTERFACE_MODEM, |
| 701 | modem_properties, |
| 702 | vector<string>()); |
Prathmesh Prabhu | b5fde53 | 2013-03-19 17:36:09 -0700 | [diff] [blame] | 703 | Mock::VerifyAndClearExpectations(device_adaptor_); |
| 704 | |
Jason Glasgow | bad114b | 2012-05-21 15:24:16 -0400 | [diff] [blame] | 705 | // Back to LTE |
| 706 | modem_properties.clear(); |
| 707 | modem_properties[MM_MODEM_PROPERTY_ACCESSTECHNOLOGIES]. |
| 708 | writer().append_uint32(MM_MODEM_ACCESS_TECHNOLOGY_LTE); |
| 709 | EXPECT_CALL(*device_adaptor_, EmitStringChanged( |
| 710 | flimflam::kTechnologyFamilyProperty, flimflam::kTechnologyFamilyGsm)). |
| 711 | Times(1); |
| 712 | capability_->OnDBusPropertiesChanged(MM_DBUS_INTERFACE_MODEM, |
| 713 | modem_properties, |
| 714 | vector<string>()); |
Prathmesh Prabhu | b5fde53 | 2013-03-19 17:36:09 -0700 | [diff] [blame] | 715 | Mock::VerifyAndClearExpectations(device_adaptor_); |
Jason Glasgow | bad114b | 2012-05-21 15:24:16 -0400 | [diff] [blame] | 716 | |
| 717 | // LTE & CDMA - the device adaptor should not be called! |
| 718 | modem_properties.clear(); |
| 719 | modem_properties[MM_MODEM_PROPERTY_ACCESSTECHNOLOGIES]. |
| 720 | writer().append_uint32(MM_MODEM_ACCESS_TECHNOLOGY_LTE | |
| 721 | MM_MODEM_ACCESS_TECHNOLOGY_1XRTT); |
| 722 | EXPECT_CALL(*device_adaptor_, EmitStringChanged(_, _)).Times(0); |
| 723 | capability_->OnDBusPropertiesChanged(MM_DBUS_INTERFACE_MODEM, |
| 724 | modem_properties, |
| 725 | vector<string>()); |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 726 | } |
| 727 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 728 | TEST_F(CellularCapabilityUniversalMainTest, UpdateServiceName) { |
Arman Uguray | 2717a10 | 2013-01-29 23:36:06 -0800 | [diff] [blame] | 729 | ::DBus::Struct<uint32_t, bool> data; |
| 730 | data._1 = 100; |
| 731 | data._2 = true; |
| 732 | EXPECT_CALL(*modem_proxy_, SignalQuality()).WillRepeatedly(Return(data)); |
| 733 | |
| 734 | SetUp(); |
| 735 | InitProviderDB(); |
| 736 | capability_->InitProxies(); |
Arman Uguray | 2717a10 | 2013-01-29 23:36:06 -0800 | [diff] [blame] | 737 | |
| 738 | SetService(); |
| 739 | |
| 740 | size_t len = strlen(CellularCapabilityUniversal::kGenericServiceNamePrefix); |
| 741 | EXPECT_EQ(CellularCapabilityUniversal::kGenericServiceNamePrefix, |
| 742 | cellular_->service_->friendly_name().substr(0, len)); |
| 743 | |
| 744 | capability_->imsi_ = "310240123456789"; |
| 745 | capability_->SetHomeProvider(); |
| 746 | EXPECT_EQ("", capability_->spn_); |
| 747 | EXPECT_EQ("T-Mobile", cellular_->home_provider().GetName()); |
| 748 | EXPECT_EQ(CellularCapabilityUniversal::kGenericServiceNamePrefix, |
| 749 | cellular_->service_->friendly_name().substr(0, len)); |
| 750 | |
| 751 | capability_->registration_state_ = MM_MODEM_3GPP_REGISTRATION_STATE_HOME; |
| 752 | capability_->SetHomeProvider(); |
| 753 | EXPECT_EQ("", capability_->spn_); |
| 754 | EXPECT_EQ("T-Mobile", cellular_->home_provider().GetName()); |
| 755 | EXPECT_EQ("T-Mobile", cellular_->service_->friendly_name()); |
| 756 | |
| 757 | capability_->spn_ = "Test Home Provider"; |
| 758 | capability_->SetHomeProvider(); |
| 759 | EXPECT_EQ("Test Home Provider", cellular_->home_provider().GetName()); |
| 760 | EXPECT_EQ("Test Home Provider", cellular_->service_->friendly_name()); |
| 761 | |
| 762 | capability_->On3GPPRegistrationChanged( |
| 763 | MM_MODEM_3GPP_REGISTRATION_STATE_HOME, "", "OTA Name"); |
| 764 | EXPECT_EQ("OTA Name", cellular_->service_->friendly_name()); |
| 765 | |
| 766 | capability_->On3GPPRegistrationChanged( |
| 767 | MM_MODEM_3GPP_REGISTRATION_STATE_HOME, "123", "OTA Name 2"); |
| 768 | EXPECT_EQ("OTA Name 2", cellular_->service_->friendly_name()); |
| 769 | |
| 770 | capability_->On3GPPRegistrationChanged( |
| 771 | MM_MODEM_3GPP_REGISTRATION_STATE_HOME, "123", ""); |
| 772 | EXPECT_EQ("Test Home Provider", cellular_->service_->friendly_name()); |
| 773 | } |
| 774 | |
Prathmesh Prabhu | 8f6479f | 2013-05-15 12:56:13 -0700 | [diff] [blame] | 775 | TEST_F(CellularCapabilityUniversalMainTest, UpdateRegistrationState) { |
| 776 | SetUp(); |
| 777 | InitProviderDB(); |
| 778 | capability_->InitProxies(); |
| 779 | |
| 780 | SetService(); |
| 781 | capability_->imsi_ = "310240123456789"; |
| 782 | capability_->SetHomeProvider(); |
| 783 | cellular_->set_modem_state(Cellular::kModemStateConnected); |
| 784 | SetRegistrationDroppedUpdateTimeout(0); |
| 785 | |
| 786 | string home_provider = cellular_->home_provider().GetName(); |
| 787 | string ota_name = cellular_->service_->friendly_name(); |
| 788 | |
| 789 | // Home --> Roaming should be effective immediately. |
| 790 | capability_->On3GPPRegistrationChanged( |
| 791 | MM_MODEM_3GPP_REGISTRATION_STATE_HOME, |
| 792 | home_provider, |
| 793 | ota_name); |
| 794 | EXPECT_EQ(MM_MODEM_3GPP_REGISTRATION_STATE_HOME, |
| 795 | capability_->registration_state_); |
| 796 | capability_->On3GPPRegistrationChanged( |
| 797 | MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING, |
| 798 | home_provider, |
| 799 | ota_name); |
| 800 | EXPECT_EQ(MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING, |
| 801 | capability_->registration_state_); |
| 802 | |
| 803 | // Idle --> Roaming should be effective immediately. |
| 804 | capability_->On3GPPRegistrationChanged( |
| 805 | MM_MODEM_3GPP_REGISTRATION_STATE_IDLE, |
| 806 | home_provider, |
| 807 | ota_name); |
| 808 | dispatcher_.DispatchPendingEvents(); |
| 809 | EXPECT_EQ(MM_MODEM_3GPP_REGISTRATION_STATE_IDLE, |
| 810 | capability_->registration_state_); |
| 811 | capability_->On3GPPRegistrationChanged( |
| 812 | MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING, |
| 813 | home_provider, |
| 814 | ota_name); |
| 815 | EXPECT_EQ(MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING, |
| 816 | capability_->registration_state_); |
| 817 | |
| 818 | // Idle --> Searching should be effective immediately. |
| 819 | capability_->On3GPPRegistrationChanged( |
| 820 | MM_MODEM_3GPP_REGISTRATION_STATE_IDLE, |
| 821 | home_provider, |
| 822 | ota_name); |
| 823 | dispatcher_.DispatchPendingEvents(); |
| 824 | EXPECT_EQ(MM_MODEM_3GPP_REGISTRATION_STATE_IDLE, |
| 825 | capability_->registration_state_); |
| 826 | capability_->On3GPPRegistrationChanged( |
| 827 | MM_MODEM_3GPP_REGISTRATION_STATE_SEARCHING, |
| 828 | home_provider, |
| 829 | ota_name); |
| 830 | EXPECT_EQ(MM_MODEM_3GPP_REGISTRATION_STATE_SEARCHING, |
| 831 | capability_->registration_state_); |
| 832 | |
| 833 | // Home --> Searching --> Home should never see Searching. |
Prathmesh Prabhu | 08757aa | 2013-05-15 17:17:33 -0700 | [diff] [blame] | 834 | EXPECT_CALL(*(modem_info_.mock_metrics()), |
| 835 | Notify3GPPRegistrationDelayedDropPosted()); |
| 836 | EXPECT_CALL(*(modem_info_.mock_metrics()), |
| 837 | Notify3GPPRegistrationDelayedDropCanceled()); |
| 838 | |
Prathmesh Prabhu | 8f6479f | 2013-05-15 12:56:13 -0700 | [diff] [blame] | 839 | capability_->On3GPPRegistrationChanged( |
| 840 | MM_MODEM_3GPP_REGISTRATION_STATE_HOME, |
| 841 | home_provider, |
| 842 | ota_name); |
| 843 | EXPECT_EQ(MM_MODEM_3GPP_REGISTRATION_STATE_HOME, |
| 844 | capability_->registration_state_); |
| 845 | capability_->On3GPPRegistrationChanged( |
| 846 | MM_MODEM_3GPP_REGISTRATION_STATE_SEARCHING, |
| 847 | home_provider, |
| 848 | ota_name); |
| 849 | EXPECT_EQ(MM_MODEM_3GPP_REGISTRATION_STATE_HOME, |
| 850 | capability_->registration_state_); |
| 851 | capability_->On3GPPRegistrationChanged( |
| 852 | MM_MODEM_3GPP_REGISTRATION_STATE_HOME, |
| 853 | home_provider, |
| 854 | ota_name); |
| 855 | EXPECT_EQ(MM_MODEM_3GPP_REGISTRATION_STATE_HOME, |
| 856 | capability_->registration_state_); |
| 857 | dispatcher_.DispatchPendingEvents(); |
| 858 | EXPECT_EQ(MM_MODEM_3GPP_REGISTRATION_STATE_HOME, |
| 859 | capability_->registration_state_); |
Prathmesh Prabhu | 08757aa | 2013-05-15 17:17:33 -0700 | [diff] [blame] | 860 | Mock::VerifyAndClearExpectations(modem_info_.mock_metrics()); |
Prathmesh Prabhu | 8f6479f | 2013-05-15 12:56:13 -0700 | [diff] [blame] | 861 | |
| 862 | // Home --> Searching --> wait till dispatch should see Searching |
Prathmesh Prabhu | 08757aa | 2013-05-15 17:17:33 -0700 | [diff] [blame] | 863 | EXPECT_CALL(*(modem_info_.mock_metrics()), |
| 864 | Notify3GPPRegistrationDelayedDropPosted()); |
Prathmesh Prabhu | 8f6479f | 2013-05-15 12:56:13 -0700 | [diff] [blame] | 865 | capability_->On3GPPRegistrationChanged( |
| 866 | MM_MODEM_3GPP_REGISTRATION_STATE_HOME, |
| 867 | home_provider, |
| 868 | ota_name); |
| 869 | EXPECT_EQ(MM_MODEM_3GPP_REGISTRATION_STATE_HOME, |
| 870 | capability_->registration_state_); |
| 871 | capability_->On3GPPRegistrationChanged( |
| 872 | MM_MODEM_3GPP_REGISTRATION_STATE_SEARCHING, |
| 873 | home_provider, |
| 874 | ota_name); |
| 875 | EXPECT_EQ(MM_MODEM_3GPP_REGISTRATION_STATE_HOME, |
| 876 | capability_->registration_state_); |
| 877 | dispatcher_.DispatchPendingEvents(); |
| 878 | EXPECT_EQ(MM_MODEM_3GPP_REGISTRATION_STATE_SEARCHING, |
| 879 | capability_->registration_state_); |
Prathmesh Prabhu | 08757aa | 2013-05-15 17:17:33 -0700 | [diff] [blame] | 880 | Mock::VerifyAndClearExpectations(modem_info_.mock_metrics()); |
Prathmesh Prabhu | 8f6479f | 2013-05-15 12:56:13 -0700 | [diff] [blame] | 881 | |
| 882 | // Home --> Searching --> Searching --> wait till dispatch should see |
| 883 | // Searching *and* the first callback should be cancelled. |
| 884 | EXPECT_CALL(*this, DummyCallback()).Times(0); |
Prathmesh Prabhu | 08757aa | 2013-05-15 17:17:33 -0700 | [diff] [blame] | 885 | EXPECT_CALL(*(modem_info_.mock_metrics()), |
| 886 | Notify3GPPRegistrationDelayedDropPosted()); |
| 887 | |
Prathmesh Prabhu | 8f6479f | 2013-05-15 12:56:13 -0700 | [diff] [blame] | 888 | capability_->On3GPPRegistrationChanged( |
| 889 | MM_MODEM_3GPP_REGISTRATION_STATE_HOME, |
| 890 | home_provider, |
| 891 | ota_name); |
| 892 | EXPECT_EQ(MM_MODEM_3GPP_REGISTRATION_STATE_HOME, |
| 893 | capability_->registration_state_); |
| 894 | capability_->On3GPPRegistrationChanged( |
| 895 | MM_MODEM_3GPP_REGISTRATION_STATE_SEARCHING, |
| 896 | home_provider, |
| 897 | ota_name); |
| 898 | SetMockRegistrationDroppedUpdateCallback(); |
| 899 | capability_->On3GPPRegistrationChanged( |
| 900 | MM_MODEM_3GPP_REGISTRATION_STATE_SEARCHING, |
| 901 | home_provider, |
| 902 | ota_name); |
| 903 | EXPECT_EQ(MM_MODEM_3GPP_REGISTRATION_STATE_HOME, |
| 904 | capability_->registration_state_); |
| 905 | dispatcher_.DispatchPendingEvents(); |
| 906 | EXPECT_EQ(MM_MODEM_3GPP_REGISTRATION_STATE_SEARCHING, |
| 907 | capability_->registration_state_); |
Prathmesh Prabhu | 8f6479f | 2013-05-15 12:56:13 -0700 | [diff] [blame] | 908 | } |
| 909 | |
| 910 | TEST_F(CellularCapabilityUniversalMainTest, |
| 911 | UpdateRegistrationStateModemNotConnected) { |
| 912 | SetUp(); |
| 913 | InitProviderDB(); |
| 914 | capability_->InitProxies(); |
| 915 | SetService(); |
| 916 | |
| 917 | capability_->imsi_ = "310240123456789"; |
| 918 | capability_->SetHomeProvider(); |
| 919 | cellular_->set_modem_state(Cellular::kModemStateRegistered); |
| 920 | SetRegistrationDroppedUpdateTimeout(0); |
| 921 | |
| 922 | string home_provider = cellular_->home_provider().GetName(); |
| 923 | string ota_name = cellular_->service_->friendly_name(); |
| 924 | |
| 925 | // Home --> Searching should be effective immediately. |
| 926 | capability_->On3GPPRegistrationChanged( |
| 927 | MM_MODEM_3GPP_REGISTRATION_STATE_HOME, |
| 928 | home_provider, |
| 929 | ota_name); |
| 930 | EXPECT_EQ(MM_MODEM_3GPP_REGISTRATION_STATE_HOME, |
| 931 | capability_->registration_state_); |
| 932 | capability_->On3GPPRegistrationChanged( |
| 933 | MM_MODEM_3GPP_REGISTRATION_STATE_SEARCHING, |
| 934 | home_provider, |
| 935 | ota_name); |
| 936 | EXPECT_EQ(MM_MODEM_3GPP_REGISTRATION_STATE_SEARCHING, |
| 937 | capability_->registration_state_); |
| 938 | } |
| 939 | |
Arman Uguray | 6552f8c | 2013-02-12 15:33:18 -0800 | [diff] [blame] | 940 | TEST_F(CellularCapabilityUniversalMainTest, IsValidSimPath) { |
| 941 | // Invalid paths |
| 942 | EXPECT_FALSE(capability_->IsValidSimPath("")); |
| 943 | EXPECT_FALSE(capability_->IsValidSimPath("/")); |
| 944 | |
| 945 | // A valid path |
| 946 | EXPECT_TRUE(capability_->IsValidSimPath( |
| 947 | "/org/freedesktop/ModemManager1/SIM/0")); |
| 948 | |
| 949 | // Note that any string that is not one of the above invalid paths is |
| 950 | // currently regarded as valid, since the ModemManager spec doesn't impose |
| 951 | // a strict format on the path. The validity of this is subject to change. |
| 952 | EXPECT_TRUE(capability_->IsValidSimPath("path")); |
| 953 | } |
| 954 | |
Ben Chan | d759252 | 2013-02-13 16:02:01 -0800 | [diff] [blame] | 955 | TEST_F(CellularCapabilityUniversalMainTest, NormalizeMdn) { |
| 956 | EXPECT_EQ("", capability_->NormalizeMdn("")); |
| 957 | EXPECT_EQ("12345678901", capability_->NormalizeMdn("12345678901")); |
| 958 | EXPECT_EQ("12345678901", capability_->NormalizeMdn("+1 234 567 8901")); |
| 959 | EXPECT_EQ("12345678901", capability_->NormalizeMdn("+1-234-567-8901")); |
| 960 | EXPECT_EQ("12345678901", capability_->NormalizeMdn("+1 (234) 567-8901")); |
| 961 | EXPECT_EQ("12345678901", capability_->NormalizeMdn("1 234 567 8901 ")); |
| 962 | EXPECT_EQ("2345678901", capability_->NormalizeMdn("(234) 567-8901")); |
| 963 | } |
| 964 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 965 | TEST_F(CellularCapabilityUniversalMainTest, SimPathChanged) { |
Ben Chan | bd3aee8 | 2012-10-16 23:52:04 -0700 | [diff] [blame] | 966 | // Set up mock modem SIM properties |
| 967 | const char kImsi[] = "310100000001"; |
| 968 | const char kSimIdentifier[] = "9999888"; |
| 969 | const char kOperatorIdentifier[] = "310240"; |
| 970 | const char kOperatorName[] = "Custom SPN"; |
| 971 | DBusPropertiesMap sim_properties; |
| 972 | sim_properties[MM_SIM_PROPERTY_IMSI].writer().append_string(kImsi); |
| 973 | sim_properties[MM_SIM_PROPERTY_SIMIDENTIFIER].writer() |
| 974 | .append_string(kSimIdentifier); |
| 975 | sim_properties[MM_SIM_PROPERTY_OPERATORIDENTIFIER].writer() |
| 976 | .append_string(kOperatorIdentifier); |
| 977 | sim_properties[MM_SIM_PROPERTY_OPERATORNAME].writer() |
| 978 | .append_string(kOperatorName); |
| 979 | |
| 980 | EXPECT_CALL(*properties_proxy_, GetAll(MM_DBUS_INTERFACE_SIM)) |
| 981 | .Times(1).WillOnce(Return(sim_properties)); |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 982 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 983 | GetActivationState(PendingActivationStore::kIdentifierICCID, _)) |
Prathmesh Prabhu | 97f317c | 2013-03-15 16:20:34 -0700 | [diff] [blame] | 984 | .Times(1); |
Ben Chan | bd3aee8 | 2012-10-16 23:52:04 -0700 | [diff] [blame] | 985 | |
| 986 | EXPECT_FALSE(capability_->sim_present_); |
| 987 | EXPECT_TRUE(capability_->sim_proxy_ == NULL); |
| 988 | EXPECT_EQ("", capability_->sim_path_); |
| 989 | EXPECT_EQ("", capability_->imsi_); |
| 990 | EXPECT_EQ("", capability_->sim_identifier_); |
| 991 | EXPECT_EQ("", capability_->operator_id_); |
| 992 | EXPECT_EQ("", capability_->spn_); |
| 993 | |
| 994 | capability_->OnSimPathChanged(kSimPath); |
| 995 | EXPECT_TRUE(capability_->sim_present_); |
| 996 | EXPECT_TRUE(capability_->sim_proxy_ != NULL); |
| 997 | EXPECT_EQ(kSimPath, capability_->sim_path_); |
| 998 | EXPECT_EQ(kImsi, capability_->imsi_); |
| 999 | EXPECT_EQ(kSimIdentifier, capability_->sim_identifier_); |
| 1000 | EXPECT_EQ(kOperatorIdentifier, capability_->operator_id_); |
| 1001 | EXPECT_EQ(kOperatorName, capability_->spn_); |
| 1002 | |
| 1003 | // Changing to the same SIM path should be a no-op. |
| 1004 | capability_->OnSimPathChanged(kSimPath); |
| 1005 | EXPECT_TRUE(capability_->sim_present_); |
| 1006 | EXPECT_TRUE(capability_->sim_proxy_ != NULL); |
| 1007 | EXPECT_EQ(kSimPath, capability_->sim_path_); |
| 1008 | EXPECT_EQ(kImsi, capability_->imsi_); |
| 1009 | EXPECT_EQ(kSimIdentifier, capability_->sim_identifier_); |
| 1010 | EXPECT_EQ(kOperatorIdentifier, capability_->operator_id_); |
| 1011 | EXPECT_EQ(kOperatorName, capability_->spn_); |
| 1012 | |
| 1013 | capability_->OnSimPathChanged(""); |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1014 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
Prathmesh Prabhu | b5fde53 | 2013-03-19 17:36:09 -0700 | [diff] [blame] | 1015 | Mock::VerifyAndClearExpectations(properties_proxy_.get()); |
Ben Chan | bd3aee8 | 2012-10-16 23:52:04 -0700 | [diff] [blame] | 1016 | EXPECT_FALSE(capability_->sim_present_); |
| 1017 | EXPECT_TRUE(capability_->sim_proxy_ == NULL); |
| 1018 | EXPECT_EQ("", capability_->sim_path_); |
| 1019 | EXPECT_EQ("", capability_->imsi_); |
| 1020 | EXPECT_EQ("", capability_->sim_identifier_); |
| 1021 | EXPECT_EQ("", capability_->operator_id_); |
| 1022 | EXPECT_EQ("", capability_->spn_); |
Arman Uguray | 6552f8c | 2013-02-12 15:33:18 -0800 | [diff] [blame] | 1023 | |
| 1024 | EXPECT_CALL(*properties_proxy_, GetAll(MM_DBUS_INTERFACE_SIM)) |
| 1025 | .Times(1).WillOnce(Return(sim_properties)); |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1026 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 1027 | GetActivationState(PendingActivationStore::kIdentifierICCID, _)) |
Prathmesh Prabhu | 97f317c | 2013-03-15 16:20:34 -0700 | [diff] [blame] | 1028 | .Times(1); |
Arman Uguray | 6552f8c | 2013-02-12 15:33:18 -0800 | [diff] [blame] | 1029 | |
| 1030 | capability_->OnSimPathChanged(kSimPath); |
| 1031 | EXPECT_TRUE(capability_->sim_present_); |
| 1032 | EXPECT_TRUE(capability_->sim_proxy_ != NULL); |
| 1033 | EXPECT_EQ(kSimPath, capability_->sim_path_); |
| 1034 | EXPECT_EQ(kImsi, capability_->imsi_); |
| 1035 | EXPECT_EQ(kSimIdentifier, capability_->sim_identifier_); |
| 1036 | EXPECT_EQ(kOperatorIdentifier, capability_->operator_id_); |
| 1037 | EXPECT_EQ(kOperatorName, capability_->spn_); |
| 1038 | |
| 1039 | capability_->OnSimPathChanged("/"); |
| 1040 | EXPECT_FALSE(capability_->sim_present_); |
| 1041 | EXPECT_TRUE(capability_->sim_proxy_ == NULL); |
| 1042 | EXPECT_EQ("/", capability_->sim_path_); |
| 1043 | EXPECT_EQ("", capability_->imsi_); |
| 1044 | EXPECT_EQ("", capability_->sim_identifier_); |
| 1045 | EXPECT_EQ("", capability_->operator_id_); |
| 1046 | EXPECT_EQ("", capability_->spn_); |
Ben Chan | bd3aee8 | 2012-10-16 23:52:04 -0700 | [diff] [blame] | 1047 | } |
| 1048 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 1049 | TEST_F(CellularCapabilityUniversalMainTest, SimPropertiesChanged) { |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 1050 | // Set up mock modem properties |
| 1051 | DBusPropertiesMap modem_properties; |
| 1052 | modem_properties[MM_MODEM_PROPERTY_SIM].writer().append_path(kSimPath); |
| 1053 | |
| 1054 | // Set up mock modem sim properties |
| 1055 | const char kImsi[] = "310100000001"; |
| 1056 | DBusPropertiesMap sim_properties; |
| 1057 | sim_properties[MM_SIM_PROPERTY_IMSI].writer().append_string(kImsi); |
| 1058 | |
| 1059 | EXPECT_CALL(*properties_proxy_, GetAll(MM_DBUS_INTERFACE_SIM)) |
| 1060 | .WillOnce(Return(sim_properties)); |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1061 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 1062 | GetActivationState(PendingActivationStore::kIdentifierICCID, _)) |
Prathmesh Prabhu | 97f317c | 2013-03-15 16:20:34 -0700 | [diff] [blame] | 1063 | .Times(0); |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 1064 | // After setup we lose pointers to the proxies, so it is hard to set |
| 1065 | // expectations. |
| 1066 | SetUp(); |
Jason Glasgow | 4380f0d | 2012-05-03 18:05:04 -0400 | [diff] [blame] | 1067 | InitProviderDB(); |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 1068 | |
Jason Glasgow | 4380f0d | 2012-05-03 18:05:04 -0400 | [diff] [blame] | 1069 | EXPECT_TRUE(cellular_->home_provider().GetName().empty()); |
| 1070 | EXPECT_TRUE(cellular_->home_provider().GetCountry().empty()); |
| 1071 | EXPECT_TRUE(cellular_->home_provider().GetCode().empty()); |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 1072 | EXPECT_FALSE(capability_->sim_proxy_.get()); |
| 1073 | capability_->OnDBusPropertiesChanged(MM_DBUS_INTERFACE_MODEM, |
| 1074 | modem_properties, vector<string>()); |
| 1075 | EXPECT_EQ(kSimPath, capability_->sim_path_); |
| 1076 | EXPECT_TRUE(capability_->sim_proxy_.get()); |
| 1077 | EXPECT_EQ(kImsi, capability_->imsi_); |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1078 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 1079 | |
| 1080 | // Updating the SIM |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1081 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 1082 | GetActivationState(PendingActivationStore::kIdentifierICCID, _)) |
Prathmesh Prabhu | 97f317c | 2013-03-15 16:20:34 -0700 | [diff] [blame] | 1083 | .Times(2); |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 1084 | DBusPropertiesMap new_properties; |
Jason Glasgow | 4380f0d | 2012-05-03 18:05:04 -0400 | [diff] [blame] | 1085 | const char kCountry[] = "us"; |
Jason Glasgow | 4380f0d | 2012-05-03 18:05:04 -0400 | [diff] [blame] | 1086 | const char kNewImsi[] = "310240123456789"; |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 1087 | const char kSimIdentifier[] = "9999888"; |
Jason Glasgow | 4380f0d | 2012-05-03 18:05:04 -0400 | [diff] [blame] | 1088 | const char kOperatorIdentifier[] = "310240"; |
| 1089 | const char kOperatorName[] = "Custom SPN"; |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 1090 | new_properties[MM_SIM_PROPERTY_IMSI].writer().append_string(kNewImsi); |
| 1091 | new_properties[MM_SIM_PROPERTY_SIMIDENTIFIER].writer(). |
| 1092 | append_string(kSimIdentifier); |
| 1093 | new_properties[MM_SIM_PROPERTY_OPERATORIDENTIFIER].writer(). |
| 1094 | append_string(kOperatorIdentifier); |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 1095 | capability_->OnDBusPropertiesChanged(MM_DBUS_INTERFACE_SIM, |
| 1096 | new_properties, |
| 1097 | vector<string>()); |
| 1098 | EXPECT_EQ(kNewImsi, capability_->imsi_); |
| 1099 | EXPECT_EQ(kSimIdentifier, capability_->sim_identifier_); |
| 1100 | EXPECT_EQ(kOperatorIdentifier, capability_->operator_id_); |
Jason Glasgow | 4380f0d | 2012-05-03 18:05:04 -0400 | [diff] [blame] | 1101 | EXPECT_EQ("", capability_->spn_); |
| 1102 | EXPECT_EQ("T-Mobile", cellular_->home_provider().GetName()); |
| 1103 | EXPECT_EQ(kCountry, cellular_->home_provider().GetCountry()); |
Arman Uguray | d73783f | 2013-01-31 16:11:21 -0800 | [diff] [blame] | 1104 | EXPECT_EQ(kOperatorIdentifier, cellular_->home_provider().GetCode()); |
Jason Glasgow | 4380f0d | 2012-05-03 18:05:04 -0400 | [diff] [blame] | 1105 | EXPECT_EQ(4, capability_->apn_list_.size()); |
| 1106 | |
| 1107 | new_properties[MM_SIM_PROPERTY_OPERATORNAME].writer(). |
| 1108 | append_string(kOperatorName); |
| 1109 | capability_->OnDBusPropertiesChanged(MM_DBUS_INTERFACE_SIM, |
| 1110 | new_properties, |
| 1111 | vector<string>()); |
| 1112 | EXPECT_EQ(kOperatorName, cellular_->home_provider().GetName()); |
Jason Glasgow | af58328 | 2012-04-18 15:18:22 -0400 | [diff] [blame] | 1113 | EXPECT_EQ(kOperatorName, capability_->spn_); |
| 1114 | } |
| 1115 | |
Gary Morain | ceba6aa | 2012-05-03 10:28:26 -0700 | [diff] [blame] | 1116 | MATCHER_P(SizeIs, value, "") { |
| 1117 | return static_cast<size_t>(value) == arg.size(); |
| 1118 | } |
| 1119 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 1120 | TEST_F(CellularCapabilityUniversalMainTest, Reset) { |
Ben Chan | 5d0d32c | 2013-01-08 02:05:29 -0800 | [diff] [blame] | 1121 | // Save pointers to proxies before they are lost by the call to InitProxies |
| 1122 | mm1::MockModemProxy *modem_proxy = modem_proxy_.get(); |
| 1123 | SetUp(); |
| 1124 | EXPECT_CALL(*modem_proxy, set_state_changed_callback(_)); |
| 1125 | capability_->InitProxies(); |
| 1126 | |
| 1127 | Error error; |
| 1128 | ResultCallback reset_callback; |
| 1129 | |
| 1130 | EXPECT_CALL(*modem_proxy, Reset(_, _, CellularCapability::kTimeoutReset)) |
| 1131 | .WillOnce(SaveArg<1>(&reset_callback)); |
| 1132 | |
| 1133 | capability_->Reset(&error, ResultCallback()); |
| 1134 | EXPECT_TRUE(capability_->resetting_); |
| 1135 | reset_callback.Run(error); |
| 1136 | EXPECT_FALSE(capability_->resetting_); |
| 1137 | } |
| 1138 | |
Gary Morain | ceba6aa | 2012-05-03 10:28:26 -0700 | [diff] [blame] | 1139 | // Validates that OnScanReply does not crash with a null callback. |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 1140 | TEST_F(CellularCapabilityUniversalMainTest, ScanWithNullCallback) { |
Gary Morain | ceba6aa | 2012-05-03 10:28:26 -0700 | [diff] [blame] | 1141 | Error error; |
| 1142 | EXPECT_CALL(*modem_3gpp_proxy_, Scan(_, _, CellularCapability::kTimeoutScan)) |
| 1143 | .WillOnce(Invoke(this, &CellularCapabilityUniversalTest::InvokeScan)); |
| 1144 | EXPECT_CALL(*device_adaptor_, |
| 1145 | EmitStringmapsChanged(flimflam::kFoundNetworksProperty, |
| 1146 | SizeIs(0))); |
| 1147 | Set3gppProxy(); |
| 1148 | capability_->Scan(&error, ResultCallback()); |
| 1149 | EXPECT_TRUE(error.IsSuccess()); |
| 1150 | } |
| 1151 | |
Jason Glasgow | cd0349c | 2012-05-03 23:32:15 -0400 | [diff] [blame] | 1152 | // Validates that the scanning property is updated |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 1153 | TEST_F(CellularCapabilityUniversalMainTest, Scan) { |
Jason Glasgow | cd0349c | 2012-05-03 23:32:15 -0400 | [diff] [blame] | 1154 | Error error; |
| 1155 | |
| 1156 | EXPECT_CALL(*modem_3gpp_proxy_, Scan(_, _, CellularCapability::kTimeoutScan)) |
| 1157 | .WillRepeatedly(SaveArg<1>(&scan_callback_)); |
| 1158 | EXPECT_CALL(*device_adaptor_, |
| 1159 | EmitBoolChanged(flimflam::kScanningProperty, true)); |
| 1160 | Set3gppProxy(); |
| 1161 | capability_->Scan(&error, ResultCallback()); |
| 1162 | EXPECT_TRUE(capability_->scanning_); |
Prathmesh Prabhu | b5fde53 | 2013-03-19 17:36:09 -0700 | [diff] [blame] | 1163 | Mock::VerifyAndClearExpectations(device_adaptor_); |
Jason Glasgow | cd0349c | 2012-05-03 23:32:15 -0400 | [diff] [blame] | 1164 | |
| 1165 | // Simulate the completion of the scan with 2 networks in the results. |
| 1166 | EXPECT_CALL(*device_adaptor_, |
| 1167 | EmitBoolChanged(flimflam::kScanningProperty, false)); |
| 1168 | EXPECT_CALL(*device_adaptor_, |
| 1169 | EmitStringmapsChanged(flimflam::kFoundNetworksProperty, |
| 1170 | SizeIs(2))); |
| 1171 | vector<DBusPropertiesMap> results; |
| 1172 | const char kScanID0[] = "testID0"; |
| 1173 | const char kScanID1[] = "testID1"; |
| 1174 | results.push_back(DBusPropertiesMap()); |
| 1175 | results[0][CellularCapabilityUniversal::kOperatorLongProperty]. |
| 1176 | writer().append_string(kScanID0); |
| 1177 | results.push_back(DBusPropertiesMap()); |
| 1178 | results[1][CellularCapabilityUniversal::kOperatorLongProperty]. |
| 1179 | writer().append_string(kScanID1); |
| 1180 | scan_callback_.Run(results, error); |
| 1181 | EXPECT_FALSE(capability_->scanning_); |
Prathmesh Prabhu | b5fde53 | 2013-03-19 17:36:09 -0700 | [diff] [blame] | 1182 | Mock::VerifyAndClearExpectations(device_adaptor_); |
Jason Glasgow | cd0349c | 2012-05-03 23:32:15 -0400 | [diff] [blame] | 1183 | |
| 1184 | // Simulate the completion of the scan with no networks in the results. |
| 1185 | EXPECT_CALL(*device_adaptor_, |
| 1186 | EmitBoolChanged(flimflam::kScanningProperty, true)); |
| 1187 | capability_->Scan(&error, ResultCallback()); |
| 1188 | EXPECT_TRUE(capability_->scanning_); |
Prathmesh Prabhu | b5fde53 | 2013-03-19 17:36:09 -0700 | [diff] [blame] | 1189 | Mock::VerifyAndClearExpectations(device_adaptor_); |
| 1190 | |
Jason Glasgow | cd0349c | 2012-05-03 23:32:15 -0400 | [diff] [blame] | 1191 | EXPECT_CALL(*device_adaptor_, |
| 1192 | EmitBoolChanged(flimflam::kScanningProperty, false)); |
| 1193 | EXPECT_CALL(*device_adaptor_, |
| 1194 | EmitStringmapsChanged(flimflam::kFoundNetworksProperty, |
| 1195 | SizeIs(0))); |
| 1196 | scan_callback_.Run(vector<DBusPropertiesMap>(), Error()); |
| 1197 | EXPECT_FALSE(capability_->scanning_); |
| 1198 | } |
| 1199 | |
| 1200 | // Validates expected property updates when scan fails |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 1201 | TEST_F(CellularCapabilityUniversalMainTest, ScanFailure) { |
Jason Glasgow | cd0349c | 2012-05-03 23:32:15 -0400 | [diff] [blame] | 1202 | Error error; |
| 1203 | |
| 1204 | // Test immediate error |
| 1205 | { |
| 1206 | InSequence seq; |
| 1207 | EXPECT_CALL(*modem_3gpp_proxy_, |
| 1208 | Scan(_, _, CellularCapability::kTimeoutScan)) |
| 1209 | .WillOnce(Invoke(this, &CellularCapabilityUniversalTest::ScanError)); |
| 1210 | EXPECT_CALL(*modem_3gpp_proxy_, |
| 1211 | Scan(_, _, CellularCapability::kTimeoutScan)) |
| 1212 | .WillOnce(SaveArg<1>(&scan_callback_)); |
| 1213 | } |
| 1214 | Set3gppProxy(); |
| 1215 | capability_->Scan(&error, ResultCallback()); |
| 1216 | EXPECT_FALSE(capability_->scanning_); |
| 1217 | EXPECT_TRUE(error.IsFailure()); |
| 1218 | |
| 1219 | // Initiate a scan |
| 1220 | error.Populate(Error::kSuccess); |
| 1221 | EXPECT_CALL(*device_adaptor_, |
| 1222 | EmitBoolChanged(flimflam::kScanningProperty, true)); |
| 1223 | capability_->Scan(&error, ResultCallback()); |
| 1224 | EXPECT_TRUE(capability_->scanning_); |
| 1225 | EXPECT_TRUE(error.IsSuccess()); |
| 1226 | |
| 1227 | // Validate that error is returned if Scan is called while already scanning. |
| 1228 | capability_->Scan(&error, ResultCallback()); |
| 1229 | EXPECT_TRUE(capability_->scanning_); |
| 1230 | EXPECT_TRUE(error.IsFailure()); |
Prathmesh Prabhu | b5fde53 | 2013-03-19 17:36:09 -0700 | [diff] [blame] | 1231 | Mock::VerifyAndClearExpectations(device_adaptor_); |
Jason Glasgow | cd0349c | 2012-05-03 23:32:15 -0400 | [diff] [blame] | 1232 | |
| 1233 | // Validate that signals are emitted even if an error is reported. |
| 1234 | capability_->found_networks_.clear(); |
| 1235 | capability_->found_networks_.push_back(Stringmap()); |
| 1236 | EXPECT_CALL(*device_adaptor_, |
| 1237 | EmitBoolChanged(flimflam::kScanningProperty, false)); |
| 1238 | EXPECT_CALL(*device_adaptor_, |
| 1239 | EmitStringmapsChanged(flimflam::kFoundNetworksProperty, |
| 1240 | SizeIs(0))); |
| 1241 | vector<DBusPropertiesMap> results; |
| 1242 | scan_callback_.Run(results, Error(Error::kOperationFailed)); |
| 1243 | EXPECT_FALSE(capability_->scanning_); |
| 1244 | } |
| 1245 | |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 1246 | // Validates expected behavior of OnListBearersReply function |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 1247 | TEST_F(CellularCapabilityUniversalMainTest, OnListBearersReply) { |
Arman Uguray | 6e5639f | 2012-11-15 20:30:19 -0800 | [diff] [blame] | 1248 | // Check that bearer_path_ is set correctly when an active bearer |
| 1249 | // is returned. |
| 1250 | const size_t kPathCount = 3; |
| 1251 | DBus::Path active_paths[kPathCount], inactive_paths[kPathCount]; |
| 1252 | for (size_t i = 0; i < kPathCount; ++i) { |
| 1253 | active_paths[i] = |
| 1254 | DBus::Path(base::StringPrintf("%s/%zu", kActiveBearerPathPrefix, i)); |
| 1255 | inactive_paths[i] = |
| 1256 | DBus::Path(base::StringPrintf("%s/%zu", kInactiveBearerPathPrefix, i)); |
| 1257 | } |
| 1258 | |
| 1259 | std::vector<DBus::Path> paths; |
| 1260 | paths.push_back(inactive_paths[0]); |
| 1261 | paths.push_back(inactive_paths[1]); |
| 1262 | paths.push_back(active_paths[2]); |
| 1263 | paths.push_back(inactive_paths[1]); |
| 1264 | paths.push_back(inactive_paths[2]); |
| 1265 | |
| 1266 | Error error; |
| 1267 | capability_->OnListBearersReply(paths, error); |
| 1268 | EXPECT_STREQ(capability_->bearer_path_.c_str(), active_paths[2].c_str()); |
| 1269 | |
| 1270 | paths.clear(); |
| 1271 | |
| 1272 | // Check that bearer_path_ is empty if no active bearers are returned. |
| 1273 | paths.push_back(inactive_paths[0]); |
| 1274 | paths.push_back(inactive_paths[1]); |
| 1275 | paths.push_back(inactive_paths[2]); |
| 1276 | paths.push_back(inactive_paths[1]); |
| 1277 | |
| 1278 | capability_->OnListBearersReply(paths, error); |
| 1279 | EXPECT_TRUE(capability_->bearer_path_.empty()); |
| 1280 | |
| 1281 | // Check that returning multiple bearers causes death. |
| 1282 | paths.push_back(active_paths[0]); |
| 1283 | paths.push_back(inactive_paths[1]); |
| 1284 | paths.push_back(inactive_paths[2]); |
| 1285 | paths.push_back(active_paths[1]); |
| 1286 | paths.push_back(inactive_paths[1]); |
| 1287 | |
| 1288 | EXPECT_DEATH(capability_->OnListBearersReply(paths, error), |
| 1289 | "Found more than one active bearer."); |
| 1290 | } |
| 1291 | |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 1292 | // Validates expected behavior of Connect function |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 1293 | TEST_F(CellularCapabilityUniversalMainTest, Connect) { |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 1294 | mm1::MockModemSimpleProxy *modem_simple_proxy = modem_simple_proxy_.get(); |
| 1295 | SetSimpleProxy(); |
| 1296 | Error error; |
| 1297 | DBusPropertiesMap properties; |
| 1298 | capability_->apn_try_list_.clear(); |
| 1299 | ResultCallback callback = |
| 1300 | Bind(&CellularCapabilityUniversalTest::TestCallback, Unretained(this)); |
| 1301 | DBus::Path bearer("/foo"); |
| 1302 | |
| 1303 | // Test connect failures |
| 1304 | EXPECT_CALL(*modem_simple_proxy, Connect(_, _, _, _)) |
Prathmesh Prabhu | b5fde53 | 2013-03-19 17:36:09 -0700 | [diff] [blame] | 1305 | .WillRepeatedly(SaveArg<2>(&connect_callback_)); |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 1306 | capability_->Connect(properties, &error, callback); |
| 1307 | EXPECT_TRUE(error.IsSuccess()); |
| 1308 | EXPECT_CALL(*this, TestCallback(IsFailure())); |
| 1309 | EXPECT_CALL(*service_, ClearLastGoodApn()); |
| 1310 | connect_callback_.Run(bearer, Error(Error::kOperationFailed)); |
Prathmesh Prabhu | b5fde53 | 2013-03-19 17:36:09 -0700 | [diff] [blame] | 1311 | Mock::VerifyAndClearExpectations(this); |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 1312 | |
| 1313 | // Test connect success |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 1314 | capability_->Connect(properties, &error, callback); |
| 1315 | EXPECT_TRUE(error.IsSuccess()); |
| 1316 | EXPECT_CALL(*this, TestCallback(IsSuccess())); |
| 1317 | connect_callback_.Run(bearer, Error(Error::kSuccess)); |
Prathmesh Prabhu | b5fde53 | 2013-03-19 17:36:09 -0700 | [diff] [blame] | 1318 | Mock::VerifyAndClearExpectations(this); |
Jason Glasgow | 7234ec3 | 2012-05-23 16:01:21 -0400 | [diff] [blame] | 1319 | |
| 1320 | // Test connect failures without a service. Make sure that shill |
| 1321 | // does not crash if the connect failed and there is no |
| 1322 | // CellularService object. This can happen if the modem is enabled |
| 1323 | // and then quickly disabled. |
| 1324 | cellular_->service_ = NULL; |
| 1325 | EXPECT_FALSE(capability_->cellular()->service()); |
Jason Glasgow | 7234ec3 | 2012-05-23 16:01:21 -0400 | [diff] [blame] | 1326 | capability_->Connect(properties, &error, callback); |
| 1327 | EXPECT_TRUE(error.IsSuccess()); |
| 1328 | EXPECT_CALL(*this, TestCallback(IsFailure())); |
| 1329 | connect_callback_.Run(bearer, Error(Error::kOperationFailed)); |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 1330 | } |
| 1331 | |
| 1332 | // Validates Connect iterates over APNs |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 1333 | TEST_F(CellularCapabilityUniversalMainTest, ConnectApns) { |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 1334 | mm1::MockModemSimpleProxy *modem_simple_proxy = modem_simple_proxy_.get(); |
| 1335 | SetSimpleProxy(); |
| 1336 | Error error; |
| 1337 | DBusPropertiesMap properties; |
| 1338 | capability_->apn_try_list_.clear(); |
| 1339 | ResultCallback callback = |
| 1340 | Bind(&CellularCapabilityUniversalTest::TestCallback, Unretained(this)); |
| 1341 | DBus::Path bearer("/bearer0"); |
| 1342 | |
| 1343 | const char apn_name_foo[] = "foo"; |
| 1344 | const char apn_name_bar[] = "bar"; |
| 1345 | EXPECT_CALL(*modem_simple_proxy, Connect(HasApn(apn_name_foo), _, _, _)) |
| 1346 | .WillOnce(SaveArg<2>(&connect_callback_)); |
| 1347 | Stringmap apn1; |
| 1348 | apn1[flimflam::kApnProperty] = apn_name_foo; |
| 1349 | capability_->apn_try_list_.push_back(apn1); |
| 1350 | Stringmap apn2; |
| 1351 | apn2[flimflam::kApnProperty] = apn_name_bar; |
| 1352 | capability_->apn_try_list_.push_back(apn2); |
| 1353 | capability_->FillConnectPropertyMap(&properties); |
| 1354 | capability_->Connect(properties, &error, callback); |
| 1355 | EXPECT_TRUE(error.IsSuccess()); |
Prathmesh Prabhu | b5fde53 | 2013-03-19 17:36:09 -0700 | [diff] [blame] | 1356 | Mock::VerifyAndClearExpectations(modem_simple_proxy); |
Jason Glasgow | 1452187 | 2012-05-07 19:12:15 -0400 | [diff] [blame] | 1357 | |
| 1358 | EXPECT_CALL(*modem_simple_proxy, Connect(HasApn(apn_name_bar), _, _, _)) |
| 1359 | .WillOnce(SaveArg<2>(&connect_callback_)); |
| 1360 | EXPECT_CALL(*service_, ClearLastGoodApn()); |
| 1361 | connect_callback_.Run(bearer, Error(Error::kInvalidApn)); |
| 1362 | |
| 1363 | EXPECT_CALL(*service_, SetLastGoodApn(apn2)); |
| 1364 | EXPECT_CALL(*this, TestCallback(IsSuccess())); |
| 1365 | connect_callback_.Run(bearer, Error(Error::kSuccess)); |
| 1366 | } |
| 1367 | |
Jason Glasgow | 9f09aef | 2012-05-08 16:26:55 -0400 | [diff] [blame] | 1368 | // Validates GetTypeString and AccessTechnologyToTechnologyFamily |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 1369 | TEST_F(CellularCapabilityUniversalMainTest, GetTypeString) { |
Jason Glasgow | 9f09aef | 2012-05-08 16:26:55 -0400 | [diff] [blame] | 1370 | const int gsm_technologies[] = { |
| 1371 | MM_MODEM_ACCESS_TECHNOLOGY_LTE, |
| 1372 | MM_MODEM_ACCESS_TECHNOLOGY_HSPA_PLUS, |
| 1373 | MM_MODEM_ACCESS_TECHNOLOGY_HSPA, |
| 1374 | MM_MODEM_ACCESS_TECHNOLOGY_HSUPA, |
| 1375 | MM_MODEM_ACCESS_TECHNOLOGY_HSDPA, |
| 1376 | MM_MODEM_ACCESS_TECHNOLOGY_UMTS, |
| 1377 | MM_MODEM_ACCESS_TECHNOLOGY_EDGE, |
| 1378 | MM_MODEM_ACCESS_TECHNOLOGY_GPRS, |
| 1379 | MM_MODEM_ACCESS_TECHNOLOGY_GSM_COMPACT, |
| 1380 | MM_MODEM_ACCESS_TECHNOLOGY_GSM, |
| 1381 | MM_MODEM_ACCESS_TECHNOLOGY_LTE | MM_MODEM_ACCESS_TECHNOLOGY_EVDO0, |
| 1382 | MM_MODEM_ACCESS_TECHNOLOGY_GSM | MM_MODEM_ACCESS_TECHNOLOGY_EVDO0, |
| 1383 | MM_MODEM_ACCESS_TECHNOLOGY_LTE | MM_MODEM_ACCESS_TECHNOLOGY_EVDOA, |
| 1384 | MM_MODEM_ACCESS_TECHNOLOGY_GSM | MM_MODEM_ACCESS_TECHNOLOGY_EVDOA, |
| 1385 | MM_MODEM_ACCESS_TECHNOLOGY_LTE | MM_MODEM_ACCESS_TECHNOLOGY_EVDOB, |
| 1386 | MM_MODEM_ACCESS_TECHNOLOGY_GSM | MM_MODEM_ACCESS_TECHNOLOGY_EVDOB, |
| 1387 | MM_MODEM_ACCESS_TECHNOLOGY_GSM | MM_MODEM_ACCESS_TECHNOLOGY_1XRTT, |
| 1388 | }; |
Ben Chan | 62028b2 | 2012-11-05 11:20:02 -0800 | [diff] [blame] | 1389 | for (size_t i = 0; i < arraysize(gsm_technologies); ++i) { |
Jason Glasgow | 9f09aef | 2012-05-08 16:26:55 -0400 | [diff] [blame] | 1390 | capability_->access_technologies_ = gsm_technologies[i]; |
| 1391 | ASSERT_EQ(capability_->GetTypeString(), flimflam::kTechnologyFamilyGsm); |
| 1392 | } |
| 1393 | const int cdma_technologies[] = { |
| 1394 | MM_MODEM_ACCESS_TECHNOLOGY_EVDO0, |
| 1395 | MM_MODEM_ACCESS_TECHNOLOGY_EVDOA, |
| 1396 | MM_MODEM_ACCESS_TECHNOLOGY_EVDOA | MM_MODEM_ACCESS_TECHNOLOGY_EVDO0, |
| 1397 | MM_MODEM_ACCESS_TECHNOLOGY_EVDOB, |
| 1398 | MM_MODEM_ACCESS_TECHNOLOGY_EVDOB | MM_MODEM_ACCESS_TECHNOLOGY_EVDO0, |
| 1399 | MM_MODEM_ACCESS_TECHNOLOGY_1XRTT, |
| 1400 | }; |
Ben Chan | 62028b2 | 2012-11-05 11:20:02 -0800 | [diff] [blame] | 1401 | for (size_t i = 0; i < arraysize(cdma_technologies); ++i) { |
Jason Glasgow | 9f09aef | 2012-05-08 16:26:55 -0400 | [diff] [blame] | 1402 | capability_->access_technologies_ = cdma_technologies[i]; |
| 1403 | ASSERT_EQ(capability_->GetTypeString(), flimflam::kTechnologyFamilyCdma); |
| 1404 | } |
| 1405 | capability_->access_technologies_ = MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN; |
| 1406 | ASSERT_EQ(capability_->GetTypeString(), ""); |
| 1407 | } |
| 1408 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 1409 | TEST_F(CellularCapabilityUniversalMainTest, AllowRoaming) { |
Darin Petkov | f508c82 | 2012-09-21 13:43:17 +0200 | [diff] [blame] | 1410 | EXPECT_FALSE(cellular_->allow_roaming_); |
| 1411 | EXPECT_FALSE(capability_->provider_requires_roaming_); |
| 1412 | EXPECT_FALSE(capability_->AllowRoaming()); |
| 1413 | capability_->provider_requires_roaming_ = true; |
| 1414 | EXPECT_TRUE(capability_->AllowRoaming()); |
| 1415 | capability_->provider_requires_roaming_ = false; |
| 1416 | cellular_->allow_roaming_ = true; |
| 1417 | EXPECT_TRUE(capability_->AllowRoaming()); |
| 1418 | } |
| 1419 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 1420 | TEST_F(CellularCapabilityUniversalMainTest, SetHomeProvider) { |
Darin Petkov | b4fccd2 | 2012-08-10 11:59:26 +0200 | [diff] [blame] | 1421 | static const char kTestCarrier[] = "The Cellular Carrier"; |
| 1422 | static const char kCountry[] = "us"; |
| 1423 | static const char kCode[] = "310160"; |
Darin Petkov | b4fccd2 | 2012-08-10 11:59:26 +0200 | [diff] [blame] | 1424 | |
Darin Petkov | f508c82 | 2012-09-21 13:43:17 +0200 | [diff] [blame] | 1425 | EXPECT_FALSE(capability_->home_provider_); |
| 1426 | EXPECT_FALSE(capability_->provider_requires_roaming_); |
| 1427 | |
Arman Uguray | d73783f | 2013-01-31 16:11:21 -0800 | [diff] [blame] | 1428 | // No mobile provider DB available. |
| 1429 | capability_->SetHomeProvider(); |
Darin Petkov | b4fccd2 | 2012-08-10 11:59:26 +0200 | [diff] [blame] | 1430 | EXPECT_TRUE(cellular_->home_provider().GetName().empty()); |
| 1431 | EXPECT_TRUE(cellular_->home_provider().GetCountry().empty()); |
| 1432 | EXPECT_TRUE(cellular_->home_provider().GetCode().empty()); |
Darin Petkov | f508c82 | 2012-09-21 13:43:17 +0200 | [diff] [blame] | 1433 | EXPECT_FALSE(capability_->provider_requires_roaming_); |
Darin Petkov | b4fccd2 | 2012-08-10 11:59:26 +0200 | [diff] [blame] | 1434 | |
| 1435 | InitProviderDB(); |
Arman Uguray | d73783f | 2013-01-31 16:11:21 -0800 | [diff] [blame] | 1436 | |
| 1437 | // IMSI and Operator Code not available. |
| 1438 | capability_->SetHomeProvider(); |
| 1439 | EXPECT_TRUE(cellular_->home_provider().GetName().empty()); |
| 1440 | EXPECT_TRUE(cellular_->home_provider().GetCountry().empty()); |
| 1441 | EXPECT_TRUE(cellular_->home_provider().GetCode().empty()); |
| 1442 | EXPECT_FALSE(capability_->provider_requires_roaming_); |
| 1443 | |
| 1444 | // Operator Code available. |
| 1445 | capability_->operator_id_ = "310240"; |
| 1446 | capability_->SetHomeProvider(); |
| 1447 | EXPECT_EQ("T-Mobile", cellular_->home_provider().GetName()); |
| 1448 | EXPECT_EQ(kCountry, cellular_->home_provider().GetCountry()); |
| 1449 | EXPECT_EQ("310240", cellular_->home_provider().GetCode()); |
| 1450 | EXPECT_EQ(4, capability_->apn_list_.size()); |
| 1451 | ASSERT_TRUE(capability_->home_provider_); |
| 1452 | EXPECT_FALSE(capability_->provider_requires_roaming_); |
| 1453 | |
| 1454 | cellular_->home_provider_.SetName(""); |
| 1455 | cellular_->home_provider_.SetCountry(""); |
| 1456 | cellular_->home_provider_.SetCode(""); |
| 1457 | |
| 1458 | // IMSI available |
| 1459 | capability_->imsi_ = "310240123456789"; |
| 1460 | capability_->operator_id_.clear(); |
Darin Petkov | b4fccd2 | 2012-08-10 11:59:26 +0200 | [diff] [blame] | 1461 | capability_->SetHomeProvider(); |
| 1462 | EXPECT_EQ("T-Mobile", cellular_->home_provider().GetName()); |
| 1463 | EXPECT_EQ(kCountry, cellular_->home_provider().GetCountry()); |
| 1464 | EXPECT_EQ(kCode, cellular_->home_provider().GetCode()); |
| 1465 | EXPECT_EQ(4, capability_->apn_list_.size()); |
| 1466 | ASSERT_TRUE(capability_->home_provider_); |
Darin Petkov | f508c82 | 2012-09-21 13:43:17 +0200 | [diff] [blame] | 1467 | EXPECT_FALSE(capability_->provider_requires_roaming_); |
Darin Petkov | b4fccd2 | 2012-08-10 11:59:26 +0200 | [diff] [blame] | 1468 | |
| 1469 | Cellular::Operator oper; |
| 1470 | cellular_->set_home_provider(oper); |
| 1471 | capability_->spn_ = kTestCarrier; |
| 1472 | capability_->SetHomeProvider(); |
| 1473 | EXPECT_EQ(kTestCarrier, cellular_->home_provider().GetName()); |
| 1474 | EXPECT_EQ(kCountry, cellular_->home_provider().GetCountry()); |
| 1475 | EXPECT_EQ(kCode, cellular_->home_provider().GetCode()); |
Darin Petkov | f508c82 | 2012-09-21 13:43:17 +0200 | [diff] [blame] | 1476 | EXPECT_FALSE(capability_->provider_requires_roaming_); |
Darin Petkov | b4fccd2 | 2012-08-10 11:59:26 +0200 | [diff] [blame] | 1477 | |
| 1478 | static const char kCubic[] = "Cubic"; |
| 1479 | capability_->spn_ = kCubic; |
| 1480 | capability_->SetHomeProvider(); |
| 1481 | EXPECT_EQ(kCubic, cellular_->home_provider().GetName()); |
| 1482 | EXPECT_EQ("", cellular_->home_provider().GetCode()); |
| 1483 | ASSERT_TRUE(capability_->home_provider_); |
Darin Petkov | f508c82 | 2012-09-21 13:43:17 +0200 | [diff] [blame] | 1484 | EXPECT_TRUE(capability_->provider_requires_roaming_); |
Darin Petkov | b4fccd2 | 2012-08-10 11:59:26 +0200 | [diff] [blame] | 1485 | |
| 1486 | static const char kCUBIC[] = "CUBIC"; |
| 1487 | capability_->spn_ = kCUBIC; |
| 1488 | capability_->home_provider_ = NULL; |
| 1489 | capability_->SetHomeProvider(); |
| 1490 | EXPECT_EQ(kCUBIC, cellular_->home_provider().GetName()); |
| 1491 | EXPECT_EQ("", cellular_->home_provider().GetCode()); |
| 1492 | ASSERT_TRUE(capability_->home_provider_); |
Darin Petkov | f508c82 | 2012-09-21 13:43:17 +0200 | [diff] [blame] | 1493 | EXPECT_TRUE(capability_->provider_requires_roaming_); |
Darin Petkov | b4fccd2 | 2012-08-10 11:59:26 +0200 | [diff] [blame] | 1494 | } |
| 1495 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 1496 | TEST_F(CellularCapabilityUniversalMainTest, UpdateScanningProperty) { |
Ben Chan | 8a2c01e | 2013-01-23 10:09:14 -0800 | [diff] [blame] | 1497 | // Save pointers to proxies before they are lost by the call to InitProxies |
| 1498 | // mm1::MockModemProxy *modem_proxy = modem_proxy_.get(); |
| 1499 | SetUp(); |
| 1500 | //EXPECT_CALL(*modem_proxy, set_state_changed_callback(_)); |
| 1501 | capability_->InitProxies(); |
| 1502 | |
| 1503 | EXPECT_FALSE(capability_->scanning_or_searching_); |
| 1504 | capability_->UpdateScanningProperty(); |
| 1505 | EXPECT_FALSE(capability_->scanning_or_searching_); |
| 1506 | |
| 1507 | capability_->scanning_ = true; |
| 1508 | capability_->UpdateScanningProperty(); |
| 1509 | EXPECT_TRUE(capability_->scanning_or_searching_); |
| 1510 | |
| 1511 | capability_->scanning_ = false; |
| 1512 | capability_->cellular()->modem_state_ = Cellular::kModemStateInitializing; |
| 1513 | capability_->UpdateScanningProperty(); |
| 1514 | EXPECT_FALSE(capability_->scanning_or_searching_); |
| 1515 | capability_->cellular()->modem_state_ = Cellular::kModemStateLocked; |
| 1516 | capability_->UpdateScanningProperty(); |
| 1517 | EXPECT_FALSE(capability_->scanning_or_searching_); |
| 1518 | capability_->cellular()->modem_state_ = Cellular::kModemStateDisabled; |
| 1519 | capability_->UpdateScanningProperty(); |
| 1520 | EXPECT_FALSE(capability_->scanning_or_searching_); |
| 1521 | capability_->cellular()->modem_state_ = Cellular::kModemStateEnabling; |
| 1522 | capability_->UpdateScanningProperty(); |
| 1523 | EXPECT_TRUE(capability_->scanning_or_searching_); |
| 1524 | capability_->cellular()->modem_state_ = Cellular::kModemStateEnabled; |
| 1525 | capability_->UpdateScanningProperty(); |
| 1526 | EXPECT_TRUE(capability_->scanning_or_searching_); |
| 1527 | capability_->cellular()->modem_state_ = Cellular::kModemStateSearching; |
| 1528 | capability_->UpdateScanningProperty(); |
| 1529 | EXPECT_TRUE(capability_->scanning_or_searching_); |
| 1530 | capability_->cellular()->modem_state_ = Cellular::kModemStateRegistered; |
| 1531 | capability_->UpdateScanningProperty(); |
| 1532 | EXPECT_FALSE(capability_->scanning_or_searching_); |
| 1533 | capability_->cellular()->modem_state_ = Cellular::kModemStateConnecting; |
| 1534 | capability_->UpdateScanningProperty(); |
| 1535 | EXPECT_FALSE(capability_->scanning_or_searching_); |
| 1536 | capability_->cellular()->modem_state_ = Cellular::kModemStateConnected; |
| 1537 | capability_->UpdateScanningProperty(); |
| 1538 | EXPECT_FALSE(capability_->scanning_or_searching_); |
| 1539 | capability_->cellular()->modem_state_ = Cellular::kModemStateDisconnecting; |
| 1540 | capability_->UpdateScanningProperty(); |
| 1541 | EXPECT_FALSE(capability_->scanning_or_searching_); |
Ben Chan | e1e1e56 | 2013-01-26 00:39:01 -0800 | [diff] [blame] | 1542 | |
Ben Chan | 40a2f86 | 2013-02-13 17:44:38 -0800 | [diff] [blame] | 1543 | // Modem with an unactivated service in the 'enabled' or 'searching' state |
| 1544 | capability_->cellular()->modem_state_ = Cellular::kModemStateEnabled; |
Ben Chan | e1e1e56 | 2013-01-26 00:39:01 -0800 | [diff] [blame] | 1545 | capability_->mdn_ = "0000000000"; |
Ben Chan | e1e1e56 | 2013-01-26 00:39:01 -0800 | [diff] [blame] | 1546 | CellularService::OLP olp; |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 1547 | EXPECT_CALL(*modem_info_.mock_cellular_operator_info(), GetOLPByMCCMNC(_)) |
Ben Chan | 40a2f86 | 2013-02-13 17:44:38 -0800 | [diff] [blame] | 1548 | .WillRepeatedly(Return(&olp)); |
| 1549 | capability_->UpdateScanningProperty(); |
| 1550 | EXPECT_FALSE(capability_->scanning_or_searching_); |
| 1551 | |
| 1552 | capability_->cellular()->modem_state_ = Cellular::kModemStateSearching; |
Ben Chan | e1e1e56 | 2013-01-26 00:39:01 -0800 | [diff] [blame] | 1553 | capability_->UpdateScanningProperty(); |
| 1554 | EXPECT_FALSE(capability_->scanning_or_searching_); |
Ben Chan | 8a2c01e | 2013-01-23 10:09:14 -0800 | [diff] [blame] | 1555 | } |
| 1556 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 1557 | TEST_F(CellularCapabilityUniversalTimerTest, UpdateScanningPropertyTimeout) { |
| 1558 | SetUp(); |
| 1559 | capability_->InitProxies(); |
| 1560 | |
| 1561 | EXPECT_FALSE(capability_->scanning_or_searching_); |
| 1562 | EXPECT_TRUE( |
| 1563 | capability_->scanning_or_searching_timeout_callback_.IsCancelled()); |
| 1564 | capability_->UpdateScanningProperty(); |
| 1565 | EXPECT_FALSE(capability_->scanning_or_searching_); |
| 1566 | EXPECT_TRUE( |
| 1567 | capability_->scanning_or_searching_timeout_callback_.IsCancelled()); |
| 1568 | |
| 1569 | EXPECT_CALL(mock_dispatcher_, |
| 1570 | PostDelayedTask( |
| 1571 | _, |
| 1572 | CellularCapabilityUniversal:: |
| 1573 | kDefaultScanningOrSearchingTimeoutMilliseconds)); |
| 1574 | |
| 1575 | capability_->scanning_ = true; |
| 1576 | capability_->UpdateScanningProperty(); |
| 1577 | EXPECT_FALSE( |
| 1578 | capability_->scanning_or_searching_timeout_callback_.IsCancelled()); |
| 1579 | EXPECT_TRUE(capability_->scanning_or_searching_); |
Prathmesh Prabhu | b5fde53 | 2013-03-19 17:36:09 -0700 | [diff] [blame] | 1580 | Mock::VerifyAndClearExpectations(&mock_dispatcher_); |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 1581 | |
| 1582 | EXPECT_CALL(mock_dispatcher_, |
| 1583 | PostDelayedTask( |
| 1584 | _, |
| 1585 | CellularCapabilityUniversal:: |
| 1586 | kDefaultScanningOrSearchingTimeoutMilliseconds)) |
| 1587 | .Times(0); |
| 1588 | |
| 1589 | capability_->scanning_ = false; |
| 1590 | capability_->UpdateScanningProperty(); |
| 1591 | EXPECT_TRUE( |
| 1592 | capability_->scanning_or_searching_timeout_callback_.IsCancelled()); |
| 1593 | EXPECT_FALSE(capability_->scanning_or_searching_); |
Prathmesh Prabhu | b5fde53 | 2013-03-19 17:36:09 -0700 | [diff] [blame] | 1594 | Mock::VerifyAndClearExpectations(&mock_dispatcher_); |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 1595 | |
| 1596 | EXPECT_CALL(mock_dispatcher_, |
| 1597 | PostDelayedTask( |
| 1598 | _, |
| 1599 | CellularCapabilityUniversal:: |
| 1600 | kDefaultScanningOrSearchingTimeoutMilliseconds)) |
| 1601 | .WillOnce(InvokeWithoutArgs( |
| 1602 | this, |
| 1603 | &CellularCapabilityUniversalTest::InvokeScanningOrSearchingTimeout)); |
| 1604 | |
| 1605 | capability_->scanning_ = true; |
| 1606 | capability_->UpdateScanningProperty(); |
| 1607 | // The callback has been scheduled |
| 1608 | EXPECT_FALSE( |
| 1609 | capability_->scanning_or_searching_timeout_callback_.IsCancelled()); |
| 1610 | // Our mock invocation worked |
| 1611 | EXPECT_FALSE(capability_->scanning_or_searching_); |
| 1612 | } |
| 1613 | |
| 1614 | TEST_F(CellularCapabilityUniversalMainTest, UpdateStorageIdentifier) { |
Arman Uguray | c953357 | 2013-01-22 17:34:20 -0800 | [diff] [blame] | 1615 | CellularOperatorInfo::CellularOperator provider; |
Arman Uguray | c953357 | 2013-01-22 17:34:20 -0800 | [diff] [blame] | 1616 | |
| 1617 | SetService(); |
| 1618 | |
| 1619 | const string prefix = "cellular_" + string(kMachineAddress) + "_"; |
Arman Uguray | 2717a10 | 2013-01-29 23:36:06 -0800 | [diff] [blame] | 1620 | string default_identifier_pattern = |
| 1621 | prefix + string(CellularCapabilityUniversal::kGenericServiceNamePrefix); |
| 1622 | std::replace_if(default_identifier_pattern.begin(), |
| 1623 | default_identifier_pattern.end(), |
| 1624 | &Service::IllegalChar, '_'); |
| 1625 | default_identifier_pattern += "*"; |
Arman Uguray | c953357 | 2013-01-22 17:34:20 -0800 | [diff] [blame] | 1626 | |
| 1627 | // |capability_->operator_id_| is "". |
| 1628 | capability_->UpdateStorageIdentifier(); |
| 1629 | EXPECT_TRUE(::MatchPattern(cellular_->service()->storage_identifier_, |
| 1630 | default_identifier_pattern)); |
| 1631 | |
| 1632 | // GetCellularOperatorByMCCMNC returns NULL. |
| 1633 | capability_->operator_id_ = "1"; |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 1634 | EXPECT_CALL(*modem_info_.mock_cellular_operator_info(), |
Arman Uguray | c953357 | 2013-01-22 17:34:20 -0800 | [diff] [blame] | 1635 | GetCellularOperatorByMCCMNC(capability_->operator_id_)) |
| 1636 | .WillOnce( |
| 1637 | Return((const CellularOperatorInfo::CellularOperator *)NULL)); |
| 1638 | |
| 1639 | capability_->UpdateStorageIdentifier(); |
| 1640 | EXPECT_TRUE(::MatchPattern(cellular_->service()->storage_identifier_, |
| 1641 | default_identifier_pattern)); |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 1642 | Mock::VerifyAndClearExpectations(modem_info_.mock_cellular_operator_info()); |
Arman Uguray | c953357 | 2013-01-22 17:34:20 -0800 | [diff] [blame] | 1643 | |
| 1644 | // |capability_->imsi_| is not "" |
| 1645 | capability_->imsi_ = "TESTIMSI"; |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 1646 | EXPECT_CALL(*modem_info_.mock_cellular_operator_info(), |
Arman Uguray | c953357 | 2013-01-22 17:34:20 -0800 | [diff] [blame] | 1647 | GetCellularOperatorByMCCMNC(capability_->operator_id_)) |
| 1648 | .WillOnce( |
| 1649 | Return((const CellularOperatorInfo::CellularOperator *)NULL)); |
| 1650 | |
| 1651 | capability_->UpdateStorageIdentifier(); |
| 1652 | EXPECT_EQ(prefix + "TESTIMSI", cellular_->service()->storage_identifier_); |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 1653 | Mock::VerifyAndClearExpectations(modem_info_.mock_cellular_operator_info()); |
Arman Uguray | c953357 | 2013-01-22 17:34:20 -0800 | [diff] [blame] | 1654 | |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 1655 | EXPECT_CALL(*modem_info_.mock_cellular_operator_info(), |
Arman Uguray | c953357 | 2013-01-22 17:34:20 -0800 | [diff] [blame] | 1656 | GetCellularOperatorByMCCMNC(capability_->operator_id_)) |
| 1657 | .Times(2) |
| 1658 | .WillRepeatedly(Return(&provider)); |
| 1659 | |
| 1660 | // |provider.identifier_| is "". |
| 1661 | capability_->UpdateStorageIdentifier(); |
| 1662 | EXPECT_EQ(prefix + "TESTIMSI", cellular_->service()->storage_identifier_); |
| 1663 | |
| 1664 | // Success. |
| 1665 | provider.identifier_ = "testidentifier"; |
| 1666 | capability_->UpdateStorageIdentifier(); |
| 1667 | EXPECT_EQ(prefix + "testidentifier", |
| 1668 | cellular_->service()->storage_identifier_); |
| 1669 | } |
| 1670 | |
Ben Chan | 07193fd | 2013-07-12 22:10:55 -0700 | [diff] [blame] | 1671 | TEST_F(CellularCapabilityUniversalMainTest, GetMdnForOLP) { |
| 1672 | CellularOperatorInfo::CellularOperator cellular_operator; |
| 1673 | |
| 1674 | cellular_operator.identifier_ = "vzw"; |
| 1675 | capability_->mdn_ = ""; |
| 1676 | EXPECT_EQ("", capability_->GetMdnForOLP(cellular_operator)); |
| 1677 | capability_->mdn_ = "0123456789"; |
| 1678 | EXPECT_EQ("0123456789", capability_->GetMdnForOLP(cellular_operator)); |
| 1679 | capability_->mdn_ = "10123456789"; |
| 1680 | EXPECT_EQ("0123456789", capability_->GetMdnForOLP(cellular_operator)); |
| 1681 | |
| 1682 | cellular_operator.identifier_ = "foo"; |
| 1683 | capability_->mdn_ = ""; |
| 1684 | EXPECT_EQ("", capability_->GetMdnForOLP(cellular_operator)); |
| 1685 | capability_->mdn_ = "0123456789"; |
| 1686 | EXPECT_EQ("0123456789", capability_->GetMdnForOLP(cellular_operator)); |
| 1687 | capability_->mdn_ = "10123456789"; |
| 1688 | EXPECT_EQ("10123456789", capability_->GetMdnForOLP(cellular_operator)); |
| 1689 | } |
| 1690 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 1691 | TEST_F(CellularCapabilityUniversalMainTest, UpdateOLP) { |
Ben Chan | 07193fd | 2013-07-12 22:10:55 -0700 | [diff] [blame] | 1692 | CellularOperatorInfo::CellularOperator cellular_operator; |
| 1693 | |
Ben Chan | 6d0d1e7 | 2012-11-06 21:19:28 -0800 | [diff] [blame] | 1694 | CellularService::OLP test_olp; |
| 1695 | test_olp.SetURL("http://testurl"); |
| 1696 | test_olp.SetMethod("POST"); |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 1697 | test_olp.SetPostData("imei=${imei}&imsi=${imsi}&mdn=${mdn}&" |
| 1698 | "min=${min}&iccid=${iccid}"); |
Ben Chan | 6d0d1e7 | 2012-11-06 21:19:28 -0800 | [diff] [blame] | 1699 | |
Ben Chan | 6d0d1e7 | 2012-11-06 21:19:28 -0800 | [diff] [blame] | 1700 | capability_->imei_ = "1"; |
| 1701 | capability_->imsi_ = "2"; |
Ben Chan | 07193fd | 2013-07-12 22:10:55 -0700 | [diff] [blame] | 1702 | capability_->mdn_ = "10123456789"; |
Ben Chan | 6d0d1e7 | 2012-11-06 21:19:28 -0800 | [diff] [blame] | 1703 | capability_->min_ = "5"; |
| 1704 | capability_->sim_identifier_ = "6"; |
| 1705 | capability_->operator_id_ = "123456"; |
Ben Chan | 6d0d1e7 | 2012-11-06 21:19:28 -0800 | [diff] [blame] | 1706 | |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 1707 | EXPECT_CALL(*modem_info_.mock_cellular_operator_info(), |
Ben Chan | 07193fd | 2013-07-12 22:10:55 -0700 | [diff] [blame] | 1708 | GetCellularOperatorByMCCMNC(capability_->operator_id_)) |
| 1709 | .WillRepeatedly(Return(&cellular_operator)); |
| 1710 | EXPECT_CALL(*modem_info_.mock_cellular_operator_info(), |
Arman Uguray | f4c6181 | 2013-01-10 18:58:39 -0800 | [diff] [blame] | 1711 | GetOLPByMCCMNC(capability_->operator_id_)) |
| 1712 | .WillRepeatedly(Return(&test_olp)); |
Ben Chan | 6d0d1e7 | 2012-11-06 21:19:28 -0800 | [diff] [blame] | 1713 | |
| 1714 | SetService(); |
Ben Chan | 07193fd | 2013-07-12 22:10:55 -0700 | [diff] [blame] | 1715 | cellular_operator.identifier_ = "vzw"; |
| 1716 | capability_->UpdateOLP(); |
| 1717 | const CellularService::OLP &vzw_olp = cellular_->service()->olp(); |
| 1718 | EXPECT_EQ("http://testurl", vzw_olp.GetURL()); |
| 1719 | EXPECT_EQ("POST", vzw_olp.GetMethod()); |
| 1720 | EXPECT_EQ("imei=1&imsi=2&mdn=0123456789&min=5&iccid=6", |
| 1721 | vzw_olp.GetPostData()); |
| 1722 | |
| 1723 | cellular_operator.identifier_ = "foo"; |
Ben Chan | 6d0d1e7 | 2012-11-06 21:19:28 -0800 | [diff] [blame] | 1724 | capability_->UpdateOLP(); |
| 1725 | const CellularService::OLP &olp = cellular_->service()->olp(); |
| 1726 | EXPECT_EQ("http://testurl", olp.GetURL()); |
| 1727 | EXPECT_EQ("POST", olp.GetMethod()); |
Ben Chan | 07193fd | 2013-07-12 22:10:55 -0700 | [diff] [blame] | 1728 | EXPECT_EQ("imei=1&imsi=2&mdn=10123456789&min=5&iccid=6", |
Ben Chan | 6d0d1e7 | 2012-11-06 21:19:28 -0800 | [diff] [blame] | 1729 | olp.GetPostData()); |
| 1730 | } |
| 1731 | |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 1732 | TEST_F(CellularCapabilityUniversalMainTest, IsMdnValid) { |
| 1733 | capability_->mdn_.clear(); |
| 1734 | EXPECT_FALSE(capability_->IsMdnValid()); |
| 1735 | capability_->mdn_ = "0000000"; |
| 1736 | EXPECT_FALSE(capability_->IsMdnValid()); |
| 1737 | capability_->mdn_ = "0000001"; |
| 1738 | EXPECT_TRUE(capability_->IsMdnValid()); |
| 1739 | capability_->mdn_ = "1231223"; |
| 1740 | EXPECT_TRUE(capability_->IsMdnValid()); |
| 1741 | } |
| 1742 | |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 1743 | TEST_F(CellularCapabilityUniversalTimerTest, CompleteActivation) { |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 1744 | const char kIccid[] = "1234567"; |
| 1745 | |
| 1746 | capability_->mdn_.clear(); |
| 1747 | capability_->sim_identifier_.clear(); |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 1748 | |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 1749 | EXPECT_CALL(*service_, |
| 1750 | SetActivationState(flimflam::kActivationStateActivating)) |
| 1751 | .Times(0); |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1752 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 1753 | SetActivationState( |
| 1754 | PendingActivationStore::kIdentifierICCID, _, _)) |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 1755 | .Times(0); |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 1756 | EXPECT_CALL(mock_dispatcher_, PostDelayedTask(_, _)).Times(0); |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 1757 | Error error; |
| 1758 | capability_->CompleteActivation(&error); |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1759 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
Prathmesh Prabhu | b5fde53 | 2013-03-19 17:36:09 -0700 | [diff] [blame] | 1760 | Mock::VerifyAndClearExpectations(service_); |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 1761 | Mock::VerifyAndClearExpectations(&mock_dispatcher_); |
| 1762 | EXPECT_TRUE( |
| 1763 | capability_->activation_wait_for_registration_callback_.IsCancelled()); |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 1764 | |
| 1765 | capability_->sim_identifier_ = kIccid; |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1766 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 1767 | SetActivationState(PendingActivationStore::kIdentifierICCID, |
| 1768 | kIccid, |
| 1769 | PendingActivationStore::kStatePending)) |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 1770 | .Times(1); |
| 1771 | EXPECT_CALL(*service_, |
| 1772 | SetActivationState(flimflam::kActivationStateActivating)) |
| 1773 | .Times(1); |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 1774 | EXPECT_CALL(mock_dispatcher_, PostDelayedTask(_, _)).Times(1); |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 1775 | capability_->CompleteActivation(&error); |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1776 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
Prathmesh Prabhu | b5fde53 | 2013-03-19 17:36:09 -0700 | [diff] [blame] | 1777 | Mock::VerifyAndClearExpectations(service_); |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 1778 | Mock::VerifyAndClearExpectations(&mock_dispatcher_); |
| 1779 | EXPECT_FALSE( |
| 1780 | capability_->activation_wait_for_registration_callback_.IsCancelled()); |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 1781 | |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1782 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 1783 | SetActivationState(PendingActivationStore::kIdentifierICCID, |
| 1784 | kIccid, |
| 1785 | PendingActivationStore::kStatePending)) |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 1786 | .Times(0); |
| 1787 | EXPECT_CALL(*service_, |
| 1788 | SetActivationState(flimflam::kActivationStateActivating)) |
| 1789 | .Times(0); |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 1790 | EXPECT_CALL(mock_dispatcher_, PostDelayedTask(_, _)).Times(0); |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 1791 | capability_->mdn_ = "1231231212"; |
| 1792 | capability_->CompleteActivation(&error); |
| 1793 | } |
| 1794 | |
| 1795 | TEST_F(CellularCapabilityUniversalMainTest, UpdateServiceActivationState) { |
| 1796 | const char kIccid[] = "1234567"; |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 1797 | capability_->sim_identifier_.clear(); |
| 1798 | capability_->mdn_ = "0000000000"; |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 1799 | CellularService::OLP olp; |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 1800 | EXPECT_CALL(*modem_info_.mock_cellular_operator_info(), GetOLPByMCCMNC(_)) |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 1801 | .WillRepeatedly(Return(&olp)); |
| 1802 | |
Arman Uguray | 6bb252d | 2013-05-15 14:29:53 -0700 | [diff] [blame] | 1803 | service_->SetAutoConnect(false); |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 1804 | EXPECT_CALL(*service_, |
| 1805 | SetActivationState(flimflam::kActivationStateNotActivated)) |
| 1806 | .Times(1); |
| 1807 | capability_->UpdateServiceActivationState(); |
Prathmesh Prabhu | b5fde53 | 2013-03-19 17:36:09 -0700 | [diff] [blame] | 1808 | Mock::VerifyAndClearExpectations(service_); |
Arman Uguray | 6bb252d | 2013-05-15 14:29:53 -0700 | [diff] [blame] | 1809 | EXPECT_FALSE(service_->auto_connect()); |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 1810 | |
| 1811 | capability_->mdn_ = "1231231122"; |
| 1812 | EXPECT_CALL(*service_, |
| 1813 | SetActivationState(flimflam::kActivationStateActivated)) |
| 1814 | .Times(1); |
| 1815 | capability_->UpdateServiceActivationState(); |
Prathmesh Prabhu | b5fde53 | 2013-03-19 17:36:09 -0700 | [diff] [blame] | 1816 | Mock::VerifyAndClearExpectations(service_); |
Arman Uguray | 6bb252d | 2013-05-15 14:29:53 -0700 | [diff] [blame] | 1817 | EXPECT_TRUE(service_->auto_connect()); |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 1818 | |
Arman Uguray | 6bb252d | 2013-05-15 14:29:53 -0700 | [diff] [blame] | 1819 | service_->SetAutoConnect(false); |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 1820 | capability_->mdn_ = "0000000000"; |
| 1821 | capability_->sim_identifier_ = kIccid; |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1822 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 1823 | GetActivationState(PendingActivationStore::kIdentifierICCID, |
| 1824 | kIccid)) |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 1825 | .Times(2) |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1826 | .WillOnce(Return(PendingActivationStore::kStatePending)) |
| 1827 | .WillOnce(Return(PendingActivationStore::kStatePendingTimeout)); |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 1828 | EXPECT_CALL(*service_, |
| 1829 | SetActivationState(flimflam::kActivationStateActivating)) |
| 1830 | .Times(1); |
| 1831 | capability_->UpdateServiceActivationState(); |
Prathmesh Prabhu | b5fde53 | 2013-03-19 17:36:09 -0700 | [diff] [blame] | 1832 | Mock::VerifyAndClearExpectations(service_); |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1833 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
Arman Uguray | 6bb252d | 2013-05-15 14:29:53 -0700 | [diff] [blame] | 1834 | EXPECT_FALSE(service_->auto_connect()); |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 1835 | |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1836 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 1837 | GetActivationState(PendingActivationStore::kIdentifierICCID, |
| 1838 | kIccid)) |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 1839 | .Times(2) |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1840 | .WillRepeatedly(Return(PendingActivationStore::kStateActivated)); |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 1841 | EXPECT_CALL(*service_, |
| 1842 | SetActivationState(flimflam::kActivationStateActivated)) |
| 1843 | .Times(1); |
| 1844 | capability_->UpdateServiceActivationState(); |
Arman Uguray | 6bb252d | 2013-05-15 14:29:53 -0700 | [diff] [blame] | 1845 | Mock::VerifyAndClearExpectations(service_); |
| 1846 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
| 1847 | EXPECT_TRUE(service_->auto_connect()); |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 1848 | } |
| 1849 | |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 1850 | TEST_F(CellularCapabilityUniversalMainTest, ActivationWaitForRegisterTimeout) { |
| 1851 | const char kIccid[] = "1234567"; |
| 1852 | |
| 1853 | mm1::MockModemProxy *modem_proxy = modem_proxy_.get(); |
| 1854 | capability_->InitProxies(); |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1855 | EXPECT_CALL(*modem_proxy, Reset(_, _, _)).Times(0); |
| 1856 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 1857 | SetActivationState(_, _, _)) |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 1858 | .Times(0); |
| 1859 | |
| 1860 | // No ICCID, no MDN |
| 1861 | capability_->sim_identifier_.clear(); |
| 1862 | capability_->mdn_.clear(); |
| 1863 | capability_->reset_done_ = false; |
| 1864 | capability_->OnActivationWaitForRegisterTimeout(); |
| 1865 | |
| 1866 | // State is not activated. |
| 1867 | capability_->sim_identifier_ = kIccid; |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1868 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 1869 | GetActivationState(PendingActivationStore::kIdentifierICCID, _)) |
| 1870 | .WillOnce(Return(PendingActivationStore::kStateActivated)) |
| 1871 | .WillRepeatedly(Return(PendingActivationStore::kStatePending)); |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 1872 | capability_->OnActivationWaitForRegisterTimeout(); |
| 1873 | |
| 1874 | // Valid MDN. |
| 1875 | capability_->mdn_ = "0000000001"; |
| 1876 | capability_->OnActivationWaitForRegisterTimeout(); |
| 1877 | |
| 1878 | // Invalid MDN, reset done. |
| 1879 | capability_->mdn_ = "0000000000"; |
| 1880 | capability_->reset_done_ = true; |
| 1881 | capability_->OnActivationWaitForRegisterTimeout(); |
| 1882 | |
| 1883 | Mock::VerifyAndClearExpectations(modem_proxy); |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1884 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 1885 | |
| 1886 | // Reset not done. |
| 1887 | capability_->reset_done_ = false; |
| 1888 | EXPECT_CALL(*modem_proxy, Reset(_,_,_)).Times(1); |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1889 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 1890 | GetActivationState(PendingActivationStore::kIdentifierICCID, _)) |
| 1891 | .WillOnce(Return(PendingActivationStore::kStatePending)); |
| 1892 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 1893 | SetActivationState(PendingActivationStore::kIdentifierICCID, |
| 1894 | kIccid, |
| 1895 | PendingActivationStore::kStatePendingTimeout)) |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 1896 | .Times(1); |
| 1897 | capability_->OnActivationWaitForRegisterTimeout(); |
| 1898 | } |
| 1899 | |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 1900 | TEST_F(CellularCapabilityUniversalMainTest, UpdatePendingActivationState) { |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 1901 | const char kIccid[] = "1234567"; |
| 1902 | |
| 1903 | mm1::MockModemProxy *modem_proxy = modem_proxy_.get(); |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 1904 | capability_->InitProxies(); |
| 1905 | capability_->registration_state_ = |
| 1906 | MM_MODEM_3GPP_REGISTRATION_STATE_SEARCHING; |
| 1907 | |
| 1908 | // No MDN, no ICCID. |
| 1909 | capability_->mdn_ = "0000000"; |
| 1910 | capability_->sim_identifier_.clear(); |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1911 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 1912 | GetActivationState(PendingActivationStore::kIdentifierICCID, _)) |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 1913 | .Times(0); |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 1914 | capability_->UpdatePendingActivationState(); |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1915 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 1916 | |
| 1917 | // ICCID known. |
| 1918 | capability_->sim_identifier_ = kIccid; |
| 1919 | |
| 1920 | // After the modem has reset. |
| 1921 | capability_->reset_done_ = true; |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1922 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 1923 | GetActivationState(PendingActivationStore::kIdentifierICCID, |
| 1924 | kIccid)) |
| 1925 | .Times(1).WillOnce(Return(PendingActivationStore::kStatePending)); |
| 1926 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 1927 | SetActivationState(PendingActivationStore::kIdentifierICCID, |
| 1928 | kIccid, |
| 1929 | PendingActivationStore::kStateActivated)) |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 1930 | .Times(1); |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 1931 | capability_->UpdatePendingActivationState(); |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1932 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 1933 | |
| 1934 | // Before reset, not registered. |
| 1935 | capability_->reset_done_ = false; |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1936 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 1937 | GetActivationState(PendingActivationStore::kIdentifierICCID, |
| 1938 | kIccid)) |
| 1939 | .Times(2).WillRepeatedly(Return(PendingActivationStore::kStatePending)); |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 1940 | EXPECT_CALL(*service_, |
| 1941 | SetActivationState(flimflam::kActivationStateActivating)) |
| 1942 | .Times(2); |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 1943 | EXPECT_CALL(*modem_proxy, Reset(_, _, _)).Times(0); |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 1944 | capability_->UpdatePendingActivationState(); |
Prathmesh Prabhu | b5fde53 | 2013-03-19 17:36:09 -0700 | [diff] [blame] | 1945 | Mock::VerifyAndClearExpectations(modem_proxy); |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 1946 | |
| 1947 | // Before reset, registered. |
| 1948 | capability_->registration_state_ = |
| 1949 | MM_MODEM_3GPP_REGISTRATION_STATE_HOME; |
| 1950 | EXPECT_CALL(*modem_proxy, Reset(_, _, _)).Times(1); |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 1951 | capability_->UpdatePendingActivationState(); |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1952 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 1953 | |
| 1954 | // Not registered. |
| 1955 | capability_->registration_state_ = |
| 1956 | MM_MODEM_3GPP_REGISTRATION_STATE_SEARCHING; |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1957 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 1958 | GetActivationState(PendingActivationStore::kIdentifierICCID, |
| 1959 | kIccid)) |
| 1960 | .Times(2).WillRepeatedly(Return(PendingActivationStore::kStateActivated)); |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 1961 | EXPECT_CALL(*service_, AutoConnect()).Times(0); |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 1962 | capability_->UpdatePendingActivationState(); |
Prathmesh Prabhu | b5fde53 | 2013-03-19 17:36:09 -0700 | [diff] [blame] | 1963 | Mock::VerifyAndClearExpectations(service_); |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 1964 | |
| 1965 | // Service, registered. |
| 1966 | capability_->registration_state_ = |
| 1967 | MM_MODEM_3GPP_REGISTRATION_STATE_HOME; |
| 1968 | EXPECT_CALL(*service_, AutoConnect()).Times(1); |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 1969 | capability_->UpdatePendingActivationState(); |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 1970 | |
| 1971 | cellular_->service_->activation_state_ = |
| 1972 | flimflam::kActivationStateNotActivated; |
| 1973 | |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1974 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 1975 | |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 1976 | // Device is connected. |
| 1977 | cellular_->state_ = Cellular::kStateConnected; |
| 1978 | EXPECT_CALL(*service_, |
| 1979 | SetActivationState(flimflam::kActivationStateActivated)) |
| 1980 | .Times(3); |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 1981 | capability_->UpdatePendingActivationState(); |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 1982 | |
| 1983 | // Device is linked. |
| 1984 | cellular_->state_ = Cellular::kStateLinked; |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 1985 | capability_->UpdatePendingActivationState(); |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 1986 | |
| 1987 | // Got valid MDN. |
| 1988 | cellular_->state_ = Cellular::kStateRegistered; |
| 1989 | capability_->mdn_ = "1231223"; |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1990 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 1991 | RemoveEntry(PendingActivationStore::kIdentifierICCID, kIccid)) |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 1992 | .Times(1); |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 1993 | capability_->UpdatePendingActivationState(); |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 1994 | |
| 1995 | Mock::VerifyAndClearExpectations(service_); |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 1996 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 1997 | |
| 1998 | // Timed out, not registered. |
| 1999 | capability_->mdn_.clear(); |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 2000 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 2001 | GetActivationState(PendingActivationStore::kIdentifierICCID, |
| 2002 | kIccid)) |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 2003 | .Times(1) |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 2004 | .WillOnce(Return(PendingActivationStore::kStatePendingTimeout)); |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 2005 | capability_->registration_state_ = |
| 2006 | MM_MODEM_3GPP_REGISTRATION_STATE_SEARCHING; |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 2007 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 2008 | SetActivationState(_, _, _)) |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 2009 | .Times(0); |
| 2010 | EXPECT_CALL(*service_, SetActivationState(_)).Times(0); |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 2011 | capability_->UpdatePendingActivationState(); |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 2012 | Mock::VerifyAndClearExpectations(service_); |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 2013 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 2014 | |
| 2015 | // Timed out, registered. |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 2016 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 2017 | GetActivationState(PendingActivationStore::kIdentifierICCID, |
| 2018 | kIccid)) |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 2019 | .Times(1) |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 2020 | .WillOnce(Return(PendingActivationStore::kStatePendingTimeout)); |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 2021 | capability_->registration_state_ = |
| 2022 | MM_MODEM_3GPP_REGISTRATION_STATE_HOME; |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 2023 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 2024 | SetActivationState(PendingActivationStore::kIdentifierICCID, |
| 2025 | kIccid, |
| 2026 | PendingActivationStore::kStateActivated)) |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 2027 | .Times(1); |
| 2028 | EXPECT_CALL(*service_, |
| 2029 | SetActivationState(flimflam::kActivationStateActivated)) |
| 2030 | .Times(1); |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 2031 | capability_->UpdatePendingActivationState(); |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 2032 | Mock::VerifyAndClearExpectations(service_); |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 2033 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
Arman Uguray | c7b1560 | 2013-02-16 00:56:18 -0800 | [diff] [blame] | 2034 | } |
| 2035 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 2036 | TEST_F(CellularCapabilityUniversalMainTest, UpdateOperatorInfo) { |
Darin Petkov | a4ca3c3 | 2012-08-17 16:05:24 +0200 | [diff] [blame] | 2037 | static const char kOperatorName[] = "Swisscom"; |
| 2038 | InitProviderDB(); |
| 2039 | capability_->serving_operator_.SetCode("22801"); |
| 2040 | SetService(); |
| 2041 | capability_->UpdateOperatorInfo(); |
| 2042 | EXPECT_EQ(kOperatorName, capability_->serving_operator_.GetName()); |
| 2043 | EXPECT_EQ("ch", capability_->serving_operator_.GetCountry()); |
| 2044 | EXPECT_EQ(kOperatorName, cellular_->service()->serving_operator().GetName()); |
| 2045 | |
| 2046 | static const char kTestOperator[] = "Testcom"; |
| 2047 | capability_->serving_operator_.SetName(kTestOperator); |
| 2048 | capability_->serving_operator_.SetCountry(""); |
| 2049 | capability_->UpdateOperatorInfo(); |
| 2050 | EXPECT_EQ(kTestOperator, capability_->serving_operator_.GetName()); |
| 2051 | EXPECT_EQ("ch", capability_->serving_operator_.GetCountry()); |
| 2052 | EXPECT_EQ(kTestOperator, cellular_->service()->serving_operator().GetName()); |
| 2053 | } |
| 2054 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 2055 | TEST_F(CellularCapabilityUniversalMainTest, UpdateOperatorInfoViaOperatorId) { |
Ben Chan | 092b12b | 2012-11-07 22:04:05 -0800 | [diff] [blame] | 2056 | static const char kOperatorName[] = "Swisscom"; |
| 2057 | static const char kOperatorId[] = "22801"; |
| 2058 | InitProviderDB(); |
| 2059 | capability_->serving_operator_.SetCode(""); |
| 2060 | SetService(); |
| 2061 | capability_->UpdateOperatorInfo(); |
| 2062 | EXPECT_EQ("", capability_->serving_operator_.GetName()); |
| 2063 | EXPECT_EQ("", capability_->serving_operator_.GetCountry()); |
| 2064 | EXPECT_EQ("", cellular_->service()->serving_operator().GetName()); |
| 2065 | |
| 2066 | capability_->operator_id_ = kOperatorId; |
| 2067 | |
Ben Chan | 092b12b | 2012-11-07 22:04:05 -0800 | [diff] [blame] | 2068 | capability_->UpdateOperatorInfo(); |
| 2069 | EXPECT_EQ(kOperatorId, capability_->serving_operator_.GetCode()); |
| 2070 | EXPECT_EQ(kOperatorName, capability_->serving_operator_.GetName()); |
| 2071 | EXPECT_EQ("ch", capability_->serving_operator_.GetCountry()); |
| 2072 | EXPECT_EQ(kOperatorName, cellular_->service()->serving_operator().GetName()); |
| 2073 | } |
| 2074 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 2075 | TEST_F(CellularCapabilityUniversalMainTest, CreateFriendlyServiceName) { |
Darin Petkov | a4ca3c3 | 2012-08-17 16:05:24 +0200 | [diff] [blame] | 2076 | CellularCapabilityUniversal::friendly_service_name_id_ = 0; |
Arman Uguray | 2717a10 | 2013-01-29 23:36:06 -0800 | [diff] [blame] | 2077 | EXPECT_EQ("Mobile Network 0", capability_->CreateFriendlyServiceName()); |
| 2078 | EXPECT_EQ("Mobile Network 1", capability_->CreateFriendlyServiceName()); |
Darin Petkov | a4ca3c3 | 2012-08-17 16:05:24 +0200 | [diff] [blame] | 2079 | |
Ben Chan | 092b12b | 2012-11-07 22:04:05 -0800 | [diff] [blame] | 2080 | capability_->operator_id_ = "0123"; |
Ben Chan | 092b12b | 2012-11-07 22:04:05 -0800 | [diff] [blame] | 2081 | EXPECT_EQ("cellular_0123", capability_->CreateFriendlyServiceName()); |
| 2082 | EXPECT_EQ("0123", capability_->serving_operator_.GetCode()); |
| 2083 | |
Darin Petkov | a4ca3c3 | 2012-08-17 16:05:24 +0200 | [diff] [blame] | 2084 | capability_->serving_operator_.SetCode("1234"); |
| 2085 | EXPECT_EQ("cellular_1234", capability_->CreateFriendlyServiceName()); |
| 2086 | |
| 2087 | static const char kHomeProvider[] = "The GSM Home Provider"; |
| 2088 | cellular_->home_provider_.SetName(kHomeProvider); |
| 2089 | EXPECT_EQ("cellular_1234", capability_->CreateFriendlyServiceName()); |
| 2090 | capability_->registration_state_ = MM_MODEM_3GPP_REGISTRATION_STATE_HOME; |
| 2091 | EXPECT_EQ(kHomeProvider, capability_->CreateFriendlyServiceName()); |
| 2092 | |
| 2093 | static const char kTestOperator[] = "A GSM Operator"; |
| 2094 | capability_->serving_operator_.SetName(kTestOperator); |
| 2095 | EXPECT_EQ(kTestOperator, capability_->CreateFriendlyServiceName()); |
| 2096 | |
| 2097 | capability_->registration_state_ = MM_MODEM_3GPP_REGISTRATION_STATE_ROAMING; |
| 2098 | EXPECT_EQ(StringPrintf("%s | %s", kHomeProvider, kTestOperator), |
| 2099 | capability_->CreateFriendlyServiceName()); |
| 2100 | } |
| 2101 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 2102 | TEST_F(CellularCapabilityUniversalMainTest, IsServiceActivationRequired) { |
Ben Chan | 1578603 | 2012-11-04 21:28:02 -0800 | [diff] [blame] | 2103 | capability_->mdn_ = "0000000000"; |
Ben Chan | 1578603 | 2012-11-04 21:28:02 -0800 | [diff] [blame] | 2104 | EXPECT_FALSE(capability_->IsServiceActivationRequired()); |
| 2105 | |
Arman Uguray | f4c6181 | 2013-01-10 18:58:39 -0800 | [diff] [blame] | 2106 | CellularService::OLP olp; |
Prathmesh Prabhu | 27526f1 | 2013-03-25 19:42:18 -0700 | [diff] [blame] | 2107 | EXPECT_CALL(*modem_info_.mock_cellular_operator_info(), GetOLPByMCCMNC(_)) |
Arman Uguray | f4c6181 | 2013-01-10 18:58:39 -0800 | [diff] [blame] | 2108 | .WillOnce(Return((const CellularService::OLP *)NULL)) |
| 2109 | .WillRepeatedly(Return(&olp)); |
Ben Chan | 1578603 | 2012-11-04 21:28:02 -0800 | [diff] [blame] | 2110 | EXPECT_FALSE(capability_->IsServiceActivationRequired()); |
| 2111 | |
| 2112 | capability_->mdn_ = ""; |
| 2113 | EXPECT_FALSE(capability_->IsServiceActivationRequired()); |
| 2114 | capability_->mdn_ = "1234567890"; |
| 2115 | EXPECT_FALSE(capability_->IsServiceActivationRequired()); |
Ben Chan | 1578603 | 2012-11-04 21:28:02 -0800 | [diff] [blame] | 2116 | capability_->mdn_ = "0000000000"; |
| 2117 | EXPECT_TRUE(capability_->IsServiceActivationRequired()); |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 2118 | |
| 2119 | const char kIccid[] = "1234567890"; |
| 2120 | capability_->sim_identifier_ = kIccid; |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 2121 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 2122 | GetActivationState(PendingActivationStore::kIdentifierICCID, |
| 2123 | kIccid)) |
| 2124 | .WillOnce(Return(PendingActivationStore::kStateActivated)) |
| 2125 | .WillOnce(Return(PendingActivationStore::kStatePending)) |
| 2126 | .WillOnce(Return(PendingActivationStore::kStatePendingTimeout)) |
| 2127 | .WillOnce(Return(PendingActivationStore::kStateUnknown)); |
Arman Uguray | efea6e0 | 2013-02-21 13:28:04 -0800 | [diff] [blame] | 2128 | EXPECT_FALSE(capability_->IsServiceActivationRequired()); |
Arman Uguray | a14941d | 2013-04-12 16:58:26 -0700 | [diff] [blame] | 2129 | EXPECT_FALSE(capability_->IsServiceActivationRequired()); |
| 2130 | EXPECT_FALSE(capability_->IsServiceActivationRequired()); |
| 2131 | EXPECT_TRUE(capability_->IsServiceActivationRequired()); |
Arman Uguray | 41cc634 | 2013-03-29 16:34:39 -0700 | [diff] [blame] | 2132 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
Ben Chan | 1578603 | 2012-11-04 21:28:02 -0800 | [diff] [blame] | 2133 | } |
| 2134 | |
Arman Uguray | 1361c03 | 2013-02-11 17:53:39 -0800 | [diff] [blame] | 2135 | TEST_F(CellularCapabilityUniversalMainTest, OnModemCurrentCapabilitiesChanged) { |
Ben Chan | fcca27b | 2013-01-22 15:03:44 -0800 | [diff] [blame] | 2136 | EXPECT_FALSE(capability_->scanning_supported_); |
| 2137 | capability_->OnModemCurrentCapabilitiesChanged(MM_MODEM_CAPABILITY_LTE); |
| 2138 | EXPECT_FALSE(capability_->scanning_supported_); |
| 2139 | capability_->OnModemCurrentCapabilitiesChanged(MM_MODEM_CAPABILITY_CDMA_EVDO); |
| 2140 | EXPECT_FALSE(capability_->scanning_supported_); |
| 2141 | capability_->OnModemCurrentCapabilitiesChanged(MM_MODEM_CAPABILITY_GSM_UMTS); |
| 2142 | EXPECT_TRUE(capability_->scanning_supported_); |
| 2143 | capability_->OnModemCurrentCapabilitiesChanged( |
| 2144 | MM_MODEM_CAPABILITY_GSM_UMTS | MM_MODEM_CAPABILITY_CDMA_EVDO); |
| 2145 | EXPECT_TRUE(capability_->scanning_supported_); |
| 2146 | } |
| 2147 | |
Arman Uguray | 7af0fac | 2013-03-18 17:35:35 -0700 | [diff] [blame] | 2148 | TEST_F(CellularCapabilityUniversalMainTest, GetNetworkTechnologyStringOnE362) { |
| 2149 | capability_->model_id_.clear(); |
| 2150 | capability_->access_technologies_ = 0; |
| 2151 | EXPECT_TRUE(capability_->GetNetworkTechnologyString().empty()); |
| 2152 | |
| 2153 | capability_->model_id_ = CellularCapabilityUniversal::kE362ModelId; |
| 2154 | EXPECT_EQ(flimflam::kNetworkTechnologyLte, |
| 2155 | capability_->GetNetworkTechnologyString()); |
| 2156 | |
| 2157 | capability_->access_technologies_ = MM_MODEM_ACCESS_TECHNOLOGY_GPRS; |
| 2158 | EXPECT_EQ(flimflam::kNetworkTechnologyLte, |
| 2159 | capability_->GetNetworkTechnologyString()); |
| 2160 | |
| 2161 | capability_->model_id_.clear(); |
| 2162 | EXPECT_EQ(flimflam::kNetworkTechnologyGprs, |
| 2163 | capability_->GetNetworkTechnologyString()); |
| 2164 | } |
| 2165 | |
Arman Uguray | f84a424 | 2013-04-09 20:01:07 -0700 | [diff] [blame] | 2166 | TEST_F(CellularCapabilityUniversalMainTest, ShouldDetectOutOfCredit) { |
Arman Uguray | d42d8ec | 2013-04-08 19:28:21 -0700 | [diff] [blame] | 2167 | capability_->model_id_.clear(); |
Arman Uguray | f84a424 | 2013-04-09 20:01:07 -0700 | [diff] [blame] | 2168 | EXPECT_FALSE(capability_->ShouldDetectOutOfCredit()); |
Arman Uguray | d42d8ec | 2013-04-08 19:28:21 -0700 | [diff] [blame] | 2169 | capability_->model_id_ = CellularCapabilityUniversal::kE362ModelId; |
Arman Uguray | f84a424 | 2013-04-09 20:01:07 -0700 | [diff] [blame] | 2170 | EXPECT_TRUE(capability_->ShouldDetectOutOfCredit()); |
Arman Uguray | d42d8ec | 2013-04-08 19:28:21 -0700 | [diff] [blame] | 2171 | } |
| 2172 | |
Arman Uguray | c7e63af | 2013-06-13 17:07:32 -0700 | [diff] [blame] | 2173 | TEST_F(CellularCapabilityUniversalMainTest, SimLockStatusToProperty) { |
| 2174 | Error error; |
| 2175 | KeyValueStore store = capability_->SimLockStatusToProperty(&error); |
| 2176 | EXPECT_FALSE(store.GetBool(flimflam::kSIMLockEnabledProperty)); |
| 2177 | EXPECT_TRUE(store.GetString(flimflam::kSIMLockTypeProperty).empty()); |
| 2178 | EXPECT_EQ(0, store.GetUint(flimflam::kSIMLockRetriesLeftProperty)); |
| 2179 | |
| 2180 | capability_->sim_lock_status_.enabled = true; |
| 2181 | capability_->sim_lock_status_.retries_left = 3; |
| 2182 | capability_->sim_lock_status_.lock_type = MM_MODEM_LOCK_SIM_PIN; |
| 2183 | store = capability_->SimLockStatusToProperty(&error); |
| 2184 | EXPECT_TRUE(store.GetBool(flimflam::kSIMLockEnabledProperty)); |
| 2185 | EXPECT_EQ("sim-pin", store.GetString(flimflam::kSIMLockTypeProperty)); |
| 2186 | EXPECT_EQ(3, store.GetUint(flimflam::kSIMLockRetriesLeftProperty)); |
| 2187 | |
| 2188 | capability_->sim_lock_status_.lock_type = MM_MODEM_LOCK_SIM_PUK; |
| 2189 | store = capability_->SimLockStatusToProperty(&error); |
| 2190 | EXPECT_EQ("sim-puk", store.GetString(flimflam::kSIMLockTypeProperty)); |
| 2191 | |
| 2192 | capability_->sim_lock_status_.lock_type = MM_MODEM_LOCK_SIM_PIN2; |
| 2193 | store = capability_->SimLockStatusToProperty(&error); |
| 2194 | EXPECT_TRUE(store.GetString(flimflam::kSIMLockTypeProperty).empty()); |
| 2195 | |
| 2196 | capability_->sim_lock_status_.lock_type = MM_MODEM_LOCK_SIM_PUK2; |
| 2197 | store = capability_->SimLockStatusToProperty(&error); |
| 2198 | EXPECT_TRUE(store.GetString(flimflam::kSIMLockTypeProperty).empty()); |
| 2199 | } |
| 2200 | |
| 2201 | TEST_F(CellularCapabilityUniversalMainTest, OnLockRetriesChanged) { |
| 2202 | CellularCapabilityUniversal::LockRetryData data; |
| 2203 | const uint32 kDefaultRetries = 999; |
| 2204 | |
| 2205 | capability_->OnLockRetriesChanged(data); |
| 2206 | EXPECT_EQ(kDefaultRetries, capability_->sim_lock_status_.retries_left); |
| 2207 | |
| 2208 | data[MM_MODEM_LOCK_SIM_PIN] = 3; |
Arman Uguray | ea5ff27 | 2013-06-25 10:28:02 -0700 | [diff] [blame] | 2209 | data[MM_MODEM_LOCK_SIM_PUK] = 10; |
Arman Uguray | c7e63af | 2013-06-13 17:07:32 -0700 | [diff] [blame] | 2210 | capability_->OnLockRetriesChanged(data); |
Arman Uguray | 192ad82 | 2013-06-13 19:49:16 -0700 | [diff] [blame] | 2211 | EXPECT_EQ(3, capability_->sim_lock_status_.retries_left); |
Arman Uguray | c7e63af | 2013-06-13 17:07:32 -0700 | [diff] [blame] | 2212 | |
Arman Uguray | ea5ff27 | 2013-06-25 10:28:02 -0700 | [diff] [blame] | 2213 | capability_->sim_lock_status_.lock_type = MM_MODEM_LOCK_SIM_PUK; |
Arman Uguray | c7e63af | 2013-06-13 17:07:32 -0700 | [diff] [blame] | 2214 | capability_->OnLockRetriesChanged(data); |
Arman Uguray | ea5ff27 | 2013-06-25 10:28:02 -0700 | [diff] [blame] | 2215 | EXPECT_EQ(10, capability_->sim_lock_status_.retries_left); |
Arman Uguray | c7e63af | 2013-06-13 17:07:32 -0700 | [diff] [blame] | 2216 | |
| 2217 | capability_->sim_lock_status_.lock_type = MM_MODEM_LOCK_SIM_PIN; |
| 2218 | capability_->OnLockRetriesChanged(data); |
| 2219 | EXPECT_EQ(3, capability_->sim_lock_status_.retries_left); |
Arman Uguray | 192ad82 | 2013-06-13 19:49:16 -0700 | [diff] [blame] | 2220 | |
| 2221 | data.clear(); |
| 2222 | capability_->OnLockRetriesChanged(data); |
| 2223 | EXPECT_EQ(kDefaultRetries, capability_->sim_lock_status_.retries_left); |
Arman Uguray | c7e63af | 2013-06-13 17:07:32 -0700 | [diff] [blame] | 2224 | } |
| 2225 | |
| 2226 | TEST_F(CellularCapabilityUniversalMainTest, OnLockTypeChanged) { |
| 2227 | EXPECT_EQ(MM_MODEM_LOCK_UNKNOWN, capability_->sim_lock_status_.lock_type); |
| 2228 | |
| 2229 | capability_->OnLockTypeChanged(MM_MODEM_LOCK_NONE); |
| 2230 | EXPECT_EQ(MM_MODEM_LOCK_NONE, capability_->sim_lock_status_.lock_type); |
Arman Uguray | 4ef02fd | 2013-06-13 20:14:20 -0700 | [diff] [blame] | 2231 | EXPECT_FALSE(capability_->sim_lock_status_.enabled); |
Arman Uguray | c7e63af | 2013-06-13 17:07:32 -0700 | [diff] [blame] | 2232 | |
| 2233 | capability_->OnLockTypeChanged(MM_MODEM_LOCK_SIM_PIN); |
| 2234 | EXPECT_EQ(MM_MODEM_LOCK_SIM_PIN, capability_->sim_lock_status_.lock_type); |
Arman Uguray | 4ef02fd | 2013-06-13 20:14:20 -0700 | [diff] [blame] | 2235 | EXPECT_TRUE(capability_->sim_lock_status_.enabled); |
Arman Uguray | c7e63af | 2013-06-13 17:07:32 -0700 | [diff] [blame] | 2236 | |
Arman Uguray | 4ef02fd | 2013-06-13 20:14:20 -0700 | [diff] [blame] | 2237 | capability_->sim_lock_status_.enabled = false; |
Arman Uguray | c7e63af | 2013-06-13 17:07:32 -0700 | [diff] [blame] | 2238 | capability_->OnLockTypeChanged(MM_MODEM_LOCK_SIM_PUK); |
| 2239 | EXPECT_EQ(MM_MODEM_LOCK_SIM_PUK, capability_->sim_lock_status_.lock_type); |
Arman Uguray | 4ef02fd | 2013-06-13 20:14:20 -0700 | [diff] [blame] | 2240 | EXPECT_TRUE(capability_->sim_lock_status_.enabled); |
Arman Uguray | c7e63af | 2013-06-13 17:07:32 -0700 | [diff] [blame] | 2241 | } |
| 2242 | |
| 2243 | TEST_F(CellularCapabilityUniversalMainTest, OnSimLockPropertiesChanged) { |
| 2244 | EXPECT_EQ(MM_MODEM_LOCK_UNKNOWN, capability_->sim_lock_status_.lock_type); |
| 2245 | EXPECT_EQ(0, capability_->sim_lock_status_.retries_left); |
| 2246 | |
| 2247 | DBusPropertiesMap changed; |
| 2248 | vector<string> invalidated; |
| 2249 | |
| 2250 | capability_->OnModemPropertiesChanged(changed, invalidated); |
| 2251 | EXPECT_EQ(MM_MODEM_LOCK_UNKNOWN, capability_->sim_lock_status_.lock_type); |
| 2252 | EXPECT_EQ(0, capability_->sim_lock_status_.retries_left); |
| 2253 | |
| 2254 | ::DBus::Variant variant; |
| 2255 | ::DBus::MessageIter writer = variant.writer(); |
| 2256 | |
| 2257 | // Unlock retries changed, but the SIM wasn't locked. |
| 2258 | CellularCapabilityUniversal::LockRetryData retry_data; |
| 2259 | retry_data[MM_MODEM_LOCK_SIM_PIN] = 3; |
| 2260 | writer << retry_data; |
| 2261 | changed[MM_MODEM_PROPERTY_UNLOCKRETRIES] = variant; |
| 2262 | |
| 2263 | capability_->OnModemPropertiesChanged(changed, invalidated); |
| 2264 | EXPECT_EQ(MM_MODEM_LOCK_UNKNOWN, capability_->sim_lock_status_.lock_type); |
Arman Uguray | 192ad82 | 2013-06-13 19:49:16 -0700 | [diff] [blame] | 2265 | EXPECT_EQ(3, capability_->sim_lock_status_.retries_left); |
Arman Uguray | c7e63af | 2013-06-13 17:07:32 -0700 | [diff] [blame] | 2266 | |
| 2267 | // Unlock retries changed and the SIM got locked. |
| 2268 | variant.clear(); |
| 2269 | writer = variant.writer(); |
| 2270 | writer << static_cast<uint32>(MM_MODEM_LOCK_SIM_PIN); |
| 2271 | changed[MM_MODEM_PROPERTY_UNLOCKREQUIRED] = variant; |
| 2272 | capability_->OnModemPropertiesChanged(changed, invalidated); |
| 2273 | EXPECT_EQ(MM_MODEM_LOCK_SIM_PIN, capability_->sim_lock_status_.lock_type); |
| 2274 | EXPECT_EQ(3, capability_->sim_lock_status_.retries_left); |
| 2275 | |
| 2276 | // Only unlock retries changed. |
| 2277 | changed.erase(MM_MODEM_PROPERTY_UNLOCKREQUIRED); |
| 2278 | retry_data[MM_MODEM_LOCK_SIM_PIN] = 2; |
| 2279 | variant.clear(); |
| 2280 | writer = variant.writer(); |
| 2281 | writer << retry_data; |
| 2282 | changed[MM_MODEM_PROPERTY_UNLOCKRETRIES] = variant; |
| 2283 | capability_->OnModemPropertiesChanged(changed, invalidated); |
| 2284 | EXPECT_EQ(MM_MODEM_LOCK_SIM_PIN, capability_->sim_lock_status_.lock_type); |
| 2285 | EXPECT_EQ(2, capability_->sim_lock_status_.retries_left); |
Arman Uguray | 192ad82 | 2013-06-13 19:49:16 -0700 | [diff] [blame] | 2286 | |
| 2287 | // Unlock retries changed with a value that doesn't match the current |
Arman Uguray | ea5ff27 | 2013-06-25 10:28:02 -0700 | [diff] [blame] | 2288 | // lock type. Default to whatever count is available. |
Arman Uguray | 192ad82 | 2013-06-13 19:49:16 -0700 | [diff] [blame] | 2289 | retry_data.clear(); |
| 2290 | retry_data[MM_MODEM_LOCK_SIM_PIN2] = 2; |
| 2291 | variant.clear(); |
| 2292 | writer = variant.writer(); |
| 2293 | writer << retry_data; |
| 2294 | changed[MM_MODEM_PROPERTY_UNLOCKRETRIES] = variant; |
| 2295 | capability_->OnModemPropertiesChanged(changed, invalidated); |
| 2296 | EXPECT_EQ(MM_MODEM_LOCK_SIM_PIN, capability_->sim_lock_status_.lock_type); |
Arman Uguray | ea5ff27 | 2013-06-25 10:28:02 -0700 | [diff] [blame] | 2297 | EXPECT_EQ(2, capability_->sim_lock_status_.retries_left); |
Arman Uguray | c7e63af | 2013-06-13 17:07:32 -0700 | [diff] [blame] | 2298 | } |
| 2299 | |
Jason Glasgow | ef96556 | 2012-04-10 16:12:35 -0400 | [diff] [blame] | 2300 | } // namespace shill |