Removal of Px usages part 1 of n
Relnote: "Replaced usage of Px class in various
compose classes as part of the large
refactoring effort to only rely on Dp
and primitive types for pixel parameters"
Bug: 156681014
Test: re-ran compose tests
Change-Id: Iede0b310a8a8f4a39ba6ae4a99c753f7f590d8ed
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/BorderTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/BorderTest.kt
index fc481a4..190b511 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/BorderTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/BorderTest.kt
@@ -37,7 +37,6 @@
import androidx.ui.test.createComposeRule
import androidx.ui.test.findByTag
import androidx.ui.unit.Density
-import androidx.ui.unit.px
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -52,7 +51,7 @@
@JvmStatic
@Parameterized.Parameters(name = "{0}")
fun initShapes(): Array<Any> = arrayOf(
- RectangleShape, CircleShape, RoundedCornerShape(5.px)
+ RectangleShape, CircleShape, RoundedCornerShape(5.0f)
)
}
@@ -66,9 +65,9 @@
composeTestRule.setContent {
SemanticParent {
Stack(
- Modifier.preferredSize(40.px.toDp(), 40.px.toDp())
+ Modifier.preferredSize(40.0f.toDp(), 40.0f.toDp())
.drawBackground(Color.Blue, shape)
- .drawBorder(Border(10.px.toDp(), Color.Red), shape)
+ .drawBorder(Border(10.0f.toDp(), Color.Red), shape)
) {}
}
@@ -79,10 +78,10 @@
backgroundColor = Color.Red,
shape = shape,
backgroundShape = shape,
- shapeSizeX = 20.px,
- shapeSizeY = 20.px,
+ shapeSizeX = 20.0f,
+ shapeSizeY = 20.0f,
shapeColor = Color.Blue,
- shapeOverlapPixelCount = 3.px
+ shapeOverlapPixelCount = 3.0f
)
}
@@ -91,10 +90,10 @@
composeTestRule.setContent {
SemanticParent {
Stack(
- Modifier.preferredSize(40.px.toDp(), 40.px.toDp())
+ Modifier.preferredSize(40.0f.toDp(), 40.0f.toDp())
.drawBackground(Color.Blue, shape)
.drawBorder(
- Border(10.px.toDp(), SolidColor(Color.Red)),
+ Border(10.0f.toDp(), SolidColor(Color.Red)),
shape
)
) {}
@@ -106,10 +105,10 @@
backgroundColor = Color.Red,
shape = shape,
backgroundShape = shape,
- shapeSizeX = 20.px,
- shapeSizeY = 20.px,
+ shapeSizeX = 20.0f,
+ shapeSizeY = 20.0f,
shapeColor = Color.Blue,
- shapeOverlapPixelCount = 3.px
+ shapeOverlapPixelCount = 3.0f
)
}
@@ -118,9 +117,9 @@
composeTestRule.setContent {
SemanticParent {
Stack(
- Modifier.preferredSize(40.px.toDp(), 40.px.toDp())
+ Modifier.preferredSize(40.0f.toDp(), 40.0f.toDp())
.drawBackground(Color.Blue, shape)
- .drawBorder(Border(1500.px.toDp(), Color.Red), shape)
+ .drawBorder(Border(1500.0f.toDp(), Color.Red), shape)
) {}
}
}
@@ -131,7 +130,7 @@
shapeColor = Color.Red,
shape = shape,
backgroundShape = shape,
- shapeOverlapPixelCount = 2.px
+ shapeOverlapPixelCount = 2.0f
)
}
@@ -140,9 +139,9 @@
composeTestRule.setContent {
SemanticParent {
Stack(
- Modifier.preferredSize(40.px.toDp(), 40.px.toDp())
+ Modifier.preferredSize(40.0f.toDp(), 40.0f.toDp())
.drawBackground(Color.Blue, shape)
- .drawBorder(Border(-5.px.toDp(), Color.Red), shape)
+ .drawBorder(Border(-5.0f.toDp(), Color.Red), shape)
) {}
}
}
@@ -153,7 +152,7 @@
shapeColor = Color.Blue,
shape = shape,
backgroundShape = shape,
- shapeOverlapPixelCount = 2.px
+ shapeOverlapPixelCount = 2.0f
)
}
@@ -162,12 +161,12 @@
composeTestRule.setContent {
SemanticParent {
Box(
- Modifier.preferredSize(40.px.toDp(), 40.px.toDp()),
+ Modifier.preferredSize(40.0f.toDp(), 40.0f.toDp()),
backgroundColor = Color.White
) {
Stack(
- Modifier.preferredSize(0.px.toDp(), 40.px.toDp())
- .drawBorder(Border(4.px.toDp(), Color.Red), shape)
+ Modifier.preferredSize(0.0f.toDp(), 40.0f.toDp())
+ .drawBorder(Border(4.0f.toDp(), Color.Red), shape)
) {}
}
}
@@ -178,7 +177,7 @@
backgroundColor = Color.White,
shapeColor = Color.White,
shape = RectangleShape,
- shapeOverlapPixelCount = 1.px
+ shapeOverlapPixelCount = 1.0f
)
}
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/BoxTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/BoxTest.kt
index 54597c6..f927e06 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/BoxTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/BoxTest.kt
@@ -46,7 +46,6 @@
import androidx.ui.unit.PxPosition
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
-import androidx.ui.unit.px
import com.google.common.truth.Truth
import org.junit.Rule
import org.junit.Test
@@ -287,8 +286,8 @@
shape = RectangleShape,
shapeColor = Color.Blue,
backgroundColor = Color.Red,
- shapeSizeX = size.toPx() - padding.toPx() - padding.toPx(),
- shapeSizeY = size.toPx() - padding.toPx() - padding.toPx()
+ shapeSizeX = (size.toPx() - padding.toPx() - padding.toPx()).value,
+ shapeSizeY = (size.toPx() - padding.toPx() - padding.toPx()).value
)
}
}
@@ -315,9 +314,9 @@
shape = CircleShape,
shapeColor = Color.Blue,
backgroundColor = Color.Red,
- shapeSizeX = size.toPx() - padding.toPx() - padding.toPx(),
- shapeSizeY = size.toPx() - padding.toPx() - padding.toPx(),
- shapeOverlapPixelCount = 2.px
+ shapeSizeX = (size.toPx() - padding.toPx() - padding.toPx()).value,
+ shapeSizeY = (size.toPx() - padding.toPx() - padding.toPx()).value,
+ shapeOverlapPixelCount = 2.0f
)
}
}
@@ -342,9 +341,9 @@
shape = RectangleShape,
shapeColor = Color.Blue,
backgroundColor = Color.Red,
- shapeSizeX = size.toPx() - borderSize.toPx() * 2,
- shapeSizeY = size.toPx() - borderSize.toPx() * 2,
- shapeOverlapPixelCount = 2.px
+ shapeSizeX = (size.toPx() - borderSize.toPx() * 2).value,
+ shapeSizeY = (size.toPx() - borderSize.toPx() * 2).value,
+ shapeOverlapPixelCount = 2.0f
)
}
}
@@ -375,7 +374,7 @@
shape = CircleShape,
shapeColor = Color.Blue,
backgroundColor = Color.Red,
- shapeOverlapPixelCount = 2.px
+ shapeOverlapPixelCount = 2.0f
)
}
}
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/CanvasTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/CanvasTest.kt
index d00c380..ea4e260c 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/CanvasTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/CanvasTest.kt
@@ -43,7 +43,6 @@
import androidx.ui.unit.Density
import androidx.ui.unit.IntPxSize
import androidx.ui.unit.dp
-import androidx.ui.unit.px
import com.google.common.truth.Truth
import org.junit.Assert
import org.junit.Assert.assertTrue
@@ -216,9 +215,9 @@
backgroundColor = Color.Red,
shapeColor = Color.Blue,
shape = CircleShape,
- shapeSizeX = 20.px,
- shapeSizeY = 20.px,
- shapeOverlapPixelCount = 2.px
+ shapeSizeX = 20.0f,
+ shapeSizeY = 20.0f,
+ shapeOverlapPixelCount = 2.0f
)
}
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DrawBackgroundTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DrawBackgroundTest.kt
index 8505d8a..95e1d89 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DrawBackgroundTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/DrawBackgroundTest.kt
@@ -68,8 +68,8 @@
density = composeTestRule.density,
backgroundColor = Color.Magenta,
shape = RectangleShape,
- shapeSizeX = 20.px,
- shapeSizeY = 20.px,
+ shapeSizeX = 20.0f,
+ shapeSizeY = 20.0f,
shapeColor = Color.White
)
}
@@ -94,8 +94,8 @@
density = composeTestRule.density,
backgroundColor = Color.Magenta,
shape = RectangleShape,
- shapeSizeX = 20.px,
- shapeSizeY = 20.px,
+ shapeSizeX = 20.0f,
+ shapeSizeY = 20.0f,
shapeColor = Color.White
)
}
@@ -117,7 +117,7 @@
backgroundColor = Color.Magenta,
shape = CircleShape,
shapeColor = Color.White,
- shapeOverlapPixelCount = 2.px
+ shapeOverlapPixelCount = 2.0f
)
}
@@ -141,7 +141,7 @@
backgroundColor = Color.Magenta,
shape = CircleShape,
shapeColor = Color.White,
- shapeOverlapPixelCount = 2.px
+ shapeOverlapPixelCount = 2.0f
)
}
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldTest.kt
index 408b108..e80e1f4 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/TextFieldTest.kt
@@ -60,7 +60,6 @@
import androidx.ui.unit.IntPxSize
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
-import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
import com.nhaarman.mockitokotlin2.any
import com.nhaarman.mockitokotlin2.argumentCaptor
@@ -441,7 +440,7 @@
shape = RectangleShape,
shapeColor = Color.White,
backgroundColor = Color.White,
- shapeOverlapPixelCount = 0.px
+ shapeOverlapPixelCount = 0.0f
)
}
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/shape/corner/CornerBasedShapeTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/shape/corner/CornerBasedShapeTest.kt
index cac90d8..bb48fb2 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/shape/corner/CornerBasedShapeTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/shape/corner/CornerBasedShapeTest.kt
@@ -20,10 +20,8 @@
import androidx.ui.geometry.RRect
import androidx.ui.graphics.Outline
import androidx.ui.unit.Density
-import androidx.ui.unit.Px
import androidx.ui.unit.PxSize
import androidx.ui.unit.dp
-import androidx.ui.unit.px
import androidx.ui.unit.toRect
import com.google.common.truth.Truth.assertThat
import org.junit.Test
@@ -37,23 +35,23 @@
@Test
fun createOutlineCalledWithCorrectParams() {
val density = Density(2f, 1f)
- val passedSize = PxSize(100.px, 50.px)
+ val passedSize = PxSize(100.0f, 50.0f)
var assertionExecuted = false
val assertSizes = { size: PxSize,
- topLeft: Px,
- topRight: Px,
- bottomRight: Px,
- bottomLeft: Px ->
+ topLeft: Float,
+ topRight: Float,
+ bottomRight: Float,
+ bottomLeft: Float ->
assertThat(size).isEqualTo(passedSize)
- assertThat(topLeft).isEqualTo(4.px)
- assertThat(topRight).isEqualTo(3.px)
- assertThat(bottomRight).isEqualTo(6.px)
- assertThat(bottomLeft).isEqualTo(25.px)
+ assertThat(topLeft).isEqualTo(4.0f)
+ assertThat(topRight).isEqualTo(3.0f)
+ assertThat(bottomRight).isEqualTo(6.0f)
+ assertThat(bottomLeft).isEqualTo(25.0f)
assertionExecuted = true
}
val impl = Impl(
- topLeft = CornerSize(4.px),
- topRight = CornerSize(3.px),
+ topLeft = CornerSize(4.0f),
+ topRight = CornerSize(3.0f),
bottomRight = CornerSize(3.dp),
bottomLeft = CornerSize(50),
>
@@ -68,27 +66,27 @@
@Test
fun cornersSizesAreNotLargerThenMinDimension() {
val density = Density(2f, 1f)
- val sizeWithLargerWidth = PxSize(6.px, 4.px)
- val sizeWithLargerHeight = PxSize(4.px, 6.px)
+ val sizeWithLargerWidth = PxSize(6.0f, 4.0f)
+ val sizeWithLargerHeight = PxSize(4.0f, 6.0f)
val sizesList = mutableListOf<PxSize>()
val assertSizes = { size: PxSize,
- topLeft: Px,
- topRight: Px,
- bottomRight: Px,
- bottomLeft: Px ->
+ topLeft: Float,
+ topRight: Float,
+ bottomRight: Float,
+ bottomLeft: Float ->
sizesList.add(size)
- assertThat(topLeft).isEqualTo(2.px)
- assertThat(topRight).isEqualTo(2.px)
- assertThat(bottomRight).isEqualTo(1.px)
- assertThat(bottomLeft).isEqualTo(2.px)
+ assertThat(topLeft).isEqualTo(2.0f)
+ assertThat(topRight).isEqualTo(2.0f)
+ assertThat(bottomRight).isEqualTo(1.0f)
+ assertThat(bottomLeft).isEqualTo(2.0f)
}
val impl = Impl(
- topLeft = CornerSize(10.px),
+ topLeft = CornerSize(10.0f),
topRight = CornerSize(6.dp),
- bottomRight = CornerSize(1.px),
- bottomLeft = CornerSize(2.px),
+ bottomRight = CornerSize(1.0f),
+ bottomLeft = CornerSize(2.0f),
>
)
@@ -103,14 +101,14 @@
@Suppress("ReplaceCallWithBinaryOperator")
assertThat(
Impl2(
- topLeft = CornerSize(4.px),
- topRight = CornerSize(3.px),
+ topLeft = CornerSize(4.0f),
+ topRight = CornerSize(3.0f),
bottomRight = CornerSize(3.dp),
bottomLeft = CornerSize(50)
).equals(
Impl2(
- topLeft = CornerSize(4.px),
- topRight = CornerSize(3.px),
+ topLeft = CornerSize(4.0f),
+ topRight = CornerSize(3.0f),
bottomRight = CornerSize(3.dp),
bottomLeft = CornerSize(50)
)
@@ -123,14 +121,14 @@
@Suppress("ReplaceCallWithBinaryOperator")
assertThat(
Impl(
- topLeft = CornerSize(4.px),
- topRight = CornerSize(3.px),
+ topLeft = CornerSize(4.0f),
+ topRight = CornerSize(3.0f),
bottomRight = CornerSize(3.dp),
bottomLeft = CornerSize(50)
).equals(
Impl2(
- topLeft = CornerSize(4.px),
- topRight = CornerSize(3.px),
+ topLeft = CornerSize(4.0f),
+ topRight = CornerSize(3.0f),
bottomRight = CornerSize(3.dp),
bottomLeft = CornerSize(50)
)
@@ -141,8 +139,8 @@
@Test
fun copyingUsesCorrectDefaults() {
val impl = Impl(
- topLeft = CornerSize(4.px),
- topRight = CornerSize(3.px),
+ topLeft = CornerSize(4.0f),
+ topRight = CornerSize(3.0f),
bottomRight = CornerSize(3.dp),
bottomLeft = CornerSize(50)
)
@@ -156,15 +154,15 @@
topRight: CornerSize,
bottomRight: CornerSize,
bottomLeft: CornerSize,
- private val onOutlineRequested: ((PxSize, Px, Px, Px, Px) -> Unit)? = null
+ private val onOutlineRequested: ((PxSize, Float, Float, Float, Float) -> Unit)? = null
) : CornerBasedShape(topLeft, topRight, bottomRight, bottomLeft) {
override fun createOutline(
size: PxSize,
- topLeft: Px,
- topRight: Px,
- bottomRight: Px,
- bottomLeft: Px
+ topLeft: Float,
+ topRight: Float,
+ bottomRight: Float,
+ bottomLeft: Float
): Outline {
onOutlineRequested?.invoke(size, topLeft, topRight, bottomRight, bottomLeft)
return Outline.Rectangle(size.toRect())
@@ -187,10 +185,10 @@
override fun createOutline(
size: PxSize,
- topLeft: Px,
- topRight: Px,
- bottomRight: Px,
- bottomLeft: Px
+ topLeft: Float,
+ topRight: Float,
+ bottomRight: Float,
+ bottomLeft: Float
): Outline {
return Outline.Rounded(RRect(size.toRect()))
}
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/shape/corner/CornerSizeTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/shape/corner/CornerSizeTest.kt
index 637f0d1..f6eea7f 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/shape/corner/CornerSizeTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/shape/corner/CornerSizeTest.kt
@@ -35,46 +35,35 @@
@Test
fun pxCorners() {
- val corner = CornerSize(24.px)
- assertThat(corner.toPx(size, density)).isEqualTo(24.px)
+ val corner = CornerSize(24.0f)
+ assertThat(corner.toPx(size, density)).isEqualTo(24.0f)
}
@Test
fun dpCorners() {
val corner = CornerSize(5.dp)
- assertThat(corner.toPx(size, density)).isEqualTo(12.5.px)
+ assertThat(corner.toPx(size, density)).isEqualTo(12.5f)
}
@Test
fun intPercentCorners() {
val corner = CornerSize(15)
- assertThat(corner.toPx(size, density)).isEqualTo(22.5.px)
- }
-
- @Test
- fun floatPercentCorners() {
- val corner = CornerSize(21.6f)
- assertThat(corner.toPx(PxSize(1000.px, 120.px), density)).isEqualTo(25.92.px)
+ assertThat(corner.toPx(size, density)).isEqualTo(22.5f)
}
@Test
fun zeroCorners() {
val corner = ZeroCornerSize
- assertThat(corner.toPx(size, density)).isEqualTo(0.px)
+ assertThat(corner.toPx(size, density)).isEqualTo(0.0f)
}
@Test
fun pxCornersAreEquals() {
- assertThat(CornerSize(24.px)).isEqualTo(CornerSize(24.px))
+ assertThat(CornerSize(24.0f)).isEqualTo(CornerSize(24.0f))
}
@Test
fun dpCornersAreEquals() {
assertThat(CornerSize(8.dp)).isEqualTo(CornerSize(8.dp))
}
-
- @Test
- fun percentCornersAreEquals() {
- assertThat(CornerSize(20f)).isEqualTo(CornerSize(20))
- }
}
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/shape/corner/CutCornerShapeTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/shape/corner/CutCornerShapeTest.kt
index 2b92be5..a3a034d 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/shape/corner/CutCornerShapeTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/shape/corner/CutCornerShapeTest.kt
@@ -41,7 +41,7 @@
@Test
fun cutCornersUniformCorners() {
- val cut = CutCornerShape(10.px)
+ val cut = CutCornerShape(10.0f)
val outline = cut.toOutline() as Outline.Generic
assertPathsEquals(outline.path, Path().apply {
@@ -63,7 +63,7 @@
val size2 = 22f
val size3 = 32f
val size4 = 42f
- val cut = CutCornerShape(size1.px, size2.px, size3.px, size4.px)
+ val cut = CutCornerShape(size1, size2, size3, size4)
val outline = cut.toOutline() as Outline.Generic
assertPathsEquals(outline.path, Path().apply {
@@ -81,7 +81,7 @@
@Test
fun createsRectangleOutlineForZeroSizedCorners() {
- val rounded = CutCornerShape(0.px, 0.px, 0.px, 0.px)
+ val rounded = CutCornerShape(0.0f, 0.0f, 0.0f, 0.0f)
assertThat(rounded.toOutline())
.isEqualTo(Outline.Rectangle(size.toRect()))
@@ -89,25 +89,25 @@
@Test
fun cutCornerShapesAreEquals() {
- assertThat(CutCornerShape(10.px))
- .isEqualTo(CutCornerShape(10.px))
+ assertThat(CutCornerShape(10.0f))
+ .isEqualTo(CutCornerShape(10.0f))
}
@Test
fun cutCornerUpdateAllCornerSize() {
- assertThat(CutCornerShape(10.px).copy(CornerSize(5.px)))
- .isEqualTo(CutCornerShape(5.px))
+ assertThat(CutCornerShape(10.0f).copy(CornerSize(5.0f)))
+ .isEqualTo(CutCornerShape(5.0f))
}
@Test
fun cutCornerUpdateTwoCornerSizes() {
- assertThat(CutCornerShape(10.px).copy(
+ assertThat(CutCornerShape(10.0f).copy(
topRight = CornerSize(3.dp),
bottomLeft = CornerSize(50)
)).isEqualTo(CutCornerShape(
- topLeft = CornerSize(10.px),
+ topLeft = CornerSize(10.0f),
topRight = CornerSize(3.dp),
- bottomRight = CornerSize(10.px),
+ bottomRight = CornerSize(10.0f),
bottomLeft = CornerSize(50)
))
}
diff --git a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/shape/corner/RoundedCornerShapeTest.kt b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/shape/corner/RoundedCornerShapeTest.kt
index 559b8f5..5195ced 100644
--- a/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/shape/corner/RoundedCornerShapeTest.kt
+++ b/ui/ui-foundation/src/androidTest/java/androidx/ui/foundation/shape/corner/RoundedCornerShapeTest.kt
@@ -27,6 +27,7 @@
import androidx.ui.unit.px
import androidx.ui.unit.toRect
import com.google.common.truth.Truth.assertThat
+import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
@@ -57,7 +58,7 @@
val radius2 = 22f
val radius3 = 32f
val radius4 = 42f
- val rounded = RoundedCornerShape(radius1.px, radius2.px, radius3.px, radius4.px)
+ val rounded = RoundedCornerShape(radius1, radius2, radius3, radius4)
val outline = rounded.toOutline() as Outline.Rounded
assertThat(outline.rrect).isEqualTo(
@@ -73,7 +74,7 @@
@Test
fun createsRectangleOutlineForZeroSizedCorners() {
- val rounded = RoundedCornerShape(0.px, 0.px, 0.px, 0.px)
+ val rounded = RoundedCornerShape(0.0f, 0.0f, 0.0f, 0.0f)
assertThat(rounded.toOutline())
.isEqualTo(Outline.Rectangle(size.toRect()))
@@ -87,19 +88,28 @@
@Test
fun roundedCornerUpdateAllCornerSize() {
- assertThat(RoundedCornerShape(10.px).copy(CornerSize(5.dp)))
+ assertThat(RoundedCornerShape(10.0f).copy(CornerSize(5.dp)))
.isEqualTo(RoundedCornerShape(5.dp))
}
@Test
fun roundedCornerUpdateTwoCornerSizes() {
- assertThat(RoundedCornerShape(10.px).copy(
+ val original = RoundedCornerShape(10.0f).copy(
+ topLeft = CornerSize(3.dp),
+ bottomLeft = CornerSize(50)
+ )
+
+ assertEquals(CornerSize(3.dp), original.topLeft)
+ assertEquals(CornerSize(10.0f), original.topRight)
+ assertEquals(CornerSize(10.0f), original.bottomRight)
+ assertEquals(CornerSize(50), original.bottomLeft)
+ assertThat(RoundedCornerShape(10.0f).copy(
topLeft = CornerSize(3.dp),
bottomLeft = CornerSize(50)
)).isEqualTo(RoundedCornerShape(
topLeft = CornerSize(3.dp),
- topRight = CornerSize(10.px),
- bottomRight = CornerSize(10.px),
+ topRight = CornerSize(10.0f),
+ bottomRight = CornerSize(10.0f),
bottomLeft = CornerSize(50)
))
}