From 20d23f473aa274507caa3db76ca55de77c711f83 Mon Sep 17 00:00:00 2001 From: Jordan Silva Date: Wed, 28 Jun 2023 16:59:33 +0100 Subject: [PATCH] Add function to update SysUiScrim duration for tests A new function was added to update the animation duration to 0 for testing. Fix: 288392860 Test: HomeScreenFolderImageTest Test: ResponsiveHomeScreenFolderImageTest Flag: N/A Change-Id: If0c9c169eb3339ae2940c88c57d69728ee844f71 --- src/com/android/launcher3/graphics/SysUiScrim.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/com/android/launcher3/graphics/SysUiScrim.java b/src/com/android/launcher3/graphics/SysUiScrim.java index a572a607a6..66001d8125 100644 --- a/src/com/android/launcher3/graphics/SysUiScrim.java +++ b/src/com/android/launcher3/graphics/SysUiScrim.java @@ -32,6 +32,7 @@ import android.util.DisplayMetrics; import android.view.View; import androidx.annotation.ColorInt; +import androidx.annotation.VisibleForTesting; import com.android.launcher3.BaseDraggingActivity; import com.android.launcher3.DeviceProfile; @@ -87,6 +88,7 @@ public class SysUiScrim implements View.OnAttachStateChangeListener { private final View mRoot; private final BaseDraggingActivity mActivity; private final boolean mHideSysUiScrim; + private boolean mSkipScrimAnimationForTest = false; private boolean mAnimateScrimOnNextDraw = false; private final AnimatedFloat mSysUiAnimMultiplier = new AnimatedFloat(this::reapplySysUiAlpha); @@ -189,6 +191,15 @@ public class SysUiScrim implements View.OnAttachStateChangeListener { mBottomMaskRect.set(0, h - mBottomMaskHeight, w, h); } + /** + * Sets whether the SysUiScrim should hide for testing. + */ + @VisibleForTesting + public void skipScrimAnimation() { + mSkipScrimAnimationForTest = true; + reapplySysUiAlpha(); + } + private void reapplySysUiAlpha() { reapplySysUiAlphaNoInvalidate(); if (!mHideSysUiScrim) { @@ -198,6 +209,7 @@ public class SysUiScrim implements View.OnAttachStateChangeListener { private void reapplySysUiAlphaNoInvalidate() { float factor = mSysUiProgress.value * mSysUiAnimMultiplier.value; + if (mSkipScrimAnimationForTest) factor = 1f; mBottomMaskPaint.setAlpha(Math.round(MAX_SYSUI_SCRIM_ALPHA * factor)); mTopMaskPaint.setAlpha(Math.round(MAX_SYSUI_SCRIM_ALPHA * factor)); }