Add Unit Em
Bug: 139312484
Test: ./gradlew test
Change-Id: Ie3c229a699422048418f4addb3a7218473a96c95
diff --git a/ui/ui-text/src/androidTest/java/androidx/ui/text/ParagraphIntegrationTest.kt b/ui/ui-text/src/androidTest/java/androidx/ui/text/ParagraphIntegrationTest.kt
index 51a0e6a..50c660c 100644
--- a/ui/ui-text/src/androidTest/java/androidx/ui/text/ParagraphIntegrationTest.kt
+++ b/ui/ui-text/src/androidTest/java/androidx/ui/text/ParagraphIntegrationTest.kt
@@ -22,6 +22,7 @@
import androidx.ui.core.Density
import androidx.ui.core.PxPosition
import androidx.ui.core.Sp
+import androidx.ui.core.em
import androidx.ui.core.px
import androidx.ui.core.sp
import androidx.ui.core.withDensity
@@ -2348,7 +2349,7 @@
val fontSize = 20.sp
val fontSizeInPx = fontSize.toPx().value
val letterSpacing = 5.0f
- val textStyle = TextStyle(letterSpacing = letterSpacing)
+ val textStyle = TextStyle(letterSpacing = letterSpacing.em)
val paragraphWidth = fontSizeInPx * (1 + letterSpacing) * text.length
val paragraph = simpleParagraph(
@@ -2373,7 +2374,7 @@
val fontSize = 20.sp
val fontSizeInPx = fontSize.toPx().value
val letterSpacing = 5.0f
- val textStyle = TextStyle(letterSpacing = letterSpacing)
+ val textStyle = TextStyle(letterSpacing = letterSpacing.em)
val paragraphWidth = fontSizeInPx * (1 + letterSpacing) * text.length
val paragraph = simpleParagraph(
@@ -2398,11 +2399,11 @@
val fontSize = 20.sp
val fontSizeInPx = fontSize.toPx().value
val letterSpacing = 5.0f
- val textStyle = TextStyle(letterSpacing = letterSpacing)
+ val textStyle = TextStyle(letterSpacing = letterSpacing.em)
val letterSpacingOverwrite = 10.0f
val textStyleOverwrite =
- TextStyle(letterSpacing = letterSpacingOverwrite)
+ TextStyle(letterSpacing = letterSpacingOverwrite.em)
val paragraphWidth = fontSizeInPx * (1 + letterSpacingOverwrite) * text.length
val paragraph = simpleParagraph(
@@ -2625,7 +2626,7 @@
val fontSize = 100.sp
val fontSizeInPx = fontSize.toPx().value
val letterSpacing = 1f
- val textStyle = TextStyle(letterSpacing = letterSpacing)
+ val textStyle = TextStyle(letterSpacing = letterSpacing.em)
val paragraph = simpleParagraph(
text = text,
diff --git a/ui/ui-text/src/androidTest/java/androidx/ui/text/platform/AndroidParagraphTest.kt b/ui/ui-text/src/androidTest/java/androidx/ui/text/platform/AndroidParagraphTest.kt
index 7afacb2..e28d153 100644
--- a/ui/ui-text/src/androidTest/java/androidx/ui/text/platform/AndroidParagraphTest.kt
+++ b/ui/ui-text/src/androidTest/java/androidx/ui/text/platform/AndroidParagraphTest.kt
@@ -21,6 +21,7 @@
import androidx.text.style.SkewXSpan
import androidx.text.style.TypefaceSpan
import androidx.ui.core.Density
+import androidx.ui.core.em
import androidx.ui.core.px
import androidx.ui.core.sp
import androidx.ui.core.withDensity
@@ -330,7 +331,7 @@
fun testAnnotatedString_setLetterSpacingOnWholeText() {
val text = "abcde"
val letterSpacing = 2.0f
- val textStyle = TextStyle(letterSpacing = letterSpacing)
+ val textStyle = TextStyle(letterSpacing = letterSpacing.em)
val paragraph = simpleParagraph(
text = text,
@@ -345,7 +346,7 @@
@Test
fun testAnnotatedString_setLetterSpacingOnPartText() {
val text = "abcde"
- val textStyle = TextStyle(letterSpacing = 2.0f)
+ val textStyle = TextStyle(letterSpacing = 2.em)
val paragraph = simpleParagraph(
text = text,
@@ -360,8 +361,8 @@
@Test
fun testAnnotatedString_setLetterSpacingTwice_lastOneOverwrite() {
val text = "abcde"
- val textStyle = TextStyle(letterSpacing = 2.0f)
- val textStyleOverwrite = TextStyle(letterSpacing = 3.0f)
+ val textStyle = TextStyle(letterSpacing = 2.em)
+ val textStyleOverwrite = TextStyle(letterSpacing = 3.em)
val paragraph = simpleParagraph(
text = text,
@@ -1035,10 +1036,10 @@
@Test
fun testTextStyle_letterSpacing_appliedOnTextPaint() {
- val letterSpacing = 2.0f
+ val letterSpacing = 2
val paragraph = simpleParagraph(
text = "",
- textStyle = TextStyle(letterSpacing = letterSpacing),
+ textStyle = TextStyle(letterSpacing = letterSpacing.em),
constraints = ParagraphConstraints(width = 0.0f)
)