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


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 ''

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

        BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(
        byte[] scanRecord = new byte[] {
                1, 2, 3 };
        int rssi = -10;
        long timestampMicros = 10000L;

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