Loading android/app/src/com/android/bluetooth/hap/HapClientNativeInterface.java +2 −1 Original line number Diff line number Diff line Loading @@ -104,7 +104,8 @@ public class HapClientNativeInterface { return Utils.getBytesFromAddress(device.getAddress()); } private void sendMessageToService(HapClientStackEvent event) { @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) void sendMessageToService(HapClientStackEvent event) { HapClientService service = HapClientService.getHapClientService(); if (service != null) { service.messageFromNative(event); Loading android/app/tests/unit/src/com/android/bluetooth/csip/CsipSetCoordinatorServiceTest.java +12 −3 Original line number Diff line number Diff line Loading @@ -57,6 +57,8 @@ import org.mockito.MockitoAnnotations; @MediumTest @RunWith(AndroidJUnit4.class) public class CsipSetCoordinatorServiceTest { private final String mFlagDexmarker = System.getProperty("dexmaker.share_classloader", "false"); public final ServiceTestRule mServiceRule = new ServiceTestRule(); private Context mTargetContext; private BluetoothAdapter mAdapter; Loading @@ -73,11 +75,14 @@ public class CsipSetCoordinatorServiceTest { @Mock private AdapterService mAdapterService; @Mock private DatabaseManager mDatabaseManager; @Mock private CsipSetCoordinatorNativeInterface mCsipSetCoordinatorNativeInterface; @Mock private CsipSetCoordinatorService mCsipSetCoordinatorService; @Mock private IBluetoothCsipSetCoordinatorLockCallback mCsipSetCoordinatorLockCallback; @Before public void setUp() throws Exception { if (!mFlagDexmarker.equals("true")) { System.setProperty("dexmaker.share_classloader", "true"); } mTargetContext = InstrumentationRegistry.getTargetContext(); if (Looper.myLooper() == null) { Looper.prepare(); Loading Loading @@ -132,14 +137,18 @@ public class CsipSetCoordinatorServiceTest { @After public void tearDown() throws Exception { if (mService == null) { return; if (!mFlagDexmarker.equals("true")) { System.setProperty("dexmaker.share_classloader", mFlagDexmarker); } if (Looper.myLooper() == null) { return; } if (mService == null) { return; } stopService(); mTargetContext.unregisterReceiver(mCsipSetCoordinatorIntentReceiver); TestUtils.clearAdapterService(mAdapterService); Loading android/app/tests/unit/src/com/android/bluetooth/csip/CsipSetCoordinatorStateMachineTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,8 @@ import org.mockito.MockitoAnnotations; @MediumTest @RunWith(AndroidJUnit4.class) public class CsipSetCoordinatorStateMachineTest { private final String mFlagDexmarker = System.getProperty("dexmaker.share_classloader", "false"); private Context mTargetContext; private BluetoothAdapter mAdapter; private BluetoothDevice mTestDevice; Loading @@ -60,6 +62,10 @@ public class CsipSetCoordinatorStateMachineTest { @Before public void setUp() throws Exception { if (!mFlagDexmarker.equals("true")) { System.setProperty("dexmaker.share_classloader", "true"); } mTargetContext = InstrumentationRegistry.getTargetContext(); // Set up mocks and test assets MockitoAnnotations.initMocks(this); Loading @@ -83,6 +89,9 @@ public class CsipSetCoordinatorStateMachineTest { @After public void tearDown() throws Exception { if (!mFlagDexmarker.equals("true")) { System.setProperty("dexmaker.share_classloader", mFlagDexmarker); } mStateMachine.doQuit(); mHandlerThread.quit(); TestUtils.clearAdapterService(mAdapterService); Loading android/app/tests/unit/src/com/android/bluetooth/hap/HapClientTest.java +36 −3 Original line number Diff line number Diff line Loading @@ -66,6 +66,8 @@ import java.util.concurrent.TimeoutException; @MediumTest @RunWith(AndroidJUnit4.class) public class HapClientTest { private final String mFlagDexmarker = System.getProperty("dexmaker.share_classloader", "false"); private static final int TIMEOUT_MS = 1000; @Rule public final ServiceTestRule mServiceRule = new ServiceTestRule(); Loading Loading @@ -95,6 +97,10 @@ public class HapClientTest { @Before public void setUp() throws Exception { if (!mFlagDexmarker.equals("true")) { System.setProperty("dexmaker.share_classloader", "true"); } mTargetContext = InstrumentationRegistry.getTargetContext(); // Set up mocks and test assets MockitoAnnotations.initMocks(this); Loading Loading @@ -134,6 +140,21 @@ public class HapClientTest { mDevice3 = TestUtils.getTestDevice(mAdapter, 2); when(mNativeInterface.getDevice(getByteAddress(mDevice3))).thenReturn(mDevice3); doCallRealMethod().when(mNativeInterface) .sendMessageToService(any(HapClientStackEvent.class)); doCallRealMethod().when(mNativeInterface).onFeaturesUpdate(any(byte[].class), anyInt()); doCallRealMethod().when(mNativeInterface).onDeviceAvailable(any(byte[].class), anyInt()); doCallRealMethod().when(mNativeInterface) .onActivePresetSelected(any(byte[].class), anyInt()); doCallRealMethod().when(mNativeInterface) .onActivePresetSelectError(any(byte[].class), anyInt()); doCallRealMethod().when(mNativeInterface) .onPresetNameSetError(any(byte[].class), anyInt(), anyInt()); doCallRealMethod().when(mNativeInterface) .onPresetInfo(any(byte[].class), anyInt(), any(BluetoothHapPresetInfo[].class)); doCallRealMethod().when(mNativeInterface) .onGroupPresetNameSetError(anyInt(), anyInt(), anyInt()); /* Prepare CAS groups */ doReturn(Arrays.asList(0x02, 0x03)).when(mCsipService).getAllGroupIds(BluetoothUuid.CAP); Loading Loading @@ -170,6 +191,10 @@ public class HapClientTest { @After public void tearDown() throws Exception { if (!mFlagDexmarker.equals("true")) { System.setProperty("dexmaker.share_classloader", mFlagDexmarker); } if (mService == null) { return; } Loading @@ -177,10 +202,18 @@ public class HapClientTest { mService.mCallbacks.unregister(mCallback); stopService(); if (mHasIntentReceiver != null) { mTargetContext.unregisterReceiver(mHasIntentReceiver); } mAdapter = null; if (mAdapterService != null) { TestUtils.clearAdapterService(mAdapterService); } if (mIntentQueue != null) mIntentQueue.clear(); } Loading Loading
android/app/src/com/android/bluetooth/hap/HapClientNativeInterface.java +2 −1 Original line number Diff line number Diff line Loading @@ -104,7 +104,8 @@ public class HapClientNativeInterface { return Utils.getBytesFromAddress(device.getAddress()); } private void sendMessageToService(HapClientStackEvent event) { @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) void sendMessageToService(HapClientStackEvent event) { HapClientService service = HapClientService.getHapClientService(); if (service != null) { service.messageFromNative(event); Loading
android/app/tests/unit/src/com/android/bluetooth/csip/CsipSetCoordinatorServiceTest.java +12 −3 Original line number Diff line number Diff line Loading @@ -57,6 +57,8 @@ import org.mockito.MockitoAnnotations; @MediumTest @RunWith(AndroidJUnit4.class) public class CsipSetCoordinatorServiceTest { private final String mFlagDexmarker = System.getProperty("dexmaker.share_classloader", "false"); public final ServiceTestRule mServiceRule = new ServiceTestRule(); private Context mTargetContext; private BluetoothAdapter mAdapter; Loading @@ -73,11 +75,14 @@ public class CsipSetCoordinatorServiceTest { @Mock private AdapterService mAdapterService; @Mock private DatabaseManager mDatabaseManager; @Mock private CsipSetCoordinatorNativeInterface mCsipSetCoordinatorNativeInterface; @Mock private CsipSetCoordinatorService mCsipSetCoordinatorService; @Mock private IBluetoothCsipSetCoordinatorLockCallback mCsipSetCoordinatorLockCallback; @Before public void setUp() throws Exception { if (!mFlagDexmarker.equals("true")) { System.setProperty("dexmaker.share_classloader", "true"); } mTargetContext = InstrumentationRegistry.getTargetContext(); if (Looper.myLooper() == null) { Looper.prepare(); Loading Loading @@ -132,14 +137,18 @@ public class CsipSetCoordinatorServiceTest { @After public void tearDown() throws Exception { if (mService == null) { return; if (!mFlagDexmarker.equals("true")) { System.setProperty("dexmaker.share_classloader", mFlagDexmarker); } if (Looper.myLooper() == null) { return; } if (mService == null) { return; } stopService(); mTargetContext.unregisterReceiver(mCsipSetCoordinatorIntentReceiver); TestUtils.clearAdapterService(mAdapterService); Loading
android/app/tests/unit/src/com/android/bluetooth/csip/CsipSetCoordinatorStateMachineTest.java +9 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,8 @@ import org.mockito.MockitoAnnotations; @MediumTest @RunWith(AndroidJUnit4.class) public class CsipSetCoordinatorStateMachineTest { private final String mFlagDexmarker = System.getProperty("dexmaker.share_classloader", "false"); private Context mTargetContext; private BluetoothAdapter mAdapter; private BluetoothDevice mTestDevice; Loading @@ -60,6 +62,10 @@ public class CsipSetCoordinatorStateMachineTest { @Before public void setUp() throws Exception { if (!mFlagDexmarker.equals("true")) { System.setProperty("dexmaker.share_classloader", "true"); } mTargetContext = InstrumentationRegistry.getTargetContext(); // Set up mocks and test assets MockitoAnnotations.initMocks(this); Loading @@ -83,6 +89,9 @@ public class CsipSetCoordinatorStateMachineTest { @After public void tearDown() throws Exception { if (!mFlagDexmarker.equals("true")) { System.setProperty("dexmaker.share_classloader", mFlagDexmarker); } mStateMachine.doQuit(); mHandlerThread.quit(); TestUtils.clearAdapterService(mAdapterService); Loading
android/app/tests/unit/src/com/android/bluetooth/hap/HapClientTest.java +36 −3 Original line number Diff line number Diff line Loading @@ -66,6 +66,8 @@ import java.util.concurrent.TimeoutException; @MediumTest @RunWith(AndroidJUnit4.class) public class HapClientTest { private final String mFlagDexmarker = System.getProperty("dexmaker.share_classloader", "false"); private static final int TIMEOUT_MS = 1000; @Rule public final ServiceTestRule mServiceRule = new ServiceTestRule(); Loading Loading @@ -95,6 +97,10 @@ public class HapClientTest { @Before public void setUp() throws Exception { if (!mFlagDexmarker.equals("true")) { System.setProperty("dexmaker.share_classloader", "true"); } mTargetContext = InstrumentationRegistry.getTargetContext(); // Set up mocks and test assets MockitoAnnotations.initMocks(this); Loading Loading @@ -134,6 +140,21 @@ public class HapClientTest { mDevice3 = TestUtils.getTestDevice(mAdapter, 2); when(mNativeInterface.getDevice(getByteAddress(mDevice3))).thenReturn(mDevice3); doCallRealMethod().when(mNativeInterface) .sendMessageToService(any(HapClientStackEvent.class)); doCallRealMethod().when(mNativeInterface).onFeaturesUpdate(any(byte[].class), anyInt()); doCallRealMethod().when(mNativeInterface).onDeviceAvailable(any(byte[].class), anyInt()); doCallRealMethod().when(mNativeInterface) .onActivePresetSelected(any(byte[].class), anyInt()); doCallRealMethod().when(mNativeInterface) .onActivePresetSelectError(any(byte[].class), anyInt()); doCallRealMethod().when(mNativeInterface) .onPresetNameSetError(any(byte[].class), anyInt(), anyInt()); doCallRealMethod().when(mNativeInterface) .onPresetInfo(any(byte[].class), anyInt(), any(BluetoothHapPresetInfo[].class)); doCallRealMethod().when(mNativeInterface) .onGroupPresetNameSetError(anyInt(), anyInt(), anyInt()); /* Prepare CAS groups */ doReturn(Arrays.asList(0x02, 0x03)).when(mCsipService).getAllGroupIds(BluetoothUuid.CAP); Loading Loading @@ -170,6 +191,10 @@ public class HapClientTest { @After public void tearDown() throws Exception { if (!mFlagDexmarker.equals("true")) { System.setProperty("dexmaker.share_classloader", mFlagDexmarker); } if (mService == null) { return; } Loading @@ -177,10 +202,18 @@ public class HapClientTest { mService.mCallbacks.unregister(mCallback); stopService(); if (mHasIntentReceiver != null) { mTargetContext.unregisterReceiver(mHasIntentReceiver); } mAdapter = null; if (mAdapterService != null) { TestUtils.clearAdapterService(mAdapterService); } if (mIntentQueue != null) mIntentQueue.clear(); } Loading