Skip to content

Commit

Permalink
Merge branch 'master' into addDegradatinParameter
Browse files Browse the repository at this point in the history
  • Loading branch information
burak-58 authored Nov 23, 2023
2 parents b52ab4a + 1f642c7 commit 172dec4
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public void controlAudio(View view) {
audioButton.setText("Enable Audio");
sendNotificationEvent(MIC_MUTED, null);
} else {
webRTCClient.isAudioOn();
webRTCClient.enableAudio();
audioButton.setText("Disable Audio");
sendNotificationEvent(MIC_UNMUTED, null);
}
Expand Down Expand Up @@ -396,8 +396,15 @@ else if(eventType.equals(UPDATE_STATUS)) {
}
}

// This method is added for unit testing purposes
public void setWebRTCClient(WebRTCClient webRTCClient) {
this.webRTCClient = webRTCClient;
}


// This method is added for unit testing purposes
public void setAudioButton(Button audioButton) {
this.audioButton = audioButton;
}

}

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package io.antmedia.webrtc_android_sample_app;

import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.when;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.Switch;

import org.json.JSONObject;
import org.junit.Test;
import org.mockito.Mockito;
import org.webrtc.SurfaceViewRenderer;

import io.antmedia.webrtcandroidframework.WebRTCClient;

public class TrackBasedConferenceActivityUnitTest {


@Test
public void testControlAudio() {
TrackBasedConferenceActivity trackBasedConferenceActivity = Mockito.spy(new TrackBasedConferenceActivity());
doNothing().when(trackBasedConferenceActivity).sendNotificationEvent(anyString(), Mockito.any(JSONObject.class));

Button audioButton = Mockito.mock(Button.class);
doNothing().when(audioButton).setText(anyString());

WebRTCClient webRTCClient = Mockito.mock(WebRTCClient.class);
doNothing().when(webRTCClient).enableAudio();
doNothing().when(webRTCClient).disableAudio();

trackBasedConferenceActivity.setWebRTCClient(webRTCClient);
trackBasedConferenceActivity.setAudioButton(audioButton);

Mockito.verify(webRTCClient, Mockito.times(0)).disableAudio();
Mockito.verify(webRTCClient, Mockito.times(0)).enableAudio();

when(webRTCClient.isAudioOn()).thenReturn(true);
trackBasedConferenceActivity.controlAudio(null);
Mockito.verify(webRTCClient, Mockito.times(1)).disableAudio();
Mockito.verify(webRTCClient, Mockito.times(0)).enableAudio();

when(webRTCClient.isAudioOn()).thenReturn(false);
trackBasedConferenceActivity.controlAudio(null);
Mockito.verify(webRTCClient, Mockito.times(1)).disableAudio();
Mockito.verify(webRTCClient, Mockito.times(1)).enableAudio();
}
}

0 comments on commit 172dec4

Please sign in to comment.