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

Commit 33e70760 authored by lyn's avatar lyn
Browse files

Test assign section to bundle and children

Bug: 389839319
Test: this
Flag: TEST_ONLY
Change-Id: I397aefec0eda68a655197aa55d90328d947bada8
parent caaa6489
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -1273,7 +1273,6 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable {
    private void assignSections() {
        Trace.beginSection("ShadeListBuilder.assignSections");
        // Assign sections to top-level elements and their children
        // TODO(b/399736937) Add tests.
        for (PipelineEntry entry : mNotifList) {
            NotifSection section = applySections(entry);

+50 −0
Original line number Diff line number Diff line
@@ -996,6 +996,53 @@ public class ShadeListBuilderTest extends SysuiTestCase {
        assertEquals(1, notif(0).entry.getSectionIndex());
    }

    @Test
    public void testBundle_childrenAssignedSection() {
        mListBuilder.setBundler(TestBundler.INSTANCE);

        // GIVEN a Section for Package1
        final NotifSectioner pkg2Section = spy(new PackageSectioner(PACKAGE_1));
        mListBuilder.setSectioners(singletonList(pkg2Section));

        // WHEN we build a list with a notif and group that will be bundled
        addNotif(0, PACKAGE_1, BUNDLE_1);
        addGroupChild(1, PACKAGE_1, GROUP_1, BUNDLE_1);
        addGroupChild(2, PACKAGE_1, GROUP_1, BUNDLE_1);
        addGroupSummary(3, PACKAGE_1, GROUP_1, BUNDLE_1);
        dispatchBuild();

        // THEN the notif and group are bundled
        verifyBuiltList(
            bundle(
                BUNDLE_1,
                notif(0),
                group(
                    summary(3),
                    child(1),
                    child(2)
                )
            )
        );

        assertEquals(1, mBuiltList.size());
        PipelineEntry pipelineEntry = mBuiltList.get(0);
        assertThat(pipelineEntry instanceof BundleEntry).isTrue();

        // VERIFY all pipeline entries are assigned sections
        BundleEntry bundleEntry = (BundleEntry) pipelineEntry;
        assertNotNull(bundleEntry.getSection());

        for (ListEntry listEntry: bundleEntry.getChildren()) {
            assertNotNull(listEntry.getSection());

            if (listEntry instanceof GroupEntry groupEntry) {
                for (NotificationEntry child: groupEntry.getChildren()) {
                    assertNotNull(child.getSection());
                }
            }
        }
    }

    @Test
    public void testThatNotifComparatorsAreCalled() {
        // GIVEN a set of comparators that care about specific packages
@@ -2868,6 +2915,9 @@ public class ShadeListBuilderTest extends SysuiTestCase {

        @Override
        public boolean isInSection(PipelineEntry entry) {
            if (entry instanceof BundleEntry) {
                return true;
            }
            return mPackages.contains(
                    entry.asListEntry().getRepresentativeEntry().getSbn().getPackageName());
        }