Loading mechanics/src/com/android/mechanics/impl/Computations.kt +16 −14 Original line number Diff line number Diff line Loading @@ -495,7 +495,8 @@ internal abstract class Computations : CurrentFrameInput, LastFrameState, Static val delta = afterBreakpoint - beforeBreakpoint val deltaIsFinite = delta.fastIsFinite() if (deltaIsFinite && delta != 0f) { if (deltaIsFinite) { if (delta != 0f) { // There is a discontinuity on this breakpoint, that needs to be // animated. The delta is pushed to the spring, to consume the // discontinuity over time. Loading @@ -505,11 +506,12 @@ internal abstract class Computations : CurrentFrameInput, LastFrameState, Static velocityDelta = initialSpringVelocity, ) // When *first* crossing a discontinuity in a given frame, the static // mapped velocity observed during previous frame is added as initial // velocity to the spring. This is done ot most once per frame, and only // if there is an actual discontinuity. // When *first* crossing a discontinuity in a given frame, the // static mapped velocity observed during previous frame is added as // initial velocity to the spring. This is done ot most once per // frame, and only if there is an actual discontinuity. initialSpringVelocity = 0f } } else { // The before and / or after mapping produced an non-finite number, // which is not allowed. This intentionally crashes eng-builds, since Loading mechanics/tests/goldens/segmentChange_inMaxDirection_zeroDelta.json 0 → 100644 +82 −0 Original line number Diff line number Diff line { "frame_ids": [ 0, 16, 32, 48 ], "features": [ { "name": "input", "type": "float", "data_points": [ 0, 0.5, 1, 1 ] }, { "name": "gestureDirection", "type": "string", "data_points": [ "Max", "Max", "Max", "Max" ] }, { "name": "output", "type": "float", "data_points": [ 0, 0, 0, 0 ] }, { "name": "outputTarget", "type": "float", "data_points": [ 0, 0, 0, 0 ] }, { "name": "outputSpring", "type": "springParameters", "data_points": [ { "stiffness": 100000, "dampingRatio": 1 }, { "stiffness": 700, "dampingRatio": 0.9 }, { "stiffness": 700, "dampingRatio": 0.9 }, { "stiffness": 700, "dampingRatio": 0.9 } ] }, { "name": "isStable", "type": "boolean", "data_points": [ true, true, true, true ] } ] } No newline at end of file mechanics/tests/src/com/android/mechanics/MotionValueTest.kt +7 −9 Original line number Diff line number Diff line Loading @@ -111,6 +111,13 @@ class MotionValueTest : MotionBuilderContext by FakeMotionSpecBuilderContext.Def awaitStable() } @Test fun segmentChange_inMaxDirection_zeroDelta() = motion.goldenTest(spec = specBuilder(Mapping.Zero) { fixedValueFromCurrent(0.5f) }) { animateValueTo(1f, changePerFrame = 0.5f) awaitStable() } @Test fun segmentChange_inMinDirection_animatedWhenReachingBreakpoint() = motion.goldenTest( Loading Loading @@ -198,9 +205,6 @@ class MotionValueTest : MotionBuilderContext by FakeMotionSpecBuilderContext.Def ) { animateValueTo(21f, changePerFrame = 3f) awaitStable() // TODO(b/420622452) This test should not produce a WTF log. wtfLog.removeLoggedFailures() } @Test Loading @@ -214,9 +218,6 @@ class MotionValueTest : MotionBuilderContext by FakeMotionSpecBuilderContext.Def ) { animateValueTo(30f, changePerFrame = 3f) awaitStable() // TODO(b/420622452) This test should not produce a WTF log. wtfLog.removeLoggedFailures() } @Test Loading Loading @@ -248,9 +249,6 @@ class MotionValueTest : MotionBuilderContext by FakeMotionSpecBuilderContext.Def awaitStable() animateValueTo(3f) awaitStable() // TODO(b/420622452) This test should not produce a WTF log. wtfLog.removeLoggedFailures() } @Test Loading Loading
mechanics/src/com/android/mechanics/impl/Computations.kt +16 −14 Original line number Diff line number Diff line Loading @@ -495,7 +495,8 @@ internal abstract class Computations : CurrentFrameInput, LastFrameState, Static val delta = afterBreakpoint - beforeBreakpoint val deltaIsFinite = delta.fastIsFinite() if (deltaIsFinite && delta != 0f) { if (deltaIsFinite) { if (delta != 0f) { // There is a discontinuity on this breakpoint, that needs to be // animated. The delta is pushed to the spring, to consume the // discontinuity over time. Loading @@ -505,11 +506,12 @@ internal abstract class Computations : CurrentFrameInput, LastFrameState, Static velocityDelta = initialSpringVelocity, ) // When *first* crossing a discontinuity in a given frame, the static // mapped velocity observed during previous frame is added as initial // velocity to the spring. This is done ot most once per frame, and only // if there is an actual discontinuity. // When *first* crossing a discontinuity in a given frame, the // static mapped velocity observed during previous frame is added as // initial velocity to the spring. This is done ot most once per // frame, and only if there is an actual discontinuity. initialSpringVelocity = 0f } } else { // The before and / or after mapping produced an non-finite number, // which is not allowed. This intentionally crashes eng-builds, since Loading
mechanics/tests/goldens/segmentChange_inMaxDirection_zeroDelta.json 0 → 100644 +82 −0 Original line number Diff line number Diff line { "frame_ids": [ 0, 16, 32, 48 ], "features": [ { "name": "input", "type": "float", "data_points": [ 0, 0.5, 1, 1 ] }, { "name": "gestureDirection", "type": "string", "data_points": [ "Max", "Max", "Max", "Max" ] }, { "name": "output", "type": "float", "data_points": [ 0, 0, 0, 0 ] }, { "name": "outputTarget", "type": "float", "data_points": [ 0, 0, 0, 0 ] }, { "name": "outputSpring", "type": "springParameters", "data_points": [ { "stiffness": 100000, "dampingRatio": 1 }, { "stiffness": 700, "dampingRatio": 0.9 }, { "stiffness": 700, "dampingRatio": 0.9 }, { "stiffness": 700, "dampingRatio": 0.9 } ] }, { "name": "isStable", "type": "boolean", "data_points": [ true, true, true, true ] } ] } No newline at end of file
mechanics/tests/src/com/android/mechanics/MotionValueTest.kt +7 −9 Original line number Diff line number Diff line Loading @@ -111,6 +111,13 @@ class MotionValueTest : MotionBuilderContext by FakeMotionSpecBuilderContext.Def awaitStable() } @Test fun segmentChange_inMaxDirection_zeroDelta() = motion.goldenTest(spec = specBuilder(Mapping.Zero) { fixedValueFromCurrent(0.5f) }) { animateValueTo(1f, changePerFrame = 0.5f) awaitStable() } @Test fun segmentChange_inMinDirection_animatedWhenReachingBreakpoint() = motion.goldenTest( Loading Loading @@ -198,9 +205,6 @@ class MotionValueTest : MotionBuilderContext by FakeMotionSpecBuilderContext.Def ) { animateValueTo(21f, changePerFrame = 3f) awaitStable() // TODO(b/420622452) This test should not produce a WTF log. wtfLog.removeLoggedFailures() } @Test Loading @@ -214,9 +218,6 @@ class MotionValueTest : MotionBuilderContext by FakeMotionSpecBuilderContext.Def ) { animateValueTo(30f, changePerFrame = 3f) awaitStable() // TODO(b/420622452) This test should not produce a WTF log. wtfLog.removeLoggedFailures() } @Test Loading Loading @@ -248,9 +249,6 @@ class MotionValueTest : MotionBuilderContext by FakeMotionSpecBuilderContext.Def awaitStable() animateValueTo(3f) awaitStable() // TODO(b/420622452) This test should not produce a WTF log. wtfLog.removeLoggedFailures() } @Test Loading