Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ce961774 authored by William Escande's avatar William Escande
Browse files

AvrcpController: Split NativeInterface for test

Having a separate NativeInterface facilitate to mock it and to not have
test relying on a uninitialized native

Bug: 295237486
Test: atest AvrcpControllerServiceTest
Test: atest AvrcpControllerStateMachineTest
Test: atest A2dpSinkStreamHandlerTest
Change-Id: I43b0ceeb9d6bf5b745686bd115da02b0c0be056c
parent a8c9d53a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1308,7 +1308,8 @@ static JNINativeMethod sMethods[] = {

int register_com_android_bluetooth_avrcp_controller(JNIEnv* env) {
  return jniRegisterNativeMethods(
      env, "com/android/bluetooth/avrcpcontroller/AvrcpControllerService",
      env,
      "com/android/bluetooth/avrcpcontroller/AvrcpControllerNativeInterface",
      sMethods, NELEM(sMethods));
}
}
+575 −0

File added.

Preview size limit exceeded, changes collapsed.

+45 −367

File changed.

Preview size limit exceeded, changes collapsed.

+49 −38

File changed.

Preview size limit exceeded, changes collapsed.

+4 −2
Original line number Diff line number Diff line
@@ -53,8 +53,8 @@ public class AvrcpBipClientTest {
    @Rule
    public final ServiceTestRule mBluetoothBrowserMediaServiceTestRule = new ServiceTestRule();

    @Mock
    private AdapterService mAdapterService;
    @Mock private AdapterService mAdapterService;
    @Mock private AvrcpControllerNativeInterface mNativeInterface;

    private BluetoothAdapter mAdapter;
    private BluetoothDevice mTestDevice;
@@ -67,6 +67,7 @@ public class AvrcpBipClientTest {
        MockitoAnnotations.initMocks(this);
        TestUtils.setAdapterService(mAdapterService);
        doReturn(true, false).when(mAdapterService).isStartedProfile(anyString());
        AvrcpControllerNativeInterface.setInstance(mNativeInterface);
        TestUtils.startService(mServiceRule, AvrcpControllerService.class);
        mService = AvrcpControllerService.getAvrcpControllerService();
        final Intent bluetoothBrowserMediaServiceStartIntent =
@@ -87,6 +88,7 @@ public class AvrcpBipClientTest {
    @After
    public void tearDown() throws Exception {
        TestUtils.stopService(mServiceRule, AvrcpControllerService.class);
        AvrcpControllerNativeInterface.setInstance(null);
        mService = AvrcpControllerService.getAvrcpControllerService();
        assertThat(mService).isNull();
        TestUtils.clearAdapterService(mAdapterService);
Loading