android.telephony.PhoneStateListener#onCallStateChanged ( )源码实例Demo

下面列出了android.telephony.PhoneStateListener#onCallStateChanged ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: mytracks   文件: AnnouncementPeriodicTaskTest.java
public void testRun_ringWhileSpeaking() throws Exception {
  startTask(TextToSpeech.SUCCESS);

  expect(tts.isSpeaking()).andStubReturn(true);
  expect(tts.stop()).andReturn(TextToSpeech.SUCCESS);

  AndroidMock.replay(tts);

  // Update the state to ringing - this should stop the current announcement.
  PhoneStateListener phoneListener = phoneListenerCapture.getValue();
  phoneListener.onCallStateChanged(TelephonyManager.CALL_STATE_RINGING, null);

  // Run the announcement - this should do nothing.
  task.run(null);

  AndroidMock.verify(mockTask, tts);
}
 
源代码2 项目: mytracks   文件: AnnouncementPeriodicTaskTest.java
public void testRun_duringCall() throws Exception {
  startTask(TextToSpeech.SUCCESS);

  expect(tts.isSpeaking()).andStubReturn(false);

  // Run the announcement
  AndroidMock.replay(tts);
  PhoneStateListener phoneListener = phoneListenerCapture.getValue();
  phoneListener.onCallStateChanged(TelephonyManager.CALL_STATE_OFFHOOK, null);
  task.run(null);
  AndroidMock.verify(mockTask, tts);
}
 
源代码3 项目: mytracks   文件: AnnouncementPeriodicTaskTest.java
public void testRun_whileRinging() throws Exception {
  startTask(TextToSpeech.SUCCESS);

  expect(tts.isSpeaking()).andStubReturn(false);

  // Run the announcement
  AndroidMock.replay(tts);
  PhoneStateListener phoneListener = phoneListenerCapture.getValue();
  phoneListener.onCallStateChanged(TelephonyManager.CALL_STATE_RINGING, null);
  task.run(null);
  AndroidMock.verify(mockTask, tts);
}