Merge "Unignore tests that are no longer failing" into androidx-master-dev
diff --git a/buildSrc/src/main/kotlin/androidx/build/LibraryVersions.kt b/buildSrc/src/main/kotlin/androidx/build/LibraryVersions.kt
index 7439c33..be020b3 100644
--- a/buildSrc/src/main/kotlin/androidx/build/LibraryVersions.kt
+++ b/buildSrc/src/main/kotlin/androidx/build/LibraryVersions.kt
@@ -42,7 +42,7 @@
val CARDVIEW = Version("1.1.0-alpha01")
val COLLECTION = Version("1.2.0-alpha01")
val CONTENTPAGER = Version("1.1.0-alpha01")
- val COMPOSE = Version("0.1.0-dev17")
+ val COMPOSE = Version("1.0.0-alpha02")
val CONTENTACCESS = Version("1.0.0-alpha01")
val COORDINATORLAYOUT = Version("1.2.0-alpha01")
val CORE = Version("1.5.0-alpha02")
@@ -110,7 +110,7 @@
val TRACING = Version("1.0.0-beta01")
val TRANSITION = Version("1.4.0-beta01")
val TVPROVIDER = Version("1.1.0-alpha01")
- val UI = Version("0.1.0-dev17")
+ val UI = Version("1.0.0-alpha02")
val VECTORDRAWABLE = Version("1.2.0-alpha02")
val VECTORDRAWABLE_ANIMATED = Version("1.2.0-alpha01")
val VECTORDRAWABLE_SEEKABLE = Version("1.0.0-alpha02")
diff --git a/ui/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/TextBasicBenchmark.kt b/ui/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/TextBasicBenchmark.kt
index f228672..1b94abd 100644
--- a/ui/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/TextBasicBenchmark.kt
+++ b/ui/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/TextBasicBenchmark.kt
@@ -16,6 +16,7 @@
package androidx.compose.ui
+import androidx.compose.ui.text.AnnotatedString
import androidx.test.filters.LargeTest
import androidx.ui.benchmark.ComposeBenchmarkRule
import androidx.ui.benchmark.benchmarkDrawPerf
@@ -24,7 +25,6 @@
import androidx.ui.benchmark.toggleStateBenchmarkLayout
import androidx.ui.benchmark.toggleStateBenchmarkMeasure
import androidx.ui.benchmark.toggleStateBenchmarkRecompose
-import androidx.ui.integration.test.core.text.TextBasicTestCase
import androidx.ui.integration.test.TextBenchmarkTestRule
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
@@ -32,6 +32,7 @@
import androidx.ui.benchmark.benchmarkFirstDrawFast
import androidx.ui.benchmark.benchmarkFirstLayoutFast
import androidx.ui.benchmark.benchmarkFirstMeasureFast
+import androidx.ui.integration.test.core.text.TextInColumnTestCase
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -60,7 +61,7 @@
private val width = textBenchmarkRule.widthDp.dp
private val fontSize = textBenchmarkRule.fontSizeSp.sp
- private val textCaseFactory = {
+ private val caseFactory = {
textBenchmarkRule.generator { textGenerator ->
/**
* Text render has a word cache in the underlying system. To get a proper metric of its
@@ -68,9 +69,11 @@
* public API. Here is a workaround which generates a new string when a new test case
* is created.
*/
- val text = textGenerator.nextParagraph(textLength)
- TextBasicTestCase(
- text = text,
+ val texts = List(textBenchmarkRule.repeatTimes) {
+ AnnotatedString(textGenerator.nextParagraph(textLength))
+ }
+ TextInColumnTestCase(
+ texts = texts,
width = width,
fontSize = fontSize
)
@@ -83,7 +86,7 @@
*/
@Test
fun first_compose() {
- benchmarkRule.benchmarkFirstComposeFast(textCaseFactory)
+ benchmarkRule.benchmarkFirstComposeFast(caseFactory)
}
/**
@@ -92,11 +95,7 @@
*/
@Test
fun first_measure() {
- textBenchmarkRule.generator { textGenerator ->
- benchmarkRule.benchmarkFirstMeasureFast {
- TextBasicTestCase(textGenerator.nextParagraph(textLength), width, fontSize)
- }
- }
+ benchmarkRule.benchmarkFirstMeasureFast(caseFactory)
}
/**
@@ -105,7 +104,7 @@
*/
@Test
fun first_layout() {
- benchmarkRule.benchmarkFirstLayoutFast(textCaseFactory)
+ benchmarkRule.benchmarkFirstLayoutFast(caseFactory)
}
/**
@@ -113,7 +112,7 @@
*/
@Test
fun first_draw() {
- benchmarkRule.benchmarkFirstDrawFast(textCaseFactory)
+ benchmarkRule.benchmarkFirstDrawFast(caseFactory)
}
/**
@@ -122,7 +121,7 @@
*/
@Test
fun layout() {
- benchmarkRule.benchmarkLayoutPerf(textCaseFactory)
+ benchmarkRule.benchmarkLayoutPerf(caseFactory)
}
/**
@@ -130,7 +129,7 @@
*/
@Test
fun draw() {
- benchmarkRule.benchmarkDrawPerf(textCaseFactory)
+ benchmarkRule.benchmarkDrawPerf(caseFactory)
}
/**
@@ -138,7 +137,7 @@
*/
@Test
fun toggleColor_recompose() {
- benchmarkRule.toggleStateBenchmarkRecompose(textCaseFactory)
+ benchmarkRule.toggleStateBenchmarkRecompose(caseFactory)
}
/**
@@ -146,7 +145,7 @@
*/
@Test
fun toggleColor_measure() {
- benchmarkRule.toggleStateBenchmarkMeasure(textCaseFactory)
+ benchmarkRule.toggleStateBenchmarkMeasure(caseFactory)
}
/**
@@ -154,7 +153,7 @@
*/
@Test
fun toggleColor_layout() {
- benchmarkRule.toggleStateBenchmarkLayout(textCaseFactory)
+ benchmarkRule.toggleStateBenchmarkLayout(caseFactory)
}
/**
@@ -162,6 +161,6 @@
*/
@Test
fun toggleColor_draw() {
- benchmarkRule.toggleStateBenchmarkDraw(textCaseFactory)
+ benchmarkRule.toggleStateBenchmarkDraw(caseFactory)
}
}
\ No newline at end of file
diff --git a/ui/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/TextMultiStyleBenchmark.kt b/ui/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/TextMultiStyleBenchmark.kt
index 073c8d7..dccc21a34 100644
--- a/ui/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/TextMultiStyleBenchmark.kt
+++ b/ui/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/TextMultiStyleBenchmark.kt
@@ -24,11 +24,11 @@
import androidx.ui.benchmark.benchmarkFirstLayout
import androidx.ui.benchmark.benchmarkFirstMeasure
import androidx.ui.benchmark.benchmarkLayoutPerf
-import androidx.ui.integration.test.core.text.TextMultiStyleTestCase
import androidx.ui.integration.test.TextBenchmarkTestRule
import androidx.ui.integration.test.cartesian
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
+import androidx.ui.integration.test.core.text.TextInColumnTestCase
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -59,25 +59,39 @@
@get:Rule
val benchmarkRule = ComposeBenchmarkRule()
- val width = textBenchmarkRule.widthDp.dp
- val fontSize = textBenchmarkRule.fontSizeSp.sp
+ private val width = textBenchmarkRule.widthDp.dp
+ private val fontSize = textBenchmarkRule.fontSizeSp.sp
+
+ private val caseFactory = {
+ textBenchmarkRule.generator { textGenerator ->
+ /**
+ * Text render has a word cache in the underlying system. To get a proper metric of its
+ * performance, the cache needs to be disabled, which unfortunately is not doable via
+ * public API. Here is a workaround which generates a new string when a new test case
+ * is created.
+ */
+ val texts = List(textBenchmarkRule.repeatTimes) {
+ textGenerator.nextAnnotatedString(
+ length = textLength,
+ styleCount = styleCount,
+ hasMetricAffectingStyle = true
+ )
+ }
+ TextInColumnTestCase(
+ texts = texts,
+ width = width,
+ fontSize = fontSize
+ )
+ }
+ }
+
/**
* Measure the time taken to compose a [Text] composable from scratch with styled text as input.
* This is the time taken to call the [Text] composable function.
*/
@Test
fun first_compose() {
- textBenchmarkRule.generator { textGenerator ->
- benchmarkRule.benchmarkFirstCompose {
- TextMultiStyleTestCase(
- width,
- fontSize,
- textLength,
- styleCount,
- textGenerator
- )
- }
- }
+ benchmarkRule.benchmarkFirstCompose(caseFactory)
}
/**
@@ -86,17 +100,7 @@
*/
@Test
fun first_measure() {
- textBenchmarkRule.generator { textGenerator ->
- benchmarkRule.benchmarkFirstMeasure {
- TextMultiStyleTestCase(
- width,
- fontSize,
- textLength,
- styleCount,
- textGenerator
- )
- }
- }
+ benchmarkRule.benchmarkFirstMeasure(caseFactory)
}
/**
@@ -105,17 +109,7 @@
*/
@Test
fun first_layout() {
- textBenchmarkRule.generator { textGenerator ->
- benchmarkRule.benchmarkFirstLayout {
- TextMultiStyleTestCase(
- width,
- fontSize,
- textLength,
- styleCount,
- textGenerator
- )
- }
- }
+ benchmarkRule.benchmarkFirstLayout(caseFactory)
}
/**
@@ -124,17 +118,7 @@
*/
@Test
fun first_draw() {
- textBenchmarkRule.generator { textGenerator ->
- benchmarkRule.benchmarkFirstDraw {
- TextMultiStyleTestCase(
- width,
- fontSize,
- textLength,
- styleCount,
- textGenerator
- )
- }
- }
+ benchmarkRule.benchmarkFirstDraw(caseFactory)
}
/**
@@ -144,17 +128,7 @@
*/
@Test
fun layout() {
- textBenchmarkRule.generator { textGenerator ->
- benchmarkRule.benchmarkLayoutPerf {
- TextMultiStyleTestCase(
- width,
- fontSize,
- textLength,
- styleCount,
- textGenerator
- )
- }
- }
+ benchmarkRule.benchmarkLayoutPerf(caseFactory)
}
/**
@@ -162,16 +136,6 @@
*/
@Test
fun draw() {
- textBenchmarkRule.generator { textGenerator ->
- benchmarkRule.benchmarkDrawPerf {
- TextMultiStyleTestCase(
- width,
- fontSize,
- textLength,
- styleCount,
- textGenerator
- )
- }
- }
+ benchmarkRule.benchmarkDrawPerf(caseFactory)
}
}
diff --git a/ui/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/TextToggleTextBenchmark.kt b/ui/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/TextToggleTextBenchmark.kt
index 184555c..6a1c24c 100644
--- a/ui/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/TextToggleTextBenchmark.kt
+++ b/ui/integration-tests/benchmark/src/androidTest/java/androidx/compose/ui/TextToggleTextBenchmark.kt
@@ -51,9 +51,15 @@
private val width = textBenchmarkRule.widthDp.dp
private val fontSize = textBenchmarkRule.fontSizeSp.sp
- private val toggleTextCaseFactory = {
+ private val caseFactory = {
textBenchmarkRule.generator { generator ->
- TextToggleTextTestCase(generator, textLength, width, fontSize)
+ TextToggleTextTestCase(
+ textGenerator = generator,
+ textLength = textLength,
+ textNumber = textBenchmarkRule.repeatTimes,
+ width = width,
+ fontSize = fontSize
+ )
}
}
@@ -62,7 +68,7 @@
*/
@Test
fun toggleText_recompose() {
- benchmarkRule.toggleStateBenchmarkRecompose(toggleTextCaseFactory)
+ benchmarkRule.toggleStateBenchmarkRecompose(caseFactory)
}
/**
@@ -70,7 +76,7 @@
*/
@Test
fun toggleText_measure() {
- benchmarkRule.toggleStateBenchmarkMeasure(toggleTextCaseFactory)
+ benchmarkRule.toggleStateBenchmarkMeasure(caseFactory)
}
/**
@@ -78,7 +84,7 @@
*/
@Test
fun toggleText_layout() {
- benchmarkRule.toggleStateBenchmarkLayout(toggleTextCaseFactory)
+ benchmarkRule.toggleStateBenchmarkLayout(caseFactory)
}
/**
@@ -86,6 +92,6 @@
*/
@Test
fun toggleText_draw() {
- benchmarkRule.toggleStateBenchmarkDraw(toggleTextCaseFactory)
+ benchmarkRule.toggleStateBenchmarkDraw(caseFactory)
}
}
\ No newline at end of file
diff --git a/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/view/AndroidTextViewBenchmark.kt b/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/view/AndroidTextViewBenchmark.kt
index f13a503..d82f070 100644
--- a/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/view/AndroidTextViewBenchmark.kt
+++ b/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/benchmark/test/view/AndroidTextViewBenchmark.kt
@@ -50,40 +50,37 @@
@get:Rule
val benchmarkRule = AndroidBenchmarkRule()
+ private val caseFactory = {
+ textBenchmarkRule.generator { textGenerator ->
+ AndroidTextViewTestCase(
+ List(textBenchmarkRule.repeatTimes) {
+ textGenerator.nextParagraph(textLength)
+ }
+ )
+ }
+ }
@Test
fun first_setContent() {
- textBenchmarkRule.generator { textGenerator ->
- benchmarkRule.benchmarkFirstSetContent {
- AndroidTextViewTestCase(textGenerator.nextParagraph(textLength))
- }
- }
+ benchmarkRule.benchmarkFirstSetContent(caseFactory)
}
@Test
fun first_measure() {
- textBenchmarkRule.generator { textGenerator ->
- benchmarkRule.benchmarkFirstMeasure {
- AndroidTextViewTestCase(textGenerator.nextParagraph(textLength))
- }
- }
+ benchmarkRule.benchmarkFirstMeasure(caseFactory)
}
@Test
fun first_setContentPlusMeasure() {
- textBenchmarkRule.generator { textGenerator ->
- with(benchmarkRule) {
- runBenchmarkFor(
- { AndroidTextViewTestCase(textGenerator.nextParagraph(textLength)) }
- ) {
- measureRepeated {
- setupContent()
- runWithTimingDisabled {
- requestLayout()
- }
- measure()
- runWithTimingDisabled {
- disposeContent()
- }
+ with(benchmarkRule) {
+ runBenchmarkFor(caseFactory) {
+ measureRepeated {
+ setupContent()
+ runWithTimingDisabled {
+ requestLayout()
+ }
+ measure()
+ runWithTimingDisabled {
+ disposeContent()
}
}
}
@@ -92,37 +89,21 @@
@Test
fun first_layout() {
- textBenchmarkRule.generator { textGenerator ->
- benchmarkRule.benchmarkFirstLayout {
- AndroidTextViewTestCase(textGenerator.nextParagraph(textLength))
- }
- }
+ benchmarkRule.benchmarkFirstLayout(caseFactory)
}
@Test
fun first_draw() {
- textBenchmarkRule.generator { textGenerator ->
- benchmarkRule.benchmarkFirstDraw {
- AndroidTextViewTestCase(textGenerator.nextParagraph(textLength))
- }
- }
+ benchmarkRule.benchmarkFirstDraw(caseFactory)
}
@Test
fun layout() {
- textBenchmarkRule.generator { textGenerator ->
- benchmarkRule.benchmarkLayoutPerf {
- AndroidTextViewTestCase(textGenerator.nextParagraph(textLength))
- }
- }
+ benchmarkRule.benchmarkLayoutPerf(caseFactory)
}
@Test
fun draw() {
- textBenchmarkRule.generator { textGenerator ->
- benchmarkRule.benchmarkDrawPerf {
- AndroidTextViewTestCase(textGenerator.nextParagraph(textLength))
- }
- }
+ benchmarkRule.benchmarkDrawPerf(caseFactory)
}
}
\ No newline at end of file
diff --git a/ui/integration-tests/src/main/java/androidx/ui/integration/test/TextBenchmarkTestRule.kt b/ui/integration-tests/src/main/java/androidx/ui/integration/test/TextBenchmarkTestRule.kt
index afd8434..a81e39d 100644
--- a/ui/integration-tests/src/main/java/androidx/ui/integration/test/TextBenchmarkTestRule.kt
+++ b/ui/integration-tests/src/main/java/androidx/ui/integration/test/TextBenchmarkTestRule.kt
@@ -54,6 +54,10 @@
// fontSize here are dp and sp, which should be converted into needed unit in the test case.
val widthDp: Float = 160f
val fontSizeSp: Float = 8f
+
+ // We noticed that benchmark a single composable Text will lead to inaccurate result. To fix
+ // this problem, we benchmark a column of Texts with its length equal to [repeatTimes].
+ val repeatTimes: Int = 10
}
/**
diff --git a/ui/integration-tests/src/main/java/androidx/ui/integration/test/core/text/TextBasicTestCase.kt b/ui/integration-tests/src/main/java/androidx/ui/integration/test/core/text/TextInColumnTestCase.kt
similarity index 86%
rename from ui/integration-tests/src/main/java/androidx/ui/integration/test/core/text/TextBasicTestCase.kt
rename to ui/integration-tests/src/main/java/androidx/ui/integration/test/core/text/TextInColumnTestCase.kt
index 102cc50..a4f4579 100644
--- a/ui/integration-tests/src/main/java/androidx/ui/integration/test/core/text/TextBasicTestCase.kt
+++ b/ui/integration-tests/src/main/java/androidx/ui/integration/test/core/text/TextInColumnTestCase.kt
@@ -20,12 +20,13 @@
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
-import androidx.compose.foundation.Box
import androidx.compose.foundation.Text
+import androidx.compose.foundation.layout.Column
import androidx.compose.ui.graphics.Color
import androidx.ui.test.ToggleableTestCase
import androidx.compose.foundation.layout.preferredWidth
import androidx.compose.foundation.layout.wrapContentSize
+import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.TextUnit
import androidx.ui.test.LayeredComposeTestCase
@@ -33,8 +34,8 @@
/**
* The benchmark test case for [Text], where the input is a plain string.
*/
-class TextBasicTestCase(
- private val text: String,
+class TextInColumnTestCase(
+ private val texts: List<AnnotatedString>,
private val width: Dp,
private val fontSize: TextUnit
) : LayeredComposeTestCase, ToggleableTestCase {
@@ -43,17 +44,20 @@
@Composable
override fun emitMeasuredContent() {
- Text(text = text, color = color.value, fontSize = fontSize)
+ for (text in texts) {
+ Text(text = text, color = color.value, fontSize = fontSize)
+ }
}
@Composable
override fun emitContentWrappers(content: @Composable () -> Unit) {
- Box(
+ Column(
modifier = Modifier.wrapContentSize(Alignment.Center).preferredWidth(width)
) {
content()
}
}
+
override fun toggleState() {
if (color.value == Color.Black) {
color.value = Color.Red
diff --git a/ui/integration-tests/src/main/java/androidx/ui/integration/test/core/text/TextMultiStyleTestCase.kt b/ui/integration-tests/src/main/java/androidx/ui/integration/test/core/text/TextMultiStyleTestCase.kt
deleted file mode 100644
index 7e89dbf..0000000
--- a/ui/integration-tests/src/main/java/androidx/ui/integration/test/core/text/TextMultiStyleTestCase.kt
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 2020 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.core.text
-
-import androidx.compose.runtime.Composable
-import androidx.compose.ui.Alignment
-import androidx.compose.ui.Modifier
-import androidx.compose.foundation.Text
-import androidx.compose.ui.graphics.Color
-import androidx.ui.integration.test.RandomTextGenerator
-import androidx.compose.foundation.layout.preferredWidth
-import androidx.compose.foundation.layout.wrapContentSize
-import androidx.ui.test.ComposeTestCase
-import androidx.compose.ui.text.AnnotatedString
-import androidx.compose.ui.text.TextStyle
-import androidx.compose.ui.unit.Dp
-import androidx.compose.ui.unit.TextUnit
-
-/**
- * The benchmark test case for [Text], where the input is an [AnnotatedString] with [TextStyle]s
- * on it.
- */
-class TextMultiStyleTestCase(
- private val width: Dp,
- private val fontSize: TextUnit,
- textLength: Int,
- styleCount: Int,
- randomTextGenerator: RandomTextGenerator
-) : ComposeTestCase {
-
- /**
- * Trick to avoid the text word cache.
- * @see TextBasicTestCase.text
- */
- private val text = randomTextGenerator.nextAnnotatedString(
- length = textLength,
- styleCount = styleCount,
- hasMetricAffectingStyle = true
- )
-
- @Composable
- override fun emitContent() {
- Text(
- text = text, color = Color.Black, fontSize = fontSize,
- modifier = Modifier.wrapContentSize(Alignment.Center).preferredWidth(width)
- )
- }
-}
\ No newline at end of file
diff --git a/ui/integration-tests/src/main/java/androidx/ui/integration/test/core/text/TextToggleTextTestCase.kt b/ui/integration-tests/src/main/java/androidx/ui/integration/test/core/text/TextToggleTextTestCase.kt
index 69fdf8a..891ac21 100644
--- a/ui/integration-tests/src/main/java/androidx/ui/integration/test/core/text/TextToggleTextTestCase.kt
+++ b/ui/integration-tests/src/main/java/androidx/ui/integration/test/core/text/TextToggleTextTestCase.kt
@@ -17,8 +17,8 @@
package androidx.ui.integration.test.core.text
import androidx.compose.runtime.Composable
-import androidx.compose.foundation.Box
import androidx.compose.foundation.Text
+import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.preferredWidth
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.runtime.mutableStateOf
@@ -34,22 +34,31 @@
class TextToggleTextTestCase(
private val textGenerator: RandomTextGenerator,
private val textLength: Int,
+ private val textNumber: Int,
private val width: Dp,
private val fontSize: TextUnit
) : ComposeTestCase, ToggleableTestCase {
- val text = mutableStateOf(textGenerator.nextParagraph(length = textLength))
+ private val texts = mutableStateOf(
+ List(textNumber) {
+ textGenerator.nextParagraph(length = textLength)
+ }
+ )
@Composable
override fun emitContent() {
- Box(
+ Column(
modifier = Modifier.wrapContentSize(Alignment.Center).preferredWidth(width)
) {
- Text(text = text.value, color = Color.Black, fontSize = fontSize)
+ for (text in texts.value) {
+ Text(text = text, color = Color.Black, fontSize = fontSize)
+ }
}
}
override fun toggleState() {
- text.value = textGenerator.nextParagraph(length = textLength)
+ texts.value = List(textNumber) {
+ textGenerator.nextParagraph(length = textLength)
+ }
}
}
\ No newline at end of file
diff --git a/ui/integration-tests/src/main/java/androidx/ui/integration/test/view/AndroidTextViewTestCase.kt b/ui/integration-tests/src/main/java/androidx/ui/integration/test/view/AndroidTextViewTestCase.kt
index 2dfbcc5..0db1c47 100644
--- a/ui/integration-tests/src/main/java/androidx/ui/integration/test/view/AndroidTextViewTestCase.kt
+++ b/ui/integration-tests/src/main/java/androidx/ui/integration/test/view/AndroidTextViewTestCase.kt
@@ -19,7 +19,7 @@
import android.app.Activity
import android.util.TypedValue
import android.view.ViewGroup
-import android.widget.FrameLayout
+import android.widget.LinearLayout
import android.widget.TextView
import androidx.ui.benchmark.android.AndroidTestCase
import kotlin.math.roundToInt
@@ -28,28 +28,35 @@
* Version of [androidx.ui.integration.test.core.text.TextBasicTestCase] using Android views.
*/
class AndroidTextViewTestCase(
- val text: String
+ private val texts: List<String>
) : AndroidTestCase {
private var fontSize = 8f
override fun getContent(activity: Activity): ViewGroup {
- val frameLayout = FrameLayout(activity)
- val textView = TextView(activity)
- textView.text = text
- textView.layoutParams = ViewGroup.LayoutParams(
- ViewGroup.LayoutParams.WRAP_CONTENT,
+ val column = LinearLayout(activity)
+ column.orientation = LinearLayout.VERTICAL
+ column.layoutParams = ViewGroup.LayoutParams(
+ ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
)
+ for (text in texts) {
+ val textView = TextView(activity)
+ textView.text = text
+ textView.layoutParams = ViewGroup.LayoutParams(
+ ViewGroup.LayoutParams.WRAP_CONTENT,
+ ViewGroup.LayoutParams.WRAP_CONTENT
+ )
- textView.width = TypedValue.applyDimension(
- TypedValue.COMPLEX_UNIT_DIP,
- 160f,
- activity.resources.displayMetrics
- ).roundToInt()
+ textView.width = TypedValue.applyDimension(
+ TypedValue.COMPLEX_UNIT_DIP,
+ 160f,
+ activity.resources.displayMetrics
+ ).roundToInt()
- textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize)
- frameLayout.addView(textView)
- return frameLayout
+ textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize)
+ column.addView(textView)
+ }
+ return column
}
}