mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-04 09:56:49 +00:00
Update bubble stash test for transient taskbar
Include unit test to check that view properties are set to expected values at the end of an unstash animation. Add tests to check that alpha for bubbles and background changes separately during unstash and stash animations. Bug: 345488489 Test: TransientBubbleStashControllerTest Flag: com.android.wm.shell.enable_bubble_bar Change-Id: Ifd10d4524128d42d23fe67c0eff2c4ae16d3b27b
This commit is contained in:
@@ -29,6 +29,7 @@ import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
|
||||
import com.android.launcher3.anim.AnimatedFloat
|
||||
import com.android.launcher3.taskbar.StashedHandleView
|
||||
import com.android.launcher3.taskbar.TaskbarInsetsController
|
||||
import com.android.launcher3.taskbar.TaskbarStashController
|
||||
import com.android.launcher3.taskbar.bubbles.BubbleBarView
|
||||
import com.android.launcher3.taskbar.bubbles.BubbleBarViewController
|
||||
import com.android.launcher3.taskbar.bubbles.BubbleStashedHandleViewController
|
||||
@@ -36,6 +37,7 @@ import com.android.launcher3.taskbar.bubbles.BubbleView
|
||||
import com.android.launcher3.util.MultiValueAlpha
|
||||
import com.android.wm.shell.shared.animation.PhysicsAnimator
|
||||
import com.android.wm.shell.shared.animation.PhysicsAnimatorTestUtils
|
||||
import com.google.common.collect.Range
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
@@ -59,7 +61,7 @@ class TransientBubbleStashControllerTest {
|
||||
const val BUBBLE_BAR_WIDTH = 200
|
||||
const val BUBBLE_BAR_HEIGHT = 100
|
||||
const val HOTSEAT_TRANSLATION_Y = -45f
|
||||
const val TASK_BAR_TRANSLATION_Y = -TASKBAR_BOTTOM_SPACE
|
||||
const val TASK_BAR_TRANSLATION_Y = -TASKBAR_BOTTOM_SPACE.toFloat()
|
||||
const val HANDLE_VIEW_WIDTH = 150
|
||||
const val HANDLE_VIEW_HEIGHT = 4
|
||||
const val BUBBLE_BAR_STASHED_TRANSLATION_Y = -4.5f
|
||||
@@ -195,6 +197,93 @@ class TransientBubbleStashControllerTest {
|
||||
assertThat(bubbleView.alpha).isEqualTo(1f)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun updateStashedAndExpandedState_unstash_bubbleBarShown_stashedHandleHidden() {
|
||||
// Given bubble bar has bubbles and is stashed
|
||||
mTransientBubbleStashController.isStashed = true
|
||||
whenever(bubbleBarViewController.isHiddenForNoBubbles).thenReturn(false)
|
||||
|
||||
val bubbleInitialTranslation = bubbleView.translationY
|
||||
|
||||
// When unstash
|
||||
getInstrumentation().runOnMainSync {
|
||||
mTransientBubbleStashController.updateStashedAndExpandedState(
|
||||
stash = false,
|
||||
expand = false,
|
||||
)
|
||||
}
|
||||
|
||||
// Wait until animations ends
|
||||
advanceTimeBy(BubbleStashController.BAR_STASH_DURATION)
|
||||
PhysicsAnimatorTestUtils.blockUntilAnimationsEnd(DynamicAnimation.TRANSLATION_Y)
|
||||
|
||||
// Then check BubbleBarController is notified
|
||||
verify(bubbleBarViewController).onStashStateChanging()
|
||||
// Bubble bar is unstashed
|
||||
assertThat(mTransientBubbleStashController.isStashed).isFalse()
|
||||
assertThat(bubbleBarView.translationY).isEqualTo(TASK_BAR_TRANSLATION_Y)
|
||||
assertThat(bubbleBarView.alpha).isEqualTo(1f)
|
||||
assertThat(bubbleBarView.scaleX).isEqualTo(1f)
|
||||
assertThat(bubbleBarView.scaleY).isEqualTo(1f)
|
||||
assertThat(bubbleBarView.background.alpha).isEqualTo(255)
|
||||
// Handle view is hidden
|
||||
assertThat(stashedHandleView.translationY).isEqualTo(0)
|
||||
assertThat(stashedHandleView.alpha).isEqualTo(0)
|
||||
// Bubble view is reset
|
||||
assertThat(bubbleView.translationY).isEqualTo(bubbleInitialTranslation)
|
||||
assertThat(bubbleView.alpha).isEqualTo(1f)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun updateStashedAndExpandedState_stash_animatesAlphaForBubblesAndBackgroundSeparately() {
|
||||
// Given bubble bar has bubbles and is unstashed
|
||||
mTransientBubbleStashController.isStashed = false
|
||||
whenever(bubbleBarViewController.isHiddenForNoBubbles).thenReturn(false)
|
||||
|
||||
// When unstash
|
||||
getInstrumentation().runOnMainSync {
|
||||
mTransientBubbleStashController.updateStashedAndExpandedState(
|
||||
stash = true,
|
||||
expand = false,
|
||||
)
|
||||
}
|
||||
|
||||
// Stop after alpha starts
|
||||
advanceTimeBy(TaskbarStashController.TASKBAR_STASH_ALPHA_START_DELAY + 10)
|
||||
|
||||
// Bubble bar alpha is set to 1
|
||||
assertThat(bubbleBarView.alpha).isEqualTo(1f)
|
||||
// We animate alpha for background and children separately
|
||||
assertThat(bubbleView.alpha).isIn(Range.open(0f, 1f))
|
||||
assertThat(bubbleBarView.background.alpha).isIn(Range.open(0, 255))
|
||||
assertThat(bubbleBarView.background.alpha).isNotEqualTo((bubbleView.alpha * 255f).toInt())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun updateStashedAndExpandedState_unstash_animatesAlphaForBubblesAndBackgroundSeparately() {
|
||||
// Given bubble bar has bubbles and is stashed
|
||||
mTransientBubbleStashController.isStashed = true
|
||||
whenever(bubbleBarViewController.isHiddenForNoBubbles).thenReturn(false)
|
||||
|
||||
// When unstash
|
||||
getInstrumentation().runOnMainSync {
|
||||
mTransientBubbleStashController.updateStashedAndExpandedState(
|
||||
stash = false,
|
||||
expand = false,
|
||||
)
|
||||
}
|
||||
|
||||
// Stop after alpha starts
|
||||
advanceTimeBy(TaskbarStashController.TASKBAR_STASH_ALPHA_START_DELAY + 10)
|
||||
|
||||
// Bubble bar alpha is set to 1
|
||||
assertThat(bubbleBarView.alpha).isEqualTo(1f)
|
||||
// We animate alpha for background and children separately
|
||||
assertThat(bubbleView.alpha).isIn(Range.open(0f, 1f))
|
||||
assertThat(bubbleBarView.background.alpha).isIn(Range.open(0, 255))
|
||||
assertThat(bubbleBarView.background.alpha).isNotEqualTo((bubbleView.alpha * 255f).toInt())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun isSysuiLockedSwitchedToFalseForOverview_unlockAnimationIsShown() {
|
||||
// Given screen is locked and bubble bar has bubbles
|
||||
|
||||
Reference in New Issue
Block a user