Loading android/app/tests/unit/src/com/android/bluetooth/btservice/AdapterServiceTest.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -216,6 +216,8 @@ public class AdapterServiceTest { AsyncTask.setDefaultExecutor((r) -> { AsyncTask.setDefaultExecutor((r) -> { InstrumentationRegistry.getInstrumentation().runOnMainSync(r); InstrumentationRegistry.getInstrumentation().runOnMainSync(r); }); }); InstrumentationRegistry.getInstrumentation().getUiAutomation() .adoptShellPermissionIdentity(); InstrumentationRegistry.getInstrumentation().runOnMainSync( InstrumentationRegistry.getInstrumentation().runOnMainSync( () -> mAdapterService = new AdapterService()); () -> mAdapterService = new AdapterService()); Loading Loading @@ -243,6 +245,8 @@ public class AdapterServiceTest { mBluetoothManager = InstrumentationRegistry.getTargetContext() mBluetoothManager = InstrumentationRegistry.getTargetContext() .getSystemService(BluetoothManager.class); .getSystemService(BluetoothManager.class); when(mMockContext.getCacheDir()).thenReturn(InstrumentationRegistry.getTargetContext() .getCacheDir()); when(mMockContext.getApplicationInfo()).thenReturn(mMockApplicationInfo); when(mMockContext.getApplicationInfo()).thenReturn(mMockApplicationInfo); when(mMockContext.getContentResolver()).thenReturn(mMockContentResolver); when(mMockContext.getContentResolver()).thenReturn(mMockContentResolver); when(mMockContext.getApplicationContext()).thenReturn(mMockContext); when(mMockContext.getApplicationContext()).thenReturn(mMockContext); Loading android/app/tests/unit/src/com/android/bluetooth/tbs/TbsGattTest.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -108,6 +108,8 @@ public class TbsGattTest { Looper.prepare(); Looper.prepare(); } } getInstrumentation().getUiAutomation().adoptShellPermissionIdentity(); MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this); TestUtils.setAdapterService(mAdapterService); TestUtils.setAdapterService(mAdapterService); Loading android/app/tests/unit/src/com/android/bluetooth/tbs/TbsGenericTest.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -82,6 +82,8 @@ public class TbsGenericTest { mAdapter = BluetoothAdapter.getDefaultAdapter(); mAdapter = BluetoothAdapter.getDefaultAdapter(); mContext = getInstrumentation().getTargetContext(); mContext = getInstrumentation().getTargetContext(); getInstrumentation().getUiAutomation().adoptShellPermissionIdentity(); // Default TbsGatt mock behavior // Default TbsGatt mock behavior doReturn(true).when(mTbsGatt).init(mGtbsCcidCaptor.capture(), mGtbsUciCaptor.capture(), doReturn(true).when(mTbsGatt).init(mGtbsCcidCaptor.capture(), mGtbsUciCaptor.capture(), mDefaultGtbsUriSchemesCaptor.capture(), anyBoolean(), anyBoolean(), mDefaultGtbsUriSchemesCaptor.capture(), anyBoolean(), anyBoolean(), Loading android/app/tests/unit/src/com/android/bluetooth/telephony/BluetoothInCallServiceTest.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.telephony.TelephonyManager; import android.util.Log; import android.util.Log; import androidx.test.core.app.ApplicationProvider; import androidx.test.core.app.ApplicationProvider; import androidx.test.InstrumentationRegistry; import androidx.test.filters.MediumTest; import androidx.test.filters.MediumTest; import androidx.test.rule.ServiceTestRule; import androidx.test.rule.ServiceTestRule; import androidx.test.runner.AndroidJUnit4; import androidx.test.runner.AndroidJUnit4; Loading Loading @@ -120,6 +121,7 @@ public class BluetoothInCallServiceTest { @Before @Before public void setUp() throws Exception { public void setUp() throws Exception { MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this); InstrumentationRegistry.getInstrumentation().getUiAutomation().adoptShellPermissionIdentity(); // Create the service Intent. // Create the service Intent. Intent serviceIntent = Intent serviceIntent = Loading android/app/tests/unit/src/com/android/bluetooth/util/GsmAlphabetTest.java +8 −0 Original line number Original line Diff line number Diff line Loading @@ -18,8 +18,11 @@ package com.android.bluetooth.util; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat; import androidx.test.InstrumentationRegistry; import com.android.internal.telephony.uicc.IccUtils; import com.android.internal.telephony.uicc.IccUtils; import org.junit.Before; import org.junit.Test; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.junit.runners.JUnit4; Loading @@ -29,6 +32,11 @@ public final class GsmAlphabetTest { private static final String GSM_EXTENDED_CHARS = "{|}\\[~]\f\u20ac"; private static final String GSM_EXTENDED_CHARS = "{|}\\[~]\f\u20ac"; @Before public void setUp() throws Exception { InstrumentationRegistry.getInstrumentation().getUiAutomation().adoptShellPermissionIdentity(); } @Test @Test public void gsm7BitPackedToString() throws Exception { public void gsm7BitPackedToString() throws Exception { byte[] packed; byte[] packed; Loading Loading
android/app/tests/unit/src/com/android/bluetooth/btservice/AdapterServiceTest.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -216,6 +216,8 @@ public class AdapterServiceTest { AsyncTask.setDefaultExecutor((r) -> { AsyncTask.setDefaultExecutor((r) -> { InstrumentationRegistry.getInstrumentation().runOnMainSync(r); InstrumentationRegistry.getInstrumentation().runOnMainSync(r); }); }); InstrumentationRegistry.getInstrumentation().getUiAutomation() .adoptShellPermissionIdentity(); InstrumentationRegistry.getInstrumentation().runOnMainSync( InstrumentationRegistry.getInstrumentation().runOnMainSync( () -> mAdapterService = new AdapterService()); () -> mAdapterService = new AdapterService()); Loading Loading @@ -243,6 +245,8 @@ public class AdapterServiceTest { mBluetoothManager = InstrumentationRegistry.getTargetContext() mBluetoothManager = InstrumentationRegistry.getTargetContext() .getSystemService(BluetoothManager.class); .getSystemService(BluetoothManager.class); when(mMockContext.getCacheDir()).thenReturn(InstrumentationRegistry.getTargetContext() .getCacheDir()); when(mMockContext.getApplicationInfo()).thenReturn(mMockApplicationInfo); when(mMockContext.getApplicationInfo()).thenReturn(mMockApplicationInfo); when(mMockContext.getContentResolver()).thenReturn(mMockContentResolver); when(mMockContext.getContentResolver()).thenReturn(mMockContentResolver); when(mMockContext.getApplicationContext()).thenReturn(mMockContext); when(mMockContext.getApplicationContext()).thenReturn(mMockContext); Loading
android/app/tests/unit/src/com/android/bluetooth/tbs/TbsGattTest.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -108,6 +108,8 @@ public class TbsGattTest { Looper.prepare(); Looper.prepare(); } } getInstrumentation().getUiAutomation().adoptShellPermissionIdentity(); MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this); TestUtils.setAdapterService(mAdapterService); TestUtils.setAdapterService(mAdapterService); Loading
android/app/tests/unit/src/com/android/bluetooth/tbs/TbsGenericTest.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -82,6 +82,8 @@ public class TbsGenericTest { mAdapter = BluetoothAdapter.getDefaultAdapter(); mAdapter = BluetoothAdapter.getDefaultAdapter(); mContext = getInstrumentation().getTargetContext(); mContext = getInstrumentation().getTargetContext(); getInstrumentation().getUiAutomation().adoptShellPermissionIdentity(); // Default TbsGatt mock behavior // Default TbsGatt mock behavior doReturn(true).when(mTbsGatt).init(mGtbsCcidCaptor.capture(), mGtbsUciCaptor.capture(), doReturn(true).when(mTbsGatt).init(mGtbsCcidCaptor.capture(), mGtbsUciCaptor.capture(), mDefaultGtbsUriSchemesCaptor.capture(), anyBoolean(), anyBoolean(), mDefaultGtbsUriSchemesCaptor.capture(), anyBoolean(), anyBoolean(), Loading
android/app/tests/unit/src/com/android/bluetooth/telephony/BluetoothInCallServiceTest.java +2 −0 Original line number Original line Diff line number Diff line Loading @@ -39,6 +39,7 @@ import android.telephony.TelephonyManager; import android.util.Log; import android.util.Log; import androidx.test.core.app.ApplicationProvider; import androidx.test.core.app.ApplicationProvider; import androidx.test.InstrumentationRegistry; import androidx.test.filters.MediumTest; import androidx.test.filters.MediumTest; import androidx.test.rule.ServiceTestRule; import androidx.test.rule.ServiceTestRule; import androidx.test.runner.AndroidJUnit4; import androidx.test.runner.AndroidJUnit4; Loading Loading @@ -120,6 +121,7 @@ public class BluetoothInCallServiceTest { @Before @Before public void setUp() throws Exception { public void setUp() throws Exception { MockitoAnnotations.initMocks(this); MockitoAnnotations.initMocks(this); InstrumentationRegistry.getInstrumentation().getUiAutomation().adoptShellPermissionIdentity(); // Create the service Intent. // Create the service Intent. Intent serviceIntent = Intent serviceIntent = Loading
android/app/tests/unit/src/com/android/bluetooth/util/GsmAlphabetTest.java +8 −0 Original line number Original line Diff line number Diff line Loading @@ -18,8 +18,11 @@ package com.android.bluetooth.util; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertThat; import androidx.test.InstrumentationRegistry; import com.android.internal.telephony.uicc.IccUtils; import com.android.internal.telephony.uicc.IccUtils; import org.junit.Before; import org.junit.Test; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; import org.junit.runners.JUnit4; Loading @@ -29,6 +32,11 @@ public final class GsmAlphabetTest { private static final String GSM_EXTENDED_CHARS = "{|}\\[~]\f\u20ac"; private static final String GSM_EXTENDED_CHARS = "{|}\\[~]\f\u20ac"; @Before public void setUp() throws Exception { InstrumentationRegistry.getInstrumentation().getUiAutomation().adoptShellPermissionIdentity(); } @Test @Test public void gsm7BitPackedToString() throws Exception { public void gsm7BitPackedToString() throws Exception { byte[] packed; byte[] packed; Loading