use of android.telephony.TelephonyManager.CellInfoCallback in project robolectric by robolectric.
the class ShadowTelephonyManagerTest method shouldGiveCellInfoUpdate.
@Test
@Config(minSdk = Q)
public void shouldGiveCellInfoUpdate() throws Exception {
List<CellInfo> callbackCellInfo = Collections.singletonList(mock(CellInfo.class));
shadowOf(telephonyManager).setCallbackCellInfos(callbackCellInfo);
assertNotEquals(callbackCellInfo, telephonyManager.getAllCellInfo());
CountDownLatch callbackLatch = new CountDownLatch(1);
shadowOf(telephonyManager).requestCellInfoUpdate(new Executor() {
@Override
public void execute(Runnable r) {
r.run();
}
}, new CellInfoCallback() {
@Override
public void onCellInfo(List<CellInfo> list) {
assertEquals(callbackCellInfo, list);
callbackLatch.countDown();
}
});
assertTrue(callbackLatch.await(5000, TimeUnit.MILLISECONDS));
}
Aggregations