Skip to content

Commit

Permalink
Add Box stretch tests (#1843)
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeWharton authored Mar 5, 2024
1 parent 35bedbc commit 68b61d0
Show file tree
Hide file tree
Showing 72 changed files with 312 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ internal class ComposeUiBox(
CrossAxisAlignment.Start -> -1f
CrossAxisAlignment.Center -> 0f
CrossAxisAlignment.End -> 1f
CrossAxisAlignment.Stretch -> TODO()
// TODO Implement stretch with custom Layout.
CrossAxisAlignment.Stretch -> -1f
else -> throw AssertionError()
},
verticalBias = alignment.verticalBias,
Expand All @@ -114,7 +115,8 @@ internal class ComposeUiBox(
CrossAxisAlignment.Start -> -1f
CrossAxisAlignment.Center -> 0f
CrossAxisAlignment.End -> 1f
CrossAxisAlignment.Stretch -> TODO()
// TODO Implement stretch with custom Layout.
CrossAxisAlignment.Stretch -> -1f
else -> throw AssertionError()
},
)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@ abstract class AbstractBoxTest<T : Any> {
verticalAlignment = CrossAxisAlignment.Start,
)

@Test
fun testWrapWithChildren_Wrap_Stretch_Start() = testWithChildren(
constraint = Constraint.Wrap,
horizontalAlignment = CrossAxisAlignment.Stretch,
verticalAlignment = CrossAxisAlignment.Start,
)

@Test
fun testWrapWithChildren_Wrap_Start_Center() = testWithChildren(
constraint = Constraint.Wrap,
Expand All @@ -107,6 +114,13 @@ abstract class AbstractBoxTest<T : Any> {
verticalAlignment = CrossAxisAlignment.Center,
)

@Test
fun testWrapWithChildren_Wrap_Stretch_Center() = testWithChildren(
constraint = Constraint.Wrap,
horizontalAlignment = CrossAxisAlignment.Stretch,
verticalAlignment = CrossAxisAlignment.Center,
)

@Test
fun testWrapWithChildren_Wrap_Start_End() = testWithChildren(
constraint = Constraint.Wrap,
Expand All @@ -128,6 +142,41 @@ abstract class AbstractBoxTest<T : Any> {
verticalAlignment = CrossAxisAlignment.End,
)

@Test
fun testWrapWithChildren_Wrap_Stretch_End() = testWithChildren(
constraint = Constraint.Wrap,
horizontalAlignment = CrossAxisAlignment.Stretch,
verticalAlignment = CrossAxisAlignment.End,
)

@Test
fun testWrapWithChildren_Wrap_Start_Stretch() = testWithChildren(
constraint = Constraint.Wrap,
horizontalAlignment = CrossAxisAlignment.Start,
verticalAlignment = CrossAxisAlignment.Stretch,
)

@Test
fun testWrapWithChildren_Wrap_Center_Stretch() = testWithChildren(
constraint = Constraint.Wrap,
horizontalAlignment = CrossAxisAlignment.Center,
verticalAlignment = CrossAxisAlignment.Stretch,
)

@Test
fun testWrapWithChildren_Wrap_End_Stretch() = testWithChildren(
constraint = Constraint.Wrap,
horizontalAlignment = CrossAxisAlignment.End,
verticalAlignment = CrossAxisAlignment.Stretch,
)

@Test
fun testWrapWithChildren_Wrap_Stretch_Stretch() = testWithChildren(
constraint = Constraint.Wrap,
horizontalAlignment = CrossAxisAlignment.Stretch,
verticalAlignment = CrossAxisAlignment.Stretch,
)

// testFillWithChildren

@Test
Expand All @@ -151,6 +200,13 @@ abstract class AbstractBoxTest<T : Any> {
verticalAlignment = CrossAxisAlignment.Start,
)

@Test
fun testFillWithChildren_Wrap_Stretch_Start() = testWithChildren(
constraint = Constraint.Fill,
horizontalAlignment = CrossAxisAlignment.Stretch,
verticalAlignment = CrossAxisAlignment.Start,
)

@Test
fun testFillWithChildren_Wrap_Start_Center() = testWithChildren(
constraint = Constraint.Fill,
Expand All @@ -172,6 +228,13 @@ abstract class AbstractBoxTest<T : Any> {
verticalAlignment = CrossAxisAlignment.Center,
)

@Test
fun testFillWithChildren_Wrap_Stretch_Center() = testWithChildren(
constraint = Constraint.Fill,
horizontalAlignment = CrossAxisAlignment.Stretch,
verticalAlignment = CrossAxisAlignment.Center,
)

@Test
fun testFillWithChildren_Wrap_Start_End() = testWithChildren(
constraint = Constraint.Fill,
Expand All @@ -193,6 +256,41 @@ abstract class AbstractBoxTest<T : Any> {
verticalAlignment = CrossAxisAlignment.End,
)

@Test
fun testFillWithChildren_Wrap_Stretch_End() = testWithChildren(
constraint = Constraint.Fill,
horizontalAlignment = CrossAxisAlignment.Stretch,
verticalAlignment = CrossAxisAlignment.End,
)

@Test
fun testFillWithChildren_Wrap_Start_Stretch() = testWithChildren(
constraint = Constraint.Fill,
horizontalAlignment = CrossAxisAlignment.Start,
verticalAlignment = CrossAxisAlignment.Stretch,
)

@Test
fun testFillWithChildren_Wrap_Center_Stretch() = testWithChildren(
constraint = Constraint.Fill,
horizontalAlignment = CrossAxisAlignment.Center,
verticalAlignment = CrossAxisAlignment.Stretch,
)

@Test
fun testFillWithChildren_Wrap_End_Stretch() = testWithChildren(
constraint = Constraint.Fill,
horizontalAlignment = CrossAxisAlignment.End,
verticalAlignment = CrossAxisAlignment.Stretch,
)

@Test
fun testFillWithChildren_Wrap_Stretch_Stretch() = testWithChildren(
constraint = Constraint.Fill,
horizontalAlignment = CrossAxisAlignment.Stretch,
verticalAlignment = CrossAxisAlignment.Stretch,
)

private fun testWithChildren(
constraint: Constraint,
horizontalAlignment: CrossAxisAlignment,
Expand Down
Loading

0 comments on commit 68b61d0

Please sign in to comment.