Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 1 | // Copyright (c) 2013 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "shill/cellular_capability_universal_cdma.h" |
| 6 | |
| 7 | #include <string> |
| 8 | #include <vector> |
| 9 | |
Prathmesh Prabhu | 6e0a8ef | 2014-05-05 22:30:07 -0700 | [diff] [blame] | 10 | #include <base/strings/string_number_conversions.h> |
Ben Chan | a0ddf46 | 2014-02-06 11:32:42 -0800 | [diff] [blame] | 11 | #include <base/strings/string_util.h> |
| 12 | #include <base/strings/stringprintf.h> |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 13 | #include <gmock/gmock.h> |
| 14 | #include <gtest/gtest.h> |
| 15 | #include <ModemManager/ModemManager.h> |
| 16 | |
| 17 | #include "shill/cellular.h" |
| 18 | #include "shill/cellular_service.h" |
| 19 | #include "shill/event_dispatcher.h" |
| 20 | #include "shill/mock_adaptors.h" |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 21 | #include "shill/mock_cellular_service.h" |
| 22 | #include "shill/mock_dbus_properties_proxy.h" |
| 23 | #include "shill/mock_glib.h" |
| 24 | #include "shill/mock_manager.h" |
| 25 | #include "shill/mock_metrics.h" |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 26 | #include "shill/mock_mm1_modem_modem3gpp_proxy.h" |
| 27 | #include "shill/mock_mm1_modem_modemcdma_proxy.h" |
| 28 | #include "shill/mock_mm1_modem_proxy.h" |
| 29 | #include "shill/mock_mm1_modem_simple_proxy.h" |
| 30 | #include "shill/mock_mm1_sim_proxy.h" |
Prathmesh Prabhu | 92df619 | 2014-04-29 18:08:08 -0700 | [diff] [blame] | 31 | #include "shill/mock_mobile_operator_info.h" |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 32 | #include "shill/mock_modem_info.h" |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 33 | #include "shill/mock_pending_activation_store.h" |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 34 | #include "shill/nice_mock_control.h" |
| 35 | #include "shill/proxy_factory.h" |
| 36 | |
| 37 | using base::StringPrintf; |
Prathmesh Prabhu | 6e0a8ef | 2014-05-05 22:30:07 -0700 | [diff] [blame] | 38 | using base::UintToString; |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 39 | using std::string; |
| 40 | using std::vector; |
| 41 | using testing::Invoke; |
| 42 | using testing::Mock; |
| 43 | using testing::NiceMock; |
| 44 | using testing::Return; |
| 45 | using testing::SetArgumentPointee; |
| 46 | using testing::_; |
| 47 | |
| 48 | namespace shill { |
| 49 | |
| 50 | class CellularCapabilityUniversalCDMATest : public testing::Test { |
| 51 | public: |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 52 | explicit CellularCapabilityUniversalCDMATest(EventDispatcher *dispatcher) |
Prathmesh Prabhu | 6e0a8ef | 2014-05-05 22:30:07 -0700 | [diff] [blame] | 53 | : dispatcher_(dispatcher), |
| 54 | capability_(NULL), |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 55 | device_adaptor_(NULL), |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 56 | modem_info_(NULL, dispatcher, NULL, NULL, NULL), |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 57 | modem_3gpp_proxy_(new mm1::MockModemModem3gppProxy()), |
| 58 | modem_cdma_proxy_(new mm1::MockModemModemCdmaProxy()), |
| 59 | modem_proxy_(new mm1::MockModemProxy()), |
| 60 | modem_simple_proxy_(new mm1::MockModemSimpleProxy()), |
| 61 | sim_proxy_(new mm1::MockSimProxy()), |
| 62 | properties_proxy_(new MockDBusPropertiesProxy()), |
| 63 | proxy_factory_(this), |
| 64 | cellular_(new Cellular(&modem_info_, |
| 65 | "", |
| 66 | kMachineAddress, |
| 67 | 0, |
| 68 | Cellular::kTypeUniversalCDMA, |
| 69 | "", |
| 70 | "", |
| 71 | "", |
| 72 | &proxy_factory_)), |
| 73 | service_(new MockCellularService(&modem_info_, |
Prathmesh Prabhu | 6e0a8ef | 2014-05-05 22:30:07 -0700 | [diff] [blame] | 74 | cellular_)), |
| 75 | mock_home_provider_info_(NULL), |
| 76 | mock_serving_operator_info_(NULL) {} |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 77 | |
| 78 | virtual ~CellularCapabilityUniversalCDMATest() { |
| 79 | cellular_->service_ = NULL; |
| 80 | capability_ = NULL; |
| 81 | device_adaptor_ = NULL; |
| 82 | } |
| 83 | |
| 84 | virtual void SetUp() { |
| 85 | capability_ = dynamic_cast<CellularCapabilityUniversalCDMA *>( |
| 86 | cellular_->capability_.get()); |
| 87 | device_adaptor_ = |
| 88 | dynamic_cast<NiceMock<DeviceMockAdaptor> *>(cellular_->adaptor()); |
| 89 | cellular_->service_ = service_; |
| 90 | } |
| 91 | |
| 92 | virtual void TearDown() { |
| 93 | capability_->proxy_factory_ = NULL; |
| 94 | } |
| 95 | |
| 96 | void SetService() { |
| 97 | cellular_->service_ = new CellularService(&modem_info_, cellular_); |
| 98 | } |
| 99 | |
Arman Uguray | c539123 | 2013-09-23 21:30:46 -0700 | [diff] [blame] | 100 | void ClearService() { |
| 101 | cellular_->service_ = NULL; |
| 102 | } |
| 103 | |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 104 | void ReleaseCapabilityProxies() { |
| 105 | capability_->ReleaseProxies(); |
| 106 | } |
| 107 | |
| 108 | void SetCdmaProxy() { |
| 109 | capability_->modem_cdma_proxy_.reset(modem_cdma_proxy_.release()); |
| 110 | } |
| 111 | |
| 112 | void SetSimpleProxy() { |
| 113 | capability_->modem_simple_proxy_.reset(modem_simple_proxy_.release()); |
| 114 | } |
| 115 | |
Prathmesh Prabhu | 92df619 | 2014-04-29 18:08:08 -0700 | [diff] [blame] | 116 | void SetMockMobileOperatorInfoObjects() { |
Prathmesh Prabhu | 6e0a8ef | 2014-05-05 22:30:07 -0700 | [diff] [blame] | 117 | CHECK(!mock_home_provider_info_); |
| 118 | CHECK(!mock_serving_operator_info_); |
Miao-chen Chou | 70190b3 | 2014-05-14 18:24:30 -0700 | [diff] [blame] | 119 | mock_home_provider_info_ = |
| 120 | new MockMobileOperatorInfo(dispatcher_, "HomeProvider"); |
| 121 | mock_serving_operator_info_ = |
| 122 | new MockMobileOperatorInfo(dispatcher_, "ServingOperator"); |
Prathmesh Prabhu | 6e0a8ef | 2014-05-05 22:30:07 -0700 | [diff] [blame] | 123 | cellular_->set_home_provider_info(mock_home_provider_info_); |
| 124 | cellular_->set_serving_operator_info(mock_serving_operator_info_); |
Prathmesh Prabhu | 92df619 | 2014-04-29 18:08:08 -0700 | [diff] [blame] | 125 | } |
| 126 | |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 127 | protected: |
| 128 | static const char kEsn[]; |
| 129 | static const char kMachineAddress[]; |
| 130 | static const char kMeid[]; |
| 131 | |
| 132 | class TestProxyFactory : public ProxyFactory { |
| 133 | public: |
| 134 | explicit TestProxyFactory(CellularCapabilityUniversalCDMATest *test) : |
| 135 | test_(test) {} |
| 136 | |
| 137 | // TODO(armansito): Some of these methods won't be necessary after 3GPP |
| 138 | // gets refactored out of CellularCapabilityUniversal. |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 139 | virtual mm1::ModemModem3gppProxyInterface *CreateMM1ModemModem3gppProxy( |
| 140 | const std::string &/*path*/, |
| 141 | const std::string &/*service*/) { |
| 142 | return test_->modem_3gpp_proxy_.release(); |
| 143 | } |
| 144 | |
| 145 | virtual mm1::ModemModemCdmaProxyInterface *CreateMM1ModemModemCdmaProxy( |
| 146 | const std::string &/*path*/, |
| 147 | const std::string &/*service*/) { |
| 148 | return test_->modem_cdma_proxy_.release(); |
| 149 | } |
| 150 | |
| 151 | virtual mm1::ModemProxyInterface *CreateMM1ModemProxy( |
| 152 | const std::string &/*path*/, |
| 153 | const std::string &/*service*/) { |
| 154 | return test_->modem_proxy_.release(); |
| 155 | } |
| 156 | |
| 157 | virtual mm1::ModemSimpleProxyInterface *CreateMM1ModemSimpleProxy( |
| 158 | const std::string &/*path*/, |
| 159 | const std::string &/*service*/) { |
| 160 | return test_->modem_simple_proxy_.release(); |
| 161 | } |
| 162 | |
| 163 | virtual mm1::SimProxyInterface *CreateSimProxy( |
| 164 | const std::string &/*path*/, |
| 165 | const std::string &/*service*/) { |
| 166 | return test_->sim_proxy_.release(); |
| 167 | } |
| 168 | |
| 169 | virtual DBusPropertiesProxyInterface *CreateDBusPropertiesProxy( |
| 170 | const std::string &/*path*/, |
| 171 | const std::string &/*service*/) { |
| 172 | return test_->properties_proxy_.release(); |
| 173 | } |
| 174 | |
| 175 | private: |
| 176 | CellularCapabilityUniversalCDMATest *test_; |
| 177 | }; |
| 178 | |
Prathmesh Prabhu | 6e0a8ef | 2014-05-05 22:30:07 -0700 | [diff] [blame] | 179 | EventDispatcher *dispatcher_; |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 180 | CellularCapabilityUniversalCDMA *capability_; |
| 181 | NiceMock<DeviceMockAdaptor> *device_adaptor_; |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 182 | MockModemInfo modem_info_; |
| 183 | MockGLib glib_; |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 184 | // TODO(armansito): Remove |modem_3gpp_proxy_| after refactor. |
| 185 | scoped_ptr<mm1::MockModemModem3gppProxy> modem_3gpp_proxy_; |
| 186 | scoped_ptr<mm1::MockModemModemCdmaProxy> modem_cdma_proxy_; |
| 187 | scoped_ptr<mm1::MockModemProxy> modem_proxy_; |
| 188 | scoped_ptr<mm1::MockModemSimpleProxy> modem_simple_proxy_; |
| 189 | scoped_ptr<mm1::MockSimProxy> sim_proxy_; |
| 190 | scoped_ptr<MockDBusPropertiesProxy> properties_proxy_; |
| 191 | TestProxyFactory proxy_factory_; |
| 192 | CellularRefPtr cellular_; |
| 193 | MockCellularService *service_; |
Prathmesh Prabhu | 6e0a8ef | 2014-05-05 22:30:07 -0700 | [diff] [blame] | 194 | |
| 195 | // Set when required and passed to |cellular_|. Owned by |cellular_|. |
| 196 | MockMobileOperatorInfo *mock_home_provider_info_; |
| 197 | MockMobileOperatorInfo *mock_serving_operator_info_; |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 198 | }; |
| 199 | |
| 200 | // static |
| 201 | const char CellularCapabilityUniversalCDMATest::kEsn[] = "0000"; |
| 202 | // static |
| 203 | const char CellularCapabilityUniversalCDMATest::kMachineAddress[] = |
| 204 | "TestMachineAddress"; |
| 205 | // static |
| 206 | const char CellularCapabilityUniversalCDMATest::kMeid[] = "11111111111111"; |
| 207 | |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 208 | class CellularCapabilityUniversalCDMAMainTest |
| 209 | : public CellularCapabilityUniversalCDMATest { |
| 210 | public: |
| 211 | CellularCapabilityUniversalCDMAMainTest() |
| 212 | : CellularCapabilityUniversalCDMATest(&dispatcher_) {} |
| 213 | |
| 214 | private: |
| 215 | EventDispatcher dispatcher_; |
| 216 | }; |
| 217 | |
| 218 | class CellularCapabilityUniversalCDMADispatcherTest |
| 219 | : public CellularCapabilityUniversalCDMATest { |
| 220 | public: |
| 221 | CellularCapabilityUniversalCDMADispatcherTest() |
| 222 | : CellularCapabilityUniversalCDMATest(NULL) {} |
| 223 | }; |
| 224 | |
| 225 | TEST_F(CellularCapabilityUniversalCDMAMainTest, PropertiesChanged) { |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 226 | // Set up mock modem CDMA properties. |
| 227 | DBusPropertiesMap modem_cdma_properties; |
| 228 | modem_cdma_properties[MM_MODEM_MODEMCDMA_PROPERTY_MEID]. |
| 229 | writer().append_string(kMeid); |
| 230 | modem_cdma_properties[MM_MODEM_MODEMCDMA_PROPERTY_ESN]. |
| 231 | writer().append_string(kEsn); |
| 232 | |
| 233 | SetUp(); |
| 234 | |
Prathmesh Prabhu | 9f06c87 | 2013-11-21 14:08:23 -0800 | [diff] [blame] | 235 | EXPECT_TRUE(cellular_->meid().empty()); |
| 236 | EXPECT_TRUE(cellular_->esn().empty()); |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 237 | |
| 238 | // Changing properties on wrong interface will not have an effect |
| 239 | capability_->OnDBusPropertiesChanged(MM_DBUS_INTERFACE_MODEM, |
| 240 | modem_cdma_properties, |
| 241 | vector<string>()); |
Prathmesh Prabhu | 9f06c87 | 2013-11-21 14:08:23 -0800 | [diff] [blame] | 242 | EXPECT_TRUE(cellular_->meid().empty()); |
| 243 | EXPECT_TRUE(cellular_->esn().empty()); |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 244 | |
| 245 | // Changing properties on the right interface gets reflected in the |
| 246 | // capabilities object |
| 247 | capability_->OnDBusPropertiesChanged(MM_DBUS_INTERFACE_MODEM_MODEMCDMA, |
| 248 | modem_cdma_properties, |
| 249 | vector<string>()); |
Prathmesh Prabhu | 9f06c87 | 2013-11-21 14:08:23 -0800 | [diff] [blame] | 250 | EXPECT_EQ(kMeid, cellular_->meid()); |
| 251 | EXPECT_EQ(kEsn, cellular_->esn()); |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 252 | } |
| 253 | |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 254 | TEST_F(CellularCapabilityUniversalCDMAMainTest, OnCDMARegistrationChanged) { |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 255 | EXPECT_EQ(0, capability_->sid_); |
| 256 | EXPECT_EQ(0, capability_->nid_); |
| 257 | EXPECT_EQ(MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN, |
| 258 | capability_->cdma_1x_registration_state_); |
| 259 | EXPECT_EQ(MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN, |
| 260 | capability_->cdma_evdo_registration_state_); |
| 261 | |
Prathmesh Prabhu | 6e0a8ef | 2014-05-05 22:30:07 -0700 | [diff] [blame] | 262 | const unsigned kSid = 2; |
| 263 | const unsigned kNid = 1; |
| 264 | SetMockMobileOperatorInfoObjects(); |
| 265 | EXPECT_CALL(*mock_serving_operator_info_, UpdateSID(UintToString(kSid))); |
| 266 | EXPECT_CALL(*mock_serving_operator_info_, UpdateNID(UintToString(kNid))); |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 267 | capability_->OnCDMARegistrationChanged( |
| 268 | MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN, |
| 269 | MM_MODEM_CDMA_REGISTRATION_STATE_HOME, |
Prathmesh Prabhu | 6e0a8ef | 2014-05-05 22:30:07 -0700 | [diff] [blame] | 270 | kSid, |
| 271 | kNid); |
| 272 | EXPECT_EQ(kSid, capability_->sid_); |
| 273 | EXPECT_EQ(kNid, capability_->nid_); |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 274 | EXPECT_EQ(MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN, |
| 275 | capability_->cdma_1x_registration_state_); |
| 276 | EXPECT_EQ(MM_MODEM_CDMA_REGISTRATION_STATE_HOME, |
| 277 | capability_->cdma_evdo_registration_state_); |
| 278 | |
| 279 | EXPECT_TRUE(capability_->IsRegistered()); |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 280 | } |
| 281 | |
Prathmesh Prabhu | 92df619 | 2014-04-29 18:08:08 -0700 | [diff] [blame] | 282 | TEST_F(CellularCapabilityUniversalCDMAMainTest, UpdateServiceOLP) { |
| 283 | const MobileOperatorInfo::OnlinePortal kOlp { |
| 284 | "http://testurl", |
| 285 | "POST", |
| 286 | "esn=${esn}&mdn=${mdn}&meid=${meid}"}; |
| 287 | const vector<MobileOperatorInfo::OnlinePortal> kOlpList {kOlp}; |
Prathmesh Prabhu | 5089a6e | 2014-05-07 20:49:16 -0700 | [diff] [blame] | 288 | const string kUuidVzw = "c83d6597-dc91-4d48-a3a7-d86b80123751"; |
Prathmesh Prabhu | 92df619 | 2014-04-29 18:08:08 -0700 | [diff] [blame] | 289 | const string kUuidFoo = "foo"; |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 290 | |
Prathmesh Prabhu | 92df619 | 2014-04-29 18:08:08 -0700 | [diff] [blame] | 291 | SetMockMobileOperatorInfoObjects(); |
Prathmesh Prabhu | 9f06c87 | 2013-11-21 14:08:23 -0800 | [diff] [blame] | 292 | cellular_->set_esn("0"); |
| 293 | cellular_->set_mdn("10123456789"); |
| 294 | cellular_->set_meid("4"); |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 295 | |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 296 | |
Prathmesh Prabhu | 6e0a8ef | 2014-05-05 22:30:07 -0700 | [diff] [blame] | 297 | mock_serving_operator_info_->SetEmptyDefaultsForProperties(); |
| 298 | EXPECT_CALL(*mock_serving_operator_info_, IsMobileNetworkOperatorKnown()) |
Prathmesh Prabhu | 92df619 | 2014-04-29 18:08:08 -0700 | [diff] [blame] | 299 | .WillRepeatedly(Return(true)); |
Prathmesh Prabhu | 6e0a8ef | 2014-05-05 22:30:07 -0700 | [diff] [blame] | 300 | EXPECT_CALL(*mock_serving_operator_info_, olp_list()) |
Prathmesh Prabhu | 92df619 | 2014-04-29 18:08:08 -0700 | [diff] [blame] | 301 | .WillRepeatedly(ReturnRef(kOlpList)); |
Prathmesh Prabhu | 6e0a8ef | 2014-05-05 22:30:07 -0700 | [diff] [blame] | 302 | EXPECT_CALL(*mock_serving_operator_info_, uuid()) |
Prathmesh Prabhu | 92df619 | 2014-04-29 18:08:08 -0700 | [diff] [blame] | 303 | .WillOnce(ReturnRef(kUuidVzw)); |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 304 | SetService(); |
Prathmesh Prabhu | 92df619 | 2014-04-29 18:08:08 -0700 | [diff] [blame] | 305 | capability_->UpdateServiceOLP(); |
| 306 | // Copy to simplify assertions below. |
| 307 | Stringmap vzw_olp = cellular_->service()->olp(); |
| 308 | EXPECT_EQ("http://testurl", vzw_olp[kPaymentPortalURL]); |
| 309 | EXPECT_EQ("POST", vzw_olp[kPaymentPortalMethod]); |
| 310 | EXPECT_EQ("esn=0&mdn=0123456789&meid=4", |
| 311 | vzw_olp[kPaymentPortalPostData]); |
Prathmesh Prabhu | 6e0a8ef | 2014-05-05 22:30:07 -0700 | [diff] [blame] | 312 | Mock::VerifyAndClearExpectations(mock_serving_operator_info_); |
Ben Chan | 07193fd | 2013-07-12 22:10:55 -0700 | [diff] [blame] | 313 | |
Prathmesh Prabhu | 6e0a8ef | 2014-05-05 22:30:07 -0700 | [diff] [blame] | 314 | mock_serving_operator_info_->SetEmptyDefaultsForProperties(); |
| 315 | EXPECT_CALL(*mock_serving_operator_info_, IsMobileNetworkOperatorKnown()) |
Prathmesh Prabhu | 92df619 | 2014-04-29 18:08:08 -0700 | [diff] [blame] | 316 | .WillRepeatedly(Return(true)); |
Prathmesh Prabhu | 6e0a8ef | 2014-05-05 22:30:07 -0700 | [diff] [blame] | 317 | EXPECT_CALL(*mock_serving_operator_info_, olp_list()) |
Prathmesh Prabhu | 92df619 | 2014-04-29 18:08:08 -0700 | [diff] [blame] | 318 | .WillRepeatedly(ReturnRef(kOlpList)); |
Prathmesh Prabhu | 6e0a8ef | 2014-05-05 22:30:07 -0700 | [diff] [blame] | 319 | EXPECT_CALL(*mock_serving_operator_info_, uuid()) |
Prathmesh Prabhu | 92df619 | 2014-04-29 18:08:08 -0700 | [diff] [blame] | 320 | .WillOnce(ReturnRef(kUuidFoo)); |
| 321 | capability_->UpdateServiceOLP(); |
| 322 | // Copy to simplify assertions below. |
| 323 | Stringmap olp = cellular_->service()->olp(); |
| 324 | EXPECT_EQ("http://testurl", olp[kPaymentPortalURL]); |
| 325 | EXPECT_EQ("POST", olp[kPaymentPortalMethod]); |
| 326 | EXPECT_EQ("esn=0&mdn=10123456789&meid=4", |
| 327 | olp[kPaymentPortalPostData]); |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 328 | } |
| 329 | |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 330 | TEST_F(CellularCapabilityUniversalCDMAMainTest, ActivateAutomatic) { |
Prathmesh Prabhu | f228821 | 2014-05-21 19:19:19 -0700 | [diff] [blame] | 331 | const string activation_code {"1234"}; |
| 332 | SetMockMobileOperatorInfoObjects(); |
| 333 | |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 334 | mm1::MockModemModemCdmaProxy *cdma_proxy = modem_cdma_proxy_.get(); |
| 335 | SetUp(); |
| 336 | capability_->InitProxies(); |
| 337 | |
Prathmesh Prabhu | f228821 | 2014-05-21 19:19:19 -0700 | [diff] [blame] | 338 | // Cases when activation fails because |activation_code| is not available. |
| 339 | EXPECT_CALL(*mock_serving_operator_info_, IsMobileNetworkOperatorKnown()) |
| 340 | .WillRepeatedly(Return(false)); |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 341 | EXPECT_CALL(*cdma_proxy, Activate(_, _, _, _)).Times(0); |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 342 | capability_->ActivateAutomatic(); |
Prathmesh Prabhu | f228821 | 2014-05-21 19:19:19 -0700 | [diff] [blame] | 343 | Mock::VerifyAndClearExpectations(mock_serving_operator_info_); |
| 344 | Mock::VerifyAndClearExpectations(modem_cdma_proxy_.get()); |
| 345 | EXPECT_CALL(*mock_serving_operator_info_, IsMobileNetworkOperatorKnown()) |
| 346 | .WillRepeatedly(Return(true)); |
| 347 | mock_serving_operator_info_->SetEmptyDefaultsForProperties(); |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 348 | EXPECT_CALL(*cdma_proxy, Activate(_, _, _, _)).Times(0); |
Prathmesh Prabhu | f228821 | 2014-05-21 19:19:19 -0700 | [diff] [blame] | 349 | capability_->ActivateAutomatic(); |
| 350 | Mock::VerifyAndClearExpectations(mock_serving_operator_info_); |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 351 | Mock::VerifyAndClearExpectations(modem_cdma_proxy_.get()); |
| 352 | |
Prathmesh Prabhu | f228821 | 2014-05-21 19:19:19 -0700 | [diff] [blame] | 353 | // These expectations hold for all subsequent tests. |
| 354 | EXPECT_CALL(*mock_serving_operator_info_, IsMobileNetworkOperatorKnown()) |
| 355 | .WillRepeatedly(Return(true)); |
| 356 | EXPECT_CALL(*mock_serving_operator_info_, activation_code()) |
| 357 | .WillRepeatedly(ReturnRef(activation_code)); |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 358 | |
| 359 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 360 | GetActivationState(PendingActivationStore::kIdentifierMEID, _)) |
| 361 | .WillOnce(Return(PendingActivationStore::kStatePending)) |
| 362 | .WillOnce(Return(PendingActivationStore::kStateActivated)); |
| 363 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 364 | SetActivationState(_, _, _)) |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 365 | .Times(0); |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 366 | EXPECT_CALL(*cdma_proxy, Activate(_, _, _, _)).Times(0); |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 367 | capability_->ActivateAutomatic(); |
| 368 | capability_->ActivateAutomatic(); |
| 369 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
| 370 | Mock::VerifyAndClearExpectations(modem_cdma_proxy_.get()); |
| 371 | |
| 372 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
| 373 | GetActivationState(PendingActivationStore::kIdentifierMEID, _)) |
| 374 | .WillOnce(Return(PendingActivationStore::kStateUnknown)) |
| 375 | .WillOnce(Return(PendingActivationStore::kStateFailureRetry)); |
| 376 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 377 | SetActivationState(_, _, PendingActivationStore::kStatePending)) |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 378 | .Times(2); |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 379 | EXPECT_CALL(*cdma_proxy, Activate(_, _, _, _)).Times(2); |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 380 | capability_->ActivateAutomatic(); |
| 381 | capability_->ActivateAutomatic(); |
| 382 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
| 383 | Mock::VerifyAndClearExpectations(modem_cdma_proxy_.get()); |
| 384 | } |
| 385 | |
| 386 | TEST_F(CellularCapabilityUniversalCDMAMainTest, IsServiceActivationRequired) { |
Prathmesh Prabhu | 3ee2f41 | 2014-05-20 17:30:19 -0700 | [diff] [blame] | 387 | const vector<MobileOperatorInfo::OnlinePortal> empty_list; |
| 388 | const vector<MobileOperatorInfo::OnlinePortal> olp_list { |
| 389 | {"some@url", "some_method", "some_post_data"} |
| 390 | }; |
| 391 | SetMockMobileOperatorInfoObjects(); |
| 392 | |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 393 | capability_->activation_state_ = |
| 394 | MM_MODEM_CDMA_ACTIVATION_STATE_NOT_ACTIVATED; |
Prathmesh Prabhu | 3ee2f41 | 2014-05-20 17:30:19 -0700 | [diff] [blame] | 395 | EXPECT_CALL(*mock_serving_operator_info_, IsMobileNetworkOperatorKnown()) |
| 396 | .WillRepeatedly(Return(false)); |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 397 | EXPECT_FALSE(capability_->IsServiceActivationRequired()); |
Prathmesh Prabhu | 3ee2f41 | 2014-05-20 17:30:19 -0700 | [diff] [blame] | 398 | Mock::VerifyAndClearExpectations(mock_serving_operator_info_); |
| 399 | |
| 400 | capability_->activation_state_ = |
| 401 | MM_MODEM_CDMA_ACTIVATION_STATE_NOT_ACTIVATED; |
| 402 | EXPECT_CALL(*mock_serving_operator_info_, IsMobileNetworkOperatorKnown()) |
| 403 | .WillRepeatedly(Return(true)); |
| 404 | EXPECT_CALL(*mock_serving_operator_info_, olp_list()) |
| 405 | .WillRepeatedly(ReturnRef(empty_list)); |
| 406 | EXPECT_FALSE(capability_->IsServiceActivationRequired()); |
| 407 | Mock::VerifyAndClearExpectations(mock_serving_operator_info_); |
| 408 | |
| 409 | // These expectations hold for all subsequent tests. |
| 410 | EXPECT_CALL(*mock_serving_operator_info_, IsMobileNetworkOperatorKnown()) |
| 411 | .WillRepeatedly(Return(true)); |
| 412 | EXPECT_CALL(*mock_serving_operator_info_, olp_list()) |
| 413 | .WillRepeatedly(ReturnRef(olp_list)); |
| 414 | |
| 415 | capability_->activation_state_ = |
| 416 | MM_MODEM_CDMA_ACTIVATION_STATE_NOT_ACTIVATED; |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 417 | EXPECT_TRUE(capability_->IsServiceActivationRequired()); |
| 418 | capability_->activation_state_ = |
| 419 | MM_MODEM_CDMA_ACTIVATION_STATE_ACTIVATING; |
| 420 | EXPECT_FALSE(capability_->IsServiceActivationRequired()); |
| 421 | capability_->activation_state_ = |
| 422 | MM_MODEM_CDMA_ACTIVATION_STATE_ACTIVATED; |
| 423 | EXPECT_FALSE(capability_->IsServiceActivationRequired()); |
| 424 | } |
| 425 | |
| 426 | TEST_F(CellularCapabilityUniversalCDMAMainTest, |
| 427 | UpdateServiceActivationStateProperty) { |
Prathmesh Prabhu | 3ee2f41 | 2014-05-20 17:30:19 -0700 | [diff] [blame] | 428 | const vector<MobileOperatorInfo::OnlinePortal> olp_list { |
| 429 | {"some@url", "some_method", "some_post_data"} |
| 430 | }; |
| 431 | SetMockMobileOperatorInfoObjects(); |
| 432 | EXPECT_CALL(*mock_serving_operator_info_, IsMobileNetworkOperatorKnown()) |
| 433 | .WillRepeatedly(Return(true)); |
| 434 | EXPECT_CALL(*mock_serving_operator_info_, olp_list()) |
| 435 | .WillRepeatedly(ReturnRef(olp_list)); |
| 436 | |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 437 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
Ben Chan | 7ea768e | 2013-09-20 15:08:40 -0700 | [diff] [blame] | 438 | GetActivationState(_, _)) |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 439 | .WillOnce(Return(PendingActivationStore::kStatePending)) |
| 440 | .WillRepeatedly(Return(PendingActivationStore::kStateUnknown)); |
| 441 | |
Ben Chan | 7ea768e | 2013-09-20 15:08:40 -0700 | [diff] [blame] | 442 | capability_->activation_state_ = MM_MODEM_CDMA_ACTIVATION_STATE_NOT_ACTIVATED; |
| 443 | EXPECT_CALL(*service_, SetActivationState(kActivationStateActivating)) |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 444 | .Times(1); |
| 445 | capability_->UpdateServiceActivationStateProperty(); |
| 446 | Mock::VerifyAndClearExpectations(service_); |
| 447 | |
Ben Chan | 7ea768e | 2013-09-20 15:08:40 -0700 | [diff] [blame] | 448 | EXPECT_CALL(*service_, SetActivationState(kActivationStateNotActivated)) |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 449 | .Times(1); |
| 450 | capability_->UpdateServiceActivationStateProperty(); |
| 451 | Mock::VerifyAndClearExpectations(service_); |
| 452 | |
Ben Chan | 7ea768e | 2013-09-20 15:08:40 -0700 | [diff] [blame] | 453 | capability_->activation_state_ = MM_MODEM_CDMA_ACTIVATION_STATE_ACTIVATING; |
| 454 | EXPECT_CALL(*service_, SetActivationState(kActivationStateActivating)) |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 455 | .Times(1); |
| 456 | capability_->UpdateServiceActivationStateProperty(); |
| 457 | Mock::VerifyAndClearExpectations(service_); |
| 458 | |
Ben Chan | 7ea768e | 2013-09-20 15:08:40 -0700 | [diff] [blame] | 459 | capability_->activation_state_ = MM_MODEM_CDMA_ACTIVATION_STATE_ACTIVATED; |
| 460 | EXPECT_CALL(*service_, SetActivationState(kActivationStateActivated)) |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 461 | .Times(1); |
| 462 | capability_->UpdateServiceActivationStateProperty(); |
| 463 | Mock::VerifyAndClearExpectations(service_); |
Ben Chan | 7ea768e | 2013-09-20 15:08:40 -0700 | [diff] [blame] | 464 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 465 | } |
| 466 | |
| 467 | TEST_F(CellularCapabilityUniversalCDMAMainTest, IsActivating) { |
| 468 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 469 | GetActivationState(_, _)) |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 470 | .WillOnce(Return(PendingActivationStore::kStatePending)) |
| 471 | .WillOnce(Return(PendingActivationStore::kStatePending)) |
| 472 | .WillOnce(Return(PendingActivationStore::kStateFailureRetry)) |
| 473 | .WillRepeatedly(Return(PendingActivationStore::kStateUnknown)); |
| 474 | |
| 475 | capability_->activation_state_ = |
| 476 | MM_MODEM_CDMA_ACTIVATION_STATE_NOT_ACTIVATED; |
| 477 | EXPECT_TRUE(capability_->IsActivating()); |
| 478 | EXPECT_TRUE(capability_->IsActivating()); |
| 479 | capability_->activation_state_ = MM_MODEM_CDMA_ACTIVATION_STATE_ACTIVATING; |
| 480 | EXPECT_TRUE(capability_->IsActivating()); |
| 481 | EXPECT_TRUE(capability_->IsActivating()); |
| 482 | capability_->activation_state_ = |
| 483 | MM_MODEM_CDMA_ACTIVATION_STATE_NOT_ACTIVATED; |
| 484 | EXPECT_FALSE(capability_->IsActivating()); |
| 485 | } |
| 486 | |
Ben Chan | b2c4a80 | 2013-11-14 12:47:52 -0800 | [diff] [blame] | 487 | TEST_F(CellularCapabilityUniversalCDMAMainTest, IsRegistered) { |
| 488 | capability_->cdma_1x_registration_state_ = |
| 489 | MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN; |
| 490 | capability_->cdma_evdo_registration_state_ = |
| 491 | MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN; |
| 492 | EXPECT_FALSE(capability_->IsRegistered()); |
| 493 | |
| 494 | capability_->cdma_evdo_registration_state_ = |
| 495 | MM_MODEM_CDMA_REGISTRATION_STATE_REGISTERED; |
| 496 | EXPECT_TRUE(capability_->IsRegistered()); |
| 497 | |
| 498 | capability_->cdma_evdo_registration_state_ = |
| 499 | MM_MODEM_CDMA_REGISTRATION_STATE_HOME; |
| 500 | EXPECT_TRUE(capability_->IsRegistered()); |
| 501 | |
| 502 | capability_->cdma_evdo_registration_state_ = |
| 503 | MM_MODEM_CDMA_REGISTRATION_STATE_ROAMING; |
| 504 | EXPECT_TRUE(capability_->IsRegistered()); |
| 505 | |
| 506 | capability_->cdma_1x_registration_state_ = |
| 507 | MM_MODEM_CDMA_REGISTRATION_STATE_REGISTERED; |
| 508 | capability_->cdma_evdo_registration_state_ = |
| 509 | MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN; |
| 510 | EXPECT_TRUE(capability_->IsRegistered()); |
| 511 | |
| 512 | capability_->cdma_evdo_registration_state_ = |
| 513 | MM_MODEM_CDMA_REGISTRATION_STATE_REGISTERED; |
| 514 | EXPECT_TRUE(capability_->IsRegistered()); |
| 515 | |
| 516 | capability_->cdma_evdo_registration_state_ = |
| 517 | MM_MODEM_CDMA_REGISTRATION_STATE_HOME; |
| 518 | EXPECT_TRUE(capability_->IsRegistered()); |
| 519 | |
| 520 | capability_->cdma_evdo_registration_state_ = |
| 521 | MM_MODEM_CDMA_REGISTRATION_STATE_ROAMING; |
| 522 | EXPECT_TRUE(capability_->IsRegistered()); |
| 523 | |
| 524 | capability_->cdma_1x_registration_state_ = |
| 525 | MM_MODEM_CDMA_REGISTRATION_STATE_HOME; |
| 526 | capability_->cdma_evdo_registration_state_ = |
| 527 | MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN; |
| 528 | EXPECT_TRUE(capability_->IsRegistered()); |
| 529 | |
| 530 | capability_->cdma_evdo_registration_state_ = |
| 531 | MM_MODEM_CDMA_REGISTRATION_STATE_REGISTERED; |
| 532 | EXPECT_TRUE(capability_->IsRegistered()); |
| 533 | |
| 534 | capability_->cdma_evdo_registration_state_ = |
| 535 | MM_MODEM_CDMA_REGISTRATION_STATE_HOME; |
| 536 | EXPECT_TRUE(capability_->IsRegistered()); |
| 537 | |
| 538 | capability_->cdma_evdo_registration_state_ = |
| 539 | MM_MODEM_CDMA_REGISTRATION_STATE_ROAMING; |
| 540 | EXPECT_TRUE(capability_->IsRegistered()); |
| 541 | |
| 542 | capability_->cdma_1x_registration_state_ = |
| 543 | MM_MODEM_CDMA_REGISTRATION_STATE_ROAMING; |
| 544 | capability_->cdma_evdo_registration_state_ = |
| 545 | MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN; |
| 546 | EXPECT_TRUE(capability_->IsRegistered()); |
| 547 | |
| 548 | capability_->cdma_evdo_registration_state_ = |
| 549 | MM_MODEM_CDMA_REGISTRATION_STATE_REGISTERED; |
| 550 | EXPECT_TRUE(capability_->IsRegistered()); |
| 551 | |
| 552 | capability_->cdma_evdo_registration_state_ = |
| 553 | MM_MODEM_CDMA_REGISTRATION_STATE_HOME; |
| 554 | EXPECT_TRUE(capability_->IsRegistered()); |
| 555 | |
| 556 | capability_->cdma_evdo_registration_state_ = |
| 557 | MM_MODEM_CDMA_REGISTRATION_STATE_ROAMING; |
| 558 | EXPECT_TRUE(capability_->IsRegistered()); |
| 559 | } |
| 560 | |
Arman Uguray | c967306 | 2013-05-13 21:21:53 -0700 | [diff] [blame] | 561 | TEST_F(CellularCapabilityUniversalCDMAMainTest, SetupConnectProperties) { |
| 562 | DBusPropertiesMap map; |
| 563 | capability_->SetupConnectProperties(&map); |
| 564 | EXPECT_EQ(1, map.size()); |
| 565 | EXPECT_STREQ("#777", map["number"].reader().get_string()); |
| 566 | } |
| 567 | |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 568 | TEST_F(CellularCapabilityUniversalCDMADispatcherTest, |
| 569 | UpdatePendingActivationState) { |
| 570 | capability_->activation_state_ = MM_MODEM_CDMA_ACTIVATION_STATE_ACTIVATED; |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 571 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), RemoveEntry(_, _)) |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 572 | .Times(1); |
| 573 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 574 | GetActivationState(_, _)) |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 575 | .Times(0); |
| 576 | EXPECT_CALL(*modem_info_.mock_dispatcher(), PostTask(_)).Times(0); |
| 577 | capability_->UpdatePendingActivationState(); |
| 578 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
| 579 | Mock::VerifyAndClearExpectations(modem_info_.mock_dispatcher()); |
| 580 | |
| 581 | capability_->activation_state_ = MM_MODEM_CDMA_ACTIVATION_STATE_ACTIVATING; |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 582 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), RemoveEntry(_, _)) |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 583 | .Times(0); |
| 584 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 585 | GetActivationState(_, _)) |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 586 | .Times(2) |
| 587 | .WillRepeatedly(Return(PendingActivationStore::kStateUnknown)); |
| 588 | EXPECT_CALL(*modem_info_.mock_dispatcher(), PostTask(_)).Times(0); |
| 589 | capability_->UpdatePendingActivationState(); |
| 590 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
| 591 | Mock::VerifyAndClearExpectations(modem_info_.mock_dispatcher()); |
| 592 | |
| 593 | capability_->activation_state_ = MM_MODEM_CDMA_ACTIVATION_STATE_NOT_ACTIVATED; |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 594 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), RemoveEntry(_, _)) |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 595 | .Times(0); |
| 596 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 597 | GetActivationState(_, _)) |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 598 | .Times(2) |
| 599 | .WillRepeatedly(Return(PendingActivationStore::kStatePending)); |
| 600 | EXPECT_CALL(*modem_info_.mock_dispatcher(), PostTask(_)).Times(0); |
| 601 | capability_->UpdatePendingActivationState(); |
| 602 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
| 603 | Mock::VerifyAndClearExpectations(modem_info_.mock_dispatcher()); |
| 604 | |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 605 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), RemoveEntry(_, _)) |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 606 | .Times(0); |
| 607 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 608 | GetActivationState(_, _)) |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 609 | .Times(2) |
| 610 | .WillRepeatedly(Return(PendingActivationStore::kStateFailureRetry)); |
| 611 | EXPECT_CALL(*modem_info_.mock_dispatcher(), PostTask(_)).Times(1); |
| 612 | capability_->UpdatePendingActivationState(); |
| 613 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
| 614 | Mock::VerifyAndClearExpectations(modem_info_.mock_dispatcher()); |
| 615 | |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 616 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), RemoveEntry(_, _)) |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 617 | .Times(0); |
| 618 | EXPECT_CALL(*modem_info_.mock_pending_activation_store(), |
Alex Vakulenko | 8a53229 | 2014-06-16 17:18:44 -0700 | [diff] [blame] | 619 | GetActivationState(_, _)) |
Arman Uguray | 0a3e279 | 2013-01-17 16:31:50 -0800 | [diff] [blame] | 620 | .Times(4) |
| 621 | .WillOnce(Return(PendingActivationStore::kStateActivated)) |
| 622 | .WillOnce(Return(PendingActivationStore::kStateActivated)) |
| 623 | .WillOnce(Return(PendingActivationStore::kStateUnknown)) |
| 624 | .WillOnce(Return(PendingActivationStore::kStateUnknown)); |
| 625 | EXPECT_CALL(*modem_info_.mock_dispatcher(), PostTask(_)).Times(0); |
| 626 | capability_->UpdatePendingActivationState(); |
| 627 | capability_->UpdatePendingActivationState(); |
| 628 | Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store()); |
| 629 | Mock::VerifyAndClearExpectations(modem_info_.mock_dispatcher()); |
| 630 | } |
| 631 | |
Arman Uguray | 72fab6a | 2013-01-10 19:32:42 -0800 | [diff] [blame] | 632 | } // namespace shill |