Merge "Fix WithConstraints test failing on API 30" into androidx-master-dev
diff --git a/ui/ui-framework/src/androidTest/java/androidx/ui/core/test/WithConstraintsTest.kt b/ui/ui-framework/src/androidTest/java/androidx/ui/core/test/WithConstraintsTest.kt
index a13e89e..b495d89 100644
--- a/ui/ui-framework/src/androidTest/java/androidx/ui/core/test/WithConstraintsTest.kt
+++ b/ui/ui-framework/src/androidTest/java/androidx/ui/core/test/WithConstraintsTest.kt
@@ -32,7 +32,6 @@
import androidx.ui.core.MeasureBlock
import androidx.ui.core.Modifier
import androidx.ui.core.Ref
-import androidx.ui.core.TextFieldDelegate.Companion.layout
import androidx.ui.core.WithConstraints
import androidx.ui.core.draw
import androidx.ui.core.onPositioned
@@ -514,26 +513,37 @@
activity.setContent {
assertEquals(1, outerComposeLatch.count)
outerComposeLatch.countDown()
- Layout(children = {
- WithConstraints { _, _ ->
- assertEquals(1, innerComposeLatch.count)
- innerComposeLatch.countDown()
- Layout(children = emptyContent()) { _, _, _ ->
- assertEquals(1, innerMeasureLatch.count)
- innerMeasureLatch.countDown()
- layout(100.ipx, 100.ipx) {
- assertEquals(1, innerLayoutLatch.count)
- innerLayoutLatch.countDown()
+ val children = @Composable {
+ Layout(children = {
+ WithConstraints { _, _ ->
+ assertEquals(1, innerComposeLatch.count)
+ innerComposeLatch.countDown()
+ Layout(children = emptyContent()) { _, _, _ ->
+ assertEquals(1, innerMeasureLatch.count)
+ innerMeasureLatch.countDown()
+ layout(100.ipx, 100.ipx) {
+ assertEquals(1, innerLayoutLatch.count)
+ innerLayoutLatch.countDown()
+ }
}
}
+ }) { measurables, constraints, _ ->
+ assertEquals(1, outerMeasureLatch.count)
+ outerMeasureLatch.countDown()
+ layout(100.ipx, 100.ipx) {
+ assertEquals(1, outerLayoutLatch.count)
+ outerLayoutLatch.countDown()
+ measurables.forEach { it.measure(constraints).place(0.ipx, 0.ipx) }
+ }
}
- }) { measurables, constraints, _ ->
- assertEquals(1, outerMeasureLatch.count)
- outerMeasureLatch.countDown()
+ }
+
+ Layout(children) { measurables, _, _ ->
layout(100.ipx, 100.ipx) {
- assertEquals(1, outerLayoutLatch.count)
- outerLayoutLatch.countDown()
- measurables.forEach { it.measure(constraints).place(0.ipx, 0.ipx) }
+ // we fix the constraints used by children so if the constraints given
+ // by the android view will change it would not affect the test
+ val constraints = Constraints(maxWidth = 100.ipx, maxHeight = 100.ipx)
+ measurables.first().measure(constraints).place(0.ipx, 0.ipx)
}
}
}