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

Commit 7e4e66b1 authored by Lyn Han's avatar Lyn Han Committed by Android (Google) Code Review
Browse files

Merge "Clear previousHunKey when removing last avalanche HUN" into main

parents 5c7b4325 fb88bc79
Loading
Loading
Loading
Loading
+25 −7
Original line number Diff line number Diff line
@@ -249,22 +249,40 @@ class AvalancheControllerTest : SysuiTestCase() {


    @Test
    fun testDelete_showingEntryKeyBecomesPreviousHunKey() {
    fun testDelete_deleteSecondToLastEntry_showingEntryKeyBecomesPreviousHunKey() {
        mAvalancheController.previousHunKey = ""

        // Entry is showing
        val showingEntry = createHeadsUpEntry(id = 0)
        mAvalancheController.headsUpEntryShowing = showingEntry
        val firstEntry = createHeadsUpEntry(id = 0)
        mAvalancheController.headsUpEntryShowing = firstEntry

        // There's another entry waiting to show next
        val nextEntry = createHeadsUpEntry(id = 1)
        mAvalancheController.addToNext(nextEntry, runnableMock!!)
        val secondEntry = createHeadsUpEntry(id = 1)
        mAvalancheController.addToNext(secondEntry, runnableMock!!)

        // Delete
        mAvalancheController.delete(showingEntry, runnableMock, "testLabel")
        mAvalancheController.delete(firstEntry, runnableMock, "testLabel")

        // Next entry is shown
        assertThat(mAvalancheController.previousHunKey).isEqualTo(firstEntry.mEntry!!.key)
    }

    @Test
    fun testDelete_deleteLastEntry_previousHunKeyCleared() {
        mAvalancheController.previousHunKey = "key"

        // Nothing waiting to show
        mAvalancheController.clearNext()

        // One entry is showing
        val showingEntry = createHeadsUpEntry(id = 0)
        mAvalancheController.headsUpEntryShowing = showingEntry

        // Delete
        mAvalancheController.delete(showingEntry, runnableMock!!, "testLabel")

        // Next entry is shown
        assertThat(mAvalancheController.previousHunKey).isEqualTo(showingEntry.mEntry!!.key)
        assertThat(mAvalancheController.previousHunKey).isEqualTo("");
    }

    @Test
+1 −0
Original line number Diff line number Diff line
@@ -253,6 +253,7 @@ class AvalancheController @Inject constructor(

        if (nextList.isEmpty()) {
            log { "NO MORE TO SHOW" }
            previousHunKey = ""
            return
        }