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

Commit 8417d27f authored by Hawkwood Glazier's avatar Hawkwood Glazier
Browse files

Deflake Lockscreen Clock Screenshot Tests

Disabling the TextAnimator when animation is disabled should produce
consistent text between runs of the screenshot test.

Fixes: 243942947
Test: atest KeyguardClockSwitchScreenshotTest
Change-Id: Ifaa060a1212331756ad412f1e6027c140fa35921
Merged-In: Ifaa060a1212331756ad412f1e6027c140fa35921
parent bd92f05e
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -185,8 +185,13 @@ class AnimatableClockView @JvmOverloads constructor(

    override fun onDraw(canvas: Canvas) {
        lastDraw = getTimestamp()
        // intentionally doesn't call super.onDraw here or else the text will be rendered twice
        // Use textAnimator to render text if animation is enabled.
        // Otherwise default to using standard draw functions.
        if (isAnimationEnabled) {
            textAnimator?.draw(canvas)
        } else {
            super.onDraw(canvas)
        }
    }

    override fun invalidate() {
@@ -340,6 +345,9 @@ class AnimatableClockView @JvmOverloads constructor(
                onAnimationEnd = onAnimationEnd
            )
            textAnimator?.glyphFilter = glyphFilter
            if (color != null && !isAnimationEnabled) {
                setTextColor(color)
            }
        } else {
            // when the text animator is set, update its start values
            onTextAnimatorInitialized = Runnable {
@@ -354,6 +362,9 @@ class AnimatableClockView @JvmOverloads constructor(
                    onAnimationEnd = onAnimationEnd
                )
                textAnimator?.glyphFilter = glyphFilter
                if (color != null && !isAnimationEnabled) {
                    setTextColor(color)
                }
            }
        }
    }