FileDocCategorySizeDatePackage
ScanResultTest.javaAPI DocAndroid 5.1 API1957Thu Mar 12 22:22:12 GMT 2015android.bluetooth.le

ScanResultTest

public class ScanResultTest extends TestCase
Unit test cases for Bluetooth LE scans.

To run this test, use adb shell am instrument -e class 'android.bluetooth.ScanResultTest' -w 'com.android.bluetooth.tests/android.bluetooth.BluetoothTestRunner'

Fields Summary
Constructors Summary
Methods Summary
public voidtestScanResultParceling()
Test read and write parcel of ScanResult

        BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(
                "01:02:03:04:05:06");
        byte[] scanRecord = new byte[] {
                1, 2, 3 };
        int rssi = -10;
        long timestampMicros = 10000L;

        ScanResult result = new ScanResult(device, ScanRecord.parseFromBytes(scanRecord), rssi,
                timestampMicros);
        Parcel parcel = Parcel.obtain();
        result.writeToParcel(parcel, 0);
        // Need to reset parcel data position to the beginning.
        parcel.setDataPosition(0);
        ScanResult resultFromParcel = ScanResult.CREATOR.createFromParcel(parcel);
        assertEquals(result, resultFromParcel);