Merge "Fix wrong shouldSucceed values" into androidx-main
diff --git a/compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/style/HyphensTest.kt b/compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/style/HyphensTest.kt
new file mode 100644
index 0000000..cb93b53
--- /dev/null
+++ b/compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/style/HyphensTest.kt
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2022 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.compose.ui.text.style
+
+import androidx.compose.ui.text.ExperimentalTextApi
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+
+@OptIn(ExperimentalTextApi::class)
+class HyphensTest : TextLineBreaker() {
+ private val text = "Transformation"
+
+ @Test
+ fun check_hyphens_Auto() {
+ val brokenLines = breakTextIntoLines(
+ text = text,
+ hyphens = Hyphens.Auto,
+ maxWidth = 30
+ )
+ val expected = listOf(
+ "Tran",
+ "sfor",
+ "ma",
+ "tion"
+ )
+ assertThat(brokenLines).isEqualTo(expected)
+ }
+
+ @Test
+ fun check_hyphens_None() {
+ val brokenLines = breakTextIntoLines(
+ text = text,
+ hyphens = Hyphens.None,
+ maxWidth = 30
+ )
+ val expected = listOf(
+ "Tran",
+ "sfor",
+ "mati",
+ "on"
+ )
+ assertThat(brokenLines).isEqualTo(expected)
+ }
+}
\ No newline at end of file
diff --git a/compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/style/LineBreakTest.kt b/compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/style/LineBreakTest.kt
index e3610d6..69d112c 100644
--- a/compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/style/LineBreakTest.kt
+++ b/compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/style/LineBreakTest.kt
@@ -16,33 +16,17 @@
package androidx.compose.ui.text.style
-import androidx.compose.ui.text.AnnotatedString
import androidx.compose.ui.text.ExperimentalTextApi
-import androidx.compose.ui.text.MultiParagraph
-import androidx.compose.ui.text.TextLayoutInput
-import androidx.compose.ui.text.TextLayoutResult
-import androidx.compose.ui.text.TextStyle
-import androidx.compose.ui.text.font.createFontFamilyResolver
-import androidx.compose.ui.unit.Constraints
-import androidx.compose.ui.unit.Density
-import androidx.compose.ui.unit.IntSize
-import androidx.compose.ui.unit.LayoutDirection
-import androidx.compose.ui.unit.constrain
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
-import androidx.test.platform.app.InstrumentationRegistry
import com.google.common.truth.Truth.assertThat
-import kotlin.math.ceil
import org.junit.Test
import org.junit.runner.RunWith
@OptIn(ExperimentalTextApi::class)
@RunWith(AndroidJUnit4::class)
@SmallTest
-class LineBreakTest {
- private val defaultDensity = Density(1f)
- private val context = InstrumentationRegistry.getInstrumentation().context
- private val fontFamilyResolver = createFontFamilyResolver(context)
+class LineBreakTest : TextLineBreaker() {
private val textToLineBreak = "This is an example text"
@Test
@@ -263,63 +247,4 @@
assertThat(brokenLines).isEqualTo(expectedBrokenLines)
}
-
- private fun constructTextLayoutResult(
- text: String,
- textStyle: TextStyle,
- maxWidth: Int = Constraints.Infinity
- ): TextLayoutResult {
- val constraints = Constraints(maxWidth = maxWidth)
-
- val input = TextLayoutInput(
- text = AnnotatedString(text),
- style = textStyle,
- placeholders = listOf(),
- maxLines = Int.MAX_VALUE,
- softWrap = true,
- overflow = TextOverflow.Visible,
- density = defaultDensity,
- layoutDirection = LayoutDirection.Ltr,
- fontFamilyResolver = fontFamilyResolver,
- constraints = constraints
- )
-
- val paragraph = MultiParagraph(
- annotatedString = input.text,
- style = input.style,
- constraints = input.constraints,
- density = input.density,
- fontFamilyResolver = input.fontFamilyResolver
- )
-
- return TextLayoutResult(
- layoutInput = input,
- multiParagraph = paragraph,
- size = constraints.constrain(
- IntSize(
- ceil(paragraph.width).toInt(),
- ceil(paragraph.height).toInt()
- )
- )
- )
- }
-
- private fun breakTextIntoLines(
- text: String,
- lineBreak: LineBreak,
- maxWidth: Int
- ): List<String> {
- val layoutResult = constructTextLayoutResult(
- text = text,
- textStyle = TextStyle(lineBreak = lineBreak),
- maxWidth = maxWidth
- )
-
- return (0 until layoutResult.lineCount).map { lineIndex ->
- text.substring(
- layoutResult.getLineStart(lineIndex),
- layoutResult.getLineEnd(lineIndex)
- )
- }
- }
}
\ No newline at end of file
diff --git a/compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/style/TextLineBreaker.kt b/compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/style/TextLineBreaker.kt
new file mode 100644
index 0000000..6f3ff165
--- /dev/null
+++ b/compose/ui/ui-text/src/androidAndroidTest/kotlin/androidx/compose/ui/text/style/TextLineBreaker.kt
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2022 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.compose.ui.text.style
+
+import androidx.compose.ui.text.AnnotatedString
+import androidx.compose.ui.text.ExperimentalTextApi
+import androidx.compose.ui.text.MultiParagraph
+import androidx.compose.ui.text.TextLayoutInput
+import androidx.compose.ui.text.TextLayoutResult
+import androidx.compose.ui.text.TextStyle
+import androidx.compose.ui.text.font.createFontFamilyResolver
+import androidx.compose.ui.unit.Constraints
+import androidx.compose.ui.unit.Density
+import androidx.compose.ui.unit.IntSize
+import androidx.compose.ui.unit.LayoutDirection
+import androidx.compose.ui.unit.constrain
+import androidx.test.platform.app.InstrumentationRegistry
+import kotlin.math.ceil
+
+@OptIn(ExperimentalTextApi::class)
+open class TextLineBreaker {
+ private val defaultDensity = Density(1f)
+ private val context = InstrumentationRegistry.getInstrumentation().context
+ private val fontFamilyResolver = createFontFamilyResolver(context)
+ private val defaultHyphens = Hyphens.None
+ private val defaultLineBreak = LineBreak.Simple
+
+ private fun constructTextLayoutResult(
+ text: String,
+ textStyle: TextStyle,
+ maxWidth: Int = Constraints.Infinity
+ ): TextLayoutResult {
+ val constraints = Constraints(maxWidth = maxWidth)
+
+ val input = TextLayoutInput(
+ text = AnnotatedString(text),
+ style = textStyle,
+ placeholders = listOf(),
+ maxLines = Int.MAX_VALUE,
+ softWrap = true,
+ overflow = TextOverflow.Visible,
+ density = defaultDensity,
+ layoutDirection = LayoutDirection.Ltr,
+ fontFamilyResolver = fontFamilyResolver,
+ constraints = constraints
+ )
+
+ val paragraph = MultiParagraph(
+ annotatedString = input.text,
+ style = input.style,
+ constraints = input.constraints,
+ density = input.density,
+ fontFamilyResolver = input.fontFamilyResolver
+ )
+
+ return TextLayoutResult(
+ layoutInput = input,
+ multiParagraph = paragraph,
+ size = constraints.constrain(
+ IntSize(
+ ceil(paragraph.width).toInt(),
+ ceil(paragraph.height).toInt()
+ )
+ )
+ )
+ }
+
+ fun breakTextIntoLines(
+ text: String,
+ hyphens: Hyphens = defaultHyphens,
+ lineBreak: LineBreak = defaultLineBreak,
+ maxWidth: Int
+ ): List<String> {
+ val layoutResult = constructTextLayoutResult(
+ text = text,
+ textStyle = TextStyle(hyphens = hyphens, lineBreak = lineBreak),
+ maxWidth = maxWidth
+ )
+
+ return (0 until layoutResult.lineCount).map { lineIndex ->
+ text.substring(
+ layoutResult.getLineStart(lineIndex),
+ layoutResult.getLineEnd(lineIndex)
+ )
+ }
+ }
+}
\ No newline at end of file
diff --git a/room/room-migration/src/main/java/androidx/room/migration/bundle/FtsEntityBundle.kt b/room/room-migration/src/main/java/androidx/room/migration/bundle/FtsEntityBundle.kt
index b5e8ed9..ec1c6ed 100644
--- a/room/room-migration/src/main/java/androidx/room/migration/bundle/FtsEntityBundle.kt
+++ b/room/room-migration/src/main/java/androidx/room/migration/bundle/FtsEntityBundle.kt
@@ -60,6 +60,7 @@
emptyList()
)
+ @Transient
private val SHADOW_TABLE_NAME_SUFFIXES = listOf(
"_content",
"_segdir",
@@ -92,6 +93,7 @@
* Gets the list of shadow table names corresponding to the FTS virtual table.
* @return the list of names.
*/
+ @delegate:Transient
public open val shadowTableNames: List<String> by lazy {
val currentTable = this@FtsEntityBundle.tableName
buildList {