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

Commit 2dcec3b1 authored by AI test gen's avatar AI test gen Committed by Ang Li
Browse files

Add test for quick switch animation race condition

Adds a new unit test to verify that the expanded view's visibility is correctly set to VISIBLE at the start of a switch-in animation.

This test simulates a race condition that can occur during a rapid switch between bubbles (e.g., A -> B -> A). It ensures that even if the "switch out" animation for a bubble (A) finishes late and sets its visibility to INVISIBLE, the subsequent "switch in" animation for that same bubble will correctly restore its visibility to VISIBLE, preventing the bubble from disappearing.

Original Change: ag/34894797 (Note tests are based on the original CL but may add coverage beyond the specific changes to improve overall code health)

Please help fill out the survey for feedback: https://docs.google.com/forms/d/e/1FAIpQLSeKFKpHImCAqZIa_OR801cw72HQUreM2oGM25C3mKKT2tBFnw/viewform?usp=pp_url&entry.1586624956=ag/35413245

Please feel free to use your domain knowledge to make changes to the generated tests to make it more valuable for your team.

Test: Without original one-line fix (http://ab/I23600010441008136), With original one-line fix (http://ab/I73200010442187511) AND ATP tests passed http://go/forrest-run/L63600030017457342
Bug: 431235865
Flag: TEST_ONLY

Change-Id: I8fbc0769e00d9cc2be9433e4d64d4f3ebcafecbb
parent 75720fac
Loading
Loading
Loading
Loading
+21 −0
Original line number Original line Diff line number Diff line
@@ -190,6 +190,27 @@ class BubbleBarAnimationHelperTest {
        assertThat(toBubble.bubbleBarExpandedView?.isSurfaceZOrderedOnTop).isFalse()
        assertThat(toBubble.bubbleBarExpandedView?.isSurfaceZOrderedOnTop).isFalse()
    }
    }


    @Test
    fun animateSwitch_quickSwitch_newlySelectedIsVisible() {
        val bubbleA = createBubble(key = "A").initialize(container)
        val bubbleB = createBubble(key = "B").initialize(container)

        activityScenario.onActivity {
            // Start an animation from A to B
            animationHelper.animateSwitch(
                    bubbleA, bubbleB, /* shouldApplyAsJumpcut= */ false, /* endRunnable= */ null)
            // This simulates Bubble B has finished animating out
            bubbleB.bubbleBarExpandedView!!.visibility = View.INVISIBLE
            // Let it run for a bit, but not finish
            animatorTestRule.advanceTimeBy(100)
        }
        getInstrumentation().waitForIdleSync()

        // Assert that even though we manually set it to INVISIBLE, the animation start
        // callback has corrected it to VISIBLE.
        assertThat(bubbleB.bubbleBarExpandedView?.visibility).isEqualTo(View.VISIBLE)
    }

    @Test
    @Test
    fun animateSwitch_bubbleToBubble_handleColorTransferred() {
    fun animateSwitch_bubbleToBubble_handleColorTransferred() {
        val fromBubble = createBubble(key = "from").initialize(container)
        val fromBubble = createBubble(key = "from").initialize(container)