summaryrefslogtreecommitdiffstats
path: root/core/tests/bluetoothtests/src
diff options
context:
space:
mode:
authorWei Wang <weiwa@google.com>2014-04-15 14:57:16 -0700
committerMatthew Xie <mattx@google.com>2014-05-06 19:20:46 -0700
commit82500dd86631a08d290929f64824c4fd22f0aa75 (patch)
treeb53cc4fa11dd6e7109ae6f684637e6f59a52a229 /core/tests/bluetoothtests/src
parent3e8eb40950f4d02322ded64503314b7db2bf9825 (diff)
downloadframeworks_base-82500dd86631a08d290929f64824c4fd22f0aa75.zip
frameworks_base-82500dd86631a08d290929f64824c4fd22f0aa75.tar.gz
frameworks_base-82500dd86631a08d290929f64824c4fd22f0aa75.tar.bz2
Add parse method to parse UUID from bytes for 16 bit, 32 bit and 128 bit
Bluetooth UUIDs. Added unit tests. Change-Id: I4ecf0ede02561a5e9815acf8a5a1309d5756b887
Diffstat (limited to 'core/tests/bluetoothtests/src')
-rw-r--r--core/tests/bluetoothtests/src/android/bluetooth/BluetoothUuidTest.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/core/tests/bluetoothtests/src/android/bluetooth/BluetoothUuidTest.java b/core/tests/bluetoothtests/src/android/bluetooth/BluetoothUuidTest.java
new file mode 100644
index 0000000..0f3ea0e
--- /dev/null
+++ b/core/tests/bluetoothtests/src/android/bluetooth/BluetoothUuidTest.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2014 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;
+
+import android.os.ParcelUuid;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit test cases for {@link BluetoothUuid}.
+ * <p>
+ * To run this test, use adb shell am instrument -e class 'android.bluetooth.BluetoothUuidTest' -w
+ * 'com.android.bluetooth.tests/android.bluetooth.BluetoothTestRunner'
+ */
+public class BluetoothUuidTest extends TestCase {
+
+ @SmallTest
+ public void testUuidParser() {
+ byte[] uuid16 = new byte[] {
+ 0x0B, 0x11 };
+ assertEquals(ParcelUuid.fromString("0000110B-0000-1000-8000-00805F9B34FB"),
+ BluetoothUuid.parseUuidFrom(uuid16));
+
+ byte[] uuid32 = new byte[] {
+ 0x0B, 0x11, 0x33, (byte) 0xFE };
+ assertEquals(ParcelUuid.fromString("FE33110B-0000-1000-8000-00805F9B34FB"),
+ BluetoothUuid.parseUuidFrom(uuid32));
+
+ byte[] uuid128 = new byte[] {
+ 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
+ 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, (byte) 0xFF };
+ assertEquals(ParcelUuid.fromString("FF0F0E0D-0C0B-0A09-0807-0060504030201"),
+ BluetoothUuid.parseUuidFrom(uuid128));
+ }
+}