FileDocCategorySizeDatePackage
AdvertiseDataTest.javaAPI DocAndroid 5.1 API5487Thu Mar 12 22:22:12 GMT 2015android.bluetooth.le

AdvertiseDataTest

public class AdvertiseDataTest extends TestCase
Unit test cases for {@link AdvertiseData}.

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

Fields Summary
private AdvertiseData.Builder
mAdvertiseDataBuilder
Constructors Summary
Methods Summary
protected voidsetUp()

        mAdvertiseDataBuilder = new AdvertiseData.Builder();
    
public voidtestEmptyData()

        Parcel parcel = Parcel.obtain();
        AdvertiseData data = mAdvertiseDataBuilder.build();
        data.writeToParcel(parcel, 0);
        parcel.setDataPosition(0);
        AdvertiseData dataFromParcel =
                AdvertiseData.CREATOR.createFromParcel(parcel);
        assertEquals(data, dataFromParcel);
    
public voidtestEmptyManufacturerData()

        Parcel parcel = Parcel.obtain();
        int manufacturerId = 50;
        byte[] manufacturerData = new byte[0];
        AdvertiseData data =
                mAdvertiseDataBuilder.setIncludeDeviceName(true)
                        .addManufacturerData(manufacturerId, manufacturerData).build();
        data.writeToParcel(parcel, 0);
        parcel.setDataPosition(0);
        AdvertiseData dataFromParcel =
                AdvertiseData.CREATOR.createFromParcel(parcel);
        assertEquals(data, dataFromParcel);
    
public voidtestEmptyServiceData()

        Parcel parcel = Parcel.obtain();
        ParcelUuid uuid = ParcelUuid.fromString("0000110A-0000-1000-8000-00805F9B34FB");
        byte[] serviceData = new byte[0];
        AdvertiseData data =
                mAdvertiseDataBuilder.setIncludeDeviceName(true)
                        .addServiceData(uuid, serviceData).build();
        data.writeToParcel(parcel, 0);
        parcel.setDataPosition(0);
        AdvertiseData dataFromParcel =
                AdvertiseData.CREATOR.createFromParcel(parcel);
        assertEquals(data, dataFromParcel);
    
public voidtestEmptyServiceUuid()

        Parcel parcel = Parcel.obtain();
        AdvertiseData data = mAdvertiseDataBuilder.setIncludeDeviceName(true).build();
        data.writeToParcel(parcel, 0);
        parcel.setDataPosition(0);
        AdvertiseData dataFromParcel =
                AdvertiseData.CREATOR.createFromParcel(parcel);
        assertEquals(data, dataFromParcel);
    
public voidtestManufacturerData()

        Parcel parcel = Parcel.obtain();
        ParcelUuid uuid = ParcelUuid.fromString("0000110A-0000-1000-8000-00805F9B34FB");
        ParcelUuid uuid2 = ParcelUuid.fromString("0000110B-0000-1000-8000-00805F9B34FB");

        int manufacturerId = 50;
        byte[] manufacturerData = new byte[] {
                (byte) 0xF0, 0x00, 0x02, 0x15 };
        AdvertiseData data =
                mAdvertiseDataBuilder.setIncludeDeviceName(true)
                        .addServiceUuid(uuid).addServiceUuid(uuid2)
                        .addManufacturerData(manufacturerId, manufacturerData).build();

        data.writeToParcel(parcel, 0);
        parcel.setDataPosition(0);
        AdvertiseData dataFromParcel =
                AdvertiseData.CREATOR.createFromParcel(parcel);
        assertEquals(data, dataFromParcel);
    
public voidtestServiceData()

        Parcel parcel = Parcel.obtain();
        ParcelUuid uuid = ParcelUuid.fromString("0000110A-0000-1000-8000-00805F9B34FB");
        byte[] serviceData = new byte[] {
                (byte) 0xF0, 0x00, 0x02, 0x15 };
        AdvertiseData data =
                mAdvertiseDataBuilder.setIncludeDeviceName(true)
                        .addServiceData(uuid, serviceData).build();
        data.writeToParcel(parcel, 0);
        parcel.setDataPosition(0);
        AdvertiseData dataFromParcel =
                AdvertiseData.CREATOR.createFromParcel(parcel);
        assertEquals(data, dataFromParcel);
    
public voidtestServiceUuid()

        Parcel parcel = Parcel.obtain();
        ParcelUuid uuid = ParcelUuid.fromString("0000110A-0000-1000-8000-00805F9B34FB");
        ParcelUuid uuid2 = ParcelUuid.fromString("0000110B-0000-1000-8000-00805F9B34FB");

        AdvertiseData data =
                mAdvertiseDataBuilder.setIncludeDeviceName(true)
                        .addServiceUuid(uuid).addServiceUuid(uuid2).build();
        data.writeToParcel(parcel, 0);
        parcel.setDataPosition(0);
        AdvertiseData dataFromParcel =
                AdvertiseData.CREATOR.createFromParcel(parcel);
        assertEquals(data, dataFromParcel);