Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a309b709 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Convert various android.bluetooth unit tests to go/truth" into main

parents 4fa63586 44ea9eb1
Loading
Loading
Loading
Loading
+181 −35
Original line number Diff line number Diff line
@@ -16,11 +16,22 @@

package android.bluetooth;

import androidx.test.filters.SmallTest;
import junit.framework.TestCase;
import static com.google.common.truth.Truth.assertThat;

import androidx.test.runner.AndroidJUnit4;

import com.google.common.truth.Expect;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

/** Unit test cases for {@link BluetoothCodecConfig}. */
public class BluetoothCodecConfigTest extends TestCase {
@RunWith(AndroidJUnit4.class)
public class BluetoothCodecConfigTest {

    @Rule public Expect expect = Expect.create();

    private static final int[] sCodecTypeArray =
            new int[] {
                BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
@@ -199,9 +210,8 @@ public class BluetoothCodecConfigTest extends TestCase {
        return sCodecSpecific4Array[index];
    }

    @SmallTest
    @Test
    public void testBluetoothCodecConfig_valid_get_methods() {

        for (int config_id = 0; config_id < sTotalConfigs; config_id++) {
            int codec_type = selectCodecType(config_id);
            int codec_priority = selectCodecPriority(config_id);
@@ -226,47 +236,48 @@ public class BluetoothCodecConfigTest extends TestCase {
                            codec_specific4);

            if (codec_type == BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC) {
                assertTrue(bcc.isMandatoryCodec());
                expect.that(bcc.isMandatoryCodec()).isTrue();
            } else {
                assertFalse(bcc.isMandatoryCodec());
                expect.that(bcc.isMandatoryCodec()).isFalse();
            }

            if (codec_type == BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC) {
                assertEquals("SBC", BluetoothCodecConfig.getCodecName(codec_type));
                expect.that(BluetoothCodecConfig.getCodecName(codec_type)).isEqualTo("SBC");
            }
            if (codec_type == BluetoothCodecConfig.SOURCE_CODEC_TYPE_AAC) {
                assertEquals("AAC", BluetoothCodecConfig.getCodecName(codec_type));
                expect.that(BluetoothCodecConfig.getCodecName(codec_type)).isEqualTo("AAC");
            }
            if (codec_type == BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX) {
                assertEquals("aptX", BluetoothCodecConfig.getCodecName(codec_type));
                expect.that(BluetoothCodecConfig.getCodecName(codec_type)).isEqualTo("aptX");
            }
            if (codec_type == BluetoothCodecConfig.SOURCE_CODEC_TYPE_APTX_HD) {
                assertEquals("aptX HD", BluetoothCodecConfig.getCodecName(codec_type));
                expect.that(BluetoothCodecConfig.getCodecName(codec_type)).isEqualTo("aptX HD");
            }
            if (codec_type == BluetoothCodecConfig.SOURCE_CODEC_TYPE_LDAC) {
                assertEquals("LDAC", BluetoothCodecConfig.getCodecName(codec_type));
                expect.that(BluetoothCodecConfig.getCodecName(codec_type)).isEqualTo("LDAC");
            }
            if (codec_type == BluetoothCodecConfig.SOURCE_CODEC_TYPE_OPUS) {
                assertEquals("Opus", BluetoothCodecConfig.getCodecName(codec_type));
                expect.that(BluetoothCodecConfig.getCodecName(codec_type)).isEqualTo("Opus");
            }
            if (codec_type == BluetoothCodecConfig.SOURCE_CODEC_TYPE_INVALID) {
                assertEquals("INVALID CODEC", BluetoothCodecConfig.getCodecName(codec_type));
                expect.that(BluetoothCodecConfig.getCodecName(codec_type))
                        .isEqualTo("INVALID CODEC");
            }

            assertEquals(codec_type, bcc.getCodecType());
            assertEquals(codec_priority, bcc.getCodecPriority());
            assertEquals(sample_rate, bcc.getSampleRate());
            assertEquals(bits_per_sample, bcc.getBitsPerSample());
            assertEquals(channel_mode, bcc.getChannelMode());
            assertEquals(codec_specific1, bcc.getCodecSpecific1());
            assertEquals(codec_specific2, bcc.getCodecSpecific2());
            assertEquals(codec_specific3, bcc.getCodecSpecific3());
            assertEquals(codec_specific4, bcc.getCodecSpecific4());
            expect.that(bcc.getCodecType()).isEqualTo(codec_type);
            expect.that(bcc.getCodecPriority()).isEqualTo(codec_priority);
            expect.that(bcc.getSampleRate()).isEqualTo(sample_rate);
            expect.that(bcc.getBitsPerSample()).isEqualTo(bits_per_sample);
            expect.that(bcc.getChannelMode()).isEqualTo(channel_mode);
            expect.that(bcc.getCodecSpecific1()).isEqualTo(codec_specific1);
            expect.that(bcc.getCodecSpecific2()).isEqualTo(codec_specific2);
            expect.that(bcc.getCodecSpecific3()).isEqualTo(codec_specific3);
            expect.that(bcc.getCodecSpecific4()).isEqualTo(codec_specific4);
        }
    }

    @SmallTest
    public void testBluetoothCodecConfig_equals() {
    @Test
    public void testBluetoothCodecConfig_same() {
        BluetoothCodecConfig bcc1 =
                buildBluetoothCodecConfig(
                        BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
@@ -290,7 +301,22 @@ public class BluetoothCodecConfigTest extends TestCase {
                        2000,
                        3000,
                        4000);
        assertTrue(bcc1.equals(bcc2_same));
        assertThat(bcc2_same).isEqualTo(bcc1);
    }

    @Test
    public void testBluetoothCodecConfig_different_codec_type() {
        BluetoothCodecConfig bcc1 =
                buildBluetoothCodecConfig(
                        BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
                        BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
                        BluetoothCodecConfig.SAMPLE_RATE_44100,
                        BluetoothCodecConfig.BITS_PER_SAMPLE_16,
                        BluetoothCodecConfig.CHANNEL_MODE_STEREO,
                        1000,
                        2000,
                        3000,
                        4000);

        BluetoothCodecConfig bcc3_codec_type =
                buildBluetoothCodecConfig(
@@ -303,7 +329,22 @@ public class BluetoothCodecConfigTest extends TestCase {
                        2000,
                        3000,
                        4000);
        assertFalse(bcc1.equals(bcc3_codec_type));
        assertThat(bcc3_codec_type).isNotEqualTo(bcc1);
    }

    @Test
    public void testBluetoothCodecConfig_different_codec_priority() {
        BluetoothCodecConfig bcc1 =
                buildBluetoothCodecConfig(
                        BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
                        BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
                        BluetoothCodecConfig.SAMPLE_RATE_44100,
                        BluetoothCodecConfig.BITS_PER_SAMPLE_16,
                        BluetoothCodecConfig.CHANNEL_MODE_STEREO,
                        1000,
                        2000,
                        3000,
                        4000);

        BluetoothCodecConfig bcc4_codec_priority =
                buildBluetoothCodecConfig(
@@ -316,7 +357,22 @@ public class BluetoothCodecConfigTest extends TestCase {
                        2000,
                        3000,
                        4000);
        assertFalse(bcc1.equals(bcc4_codec_priority));
        assertThat(bcc4_codec_priority).isNotEqualTo(bcc1);
    }

    @Test
    public void testBluetoothCodecConfig_different_sample_rate() {
        BluetoothCodecConfig bcc1 =
                buildBluetoothCodecConfig(
                        BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
                        BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
                        BluetoothCodecConfig.SAMPLE_RATE_44100,
                        BluetoothCodecConfig.BITS_PER_SAMPLE_16,
                        BluetoothCodecConfig.CHANNEL_MODE_STEREO,
                        1000,
                        2000,
                        3000,
                        4000);

        BluetoothCodecConfig bcc5_sample_rate =
                buildBluetoothCodecConfig(
@@ -329,7 +385,22 @@ public class BluetoothCodecConfigTest extends TestCase {
                        2000,
                        3000,
                        4000);
        assertFalse(bcc1.equals(bcc5_sample_rate));
        assertThat(bcc5_sample_rate).isNotEqualTo(bcc1);
    }

    @Test
    public void testBluetoothCodecConfig_different_bits_per_sample() {
        BluetoothCodecConfig bcc1 =
                buildBluetoothCodecConfig(
                        BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
                        BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
                        BluetoothCodecConfig.SAMPLE_RATE_44100,
                        BluetoothCodecConfig.BITS_PER_SAMPLE_16,
                        BluetoothCodecConfig.CHANNEL_MODE_STEREO,
                        1000,
                        2000,
                        3000,
                        4000);

        BluetoothCodecConfig bcc6_bits_per_sample =
                buildBluetoothCodecConfig(
@@ -342,7 +413,22 @@ public class BluetoothCodecConfigTest extends TestCase {
                        2000,
                        3000,
                        4000);
        assertFalse(bcc1.equals(bcc6_bits_per_sample));
        assertThat(bcc6_bits_per_sample).isNotEqualTo(bcc1);
    }

    @Test
    public void testBluetoothCodecConfig_different_channel_mode() {
        BluetoothCodecConfig bcc1 =
                buildBluetoothCodecConfig(
                        BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
                        BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
                        BluetoothCodecConfig.SAMPLE_RATE_44100,
                        BluetoothCodecConfig.BITS_PER_SAMPLE_16,
                        BluetoothCodecConfig.CHANNEL_MODE_STEREO,
                        1000,
                        2000,
                        3000,
                        4000);

        BluetoothCodecConfig bcc7_channel_mode =
                buildBluetoothCodecConfig(
@@ -355,7 +441,22 @@ public class BluetoothCodecConfigTest extends TestCase {
                        2000,
                        3000,
                        4000);
        assertFalse(bcc1.equals(bcc7_channel_mode));
        assertThat(bcc7_channel_mode).isNotEqualTo(bcc1);
    }

    @Test
    public void testBluetoothCodecConfig_different_code_specific_1() {
        BluetoothCodecConfig bcc1 =
                buildBluetoothCodecConfig(
                        BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
                        BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
                        BluetoothCodecConfig.SAMPLE_RATE_44100,
                        BluetoothCodecConfig.BITS_PER_SAMPLE_16,
                        BluetoothCodecConfig.CHANNEL_MODE_STEREO,
                        1000,
                        2000,
                        3000,
                        4000);

        BluetoothCodecConfig bcc8_codec_specific1 =
                buildBluetoothCodecConfig(
@@ -368,7 +469,22 @@ public class BluetoothCodecConfigTest extends TestCase {
                        2000,
                        3000,
                        4000);
        assertFalse(bcc1.equals(bcc8_codec_specific1));
        assertThat(bcc8_codec_specific1).isNotEqualTo(bcc1);
    }

    @Test
    public void testBluetoothCodecConfig_different_code_specific_2() {
        BluetoothCodecConfig bcc1 =
                buildBluetoothCodecConfig(
                        BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
                        BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
                        BluetoothCodecConfig.SAMPLE_RATE_44100,
                        BluetoothCodecConfig.BITS_PER_SAMPLE_16,
                        BluetoothCodecConfig.CHANNEL_MODE_STEREO,
                        1000,
                        2000,
                        3000,
                        4000);

        BluetoothCodecConfig bcc9_codec_specific2 =
                buildBluetoothCodecConfig(
@@ -381,7 +497,22 @@ public class BluetoothCodecConfigTest extends TestCase {
                        2002,
                        3000,
                        4000);
        assertFalse(bcc1.equals(bcc9_codec_specific2));
        assertThat(bcc9_codec_specific2).isNotEqualTo(bcc1);
    }

    @Test
    public void testBluetoothCodecConfig_different_code_specific_3() {
        BluetoothCodecConfig bcc1 =
                buildBluetoothCodecConfig(
                        BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
                        BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
                        BluetoothCodecConfig.SAMPLE_RATE_44100,
                        BluetoothCodecConfig.BITS_PER_SAMPLE_16,
                        BluetoothCodecConfig.CHANNEL_MODE_STEREO,
                        1000,
                        2000,
                        3000,
                        4000);

        BluetoothCodecConfig bcc10_codec_specific3 =
                buildBluetoothCodecConfig(
@@ -394,7 +525,22 @@ public class BluetoothCodecConfigTest extends TestCase {
                        2000,
                        3003,
                        4000);
        assertFalse(bcc1.equals(bcc10_codec_specific3));
        assertThat(bcc10_codec_specific3).isNotEqualTo(bcc1);
    }

    @Test
    public void testBluetoothCodecConfig_different_code_specific_4() {
        BluetoothCodecConfig bcc1 =
                buildBluetoothCodecConfig(
                        BluetoothCodecConfig.SOURCE_CODEC_TYPE_SBC,
                        BluetoothCodecConfig.CODEC_PRIORITY_DEFAULT,
                        BluetoothCodecConfig.SAMPLE_RATE_44100,
                        BluetoothCodecConfig.BITS_PER_SAMPLE_16,
                        BluetoothCodecConfig.CHANNEL_MODE_STEREO,
                        1000,
                        2000,
                        3000,
                        4000);

        BluetoothCodecConfig bcc11_codec_specific4 =
                buildBluetoothCodecConfig(
@@ -407,7 +553,7 @@ public class BluetoothCodecConfigTest extends TestCase {
                        2000,
                        3000,
                        4004);
        assertFalse(bcc1.equals(bcc11_codec_specific4));
        assertThat(bcc11_codec_specific4).isNotEqualTo(bcc1);
    }

    private BluetoothCodecConfig buildBluetoothCodecConfig(
+29 −22
Original line number Diff line number Diff line
@@ -16,13 +16,21 @@

package android.bluetooth;

import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;

import com.google.common.truth.Expect;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.List;
import java.util.Objects;
import junit.framework.TestCase;

/** Unit test cases for {@link BluetoothCodecStatus}. */
public class BluetoothCodecStatusTest extends TestCase {
@RunWith(AndroidJUnit4.class)
public class BluetoothCodecStatusTest {

    @Rule public Expect expect = Expect.create();

    // Codec configs: A and B are same; C is different
    private static final BluetoothCodecConfig CONFIG_A =
@@ -547,30 +555,29 @@ public class BluetoothCodecStatusTest extends TestCase {
    private static final BluetoothCodecStatus BCS_C =
            new BluetoothCodecStatus(CONFIG_C, LOCAL_CAPABILITY_C, SELECTABLE_CAPABILITY_C);

    @SmallTest
    @Test
    public void testBluetoothCodecStatus_get_methods() {
        expect.that(BCS_A.getCodecConfig()).isEqualTo(CONFIG_A);
        expect.that(BCS_A.getCodecConfig()).isEqualTo(CONFIG_B);
        expect.that(BCS_A.getCodecConfig()).isNotEqualTo(CONFIG_C);

        assertTrue(Objects.equals(BCS_A.getCodecConfig(), CONFIG_A));
        assertTrue(Objects.equals(BCS_A.getCodecConfig(), CONFIG_B));
        assertFalse(Objects.equals(BCS_A.getCodecConfig(), CONFIG_C));

        assertTrue(BCS_A.getCodecsLocalCapabilities().equals(LOCAL_CAPABILITY_A));
        assertTrue(BCS_A.getCodecsLocalCapabilities().equals(LOCAL_CAPABILITY_B));
        assertFalse(BCS_A.getCodecsLocalCapabilities().equals(LOCAL_CAPABILITY_C));
        expect.that(BCS_A.getCodecsLocalCapabilities()).isEqualTo(LOCAL_CAPABILITY_A);
        expect.that(BCS_A.getCodecsLocalCapabilities()).isEqualTo(LOCAL_CAPABILITY_B);
        expect.that(BCS_A.getCodecsLocalCapabilities()).isNotEqualTo(LOCAL_CAPABILITY_C);

        assertTrue(BCS_A.getCodecsSelectableCapabilities().equals(SELECTABLE_CAPABILITY_A));
        assertTrue(BCS_A.getCodecsSelectableCapabilities().equals(SELECTABLE_CAPABILITY_B));
        assertFalse(BCS_A.getCodecsSelectableCapabilities().equals(SELECTABLE_CAPABILITY_C));
        expect.that(BCS_A.getCodecsSelectableCapabilities()).isEqualTo(SELECTABLE_CAPABILITY_A);
        expect.that(BCS_A.getCodecsSelectableCapabilities()).isEqualTo(SELECTABLE_CAPABILITY_B);
        expect.that(BCS_A.getCodecsSelectableCapabilities()).isNotEqualTo(SELECTABLE_CAPABILITY_C);
    }

    @SmallTest
    @Test
    public void testBluetoothCodecStatus_equals() {
        assertTrue(BCS_A.equals(BCS_B));
        assertTrue(BCS_B.equals(BCS_A));
        assertTrue(BCS_A.equals(BCS_B_REORDERED));
        assertTrue(BCS_B_REORDERED.equals(BCS_A));
        assertFalse(BCS_A.equals(BCS_C));
        assertFalse(BCS_C.equals(BCS_A));
        expect.that(BCS_A).isEqualTo(BCS_B);
        expect.that(BCS_B).isEqualTo(BCS_A);
        expect.that(BCS_A).isEqualTo(BCS_B_REORDERED);
        expect.that(BCS_B_REORDERED).isEqualTo(BCS_A);
        expect.that(BCS_A).isNotEqualTo(BCS_C);
        expect.that(BCS_C).isNotEqualTo(BCS_A);
    }

    private static BluetoothCodecConfig buildBluetoothCodecConfig(
+16 −8
Original line number Diff line number Diff line
@@ -16,20 +16,28 @@

package android.bluetooth;

import androidx.test.filters.SmallTest;
import junit.framework.TestCase;
import androidx.test.runner.AndroidJUnit4;

import com.google.common.truth.Expect;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

/** Unit test cases for {@link BluetoothLeAudioCodecConfig}. */
public class BluetoothLeAudioCodecConfigTest extends TestCase {
@RunWith(AndroidJUnit4.class)
public class BluetoothLeAudioCodecConfigTest {

    @Rule public Expect expect = Expect.create();

    private int[] mCodecTypeArray =
            new int[] {
                BluetoothLeAudioCodecConfig.SOURCE_CODEC_TYPE_LC3,
                BluetoothLeAudioCodecConfig.SOURCE_CODEC_TYPE_INVALID,
            };

    @SmallTest
    @Test
    public void testBluetoothLeAudioCodecConfig_valid_get_methods() {

        for (int codecIdx = 0; codecIdx < mCodecTypeArray.length; codecIdx++) {
            int codecType = mCodecTypeArray[codecIdx];

@@ -37,13 +45,13 @@ public class BluetoothLeAudioCodecConfigTest extends TestCase {
                    buildBluetoothLeAudioCodecConfig(codecType);

            if (codecType == BluetoothLeAudioCodecConfig.SOURCE_CODEC_TYPE_LC3) {
                assertEquals("LC3", leAudioCodecConfig.getCodecName());
                expect.that(leAudioCodecConfig.getCodecName()).isEqualTo("LC3");
            }
            if (codecType == BluetoothLeAudioCodecConfig.SOURCE_CODEC_TYPE_INVALID) {
                assertEquals("INVALID CODEC", leAudioCodecConfig.getCodecName());
                expect.that(leAudioCodecConfig.getCodecName()).isEqualTo("INVALID CODEC");
            }

            assertEquals(codecType, leAudioCodecConfig.getCodecType());
            expect.that(leAudioCodecConfig.getCodecType()).isEqualTo(codecType);
        }
    }

+48 −31
Original line number Diff line number Diff line
@@ -16,25 +16,39 @@

package android.bluetooth;

import static com.google.common.truth.Truth.assertThat;

import android.os.ParcelUuid;
import androidx.test.filters.SmallTest;
import junit.framework.TestCase;

import com.google.common.truth.Expect;

import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Unit test cases for {@link BluetoothUuid}. */
public class BluetoothUuidTest extends TestCase {
@RunWith(JUnit4.class)
public class BluetoothUuidTest {

    @Rule public Expect expect = Expect.create();

    @SmallTest
    public void testUuidParser() {
    @Test
    public void testUuid16Parser() {
        byte[] uuid16 = new byte[] {0x0B, 0x11};
        assertEquals(
                ParcelUuid.fromString("0000110B-0000-1000-8000-00805F9B34FB"),
                BluetoothUuid.parseUuidFrom(uuid16));
        assertThat(BluetoothUuid.parseUuidFrom(uuid16))
                .isEqualTo(ParcelUuid.fromString("0000110B-0000-1000-8000-00805F9B34FB"));
    }

    @Test
    public void testUuid32Parser() {
        byte[] uuid32 = new byte[] {0x0B, 0x11, 0x33, (byte) 0xFE};
        assertEquals(
                ParcelUuid.fromString("FE33110B-0000-1000-8000-00805F9B34FB"),
                BluetoothUuid.parseUuidFrom(uuid32));
        assertThat(BluetoothUuid.parseUuidFrom(uuid32))
                .isEqualTo(ParcelUuid.fromString("FE33110B-0000-1000-8000-00805F9B34FB"));
    }

    @Test
    public void testUuid128Parser() {
        byte[] uuid128 =
                new byte[] {
                    0x01,
@@ -54,28 +68,31 @@ public class BluetoothUuidTest extends TestCase {
                    0x0F,
                    (byte) 0xFF
                };
        assertEquals(
                ParcelUuid.fromString("FF0F0E0D-0C0B-0A09-0807-060504030201"),
                BluetoothUuid.parseUuidFrom(uuid128));
        assertThat(BluetoothUuid.parseUuidFrom(uuid128))
                .isEqualTo(ParcelUuid.fromString("FF0F0E0D-0C0B-0A09-0807-060504030201"));
    }

    @SmallTest
    @Test
    public void testUuidType() {
        assertTrue(
        expect.that(
                        BluetoothUuid.is16BitUuid(
                        ParcelUuid.fromString("0000110B-0000-1000-8000-00805F9B34FB")));
        assertFalse(
                                ParcelUuid.fromString("0000110B-0000-1000-8000-00805F9B34FB")))
                .isTrue();
        expect.that(
                        BluetoothUuid.is32BitUuid(
                        ParcelUuid.fromString("0000110B-0000-1000-8000-00805F9B34FB")));

        assertFalse(
                                ParcelUuid.fromString("0000110B-0000-1000-8000-00805F9B34FB")))
                .isFalse();
        expect.that(
                        BluetoothUuid.is16BitUuid(
                        ParcelUuid.fromString("FE33110B-0000-1000-8000-00805F9B34FB")));
        assertTrue(
                                ParcelUuid.fromString("FE33110B-0000-1000-8000-00805F9B34FB")))
                .isFalse();
        expect.that(
                        BluetoothUuid.is32BitUuid(
                        ParcelUuid.fromString("FE33110B-0000-1000-8000-00805F9B34FB")));
        assertFalse(
                                ParcelUuid.fromString("FE33110B-0000-1000-8000-00805F9B34FB")))
                .isTrue();
        expect.that(
                        BluetoothUuid.is32BitUuid(
                        ParcelUuid.fromString("FE33110B-1000-1000-8000-00805F9B34FB")));
                                ParcelUuid.fromString("FE33110B-1000-1000-8000-00805F9B34FB")))
                .isFalse();
    }
}
+12 −5
Original line number Diff line number Diff line
@@ -16,13 +16,20 @@

package android.bluetooth.le;

import static com.google.common.truth.Truth.assertThat;

import android.bluetooth.BluetoothDevice;
import android.os.Parcel;
import androidx.test.filters.SmallTest;
import junit.framework.TestCase;

public class ScanFilterTest extends TestCase {
    @SmallTest
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/** Test for Bluetooth LE {@link ScanFilter}. */
@RunWith(JUnit4.class)
public class ScanFilterTest {

    @Test
    public void testIrkFilterParcelable() {
        // arrange: an IRK filter
        Parcel parcel = Parcel.obtain();
@@ -40,6 +47,6 @@ public class ScanFilterTest extends TestCase {
        ScanFilter filterFromParcel = ScanFilter.CREATOR.createFromParcel(parcel);

        // assert: no change
        assertEquals(filter, filterFromParcel);
        assertThat(filterFromParcel).isEqualTo(filter);
    }
}
Loading