shill: cellular: Obtain |actvation_code| from serving operator.

In automatic activation implemented in CellularCapabilityUniversalCDMA, obtain
the activation code from the serving operator.

BUG=chromium:376098
TEST=(1) Run shill_unittests
     (2) Run network_CDMAActivate

Change-Id: Id56dcd99625ad2d655e58b68090a17febb7a56f9
Reviewed-on: https://chromium-review.googlesource.com/201084
Reviewed-by: Ben Chan <benchan@chromium.org>
Commit-Queue: Prathmesh Prabhu <pprabhu@chromium.org>
Tested-by: Prathmesh Prabhu <pprabhu@chromium.org>
diff --git a/cellular_capability_universal_cdma_unittest.cc b/cellular_capability_universal_cdma_unittest.cc
index a65148b..e108111 100644
--- a/cellular_capability_universal_cdma_unittest.cc
+++ b/cellular_capability_universal_cdma_unittest.cc
@@ -328,22 +328,33 @@
 }
 
 TEST_F(CellularCapabilityUniversalCDMAMainTest, ActivateAutomatic) {
+  const string activation_code {"1234"};
+  SetMockMobileOperatorInfoObjects();
+
   mm1::MockModemModemCdmaProxy *cdma_proxy = modem_cdma_proxy_.get();
   SetUp();
   capability_->InitProxies();
 
-  EXPECT_CALL(*modem_info_.mock_pending_activation_store(),
-              GetActivationState(_,_))
-      .Times(0);
-  EXPECT_CALL(*modem_info_.mock_pending_activation_store(),
-              SetActivationState(_,_,_))
-      .Times(0);
+  // Cases when activation fails because |activation_code| is not available.
+  EXPECT_CALL(*mock_serving_operator_info_, IsMobileNetworkOperatorKnown())
+      .WillRepeatedly(Return(false));
   EXPECT_CALL(*cdma_proxy, Activate(_,_,_,_)).Times(0);
   capability_->ActivateAutomatic();
-  Mock::VerifyAndClearExpectations(modem_info_.mock_pending_activation_store());
+  Mock::VerifyAndClearExpectations(mock_serving_operator_info_);
+  Mock::VerifyAndClearExpectations(modem_cdma_proxy_.get());
+  EXPECT_CALL(*mock_serving_operator_info_, IsMobileNetworkOperatorKnown())
+      .WillRepeatedly(Return(true));
+  mock_serving_operator_info_->SetEmptyDefaultsForProperties();
+  EXPECT_CALL(*cdma_proxy, Activate(_,_,_,_)).Times(0);
+  capability_->ActivateAutomatic();
+  Mock::VerifyAndClearExpectations(mock_serving_operator_info_);
   Mock::VerifyAndClearExpectations(modem_cdma_proxy_.get());
 
-  capability_->activation_code_ = "1234";
+  // These expectations hold for all subsequent tests.
+  EXPECT_CALL(*mock_serving_operator_info_, IsMobileNetworkOperatorKnown())
+      .WillRepeatedly(Return(true));
+  EXPECT_CALL(*mock_serving_operator_info_, activation_code())
+      .WillRepeatedly(ReturnRef(activation_code));
 
   EXPECT_CALL(*modem_info_.mock_pending_activation_store(),
               GetActivationState(PendingActivationStore::kIdentifierMEID, _))