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

Commit c2a99a2f authored by lyn's avatar lyn
Browse files

Test applying filters to bundle and children

Bug: 389839319
Test: this
Flag: TEST_ONLY
Change-Id: I667d0e7f4ff1ec84fe6917daf191976ebebce086
parent 33e70760
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -612,7 +612,6 @@ public class ShadeListBuilder implements Dumpable, PipelineDumpable {
    private void applyFilterToBundle(BundleEntry bundleEntry, long now, List<NotifFilter> filters) {
        List<ListEntry> bundleChildren = bundleEntry.getChildren();
        List<ListEntry> bundleChildrenToRemove = new ArrayList();
        // TODO(b/399736937) Add tests
        for (ListEntry listEntry : bundleChildren) {
            if (listEntry instanceof GroupEntry groupEntry) {
                applyFilterToGroup(groupEntry, now, filters);
+42 −0
Original line number Diff line number Diff line
@@ -1283,6 +1283,48 @@ public class ShadeListBuilderTest extends SysuiTestCase {
        verify(filter3).shouldFilterOut(mEntrySet.get(1), 10047);
    }

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

        // GIVEN a notif filter
        NotifFilter filter1 = spy(new PackageFilter(PACKAGE_1));
        mListBuilder.addPreGroupFilter(filter1);

        // GIVEN two notifs and one group that will be bundled
        addNotif(0, PACKAGE_1, BUNDLE_1);
        addNotif(1, PACKAGE_2, BUNDLE_1);
        addGroupChild(2, PACKAGE_1, GROUP_1, BUNDLE_1);
        addGroupChild(3, PACKAGE_1, GROUP_1, BUNDLE_1);
        addGroupSummary(4, PACKAGE_1, GROUP_1, BUNDLE_1);
        dispatchBuild();

        // VERIFY that filters were applied to notif and group
        verifyBuiltList(
                bundle(
                        BUNDLE_1,
                        notif(1)
                )
        );
    }

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

        // GIVEN a notif filter
        NotifFilter filter1 = spy(new PackageFilter(PACKAGE_1));
        mListBuilder.addPreGroupFilter(filter1);

        // GIVEN a notif that will be bundled
        addNotif(0, PACKAGE_1, BUNDLE_1);
        dispatchBuild();

        // VERIFY that filters was applied and bundle was pruned
        verifyBuiltList();
    }


    @Test
    public void testGroupTransformEntries() {
        // GIVEN a registered OnBeforeTransformGroupsListener