blob: e74cc8e6d44e99d87939469d18e20a7c8f3a960f [file] [log] [blame]
Fabian Kozynskib176f422019-02-05 09:36:59 -05001/*
2 * Copyright (C) 2019 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.keyguard;
18
19
20import static android.telephony.SubscriptionManager.DATA_ROAMING_DISABLE;
21import static android.telephony.SubscriptionManager.DATA_ROAMING_ENABLE;
22import static android.telephony.SubscriptionManager.NAME_SOURCE_DEFAULT_SOURCE;
23
24import static junit.framework.Assert.assertTrue;
25
26import static org.junit.Assert.assertEquals;
27import static org.mockito.ArgumentMatchers.any;
28import static org.mockito.ArgumentMatchers.anyBoolean;
29import static org.mockito.ArgumentMatchers.anyInt;
30import static org.mockito.Mockito.never;
31import static org.mockito.Mockito.reset;
32import static org.mockito.Mockito.verify;
33import static org.mockito.Mockito.when;
34
35import android.content.Context;
36import android.net.ConnectivityManager;
37import android.net.wifi.WifiManager;
38import android.os.Handler;
Fabian Kozynskic3d06f32019-07-31 14:18:41 -040039import android.provider.Settings;
Fabian Kozynskib176f422019-02-05 09:36:59 -050040import android.telephony.SubscriptionInfo;
Malcolm Chen06ec3572019-04-09 15:55:29 -070041import android.telephony.SubscriptionManager;
Fabian Kozynskib176f422019-02-05 09:36:59 -050042import android.telephony.TelephonyManager;
43import android.test.suitebuilder.annotation.SmallTest;
44import android.testing.AndroidTestingRunner;
45import android.testing.TestableLooper;
46
47import com.android.internal.telephony.IccCardConstants;
48import com.android.systemui.Dependency;
49import com.android.systemui.SysuiTestCase;
50import com.android.systemui.keyguard.WakefulnessLifecycle;
51
52import org.junit.Before;
53import org.junit.Test;
54import org.junit.runner.RunWith;
55import org.mockito.ArgumentCaptor;
56import org.mockito.Mock;
57import org.mockito.MockitoAnnotations;
58
59import java.util.ArrayList;
Bonian Chena7e9e8c2019-06-02 23:59:31 +000060import java.util.HashMap;
Fabian Kozynskib176f422019-02-05 09:36:59 -050061import java.util.List;
62
63@SmallTest
64@RunWith(AndroidTestingRunner.class)
65@TestableLooper.RunWithLooper
66public class CarrierTextControllerTest extends SysuiTestCase {
67
68 private static final CharSequence SEPARATOR = " \u2014 ";
Fabian Kozynskic3d06f32019-07-31 14:18:41 -040069 private static final CharSequence INVALID_CARD_TEXT = "Invalid card";
70 private static final CharSequence AIRPLANE_MODE_TEXT = "Airplane mode";
Fabian Kozynskib176f422019-02-05 09:36:59 -050071 private static final String TEST_CARRIER = "TEST_CARRIER";
Sooraj Sasindran0d45da72019-04-25 15:12:21 -070072 private static final String TEST_CARRIER_2 = "TEST_CARRIER_2";
73 private static final String TEST_GROUP_UUID = "59b5c870-fc4c-47a4-a99e-9db826b48b24";
74 private static final int TEST_CARRIER_ID = 1;
Fabian Kozynskib176f422019-02-05 09:36:59 -050075 private static final SubscriptionInfo TEST_SUBSCRIPTION = new SubscriptionInfo(0, "", 0,
76 TEST_CARRIER, TEST_CARRIER, NAME_SOURCE_DEFAULT_SOURCE, 0xFFFFFF, "",
Sooraj Sasindran0d45da72019-04-25 15:12:21 -070077 DATA_ROAMING_DISABLE, null, null, null, null, false, null, "", false, TEST_GROUP_UUID,
78 TEST_CARRIER_ID, 0);
79 private static final SubscriptionInfo TEST_SUBSCRIPTION_2 = new SubscriptionInfo(0, "", 0,
80 TEST_CARRIER, TEST_CARRIER_2, NAME_SOURCE_DEFAULT_SOURCE, 0xFFFFFF, "",
81 DATA_ROAMING_DISABLE, null, null, null, null, false, null, "", true, TEST_GROUP_UUID,
82 TEST_CARRIER_ID, 0);
Fabian Kozynskib176f422019-02-05 09:36:59 -050083 private static final SubscriptionInfo TEST_SUBSCRIPTION_ROAMING = new SubscriptionInfo(0, "", 0,
84 TEST_CARRIER, TEST_CARRIER, NAME_SOURCE_DEFAULT_SOURCE, 0xFFFFFF, "",
85 DATA_ROAMING_ENABLE, null, null, null, null, false, null, "");
86 @Mock
87 private WifiManager mWifiManager;
88 @Mock
89 private CarrierTextController.CarrierTextCallback mCarrierTextCallback;
90 @Mock
91 private KeyguardUpdateMonitor mKeyguardUpdateMonitor;
92 @Mock
93 private ConnectivityManager mConnectivityManager;
94 @Mock
95 private TelephonyManager mTelephonyManager;
Malcolm Chen06ec3572019-04-09 15:55:29 -070096 @Mock
97 private SubscriptionManager mSubscriptionManager;
Fabian Kozynskib176f422019-02-05 09:36:59 -050098 private CarrierTextController.CarrierTextCallbackInfo mCarrierTextCallbackInfo;
99
100 private CarrierTextController mCarrierTextController;
101 private TestableLooper mTestableLooper;
102
103 @Before
104 public void setUp() {
105 MockitoAnnotations.initMocks(this);
106 mTestableLooper = TestableLooper.get(this);
107
108 mContext.addMockSystemService(WifiManager.class, mWifiManager);
109 mContext.addMockSystemService(ConnectivityManager.class, mConnectivityManager);
110 mContext.addMockSystemService(TelephonyManager.class, mTelephonyManager);
Malcolm Chen06ec3572019-04-09 15:55:29 -0700111 mContext.addMockSystemService(SubscriptionManager.class, mSubscriptionManager);
Fabian Kozynskic3d06f32019-07-31 14:18:41 -0400112 mContext.getOrCreateTestableResources().addOverride(
113 R.string.keyguard_sim_error_message_short, INVALID_CARD_TEXT);
114 mContext.getOrCreateTestableResources().addOverride(
115 R.string.airplane_mode, AIRPLANE_MODE_TEXT);
Fabian Kozynskib176f422019-02-05 09:36:59 -0500116 mDependency.injectMockDependency(WakefulnessLifecycle.class);
117 mDependency.injectTestDependency(Dependency.MAIN_HANDLER,
118 new Handler(mTestableLooper.getLooper()));
119
120 mCarrierTextCallbackInfo = new CarrierTextController.CarrierTextCallbackInfo("",
121 new CharSequence[]{}, false, new int[]{});
Malcolm Chen387dc0e2019-10-08 18:11:22 -0700122 when(mTelephonyManager.getSupportedModemCount()).thenReturn(3);
Malcolm Chend3844352019-11-04 16:26:28 -0800123 when(mTelephonyManager.getActiveModemCount()).thenReturn(3);
Fabian Kozynski00d02f12019-04-15 09:48:30 -0400124
Fabian Kozynskib176f422019-02-05 09:36:59 -0500125 mCarrierTextController = new TestCarrierTextController(mContext, SEPARATOR, true, true,
126 mKeyguardUpdateMonitor);
127 // This should not start listening on any of the real dependencies
128 mCarrierTextController.setListening(mCarrierTextCallback);
Sooraj Sasindranb7d633b2019-05-02 13:47:21 -0700129 mCarrierTextController.updateDisplayOpportunisticSubscriptionCarrierText(false);
Fabian Kozynskib176f422019-02-05 09:36:59 -0500130 }
131
132 @Test
Fabian Kozynskic3d06f32019-07-31 14:18:41 -0400133 public void testAirplaneMode() {
134 Settings.Global.putInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 1);
135 reset(mCarrierTextCallback);
136 List<SubscriptionInfo> list = new ArrayList<>();
137 list.add(TEST_SUBSCRIPTION);
138 when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list);
139 when(mKeyguardUpdateMonitor.getSimState(0)).thenReturn(IccCardConstants.State.READY);
140 mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
141
142 mCarrierTextController.updateCarrierText();
143
144 ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
145 ArgumentCaptor.forClass(
146 CarrierTextController.CarrierTextCallbackInfo.class);
147
148 mTestableLooper.processAllMessages();
149 verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
150 assertEquals(AIRPLANE_MODE_TEXT, captor.getValue().carrierText);
151 }
152
153 @Test
154 public void testCardIOError() {
155 reset(mCarrierTextCallback);
156 List<SubscriptionInfo> list = new ArrayList<>();
157 list.add(TEST_SUBSCRIPTION);
158 when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list);
159 when(mKeyguardUpdateMonitor.getSimState(0)).thenReturn(IccCardConstants.State.READY);
160 when(mKeyguardUpdateMonitor.getSimState(1)).thenReturn(
161 IccCardConstants.State.CARD_IO_ERROR);
162 mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
163
164 mCarrierTextController.mCallback.onSimStateChanged(3, 1,
165 IccCardConstants.State.CARD_IO_ERROR);
166
167 ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
168 ArgumentCaptor.forClass(
169 CarrierTextController.CarrierTextCallbackInfo.class);
170
171 mTestableLooper.processAllMessages();
172 verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
173 assertEquals("TEST_CARRIER" + SEPARATOR + INVALID_CARD_TEXT, captor.getValue().carrierText);
174 // There's only one subscription in the list
175 assertEquals(1, captor.getValue().listOfCarriers.length);
176 assertEquals(TEST_CARRIER, captor.getValue().listOfCarriers[0]);
Malcolm Chend3844352019-11-04 16:26:28 -0800177
178 // Now it becomes single SIM active mode.
179 reset(mCarrierTextCallback);
180 when(mTelephonyManager.getActiveModemCount()).thenReturn(1);
181 // Update carrier text. It should ignore error state of subId 3 in inactive slotId.
182 mCarrierTextController.updateCarrierText();
183 mTestableLooper.processAllMessages();
184 verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
185 assertEquals("TEST_CARRIER", captor.getValue().carrierText);
Fabian Kozynskic3d06f32019-07-31 14:18:41 -0400186 }
187
188 @Test
Fabian Kozynskib176f422019-02-05 09:36:59 -0500189 public void testWrongSlots() {
190 reset(mCarrierTextCallback);
191 when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(
192 new ArrayList<>());
193 when(mKeyguardUpdateMonitor.getSimState(anyInt())).thenReturn(
194 IccCardConstants.State.CARD_IO_ERROR);
195 // This should not produce an out of bounds error, even though there are no subscriptions
196 mCarrierTextController.mCallback.onSimStateChanged(0, -3,
197 IccCardConstants.State.CARD_IO_ERROR);
198 mCarrierTextController.mCallback.onSimStateChanged(0, 3, IccCardConstants.State.READY);
199 verify(mCarrierTextCallback, never()).updateCarrierInfo(any());
200 }
201
202 @Test
203 public void testMoreSlotsThanSubs() {
204 reset(mCarrierTextCallback);
205 when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(
206 new ArrayList<>());
Fabian Kozynski00d02f12019-04-15 09:48:30 -0400207
208 // STOPSHIP(b/130246708) This line makes sure that SubscriptionManager provides the
209 // same answer as KeyguardUpdateMonitor. Remove when this is addressed
210 when(mSubscriptionManager.getActiveSubscriptionInfoList(anyBoolean())).thenReturn(
211 new ArrayList<>());
212
Fabian Kozynskib176f422019-02-05 09:36:59 -0500213 when(mKeyguardUpdateMonitor.getSimState(anyInt())).thenReturn(
214 IccCardConstants.State.CARD_IO_ERROR);
215 // This should not produce an out of bounds error, even though there are no subscriptions
216 mCarrierTextController.mCallback.onSimStateChanged(0, 1,
217 IccCardConstants.State.CARD_IO_ERROR);
218
219 mTestableLooper.processAllMessages();
220 verify(mCarrierTextCallback).updateCarrierInfo(
221 any(CarrierTextController.CarrierTextCallbackInfo.class));
222 }
223
224 @Test
225 public void testCallback() {
226 reset(mCarrierTextCallback);
227 mCarrierTextController.postToCallback(mCarrierTextCallbackInfo);
228 mTestableLooper.processAllMessages();
229
230 ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
231 ArgumentCaptor.forClass(
232 CarrierTextController.CarrierTextCallbackInfo.class);
233 verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
234 assertEquals(mCarrierTextCallbackInfo, captor.getValue());
235 }
236
237 @Test
238 public void testNullingCallback() {
239 reset(mCarrierTextCallback);
240
241 mCarrierTextController.postToCallback(mCarrierTextCallbackInfo);
242 mCarrierTextController.setListening(null);
243
244 // This shouldn't produce NPE
245 mTestableLooper.processAllMessages();
246 verify(mCarrierTextCallback).updateCarrierInfo(any());
247 }
248
249 @Test
250 public void testCreateInfo_OneValidSubscription() {
251 reset(mCarrierTextCallback);
252 List<SubscriptionInfo> list = new ArrayList<>();
253 list.add(TEST_SUBSCRIPTION);
254 when(mKeyguardUpdateMonitor.getSimState(anyInt())).thenReturn(IccCardConstants.State.READY);
255 when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list);
Fabian Kozynski00d02f12019-04-15 09:48:30 -0400256
Bonian Chena7e9e8c2019-06-02 23:59:31 +0000257 mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
258
Fabian Kozynskib176f422019-02-05 09:36:59 -0500259 ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
260 ArgumentCaptor.forClass(
261 CarrierTextController.CarrierTextCallbackInfo.class);
262
263 mCarrierTextController.updateCarrierText();
264 mTestableLooper.processAllMessages();
265 verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
266
267 CarrierTextController.CarrierTextCallbackInfo info = captor.getValue();
268 assertEquals(1, info.listOfCarriers.length);
269 assertEquals(TEST_CARRIER, info.listOfCarriers[0]);
270 assertEquals(1, info.subscriptionIds.length);
271 }
272
273 @Test
274 public void testCreateInfo_OneValidSubscriptionWithRoaming() {
275 reset(mCarrierTextCallback);
276 List<SubscriptionInfo> list = new ArrayList<>();
277 list.add(TEST_SUBSCRIPTION_ROAMING);
278 when(mKeyguardUpdateMonitor.getSimState(anyInt())).thenReturn(IccCardConstants.State.READY);
279 when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list);
Fabian Kozynski00d02f12019-04-15 09:48:30 -0400280
Bonian Chena7e9e8c2019-06-02 23:59:31 +0000281 mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
282
Fabian Kozynskib176f422019-02-05 09:36:59 -0500283 ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
284 ArgumentCaptor.forClass(
285 CarrierTextController.CarrierTextCallbackInfo.class);
286
287 mCarrierTextController.updateCarrierText();
288 mTestableLooper.processAllMessages();
289 verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
290
291 CarrierTextController.CarrierTextCallbackInfo info = captor.getValue();
292 assertEquals(1, info.listOfCarriers.length);
293 assertTrue(info.listOfCarriers[0].toString().contains(TEST_CARRIER));
294 assertEquals(1, info.subscriptionIds.length);
295 }
296
297 @Test
298 public void testCreateInfo_noSubscriptions() {
299 reset(mCarrierTextCallback);
300 when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(
301 new ArrayList<>());
Fabian Kozynski00d02f12019-04-15 09:48:30 -0400302
Fabian Kozynskib176f422019-02-05 09:36:59 -0500303 ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
304 ArgumentCaptor.forClass(
305 CarrierTextController.CarrierTextCallbackInfo.class);
306
307 mCarrierTextController.updateCarrierText();
308 mTestableLooper.processAllMessages();
309 verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
310
311 CarrierTextController.CarrierTextCallbackInfo info = captor.getValue();
312 assertEquals(0, info.listOfCarriers.length);
313 assertEquals(0, info.subscriptionIds.length);
314
315 }
316
Fabian Kozynski00d02f12019-04-15 09:48:30 -0400317 @Test
318 public void testCarrierText_twoValidSubscriptions() {
319 reset(mCarrierTextCallback);
320 List<SubscriptionInfo> list = new ArrayList<>();
321 list.add(TEST_SUBSCRIPTION);
322 list.add(TEST_SUBSCRIPTION);
323 when(mKeyguardUpdateMonitor.getSimState(anyInt())).thenReturn(IccCardConstants.State.READY);
324 when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list);
325
Bonian Chena7e9e8c2019-06-02 23:59:31 +0000326 mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
327
Fabian Kozynski00d02f12019-04-15 09:48:30 -0400328 ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
329 ArgumentCaptor.forClass(
330 CarrierTextController.CarrierTextCallbackInfo.class);
331
332 mCarrierTextController.updateCarrierText();
333 mTestableLooper.processAllMessages();
334 verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
335
336 assertEquals(TEST_CARRIER + SEPARATOR + TEST_CARRIER,
337 captor.getValue().carrierText);
338 }
339
340 @Test
341 public void testCarrierText_oneDisabledSub() {
342 reset(mCarrierTextCallback);
343 List<SubscriptionInfo> list = new ArrayList<>();
344 list.add(TEST_SUBSCRIPTION);
345 list.add(TEST_SUBSCRIPTION);
346 when(mKeyguardUpdateMonitor.getSimState(anyInt()))
347 .thenReturn(IccCardConstants.State.READY)
348 .thenReturn(IccCardConstants.State.NOT_READY);
349 when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list);
350
Bonian Chena7e9e8c2019-06-02 23:59:31 +0000351 mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
352
Fabian Kozynski00d02f12019-04-15 09:48:30 -0400353 ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
354 ArgumentCaptor.forClass(
355 CarrierTextController.CarrierTextCallbackInfo.class);
356
357 mCarrierTextController.updateCarrierText();
358 mTestableLooper.processAllMessages();
359 verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
360
361 assertEquals(TEST_CARRIER,
362 captor.getValue().carrierText);
363 }
364
365 @Test
366 public void testCarrierText_firstDisabledSub() {
367 reset(mCarrierTextCallback);
368 List<SubscriptionInfo> list = new ArrayList<>();
369 list.add(TEST_SUBSCRIPTION);
370 list.add(TEST_SUBSCRIPTION);
371 when(mKeyguardUpdateMonitor.getSimState(anyInt()))
372 .thenReturn(IccCardConstants.State.NOT_READY)
373 .thenReturn(IccCardConstants.State.READY);
374 when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list);
375
Bonian Chena7e9e8c2019-06-02 23:59:31 +0000376 mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
377
Fabian Kozynski00d02f12019-04-15 09:48:30 -0400378 ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
379 ArgumentCaptor.forClass(
380 CarrierTextController.CarrierTextCallbackInfo.class);
381
382 mCarrierTextController.updateCarrierText();
383 mTestableLooper.processAllMessages();
384 verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
385
386 assertEquals(TEST_CARRIER,
387 captor.getValue().carrierText);
388 }
389
390 @Test
391 public void testCarrierText_threeSubsMiddleDisabled() {
392 reset(mCarrierTextCallback);
393 List<SubscriptionInfo> list = new ArrayList<>();
394 list.add(TEST_SUBSCRIPTION);
395 list.add(TEST_SUBSCRIPTION);
396 list.add(TEST_SUBSCRIPTION);
397 when(mKeyguardUpdateMonitor.getSimState(anyInt()))
398 .thenReturn(IccCardConstants.State.READY)
399 .thenReturn(IccCardConstants.State.NOT_READY)
400 .thenReturn(IccCardConstants.State.READY);
401 when(mKeyguardUpdateMonitor.getSubscriptionInfo(anyBoolean())).thenReturn(list);
Bonian Chena7e9e8c2019-06-02 23:59:31 +0000402 mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
Fabian Kozynski00d02f12019-04-15 09:48:30 -0400403
Fabian Kozynski00d02f12019-04-15 09:48:30 -0400404 ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
405 ArgumentCaptor.forClass(
406 CarrierTextController.CarrierTextCallbackInfo.class);
407
408 mCarrierTextController.updateCarrierText();
409 mTestableLooper.processAllMessages();
410 verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
411
412 assertEquals(TEST_CARRIER + SEPARATOR + TEST_CARRIER,
413 captor.getValue().carrierText);
414 }
415
Sooraj Sasindran0d45da72019-04-25 15:12:21 -0700416 @Test
417 public void testCarrierText_GroupedSubWithOpportunisticCarrierText() {
418 reset(mCarrierTextCallback);
419 List<SubscriptionInfo> list = new ArrayList<>();
420 list.add(TEST_SUBSCRIPTION);
421 list.add(TEST_SUBSCRIPTION_2);
422 when(mKeyguardUpdateMonitor.getSimState(anyInt()))
423 .thenReturn(IccCardConstants.State.READY);
Fabian Kozynski8d735cc2019-04-29 10:44:10 -0400424
Bonian Chena7e9e8c2019-06-02 23:59:31 +0000425 mKeyguardUpdateMonitor.mServiceStates = new HashMap<>();
Sooraj Sasindranb7d633b2019-05-02 13:47:21 -0700426 mCarrierTextController.updateDisplayOpportunisticSubscriptionCarrierText(true);
Sooraj Sasindran0d45da72019-04-25 15:12:21 -0700427 when(mSubscriptionManager.getActiveSubscriptionInfoList(anyBoolean())).thenReturn(list);
428
429 ArgumentCaptor<CarrierTextController.CarrierTextCallbackInfo> captor =
430 ArgumentCaptor.forClass(
431 CarrierTextController.CarrierTextCallbackInfo.class);
432
433 mCarrierTextController.updateCarrierText();
434 mTestableLooper.processAllMessages();
435 verify(mCarrierTextCallback).updateCarrierInfo(captor.capture());
436
437 assertEquals(TEST_CARRIER_2, captor.getValue().carrierText);
438 }
439
Fabian Kozynskib176f422019-02-05 09:36:59 -0500440 public static class TestCarrierTextController extends CarrierTextController {
441 private KeyguardUpdateMonitor mKUM;
442
443 public TestCarrierTextController(Context context, CharSequence separator,
444 boolean showAirplaneMode, boolean showMissingSim, KeyguardUpdateMonitor kum) {
445 super(context, separator, showAirplaneMode, showMissingSim);
446 mKUM = kum;
447 }
448
449 @Override
450 public void setListening(CarrierTextCallback callback) {
451 super.setListening(callback);
452 mKeyguardUpdateMonitor = mKUM;
453 }
Fabian Kozynskib176f422019-02-05 09:36:59 -0500454 }
455}