Search in sources :

Example 61 with SmallTest

use of android.test.suitebuilder.annotation.SmallTest in project android_frameworks_base by ResurrectionRemix.

the class ScanResultTest method testScanResultParceling.

/**
     * Test read and write parcel of ScanResult
     */
@SmallTest
public void testScanResultParceling() {
    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);
}
Also used : BluetoothDevice(android.bluetooth.BluetoothDevice) Parcel(android.os.Parcel) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 62 with SmallTest

use of android.test.suitebuilder.annotation.SmallTest in project android_frameworks_base by ResurrectionRemix.

the class ScanRecordTest method testParser.

@SmallTest
public void testParser() {
    byte[] scanRecord = new byte[] { // advertising flags
    0x02, // advertising flags
    0x01, // advertising flags
    0x1a, // 16 bit service uuids
    0x05, // 16 bit service uuids
    0x02, // 16 bit service uuids
    0x0b, // 16 bit service uuids
    0x11, // 16 bit service uuids
    0x0a, // 16 bit service uuids
    0x11, // name
    0x04, // name
    0x09, // name
    0x50, // name
    0x65, // name
    0x64, // tx power level
    0x02, // tx power level
    0x0A, // tx power level
    (byte) 0xec, // service data
    0x05, // service data
    0x16, // service data
    0x0b, // service data
    0x11, // service data
    0x50, // service data
    0x64, // manufacturer specific data
    0x05, // manufacturer specific data
    (byte) 0xff, // manufacturer specific data
    (byte) 0xe0, // manufacturer specific data
    0x00, // manufacturer specific data
    0x02, // manufacturer specific data
    0x15, // an unknown data type won't cause trouble
    0x03, // an unknown data type won't cause trouble
    0x50, // an unknown data type won't cause trouble
    0x01, // an unknown data type won't cause trouble
    0x02 };
    ScanRecord data = ScanRecord.parseFromBytes(scanRecord);
    assertEquals(0x1a, data.getAdvertiseFlags());
    ParcelUuid uuid1 = ParcelUuid.fromString("0000110A-0000-1000-8000-00805F9B34FB");
    ParcelUuid uuid2 = ParcelUuid.fromString("0000110B-0000-1000-8000-00805F9B34FB");
    assertTrue(data.getServiceUuids().contains(uuid1));
    assertTrue(data.getServiceUuids().contains(uuid2));
    assertEquals("Ped", data.getDeviceName());
    assertEquals(-20, data.getTxPowerLevel());
    assertTrue(data.getManufacturerSpecificData().get(0x00E0) != null);
    assertArrayEquals(new byte[] { 0x02, 0x15 }, data.getManufacturerSpecificData().get(0x00E0));
    assertTrue(data.getServiceData().containsKey(uuid2));
    assertArrayEquals(new byte[] { 0x50, 0x64 }, data.getServiceData().get(uuid2));
}
Also used : ParcelUuid(android.os.ParcelUuid) ScanRecord(android.bluetooth.le.ScanRecord) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 63 with SmallTest

use of android.test.suitebuilder.annotation.SmallTest in project android_frameworks_base by ResurrectionRemix.

the class ScanFilterTest method testsetServiceUuidFilter.

@SmallTest
public void testsetServiceUuidFilter() {
    ScanFilter filter = mFilterBuilder.setServiceUuid(ParcelUuid.fromString("0000110A-0000-1000-8000-00805F9B34FB")).build();
    assertTrue("uuid filter fails", filter.matches(mScanResult));
    filter = mFilterBuilder.setServiceUuid(ParcelUuid.fromString("0000110C-0000-1000-8000-00805F9B34FB")).build();
    assertFalse("uuid filter fails", filter.matches(mScanResult));
    filter = mFilterBuilder.setServiceUuid(ParcelUuid.fromString("0000110C-0000-1000-8000-00805F9B34FB"), ParcelUuid.fromString("FFFFFFF0-FFFF-FFFF-FFFF-FFFFFFFFFFFF")).build();
    assertTrue("uuid filter fails", filter.matches(mScanResult));
}
Also used : ScanFilter(android.bluetooth.le.ScanFilter) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 64 with SmallTest

use of android.test.suitebuilder.annotation.SmallTest in project android_frameworks_base by ResurrectionRemix.

the class ScanFilterTest method testReadWriteParcel.

