[go: nahoru, domu]

blob: d35ea816695576c2ffab877d6a8d225d57d0bd3d [file] [log] [blame]
/*
* Copyright 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package androidx.ui.integration.test.foundation
import androidx.compose.Composable
import androidx.compose.mutableStateOf
import androidx.compose.foundation.Text
import androidx.ui.integration.test.ToggleableTestCase
import androidx.compose.foundation.layout.Column
import androidx.ui.material.MaterialTheme
import androidx.ui.material.Surface
import androidx.ui.test.ComposeTestCase
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.unit.sp
/**
* Test case that puts the given amount of rectangles into a column layout and makes changes by
* modifying the color used in the model.
*
* Note: Each rectangle has its own model so changes should always affect only the first one.
*/
class TextInColumnTestCase(
private val numberOfTexts: Int
) : ComposeTestCase, ToggleableTestCase {
private val fontSize = mutableStateOf(20.sp)
@Composable
override fun emitContent() {
MaterialTheme {
Surface {
Column {
repeat(numberOfTexts) {
// 32-character text to match dashboards
Text(
"Hello World Hello World Hello W",
style = TextStyle(fontSize = fontSize.value)
)
}
}
}
}
}
override fun toggleState() {
fontSize.value = if (fontSize.value == 20.sp) {
15.sp
} else {
20.sp
}
}
}