Code example for TelephonyManager

Methods: listen

0
		listener = new MyPhoneStateListener(); 
	} 
 
	@Test 
	public void testListen() { 
		manager.listen(listener, PhoneStateListener.LISTEN_CALL_STATE);
        assertThat(shadowManager.getListener()).isNotNull();
        assertThat((MyPhoneStateListener) shadowManager.getListener()).isSameAs(listener);
        assertThat(shadowManager.getEventFlags()).isEqualTo(PhoneStateListener.LISTEN_CALL_STATE);
	} 
 
    @Test 
    public void shouldGiveDeviceId() { 
        String testId = "TESTING123";
        TelephonyManager telephonyManager = (TelephonyManager) application.getSystemService(TELEPHONY_SERVICE);
        shadowOf(telephonyManager).setDeviceId(testId);
        assertEquals(testId, telephonyManager.getDeviceId());
    } 
 
    @Test 
    public void shouldGiveNetworkOperatorName() {