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
This commit is contained in:
Hawkwood Glazier
2022-09-07 15:39:29 +00:00
parent 38b3e55858
commit 9d6e679a4e

View File

@@ -189,8 +189,13 @@ class AnimatableClockView @JvmOverloads constructor(
override fun onDraw(canvas: Canvas) { override fun onDraw(canvas: Canvas) {
lastDraw = getTimestamp() 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.
textAnimator?.draw(canvas) // Otherwise default to using standard draw functions.
if (isAnimationEnabled) {
textAnimator?.draw(canvas)
} else {
super.onDraw(canvas)
}
} }
override fun invalidate() { override fun invalidate() {
@@ -345,6 +350,9 @@ class AnimatableClockView @JvmOverloads constructor(
onAnimationEnd = onAnimationEnd onAnimationEnd = onAnimationEnd
) )
textAnimator?.glyphFilter = glyphFilter textAnimator?.glyphFilter = glyphFilter
if (color != null && !isAnimationEnabled) {
setTextColor(color)
}
} else { } else {
// when the text animator is set, update its start values // when the text animator is set, update its start values
onTextAnimatorInitialized = Runnable { onTextAnimatorInitialized = Runnable {
@@ -359,6 +367,9 @@ class AnimatableClockView @JvmOverloads constructor(
onAnimationEnd = onAnimationEnd onAnimationEnd = onAnimationEnd
) )
textAnimator?.glyphFilter = glyphFilter textAnimator?.glyphFilter = glyphFilter
if (color != null && !isAnimationEnabled) {
setTextColor(color)
}
} }
} }
} }