Skip to content
Snippets Groups Projects
Commit 3e46d803 authored by William Escande's avatar William Escande
Browse files

Fix mockito that fail to stub a second time

doReturn().when(foo).bar() should replace all when(foo.bar()).thenReturn()

Bug: 256752741
Test: atest BluetoothInstrumentationTests
Change-Id: I89d444cdffaee80d45eb1ad58daa7ded2500c9e3
parent 48ae6e7f
No related branches found
No related tags found
No related merge requests found
......@@ -181,12 +181,12 @@ public class HeadsetServiceAndStateMachineTest {
mAdapterService).getBondedDevices();
// Mock system interface
doNothing().when(mSystemInterface).stop();
when(mSystemInterface.getHeadsetPhoneState()).thenReturn(mPhoneState);
when(mSystemInterface.getAudioManager()).thenReturn(mAudioManager);
when(mSystemInterface.activateVoiceRecognition()).thenReturn(true);
when(mSystemInterface.deactivateVoiceRecognition()).thenReturn(true);
when(mSystemInterface.getVoiceRecognitionWakeLock()).thenReturn(mVoiceRecognitionWakeLock);
when(mSystemInterface.isCallIdle()).thenReturn(true);
doReturn(mPhoneState).when(mSystemInterface).getHeadsetPhoneState();
doReturn(mAudioManager).when(mSystemInterface).getAudioManager();
doReturn(true).when(mSystemInterface).activateVoiceRecognition();
doReturn(true).when(mSystemInterface).deactivateVoiceRecognition();
doReturn(mVoiceRecognitionWakeLock).when(mSystemInterface).getVoiceRecognitionWakeLock();
doReturn(true).when(mSystemInterface).isCallIdle();
// Mock methods in HeadsetNativeInterface
mNativeInterface = spy(HeadsetNativeInterface.getInstance());
doNothing().when(mNativeInterface).init(anyInt(), anyBoolean());
......@@ -710,7 +710,7 @@ public class HeadsetServiceAndStateMachineTest {
*/
@Test
public void testVoiceRecognition_SingleHfInitiatedFailedToActivate() {
when(mSystemInterface.activateVoiceRecognition()).thenReturn(false);
doReturn(false).when(mSystemInterface).activateVoiceRecognition();
// Connect HF
BluetoothDevice device = TestUtils.getTestDevice(mAdapter, 0);
connectTestDevice(device);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment