Merge "Rename constantValue* into fixedValue*" into main
diff --git a/mechanics/benchmark/tests/src/com/android/mechanics/benchmark/MotionValueBenchmark.kt b/mechanics/benchmark/tests/src/com/android/mechanics/benchmark/MotionValueBenchmark.kt
index 7a181e6..f5eab76 100644
--- a/mechanics/benchmark/tests/src/com/android/mechanics/benchmark/MotionValueBenchmark.kt
+++ b/mechanics/benchmark/tests/src/com/android/mechanics/benchmark/MotionValueBenchmark.kt
@@ -173,7 +173,7 @@
defaultSpring = SpringParameters(stiffness = 300f, dampingRatio = .9f),
initialMapping = Mapping.Zero,
) {
- constantValue(breakpoint = 1f, value = 1f)
+ fixedValue(breakpoint = 1f, value = 1f)
}
)
@@ -232,7 +232,7 @@
defaultSpring = SpringParameters(stiffness = 300f, dampingRatio = .9f),
initialMapping = Mapping.Zero,
) {
- constantValue(
+ fixedValue(
breakpoint = 1f,
value = 1f,
guarantee = Guarantee.GestureDragDelta(1f),
diff --git a/mechanics/src/com/android/mechanics/behavior/VerticalExpandContainerSpec.kt b/mechanics/src/com/android/mechanics/behavior/VerticalExpandContainerSpec.kt
index 8e9ed24..3bc264a 100644
--- a/mechanics/src/com/android/mechanics/behavior/VerticalExpandContainerSpec.kt
+++ b/mechanics/src/com/android/mechanics/behavior/VerticalExpandContainerSpec.kt
@@ -130,7 +130,7 @@
return with(density) {
MotionSpec(
directionalMotionSpec(opacitySpring, initialMapping = Mapping.Zero) {
- constantValue(breakpoint = visibleHeight.toPx(), value = 1f)
+ fixedValue(breakpoint = visibleHeight.toPx(), value = 1f)
}
)
}
diff --git a/mechanics/src/com/android/mechanics/spec/builder/DirectionalBuilderImpl.kt b/mechanics/src/com/android/mechanics/spec/builder/DirectionalBuilderImpl.kt
index 17d0be2..88efe33 100644
--- a/mechanics/src/com/android/mechanics/spec/builder/DirectionalBuilderImpl.kt
+++ b/mechanics/src/com/android/mechanics/spec/builder/DirectionalBuilderImpl.kt
@@ -193,7 +193,7 @@
return CanBeLastSegmentImpl
}
- override fun constantValue(
+ override fun fixedValue(
breakpoint: Float,
value: Float,
spring: SpringParameters,
@@ -204,11 +204,11 @@
applySemantics(semantics)
toBreakpointImpl(breakpoint, key)
jumpToImpl(value, spring, guarantee)
- continueWithConstantValueImpl()
+ continueWithFixedValueImpl()
return CanBeLastSegmentImpl
}
- override fun constantValueFromCurrent(
+ override fun fixedValueFromCurrent(
breakpoint: Float,
delta: Float,
spring: SpringParameters,
@@ -219,7 +219,7 @@
applySemantics(semantics)
toBreakpointImpl(breakpoint, key)
jumpByImpl(delta, spring, guarantee)
- continueWithConstantValueImpl()
+ continueWithFixedValueImpl()
return CanBeLastSegmentImpl
}
@@ -258,7 +258,7 @@
fractionalMapping = fraction
}
- private fun continueWithConstantValueImpl() {
+ private fun continueWithFixedValueImpl() {
check(sourceValue.isFinite())
mappings.add(Mapping.Fixed(sourceValue))
diff --git a/mechanics/src/com/android/mechanics/spec/builder/DirectionalBuilderScope.kt b/mechanics/src/com/android/mechanics/spec/builder/DirectionalBuilderScope.kt
index d10c6a7..9eacd8f 100644
--- a/mechanics/src/com/android/mechanics/spec/builder/DirectionalBuilderScope.kt
+++ b/mechanics/src/com/android/mechanics/spec/builder/DirectionalBuilderScope.kt
@@ -155,7 +155,7 @@
/**
* Ends the current segment at the [breakpoint] position and defines the next segment to output
- * a constant value ([value]).
+ * a fixed value ([value]).
*
* Note: This segment can be used as the last segment in the specification.
*
@@ -169,7 +169,7 @@
* @param semantics Updated semantics values to be applied. Must be a subset of the
* [SemanticKey]s used when first creating this builder.
*/
- fun constantValue(
+ fun fixedValue(
breakpoint: Float,
value: Float,
spring: SpringParameters = defaultSpring,
@@ -187,7 +187,7 @@
*
* @param breakpoint The breakpoint defining the end of the current segment and the start of the
* next.
- * @param delta An optional offset to apply to the mapped value to determine the constant value.
+ * @param delta An optional offset to apply to the mapped value to determine the fixed value.
* Defaults to 0f.
* @param spring The [SpringParameters] for the transition to this breakpoint. Defaults to
* [defaultSpring].
@@ -196,7 +196,7 @@
* @param semantics Updated semantics values to be applied. Must be a subset of the
* [SemanticKey]s used when first creating this builder.
*/
- fun constantValueFromCurrent(
+ fun fixedValueFromCurrent(
breakpoint: Float,
delta: Float = 0f,
spring: SpringParameters = defaultSpring,
@@ -238,7 +238,7 @@
*
* @param breakpoint The breakpoint defining the end of the current segment and the start of the
* next.
- * @param delta An optional offset to apply to the mapped value to determine the constant value.
+ * @param delta An optional offset to apply to the mapped value to determine the fixed value.
* @param spring The [SpringParameters] for the transition to this breakpoint.
* @param guarantee The animation guarantee for this transition.
* @param key A unique [BreakpointKey] for this breakpoint.
diff --git a/mechanics/src/com/android/mechanics/spec/builder/DirectionalSpecBuilder.kt b/mechanics/src/com/android/mechanics/spec/builder/DirectionalSpecBuilder.kt
index 8a875d1..b4483b7 100644
--- a/mechanics/src/com/android/mechanics/spec/builder/DirectionalSpecBuilder.kt
+++ b/mechanics/src/com/android/mechanics/spec/builder/DirectionalSpecBuilder.kt
@@ -75,7 +75,7 @@
* target(breakpoint = 10f, from = 0f, to = 50f)
*
* // At breakpoint 20: Jump +5, and constant value 55.
- * constantValueFromCurrent(breakpoint = 20f, delta = 5f)
+ * fixedValueFromCurrent(breakpoint = 20f, delta = 5f)
*
* // At breakpoint 30: Jump to 40. Linear mapping using: progress_since_breakpoint * fraction.
* fractionalInput(breakpoint = 30f, from = 40f, fraction = 2f)
diff --git a/mechanics/testing/src/com/android/mechanics/testing/MotionSpecSubject.kt b/mechanics/testing/src/com/android/mechanics/testing/MotionSpecSubject.kt
index ea036c1..9816d01 100644
--- a/mechanics/testing/src/com/android/mechanics/testing/MotionSpecSubject.kt
+++ b/mechanics/testing/src/com/android/mechanics/testing/MotionSpecSubject.kt
@@ -261,7 +261,7 @@
check("input @ $in2").that(actual?.map(in2)).isEqualTo(out2)
}
- fun isConstantValue(value: Float) {
+ fun isFixedValue(value: Float) {
when (actual) {
is Mapping.Fixed -> check("fixed value").that(actual.value).isEqualTo(value)
is Mapping.Linear -> {
diff --git a/mechanics/tests/src/com/android/mechanics/MotionValueLifecycleTest.kt b/mechanics/tests/src/com/android/mechanics/MotionValueLifecycleTest.kt
index 61796f2..72ba985 100644
--- a/mechanics/tests/src/com/android/mechanics/MotionValueLifecycleTest.kt
+++ b/mechanics/tests/src/com/android/mechanics/MotionValueLifecycleTest.kt
@@ -41,7 +41,7 @@
@Test
fun keepRunning_suspendsWithoutAnAnimation() = runTest {
val input = mutableFloatStateOf(0f)
- val spec = specBuilder(Mapping.Zero) { constantValue(breakpoint = 1f, value = 1f) }
+ val spec = specBuilder(Mapping.Zero) { fixedValue(breakpoint = 1f, value = 1f) }
val underTest = MotionValue(input::value, FakeGestureContext, spec)
rule.setContent { LaunchedEffect(Unit) { underTest.keepRunning() } }
@@ -90,7 +90,7 @@
@Test
fun keepRunning_remainsActiveWhileAnimating() = runTest {
val input = mutableFloatStateOf(0f)
- val spec = specBuilder(Mapping.Zero) { constantValue(breakpoint = 1f, value = 1f) }
+ val spec = specBuilder(Mapping.Zero) { fixedValue(breakpoint = 1f, value = 1f) }
val underTest = MotionValue(input::value, FakeGestureContext, spec)
rule.setContent { LaunchedEffect(Unit) { underTest.keepRunning() } }
@@ -149,7 +149,7 @@
@Test
fun keepRunningWhile_stopRunningWhileStable_endsImmediately() = runTest {
val input = mutableFloatStateOf(0f)
- val spec = specBuilder(Mapping.Zero) { constantValue(breakpoint = 1f, value = 1f) }
+ val spec = specBuilder(Mapping.Zero) { fixedValue(breakpoint = 1f, value = 1f) }
val underTest = MotionValue(input::value, FakeGestureContext, spec)
val continueRunning = mutableStateOf(true)
diff --git a/mechanics/tests/src/com/android/mechanics/MotionValueTest.kt b/mechanics/tests/src/com/android/mechanics/MotionValueTest.kt
index cacc7b6..c7ec564 100644
--- a/mechanics/tests/src/com/android/mechanics/MotionValueTest.kt
+++ b/mechanics/tests/src/com/android/mechanics/MotionValueTest.kt
@@ -107,7 +107,7 @@
@Test
fun segmentChange_inMaxDirection_animatedWhenReachingBreakpoint() =
motion.goldenTest(
- spec = specBuilder(Mapping.Zero) { constantValue(breakpoint = 1f, value = 1f) }
+ spec = specBuilder(Mapping.Zero) { fixedValue(breakpoint = 1f, value = 1f) }
) {
animateValueTo(1f, changePerFrame = 0.5f)
awaitStable()
@@ -118,7 +118,7 @@
motion.goldenTest(
initialValue = 2f,
initialDirection = InputDirection.Min,
- spec = specBuilder(Mapping.Zero) { constantValue(breakpoint = 1f, value = 1f) },
+ spec = specBuilder(Mapping.Zero) { fixedValue(breakpoint = 1f, value = 1f) },
) {
animateValueTo(1f, changePerFrame = 0.5f)
awaitStable()
@@ -149,7 +149,7 @@
motion.goldenTest(
spec =
specBuilder(Mapping.Zero) {
- constantValue(breakpoint = 1f, guarantee = None, value = 1f)
+ fixedValue(breakpoint = 1f, guarantee = None, value = 1f)
}
) {
animateValueTo(5f, changePerFrame = 0.5f)
@@ -161,7 +161,7 @@
motion.goldenTest(
spec =
specBuilder(Mapping.Zero) {
- constantValue(breakpoint = 1f, guarantee = InputDelta(3f), value = 1f)
+ fixedValue(breakpoint = 1f, guarantee = InputDelta(3f), value = 1f)
}
) {
animateValueTo(4f, changePerFrame = 0.5f)
@@ -172,7 +172,7 @@
motion.goldenTest(
spec =
specBuilder(Mapping.Zero) {
- constantValue(breakpoint = 1f, guarantee = GestureDragDelta(3f), value = 1f)
+ fixedValue(breakpoint = 1f, guarantee = GestureDragDelta(3f), value = 1f)
}
) {
animateValueTo(1f, changePerFrame = 0.5f)
@@ -184,7 +184,7 @@
@Test
fun segmentChange_appliesOutputVelocity_atSpringStart() =
- motion.goldenTest(spec = specBuilder { constantValue(breakpoint = 10f, value = 20f) }) {
+ motion.goldenTest(spec = specBuilder { fixedValue(breakpoint = 10f, value = 20f) }) {
animateValueTo(11f, changePerFrame = 3f)
awaitStable()
}
@@ -195,7 +195,7 @@
spec =
specBuilder {
fractionalInputFromCurrent(breakpoint = 10f, fraction = 1f, delta = 20f)
- constantValueFromCurrent(breakpoint = 20f)
+ fixedValueFromCurrent(breakpoint = 20f)
}
) {
animateValueTo(21f, changePerFrame = 3f)
@@ -208,7 +208,7 @@
spec =
specBuilder {
fractionalInputFromCurrent(breakpoint = 10f, fraction = 5f, delta = 5f)
- constantValueFromCurrent(breakpoint = 20f)
+ fixedValueFromCurrent(breakpoint = 20f)
}
) {
animateValueTo(30f, changePerFrame = 3f)
@@ -221,7 +221,7 @@
spec =
specBuilder {
fractionalInputFromCurrent(breakpoint = 10f, fraction = 5f, delta = 5f)
- constantValueFromCurrent(breakpoint = 20f, delta = -5f)
+ fixedValueFromCurrent(breakpoint = 20f, delta = -5f)
}
) {
animateValueTo(30f, changePerFrame = 3f)
@@ -234,9 +234,9 @@
motion.goldenTest(
spec =
specBuilder(Mapping.Zero) {
- constantValue(breakpoint = 1f, value = 20f)
- constantValue(breakpoint = 2f, value = 20f)
- constantValue(breakpoint = 3f, value = 10f)
+ fixedValue(breakpoint = 1f, value = 20f)
+ fixedValue(breakpoint = 2f, value = 20f)
+ fixedValue(breakpoint = 3f, value = 10f)
},
stableThreshold = 1f,
) {
@@ -251,7 +251,7 @@
fun generateSpec(offset: Float) =
specBuilder(Mapping.Zero) {
targetFromCurrent(breakpoint = offset, key = B1, delta = 1f, to = 2f)
- constantValue(breakpoint = offset + 1f, key = B2, value = 0f)
+ fixedValue(breakpoint = offset + 1f, key = B2, value = 0f)
}
motion.goldenTest(spec = generateSpec(0f), initialValue = .5f) {
@@ -270,7 +270,7 @@
fun generateSpec(offset: Float) =
specBuilder(Mapping.Zero) {
targetFromCurrent(breakpoint = offset, key = B1, delta = 1f, to = 2f)
- constantValue(breakpoint = offset + 1f, key = B2, value = 0f)
+ fixedValue(breakpoint = offset + 1f, key = B2, value = 0f)
}
motion.goldenTest(spec = generateSpec(0f), initialValue = .5f) {
@@ -287,7 +287,7 @@
@Test
fun directionChange_maxToMin_changesSegmentWithDirectionChange() =
motion.goldenTest(
- spec = specBuilder(Mapping.Zero) { constantValue(breakpoint = 1f, value = 1f) },
+ spec = specBuilder(Mapping.Zero) { fixedValue(breakpoint = 1f, value = 1f) },
initialValue = 2f,
initialDirection = InputDirection.Max,
directionChangeSlop = 3f,
@@ -299,7 +299,7 @@
@Test
fun directionChange_minToMax_changesSegmentWithDirectionChange() =
motion.goldenTest(
- spec = specBuilder(Mapping.Zero) { constantValue(breakpoint = 1f, value = 1f) },
+ spec = specBuilder(Mapping.Zero) { fixedValue(breakpoint = 1f, value = 1f) },
initialValue = 0f,
initialDirection = InputDirection.Min,
directionChangeSlop = 3f,
@@ -313,7 +313,7 @@
motion.goldenTest(
spec =
specBuilder(Mapping.Zero) {
- constantValue(breakpoint = 1f, value = 1f, guarantee = InputDelta(1f))
+ fixedValue(breakpoint = 1f, value = 1f, guarantee = InputDelta(1f))
},
initialValue = 2f,
initialDirection = InputDirection.Max,
@@ -328,8 +328,8 @@
motion.goldenTest(
spec =
specBuilder(Mapping.Zero) {
- constantValue(breakpoint = 1f, value = 1f)
- constantValue(breakpoint = 2f, value = 2f)
+ fixedValue(breakpoint = 1f, value = 1f)
+ fixedValue(breakpoint = 2f, value = 2f)
}
) {
animateValueTo(3f, changePerFrame = 0.2f)
@@ -341,8 +341,8 @@
motion.goldenTest(
spec =
specBuilder(Mapping.Zero) {
- constantValue(breakpoint = 1f, value = 1f)
- constantValue(breakpoint = 2f, value = 2f)
+ fixedValue(breakpoint = 1f, value = 1f)
+ fixedValue(breakpoint = 2f, value = 2f)
}
) {
updateInput(2.5f)
@@ -354,16 +354,8 @@
motion.goldenTest(
spec =
specBuilder(Mapping.Zero) {
- constantValueFromCurrent(
- breakpoint = 1f,
- delta = 5f,
- guarantee = InputDelta(.9f),
- )
- constantValueFromCurrent(
- breakpoint = 2f,
- delta = 1f,
- guarantee = InputDelta(.9f),
- )
+ fixedValueFromCurrent(breakpoint = 1f, delta = 5f, guarantee = InputDelta(.9f))
+ fixedValueFromCurrent(breakpoint = 2f, delta = 1f, guarantee = InputDelta(.9f))
}
) {
updateInput(2.1f)
@@ -375,8 +367,8 @@
motion.goldenTest(
spec =
specBuilder(Mapping.Zero) {
- constantValue(breakpoint = 1f, value = 1f, guarantee = InputDelta(1f))
- constantValue(breakpoint = 2f, value = 2f)
+ fixedValue(breakpoint = 1f, value = 1f, guarantee = InputDelta(1f))
+ fixedValue(breakpoint = 2f, value = 2f)
},
initialValue = 2.5f,
initialDirection = InputDirection.Max,
@@ -411,8 +403,8 @@
val s1 = SemanticKey<String>("Foo")
val spec =
specBuilder(Mapping.Zero, semantics = listOf(s1 with "zero")) {
- constantValue(1f, 1f, semantics = listOf(s1 with "one"))
- constantValue(2f, 2f, semantics = listOf(s1 with "two"))
+ fixedValue(1f, 1f, semantics = listOf(s1 with "one"))
+ fixedValue(2f, 2f, semantics = listOf(s1 with "two"))
}
motion.goldenTest(spec = spec, semantics = listOf(CapturedSemantics(s1, string))) {
@@ -435,8 +427,8 @@
val s1 = SemanticKey<String>("Foo")
val spec =
specBuilder(Mapping.Zero, semantics = listOf(s1 with "zero")) {
- constantValue(1f, 1f, semantics = listOf(s1 with "one"))
- constantValue(2f, 2f, semantics = listOf(s1 with "two"))
+ fixedValue(1f, 1f, semantics = listOf(s1 with "one"))
+ fixedValue(2f, 2f, semantics = listOf(s1 with "two"))
}
val input = mutableFloatStateOf(0f)
@@ -451,8 +443,8 @@
fun segment_returnsCurrentSegmentKey() {
val spec =
specBuilder(Mapping.Zero) {
- constantValue(1f, 1f, key = B1)
- constantValue(2f, 2f, key = B2)
+ fixedValue(1f, 1f, key = B1)
+ fixedValue(2f, 2f, key = B2)
}
val input = mutableFloatStateOf(1f)
@@ -467,7 +459,7 @@
@Test
fun derivedValue_reflectsInputChangeInSameFrame() {
motion.goldenTest(
- spec = specBuilder(Mapping.Zero) { constantValue(breakpoint = 0.5f, value = 1f) },
+ spec = specBuilder(Mapping.Zero) { fixedValue(breakpoint = 0.5f, value = 1f) },
createDerived = { primary ->
listOf(MotionValue.createDerived(primary, MotionSpec.Empty, label = "derived"))
},
@@ -490,12 +482,12 @@
@Test
fun derivedValue_hasAnimationLifecycleOnItsOwn() {
motion.goldenTest(
- spec = specBuilder(Mapping.Zero) { constantValue(breakpoint = 0.5f, value = 1f) },
+ spec = specBuilder(Mapping.Zero) { fixedValue(breakpoint = 0.5f, value = 1f) },
createDerived = { primary ->
listOf(
MotionValue.createDerived(
primary,
- specBuilder(Mapping.One) { constantValue(breakpoint = 0.5f, value = 0f) },
+ specBuilder(Mapping.One) { fixedValue(breakpoint = 0.5f, value = 0f) },
label = "derived",
)
)
diff --git a/mechanics/tests/src/com/android/mechanics/spec/MotionSpecTest.kt b/mechanics/tests/src/com/android/mechanics/spec/MotionSpecTest.kt
index f8716da..260a8a7 100644
--- a/mechanics/tests/src/com/android/mechanics/spec/MotionSpecTest.kt
+++ b/mechanics/tests/src/com/android/mechanics/spec/MotionSpecTest.kt
@@ -39,7 +39,7 @@
val underTest =
MotionSpec(
directionalMotionSpec(Spring) {
- constantValue(breakpoint = 10f, key = B1, value = 1f)
+ fixedValue(breakpoint = 10f, key = B1, value = 1f)
identity(breakpoint = 20f, key = B2)
}
)
@@ -54,7 +54,7 @@
MotionSpec(
maxDirection =
directionalMotionSpec(Spring) {
- constantValue(breakpoint = 10f, key = B1, value = 1f)
+ fixedValue(breakpoint = 10f, key = B1, value = 1f)
identity(breakpoint = 20f, key = B2)
},
minDirection = DirectionalMotionSpec.Empty,
@@ -71,7 +71,7 @@
maxDirection = DirectionalMotionSpec.Empty,
minDirection =
directionalMotionSpec(Spring) {
- constantValue(breakpoint = 10f, key = B1, value = 1f)
+ fixedValue(breakpoint = 10f, key = B1, value = 1f)
identity(breakpoint = 20f, key = B2)
},
)
@@ -111,7 +111,7 @@
val underTest =
MotionSpec(
directionalMotionSpec(Spring) {
- constantValue(breakpoint = 10f, key = B1, value = 1f)
+ fixedValue(breakpoint = 10f, key = B1, value = 1f)
identity(breakpoint = 20f, key = B2)
}
)
@@ -129,7 +129,7 @@
val underTest =
MotionSpec(
directionalMotionSpec(Spring) {
- constantValue(breakpoint = 10f, key = B1, value = 1f)
+ fixedValue(breakpoint = 10f, key = B1, value = 1f)
identity(breakpoint = 20f, key = B2)
}
)
@@ -148,12 +148,12 @@
MotionSpec(
maxDirection =
directionalMotionSpec(Spring) {
- constantValue(breakpoint = 10f, key = B1, value = 1f)
+ fixedValue(breakpoint = 10f, key = B1, value = 1f)
identity(breakpoint = 20f, key = B2)
},
minDirection =
directionalMotionSpec(Spring) {
- constantValue(breakpoint = 5f, key = B1, value = 2f)
+ fixedValue(breakpoint = 5f, key = B1, value = 2f)
identity(breakpoint = 25f, key = B2)
},
)
@@ -176,7 +176,7 @@
val underTest =
MotionSpec(
directionalMotionSpec(Spring) {
- constantValue(breakpoint = 10f, key = B1, value = 1f)
+ fixedValue(breakpoint = 10f, key = B1, value = 1f)
identity(breakpoint = 20f, key = B2)
}
)
@@ -191,7 +191,7 @@
val underTest =
MotionSpec(
directionalMotionSpec(Spring) {
- constantValue(breakpoint = 10f, key = B1, value = 1f)
+ fixedValue(breakpoint = 10f, key = B1, value = 1f)
identity(breakpoint = 20f, key = B2)
}
)
@@ -208,7 +208,7 @@
val underTest =
MotionSpec(
directionalMotionSpec(Spring) {
- constantValue(breakpoint = 10f, key = B1, value = 1f)
+ fixedValue(breakpoint = 10f, key = B1, value = 1f)
identity(breakpoint = 20f, key = B2)
}
)
@@ -229,7 +229,7 @@
val underTest =
MotionSpec(
directionalMotionSpec(Spring) {
- constantValue(breakpoint = 10f, key = B1, value = 1f)
+ fixedValue(breakpoint = 10f, key = B1, value = 1f)
identity(breakpoint = 20f, key = B2)
}
)
diff --git a/mechanics/tests/src/com/android/mechanics/spec/builder/DirectionalBuilderImplTest.kt b/mechanics/tests/src/com/android/mechanics/spec/builder/DirectionalBuilderImplTest.kt
index d255856..2db300c 100644
--- a/mechanics/tests/src/com/android/mechanics/spec/builder/DirectionalBuilderImplTest.kt
+++ b/mechanics/tests/src/com/android/mechanics/spec/builder/DirectionalBuilderImplTest.kt
@@ -58,7 +58,7 @@
@Test
fun directionalSpec_mappingBuilder_setsDefaultSpring() {
- val result = directionalMotionSpec(Spring) { constantValue(breakpoint = 10f, value = 20f) }
+ val result = directionalMotionSpec(Spring) { fixedValue(breakpoint = 10f, value = 20f) }
assertThat(result).breakpoints().atPosition(10f).spring().isEqualTo(Spring)
}
@@ -68,7 +68,7 @@
val otherSpring = SpringParameters(stiffness = 10f, dampingRatio = 0.1f)
val result =
directionalMotionSpec(Spring) {
- constantValue(breakpoint = 10f, value = 20f, spring = otherSpring)
+ fixedValue(breakpoint = 10f, value = 20f, spring = otherSpring)
}
assertThat(result).breakpoints().atPosition(10f).spring().isEqualTo(otherSpring)
@@ -76,7 +76,7 @@
@Test
fun directionalSpec_mappingBuilder_defaultsToNoGuarantee() {
- val result = directionalMotionSpec(Spring) { constantValue(breakpoint = 10f, value = 20f) }
+ val result = directionalMotionSpec(Spring) { fixedValue(breakpoint = 10f, value = 20f) }
assertThat(result).breakpoints().atPosition(10f).guarantee().isEqualTo(Guarantee.None)
}
@@ -86,7 +86,7 @@
val guarantee = Guarantee.InputDelta(10f)
val result =
directionalMotionSpec(Spring) {
- constantValue(breakpoint = 10f, value = 20f, guarantee = guarantee)
+ fixedValue(breakpoint = 10f, value = 20f, guarantee = guarantee)
}
assertThat(result).breakpoints().atPosition(10f).guarantee().isEqualTo(guarantee)
@@ -96,11 +96,11 @@
fun directionalSpec_mappingBuilder_jumpTo_setsAbsoluteValue() {
val result =
directionalMotionSpec(Spring, Mapping.Fixed(99f)) {
- constantValue(breakpoint = 10f, value = 20f)
+ fixedValue(breakpoint = 10f, value = 20f)
}
assertThat(result).breakpoints().positions().containsExactly(10f)
- assertThat(result).mappings().atOrAfter(10f).isConstantValue(20f)
+ assertThat(result).mappings().atOrAfter(10f).isFixedValue(20f)
}
@Test
@@ -108,22 +108,22 @@
val result =
directionalMotionSpec(Spring, Mapping.Linear(factor = 0.5f)) {
// At 10f the current value is 5f (10f * 0.5f)
- constantValueFromCurrent(breakpoint = 10f, delta = 30f)
+ fixedValueFromCurrent(breakpoint = 10f, delta = 30f)
}
assertThat(result).breakpoints().positions().containsExactly(10f)
- assertThat(result).mappings().atOrAfter(10f).isConstantValue(35f)
+ assertThat(result).mappings().atOrAfter(10f).isFixedValue(35f)
}
@Test
- fun directionalSpec_mappingBuilder_continueWithConstantValue_usesSourceValue() {
+ fun directionalSpec_mappingBuilder_continueWithFixedValue_usesSourceValue() {
val result =
directionalMotionSpec(Spring, Mapping.Linear(factor = 0.5f)) {
// At 5f the current value is 2.5f (5f * 0.5f)
- constantValueFromCurrent(breakpoint = 5f)
+ fixedValueFromCurrent(breakpoint = 5f)
}
- assertThat(result).mappings().atOrAfter(5f).isConstantValue(2.5f)
+ assertThat(result).mappings().atOrAfter(5f).isFixedValue(2.5f)
}
@Test
@@ -258,8 +258,7 @@
fun builderContext_spatialDirectionalMotionSpec_defaultsToSpatialSpringAndIdentityMapping() {
val context = FakeMotionSpecBuilderContext.Default
- val result =
- with(context) { spatialDirectionalMotionSpec { constantValue(0f, value = 1f) } }
+ val result = with(context) { spatialDirectionalMotionSpec { fixedValue(0f, value = 1f) } }
assertThat(result).mappings().containsExactly(Mapping.Identity, Mapping.One).inOrder()
assertThat(result).breakpoints().atPosition(0f).spring().isEqualTo(context.spatial.default)
@@ -269,8 +268,7 @@
fun builderContext_effectsDirectionalMotionSpec_defaultsToEffectsSpringAndZeroMapping() {
val context = FakeMotionSpecBuilderContext.Default
- val result =
- with(context) { effectsDirectionalMotionSpec { constantValue(0f, value = 1f) } }
+ val result = with(context) { effectsDirectionalMotionSpec { fixedValue(0f, value = 1f) } }
assertThat(result).mappings().containsExactly(Mapping.Zero, Mapping.One).inOrder()
assertThat(result).breakpoints().atPosition(0f).spring().isEqualTo(context.effects.default)
diff --git a/mechanics/tests/src/com/android/mechanics/spec/builder/MotionSpecBuilderTest.kt b/mechanics/tests/src/com/android/mechanics/spec/builder/MotionSpecBuilderTest.kt
index 235277c..2b6760a 100644
--- a/mechanics/tests/src/com/android/mechanics/spec/builder/MotionSpecBuilderTest.kt
+++ b/mechanics/tests/src/com/android/mechanics/spec/builder/MotionSpecBuilderTest.kt
@@ -23,8 +23,6 @@
import com.android.mechanics.spec.Mapping
import com.android.mechanics.spec.SemanticKey
import com.android.mechanics.spec.SemanticValue
-import com.android.mechanics.spec.builder.EffectPlacement.Companion.after
-import com.android.mechanics.spec.builder.EffectPlacement.Companion.before
import com.android.mechanics.spec.with
import com.android.mechanics.spring.SpringParameters
import com.android.mechanics.testing.FakeMotionSpecBuilderContext
@@ -283,7 +281,7 @@
maxLimitKey: BreakpointKey,
placement: EffectPlacement,
) {
- forward(Mapping.One) { constantValue(breakpoint = minLimit + 0.5f, 10f) }
+ forward(Mapping.One) { fixedValue(breakpoint = minLimit + 0.5f, 10f) }
backward(Mapping.Two)
}
}
@@ -305,7 +303,7 @@
val breakpointKey = BreakpointKey("foo")
val effect =
UnidirectionalEffect(Mapping.One) {
- constantValue(breakpoint = 1.5f, value = 10f, key = breakpointKey)
+ fixedValue(breakpoint = 1.5f, value = 10f, key = breakpointKey)
}
val result =
@@ -320,7 +318,7 @@
@Test
fun effect_setBreakpointBeforeMinLimit_throws() {
val rogueEffect =
- UnidirectionalEffect(Mapping.One) { this.constantValue(breakpoint = 0.5f, value = 0f) }
+ UnidirectionalEffect(Mapping.One) { this.fixedValue(breakpoint = 0.5f, value = 0f) }
assertFailsWith<IllegalStateException> {
motionSpec(baseMapping = Mapping.Zero, defaultSpring = spatial.default) {
@@ -332,7 +330,7 @@
@Test
fun effect_setBreakpointAfterMinLimit_throws() {
val rogueEffect =
- UnidirectionalEffect(Mapping.One) { this.constantValue(breakpoint = 2.5f, value = 0f) }
+ UnidirectionalEffect(Mapping.One) { this.fixedValue(breakpoint = 2.5f, value = 0f) }
assertFailsWith<IllegalStateException> {
motionSpec(baseMapping = Mapping.Zero, defaultSpring = spatial.default) {
@@ -349,7 +347,7 @@
Mapping.One,
semantics = listOf(SemanticValue(semanticKey, "initial")),
) {
- constantValue(
+ fixedValue(
breakpoint = 1.5f,
value = 2f,
semantics = listOf(SemanticValue(semanticKey, "second")),
diff --git a/mechanics/tests/src/com/android/mechanics/view/ViewMotionValueTest.kt b/mechanics/tests/src/com/android/mechanics/view/ViewMotionValueTest.kt
index 53a06ba..7d7fdcd 100644
--- a/mechanics/tests/src/com/android/mechanics/view/ViewMotionValueTest.kt
+++ b/mechanics/tests/src/com/android/mechanics/view/ViewMotionValueTest.kt
@@ -92,7 +92,7 @@
@Test
fun segmentChange_animatedWhenReachingBreakpoint() =
motion.goldenTest(
- spec = specBuilder(Mapping.Zero) { constantValue(breakpoint = 1f, value = 1f) }
+ spec = specBuilder(Mapping.Zero) { fixedValue(breakpoint = 1f, value = 1f) }
) {
animateValueTo(1f, changePerFrame = 0.5f)
awaitStable()
@@ -104,8 +104,8 @@
val s1 = SemanticKey<String>("Foo")
val spec =
specBuilder(Mapping.Zero, semantics = listOf(s1 with "zero")) {
- constantValue(1f, 1f, semantics = listOf(s1 with "one"))
- constantValue(2f, 2f, semantics = listOf(s1 with "two"))
+ fixedValue(1f, 1f, semantics = listOf(s1 with "one"))
+ fixedValue(2f, 2f, semantics = listOf(s1 with "two"))
}
val gestureContext = DistanceGestureContext(0f, InputDirection.Max, 5f)
@@ -123,8 +123,8 @@
runBlocking(Dispatchers.Main) {
val spec =
specBuilder(Mapping.Zero) {
- constantValue(1f, 1f, key = B1)
- constantValue(2f, 2f, key = B2)
+ fixedValue(1f, 1f, key = B1)
+ fixedValue(2f, 2f, key = B2)
}
val gestureContext = DistanceGestureContext(0f, InputDirection.Max, 5f)
@@ -143,7 +143,7 @@
motion.goldenTest(
spec =
specBuilder(Mapping.Zero) {
- constantValue(breakpoint = 1f, guarantee = GestureDragDelta(3f), value = 1f)
+ fixedValue(breakpoint = 1f, guarantee = GestureDragDelta(3f), value = 1f)
}
) {
animateValueTo(1f, changePerFrame = 0.5f)
@@ -158,7 +158,7 @@
fun generateSpec(offset: Float) =
specBuilder(Mapping.Zero) {
targetFromCurrent(breakpoint = offset, key = B1, delta = 1f, to = 2f)
- constantValue(breakpoint = offset + 1f, key = B2, value = 0f)
+ fixedValue(breakpoint = offset + 1f, key = B2, value = 0f)
}
motion.goldenTest(spec = generateSpec(0f), initialValue = .5f) {
@@ -202,7 +202,7 @@
fun update_triggersCallbacksWhileAnimating() = runTest {
runBlocking(Dispatchers.Main) {
val gestureContext = DistanceGestureContext(0f, InputDirection.Max, 5f)
- val spec = specBuilder(Mapping.Zero) { constantValue(breakpoint = 1f, value = 1f) }
+ val spec = specBuilder(Mapping.Zero) { fixedValue(breakpoint = 1f, value = 1f) }
val underTest = ViewMotionValue(0f, gestureContext, spec)
var invocationCount = 0
@@ -218,7 +218,7 @@
fun removeCallback_doesNotTriggerAfterRemoving() = runTest {
runBlocking(Dispatchers.Main) {
val gestureContext = DistanceGestureContext(0f, InputDirection.Max, 5f)
- val spec = specBuilder(Mapping.Zero) { constantValue(breakpoint = 1f, value = 1f) }
+ val spec = specBuilder(Mapping.Zero) { fixedValue(breakpoint = 1f, value = 1f) }
val underTest = ViewMotionValue(0f, gestureContext, spec)
var invocationCount = 0