summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Joshua Tsuji <tsuji@google.com> 2019-12-19 15:54:12 -0500
committer Joshua Tsuji <tsuji@google.com> 2019-12-19 15:54:17 -0500
commitba5f0fe3d403a3eadb590b277d0faba465247a08 (patch)
treecfbb969373ede9107faad1836a2f2cd34b5f194d
parent60cadb2368711b10ec12c9e909c34f34440c5782 (diff)
Fix occassional CME in physics tests.
Test: atest SystemUITests Change-Id: I93748f7efa2dc4ea69854c17d62d048159a8b03d
-rw-r--r--packages/SystemUI/src/com/android/systemui/util/animation/PhysicsAnimatorTestUtils.kt11
1 files changed, 9 insertions, 2 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/util/animation/PhysicsAnimatorTestUtils.kt b/packages/SystemUI/src/com/android/systemui/util/animation/PhysicsAnimatorTestUtils.kt
index a1f74eb40cad..19b9cf41db14 100644
--- a/packages/SystemUI/src/com/android/systemui/util/animation/PhysicsAnimatorTestUtils.kt
+++ b/packages/SystemUI/src/com/android/systemui/util/animation/PhysicsAnimatorTestUtils.kt
@@ -236,6 +236,14 @@ object PhysicsAnimatorTestUtils {
vararg additionalUpdateMatchers: UpdateMatcher
) {
val updateFrames: UpdateFramesPerProperty<T> = getAnimationUpdateFrames(animator)
+
+ if (!updateFrames.containsKey(property)) {
+ error("No frames for given target object and property.")
+ }
+
+ // Copy the frames to avoid a ConcurrentModificationException if the animation update
+ // listeners attempt to add a new frame while we're verifying these.
+ val framesForProperty = ArrayList(updateFrames[property]!!)
val matchers = ArrayDeque<UpdateMatcher>(
additionalUpdateMatchers.toList())
val frameTraceMessage = StringBuilder()
@@ -243,8 +251,7 @@ object PhysicsAnimatorTestUtils {
var curMatcher = firstUpdateMatcher
// Loop through the updates from the testable animator.
- for (update in updateFrames[property]
- ?: error("No frames for given target object and property.")) {
+ for (update in framesForProperty) {
// Check whether this frame satisfies the current matcher.
if (curMatcher(update)) {