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

Commit ab5f8b23 authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Migrate notification cancelation to entryadapter" into main

parents b57f65c4 32626a51
Loading
Loading
Loading
Loading
+10 −20
Original line number Diff line number Diff line
@@ -37,7 +37,10 @@ import org.junit.runner.RunWith
@SmallTest
@RunWith(AndroidJUnit4::class)
@RunWithLooper
@EnableFlags(NotificationBundleUi.FLAG_NAME)
class BundleEntryAdapterTest : SysuiTestCase() {
    private lateinit var entry: BundleEntry

    private val kosmos = testKosmos()
    private lateinit var underTest: BundleEntryAdapter

@@ -46,120 +49,107 @@ class BundleEntryAdapterTest : SysuiTestCase() {

    @Before
    fun setUp() {
        underTest = factory.create(BundleEntry("key")) as BundleEntryAdapter
        entry = BundleEntry("key")
        underTest = factory.create(entry) as BundleEntryAdapter
    }

    @Test
    fun getBackingHashCode() {
        assertThat(underTest.backingHashCode).isEqualTo(entry.hashCode())
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun getParent_adapter() {
        assertThat(underTest.parent).isEqualTo(GroupEntry.ROOT_ENTRY)
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun isTopLevelEntry_adapter() {
        assertThat(underTest.isTopLevelEntry).isTrue()
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun getRow_adapter() {
        assertThat(underTest.row).isNull()
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun isGroupRoot_adapter() {
        assertThat(underTest.isGroupRoot).isTrue()
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun getKey_adapter() {
        assertThat(underTest.key).isEqualTo("key")
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun isClearable_adapter() {
        assertThat(underTest.isClearable).isTrue()
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun getSummarization_adapter() {
        assertThat(underTest.summarization).isNull()
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun getContrastedColor_adapter() {
        assertThat(underTest.getContrastedColor(context, false, Color.WHITE))
            .isEqualTo(Notification.COLOR_DEFAULT)
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun canPeek_adapter() {
        assertThat(underTest.canPeek()).isFalse()
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun getWhen_adapter() {
        assertThat(underTest.`when`).isEqualTo(0)
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun isColorized() {
        assertThat(underTest.isColorized).isFalse()
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun getSbn() {
        assertThat(underTest.sbn).isNull()
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun canDragAndDrop() {
        assertThat(underTest.canDragAndDrop()).isFalse()
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun isBubble() {
        assertThat(underTest.isBubble).isFalse()
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun getStyle() {
        assertThat(underTest.style).isNull()
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun getSectionBucket() {
        assertThat(underTest.sectionBucket).isEqualTo(underTest.entry.bucket)
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun isAmbient() {
        assertThat(underTest.isAmbient).isFalse()
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun canShowFullScreen() {
        assertThat(underTest.isFullScreenCapable()).isFalse()
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun getPeopleNotificationType() {
        assertThat(underTest.getPeopleNotificationType()).isEqualTo(TYPE_NON_PERSON)
    }
+2 −1
Original line number Diff line number Diff line
@@ -1804,7 +1804,8 @@ public class NotifCollectionTest extends SysuiTestCase {
    }

    private static EntryWithDismissStats entryWithDefaultStats(NotificationEntry entry) {
        return new EntryWithDismissStats(entry, defaultStats(entry));
        return new EntryWithDismissStats(
                entry, defaultStats(entry), entry.getKey(), entry.hashCode());
    }

    private CollectionEvent postNotif(NotificationEntryBuilder builder) {
+11 −0
Original line number Diff line number Diff line
@@ -62,6 +62,17 @@ class NotificationEntryAdapterTest : SysuiTestCase() {

    @get:Rule val setFlagsRule = SetFlagsRule()

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun getBackingHashCode() {
        val entry =
            NotificationEntryBuilder()
                .build()

        underTest = factory.create(entry) as NotificationEntryAdapter
        assertThat(underTest.backingHashCode).isEqualTo(entry.hashCode())
    }

    @Test
    @EnableFlags(NotificationBundleUi.FLAG_NAME)
    fun getParent_adapter() {
+5 −0
Original line number Diff line number Diff line
@@ -33,6 +33,11 @@ class BundleEntryAdapter(
    private val highPriorityProvider: HighPriorityProvider,
    val entry: BundleEntry,
) : EntryAdapter {

    override fun getBackingHashCode(): Int {
        return entry.hashCode()
    }

    /** TODO (b/394483200): convert to PipelineEntry.ROOT_ENTRY when pipeline is migrated? */
    override fun getParent(): GroupEntry {
        return GroupEntry.ROOT_ENTRY
+6 −0
Original line number Diff line number Diff line
@@ -35,6 +35,11 @@ import kotlinx.coroutines.flow.StateFlow;
 */
public interface EntryAdapter {

    /**
     * Returns the hash code of the backing entry
     */
    int getBackingHashCode();

    /**
     * Gets the parent of this entry, or null if the entry's view is not attached
     */
@@ -195,5 +200,6 @@ public interface EntryAdapter {
    NotificationEntry.DismissState getDismissState();

    void onEntryClicked(ExpandableNotificationRow row);

}
Loading