summaryrefslogtreecommitdiffstats
path: root/tests/src/com
diff options
context:
space:
mode:
authorYorke Lee <yorkelee@google.com>2015-03-06 11:40:15 -0800
committerYorke Lee <yorkelee@google.com>2015-03-06 11:40:15 -0800
commit28754684be03a7d9429d4d5c9fe796d9f9927c2c (patch)
treefe68edbb10ff99176d2ccf4035c7e4de711861f9 /tests/src/com
parentb8f6c478612eb0e116b0866fb0e9465d000da05d (diff)
downloadpackages_apps_InCallUI-28754684be03a7d9429d4d5c9fe796d9f9927c2c.tar.gz
packages_apps_InCallUI-28754684be03a7d9429d4d5c9fe796d9f9927c2c.tar.bz2
packages_apps_InCallUI-28754684be03a7d9429d4d5c9fe796d9f9927c2c.zip
Flesh out more InCall tests
Change-Id: If77e0767e9dbc65a9235dc1841f4d7298e4d39d5
Diffstat (limited to 'tests/src/com')
-rw-r--r--tests/src/com/android/incallui/InCallPresenterTest.java58
1 files changed, 47 insertions, 11 deletions
diff --git a/tests/src/com/android/incallui/InCallPresenterTest.java b/tests/src/com/android/incallui/InCallPresenterTest.java
index 6d608761..55ab1e1d 100644
--- a/tests/src/com/android/incallui/InCallPresenterTest.java
+++ b/tests/src/com/android/incallui/InCallPresenterTest.java
@@ -22,6 +22,7 @@ import static org.mockito.Mockito.when;
import android.content.Context;
import android.content.Intent;
+import android.telecom.PhoneAccountHandle;
import android.test.InstrumentationTestCase;
import com.android.incallui.InCallPresenter.InCallState;
@@ -31,10 +32,11 @@ import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
public class InCallPresenterTest extends InstrumentationTestCase {
- private static final Call TEST_INCOMING_CALL = new Call(Call.State.INCOMING);
- private static final Call TEST_ACTIVE_CALL = new Call(Call.State.ACTIVE);
- private static final Call TEST_PENDING_CALL = new Call(Call.State.CONNECTING);
- private static final Call TEST_WAITING_FOR_ACCOUNT_CALL = new Call(Call.State.PRE_DIAL_WAIT);
+ private Call mIncomingCall;
+ private Call mActiveCall;
+ private Call mConnectingCall;
+ private Call mWaitingForAccountsCall;
+ private Call mDisconnectedCall;
@Mock private InCallActivity mInCallActivity;
@Mock private AudioModeProvider mAudioModeProvider;
@@ -52,6 +54,13 @@ public class InCallPresenterTest extends InstrumentationTestCase {
System.setProperty("dexmaker.dexcache",
getInstrumentation().getTargetContext().getCacheDir().getPath());
MockitoAnnotations.initMocks(this);
+
+ mIncomingCall = getMockCall(Call.State.INCOMING);
+ mActiveCall = getMockCall(Call.State.ACTIVE);
+ mConnectingCall = getMockCall(Call.State.CONNECTING);
+ mWaitingForAccountsCall = getMockCall(Call.State.PRE_DIAL_WAIT, false);
+ mDisconnectedCall = getMockCall(Call.State.DISCONNECTED);
+
mInCallPresenter = InCallPresenter.getInstance();
mInCallPresenter.setUp(mContext, mCallList, mAudioModeProvider, mStatusBarNotifier,
mContactInfoCache, mProximitySensor);
@@ -78,7 +87,7 @@ public class InCallPresenterTest extends InstrumentationTestCase {
}
public void testOnCallListChange_sendsNotificationWhenInCall() {
- when(mCallList.getIncomingCall()).thenReturn(TEST_INCOMING_CALL);
+ when(mCallList.getIncomingCall()).thenReturn(mIncomingCall);
mInCallPresenter.onCallListChange(mCallList);
@@ -91,7 +100,7 @@ public class InCallPresenterTest extends InstrumentationTestCase {
* activity.
*/
public void testOnCallListChange_handlesCallWaitingWhenScreenOffShouldRestartActivity() {
- when(mCallList.getActiveCall()).thenReturn(TEST_ACTIVE_CALL);
+ when(mCallList.getActiveCall()).thenReturn(mActiveCall);
mInCallPresenter.onCallListChange(mCallList);
mInCallPresenter.setActivity(mInCallActivity);
@@ -100,7 +109,7 @@ public class InCallPresenterTest extends InstrumentationTestCase {
when(mInCallActivity.isDestroyed()).thenReturn(false);
when(mInCallActivity.isFinishing()).thenReturn(false);
when(mProximitySensor.isScreenReallyOff()).thenReturn(true);
- when(mCallList.getIncomingCall()).thenReturn(TEST_INCOMING_CALL);
+ when(mCallList.getIncomingCall()).thenReturn(mIncomingCall);
mInCallPresenter.onCallListChange(mCallList);
verify(mInCallActivity).finish();
@@ -111,12 +120,12 @@ public class InCallPresenterTest extends InstrumentationTestCase {
* that it can display an error dialog.
*/
public void testOnCallListChange_pendingOutgoingToInCallTransitionShowsUiForErrorDialog() {
- when(mCallList.getPendingOutgoingCall()).thenReturn(TEST_PENDING_CALL);
+ when(mCallList.getPendingOutgoingCall()).thenReturn(mConnectingCall);
mInCallPresenter.onCallListChange(mCallList);
when(mCallList.getPendingOutgoingCall()).thenReturn(null);
- when(mCallList.getActiveCall()).thenReturn(TEST_ACTIVE_CALL);
+ when(mCallList.getActiveCall()).thenReturn(mActiveCall);
mInCallPresenter.onCallListChange(mCallList);
@@ -129,7 +138,7 @@ public class InCallPresenterTest extends InstrumentationTestCase {
* to display the account picker.
*/
public void testOnCallListChange_noAccountProvidedForCallShowsUiForAccountPicker() {
- when(mCallList.getWaitingForAccountCall()).thenReturn(TEST_WAITING_FOR_ACCOUNT_CALL);
+ when(mCallList.getWaitingForAccountCall()).thenReturn(mWaitingForAccountsCall);
mInCallPresenter.onCallListChange(mCallList);
verify(mContext).startActivity(InCallPresenter.getInstance().getInCallIntent(false, false));
@@ -141,13 +150,27 @@ public class InCallPresenterTest extends InstrumentationTestCase {
* InCallActivity is not displayed.
*/
public void testOnCallListChange_noCallsToPendingOutgoingDoesNotShowUi() {
- when(mCallList.getPendingOutgoingCall()).thenReturn(TEST_PENDING_CALL);
+ when(mCallList.getPendingOutgoingCall()).thenReturn(mConnectingCall);
mInCallPresenter.onCallListChange(mCallList);
verifyInCallActivityNotStarted();
verifyIncomingCallNotificationNotSent();
}
+ public void testOnCallListChange_LastCallDisconnectedNoCallsLeftFinishesUi() {
+ when(mCallList.getDisconnectedCall()).thenReturn(mDisconnectedCall);
+ mInCallPresenter.onCallListChange(mCallList);
+
+ mInCallPresenter.setActivity(mInCallActivity);
+
+ verify(mInCallActivity, never()).finish();
+
+ // Last remaining disconnected call is removed from CallList, activity should shut down.
+ when(mCallList.getDisconnectedCall()).thenReturn(null);
+ mInCallPresenter.onCallListChange(mCallList);
+ verify(mInCallActivity).finish();
+ }
+
//TODO
public void testCircularReveal_startsCircularRevealForOutgoingCalls() {
@@ -174,4 +197,17 @@ public class InCallPresenterTest extends InstrumentationTestCase {
verify(mStatusBarNotifier, never()).updateNotification(Mockito.any(InCallState.class),
Mockito.any(CallList.class));
}
+
+ private static Call getMockCall(int state) {
+ return getMockCall(state, true);
+ }
+
+ private static Call getMockCall(int state, boolean hasAccountHandle) {
+ final Call call = Mockito.mock(Call.class);
+ when(call.getState()).thenReturn(Integer.valueOf(state));
+ if (hasAccountHandle) {
+ when(call.getAccountHandle()).thenReturn(new PhoneAccountHandle(null, null));
+ }
+ return call;
+ }
}