OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/mobile/mobile_activator.h" | 5 #include "chrome/browser/chromeos/mobile/mobile_activator.h" |
6 | 6 |
7 #include "chrome/browser/chromeos/cros/mock_network_library.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "chrome/browser/chromeos/cros/network_library.h" | 8 #include "chromeos/dbus/dbus_thread_manager.h" |
| 9 #include "chromeos/network/network_handler.h" |
| 10 #include "chromeos/network/network_state.h" |
9 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
10 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "third_party/cros_system_api/dbus/service_constants.h" |
12 | 15 |
13 using std::string; | 16 using std::string; |
14 | 17 |
15 using content::BrowserThread; | 18 using content::BrowserThread; |
16 using testing::_; | 19 using testing::_; |
17 using testing::Eq; | 20 using testing::Eq; |
| 21 using testing::Invoke; |
18 using testing::Return; | 22 using testing::Return; |
19 | 23 |
20 namespace { | 24 namespace { |
21 | 25 |
22 const char kTestServicePath[] = "/a/service/path"; | 26 const char kTestServicePath[] = "/a/service/path"; |
23 | 27 |
24 const size_t kNumOTASPStates = 3; | 28 const size_t kNumOTASPStates = 3; |
25 | 29 |
26 chromeos::MobileActivator::PlanActivationState kOTASPStates[kNumOTASPStates] = { | 30 chromeos::MobileActivator::PlanActivationState kOTASPStates[kNumOTASPStates] = { |
27 chromeos::MobileActivator::PLAN_ACTIVATION_TRYING_OTASP, | 31 chromeos::MobileActivator::PLAN_ACTIVATION_TRYING_OTASP, |
28 chromeos::MobileActivator::PLAN_ACTIVATION_INITIATING_ACTIVATION, | 32 chromeos::MobileActivator::PLAN_ACTIVATION_INITIATING_ACTIVATION, |
29 chromeos::MobileActivator::PLAN_ACTIVATION_OTASP, | 33 chromeos::MobileActivator::PLAN_ACTIVATION_OTASP, |
30 }; | 34 }; |
31 | 35 |
32 } // namespace | 36 } // namespace |
33 namespace chromeos { | 37 namespace chromeos { |
34 | 38 |
35 class TestMobileActivator : public MobileActivator { | 39 class TestMobileActivator : public MobileActivator { |
36 public: | 40 public: |
37 TestMobileActivator(MockNetworkLibrary* mock_network_library, | 41 explicit TestMobileActivator(NetworkState* cellular_network) : |
38 CellularNetwork* cellular_network) | |
39 : mock_network_library_(mock_network_library), | |
40 cellular_network_(cellular_network) { | 42 cellular_network_(cellular_network) { |
41 // Provide reasonable defaults for basic things we're usually not testing. | 43 // Provide reasonable defaults for basic things we're usually not testing. |
42 ON_CALL(*this, DCheckOnThread(_)) | 44 ON_CALL(*this, DCheckOnThread(_)) |
43 .WillByDefault(Return()); | 45 .WillByDefault(Return()); |
44 ON_CALL(*this, FindMatchingCellularNetwork(_)) | 46 ON_CALL(*this, GetNetworkState(_)) |
45 .WillByDefault(Return(cellular_network)); | 47 .WillByDefault(Return(cellular_network_)); |
46 ON_CALL(*this, GetNetworkLibrary()) | |
47 .WillByDefault(Return(mock_network_library_)); | |
48 } | 48 } |
49 virtual ~TestMobileActivator() {} | 49 virtual ~TestMobileActivator() {} |
50 | 50 |
51 MOCK_METHOD3(ChangeState, void(CellularNetwork*, | 51 MOCK_METHOD3(RequestCellularActivation, |
| 52 void(const NetworkState*, |
| 53 const base::Closure&, |
| 54 const network_handler::ErrorCallback&)); |
| 55 MOCK_METHOD3(ChangeState, void(const NetworkState*, |
52 MobileActivator::PlanActivationState, | 56 MobileActivator::PlanActivationState, |
53 const std::string&)); | 57 const std::string&)); |
54 MOCK_METHOD1(EvaluateCellularNetwork, void(CellularNetwork*)); | 58 MOCK_METHOD1(GetNetworkState, const NetworkState*(const std::string&)); |
55 MOCK_METHOD1(FindMatchingCellularNetwork, CellularNetwork*(bool)); | 59 MOCK_METHOD1(EvaluateCellularNetwork, void(const NetworkState*)); |
| 60 MOCK_METHOD0(SignalCellularPlanPayment, void(void)); |
56 MOCK_METHOD0(StartOTASPTimer, void(void)); | 61 MOCK_METHOD0(StartOTASPTimer, void(void)); |
| 62 MOCK_CONST_METHOD0(HasRecentCellularPlanPayment, bool(void)); |
57 | 63 |
58 void InvokeChangeState(CellularNetwork* network, | 64 void InvokeChangeState(const NetworkState* network, |
59 MobileActivator::PlanActivationState new_state, | 65 MobileActivator::PlanActivationState new_state, |
60 const std::string& error_description) { | 66 const std::string& error_description) { |
61 MobileActivator::ChangeState(network, new_state, error_description); | 67 MobileActivator::ChangeState(network, new_state, error_description); |
62 } | 68 } |
63 | 69 |
64 private: | 70 private: |
65 MOCK_CONST_METHOD0(GetNetworkLibrary, NetworkLibrary*(void)); | |
66 MOCK_CONST_METHOD1(DCheckOnThread, void(const BrowserThread::ID id)); | 71 MOCK_CONST_METHOD1(DCheckOnThread, void(const BrowserThread::ID id)); |
67 | 72 |
68 MockNetworkLibrary* mock_network_library_; | 73 NetworkState* cellular_network_; |
69 CellularNetwork* cellular_network_; | |
70 | 74 |
71 DISALLOW_COPY_AND_ASSIGN(TestMobileActivator); | 75 DISALLOW_COPY_AND_ASSIGN(TestMobileActivator); |
72 }; | 76 }; |
73 | 77 |
74 class MobileActivatorTest : public testing::Test { | 78 class MobileActivatorTest : public testing::Test { |
75 public: | 79 public: |
76 MobileActivatorTest() | 80 MobileActivatorTest() |
77 : network_library_(), | 81 : cellular_network_(string(kTestServicePath)), |
78 cellular_network_(string(kTestServicePath)), | 82 mobile_activator_(&cellular_network_) { |
79 mobile_activator_(&network_library_, &cellular_network_) {} | 83 } |
80 virtual ~MobileActivatorTest() {} | 84 virtual ~MobileActivatorTest() {} |
81 | 85 |
82 protected: | 86 protected: |
83 virtual void SetUp() {} | 87 virtual void SetUp() { |
84 virtual void TearDown() {} | 88 DBusThreadManager::InitializeWithStub(); |
| 89 NetworkHandler::Initialize(); |
| 90 } |
| 91 virtual void TearDown() { |
| 92 NetworkHandler::Shutdown(); |
| 93 DBusThreadManager::Shutdown(); |
| 94 } |
85 | 95 |
86 void set_activator_state(const MobileActivator::PlanActivationState state) { | 96 void set_activator_state(const MobileActivator::PlanActivationState state) { |
87 mobile_activator_.state_ = state; | 97 mobile_activator_.state_ = state; |
88 } | 98 } |
89 void set_network_activation_state(ActivationState state) { | 99 void set_network_activation_state(const std::string& activation_state) { |
90 cellular_network_.activation_state_ = state; | 100 cellular_network_.activation_state_ = activation_state; |
91 } | 101 } |
92 void set_connection_state(ConnectionState state) { | 102 void set_connection_state(const std::string& state) { |
93 cellular_network_.state_ = state; | 103 cellular_network_.connection_state_ = state; |
94 } | 104 } |
95 | 105 |
96 MockNetworkLibrary network_library_; | 106 base::MessageLoop message_loop_; |
97 MockCellularNetwork cellular_network_; | 107 NetworkState cellular_network_; |
98 TestMobileActivator mobile_activator_; | 108 TestMobileActivator mobile_activator_; |
99 private: | 109 private: |
100 DISALLOW_COPY_AND_ASSIGN(MobileActivatorTest); | 110 DISALLOW_COPY_AND_ASSIGN(MobileActivatorTest); |
101 }; | 111 }; |
102 | 112 |
103 TEST_F(MobileActivatorTest, BasicFlowForNewDevices) { | 113 TEST_F(MobileActivatorTest, BasicFlowForNewDevices) { |
104 // In a new device, we aren't connected to Verizon, we start at START | 114 // In a new device, we aren't connected to Verizon, we start at START |
105 // because we haven't paid Verizon (ever), and the modem isn't even partially | 115 // because we haven't paid Verizon (ever), and the modem isn't even partially |
106 // activated. | 116 // activated. |
107 std::string error_description; | 117 std::string error_description; |
108 set_activator_state(MobileActivator::PLAN_ACTIVATION_START); | 118 set_activator_state(MobileActivator::PLAN_ACTIVATION_START); |
109 set_connection_state(STATE_IDLE); | 119 set_connection_state(flimflam::kStateIdle); |
110 set_network_activation_state(ACTIVATION_STATE_NOT_ACTIVATED); | 120 set_network_activation_state(flimflam::kActivationStateNotActivated); |
111 EXPECT_EQ(MobileActivator::PLAN_ACTIVATION_INITIATING_ACTIVATION, | 121 EXPECT_EQ(MobileActivator::PLAN_ACTIVATION_INITIATING_ACTIVATION, |
112 mobile_activator_.PickNextState(&cellular_network_, | 122 mobile_activator_.PickNextState(&cellular_network_, |
113 &error_description)); | 123 &error_description)); |
114 // Now behave as if ChangeState() has initiated an activation. | 124 // Now behave as if ChangeState() has initiated an activation. |
115 set_activator_state(MobileActivator::PLAN_ACTIVATION_INITIATING_ACTIVATION); | 125 set_activator_state(MobileActivator::PLAN_ACTIVATION_INITIATING_ACTIVATION); |
116 set_network_activation_state(ACTIVATION_STATE_ACTIVATING); | 126 set_network_activation_state(flimflam::kActivationStateActivating); |
117 // We'll sit in this state while we wait for the OTASP to finish. | 127 // We'll sit in this state while we wait for the OTASP to finish. |
118 EXPECT_EQ(MobileActivator::PLAN_ACTIVATION_INITIATING_ACTIVATION, | 128 EXPECT_EQ(MobileActivator::PLAN_ACTIVATION_INITIATING_ACTIVATION, |
119 mobile_activator_.PickNextState(&cellular_network_, | 129 mobile_activator_.PickNextState(&cellular_network_, |
120 &error_description)); | 130 &error_description)); |
121 set_network_activation_state(ACTIVATION_STATE_PARTIALLY_ACTIVATED); | 131 set_network_activation_state(flimflam::kActivationStatePartiallyActivated); |
122 // We'll sit in this state until we go online as well. | 132 // We'll sit in this state until we go online as well. |
123 EXPECT_EQ(MobileActivator::PLAN_ACTIVATION_INITIATING_ACTIVATION, | 133 EXPECT_EQ(MobileActivator::PLAN_ACTIVATION_INITIATING_ACTIVATION, |
124 mobile_activator_.PickNextState(&cellular_network_, | 134 mobile_activator_.PickNextState(&cellular_network_, |
125 &error_description)); | 135 &error_description)); |
126 set_connection_state(STATE_PORTAL); | 136 set_connection_state(flimflam::kStatePortal); |
127 // After we go online, we go back to START, which acts as a jumping off | 137 // After we go online, we go back to START, which acts as a jumping off |
128 // point for the two types of initial OTASP. | 138 // point for the two types of initial OTASP. |
129 EXPECT_EQ(MobileActivator::PLAN_ACTIVATION_START, | 139 EXPECT_EQ(MobileActivator::PLAN_ACTIVATION_START, |
130 mobile_activator_.PickNextState(&cellular_network_, | 140 mobile_activator_.PickNextState(&cellular_network_, |
131 &error_description)); | 141 &error_description)); |
132 set_activator_state(MobileActivator::PLAN_ACTIVATION_START); | 142 set_activator_state(MobileActivator::PLAN_ACTIVATION_START); |
133 EXPECT_EQ(MobileActivator::PLAN_ACTIVATION_TRYING_OTASP, | 143 EXPECT_EQ(MobileActivator::PLAN_ACTIVATION_TRYING_OTASP, |
134 mobile_activator_.PickNextState(&cellular_network_, | 144 mobile_activator_.PickNextState(&cellular_network_, |
135 &error_description)); | 145 &error_description)); |
136 // Very similar things happen while we're trying OTASP. | 146 // Very similar things happen while we're trying OTASP. |
137 set_activator_state(MobileActivator::PLAN_ACTIVATION_TRYING_OTASP); | 147 set_activator_state(MobileActivator::PLAN_ACTIVATION_TRYING_OTASP); |
138 set_network_activation_state(ACTIVATION_STATE_ACTIVATING); | 148 set_network_activation_state(flimflam::kActivationStateActivating); |
139 EXPECT_EQ(MobileActivator::PLAN_ACTIVATION_TRYING_OTASP, | 149 EXPECT_EQ(MobileActivator::PLAN_ACTIVATION_TRYING_OTASP, |
140 mobile_activator_.PickNextState(&cellular_network_, | 150 mobile_activator_.PickNextState(&cellular_network_, |
141 &error_description)); | 151 &error_description)); |
142 set_network_activation_state(ACTIVATION_STATE_PARTIALLY_ACTIVATED); | 152 set_network_activation_state(flimflam::kActivationStatePartiallyActivated); |
143 set_connection_state(STATE_PORTAL); | 153 set_connection_state(flimflam::kStatePortal); |
144 // And when we come back online again and aren't activating, load the portal. | 154 // And when we come back online again and aren't activating, load the portal. |
145 EXPECT_EQ(MobileActivator::PLAN_ACTIVATION_PAYMENT_PORTAL_LOADING, | 155 EXPECT_EQ(MobileActivator::PLAN_ACTIVATION_PAYMENT_PORTAL_LOADING, |
146 mobile_activator_.PickNextState(&cellular_network_, | 156 mobile_activator_.PickNextState(&cellular_network_, |
147 &error_description)); | 157 &error_description)); |
148 // The JS drives us through the payment portal. | 158 // The JS drives us through the payment portal. |
149 set_activator_state(MobileActivator::PLAN_ACTIVATION_SHOWING_PAYMENT); | 159 set_activator_state(MobileActivator::PLAN_ACTIVATION_SHOWING_PAYMENT); |
150 // The JS also calls us to signal that the portal is done. This triggers us | 160 // The JS also calls us to signal that the portal is done. This triggers us |
151 // to start our final OTASP via the aptly named StartOTASP(). | 161 // to start our final OTASP via the aptly named StartOTASP(). |
152 EXPECT_CALL(network_library_, SignalCellularPlanPayment()); | 162 EXPECT_CALL(mobile_activator_, SignalCellularPlanPayment()); |
153 EXPECT_CALL(mobile_activator_, | 163 EXPECT_CALL(mobile_activator_, |
154 ChangeState(Eq(&cellular_network_), | 164 ChangeState(Eq(&cellular_network_), |
155 Eq(MobileActivator::PLAN_ACTIVATION_START_OTASP), | 165 Eq(MobileActivator::PLAN_ACTIVATION_START_OTASP), |
156 _)); | 166 _)); |
157 EXPECT_CALL(mobile_activator_, | 167 EXPECT_CALL(mobile_activator_, |
158 EvaluateCellularNetwork(Eq(&cellular_network_))); | 168 EvaluateCellularNetwork(Eq(&cellular_network_))); |
159 mobile_activator_.HandleSetTransactionStatus(true); | 169 mobile_activator_.HandleSetTransactionStatus(true); |
160 // Evaluate state will defer to PickNextState to select what to do now that | 170 // Evaluate state will defer to PickNextState to select what to do now that |
161 // we're in START_ACTIVATION. PickNextState should decide to start a final | 171 // we're in START_ACTIVATION. PickNextState should decide to start a final |
162 // OTASP. | 172 // OTASP. |
163 set_activator_state(MobileActivator::PLAN_ACTIVATION_START_OTASP); | 173 set_activator_state(MobileActivator::PLAN_ACTIVATION_START_OTASP); |
164 EXPECT_EQ(MobileActivator::PLAN_ACTIVATION_OTASP, | 174 EXPECT_EQ(MobileActivator::PLAN_ACTIVATION_OTASP, |
165 mobile_activator_.PickNextState(&cellular_network_, | 175 mobile_activator_.PickNextState(&cellular_network_, |
166 &error_description)); | 176 &error_description)); |
167 // Similarly to TRYING_OTASP and INITIATING_OTASP above... | 177 // Similarly to TRYING_OTASP and INITIATING_OTASP above... |
168 set_activator_state(MobileActivator::PLAN_ACTIVATION_OTASP); | 178 set_activator_state(MobileActivator::PLAN_ACTIVATION_OTASP); |
169 set_network_activation_state(ACTIVATION_STATE_ACTIVATING); | 179 set_network_activation_state(flimflam::kActivationStateActivating); |
170 EXPECT_EQ(MobileActivator::PLAN_ACTIVATION_OTASP, | 180 EXPECT_EQ(MobileActivator::PLAN_ACTIVATION_OTASP, |
171 mobile_activator_.PickNextState(&cellular_network_, | 181 mobile_activator_.PickNextState(&cellular_network_, |
172 &error_description)); | 182 &error_description)); |
173 set_network_activation_state(ACTIVATION_STATE_ACTIVATED); | 183 set_network_activation_state(flimflam::kActivationStateActivated); |
174 EXPECT_EQ(MobileActivator::PLAN_ACTIVATION_DONE, | 184 EXPECT_EQ(MobileActivator::PLAN_ACTIVATION_DONE, |
175 mobile_activator_.PickNextState(&cellular_network_, | 185 mobile_activator_.PickNextState(&cellular_network_, |
176 &error_description)); | 186 &error_description)); |
177 } | 187 } |
178 | 188 |
| 189 // A fake for MobileActivator::RequestCellularActivation that always succeeds. |
| 190 void FakeRequestCellularActivationSuccess( |
| 191 const NetworkState* network, |
| 192 const base::Closure& success_callback, |
| 193 const network_handler::ErrorCallback& error_callback) { |
| 194 success_callback.Run(); |
| 195 } |
| 196 |
| 197 // A fake for MobileActivator::RequestCellularActivation that always fails. |
| 198 void FakeRequestCellularActivationFailure( |
| 199 const NetworkState* network, |
| 200 const base::Closure& success_callback, |
| 201 const network_handler::ErrorCallback& error_callback) { |
| 202 scoped_ptr<base::DictionaryValue> value; |
| 203 error_callback.Run("", value.Pass()); |
| 204 } |
| 205 |
179 TEST_F(MobileActivatorTest, OTASPScheduling) { | 206 TEST_F(MobileActivatorTest, OTASPScheduling) { |
180 const std::string error; | 207 const std::string error; |
181 for (size_t i = 0; i < kNumOTASPStates; ++i) { | 208 for (size_t i = 0; i < kNumOTASPStates; ++i) { |
182 // When activation works, we start a timer to watch for success. | 209 // When activation works, we start a timer to watch for success. |
183 EXPECT_CALL(cellular_network_, StartActivation()) | 210 EXPECT_CALL(mobile_activator_, RequestCellularActivation(_, _, _)) |
184 .Times(1) | 211 .Times(1) |
185 .WillOnce(Return(true)); | 212 .WillOnce(Invoke(FakeRequestCellularActivationSuccess)); |
186 EXPECT_CALL(mobile_activator_, StartOTASPTimer()) | 213 EXPECT_CALL(mobile_activator_, StartOTASPTimer()) |
187 .Times(1); | 214 .Times(1); |
188 set_activator_state(MobileActivator::PLAN_ACTIVATION_START); | 215 set_activator_state(MobileActivator::PLAN_ACTIVATION_START); |
189 mobile_activator_.InvokeChangeState(&cellular_network_, | 216 mobile_activator_.InvokeChangeState(&cellular_network_, |
190 kOTASPStates[i], | 217 kOTASPStates[i], |
191 error); | 218 error); |
| 219 |
192 // When activation fails, it's an error, unless we're trying for the final | 220 // When activation fails, it's an error, unless we're trying for the final |
193 // OTASP, in which case we try again via DELAY_OTASP. | 221 // OTASP, in which case we try again via DELAY_OTASP. |
194 EXPECT_CALL(cellular_network_, StartActivation()) | 222 EXPECT_CALL(mobile_activator_, RequestCellularActivation(_, _, _)) |
195 .Times(1) | 223 .Times(1) |
196 .WillOnce(Return(false)); | 224 .WillOnce(Invoke(FakeRequestCellularActivationFailure)); |
197 if (kOTASPStates[i] == MobileActivator::PLAN_ACTIVATION_OTASP) { | 225 if (kOTASPStates[i] == MobileActivator::PLAN_ACTIVATION_OTASP) { |
198 EXPECT_CALL(mobile_activator_, ChangeState( | 226 EXPECT_CALL(mobile_activator_, ChangeState( |
199 Eq(&cellular_network_), | 227 Eq(&cellular_network_), |
200 Eq(MobileActivator::PLAN_ACTIVATION_DELAY_OTASP), | 228 Eq(MobileActivator::PLAN_ACTIVATION_DELAY_OTASP), |
201 _)); | 229 _)); |
202 } else { | 230 } else { |
203 EXPECT_CALL(mobile_activator_, ChangeState( | 231 EXPECT_CALL(mobile_activator_, ChangeState( |
204 Eq(&cellular_network_), | 232 Eq(&cellular_network_), |
205 Eq(MobileActivator::PLAN_ACTIVATION_ERROR), | 233 Eq(MobileActivator::PLAN_ACTIVATION_ERROR), |
206 _)); | 234 _)); |
207 } | 235 } |
208 set_activator_state(MobileActivator::PLAN_ACTIVATION_START); | 236 set_activator_state(MobileActivator::PLAN_ACTIVATION_START); |
209 mobile_activator_.InvokeChangeState(&cellular_network_, | 237 mobile_activator_.InvokeChangeState(&cellular_network_, |
210 kOTASPStates[i], | 238 kOTASPStates[i], |
211 error); | 239 error); |
212 } | 240 } |
213 } | 241 } |
214 | 242 |
215 TEST_F(MobileActivatorTest, ReconnectOnDisconnectFromPaymentPortal) { | 243 TEST_F(MobileActivatorTest, ReconnectOnDisconnectFromPaymentPortal) { |
216 // Most states either don't care if we're offline or expect to be offline at | 244 // Most states either don't care if we're offline or expect to be offline at |
217 // some point. For instance the OTASP states expect to go offline during | 245 // some point. For instance the OTASP states expect to go offline during |
218 // activation and eventually come back. There are a few transitions states | 246 // activation and eventually come back. There are a few transitions states |
219 // like START_OTASP and DELAY_OTASP which don't really depend on the state of | 247 // like START_OTASP and DELAY_OTASP which don't really depend on the state of |
220 // the modem (offline or online) to work correctly. A few places however, | 248 // the modem (offline or online) to work correctly. A few places however, |
221 // like when we're displaying the portal care quite a bit about going | 249 // like when we're displaying the portal care quite a bit about going |
222 // offline. Lets test for those cases. | 250 // offline. Lets test for those cases. |
223 std::string error_description; | 251 std::string error_description; |
224 set_connection_state(STATE_FAILURE); | 252 set_connection_state(flimflam::kStateFailure); |
225 set_network_activation_state(ACTIVATION_STATE_PARTIALLY_ACTIVATED); | 253 set_network_activation_state(flimflam::kActivationStatePartiallyActivated); |
226 set_activator_state(MobileActivator::PLAN_ACTIVATION_PAYMENT_PORTAL_LOADING); | 254 set_activator_state(MobileActivator::PLAN_ACTIVATION_PAYMENT_PORTAL_LOADING); |
227 EXPECT_EQ(MobileActivator::PLAN_ACTIVATION_RECONNECTING, | 255 EXPECT_EQ(MobileActivator::PLAN_ACTIVATION_RECONNECTING, |
228 mobile_activator_.PickNextState(&cellular_network_, | 256 mobile_activator_.PickNextState(&cellular_network_, |
229 &error_description)); | 257 &error_description)); |
230 set_activator_state(MobileActivator::PLAN_ACTIVATION_SHOWING_PAYMENT); | 258 set_activator_state(MobileActivator::PLAN_ACTIVATION_SHOWING_PAYMENT); |
231 EXPECT_EQ(MobileActivator::PLAN_ACTIVATION_RECONNECTING, | 259 EXPECT_EQ(MobileActivator::PLAN_ACTIVATION_RECONNECTING, |
232 mobile_activator_.PickNextState(&cellular_network_, | 260 mobile_activator_.PickNextState(&cellular_network_, |
233 &error_description)); | 261 &error_description)); |
234 } | 262 } |
235 | 263 |
236 TEST_F(MobileActivatorTest, StartAtStart) { | 264 TEST_F(MobileActivatorTest, StartAtStart) { |
237 EXPECT_CALL(network_library_, | 265 EXPECT_CALL(mobile_activator_, HasRecentCellularPlanPayment()) |
238 AddNetworkManagerObserver(Eq(&mobile_activator_))); | 266 .WillOnce(Return(false)); |
239 EXPECT_CALL(network_library_, HasRecentCellularPlanPayment()). | |
240 WillOnce(Return(false)); | |
241 EXPECT_CALL(mobile_activator_, | 267 EXPECT_CALL(mobile_activator_, |
242 EvaluateCellularNetwork(Eq(&cellular_network_))); | 268 EvaluateCellularNetwork(Eq(&cellular_network_))); |
243 mobile_activator_.StartActivation(); | 269 mobile_activator_.StartActivation(); |
244 EXPECT_EQ(mobile_activator_.state(), MobileActivator::PLAN_ACTIVATION_START); | 270 EXPECT_EQ(mobile_activator_.state(), MobileActivator::PLAN_ACTIVATION_START); |
245 } | 271 } |
246 | 272 |
247 } // namespace chromeos | 273 } // namespace chromeos |
OLD | NEW |