summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-03-28 20:15:27 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-03-28 20:15:27 +0000
commitf46fba259c7358c8d1d938dfe51d00bdafda55eb (patch)
tree3361b8fe80d5237fe88507b7a482b10b075848a5
parentba21a09f7a3bb1531855cf6f9b2ccbc7a4d93a20 (diff)
parent9b64856d704a05dc2b72f4898b96de5dbefc8793 (diff)
downloadcts-f46fba259c7358c8d1d938dfe51d00bdafda55eb.tar.gz
Snap for 9831766 from 9b64856d704a05dc2b72f4898b96de5dbefc8793 to android12L-tests-release
Change-Id: Ia26cfc838d2da2b712095e58dfb1a745ee900273
-rw-r--r--tests/tests/bluetooth/src/android/bluetooth/cts/AdvertiseCallbackTest.java19
-rw-r--r--tests/tests/bluetooth/src/android/bluetooth/cts/AdvertiseDataTest.java39
-rw-r--r--tests/tests/bluetooth/src/android/bluetooth/cts/AdvertiseSettingsTest.java25
-rw-r--r--tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioTest.java32
-rw-r--r--tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeScanTest.java26
-rw-r--r--tests/tests/bluetooth/src/android/bluetooth/cts/HearingAidProfileTest.java31
-rw-r--r--tests/tests/bluetooth/src/android/bluetooth/cts/LeL2capSocketTest.java19
-rw-r--r--tests/tests/bluetooth/src/android/bluetooth/cts/OobDataTest.java10
-rw-r--r--tests/tests/bluetooth/src/android/bluetooth/cts/ScanCallbackTest.java24
-rw-r--r--tests/tests/bluetooth/src/android/bluetooth/cts/ScanFilterTest.java50
-rw-r--r--tests/tests/bluetooth/src/android/bluetooth/cts/ScanRecordTest.java3
-rw-r--r--tests/tests/bluetooth/src/android/bluetooth/cts/ScanResultTest.java27
-rw-r--r--tests/tests/bluetooth/src/android/bluetooth/cts/ScanSettingsTest.java23
-rw-r--r--tests/tests/view/AndroidManifest.xml2
-rw-r--r--tests/tests/view/res/values/styles.xml4
15 files changed, 265 insertions, 69 deletions
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/AdvertiseCallbackTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/AdvertiseCallbackTest.java
index 1c68022120b..54e876779c1 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/AdvertiseCallbackTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/AdvertiseCallbackTest.java
@@ -34,15 +34,30 @@ public class AdvertiseCallbackTest extends AndroidTestCase {
private final MockAdvertiser mMockAdvertiser = new MockAdvertiser();
private final BleAdvertiseCallback mAdvertiseCallback = new BleAdvertiseCallback();
+ private boolean mHasBluetoothLe;
+
+ @Override
+ protected void setUp() {
+ mHasBluetoothLe = TestUtils.isBleSupported(getContext());
+ if (!mHasBluetoothLe) {
+ return;
+ }
+ }
@SmallTest
public void testAdvertiseSuccess() {
+ if (shouldSkipTest()) {
+ return;
+ }
mAdvertiseCallback.mAdvertiseType = ADVERTISE_TYPE_SUCCESS;
mMockAdvertiser.startAdvertise(mAdvertiseCallback);
}
@SmallTest
public void testAdvertiseFailure() {
+ if (shouldSkipTest()) {
+ return;
+ }
mAdvertiseCallback.mAdvertiseType = ADVERTISE_TYPE_SUCCESS;
mMockAdvertiser.startAdvertise(mAdvertiseCallback);
@@ -51,6 +66,10 @@ public class AdvertiseCallbackTest extends AndroidTestCase {
mMockAdvertiser.startAdvertise(mAdvertiseCallback);
}
+ private boolean shouldSkipTest() {
+ return !mHasBluetoothLe;
+ }
+
// A mock advertiser which emulate BluetoothLeAdvertiser behavior.
private static class MockAdvertiser {
private Set<AdvertiseCallback> mCallbacks = new HashSet<>();
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/AdvertiseDataTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/AdvertiseDataTest.java
index 54ca1a692cc..4878f21efb6 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/AdvertiseDataTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/AdvertiseDataTest.java
@@ -31,14 +31,22 @@ import android.test.suitebuilder.annotation.SmallTest;
public class AdvertiseDataTest extends AndroidTestCase {
private AdvertiseData.Builder mAdvertiseDataBuilder;
+ private boolean mHasBluetoothLe;
@Override
protected void setUp() {
+ mHasBluetoothLe = TestUtils.isBleSupported(getContext());
+ if (!mHasBluetoothLe) {
+ return;
+ }
mAdvertiseDataBuilder = new AdvertiseData.Builder();
}
@SmallTest
public void testEmptyData() {
+ if (shouldSkipTest()) {
+ return;
+ }
Parcel parcel = Parcel.obtain();
AdvertiseData data = mAdvertiseDataBuilder.build();
data.writeToParcel(parcel, 0);
@@ -55,6 +63,9 @@ public class AdvertiseDataTest extends AndroidTestCase {
@SmallTest
public void testEmptyServiceUuid() {
+ if (shouldSkipTest()) {
+ return;
+ }
Parcel parcel = Parcel.obtain();
AdvertiseData data = mAdvertiseDataBuilder.setIncludeDeviceName(true).build();
data.writeToParcel(parcel, 0);
@@ -68,6 +79,9 @@ public class AdvertiseDataTest extends AndroidTestCase {
@SmallTest
public void testEmptyManufacturerData() {
+ if (shouldSkipTest()) {
+ return;
+ }
Parcel parcel = Parcel.obtain();
int manufacturerId = 50;
byte[] manufacturerData = new byte[0];
@@ -84,6 +98,9 @@ public class AdvertiseDataTest extends AndroidTestCase {
@SmallTest
public void testEmptyServiceData() {
+ if (shouldSkipTest()) {
+ return;
+ }
Parcel parcel = Parcel.obtain();
ParcelUuid uuid = ParcelUuid.fromString("0000110A-0000-1000-8000-00805F9B34FB");
byte[] serviceData = new byte[0];
@@ -100,6 +117,9 @@ public class AdvertiseDataTest extends AndroidTestCase {
@SmallTest
public void testServiceUuid() {
+ if (shouldSkipTest()) {
+ return;
+ }
Parcel parcel = Parcel.obtain();
ParcelUuid uuid = ParcelUuid.fromString("0000110A-0000-1000-8000-00805F9B34FB");
ParcelUuid uuid2 = ParcelUuid.fromString("0000110B-0000-1000-8000-00805F9B34FB");
@@ -118,6 +138,9 @@ public class AdvertiseDataTest extends AndroidTestCase {
@SmallTest
public void testServiceSolicitationUuids() {
+ if (shouldSkipTest()) {
+ return;
+ }
AdvertiseData emptyData = mAdvertiseDataBuilder.build();
assertEquals(0, emptyData.getServiceSolicitationUuids().size());
@@ -139,6 +162,9 @@ public class AdvertiseDataTest extends AndroidTestCase {
@SmallTest
public void testManufacturerData() {
+ if (shouldSkipTest()) {
+ return;
+ }
Parcel parcel = Parcel.obtain();
ParcelUuid uuid = ParcelUuid.fromString("0000110A-0000-1000-8000-00805F9B34FB");
ParcelUuid uuid2 = ParcelUuid.fromString("0000110B-0000-1000-8000-00805F9B34FB");
@@ -162,6 +188,9 @@ public class AdvertiseDataTest extends AndroidTestCase {
@SmallTest
public void testServiceData() {
+ if (shouldSkipTest()) {
+ return;
+ }
Parcel parcel = Parcel.obtain();
ParcelUuid uuid = ParcelUuid.fromString("0000110A-0000-1000-8000-00805F9B34FB");
byte[] serviceData = new byte[] {
@@ -179,6 +208,9 @@ public class AdvertiseDataTest extends AndroidTestCase {
@SmallTest
public void testIncludeTxPower() {
+ if (shouldSkipTest()) {
+ return;
+ }
Parcel parcel = Parcel.obtain();
AdvertiseData data = mAdvertiseDataBuilder.setIncludeTxPowerLevel(true).build();
data.writeToParcel(parcel, 0);
@@ -190,7 +222,14 @@ public class AdvertiseDataTest extends AndroidTestCase {
@SmallTest
public void testDescribeContents() {
+ if (shouldSkipTest()) {
+ return;
+ }
AdvertiseData data = new AdvertiseData.Builder().build();
assertEquals(0, data.describeContents());
}
+
+ private boolean shouldSkipTest() {
+ return !mHasBluetoothLe;
+ }
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/AdvertiseSettingsTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/AdvertiseSettingsTest.java
index 19b7c290357..3431b09c129 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/AdvertiseSettingsTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/AdvertiseSettingsTest.java
@@ -26,8 +26,21 @@ import android.test.suitebuilder.annotation.SmallTest;
*/
public class AdvertiseSettingsTest extends AndroidTestCase {
+ private boolean mHasBluetoothLe;
+
+ @Override
+ protected void setUp() {
+ mHasBluetoothLe = TestUtils.isBleSupported(getContext());
+ if (!mHasBluetoothLe) {
+ return;
+ }
+ }
+
@SmallTest
public void testDefaultSettings() {
+ if (shouldSkipTest()) {
+ return;
+ }
AdvertiseSettings settings = new AdvertiseSettings.Builder().build();
assertEquals(AdvertiseSettings.ADVERTISE_MODE_LOW_POWER, settings.getMode());
assertEquals(AdvertiseSettings.ADVERTISE_TX_POWER_MEDIUM, settings.getTxPowerLevel());
@@ -37,12 +50,18 @@ public class AdvertiseSettingsTest extends AndroidTestCase {
@SmallTest
public void testDescribeContents() {
+ if (shouldSkipTest()) {
+ return;
+ }
AdvertiseSettings settings = new AdvertiseSettings.Builder().build();
assertEquals(0, settings.describeContents());
}
@SmallTest
public void testReadWriteParcel() {
+ if (shouldSkipTest()) {
+ return;
+ }
final int timeoutMillis = 60 * 1000;
Parcel parcel = Parcel.obtain();
AdvertiseSettings settings = new AdvertiseSettings.Builder()
@@ -63,6 +82,9 @@ public class AdvertiseSettingsTest extends AndroidTestCase {
@SmallTest
public void testIllegalTimeout() {
+ if (shouldSkipTest()) {
+ return;
+ }
AdvertiseSettings.Builder builder = new AdvertiseSettings.Builder();
builder.setTimeout(0).build();
builder.setTimeout(180 * 1000).build();
@@ -80,6 +102,9 @@ public class AdvertiseSettingsTest extends AndroidTestCase {
} catch (IllegalArgumentException e) {
// nothing to do.
}
+ }
+ private boolean shouldSkipTest() {
+ return !mHasBluetoothLe;
}
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioTest.java
index 24bcafb79f8..683612cf34d 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeAudioTest.java
@@ -21,7 +21,6 @@ import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothLeAudio;
import android.bluetooth.BluetoothManager;
import android.bluetooth.BluetoothProfile;
-import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.Build;
import android.test.AndroidTestCase;
@@ -41,7 +40,7 @@ public class BluetoothLeAudioTest extends AndroidTestCase {
private static final String PROFILE_SUPPORTED_LE_AUDIO = "profile_supported_leaudio";
private static final int LE_AUDIO_PROFILE_CONSTANT = 22;
- private boolean mHasBluetooth;
+ private boolean mHasBluetoothLe;
private BluetoothAdapter mAdapter;
private BluetoothLeAudio mBluetoothLeAudio;
@@ -54,10 +53,10 @@ public class BluetoothLeAudioTest extends AndroidTestCase {
public void setUp() throws Exception {
super.setUp();
if (ApiLevelUtil.isAtLeast(Build.VERSION_CODES.S)) {
- mHasBluetooth = getContext().getPackageManager().hasSystemFeature(
- PackageManager.FEATURE_BLUETOOTH);
-
- if (!mHasBluetooth) return;
+ mHasBluetoothLe = TestUtils.isBleSupported(getContext());
+ if (!mHasBluetoothLe) {
+ return;
+ }
BluetoothManager manager = getContext().getSystemService(BluetoothManager.class);
mAdapter = manager.getAdapter();
assertTrue(BTAdapterUtils.enableAdapter(mAdapter, mContext));
@@ -83,7 +82,7 @@ public class BluetoothLeAudioTest extends AndroidTestCase {
@Override
public void tearDown() throws Exception {
super.tearDown();
- if (mHasBluetooth) {
+ if (mHasBluetoothLe) {
if (mAdapter != null && mBluetoothLeAudio != null) {
mBluetoothLeAudio.close();
mBluetoothLeAudio = null;
@@ -95,8 +94,9 @@ public class BluetoothLeAudioTest extends AndroidTestCase {
}
public void testGetConnectedDevices() {
- if (!(mHasBluetooth && mIsLeAudioSupported)) return;
-
+ if (shouldSkipTest()) {
+ return;
+ }
assertTrue(waitForProfileConnect());
assertNotNull(mBluetoothLeAudio);
@@ -108,8 +108,9 @@ public class BluetoothLeAudioTest extends AndroidTestCase {
}
public void testGetDevicesMatchingConnectionStates() {
- if (!(mHasBluetooth && mIsLeAudioSupported)) return;
-
+ if (shouldSkipTest()) {
+ return;
+ }
assertTrue(waitForProfileConnect());
assertNotNull(mBluetoothLeAudio);
@@ -122,8 +123,9 @@ public class BluetoothLeAudioTest extends AndroidTestCase {
}
public void testGetConnectionState() {
- if (!(mHasBluetooth && mIsLeAudioSupported)) return;
-
+ if (shouldSkipTest()) {
+ return;
+ }
assertTrue(waitForProfileConnect());
assertNotNull(mBluetoothLeAudio);
@@ -179,4 +181,8 @@ public class BluetoothLeAudioTest extends AndroidTestCase {
public void onServiceDisconnected(int profile) {
}
}
+
+ private boolean shouldSkipTest() {
+ return !(mHasBluetoothLe && mIsLeAudioSupported);
+ }
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeScanTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeScanTest.java
index 1036095c26a..26b2f88af43 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeScanTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothLeScanTest.java
@@ -68,12 +68,14 @@ public class BluetoothLeScanTest extends AndroidTestCase {
private BluetoothAdapter mBluetoothAdapter;
private BluetoothLeScanner mScanner;
+ private boolean mHasBluetoothLe;
// Whether location is on before running the tests.
private boolean mLocationOn;
@Override
public void setUp() {
- if (!TestUtils.isBleSupported(getContext())) {
+ mHasBluetoothLe = TestUtils.isBleSupported(getContext());
+ if (!mHasBluetoothLe) {
return;
}
BluetoothManager manager = (BluetoothManager) mContext.getSystemService(
@@ -93,9 +95,8 @@ public class BluetoothLeScanTest extends AndroidTestCase {
@Override
public void tearDown() {
- if (!TestUtils.isBleSupported(getContext())) {
- // mBluetoothAdapter == null.
- return;
+ if (!mHasBluetoothLe) {
+ return;
}
if (!mLocationOn) {
@@ -109,7 +110,7 @@ public class BluetoothLeScanTest extends AndroidTestCase {
*/
@MediumTest
public void testBasicBleScan() {
- if (!TestUtils.isBleSupported(getContext())) {
+ if (shouldSkipTest()) {
return;
}
long scanStartMillis = SystemClock.elapsedRealtime();
@@ -126,10 +127,9 @@ public class BluetoothLeScanTest extends AndroidTestCase {
*/
@MediumTest
public void testScanFilter() {
- if (!TestUtils.isBleSupported(getContext())) {
+ if (shouldSkipTest()) {
return;
}
-
List<ScanFilter> filters = new ArrayList<ScanFilter>();
ScanFilter filter = createScanFilter();
if (filter == null) {
@@ -190,7 +190,7 @@ public class BluetoothLeScanTest extends AndroidTestCase {
// */
// @MediumTest
// public void testOpportunisticScan() {
-// if (!TestUtils.isBleSupported(getContext())) {
+// if (shouldSkipTest()) {
// return;
// }
// ScanSettings opportunisticScanSettings = new ScanSettings.Builder()
@@ -240,7 +240,7 @@ public class BluetoothLeScanTest extends AndroidTestCase {
*/
@MediumTest
public void testBatchScan() {
- if (!TestUtils.isBleSupported(getContext()) || !isBleBatchScanSupported()) {
+ if (shouldSkipTest() || !isBleBatchScanSupported()) {
Log.d(TAG, "BLE or BLE batching not suppported");
return;
}
@@ -271,7 +271,7 @@ public class BluetoothLeScanTest extends AndroidTestCase {
*/
@MediumTest
public void testStartScanPendingIntent_nullnull() throws Exception {
- if (!TestUtils.isBleSupported(getContext()) || !isBleBatchScanSupported()) {
+ if (shouldSkipTest() || !isBleBatchScanSupported()) {
Log.d(TAG, "BLE or BLE batching not suppported");
return;
}
@@ -291,7 +291,7 @@ public class BluetoothLeScanTest extends AndroidTestCase {
*/
@MediumTest
public void testStartScanPendingIntent() throws Exception {
- if (!TestUtils.isBleSupported(getContext()) || !isBleBatchScanSupported()) {
+ if (shouldSkipTest() || !isBleBatchScanSupported()) {
Log.d(TAG, "BLE or BLE batching not suppported");
return;
}
@@ -329,6 +329,10 @@ public class BluetoothLeScanTest extends AndroidTestCase {
}
}
+ private boolean shouldSkipTest() {
+ return !mHasBluetoothLe;
+ }
+
// Helper class for BLE scan callback.
private class BleScanCallback extends ScanCallback {
private Set<ScanResult> mResults = new HashSet<ScanResult>();
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/HearingAidProfileTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/HearingAidProfileTest.java
index 4e1419acbe4..b36b2020dfb 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/HearingAidProfileTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/HearingAidProfileTest.java
@@ -56,8 +56,8 @@ public class HearingAidProfileTest extends AndroidTestCase {
// AdapterState.BREDR_STOP_TIMEOUT_DELAY
private static final int ADAPTER_DISABLE_TIMEOUT_MS = 5000;
+ private boolean mHasBluetoothLe;
private boolean mIsHearingAidSupported;
- private boolean mIsBleSupported;
private BluetoothHearingAid mService;
private BluetoothAdapter mBluetoothAdapter;
private BroadcastReceiver mIntentReceiver;
@@ -73,8 +73,10 @@ public class HearingAidProfileTest extends AndroidTestCase {
private List<BluetoothDevice> mIntentCallbackDeviceList;
public void setUp() throws Exception {
- if (!isBleSupported()) return;
- mIsBleSupported = true;
+ mHasBluetoothLe = TestUtils.isBleSupported(mContext);
+ if (!mHasBluetoothLe) {
+ return;
+ }
BluetoothManager manager = (BluetoothManager) mContext.getSystemService(
Context.BLUETOOTH_SERVICE);
@@ -97,7 +99,9 @@ public class HearingAidProfileTest extends AndroidTestCase {
@Override
public void tearDown() {
- if (!mIsBleSupported) return;
+ if (shouldSkipTest()) {
+ return;
+ }
if (!BTAdapterUtils.disableAdapter(mBluetoothAdapter, mContext)) {
Log.e(TAG, "Unable to disable Bluetooth Adapter!");
@@ -110,8 +114,9 @@ public class HearingAidProfileTest extends AndroidTestCase {
*/
@MediumTest
public void test_getProxyServiceConnect() {
- if (!(mIsBleSupported && mIsHearingAidSupported)) return;
-
+ if (shouldSkipTest()) {
+ return;
+ }
waitForProfileConnect();
assertTrue(mIsProfileReady);
assertNotNull(mService);
@@ -122,7 +127,7 @@ public class HearingAidProfileTest extends AndroidTestCase {
*/
@MediumTest
public void test_getConnectionState() {
- if (!(mIsBleSupported && mIsHearingAidSupported)) {
+ if (shouldSkipTest()) {
return;
}
@@ -144,7 +149,7 @@ public class HearingAidProfileTest extends AndroidTestCase {
*/
@MediumTest
public void test_getConnectedDevices() {
- if (!(mIsBleSupported && mIsHearingAidSupported)) {
+ if (shouldSkipTest()) {
return;
}
@@ -168,7 +173,7 @@ public class HearingAidProfileTest extends AndroidTestCase {
*/
@MediumTest
public void test_getDevicesMatchingConnectionStates() {
- if (!(mIsBleSupported && mIsHearingAidSupported)) {
+ if (shouldSkipTest()) {
return;
}
@@ -193,7 +198,7 @@ public class HearingAidProfileTest extends AndroidTestCase {
*/
@MediumTest
public void test_getConnectionStateChangedIntent() {
- if (!(mIsBleSupported && mIsHearingAidSupported)) {
+ if (shouldSkipTest()) {
return;
}
@@ -327,10 +332,8 @@ public class HearingAidProfileTest extends AndroidTestCase {
return mBluetoothAdapter.isOffloadedScanBatchingSupported();
}
- // Check if Bluetooth LE feature is supported on DUT.
- private boolean isBleSupported() {
- return getContext().getPackageManager()
- .hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE);
+ private boolean shouldSkipTest() {
+ return !(mHasBluetoothLe && mIsHearingAidSupported);
}
private static void sleep(long t) {
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/LeL2capSocketTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/LeL2capSocketTest.java
index b9a93a18576..54ba63ef2d0 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/LeL2capSocketTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/LeL2capSocketTest.java
@@ -29,10 +29,13 @@ public class LeL2capSocketTest extends AndroidTestCase {
private BluetoothAdapter mAdapter = null;
+ private boolean mHasBluetoothLe;
+
@Override
public void setUp() throws Exception {
super.setUp();
- if (!TestUtils.isBleSupported(getContext())) {
+ mHasBluetoothLe = TestUtils.isBleSupported(getContext());
+ if (!mHasBluetoothLe) {
return;
}
mAdapter = BluetoothAdapter.getDefaultAdapter();
@@ -45,7 +48,7 @@ public class LeL2capSocketTest extends AndroidTestCase {
@Override
public void tearDown() throws Exception {
- if (!TestUtils.isBleSupported(getContext())) {
+ if (!mHasBluetoothLe) {
return;
}
assertTrue(BTAdapterUtils.disableAdapter(mAdapter, mContext));
@@ -56,7 +59,7 @@ public class LeL2capSocketTest extends AndroidTestCase {
@SmallTest
public void testOpenInsecureLeL2capServerSocketOnce() {
- if (!TestUtils.isBleSupported(getContext())) {
+ if (shouldSkipTest()) {
return;
}
assertTrue("Bluetooth is not enabled", mAdapter.isEnabled());
@@ -71,7 +74,7 @@ public class LeL2capSocketTest extends AndroidTestCase {
@SmallTest
public void testOpenInsecureLeL2capServerSocketRepeatedly() {
- if (!TestUtils.isBleSupported(getContext())) {
+ if (shouldSkipTest()) {
return;
}
assertTrue("Bluetooth is not enabled", mAdapter.isEnabled());
@@ -89,7 +92,7 @@ public class LeL2capSocketTest extends AndroidTestCase {
@SmallTest
public void testOpenSecureLeL2capServerSocketOnce() {
- if (!TestUtils.isBleSupported(getContext())) {
+ if (shouldSkipTest()) {
return;
}
assertTrue("Bluetooth is not enabled", mAdapter.isEnabled());
@@ -104,7 +107,7 @@ public class LeL2capSocketTest extends AndroidTestCase {
@SmallTest
public void testOpenSecureLeL2capServerSocketRepeatedly() {
- if (!TestUtils.isBleSupported(getContext())) {
+ if (shouldSkipTest()) {
return;
}
assertTrue("Bluetooth is not enabled", mAdapter.isEnabled());
@@ -118,4 +121,8 @@ public class LeL2capSocketTest extends AndroidTestCase {
fail("IOException while opening and closing server socket: " + exp);
}
}
+
+ private boolean shouldSkipTest() {
+ return !mHasBluetoothLe;
+ }
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/OobDataTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/OobDataTest.java
index 40d5c3f0bb7..bc3569bfc32 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/OobDataTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/OobDataTest.java
@@ -22,20 +22,23 @@ import android.bluetooth.OobData;
import android.content.pm.PackageManager;
import android.test.AndroidTestCase;
-import java.util.Arrays;
-
public class OobDataTest extends AndroidTestCase {
private boolean mHasBluetooth;
+ private boolean mHasBluetoothLe;
@Override
public void setUp() throws Exception {
super.setUp();
mHasBluetooth = getContext().getPackageManager().hasSystemFeature(
PackageManager.FEATURE_BLUETOOTH);
+ mHasBluetoothLe = TestUtils.isBleSupported(getContext());
}
public void testClassicBuilder() {
+ if (!mHasBluetooth) {
+ return;
+ }
byte[] defaultRandomizerHash = new byte[OobData.RANDOMIZER_OCTETS];
byte[] defaultClassOfDevice = new byte[OobData.CLASS_OF_DEVICE_OCTETS];
// Default device name: "Bluetooth Device"
@@ -106,6 +109,9 @@ public class OobDataTest extends AndroidTestCase {
}
public void testLEBuilder() {
+ if (!mHasBluetoothLe) {
+ return;
+ }
byte[] defaultRandomizerHash = new byte[OobData.RANDOMIZER_OCTETS];
byte[] defaultClassOfDevice = new byte[OobData.CLASS_OF_DEVICE_OCTETS];
byte[] defaultClassicLength = new byte[OobData.OOB_LENGTH_OCTETS];
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/ScanCallbackTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/ScanCallbackTest.java
index f447f1070db..263f536bdfa 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/ScanCallbackTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/ScanCallbackTest.java
@@ -39,14 +39,30 @@ public class ScanCallbackTest extends AndroidTestCase {
private MockScanner mMockScanner = new MockScanner();
private BleScanCallback mMockScanCallback = new BleScanCallback();
+ private boolean mHasBluetoothLe;
+
+ @Override
+ public void setUp() {
+ mHasBluetoothLe = TestUtils.isBleSupported(getContext());
+ if (!mHasBluetoothLe) {
+ return;
+ }
+ }
+
@SmallTest
public void testScanSuccess() {
+ if (shouldSkipTest()) {
+ return;
+ }
mMockScanCallback.mScanType = SCAN_TYPE_SUCCESS;
mMockScanner.startScan(new ScanSettings.Builder().build(), mMockScanCallback);
}
@SmallTest
public void testBatchScans() {
+ if (shouldSkipTest()) {
+ return;
+ }
ScanSettings settings = new ScanSettings.Builder().setReportDelay(1000).build();
mMockScanCallback.mScanType = SCAN_TYPE_BATCH;
mMockScanner.startScan(settings, mMockScanCallback);
@@ -54,6 +70,9 @@ public class ScanCallbackTest extends AndroidTestCase {
@SmallTest
public void testScanFail() {
+ if (shouldSkipTest()) {
+ return;
+ }
ScanSettings settings = new ScanSettings.Builder().build();
// The first scan is success.
mMockScanCallback.mScanType = SCAN_TYPE_SUCCESS;
@@ -63,6 +82,10 @@ public class ScanCallbackTest extends AndroidTestCase {
mMockScanner.startScan(settings, mMockScanCallback);
}
+ private boolean shouldSkipTest() {
+ return !mHasBluetoothLe;
+ }
+
// A mock scanner for mocking BLE scanner functionalities.
private static class MockScanner {
private Set<ScanCallback> mCallbacks = new HashSet<>();
@@ -106,6 +129,5 @@ public class ScanCallbackTest extends AndroidTestCase {
fail("scan should not fail");
}
}
-
}
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/ScanFilterTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/ScanFilterTest.java
index df1bb163f89..3bcb28c71c3 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/ScanFilterTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/ScanFilterTest.java
@@ -42,9 +42,14 @@ public class ScanFilterTest extends AndroidTestCase {
private ScanResult mScanResult;
private ScanFilter.Builder mFilterBuilder;
+ private boolean mHasBluetoothLe;
@Override
protected void setUp() {
+ mHasBluetoothLe = TestUtils.isBleSupported(getContext());
+ if (!mHasBluetoothLe) {
+ return;
+ }
byte[] scanRecord = new byte[] {
0x02, 0x01, 0x1a, // advertising flags
0x05, 0x02, 0x0b, 0x11, 0x0a, 0x11, // 16 bit service uuids
@@ -73,8 +78,9 @@ public class ScanFilterTest extends AndroidTestCase {
@SmallTest
public void testsetNameFilter() {
- if (mFilterBuilder == null) return;
-
+ if (shouldSkipTest()) {
+ return;
+ }
ScanFilter filter = mFilterBuilder.setDeviceName(LOCAL_NAME).build();
assertEquals(LOCAL_NAME, filter.getDeviceName());
assertTrue("setName filter fails", filter.matches(mScanResult));
@@ -85,8 +91,9 @@ public class ScanFilterTest extends AndroidTestCase {
@SmallTest
public void testDeviceAddressFilter() {
- if (mFilterBuilder == null) return;
-
+ if (shouldSkipTest()) {
+ return;
+ }
ScanFilter filter = mFilterBuilder.setDeviceAddress(DEVICE_MAC).build();
assertEquals(DEVICE_MAC, filter.getDeviceAddress());
assertTrue("device filter fails", filter.matches(mScanResult));
@@ -97,8 +104,9 @@ public class ScanFilterTest extends AndroidTestCase {
@SmallTest
public void testsetServiceUuidFilter() {
- if (mFilterBuilder == null) return;
-
+ if (shouldSkipTest()) {
+ return;
+ }
ScanFilter filter = mFilterBuilder.setServiceUuid(
ParcelUuid.fromString(UUID1)).build();
assertEquals(UUID1, filter.getServiceUuid().toString());
@@ -120,8 +128,9 @@ public class ScanFilterTest extends AndroidTestCase {
@SmallTest
public void testsetServiceSolicitationUuidFilter() {
- if (mFilterBuilder == null) return;
-
+ if (shouldSkipTest()) {
+ return;
+ }
ScanFilter filter = mFilterBuilder.setServiceSolicitationUuid(
ParcelUuid.fromString(UUID1)).build();
assertEquals(UUID1, filter.getServiceSolicitationUuid().toString());
@@ -142,8 +151,9 @@ public class ScanFilterTest extends AndroidTestCase {
@SmallTest
public void testsetServiceDataFilter() {
- if (mFilterBuilder == null) return;
-
+ if (shouldSkipTest()) {
+ return;
+ }
byte[] setServiceData = new byte[] {
0x50, 0x64 };
ParcelUuid serviceDataUuid = ParcelUuid.fromString(UUID2);
@@ -175,8 +185,9 @@ public class ScanFilterTest extends AndroidTestCase {
@SmallTest
public void testManufacturerSpecificData() {
- if (mFilterBuilder == null) return;
-
+ if (shouldSkipTest()) {
+ return;
+ }
byte[] manufacturerData = new byte[] {
0x02, 0x15 };
int manufacturerId = 0xE0;
@@ -212,8 +223,9 @@ public class ScanFilterTest extends AndroidTestCase {
@SmallTest
public void testReadWriteParcel() {
- if (mFilterBuilder == null) return;
-
+ if (shouldSkipTest()) {
+ return;
+ }
ScanFilter filter = mFilterBuilder.build();
testReadWriteParcelForFilter(filter);
@@ -267,11 +279,17 @@ public class ScanFilterTest extends AndroidTestCase {
@SmallTest
public void testDescribeContents() {
+ if (!mHasBluetoothLe) {
+ return;
+ }
final int expected = 0;
assertEquals(expected, new ScanFilter.Builder().build().describeContents());
}
private void testReadWriteParcelForFilter(ScanFilter filter) {
+ if (!mHasBluetoothLe) {
+ return;
+ }
Parcel parcel = Parcel.obtain();
filter.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
@@ -279,4 +297,8 @@ public class ScanFilterTest extends AndroidTestCase {
ScanFilter.CREATOR.createFromParcel(parcel);
assertEquals(filter, filterFromParcel);
}
+
+ private boolean shouldSkipTest() {
+ return !mHasBluetoothLe || mFilterBuilder == null;
+ }
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/ScanRecordTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/ScanRecordTest.java
index 0afd1ecd7e4..3cc018a5577 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/ScanRecordTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/ScanRecordTest.java
@@ -31,6 +31,9 @@ public class ScanRecordTest extends AndroidTestCase {
@SmallTest
public void testParser() {
+ if (!TestUtils.isBleSupported(getContext())) {
+ return;
+ }
byte[] scanRecord = new byte[] {
0x02, 0x01, 0x1a, // advertising flags
0x05, 0x02, 0x0b, 0x11, 0x0a, 0x11, // 16 bit service uuids
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/ScanResultTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/ScanResultTest.java
index f3237127cc8..11db71869bb 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/ScanResultTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/ScanResultTest.java
@@ -19,7 +19,6 @@ package android.bluetooth.cts;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.le.ScanResult;
-import android.content.pm.PackageManager;
import android.os.Parcel;
import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;
@@ -37,14 +36,24 @@ public class ScanResultTest extends AndroidTestCase {
private static final int RSSI = -10;
private static final long TIMESTAMP_NANOS = 10000L;
+ private boolean mHasBluetoothLe;
+
+ @Override
+ protected void setUp() {
+ mHasBluetoothLe = TestUtils.isBleSupported(getContext());
+ if (!mHasBluetoothLe) {
+ return;
+ }
+ }
+
/**
* Test read and write parcel of ScanResult
*/
@SmallTest
public void testScanResultParceling() {
- if (! mContext.getPackageManager().
- hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) return;
-
+ if (shouldSkipTest()) {
+ return;
+ }
BluetoothDevice device =
BluetoothAdapter.getDefaultAdapter().getRemoteDevice(DEVICE_ADDRESS);
ScanResult result = new ScanResult(device, TestUtils.parseScanRecord(SCAN_RECORD), RSSI,
@@ -63,13 +72,17 @@ public class ScanResultTest extends AndroidTestCase {
@SmallTest
public void testDescribeContents() {
- if (! mContext.getPackageManager().
- hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) return;
-
+ if (shouldSkipTest()) {
+ return;
+ }
BluetoothDevice device =
BluetoothAdapter.getDefaultAdapter().getRemoteDevice(DEVICE_ADDRESS);
ScanResult result = new ScanResult(device, TestUtils.parseScanRecord(SCAN_RECORD), RSSI,
TIMESTAMP_NANOS);
assertEquals(0, result.describeContents());
}
+
+ private boolean shouldSkipTest() {
+ return !mHasBluetoothLe;
+ }
}
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/ScanSettingsTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/ScanSettingsTest.java
index 7033c3ccb07..273cea14682 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/ScanSettingsTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/ScanSettingsTest.java
@@ -26,8 +26,21 @@ import android.test.suitebuilder.annotation.SmallTest;
*/
public class ScanSettingsTest extends AndroidTestCase {
+ private boolean mHasBluetoothLe;
+
+ @Override
+ protected void setUp() {
+ mHasBluetoothLe = TestUtils.isBleSupported(getContext());
+ if (!mHasBluetoothLe) {
+ return;
+ }
+ }
+
@SmallTest
public void testDefaultSettings() {
+ if (shouldSkipTest()) {
+ return;
+ }
ScanSettings settings = new ScanSettings.Builder().build();
assertEquals(ScanSettings.CALLBACK_TYPE_ALL_MATCHES, settings.getCallbackType());
assertEquals(ScanSettings.SCAN_MODE_LOW_POWER, settings.getScanMode());
@@ -37,12 +50,18 @@ public class ScanSettingsTest extends AndroidTestCase {
@SmallTest
public void testDescribeContents() {
+ if (shouldSkipTest()) {
+ return;
+ }
ScanSettings settings = new ScanSettings.Builder().build();
assertEquals(0, settings.describeContents());
}
@SmallTest
public void testReadWriteParcel() {
+ if (shouldSkipTest()) {
+ return;
+ }
final long reportDelayMillis = 60 * 1000;
Parcel parcel = Parcel.obtain();
ScanSettings settings = new ScanSettings.Builder()
@@ -57,4 +76,8 @@ public class ScanSettingsTest extends AndroidTestCase {
assertEquals(reportDelayMillis, settingsFromParcel.getReportDelayMillis());
assertEquals(ScanSettings.SCAN_MODE_LOW_LATENCY, settings.getScanMode());
}
+
+ private boolean shouldSkipTest() {
+ return !mHasBluetoothLe;
+ }
}
diff --git a/tests/tests/view/AndroidManifest.xml b/tests/tests/view/AndroidManifest.xml
index a892da1d6cc..6de3aac86d3 100644
--- a/tests/tests/view/AndroidManifest.xml
+++ b/tests/tests/view/AndroidManifest.xml
@@ -203,7 +203,7 @@
android:label="PixelCopyViewProducerDialogActivity"
android:screenOrientation="portrait"
android:rotationAnimation="jumpcut"
- android:theme="@android:style/Theme.Material.Dialog.NoActionBar"
+ android:theme="@style/PixelCopyViewProducerDialogActivityTheme"
android:configChanges="orientation|screenSize|screenLayout|smallestScreenSize"/>
<activity android:name="android.view.cts.FocusFinderCtsActivity"
diff --git a/tests/tests/view/res/values/styles.xml b/tests/tests/view/res/values/styles.xml
index bb513bfc73a..34df7cce0df 100644
--- a/tests/tests/view/res/values/styles.xml
+++ b/tests/tests/view/res/values/styles.xml
@@ -184,6 +184,10 @@
<item name="android:windowAnimationStyle">@null</item>
</style>
+ <style name="PixelCopyViewProducerDialogActivityTheme" parent="@android:style/Theme.Material.Dialog.NoActionBar">
+ <item name="android:windowLayoutInDisplayCutoutMode">default</item>
+ </style>
+
<style name="ViewAttributeTestTheme" parent="@android:Theme.Material"/>
<style name="ExplicitStyle1" parent="@style/ParentOfExplicitStyle1">