summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEtienne Ruffieux <eruffieux@google.com>2021-12-08 18:35:56 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2021-12-08 18:35:56 +0000
commit317c400258034742e7d7ed353c39eaba5ecacda9 (patch)
treea177d92b9e6c13f40f0ba093048912d0979d9444
parentca7160c239dffd8b2b7cc8576014fbb2c0f8d40c (diff)
parent2b03cc43b916b011cde2fa06f78977918343fbaf (diff)
downloadcts-317c400258034742e7d7ed353c39eaba5ecacda9.tar.gz
Merge "Added cts tests for BluetoothClass public methods"
-rw-r--r--tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothClassTest.java77
1 files changed, 77 insertions, 0 deletions
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothClassTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothClassTest.java
new file mode 100644
index 00000000000..3d407df8e26
--- /dev/null
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BluetoothClassTest.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.bluetooth.cts;
+
+import android.bluetooth.BluetoothClass;
+import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+
+/**
+ * Unit test cases for {@link BluetoothClass}.
+ * <p>
+ * To run this test, use adb shell am instrument -e class 'android.bluetooth.BluetoothClassTest' -w
+ * 'com.android.bluetooth.tests/android.bluetooth.BluetoothTestRunner'
+ */
+public class BluetoothClassTest extends AndroidTestCase {
+
+ private BluetoothClass mBluetoothClassHeadphones;
+ private BluetoothClass mBluetoothClassPhone;
+ private BluetoothClass mBluetoothClassService;
+
+ @Override
+ protected void setUp() {
+ mBluetoothClassHeadphones = new BluetoothClass(BluetoothClass.Device.AUDIO_VIDEO_HEADPHONES);
+ mBluetoothClassPhone = new BluetoothClass(BluetoothClass.Device.Major.PHONE);
+ mBluetoothClassService = new BluetoothClass(BluetoothClass.Service.NETWORKING);
+ }
+
+ @SmallTest
+ public void testHasService() {
+ assertTrue(mBluetoothClassService.hasService(BluetoothClass.Service.NETWORKING));
+ assertFalse(mBluetoothClassService.hasService(BluetoothClass.Service.TELEPHONY));
+ }
+
+ @SmallTest
+ public void testGetMajorDeviceClass() {
+ assertEquals(mBluetoothClassHeadphones.getMajorDeviceClass(), BluetoothClass.Device.Major.AUDIO_VIDEO);
+ assertEquals(mBluetoothClassPhone.getMajorDeviceClass(), BluetoothClass.Device.Major.PHONE);
+ }
+
+ @SmallTest
+ public void testGetDeviceClass() {
+ assertEquals(mBluetoothClassHeadphones.getDeviceClass(), BluetoothClass.Device.AUDIO_VIDEO_HEADPHONES);
+ assertEquals(mBluetoothClassPhone.getDeviceClass(), BluetoothClass.Device.PHONE_UNCATEGORIZED);
+ }
+
+ @SmallTest
+ public void testGetClassOfDevice() {
+ assertEquals(mBluetoothClassHeadphones.getClassOfDevice(), BluetoothClass.Device.AUDIO_VIDEO_HEADPHONES);
+ assertEquals(mBluetoothClassPhone.getClassOfDevice(), BluetoothClass.Device.Major.PHONE);
+ }
+
+ @SmallTest
+ public void testDoesClassMatch() {
+ assertTrue(mBluetoothClassHeadphones.doesClassMatch(BluetoothClass.PROFILE_A2DP));
+ assertFalse(mBluetoothClassHeadphones.doesClassMatch(BluetoothClass.PROFILE_HEADSET));
+
+ assertTrue(mBluetoothClassPhone.doesClassMatch(BluetoothClass.PROFILE_OPP));
+ assertFalse(mBluetoothClassPhone.doesClassMatch(BluetoothClass.PROFILE_HEADSET));
+
+ assertTrue(mBluetoothClassService.doesClassMatch(BluetoothClass.PROFILE_PANU));
+ assertFalse(mBluetoothClassService.doesClassMatch(BluetoothClass.PROFILE_OPP));
+ }
+}