Loading tests/src/com/android/server/telecom/tests/CallAudioRouteStateMachineTest.java +3 −1 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ import static org.mockito.Matchers.any; import static org.mockito.Matchers.same; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.timeout; Loading Loading @@ -1145,7 +1146,8 @@ public class CallAudioRouteStateMachineTest private void resetMocks() { reset(mockAudioManager, mockBluetoothRouteManager, mockCallsManager, mockConnectionServiceWrapper, fakeCall); mockConnectionServiceWrapper); fakeCall = mock(Call.class); when(mockCallsManager.getForegroundCall()).thenReturn(fakeCall); when(fakeCall.getConnectionService()).thenReturn(mockConnectionServiceWrapper); when(fakeCall.isAlive()).thenReturn(true); Loading tests/src/com/android/server/telecom/tests/InCallServiceFixture.java +21 −7 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import android.os.Bundle; import android.os.IBinder; import android.os.IInterface; import android.os.RemoteException; import android.telecom.AudioState; import android.telecom.CallAudioState; import android.telecom.ParcelableCall; Loading @@ -49,7 +48,8 @@ public class InCallServiceFixture implements TestFixture<IInCallService> { public boolean mShowDialpad; public boolean mCanAddCall; public boolean mSilenceRinger; public CountDownLatch mLock = new CountDownLatch(1); public CountDownLatch mUpdateCallLock = new CountDownLatch(1); public CountDownLatch mAddCallLock = new CountDownLatch(1); public class FakeInCallService extends IInCallService.Stub { @Override Loading @@ -68,8 +68,9 @@ public class InCallServiceFixture implements TestFixture<IInCallService> { if (mCallById.containsKey(call.getId())) { throw new RuntimeException("Call " + call.getId() + " already added"); } mCallById.put(call.getId(), call); mLatestCallId = call.getId(); mCallById.put(call.getId(), call); mAddCallLock.countDown(); } @Override Loading @@ -77,9 +78,9 @@ public class InCallServiceFixture implements TestFixture<IInCallService> { if (!mCallById.containsKey(call.getId())) { throw new RuntimeException("Call " + call.getId() + " not added yet"); } mCallById.put(call.getId(), call); mLatestCallId = call.getId(); mLock.countDown(); mCallById.put(call.getId(), call); mUpdateCallLock.countDown(); } @Override Loading Loading @@ -159,10 +160,23 @@ public class InCallServiceFixture implements TestFixture<IInCallService> { public void waitForUpdate() { try { mLock.await(5000, TimeUnit.MILLISECONDS); mUpdateCallLock.await(5000, TimeUnit.MILLISECONDS); } catch (InterruptedException ie) { return; } mUpdateCallLock = new CountDownLatch(1); } public void waitUntilNumCalls(int numCalls) { if (mCallById.size() == numCalls) { return; } mAddCallLock = new CountDownLatch(1); try { mAddCallLock.await(5000, TimeUnit.MILLISECONDS); } catch (InterruptedException ie) { return; } mLock = new CountDownLatch(1); } } tests/src/com/android/server/telecom/tests/TelecomSystemTest.java +32 −43 Original line number Diff line number Diff line Loading @@ -578,13 +578,8 @@ public class TelecomSystemTest extends TelecomTestCase { int startingNumConnections = connectionServiceFixture.mConnectionById.size(); int startingNumCalls = mInCallServiceFixtureX.mCallById.size(); String callId = startOutgoingPhoneCallPendingCreateConnection(number, phoneAccountHandle, startOutgoingPhoneCallPendingCreateConnection(number, phoneAccountHandle, connectionServiceFixture, initiatingUser, videoState); // Set the phone account if there is one specified if (phoneAccountHandle != null) { mInCallServiceFixtureX.getInCallAdapter().phoneAccountSelected( callId, phoneAccountHandle, false); } return outgoingCallCreateConnectionComplete(startingNumConnections, startingNumCalls, phoneAccountHandle, connectionServiceFixture); Loading Loading @@ -847,8 +842,8 @@ public class TelecomSystemTest extends TelecomTestCase { // is added, future interactions as triggered by the ConnectionService, through the various // test fixtures, will be synchronous. if (!hasInCallAdapter && phoneAccountHandle != mPhoneAccountSelfManaged.getAccountHandle()) { if (phoneAccountHandle != mPhoneAccountSelfManaged.getAccountHandle()) { if (!hasInCallAdapter) { verify(mInCallServiceFixtureX.getTestDouble(), timeout(TEST_TIMEOUT)) .setInCallAdapter(any(IInCallAdapter.class)); verify(mInCallServiceFixtureY.getTestDouble(), timeout(TEST_TIMEOUT)) Loading @@ -875,6 +870,7 @@ public class TelecomSystemTest extends TelecomTestCase { .addCall(any(ParcelableCall.class)); // Give the InCallService time to respond } assertTrueWithTimeout(new Predicate<Void>() { @Override Loading @@ -883,18 +879,11 @@ public class TelecomSystemTest extends TelecomTestCase { connectionServiceFixture.mConnectionById.size(); } }); assertTrueWithTimeout(new Predicate<Void>() { @Override public boolean apply(Void v) { return startingNumCalls + 1 == mInCallServiceFixtureX.mCallById.size(); } }); assertTrueWithTimeout(new Predicate<Void>() { @Override public boolean apply(Void v) { return startingNumCalls + 1 == mInCallServiceFixtureY.mCallById.size(); } }); mInCallServiceFixtureX.waitUntilNumCalls(startingNumCalls + 1); mInCallServiceFixtureY.waitUntilNumCalls(startingNumCalls + 1); assertEquals(startingNumCalls + 1, mInCallServiceFixtureX.mCallById.size()); assertEquals(startingNumCalls + 1, mInCallServiceFixtureY.mCallById.size()); assertEquals(mInCallServiceFixtureX.mLatestCallId, mInCallServiceFixtureY.mLatestCallId); Loading Loading
tests/src/com/android/server/telecom/tests/CallAudioRouteStateMachineTest.java +3 −1 Original line number Diff line number Diff line Loading @@ -55,6 +55,7 @@ import static org.mockito.Matchers.any; import static org.mockito.Matchers.same; import static org.mockito.Mockito.doAnswer; import static org.mockito.Mockito.doNothing; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.reset; import static org.mockito.Mockito.timeout; Loading Loading @@ -1145,7 +1146,8 @@ public class CallAudioRouteStateMachineTest private void resetMocks() { reset(mockAudioManager, mockBluetoothRouteManager, mockCallsManager, mockConnectionServiceWrapper, fakeCall); mockConnectionServiceWrapper); fakeCall = mock(Call.class); when(mockCallsManager.getForegroundCall()).thenReturn(fakeCall); when(fakeCall.getConnectionService()).thenReturn(mockConnectionServiceWrapper); when(fakeCall.isAlive()).thenReturn(true); Loading
tests/src/com/android/server/telecom/tests/InCallServiceFixture.java +21 −7 Original line number Diff line number Diff line Loading @@ -25,7 +25,6 @@ import android.os.Bundle; import android.os.IBinder; import android.os.IInterface; import android.os.RemoteException; import android.telecom.AudioState; import android.telecom.CallAudioState; import android.telecom.ParcelableCall; Loading @@ -49,7 +48,8 @@ public class InCallServiceFixture implements TestFixture<IInCallService> { public boolean mShowDialpad; public boolean mCanAddCall; public boolean mSilenceRinger; public CountDownLatch mLock = new CountDownLatch(1); public CountDownLatch mUpdateCallLock = new CountDownLatch(1); public CountDownLatch mAddCallLock = new CountDownLatch(1); public class FakeInCallService extends IInCallService.Stub { @Override Loading @@ -68,8 +68,9 @@ public class InCallServiceFixture implements TestFixture<IInCallService> { if (mCallById.containsKey(call.getId())) { throw new RuntimeException("Call " + call.getId() + " already added"); } mCallById.put(call.getId(), call); mLatestCallId = call.getId(); mCallById.put(call.getId(), call); mAddCallLock.countDown(); } @Override Loading @@ -77,9 +78,9 @@ public class InCallServiceFixture implements TestFixture<IInCallService> { if (!mCallById.containsKey(call.getId())) { throw new RuntimeException("Call " + call.getId() + " not added yet"); } mCallById.put(call.getId(), call); mLatestCallId = call.getId(); mLock.countDown(); mCallById.put(call.getId(), call); mUpdateCallLock.countDown(); } @Override Loading Loading @@ -159,10 +160,23 @@ public class InCallServiceFixture implements TestFixture<IInCallService> { public void waitForUpdate() { try { mLock.await(5000, TimeUnit.MILLISECONDS); mUpdateCallLock.await(5000, TimeUnit.MILLISECONDS); } catch (InterruptedException ie) { return; } mUpdateCallLock = new CountDownLatch(1); } public void waitUntilNumCalls(int numCalls) { if (mCallById.size() == numCalls) { return; } mAddCallLock = new CountDownLatch(1); try { mAddCallLock.await(5000, TimeUnit.MILLISECONDS); } catch (InterruptedException ie) { return; } mLock = new CountDownLatch(1); } }
tests/src/com/android/server/telecom/tests/TelecomSystemTest.java +32 −43 Original line number Diff line number Diff line Loading @@ -578,13 +578,8 @@ public class TelecomSystemTest extends TelecomTestCase { int startingNumConnections = connectionServiceFixture.mConnectionById.size(); int startingNumCalls = mInCallServiceFixtureX.mCallById.size(); String callId = startOutgoingPhoneCallPendingCreateConnection(number, phoneAccountHandle, startOutgoingPhoneCallPendingCreateConnection(number, phoneAccountHandle, connectionServiceFixture, initiatingUser, videoState); // Set the phone account if there is one specified if (phoneAccountHandle != null) { mInCallServiceFixtureX.getInCallAdapter().phoneAccountSelected( callId, phoneAccountHandle, false); } return outgoingCallCreateConnectionComplete(startingNumConnections, startingNumCalls, phoneAccountHandle, connectionServiceFixture); Loading Loading @@ -847,8 +842,8 @@ public class TelecomSystemTest extends TelecomTestCase { // is added, future interactions as triggered by the ConnectionService, through the various // test fixtures, will be synchronous. if (!hasInCallAdapter && phoneAccountHandle != mPhoneAccountSelfManaged.getAccountHandle()) { if (phoneAccountHandle != mPhoneAccountSelfManaged.getAccountHandle()) { if (!hasInCallAdapter) { verify(mInCallServiceFixtureX.getTestDouble(), timeout(TEST_TIMEOUT)) .setInCallAdapter(any(IInCallAdapter.class)); verify(mInCallServiceFixtureY.getTestDouble(), timeout(TEST_TIMEOUT)) Loading @@ -875,6 +870,7 @@ public class TelecomSystemTest extends TelecomTestCase { .addCall(any(ParcelableCall.class)); // Give the InCallService time to respond } assertTrueWithTimeout(new Predicate<Void>() { @Override Loading @@ -883,18 +879,11 @@ public class TelecomSystemTest extends TelecomTestCase { connectionServiceFixture.mConnectionById.size(); } }); assertTrueWithTimeout(new Predicate<Void>() { @Override public boolean apply(Void v) { return startingNumCalls + 1 == mInCallServiceFixtureX.mCallById.size(); } }); assertTrueWithTimeout(new Predicate<Void>() { @Override public boolean apply(Void v) { return startingNumCalls + 1 == mInCallServiceFixtureY.mCallById.size(); } }); mInCallServiceFixtureX.waitUntilNumCalls(startingNumCalls + 1); mInCallServiceFixtureY.waitUntilNumCalls(startingNumCalls + 1); assertEquals(startingNumCalls + 1, mInCallServiceFixtureX.mCallById.size()); assertEquals(startingNumCalls + 1, mInCallServiceFixtureY.mCallById.size()); assertEquals(mInCallServiceFixtureX.mLatestCallId, mInCallServiceFixtureY.mLatestCallId); Loading