@SmallTest
public void testReadWriteParcel() {
    ScanFilter filter = mFilterBuilder.build();
    testReadWriteParcelForFilter(filter);
    filter = mFilterBuilder.setDeviceName("Ped").build();
    testReadWriteParcelForFilter(filter);
    filter = mFilterBuilder.setDeviceAddress("11:22:33:44:55:66").build();
    testReadWriteParcelForFilter(filter);
    filter = mFilterBuilder.setServiceUuid(ParcelUuid.fromString("0000110C-0000-1000-8000-00805F9B34FB")).build();
    testReadWriteParcelForFilter(filter);
    filter = mFilterBuilder.setServiceUuid(ParcelUuid.fromString("0000110C-0000-1000-8000-00805F9B34FB"), ParcelUuid.fromString("FFFFFFF0-FFFF-FFFF-FFFF-FFFFFFFFFFFF")).build();
    testReadWriteParcelForFilter(filter);
    byte[] serviceData = new byte[] { 0x50, 0x64 };
    ParcelUuid serviceDataUuid = ParcelUuid.fromString("0000110B-0000-1000-8000-00805F9B34FB");
    filter = mFilterBuilder.setServiceData(serviceDataUuid, serviceData).build();
    testReadWriteParcelForFilter(filter);
    filter = mFilterBuilder.setServiceData(serviceDataUuid, new byte[0]).build();
    testReadWriteParcelForFilter(filter);
    byte[] serviceDataMask = new byte[] { (byte) 0xFF, (byte) 0xFF };
    filter = mFilterBuilder.setServiceData(serviceDataUuid, serviceData, serviceDataMask).build();
    testReadWriteParcelForFilter(filter);
    byte[] manufacturerData = new byte[] { 0x02, 0x15 };
    int manufacturerId = 0xE0;
    filter = mFilterBuilder.setManufacturerData(manufacturerId, manufacturerData).build();
    testReadWriteParcelForFilter(filter);
    filter = mFilterBuilder.setServiceData(serviceDataUuid, new byte[0]).build();
    testReadWriteParcelForFilter(filter);
    byte[] manufacturerDataMask = new byte[] { (byte) 0xFF, (byte) 0xFF };
    filter = mFilterBuilder.setManufacturerData(manufacturerId, manufacturerData, manufacturerDataMask).build();
    testReadWriteParcelForFilter(filter);
}
Also used : ParcelUuid(android.os.ParcelUuid) ScanFilter(android.bluetooth.le.ScanFilter) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 65 with SmallTest

use of android.test.suitebuilder.annotation.SmallTest in project android_frameworks_base by ResurrectionRemix.

the class ScanFilterTest method testManufacturerSpecificData.

@SmallTest
public void testManufacturerSpecificData() {
    byte[] setManufacturerData = new byte[] { 0x02, 0x15 };
    int manufacturerId = 0xE0;
    ScanFilter filter = mFilterBuilder.setManufacturerData(manufacturerId, setManufacturerData).build();
    assertTrue("manufacturer data filter fails", filter.matches(mScanResult));
    byte[] emptyData = new byte[0];
    filter = mFilterBuilder.setManufacturerData(manufacturerId, emptyData).build();
    assertTrue("manufacturer data filter fails", filter.matches(mScanResult));
    byte[] prefixData = new byte[] { 0x02 };
    filter = mFilterBuilder.setManufacturerData(manufacturerId, prefixData).build();
    assertTrue("manufacturer data filter fails", filter.matches(mScanResult));
    // Test data mask
    byte[] nonMatchData = new byte[] { 0x02, 0x14 };
    filter = mFilterBuilder.setManufacturerData(manufacturerId, nonMatchData).build();
    assertFalse("manufacturer data filter fails", filter.matches(mScanResult));
    byte[] mask = new byte[] { (byte) 0xFF, (byte) 0x00 };
    filter = mFilterBuilder.setManufacturerData(manufacturerId, nonMatchData, mask).build();
    assertTrue("partial setManufacturerData filter fails", filter.matches(mScanResult));
}
Also used : ScanFilter(android.bluetooth.le.ScanFilter) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

SmallTest (android.test.suitebuilder.annotation.SmallTest)2108 Test (org.junit.Test)235 Parcel (android.os.Parcel)153 ArrayList (java.util.ArrayList)104 Time (android.text.format.Time)97 Rect (android.graphics.Rect)94 TelephonyTest (com.android.internal.telephony.TelephonyTest)84 Bundle (android.os.Bundle)77 ByteBuffer (java.nio.ByteBuffer)71 Intent (android.content.Intent)69 LinkProperties (android.net.LinkProperties)68 SpannableString (android.text.SpannableString)61 FlakyTest (android.support.test.filters.FlakyTest)58 DhcpPacket (android.net.dhcp.DhcpPacket)52 Rational (android.util.Rational)50 NetworkRequest (android.net.NetworkRequest)48 File (java.io.File)47 RouteInfo (android.net.RouteInfo)45 BitwiseOutputStream (com.android.internal.util.BitwiseOutputStream)45 ParcelUuid (android.os.ParcelUuid)43