Code example for MediaRecorder

0
  private MediaRecorder mediaRecorder;
  private ShadowMediaRecorder shadowMediaRecorder;
 
  @Before 
  public void setUp() throws Exception { 
    mediaRecorder = new MediaRecorder();
    shadowMediaRecorder = Robolectric.shadowOf(mediaRecorder);
  } 
 
  @Test 
  public void testAudioChannels() throws Exception { 
    assertThat(shadowMediaRecorder.getAudioChannels()).isNotEqualTo(2);
    mediaRecorder.setAudioChannels(2);
    assertThat(shadowMediaRecorder.getAudioChannels()).isEqualTo(2);
  } 
 
  @Test 
  public void testAudioEncoder() throws Exception { 
    assertThat(shadowMediaRecorder.getAudioEncoder()).isNotEqualTo(MediaRecorder.AudioEncoder.AMR_NB);
    assertThat(shadowMediaRecorder.getState()).isNotEqualTo(ShadowMediaRecorder.STATE_DATA_SOURCE_CONFIGURED);
    mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);