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

Commit af325133 authored by Kihong Seong's avatar Kihong Seong
Browse files

Add additional tests for classes in package avrcpcontroller

This CL adds tests for:
- AvrcpItem
- AvrcpCoverArtStorage
- BipImageDescriptor
- BipAttachmentFormat
- BipImageFormat
- BipDatetime

Bug: 237467631
Test: Ran each test with atest
Change-Id: I2fac97ccc63c5368ab1fb731041adb50fcc559ea
parent 2324ad0d
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -329,4 +329,15 @@ public final class AvrcpCoverArtStorageTest {
        Assert.assertFalse(mAvrcpCoverArtStorage.doesImageExist(mDevice2, mHandle1));
        Assert.assertFalse(mAvrcpCoverArtStorage.doesImageExist(mDevice2, mHandle2));
    }

    @Test
    public void toString_returnsDeviceInfo() {
        String expectedString =
                "CoverArtStorage:\n" + "  " + mDevice1.getAddress() + " (" + 1 + "):" + "\n    "
                        + mHandle1 + "\n";

        mAvrcpCoverArtStorage.addImage(mDevice1, mHandle1, mImage1);

        Assert.assertEquals(expectedString, mAvrcpCoverArtStorage.toString());
    }
}
+30 −0
Original line number Diff line number Diff line
@@ -639,4 +639,34 @@ public final class AvrcpItemTest {
        Assert.assertEquals(uri, desc.getIconUri());
        Assert.assertEquals(null, desc.getIconBitmap());
    }

    @Test
    public void equals_withItself() {
        AvrcpItem.Builder builder = new AvrcpItem.Builder();

        AvrcpItem item = builder.build();

        Assert.assertTrue(item.equals(item));
    }

    @Test
    public void equals_withDifferentInstance() {
        AvrcpItem.Builder builder = new AvrcpItem.Builder();
        String notAvrcpItem = "notAvrcpItem";

        AvrcpItem item = builder.build();

        Assert.assertFalse(item.equals(notAvrcpItem));
    }

    @Test
    public void equals_withItemContainingSameInfo() {
        AvrcpItem.Builder builder = new AvrcpItem.Builder();
        AvrcpItem.Builder builderEqual = new AvrcpItem.Builder();

        AvrcpItem item = builder.build();
        AvrcpItem itemEqual = builderEqual.build();

        Assert.assertTrue(item.equals(itemEqual));
    }
}
+35 −8
Original line number Diff line number Diff line
@@ -289,4 +289,31 @@ public class BipAttachmentFormatTest {
                null);
        Assert.assertEquals(expectedRequiredOnly, attachment.toString());
    }

    @Test
    public void testEquals_withSameInstance() {
        BipAttachmentFormat attachment = new BipAttachmentFormat("text/plain", null,
                "thisisatextfile.txt", -1, null, null);

        Assert.assertTrue(attachment.equals(attachment));
    }

    @Test
    public void testEquals_withDifferentClass() {
        BipAttachmentFormat attachment = new BipAttachmentFormat("text/plain", null,
                "thisisatextfile.txt", -1, null, null);
        String notAttachment = "notAttachment";

        Assert.assertFalse(attachment.equals(notAttachment));
    }

    @Test
    public void testEquals_withSameInfo() {
        BipAttachmentFormat attachment = new BipAttachmentFormat("text/plain", null,
                "thisisatextfile.txt", -1, null, null);
        BipAttachmentFormat attachmentEqual = new BipAttachmentFormat("text/plain", null,
                "thisisatextfile.txt", -1, null, null);

        Assert.assertTrue(attachment.equals(attachmentEqual));
    }
}
+36 −3
Original line number Diff line number Diff line
@@ -176,4 +176,37 @@ public class BipDatetimeTest {
        testCreate(makeDate(1, 1, 2000, 23, 59, 59, utc), "20000101T235959Z");
        testCreate(makeDate(11, 27, 2050, 23, 59, 59, utc), "20501127T235959Z");
    }

    @Test
    public void testEquals_withSameInstance() {
        TimeZone utc = TimeZone.getTimeZone("UTC");
        utc.setRawOffset(0);

        BipDateTime bipDate = new BipDateTime(makeDate(1, 1, 2000, 6, 1, 15, utc));

        Assert.assertTrue(bipDate.equals(bipDate));
    }

    @Test
    public void testEquals_withDifferentClass() {
        TimeZone utc = TimeZone.getTimeZone("UTC");
        utc.setRawOffset(0);

        BipDateTime bipDate = new BipDateTime(makeDate(1, 1, 2000, 6, 1, 15, utc));
        String notBipDate = "notBipDate";

        Assert.assertFalse(bipDate.equals(notBipDate));
    }

    @Test
    public void testEquals_withSameInfo() {
        TimeZone utc = TimeZone.getTimeZone("UTC");
        utc.setRawOffset(0);
        Date date = makeDate(1, 1, 2000, 6, 1, 15, utc);

        BipDateTime bipDate = new BipDateTime(date);
        BipDateTime bipDateEqual = new BipDateTime(date);

        Assert.assertTrue(bipDate.equals(bipDateEqual));
    }
}
+30 −0
Original line number Diff line number Diff line
@@ -216,4 +216,34 @@ public class BipImageDescriptorTest {
        BipImageDescriptor descriptor = builder.build();
        Assert.assertEquals(null, descriptor.toString());
    }

    @Test
    public void testEquals_sameInstance() {
        BipImageDescriptor.Builder builder = new BipImageDescriptor.Builder();

        BipImageDescriptor descriptor = builder.build();

        Assert.assertTrue(descriptor.equals(descriptor));
    }

    @Test
    public void testEquals_differentClass() {
        BipImageDescriptor.Builder builder = new BipImageDescriptor.Builder();

        BipImageDescriptor descriptor = builder.build();
        String notDescriptor = "notDescriptor";

        Assert.assertFalse(descriptor.equals(notDescriptor));
    }

    @Test
    public void testEquals_sameInfo() {
        BipImageDescriptor.Builder builder = new BipImageDescriptor.Builder();
        BipImageDescriptor.Builder builderEqual = new BipImageDescriptor.Builder();

        BipImageDescriptor descriptor = builder.build();
        BipImageDescriptor descriptorEqual = builderEqual.build();

        Assert.assertTrue(descriptor.equals(descriptorEqual));
    }
}
Loading