Skip to content

Commit 228d3f4

Browse files
authored
Add two broken cases to test app (#2121)
1 parent 2f52546 commit 228d3f4

File tree

3 files changed

+119
-0
lines changed

3 files changed

+119
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (C) 2023 Square, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.example.redwood.testapp.presenter
17+
18+
import androidx.compose.runtime.Composable
19+
import app.cash.redwood.Modifier
20+
import app.cash.redwood.layout.api.Constraint
21+
import app.cash.redwood.layout.api.CrossAxisAlignment
22+
import app.cash.redwood.layout.api.MainAxisAlignment
23+
import app.cash.redwood.layout.compose.Column
24+
import app.cash.redwood.layout.compose.Row
25+
import app.cash.redwood.layout.compose.Spacer
26+
import app.cash.redwood.ui.Margin
27+
import app.cash.redwood.ui.dp
28+
import com.example.redwood.testapp.compose.backgroundColor
29+
30+
@Composable
31+
fun BrokenRowColumn(modifier: Modifier = Modifier) {
32+
Column(
33+
width = Constraint.Fill,
34+
height = Constraint.Fill,
35+
// Uncomment this to fix(?) behavior.
36+
// horizontalAlignment = CrossAxisAlignment.Stretch,
37+
margin = Margin(top = 24.dp),
38+
modifier = modifier,
39+
) {
40+
Row(
41+
width = Constraint.Fill,
42+
horizontalAlignment = MainAxisAlignment.Center,
43+
) {
44+
Column(
45+
width = Constraint.Fill,
46+
height = Constraint.Fill,
47+
horizontalAlignment = CrossAxisAlignment.Stretch,
48+
modifier = Modifier
49+
.margin(Margin(start = 24.dp, end = 24.dp))
50+
.flex(1.0),
51+
) {
52+
Spacer(48.dp, 48.dp, Modifier.backgroundColor(0xFFFF0000U))
53+
}
54+
}
55+
}
56+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright (C) 2023 Square, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.example.redwood.testapp.presenter
17+
18+
import androidx.compose.runtime.Composable
19+
import androidx.compose.runtime.LaunchedEffect
20+
import androidx.compose.runtime.getValue
21+
import androidx.compose.runtime.mutableStateOf
22+
import androidx.compose.runtime.remember
23+
import androidx.compose.runtime.setValue
24+
import app.cash.redwood.Modifier
25+
import app.cash.redwood.layout.api.Constraint.Companion.Fill
26+
import app.cash.redwood.layout.compose.Column
27+
import app.cash.redwood.ui.dp
28+
import com.example.redwood.testapp.compose.Text
29+
import com.example.redwood.testapp.compose.backgroundColor
30+
import kotlin.time.Duration.Companion.seconds
31+
import kotlinx.coroutines.delay
32+
33+
@Composable
34+
fun BrokenSizeUpdate(modifier: Modifier = Modifier) {
35+
var width by remember { mutableStateOf(20.dp) }
36+
var height by remember { mutableStateOf(20.dp) }
37+
LaunchedEffect(Unit) {
38+
while (true) {
39+
delay(1.seconds)
40+
width = 100.dp
41+
height = 100.dp
42+
43+
delay(3.seconds)
44+
width = 20.dp
45+
height = 20.dp
46+
}
47+
}
48+
49+
Column(
50+
width = Fill,
51+
height = Fill,
52+
modifier = modifier,
53+
) {
54+
Text(
55+
"hello",
56+
modifier = Modifier
57+
.size(width, height)
58+
.backgroundColor(0xFFFF0000U),
59+
)
60+
}
61+
}

test-app/presenter/src/commonMain/kotlin/com/example/redwood/testapp/presenter/TestApp.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ private val screens = buildMap<String, @Composable TestContext.() -> Unit> {
3737
put("UI Configuration") { UiConfigurationValues() }
3838
put("Box Sandbox") { BoxSandbox() }
3939
put("Unscoped Modifiers") { UnscopedModifiers() }
40+
put("Broken Row/Column") { BrokenRowColumn() }
41+
put("Broken Size Update") { BrokenSizeUpdate() }
4042
}
4143

4244
@Stable

0 commit comments

Comments
 (0)