diff options
author | Joseph Pirozzo <pirozzoj@google.com> | 2021-02-11 12:17:31 -0800 |
---|---|---|
committer | Joseph Pirozzo <pirozzoj@google.com> | 2021-02-11 12:17:31 -0800 |
commit | 9fa9bf4ce8b355eebb08ecd65caf4da58c7d7cb9 (patch) | |
tree | b14f0c15ca7581812a0b1529335756d5d5e70b67 | |
parent | eb41815e93b9184c9b198d7bda3fbd04159dd8c3 (diff) | |
download | Messenger-9fa9bf4ce8b355eebb08ecd65caf4da58c7d7cb9.tar.gz |
CarMessenger Test update
Update the Mock of mMockMapClient to return true for all instances of
sendMessage regardless of parameter types, necessary due to an ambiguous
method call.
Bug: 157948464
Test: m RunCarMessengerRoboTests
Change-Id: Id793a1ab5c010475d94ac2db30e59a2a53e49d5c
-rw-r--r-- | tests/robotests/src/com/android/car/messenger/bluetooth/BluetoothHelperTest.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/tests/robotests/src/com/android/car/messenger/bluetooth/BluetoothHelperTest.java b/tests/robotests/src/com/android/car/messenger/bluetooth/BluetoothHelperTest.java index 711d8e0..7e9e9ac 100644 --- a/tests/robotests/src/com/android/car/messenger/bluetooth/BluetoothHelperTest.java +++ b/tests/robotests/src/com/android/car/messenger/bluetooth/BluetoothHelperTest.java @@ -35,7 +35,10 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; +import org.mockito.Mockito; import org.mockito.MockitoAnnotations; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; import org.robolectric.RobolectricTestRunner; import org.robolectric.annotation.Config; import org.robolectric.shadow.api.Shadow; @@ -50,7 +53,6 @@ public class BluetoothHelperTest { private static final String BLUETOOTH_ADDRESS_ONE = "FA:F8:14:CA:32:39"; private static final String BLUETOOTH_ADDRESS_TWO = "FA:F8:33:44:32:39"; - @Mock private BluetoothMapClient mMockMapClient; @Mock private BluetoothDevice mMockDeviceOne; @@ -59,10 +61,15 @@ public class BluetoothHelperTest { @Before public void setUp() { + Answer returnTrue = new Answer() { + public Object answer(InvocationOnMock invocation) { + return true; + } + }; MockitoAnnotations.initMocks(this); when(mMockDeviceOne.getAddress()).thenReturn(BLUETOOTH_ADDRESS_ONE); when(mMockDeviceTwo.getAddress()).thenReturn(BLUETOOTH_ADDRESS_TWO); - when(mMockMapClient.sendMessage(any(), any(), any(), any(), any())).thenReturn(true); + mMockMapClient = Mockito.mock(BluetoothMapClient.class, returnTrue); BluetoothAdapter.getDefaultAdapter().enable(); } |