Change LayoutCoordinates to have size in IntPxSize.
Relnote: "LayoutCoordinates no longer has a position property. The
position property does not make sense when considering LayoutModifiers,
rotation, or scaling. Instead, developers should use parentCoordinates
and childToLocal() to calculate the transform from one
LayoutCoordinate to another.
LayoutCoordinates uses IntPxSize for the size property instead of
PxSize. Layouts use integer pixel sizes for layouts, so all layout sizes
should use integers and not floating point values."
Test: ran connectedCheck tests
Change-Id: I9367be21c2c202c8b6ad889b50a29454773f41af
diff --git a/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/core/OnPositionedBenchmark.kt b/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/core/OnPositionedBenchmark.kt
index 39b16f87..3f2a74f 100644
--- a/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/core/OnPositionedBenchmark.kt
+++ b/ui/integration-tests/benchmark/src/androidTest/java/androidx/ui/core/OnPositionedBenchmark.kt
@@ -71,7 +71,7 @@
StaticChildren(count - 1)
}
} else {
- OnPositioned { coordinates -> coordinates.position }
+ OnPositioned { coordinates -> coordinates.size }
}
}
diff --git a/ui/ui-core/api/0.1.0-dev04.txt b/ui/ui-core/api/0.1.0-dev04.txt
index 72cc4a4..4a367e9 100644
--- a/ui/ui-core/api/0.1.0-dev04.txt
+++ b/ui/ui-core/api/0.1.0-dev04.txt
@@ -140,16 +140,14 @@
public interface LayoutCoordinates {
method public androidx.ui.unit.PxPosition childToLocal(androidx.ui.core.LayoutCoordinates child, androidx.ui.unit.PxPosition childLocal);
method public androidx.ui.core.LayoutCoordinates? getParentCoordinates();
- method public androidx.ui.unit.PxPosition getPosition();
method public java.util.Map<androidx.ui.core.AlignmentLine,androidx.ui.unit.IntPx> getProvidedAlignmentLines();
- method public androidx.ui.unit.PxSize getSize();
+ method public androidx.ui.unit.IntPxSize getSize();
method public androidx.ui.unit.PxPosition globalToLocal(androidx.ui.unit.PxPosition global);
method public androidx.ui.unit.PxPosition localToGlobal(androidx.ui.unit.PxPosition local);
method public androidx.ui.unit.PxPosition localToRoot(androidx.ui.unit.PxPosition local);
property public abstract androidx.ui.core.LayoutCoordinates? parentCoordinates;
- property public abstract androidx.ui.unit.PxPosition position;
property public abstract java.util.Map<androidx.ui.core.AlignmentLine,androidx.ui.unit.IntPx> providedAlignmentLines;
- property public abstract androidx.ui.unit.PxSize size;
+ property public abstract androidx.ui.unit.IntPxSize size;
}
public final class LayoutCoordinatesKt {
diff --git a/ui/ui-core/api/current.txt b/ui/ui-core/api/current.txt
index 72cc4a4..4a367e9 100644
--- a/ui/ui-core/api/current.txt
+++ b/ui/ui-core/api/current.txt
@@ -140,16 +140,14 @@
public interface LayoutCoordinates {
method public androidx.ui.unit.PxPosition childToLocal(androidx.ui.core.LayoutCoordinates child, androidx.ui.unit.PxPosition childLocal);
method public androidx.ui.core.LayoutCoordinates? getParentCoordinates();
- method public androidx.ui.unit.PxPosition getPosition();
method public java.util.Map<androidx.ui.core.AlignmentLine,androidx.ui.unit.IntPx> getProvidedAlignmentLines();
- method public androidx.ui.unit.PxSize getSize();
+ method public androidx.ui.unit.IntPxSize getSize();
method public androidx.ui.unit.PxPosition globalToLocal(androidx.ui.unit.PxPosition global);
method public androidx.ui.unit.PxPosition localToGlobal(androidx.ui.unit.PxPosition local);
method public androidx.ui.unit.PxPosition localToRoot(androidx.ui.unit.PxPosition local);
property public abstract androidx.ui.core.LayoutCoordinates? parentCoordinates;
- property public abstract androidx.ui.unit.PxPosition position;
property public abstract java.util.Map<androidx.ui.core.AlignmentLine,androidx.ui.unit.IntPx> providedAlignmentLines;
- property public abstract androidx.ui.unit.PxSize size;
+ property public abstract androidx.ui.unit.IntPxSize size;
}
public final class LayoutCoordinatesKt {
diff --git a/ui/ui-core/api/public_plus_experimental_0.1.0-dev04.txt b/ui/ui-core/api/public_plus_experimental_0.1.0-dev04.txt
index 72cc4a4..4a367e9 100644
--- a/ui/ui-core/api/public_plus_experimental_0.1.0-dev04.txt
+++ b/ui/ui-core/api/public_plus_experimental_0.1.0-dev04.txt
@@ -140,16 +140,14 @@
public interface LayoutCoordinates {
method public androidx.ui.unit.PxPosition childToLocal(androidx.ui.core.LayoutCoordinates child, androidx.ui.unit.PxPosition childLocal);
method public androidx.ui.core.LayoutCoordinates? getParentCoordinates();
- method public androidx.ui.unit.PxPosition getPosition();
method public java.util.Map<androidx.ui.core.AlignmentLine,androidx.ui.unit.IntPx> getProvidedAlignmentLines();
- method public androidx.ui.unit.PxSize getSize();
+ method public androidx.ui.unit.IntPxSize getSize();
method public androidx.ui.unit.PxPosition globalToLocal(androidx.ui.unit.PxPosition global);
method public androidx.ui.unit.PxPosition localToGlobal(androidx.ui.unit.PxPosition local);
method public androidx.ui.unit.PxPosition localToRoot(androidx.ui.unit.PxPosition local);
property public abstract androidx.ui.core.LayoutCoordinates? parentCoordinates;
- property public abstract androidx.ui.unit.PxPosition position;
property public abstract java.util.Map<androidx.ui.core.AlignmentLine,androidx.ui.unit.IntPx> providedAlignmentLines;
- property public abstract androidx.ui.unit.PxSize size;
+ property public abstract androidx.ui.unit.IntPxSize size;
}
public final class LayoutCoordinatesKt {
diff --git a/ui/ui-core/api/public_plus_experimental_current.txt b/ui/ui-core/api/public_plus_experimental_current.txt
index 72cc4a4..4a367e9 100644
--- a/ui/ui-core/api/public_plus_experimental_current.txt
+++ b/ui/ui-core/api/public_plus_experimental_current.txt
@@ -140,16 +140,14 @@
public interface LayoutCoordinates {
method public androidx.ui.unit.PxPosition childToLocal(androidx.ui.core.LayoutCoordinates child, androidx.ui.unit.PxPosition childLocal);
method public androidx.ui.core.LayoutCoordinates? getParentCoordinates();
- method public androidx.ui.unit.PxPosition getPosition();
method public java.util.Map<androidx.ui.core.AlignmentLine,androidx.ui.unit.IntPx> getProvidedAlignmentLines();
- method public androidx.ui.unit.PxSize getSize();
+ method public androidx.ui.unit.IntPxSize getSize();
method public androidx.ui.unit.PxPosition globalToLocal(androidx.ui.unit.PxPosition global);
method public androidx.ui.unit.PxPosition localToGlobal(androidx.ui.unit.PxPosition local);
method public androidx.ui.unit.PxPosition localToRoot(androidx.ui.unit.PxPosition local);
property public abstract androidx.ui.core.LayoutCoordinates? parentCoordinates;
- property public abstract androidx.ui.unit.PxPosition position;
property public abstract java.util.Map<androidx.ui.core.AlignmentLine,androidx.ui.unit.IntPx> providedAlignmentLines;
- property public abstract androidx.ui.unit.PxSize size;
+ property public abstract androidx.ui.unit.IntPxSize size;
}
public final class LayoutCoordinatesKt {
diff --git a/ui/ui-core/api/restricted_0.1.0-dev04.txt b/ui/ui-core/api/restricted_0.1.0-dev04.txt
index 72cc4a4..4a367e9 100644
--- a/ui/ui-core/api/restricted_0.1.0-dev04.txt
+++ b/ui/ui-core/api/restricted_0.1.0-dev04.txt
@@ -140,16 +140,14 @@
public interface LayoutCoordinates {
method public androidx.ui.unit.PxPosition childToLocal(androidx.ui.core.LayoutCoordinates child, androidx.ui.unit.PxPosition childLocal);
method public androidx.ui.core.LayoutCoordinates? getParentCoordinates();
- method public androidx.ui.unit.PxPosition getPosition();
method public java.util.Map<androidx.ui.core.AlignmentLine,androidx.ui.unit.IntPx> getProvidedAlignmentLines();
- method public androidx.ui.unit.PxSize getSize();
+ method public androidx.ui.unit.IntPxSize getSize();
method public androidx.ui.unit.PxPosition globalToLocal(androidx.ui.unit.PxPosition global);
method public androidx.ui.unit.PxPosition localToGlobal(androidx.ui.unit.PxPosition local);
method public androidx.ui.unit.PxPosition localToRoot(androidx.ui.unit.PxPosition local);
property public abstract androidx.ui.core.LayoutCoordinates? parentCoordinates;
- property public abstract androidx.ui.unit.PxPosition position;
property public abstract java.util.Map<androidx.ui.core.AlignmentLine,androidx.ui.unit.IntPx> providedAlignmentLines;
- property public abstract androidx.ui.unit.PxSize size;
+ property public abstract androidx.ui.unit.IntPxSize size;
}
public final class LayoutCoordinatesKt {
diff --git a/ui/ui-core/api/restricted_current.txt b/ui/ui-core/api/restricted_current.txt
index 72cc4a4..4a367e9 100644
--- a/ui/ui-core/api/restricted_current.txt
+++ b/ui/ui-core/api/restricted_current.txt
@@ -140,16 +140,14 @@
public interface LayoutCoordinates {
method public androidx.ui.unit.PxPosition childToLocal(androidx.ui.core.LayoutCoordinates child, androidx.ui.unit.PxPosition childLocal);
method public androidx.ui.core.LayoutCoordinates? getParentCoordinates();
- method public androidx.ui.unit.PxPosition getPosition();
method public java.util.Map<androidx.ui.core.AlignmentLine,androidx.ui.unit.IntPx> getProvidedAlignmentLines();
- method public androidx.ui.unit.PxSize getSize();
+ method public androidx.ui.unit.IntPxSize getSize();
method public androidx.ui.unit.PxPosition globalToLocal(androidx.ui.unit.PxPosition global);
method public androidx.ui.unit.PxPosition localToGlobal(androidx.ui.unit.PxPosition local);
method public androidx.ui.unit.PxPosition localToRoot(androidx.ui.unit.PxPosition local);
property public abstract androidx.ui.core.LayoutCoordinates? parentCoordinates;
- property public abstract androidx.ui.unit.PxPosition position;
property public abstract java.util.Map<androidx.ui.core.AlignmentLine,androidx.ui.unit.IntPx> providedAlignmentLines;
- property public abstract androidx.ui.unit.PxSize size;
+ property public abstract androidx.ui.unit.IntPxSize size;
}
public final class LayoutCoordinatesKt {
diff --git a/ui/ui-core/src/main/java/androidx/ui/core/LayoutCoordinates.kt b/ui/ui-core/src/main/java/androidx/ui/core/LayoutCoordinates.kt
index 98bcff4..f9de2a6 100644
--- a/ui/ui-core/src/main/java/androidx/ui/core/LayoutCoordinates.kt
+++ b/ui/ui-core/src/main/java/androidx/ui/core/LayoutCoordinates.kt
@@ -17,25 +17,20 @@
package androidx.ui.core
import androidx.ui.unit.IntPx
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxBounds
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.PxSize
+import androidx.ui.unit.toPxSize
/**
* A holder of the measured bounds for the layout (MeasureBox).
*/
// TODO(Andrey): Add Matrix transformation here when we would have this logic.
interface LayoutCoordinates {
-
- /**
- * The position within the parent of this layout.
- */
- val position: PxPosition
-
/**
* The size of this layout in the local coordinates space.
*/
- val size: PxSize
+ val size: IntPxSize
/**
* The alignment lines provided for this layout, relative to the current layout.
@@ -79,6 +74,14 @@
*/
inline val LayoutCoordinates.positionInRoot: PxPosition get() = localToRoot(PxPosition.Origin)
-inline val LayoutCoordinates.boundsInRoot: PxBounds get() = PxBounds(positionInRoot, size)
+inline val LayoutCoordinates.boundsInRoot: PxBounds
+ get() = PxBounds(
+ positionInRoot,
+ size.toPxSize()
+ )
-inline val LayoutCoordinates.globalBounds: PxBounds get() = PxBounds(globalPosition, size)
+inline val LayoutCoordinates.globalBounds: PxBounds
+ get() = PxBounds(
+ globalPosition,
+ size.toPxSize()
+ )
diff --git a/ui/ui-framework/integration-tests/samples/src/main/java/androidx/ui/framework/samples/OnPositionedSample.kt b/ui/ui-framework/integration-tests/samples/src/main/java/androidx/ui/framework/samples/OnPositionedSample.kt
index 055994b..a556b5f 100644
--- a/ui/ui-framework/integration-tests/samples/src/main/java/androidx/ui/framework/samples/OnPositionedSample.kt
+++ b/ui/ui-framework/integration-tests/samples/src/main/java/androidx/ui/framework/samples/OnPositionedSample.kt
@@ -42,8 +42,6 @@
OnPositioned( coordinates ->
// This will be the size of the Column.
coordinates.size
- // This will be the position of Column inside its parent.
- coordinates.position
// The position of the Column relative to the application window.
coordinates.globalPosition
// The position of the Column relative to the Compose root.
@@ -64,8 +62,6 @@
OnChildPositioned( coordinates ->
// This will be the size of the child SizedRectangle.
coordinates.size
- // This will be the position of SizedRectangle inside its Column parent.
- coordinates.position
// The position of the SizedRectangle relative to the application window.
coordinates.globalPosition
// The position of the SizedRectangle relative to the Compose root.
diff --git a/ui/ui-framework/src/androidTest/java/androidx/ui/core/TextLayoutTest.kt b/ui/ui-framework/src/androidTest/java/androidx/ui/core/TextLayoutTest.kt
index ebc71df..1142acb 100644
--- a/ui/ui-framework/src/androidTest/java/androidx/ui/core/TextLayoutTest.kt
+++ b/ui/ui-framework/src/androidTest/java/androidx/ui/core/TextLayoutTest.kt
@@ -28,10 +28,9 @@
import androidx.ui.text.font.asFontFamily
import androidx.ui.unit.Density
import androidx.ui.unit.IntPx
-import androidx.ui.unit.PxSize
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.ipx
import androidx.ui.unit.px
-import androidx.ui.unit.round
import androidx.ui.unit.withDensity
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
@@ -66,8 +65,8 @@
@Test
fun testTextLayout() = withDensity(density) {
val layoutLatch = CountDownLatch(2)
- val textSize = Ref<PxSize>()
- val doubleTextSize = Ref<PxSize>()
+ val textSize = Ref<IntPxSize>()
+ val doubleTextSize = Ref<IntPxSize>()
show {
OnChildPositioned({ coordinates ->
textSize.value = coordinates.size
@@ -94,8 +93,8 @@
@Test
fun testTextLayout_intrinsicMeasurements() = withDensity(density) {
val layoutLatch = CountDownLatch(2)
- val textSize = Ref<PxSize>()
- val doubleTextSize = Ref<PxSize>()
+ val textSize = Ref<IntPxSize>()
+ val doubleTextSize = Ref<IntPxSize>()
show {
OnChildPositioned({ coordinates ->
textSize.value = coordinates.size
@@ -111,9 +110,9 @@
}
}
assertTrue(layoutLatch.await(1, TimeUnit.SECONDS))
- val textWidth = textSize.value!!.width.round()
- val textHeight = textSize.value!!.height.round()
- val doubleTextWidth = doubleTextSize.value!!.width.round()
+ val textWidth = textSize.value!!.width
+ val textHeight = textSize.value!!.height
+ val doubleTextWidth = doubleTextSize.value!!.width
val intrinsicsLatch = CountDownLatch(1)
show {
diff --git a/ui/ui-framework/src/androidTest/java/androidx/ui/core/test/WithConstraintsTest.kt b/ui/ui-framework/src/androidTest/java/androidx/ui/core/test/WithConstraintsTest.kt
index d5d106b..68bb364 100644
--- a/ui/ui-framework/src/androidTest/java/androidx/ui/core/test/WithConstraintsTest.kt
+++ b/ui/ui-framework/src/androidTest/java/androidx/ui/core/test/WithConstraintsTest.kt
@@ -37,7 +37,7 @@
import androidx.ui.graphics.Paint
import androidx.ui.graphics.vector.DrawVector
import androidx.ui.unit.IntPx
-import androidx.ui.unit.PxSize
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.ipx
import androidx.ui.unit.px
import androidx.ui.unit.toRect
@@ -299,8 +299,8 @@
val size = ValueModel(50.ipx)
var withConstLatch = CountDownLatch(1)
var childLatch = CountDownLatch(1)
- var withConstSize: PxSize? = null
- var childSize: PxSize? = null
+ var withConstSize: IntPxSize? = null
+ var childSize: IntPxSize? = null
rule.runOnUiThreadIR {
activity.setContentInFrameLayout {
@@ -330,7 +330,7 @@
}
assertTrue(withConstLatch.await(1, TimeUnit.SECONDS))
assertTrue(childLatch.await(1, TimeUnit.SECONDS))
- var expectedSize = PxSize(50.ipx, 50.ipx)
+ var expectedSize = IntPxSize(50.ipx, 50.ipx)
assertEquals(expectedSize, withConstSize)
assertEquals(expectedSize, childSize)
@@ -342,7 +342,7 @@
assertTrue(withConstLatch.await(1, TimeUnit.SECONDS))
assertTrue(childLatch.await(1, TimeUnit.SECONDS))
- expectedSize = PxSize(100.ipx, 100.ipx)
+ expectedSize = IntPxSize(100.ipx, 100.ipx)
assertEquals(expectedSize, withConstSize)
assertEquals(expectedSize, childSize)
}
diff --git a/ui/ui-framework/src/main/java/androidx/ui/core/Popup.kt b/ui/ui-framework/src/main/java/androidx/ui/core/Popup.kt
index b4d9e5b..858b1c5 100644
--- a/ui/ui-framework/src/main/java/androidx/ui/core/Popup.kt
+++ b/ui/ui-framework/src/main/java/androidx/ui/core/Popup.kt
@@ -33,15 +33,16 @@
import androidx.compose.ambientOf
import androidx.compose.disposeComposition
import androidx.compose.escapeCompose
-import androidx.compose.remember
import androidx.compose.onCommit
import androidx.compose.onDispose
+import androidx.compose.remember
import androidx.ui.unit.IntPx
import androidx.ui.unit.IntPxPosition
import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
import androidx.ui.unit.PxSize
import androidx.ui.unit.round
+import androidx.ui.unit.toPxSize
/**
* Opens a popup with the given content.
@@ -158,7 +159,7 @@
val layoutSize = coordinates.size
popupLayout.popupPositionProperties.parentPosition = layoutPosition
- popupLayout.popupPositionProperties.parentSize = layoutSize
+ popupLayout.popupPositionProperties.parentSize = layoutSize.toPxSize()
// Update the popup's position
popupLayout.updatePosition()
@@ -168,7 +169,7 @@
popupLayout.setContent {
OnChildPositioned({
// Get the size of the content
- popupLayout.popupPositionProperties.childrenSize = it.size
+ popupLayout.popupPositionProperties.childrenSize = it.size.toPxSize()
// Update the popup's position
popupLayout.updatePosition()
diff --git a/ui/ui-layout/build.gradle b/ui/ui-layout/build.gradle
index cd94775..93c12b0 100644
--- a/ui/ui-layout/build.gradle
+++ b/ui/ui-layout/build.gradle
@@ -46,6 +46,7 @@
testImplementation(JUNIT)
androidTestImplementation project(":ui:ui-platform")
+ androidTestImplementation project(":ui:ui-test")
androidTestImplementation(ANDROIDX_TEST_RULES)
androidTestImplementation(ANDROIDX_TEST_RUNNER)
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/AlignTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/AlignTest.kt
index 40558f3e..d40f291 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/AlignTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/AlignTest.kt
@@ -33,7 +33,6 @@
import androidx.ui.unit.IntPxPosition
import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.PxSize
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
import androidx.ui.unit.px
@@ -54,9 +53,9 @@
val size = sizeDp.toIntPx()
val positionedLatch = CountDownLatch(2)
- val alignSize = Ref<PxSize>()
+ val alignSize = Ref<IntPxSize>()
val alignPosition = Ref<PxPosition>()
- val childSize = Ref<PxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Align(alignment = Alignment.BottomRight) {
@@ -79,9 +78,9 @@
val root = findAndroidComposeView()
waitForDraw(root)
- assertEquals(PxSize(root.width.px, root.height.px), alignSize.value)
+ assertEquals(IntPxSize(root.width.ipx, root.height.ipx), alignSize.value)
assertEquals(PxPosition(0.px, 0.px), alignPosition.value)
- assertEquals(PxSize(size, size), childSize.value)
+ assertEquals(IntPxSize(size, size), childSize.value)
assertEquals(
PxPosition(root.width.px - size, root.height.px - size),
childPosition.value
@@ -94,9 +93,9 @@
val size = sizeDp.toIntPx()
val positionedLatch = CountDownLatch(2)
- val alignSize = Ref<PxSize>()
+ val alignSize = Ref<IntPxSize>()
val alignPosition = Ref<PxPosition>()
- val childSize = Ref<PxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Container {
@@ -119,9 +118,9 @@
val root = findAndroidComposeView()
waitForDraw(root)
- assertEquals(PxSize(root.width.px, root.height.px), alignSize.value)
+ assertEquals(IntPxSize(root.width.ipx, root.height.ipx), alignSize.value)
assertEquals(PxPosition(0.px, 0.px), alignPosition.value)
- assertEquals(PxSize(size, size), childSize.value)
+ assertEquals(IntPxSize(size, size), childSize.value)
assertEquals(
PxPosition(root.width.px - size, root.height.px - size),
childPosition.value
@@ -134,9 +133,9 @@
val size = sizeDp.toIntPx()
val positionedLatch = CountDownLatch(2)
- val alignSize = Ref<PxSize>()
+ val alignSize = Ref<IntPxSize>()
val alignPosition = Ref<PxPosition>()
- val childSize = Ref<PxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Container {
@@ -159,9 +158,9 @@
val root = findAndroidComposeView()
waitForDraw(root)
- assertEquals(PxSize(root.width.px, root.height.px), alignSize.value)
+ assertEquals(IntPxSize(root.width.ipx, root.height.ipx), alignSize.value)
assertEquals(PxPosition(0.px, 0.px), alignPosition.value)
- assertEquals(PxSize(size, root.height.ipx), childSize.value)
+ assertEquals(IntPxSize(size, root.height.ipx), childSize.value)
assertEquals(PxPosition(root.width.px - size, 0.px), childPosition.value)
}
@@ -171,9 +170,9 @@
val size = sizeDp.toIntPx()
val positionedLatch = CountDownLatch(2)
- val alignSize = Ref<PxSize>()
+ val alignSize = Ref<IntPxSize>()
val alignPosition = Ref<PxPosition>()
- val childSize = Ref<PxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Layout(
@@ -206,9 +205,9 @@
val root = findAndroidComposeView()
waitForDraw(root)
- assertEquals(PxSize(size, size), alignSize.value)
+ assertEquals(IntPxSize(size, size), alignSize.value)
assertEquals(PxPosition(0.px, 0.px), alignPosition.value)
- assertEquals(PxSize(size, size), childSize.value)
+ assertEquals(IntPxSize(size, size), childSize.value)
assertEquals(PxPosition(0.px, 0.px), childPosition.value)
}
@@ -220,9 +219,9 @@
val size = sizeDp.toIntPx()
val positionedLatch = CountDownLatch(2)
- val alignSize = Ref<PxSize>()
+ val alignSize = Ref<IntPxSize>()
val alignPosition = Ref<PxPosition>()
- val childSize = Ref<PxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Layout(
@@ -255,9 +254,9 @@
val root = findAndroidComposeView()
waitForDraw(root)
- assertEquals(PxSize(size, size), alignSize.value)
+ assertEquals(IntPxSize(size, size), alignSize.value)
assertEquals(PxPosition(0.px, 0.px), alignPosition.value)
- assertEquals(PxSize(size, size), childSize.value)
+ assertEquals(IntPxSize(size, size), childSize.value)
assertEquals(PxPosition(0.px, 0.px), childPosition.value)
}
@@ -397,9 +396,9 @@
val childSizeIpx = childSizeDp.toIntPx()
val positionedLatch = CountDownLatch(2)
- val alignSize = Ref<PxSize>()
+ val alignSize = Ref<IntPxSize>()
val alignPosition = Ref<PxPosition>()
- val childSize = Ref<PxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Layout(
@@ -433,7 +432,7 @@
val root = findAndroidComposeView()
waitForDraw(root)
- assertEquals(PxSize(childSizeIpx, childSizeIpx), childSize.value)
+ assertEquals(IntPxSize(childSizeIpx, childSizeIpx), childSize.value)
assertEquals(
PxPosition(
alignSize.value!!.width - childSizeIpx,
@@ -456,9 +455,9 @@
val childSizeIpx = childSizeDp.toIntPx()
val positionedLatch = CountDownLatch(2)
- val alignSize = Ref<PxSize>()
+ val alignSize = Ref<IntPxSize>()
val alignPosition = Ref<PxPosition>()
- val childSize = Ref<PxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Layout(
@@ -490,7 +489,7 @@
val root = findAndroidComposeView()
waitForDraw(root)
- assertEquals(PxSize(childSizeIpx, childSizeIpx), childSize.value)
+ assertEquals(IntPxSize(childSizeIpx, childSizeIpx), childSize.value)
assertEquals(
PxPosition(
alignSize.value!!.width - childSizeIpx,
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/AlignmentLineTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/AlignmentLineTest.kt
index 980e47c..925f10e 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/AlignmentLineTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/AlignmentLineTest.kt
@@ -23,18 +23,18 @@
import androidx.ui.core.Ref
import androidx.ui.core.VerticalAlignmentLine
import androidx.ui.core.WithConstraints
+import androidx.ui.layout.AlignmentLineOffset
+import androidx.ui.layout.CenterAlignmentLine
+import androidx.ui.layout.DpConstraints
+import androidx.ui.layout.Wrap
+import androidx.ui.unit.IntPxSize
+import androidx.ui.unit.PxPosition
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
import androidx.ui.unit.min
import androidx.ui.unit.px
import androidx.ui.unit.toPx
import androidx.ui.unit.withDensity
-import androidx.ui.layout.AlignmentLineOffset
-import androidx.ui.layout.CenterAlignmentLine
-import androidx.ui.layout.DpConstraints
-import androidx.ui.layout.Wrap
-import androidx.ui.unit.PxPosition
-import androidx.ui.unit.PxSize
import org.junit.Assert
import org.junit.Test
import org.junit.runner.RunWith
@@ -54,8 +54,8 @@
val childDp = 30.px.toDp()
val lineDp = 10.px.toDp()
- val parentSize = Ref<PxSize>()
- val childSize = Ref<PxSize>()
+ val parentSize = Ref<IntPxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Wrap {
@@ -71,7 +71,7 @@
Assert.assertNotNull(parentSize.value)
Assert.assertEquals(
- beforeDp.toIntPx().toPx() + afterDp.toIntPx().toPx(),
+ beforeDp.toIntPx() + afterDp.toIntPx(),
parentSize.value!!.width
)
Assert.assertNotNull(childSize.value)
@@ -93,8 +93,8 @@
val childDp = 30.px.toDp()
val lineDp = 10.px.toDp()
- val parentSize = Ref<PxSize>()
- val childSize = Ref<PxSize>()
+ val parentSize = Ref<IntPxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Wrap {
@@ -111,10 +111,7 @@
Assert.assertNotNull(childSize.value)
Assert.assertEquals(childSize.value!!.width, parentSize.value!!.width)
Assert.assertNotNull(parentSize.value)
- Assert.assertEquals(
- beforeDp.toIntPx().toPx() + afterDp.toIntPx().toPx(),
- parentSize.value!!.height
- )
+ Assert.assertEquals(beforeDp.toIntPx() + afterDp.toIntPx(), parentSize.value!!.height)
Assert.assertNotNull(childPosition.value)
Assert.assertEquals(0.px, childPosition.value!!.x)
Assert.assertEquals(
@@ -132,8 +129,8 @@
val childDp = 30.px.toDp()
val lineDp = 10.px.toDp()
- val parentSize = Ref<PxSize>()
- val childSize = Ref<PxSize>()
+ val parentSize = Ref<IntPxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Wrap {
@@ -164,8 +161,8 @@
val childDp = 30.px.toDp()
val lineDp = 10.px.toDp()
- val parentSize = Ref<PxSize>()
- val childSize = Ref<PxSize>()
+ val parentSize = Ref<IntPxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Wrap {
@@ -197,8 +194,8 @@
val childDp = 25.px.toDp()
val lineDp = 10.px.toDp()
- val parentSize = Ref<PxSize>()
- val childSize = Ref<PxSize>()
+ val parentSize = Ref<IntPxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Wrap {
@@ -219,7 +216,7 @@
Assert.assertTrue(layoutLatch.await(1, TimeUnit.SECONDS))
Assert.assertNotNull(parentSize.value)
- Assert.assertEquals(maxWidth.toIntPx().toPx(), parentSize.value!!.width)
+ Assert.assertEquals(maxWidth.toIntPx(), parentSize.value!!.width)
Assert.assertNotNull(childSize.value)
Assert.assertEquals(childSize.value!!.height, parentSize.value!!.height)
Assert.assertNotNull(childPosition.value)
@@ -237,8 +234,8 @@
val childDp = 25.px.toDp()
val lineDp = 10.px.toDp()
- val parentSize = Ref<PxSize>()
- val childSize = Ref<PxSize>()
+ val parentSize = Ref<IntPxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Wrap {
@@ -261,7 +258,7 @@
Assert.assertNotNull(childSize.value)
Assert.assertEquals(childSize.value!!.width, parentSize.value!!.width)
Assert.assertNotNull(parentSize.value)
- Assert.assertEquals(maxHeight.toIntPx().toPx(), parentSize.value!!.height)
+ Assert.assertEquals(maxHeight.toIntPx(), parentSize.value!!.height)
Assert.assertNotNull(childPosition.value)
Assert.assertEquals(0.px, childPosition.value!!.x)
Assert.assertEquals(5.px, childPosition.value!!.y)
@@ -355,7 +352,7 @@
val childHeight = 40.dp
val lineDp = 10.dp
- val centerSize = Ref<PxSize>()
+ val centerSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Layout({
@@ -380,10 +377,10 @@
Assert.assertNotNull(centerSize.value)
Assert.assertEquals(
- ((childWidth.toIntPx() - lineDp.toIntPx()) * 2).toPx(),
+ ((childWidth.toIntPx() - lineDp.toIntPx()) * 2),
centerSize.value!!.width
)
- Assert.assertEquals(childHeight.toIntPx().toPx(), centerSize.value!!.height)
+ Assert.assertEquals(childHeight.toIntPx(), centerSize.value!!.height)
Assert.assertNotNull(childPosition.value)
Assert.assertEquals(
(childWidth.toIntPx() - lineDp.toIntPx() * 2).toPx(), childPosition.value!!.x
@@ -399,7 +396,7 @@
val childHeight = 40.dp
val lineDp = 10.dp
- val centerSize = Ref<PxSize>()
+ val centerSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Layout({
@@ -423,9 +420,9 @@
Assert.assertTrue(layoutLatch.await(1, TimeUnit.SECONDS))
Assert.assertNotNull(centerSize.value)
- Assert.assertEquals(childWidth.toIntPx().toPx(), centerSize.value!!.width)
+ Assert.assertEquals(childWidth.toIntPx(), centerSize.value!!.width)
Assert.assertEquals(
- ((childHeight.toIntPx() - lineDp.toIntPx()) * 2).toPx(),
+ ((childHeight.toIntPx() - lineDp.toIntPx()) * 2),
centerSize.value!!.height
)
Assert.assertNotNull(childPosition.value)
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/AspectRatioModifierTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/AspectRatioModifierTest.kt
index 9472e05..fbeafa0 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/AspectRatioModifierTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/AspectRatioModifierTest.kt
@@ -24,12 +24,12 @@
import androidx.ui.layout.Container
import androidx.ui.layout.LayoutAspectRatio
import androidx.ui.unit.IntPx
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.PxSize
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
-import androidx.ui.unit.px
import androidx.ui.unit.withDensity
+import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
@@ -72,29 +72,29 @@
@Test
fun testAspectRatio_sizesCorrectly() {
- assertEquals(PxSize(30.px, 30.px), getSize(1f, Constraints(maxWidth = 30.ipx)))
- assertEquals(PxSize(30.px, 15.px), getSize(2f, Constraints(maxWidth = 30.ipx)))
+ assertEquals(IntPxSize(30.ipx, 30.ipx), getSize(1f, Constraints(maxWidth = 30.ipx)))
+ assertEquals(IntPxSize(30.ipx, 15.ipx), getSize(2f, Constraints(maxWidth = 30.ipx)))
assertEquals(
- PxSize(10.px, 10.px),
+ IntPxSize(10.ipx, 10.ipx),
getSize(1f, Constraints(maxWidth = 30.ipx, maxHeight = 10.ipx))
)
assertEquals(
- PxSize(20.px, 10.px),
+ IntPxSize(20.ipx, 10.ipx),
getSize(2f, Constraints(maxWidth = 30.ipx, maxHeight = 10.ipx))
)
assertEquals(
- PxSize(10.px, 5.px),
+ IntPxSize(10.ipx, 5.ipx),
getSize(2f, Constraints(minWidth = 10.ipx, minHeight = 5.ipx))
)
assertEquals(
- PxSize(20.px, 10.px),
+ IntPxSize(20.ipx, 10.ipx),
getSize(2f, Constraints(minWidth = 5.ipx, minHeight = 10.ipx))
)
}
- private fun getSize(aspectRatio: Float, childContraints: Constraints): PxSize {
+ private fun getSize(aspectRatio: Float, childContraints: Constraints): IntPxSize {
val positionedLatch = CountDownLatch(1)
- val size = Ref<PxSize>()
+ val size = Ref<IntPxSize>()
val position = Ref<PxPosition>()
show {
Layout(@Composable {
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/AspectRatioTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/AspectRatioTest.kt
index 03cffcdc..c967e8b 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/AspectRatioTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/AspectRatioTest.kt
@@ -31,12 +31,13 @@
import androidx.ui.layout.Container
import androidx.ui.layout.DpConstraints
import androidx.ui.unit.IntPx
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
import androidx.ui.unit.PxSize
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
import androidx.ui.unit.px
-import androidx.ui.unit.toPx
+import androidx.ui.unit.toPxSize
import androidx.ui.unit.withDensity
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
@@ -59,7 +60,7 @@
Align(alignment = Alignment.TopLeft) {
AspectRatio(1f) {
OnChildPositioned( coordinates ->
- containerSize.value = coordinates.size
+ containerSize.value = coordinates.size.toPxSize()
containerPosition.value = coordinates.localToGlobal(PxPosition(0.px, 0.px))
positionedLatch.countDown()
}) {
@@ -80,10 +81,10 @@
@Test
fun testAspectRatio_withNoChild() = withDensity(density) {
val sizeDp = 10.dp
- val sizePx = 10.dp.toIntPx().toPx()
+ val sizePx = 10.dp.toIntPx()
val positionedLatch = CountDownLatch(2)
- val size = arrayOf(Ref<PxSize>(), Ref<PxSize>())
+ val size = arrayOf(Ref<IntPxSize>(), Ref<IntPxSize>())
val position = arrayOf(Ref<PxPosition>(), Ref<PxPosition>())
show {
Align(alignment = Alignment.TopLeft) {
@@ -113,22 +114,22 @@
@Test
fun testAspectRatio_sizesCorrectly() = withDensity(density) {
- assertEquals(PxSize(30.px, 30.px), getSize(1f, Constraints(maxWidth = 30.ipx)))
- assertEquals(PxSize(30.px, 15.px), getSize(2f, Constraints(maxWidth = 30.ipx)))
+ assertEquals(IntPxSize(30.ipx, 30.ipx), getSize(1f, Constraints(maxWidth = 30.ipx)))
+ assertEquals(IntPxSize(30.ipx, 15.ipx), getSize(2f, Constraints(maxWidth = 30.ipx)))
assertEquals(
- PxSize(10.px, 10.px),
+ IntPxSize(10.ipx, 10.ipx),
getSize(1f, Constraints(maxWidth = 30.ipx, maxHeight = 10.ipx))
)
assertEquals(
- PxSize(20.px, 10.px),
+ IntPxSize(20.ipx, 10.ipx),
getSize(2f, Constraints(maxWidth = 30.ipx, maxHeight = 10.ipx))
)
assertEquals(
- PxSize(10.px, 5.px),
+ IntPxSize(10.ipx, 5.ipx),
getSize(2f, Constraints(minWidth = 10.ipx, minHeight = 5.ipx))
)
assertEquals(
- PxSize(20.px, 10.px),
+ IntPxSize(20.ipx, 10.ipx),
getSize(2f, Constraints(minWidth = 5.ipx, minHeight = 10.ipx))
)
}
@@ -152,9 +153,9 @@
}
}
- private fun getSize(aspectRatio: Float, aspectRatioConstraints: Constraints): PxSize {
+ private fun getSize(aspectRatio: Float, aspectRatioConstraints: Constraints): IntPxSize {
val positionedLatch = CountDownLatch(1)
- val size = Ref<PxSize>()
+ val size = Ref<IntPxSize>()
show {
Align(alignment = Alignment.TopLeft) {
val children = @Composable {
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/ContainerTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/ContainerTest.kt
index 335763d..4b8012a 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/ContainerTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/ContainerTest.kt
@@ -35,8 +35,8 @@
import androidx.ui.layout.Wrap
import androidx.ui.unit.Dp
import androidx.ui.unit.IntPx
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.PxSize
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
import androidx.ui.unit.px
@@ -60,7 +60,7 @@
val size = sizeDp.toIntPx()
val positionedLatch = CountDownLatch(1)
- val containerSize = Ref<PxSize>()
+ val containerSize = Ref<IntPxSize>()
show {
Align(alignment = Alignment.TopLeft) {
OnChildPositioned( coordinates ->
@@ -75,7 +75,7 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(size, size), containerSize.value)
+ assertEquals(IntPxSize(size, size), containerSize.value)
}
@Test
@@ -86,7 +86,7 @@
val size = sizeDp.toIntPx()
val positionedLatch = CountDownLatch(2)
- val containerSize = Ref<PxSize>()
+ val containerSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Align(alignment = Alignment.TopLeft) {
@@ -109,7 +109,7 @@
val totalPadding = paddingDp.toIntPx() * 2
assertEquals(
- PxSize(size + totalPadding, size + totalPadding),
+ IntPxSize(size + totalPadding, size + totalPadding),
containerSize.value
)
assertEquals(PxPosition(padding, padding), childPosition.value)
@@ -125,8 +125,8 @@
val childConstraints = DpConstraints.fixed(childWidthDp, childHeightDp)
val positionedLatch = CountDownLatch(4)
- val containerSize = Ref<PxSize>()
- val childSize = Array(3) { PxSize(0.px, 0.px) }
+ val containerSize = Ref<IntPxSize>()
+ val childSize = Array(3) { IntPxSize(0.ipx, 0.ipx) }
show {
Align(alignment = Alignment.TopLeft) {
OnChildPositioned( coordinates ->
@@ -169,10 +169,10 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(childWidth, childHeight), childSize[0])
- assertEquals(PxSize(childWidth, childHeight), childSize[1])
+ assertEquals(IntPxSize(childWidth, childHeight), childSize[0])
+ assertEquals(IntPxSize(childWidth, childHeight), childSize[1])
assertEquals(
- PxSize((childWidthDp * 2).toIntPx(), (childHeightDp * 2).toIntPx()),
+ IntPxSize((childWidthDp * 2).toIntPx(), (childHeightDp * 2).toIntPx()),
childSize[2]
)
}
@@ -183,9 +183,9 @@
val size = sizeDp.toIntPx()
val positionedLatch = CountDownLatch(3)
- val alignSize = Ref<PxSize>()
- val containerSize = Ref<PxSize>()
- val childSize = Ref<PxSize>()
+ val alignSize = Ref<IntPxSize>()
+ val containerSize = Ref<IntPxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Align(alignment = Alignment.TopLeft) {
@@ -212,11 +212,11 @@
positionedLatch.await(1, TimeUnit.SECONDS)
assertEquals(alignSize.value, containerSize.value)
- assertEquals(PxSize(size, size), childSize.value)
+ assertEquals(IntPxSize(size, size), childSize.value)
assertEquals(
PxPosition(
- (containerSize.value!!.width / 2 - size.toPx() / 2).round(),
- (containerSize.value!!.height / 2 - size.toPx() / 2).round()
+ (containerSize.value!!.width.toPx() / 2 - size.toPx() / 2).round(),
+ (containerSize.value!!.height.toPx() / 2 - size.toPx() / 2).round()
),
childPosition.value
)
@@ -231,8 +231,8 @@
val sizeDp = size.toDp()
val positionedLatch = CountDownLatch(2)
- val containerSize = Ref<PxSize>()
- val childSize = Ref<PxSize>()
+ val containerSize = Ref<IntPxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Align(alignment = Alignment.TopLeft) {
@@ -259,10 +259,10 @@
positionedLatch.await(1, TimeUnit.SECONDS)
assertEquals(
- PxSize((sizeDp * 2).toIntPx(), (sizeDp * 2).toIntPx()),
+ IntPxSize((sizeDp * 2).toIntPx(), (sizeDp * 2).toIntPx()),
containerSize.value
)
- assertEquals(PxSize(size, size), childSize.value)
+ assertEquals(IntPxSize(size, size), childSize.value)
assertEquals(PxPosition(size, size), childPosition.value)
}
@@ -271,7 +271,7 @@
val sizeDp = 50.dp
val size = sizeDp.toIntPx()
- val containerSize = Ref<PxSize>()
+ val containerSize = Ref<IntPxSize>()
val latch = CountDownLatch(1)
show {
Align(alignment = Alignment.TopLeft) {
@@ -285,7 +285,7 @@
}
assertTrue(latch.await(1, TimeUnit.SECONDS))
- assertEquals(PxSize(size, size), containerSize.value)
+ assertEquals(IntPxSize(size, size), containerSize.value)
}
@Test
@@ -299,12 +299,12 @@
left = paddingLeft, top = paddingTop,
right = paddingRight, bottom = paddingBottom
)
- val expectedSize = PxSize(
+ val expectedSize = IntPxSize(
childSizeDp.toIntPx() + paddingLeft.toIntPx() + paddingRight.toIntPx(),
childSizeDp.toIntPx() + paddingTop.toIntPx() + paddingBottom.toIntPx()
)
- var containerSize: PxSize? = null
+ var containerSize: IntPxSize? = null
val latch = CountDownLatch(1)
show {
Wrap {
@@ -347,8 +347,11 @@
val centeringOffset = padding.toIntPx() +
(containerSize.toIntPx() - padding.toIntPx() * 2 - childSize.toIntPx()) / 2
- assertEquals(PxPosition(centeringOffset, centeringOffset), childCoordinates!!.position)
- assertEquals(PxSize(childSize.toIntPx(), childSize.toIntPx()), childCoordinates!!.size)
+ val lockedChildCoord = childCoordinates!!
+ val childPosition = lockedChildCoord.parentCoordinates!!
+ .childToLocal(lockedChildCoord, PxPosition.Origin)
+ assertEquals(PxPosition(centeringOffset, centeringOffset), childPosition)
+ assertEquals(IntPxSize(childSize.toIntPx(), childSize.toIntPx()), lockedChildCoord.size)
}
@Test
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/ExpandedModifierTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/ExpandedModifierTest.kt
index d2bdbc4..69be468 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/ExpandedModifierTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/ExpandedModifierTest.kt
@@ -23,7 +23,6 @@
import androidx.ui.core.Layout
import androidx.ui.core.Modifier
import androidx.ui.core.Ref
-import androidx.ui.geometry.Rect
import androidx.ui.layout.Align
import androidx.ui.layout.Container
import androidx.ui.layout.LayoutAspectRatio
@@ -31,12 +30,11 @@
import androidx.ui.layout.LayoutSize
import androidx.ui.layout.LayoutWidth
import androidx.ui.unit.IntPx
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.PxSize
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
import androidx.ui.unit.min
-import androidx.ui.unit.toRect
import androidx.ui.unit.withDensity
import org.junit.Assert
import org.junit.Test
@@ -54,24 +52,24 @@
@Test
fun testExpandedModifier_correctSize() = withDensity(density) {
val displayMetrics = Resources.getSystem().displayMetrics
- val screenWidth = displayMetrics.widthPixels.toFloat()
- val screenHeight = displayMetrics.heightPixels.toFloat()
+ val screenWidth = displayMetrics.widthPixels
+ val screenHeight = displayMetrics.heightPixels
Assert.assertEquals(
- Rect(0f, 0f, Width.toIntPx().value.toFloat(), Height.toIntPx().value.toFloat()),
- getSize().toRect()
+ IntPxSize(Width.toIntPx(), Height.toIntPx()),
+ getSize()
)
Assert.assertEquals(
- Rect(0f, 0f, screenWidth, Height.toIntPx().value.toFloat()),
- getSize(LayoutWidth.Fill).toRect()
+ IntPxSize(screenWidth.ipx, Height.toIntPx()),
+ getSize(LayoutWidth.Fill)
)
Assert.assertEquals(
- Rect(0f, 0f, Width.toIntPx().value.toFloat(), screenHeight),
- getSize(LayoutHeight.Fill).toRect()
+ IntPxSize(Width.toIntPx(), screenHeight.ipx),
+ getSize(LayoutHeight.Fill)
)
Assert.assertEquals(
- Rect(0f, 0f, screenWidth, screenHeight),
- getSize(LayoutSize.Fill).toRect()
+ IntPxSize(screenWidth.ipx, screenHeight.ipx),
+ getSize(LayoutSize.Fill)
)
}
@@ -82,9 +80,9 @@
verifyIntrinsicMeasurements(LayoutSize.Fill)
}
- private fun getSize(modifier: Modifier = Modifier.None): PxSize {
+ private fun getSize(modifier: Modifier = Modifier.None): IntPxSize {
val positionedLatch = CountDownLatch(1)
- val size = Ref<PxSize>()
+ val size = Ref<IntPxSize>()
val position = Ref<PxPosition>()
show {
Layout(@Composable {
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/FlexTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/FlexTest.kt
index 5ac8eb4..25baab4 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/FlexTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/FlexTest.kt
@@ -49,9 +49,8 @@
import androidx.ui.layout.Wrap
import androidx.ui.unit.Dp
import androidx.ui.unit.IntPx
-import androidx.ui.unit.Px
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.PxSize
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
import androidx.ui.unit.max
@@ -60,7 +59,7 @@
import androidx.ui.unit.round
import androidx.ui.unit.toPx
import androidx.ui.unit.withDensity
-import org.junit.Assert
+import org.junit.Assert.assertEquals
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertTrue
import org.junit.Ignore
@@ -80,7 +79,7 @@
val size = sizeDp.toIntPx()
val drawLatch = CountDownLatch(2)
- val childSize = arrayOf(PxSize(-1.px, -1.px), PxSize(-1.px, -1.px))
+ val childSize = arrayOf(IntPxSize(-1.ipx, -1.ipx), IntPxSize(-1.ipx, -1.ipx))
val childPosition = arrayOf(PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px))
show {
Container(alignment = Alignment.TopLeft) {
@@ -108,9 +107,9 @@
val root = findAndroidComposeView()
waitForDraw(root)
- assertEquals(PxSize(size, size), childSize[0])
+ assertEquals(IntPxSize(size, size), childSize[0])
assertEquals(
- PxSize((sizeDp.toPx() * 2).round(), (sizeDp.toPx() * 2).round()),
+ IntPxSize((sizeDp.toPx() * 2).round(), (sizeDp.toPx() * 2).round()),
childSize[1]
)
assertEquals(PxPosition(0.px, 0.px), childPosition[0])
@@ -124,7 +123,7 @@
val childrenHeight = height.toIntPx()
val drawLatch = CountDownLatch(2)
- val childSize = arrayOfNulls<PxSize>(2)
+ val childSize = arrayOfNulls<IntPxSize>(2)
val childPosition = arrayOfNulls<PxPosition>(2)
show {
Container(alignment = Alignment.TopLeft) {
@@ -154,11 +153,11 @@
val rootWidth = root.width.px
assertEquals(
- PxSize((rootWidth / 3).round().toPx(), childrenHeight.toPx()),
+ IntPxSize((rootWidth / 3).round(), childrenHeight),
childSize[0]
)
assertEquals(
- PxSize((rootWidth * 2 / 3).round().toPx(), childrenHeight.toPx()),
+ IntPxSize((rootWidth * 2 / 3).round(), childrenHeight),
childSize[1]
)
assertEquals(PxPosition(0.px, 0.px), childPosition[0])
@@ -173,7 +172,7 @@
val childrenHeight = height.toIntPx()
val drawLatch = CountDownLatch(2)
- val childSize = arrayOfNulls<PxSize>(2)
+ val childSize = arrayOfNulls<IntPxSize>(2)
val childPosition = arrayOfNulls<PxPosition>(2)
show {
Container(alignment = Alignment.TopLeft) {
@@ -209,10 +208,8 @@
val root = findAndroidComposeView()
waitForDraw(root)
- assertEquals(PxSize(childrenWidth.toPx(), childrenHeight.toPx()), childSize[0])
- assertEquals(
- PxSize(childrenWidth.toPx(), (childrenHeight.toPx() * 2).round().toPx()), childSize[1]
- )
+ assertEquals(IntPxSize(childrenWidth, childrenHeight), childSize[0])
+ assertEquals(IntPxSize(childrenWidth, childrenHeight * 2), childSize[1])
assertEquals(PxPosition(0.px, 0.px), childPosition[0])
assertEquals(PxPosition(childrenWidth.toPx(), 0.px), childPosition[1])
}
@@ -223,7 +220,7 @@
val size = sizeDp.toIntPx()
val drawLatch = CountDownLatch(2)
- val childSize = arrayOf(PxSize(-1.px, -1.px), PxSize(-1.px, -1.px))
+ val childSize = arrayOf(IntPxSize(-1.ipx, -1.ipx), IntPxSize(-1.ipx, -1.ipx))
val childPosition = arrayOf(PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px))
show {
Container(alignment = Alignment.TopLeft) {
@@ -250,9 +247,9 @@
val root = findAndroidComposeView()
waitForDraw(root)
- assertEquals(PxSize(size, size), childSize[0])
+ assertEquals(IntPxSize(size, size), childSize[0])
assertEquals(
- PxSize((sizeDp.toPx() * 2).round(), (sizeDp.toPx() * 2).round()),
+ IntPxSize((sizeDp.toPx() * 2).round(), (sizeDp.toPx() * 2).round()),
childSize[1]
)
assertEquals(PxPosition(0.px, 0.px), childPosition[0])
@@ -266,7 +263,7 @@
val height = 50.dp
val drawLatch = CountDownLatch(2)
- val childSize = arrayOfNulls<PxSize>(2)
+ val childSize = arrayOfNulls<IntPxSize>(2)
val childPosition = arrayOfNulls<PxPosition>(2)
show {
Container(alignment = Alignment.TopLeft) {
@@ -296,10 +293,10 @@
val rootHeight = root.height.px
assertEquals(
- PxSize(childrenWidth.toPx(), (rootHeight / 3).round().toPx()), childSize[0]
+ IntPxSize(childrenWidth, (rootHeight / 3).round()), childSize[0]
)
assertEquals(
- PxSize(childrenWidth.toPx(), (rootHeight * 2 / 3).round().toPx()), childSize[1]
+ IntPxSize(childrenWidth, (rootHeight * 2 / 3).round()), childSize[1]
)
assertEquals(PxPosition(0.px, 0.px), childPosition[0])
assertEquals(PxPosition(0.px, (rootHeight / 3).round().toPx()), childPosition[1])
@@ -313,7 +310,7 @@
val childrenHeight = height.toIntPx()
val drawLatch = CountDownLatch(2)
- val childSize = arrayOfNulls<PxSize>(2)
+ val childSize = arrayOfNulls<IntPxSize>(2)
val childPosition = arrayOfNulls<PxPosition>(2)
show {
Container(alignment = Alignment.TopLeft) {
@@ -340,9 +337,9 @@
val root = findAndroidComposeView()
waitForDraw(root)
- assertEquals(PxSize(childrenWidth.toPx(), childrenHeight.toPx()), childSize[0])
+ assertEquals(IntPxSize(childrenWidth, childrenHeight), childSize[0])
assertEquals(
- PxSize(childrenWidth.toPx(), childrenHeight.toPx()), childSize[1]
+ IntPxSize(childrenWidth, childrenHeight), childSize[1]
)
assertEquals(PxPosition(0.px, 0.px), childPosition[0])
assertEquals(PxPosition(0.px, childrenHeight.toPx()), childPosition[1])
@@ -350,10 +347,10 @@
@Test
fun testRow_doesNotPlaceChildrenOutOfBounds_becauseOfRoundings() = withDensity(density) {
- val expectedRowWidth = 11.px
+ val expectedRowWidth = 11.ipx
val leftPadding = 1.px
- var rowWidth = 0.px
- val width = Array(2) { 0.px }
+ var rowWidth = 0.ipx
+ val width = Array(2) { 0.ipx }
val x = Array(2) { 0.px }
val latch = CountDownLatch(2)
show {
@@ -381,18 +378,18 @@
assertTrue(latch.await(1, TimeUnit.SECONDS))
- Assert.assertEquals(expectedRowWidth, rowWidth)
- Assert.assertEquals(leftPadding, x[0])
- Assert.assertEquals(leftPadding + width[0], x[1])
- Assert.assertEquals(rowWidth, width[0] + width[1])
+ assertEquals(expectedRowWidth, rowWidth)
+ assertEquals(leftPadding, x[0])
+ assertEquals(leftPadding + width[0], x[1])
+ assertEquals(rowWidth, width[0] + width[1])
}
@Test
fun testRow_isNotLargerThanItsChildren_becauseOfRoundings() = withDensity(density) {
- val expectedRowWidth = 8.px
+ val expectedRowWidth = 8.ipx
val leftPadding = 1.px
- var rowWidth = 0.px
- val width = Array(3) { 0.px }
+ var rowWidth = 0.ipx
+ val width = Array(3) { 0.ipx }
val x = Array(3) { 0.px }
val latch = CountDownLatch(3)
show {
@@ -427,19 +424,19 @@
assertTrue(latch.await(1, TimeUnit.SECONDS))
- Assert.assertEquals(expectedRowWidth, rowWidth)
- Assert.assertEquals(leftPadding, x[0])
- Assert.assertEquals(leftPadding + width[0], x[1])
- Assert.assertEquals(leftPadding + width[0] + width[1], x[2])
- Assert.assertEquals(rowWidth, width[0] + width[1] + width[2])
+ assertEquals(expectedRowWidth, rowWidth)
+ assertEquals(leftPadding, x[0])
+ assertEquals(leftPadding + width[0], x[1])
+ assertEquals(leftPadding + width[0] + width[1], x[2])
+ assertEquals(rowWidth, width[0] + width[1] + width[2])
}
@Test
fun testColumn_isNotLargetThanItsChildren_becauseOfRoundings() = withDensity(density) {
- val expectedColumnHeight = 8.px
+ val expectedColumnHeight = 8.ipx
val topPadding = 1.px
- var columnHeight = 0.px
- val height = Array(3) { 0.px }
+ var columnHeight = 0.ipx
+ val height = Array(3) { 0.ipx }
val y = Array(3) { 0.px }
val latch = CountDownLatch(3)
show {
@@ -474,19 +471,19 @@
assertTrue(latch.await(1, TimeUnit.SECONDS))
- Assert.assertEquals(expectedColumnHeight, columnHeight)
- Assert.assertEquals(topPadding, y[0])
- Assert.assertEquals(topPadding + height[0], y[1])
- Assert.assertEquals(topPadding + height[0] + height[1], y[2])
- Assert.assertEquals(columnHeight, height[0] + height[1] + height[2])
+ assertEquals(expectedColumnHeight, columnHeight)
+ assertEquals(topPadding, y[0])
+ assertEquals(topPadding + height[0], y[1])
+ assertEquals(topPadding + height[0] + height[1], y[2])
+ assertEquals(columnHeight, height[0] + height[1] + height[2])
}
@Test
fun testColumn_doesNotPlaceChildrenOutOfBounds_becauseOfRoundings() = withDensity(density) {
- val expectedColumnHeight = 11.px
+ val expectedColumnHeight = 11.ipx
val topPadding = 1.px
- var columnHeight = 0.px
- val height = Array(2) { 0.px }
+ var columnHeight = 0.ipx
+ val height = Array(2) { 0.ipx }
val y = Array(2) { 0.px }
val latch = CountDownLatch(2)
show {
@@ -514,10 +511,10 @@
assertTrue(latch.await(1, TimeUnit.SECONDS))
- Assert.assertEquals(expectedColumnHeight, columnHeight)
- Assert.assertEquals(topPadding, y[0])
- Assert.assertEquals(topPadding + height[0], y[1])
- Assert.assertEquals(columnHeight, height[0] + height[1])
+ assertEquals(expectedColumnHeight, columnHeight)
+ assertEquals(topPadding, y[0])
+ assertEquals(topPadding + height[0], y[1])
+ assertEquals(columnHeight, height[0] + height[1])
}
// endregion
@@ -529,7 +526,7 @@
val size = sizeDp.toIntPx()
val drawLatch = CountDownLatch(2)
- val childSize = arrayOf(PxSize(-1.px, -1.px), PxSize(-1.px, -1.px))
+ val childSize = arrayOf(IntPxSize(-1.ipx, -1.ipx), IntPxSize(-1.ipx, -1.ipx))
val childPosition = arrayOf(PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px))
show {
Align(Alignment.CenterLeft) {
@@ -561,9 +558,9 @@
val root = findAndroidComposeView()
waitForDraw(root)
- assertEquals(PxSize(size.toPx(), root.height.px), childSize[0])
+ assertEquals(IntPxSize(size, root.height.ipx), childSize[0])
assertEquals(
- PxSize((sizeDp.toPx() * 2).round().toPx(), root.height.px),
+ IntPxSize((sizeDp.toPx() * 2).round(), root.height.ipx),
childSize[1]
)
assertEquals(PxPosition(0.px, 0.px), childPosition[0])
@@ -576,7 +573,7 @@
val size = sizeDp.toIntPx()
val drawLatch = CountDownLatch(3)
- val childSize = arrayOfNulls<PxSize>(3)
+ val childSize = arrayOfNulls<IntPxSize>(3)
val childPosition = arrayOfNulls<PxPosition>(3)
show {
Align(Alignment.TopLeft) {
@@ -611,16 +608,16 @@
waitForDraw(root)
val rootHeight = root.height.px
- assertEquals(PxSize(size.toPx(), size.toPx()), childSize[0])
+ assertEquals(IntPxSize(size, size), childSize[0])
assertEquals(PxPosition(0.px, 0.px), childPosition[0])
- assertEquals(PxSize(size.toPx(), size.toPx()), childSize[1])
+ assertEquals(IntPxSize(size, size), childSize[1])
assertEquals(
PxPosition(size.toPx(), ((rootHeight - size.toPx()) / 2).round().toPx()),
childPosition[1]
)
- assertEquals(PxSize(size.toPx(), size.toPx()), childSize[2])
+ assertEquals(IntPxSize(size, size), childSize[2])
assertEquals(PxPosition(size.toPx() * 2, rootHeight - size.toPx()), childPosition[2])
}
@@ -634,7 +631,7 @@
val size = sizeDp.toIntPx()
val drawLatch = CountDownLatch(4)
- val childSize = arrayOfNulls<PxSize>(4)
+ val childSize = arrayOfNulls<IntPxSize>(4)
val childPosition = arrayOfNulls<PxPosition>(4)
show {
Align(Alignment.TopLeft) {
@@ -690,22 +687,22 @@
}
drawLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(size.toPx(), size.toPx()), childSize[0])
+ assertEquals(IntPxSize(size, size), childSize[0])
assertEquals(PxPosition(0.px, 0.px), childPosition[0])
- assertEquals(PxSize(size.toPx(), size.toPx()), childSize[1])
+ assertEquals(IntPxSize(size, size), childSize[1])
assertEquals(
PxPosition(size.toPx(), (baseline1 - (size.toPx() / 2).round()).toPx()),
childPosition[1]
)
- assertEquals(PxSize(size.toPx(), size.toPx()), childSize[2])
+ assertEquals(IntPxSize(size, size), childSize[2])
assertEquals(
PxPosition(size.toPx() * 2, (baseline1 - baseline2).toPx()),
childPosition[2]
)
- assertEquals(PxSize(size.toPx(), size.toPx()), childSize[3])
+ assertEquals(IntPxSize(size, size), childSize[3])
assertEquals(
PxPosition(size.toPx() * 3, 0.px),
childPosition[3]
@@ -720,7 +717,7 @@
val size = sizeDp.toIntPx()
val drawLatch = CountDownLatch(2)
- val childSize = arrayOf(PxSize(-1.px, -1.px), PxSize(-1.px, -1.px))
+ val childSize = arrayOf(IntPxSize(-1.ipx, -1.ipx), IntPxSize(-1.ipx, -1.ipx))
val childPosition = arrayOf(PxPosition(-1.px, -1.px), PxPosition(-1.px, -1.px))
show {
Align(Alignment.TopCenter) {
@@ -750,9 +747,9 @@
val root = findAndroidComposeView()
waitForDraw(root)
- assertEquals(PxSize(root.width.px, size.toPx()), childSize[0])
+ assertEquals(IntPxSize(root.width.ipx, size), childSize[0])
assertEquals(
- PxSize(root.width.px, (sizeDp.toPx() * 2).round().toPx()),
+ IntPxSize(root.width.ipx, (sizeDp * 2).toIntPx()),
childSize[1]
)
assertEquals(PxPosition(0.px, 0.px), childPosition[0])
@@ -765,7 +762,7 @@
val size = sizeDp.toIntPx()
val drawLatch = CountDownLatch(3)
- val childSize = arrayOfNulls<PxSize>(3)
+ val childSize = arrayOfNulls<IntPxSize>(3)
val childPosition = arrayOfNulls<PxPosition>(3)
show {
Align(Alignment.TopCenter) {
@@ -800,16 +797,16 @@
waitForDraw(root)
val rootWidth = root.width.px
- assertEquals(PxSize(size.toPx(), size.toPx()), childSize[0])
+ assertEquals(IntPxSize(size, size), childSize[0])
assertEquals(PxPosition(0.px, 0.px), childPosition[0])
- assertEquals(PxSize(size.toPx(), size.toPx()), childSize[1])
+ assertEquals(IntPxSize(size, size), childSize[1])
assertEquals(
PxPosition(((rootWidth - size.toPx()) / 2).round().toPx(), size.toPx()),
childPosition[1]
)
- assertEquals(PxSize(size.toPx(), size.toPx()), childSize[2])
+ assertEquals(IntPxSize(size, size), childSize[2])
assertEquals(PxPosition(rootWidth - size.toPx(), size.toPx() * 2), childPosition[2])
}
@@ -821,7 +818,7 @@
val firstBaseline2Dp = 30.dp
val drawLatch = CountDownLatch(4)
- val childSize = arrayOfNulls<PxSize>(4)
+ val childSize = arrayOfNulls<IntPxSize>(4)
val childPosition = arrayOfNulls<PxPosition>(4)
show {
Align(Alignment.TopLeft) {
@@ -877,19 +874,19 @@
}
drawLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(size.toPx(), size.toPx()), childSize[0])
+ assertEquals(IntPxSize(size, size), childSize[0])
assertEquals(PxPosition(0.px, 0.px), childPosition[0])
- assertEquals(PxSize(size.toPx(), size.toPx()), childSize[1])
+ assertEquals(IntPxSize(size, size), childSize[1])
assertEquals(PxPosition(size.toPx(), size.toPx()), childPosition[1])
- assertEquals(PxSize(size.toPx(), size.toPx()), childSize[2])
+ assertEquals(IntPxSize(size, size), childSize[2])
assertEquals(
PxPosition((size - firstBaseline1Dp.toIntPx()).toPx(), size.toPx() * 2),
childPosition[2]
)
- assertEquals(PxSize(size.toPx(), size.toPx()), childSize[3])
+ assertEquals(IntPxSize(size, size), childSize[3])
assertEquals(
PxPosition((size - firstBaseline2Dp.toIntPx()).toPx(), size.toPx() * 3),
childPosition[3]
@@ -903,7 +900,7 @@
val sizeDp = 50.dp
val drawLatch = CountDownLatch(1)
- lateinit var rowSize: PxSize
+ lateinit var rowSize: IntPxSize
show {
Center {
Row(LayoutWidth.Fill) {
@@ -924,7 +921,7 @@
assertEquals(
root.width.ipx,
- rowSize.width.round()
+ rowSize.width
)
}
@@ -933,7 +930,7 @@
val sizeDp = 50.dp
val drawLatch = CountDownLatch(1)
- lateinit var rowSize: PxSize
+ lateinit var rowSize: IntPxSize
show {
Center {
Row {
@@ -954,7 +951,7 @@
assertEquals(
(sizeDp * 3).toIntPx(),
- rowSize.width.round()
+ rowSize.width
)
}
@@ -963,7 +960,7 @@
val sizeDp = 50.dp
val drawLatch = CountDownLatch(1)
- lateinit var rowSize: PxSize
+ lateinit var rowSize: IntPxSize
show {
Center {
Row {
@@ -984,7 +981,7 @@
assertEquals(
root.width.ipx,
- rowSize.width.round()
+ rowSize.width
)
}
@@ -993,7 +990,7 @@
val sizeDp = 50.dp
val drawLatch = CountDownLatch(1)
- lateinit var rowSize: PxSize
+ lateinit var rowSize: IntPxSize
show {
Center {
Row(LayoutHeight.Fill) {
@@ -1014,7 +1011,7 @@
assertEquals(
root.height.ipx,
- rowSize.height.round()
+ rowSize.height
)
}
@@ -1023,7 +1020,7 @@
val sizeDp = 50.dp
val drawLatch = CountDownLatch(1)
- lateinit var rowSize: PxSize
+ lateinit var rowSize: IntPxSize
show {
Center {
Row {
@@ -1044,7 +1041,7 @@
assertEquals(
(sizeDp * 2).toIntPx(),
- rowSize.height.round()
+ rowSize.height
)
}
@@ -1054,7 +1051,7 @@
val rowWidthDp = 250.dp
val drawLatch = CountDownLatch(1)
- lateinit var rowSize: PxSize
+ lateinit var rowSize: IntPxSize
show {
Center {
ConstrainedBox(constraints = DpConstraints(maxWidth = rowWidthDp)) {
@@ -1077,7 +1074,7 @@
assertEquals(
min(root.width.ipx, rowWidthDp.toIntPx()),
- rowSize.width.round()
+ rowSize.width
)
}
@@ -1087,7 +1084,7 @@
val rowWidthDp = 250.dp
val drawLatch = CountDownLatch(1)
- lateinit var rowSize: PxSize
+ lateinit var rowSize: IntPxSize
show {
Center {
ConstrainedBox(constraints = DpConstraints(maxWidth = rowWidthDp)) {
@@ -1110,7 +1107,7 @@
assertEquals(
min(root.width.ipx, rowWidthDp.toIntPx()),
- rowSize.width.round()
+ rowSize.width
)
}
@@ -1120,7 +1117,7 @@
val rowWidthDp = 250.dp
val drawLatch = CountDownLatch(1)
- lateinit var rowSize: PxSize
+ lateinit var rowSize: IntPxSize
show {
Center {
ConstrainedBox(constraints = DpConstraints(minWidth = rowWidthDp)) {
@@ -1143,7 +1140,7 @@
assertEquals(
rowWidthDp.toIntPx(),
- rowSize.width.round()
+ rowSize.width
)
}
@@ -1153,7 +1150,7 @@
val rowHeightDp = 250.dp
val drawLatch = CountDownLatch(1)
- lateinit var rowSize: PxSize
+ lateinit var rowSize: IntPxSize
show {
Center {
ConstrainedBox(constraints = DpConstraints(maxHeight = rowHeightDp)) {
@@ -1176,7 +1173,7 @@
assertEquals(
min(root.height.ipx, rowHeightDp.toIntPx()),
- rowSize.height.round()
+ rowSize.height
)
}
@@ -1186,7 +1183,7 @@
val rowHeightDp = 150.dp
val drawLatch = CountDownLatch(1)
- lateinit var rowSize: PxSize
+ lateinit var rowSize: IntPxSize
show {
Center {
ConstrainedBox(constraints = DpConstraints(minHeight = rowHeightDp)) {
@@ -1209,7 +1206,7 @@
assertEquals(
rowHeightDp.toIntPx(),
- rowSize.height.round()
+ rowSize.height
)
}
@@ -1222,8 +1219,8 @@
val rowWidth = rowWidthDp.toIntPx()
val drawLatch = CountDownLatch(2)
- lateinit var rowSize: PxSize
- lateinit var expandedChildSize: PxSize
+ lateinit var rowSize: IntPxSize
+ lateinit var expandedChildSize: IntPxSize
show {
Center {
ConstrainedBox(constraints = DpConstraints(minWidth = rowWidthDp)) {
@@ -1249,11 +1246,11 @@
waitForDraw(root)
assertEquals(
- PxSize(rowWidth, size),
+ IntPxSize(rowWidth, size),
rowSize
)
assertEquals(
- PxSize(rowWidth, size),
+ IntPxSize(rowWidth, size),
expandedChildSize
)
}
@@ -1268,19 +1265,19 @@
ConstrainedBox(DpConstraints(minWidth = rowMinWidth)) {
Row {
WithConstraints { constraints ->
- Assert.assertEquals(Constraints(), constraints)
+ assertEquals(Constraints(), constraints)
FixedSizeLayout(inflexibleChildWidth.toIntPx(), 0.ipx, mapOf())
}
WithConstraints { constraints ->
- Assert.assertEquals(Constraints(), constraints)
+ assertEquals(Constraints(), constraints)
FixedSizeLayout(inflexibleChildWidth.toIntPx(), 0.ipx, mapOf())
}
Layout({}, LayoutFlexible(1f)) { _, constraints ->
- Assert.assertEquals(
+ assertEquals(
rowMinWidth.toIntPx() - inflexibleChildWidth.toIntPx() * 2,
constraints.minWidth
)
- Assert.assertEquals(
+ assertEquals(
rowMinWidth.toIntPx() - inflexibleChildWidth.toIntPx() * 2,
constraints.maxWidth
)
@@ -1313,7 +1310,7 @@
) {
Row {
WithConstraints { constraints ->
- Assert.assertEquals(
+ assertEquals(
Constraints(
maxWidth = availableWidth.toIntPx(),
maxHeight = availableHeight.toIntPx()
@@ -1323,7 +1320,7 @@
FixedSizeLayout(childWidth.toIntPx(), childHeight.toIntPx(), mapOf())
}
WithConstraints { constraints ->
- Assert.assertEquals(
+ assertEquals(
Constraints(
maxWidth = availableWidth.toIntPx() - childWidth.toIntPx(),
maxHeight = availableHeight.toIntPx()
@@ -1347,7 +1344,7 @@
val sizeDp = 50.dp
val drawLatch = CountDownLatch(1)
- lateinit var columnSize: PxSize
+ lateinit var columnSize: IntPxSize
show {
Center {
Column(LayoutHeight.Fill) {
@@ -1368,7 +1365,7 @@
assertEquals(
root.height.ipx,
- columnSize.height.round()
+ columnSize.height
)
}
@@ -1377,7 +1374,7 @@
val sizeDp = 50.dp
val drawLatch = CountDownLatch(1)
- lateinit var columnSize: PxSize
+ lateinit var columnSize: IntPxSize
show {
Center {
Column {
@@ -1398,7 +1395,7 @@
assertEquals(
(sizeDp * 3).toIntPx(),
- columnSize.height.round()
+ columnSize.height
)
}
@@ -1407,7 +1404,7 @@
val sizeDp = 50.dp
val drawLatch = CountDownLatch(1)
- lateinit var columnSize: PxSize
+ lateinit var columnSize: IntPxSize
show {
Center {
Column {
@@ -1428,7 +1425,7 @@
assertEquals(
root.height.ipx,
- columnSize.height.round()
+ columnSize.height
)
}
@@ -1437,7 +1434,7 @@
val sizeDp = 50.dp
val drawLatch = CountDownLatch(1)
- lateinit var columnSize: PxSize
+ lateinit var columnSize: IntPxSize
show {
Center {
Column(LayoutWidth.Fill) {
@@ -1458,7 +1455,7 @@
assertEquals(
root.width.ipx,
- columnSize.width.round()
+ columnSize.width
)
}
@@ -1467,7 +1464,7 @@
val sizeDp = 50.dp
val drawLatch = CountDownLatch(1)
- lateinit var columnSize: PxSize
+ lateinit var columnSize: IntPxSize
show {
Center {
Column {
@@ -1488,7 +1485,7 @@
assertEquals(
(sizeDp * 2).toIntPx(),
- columnSize.width.round()
+ columnSize.width
)
}
@@ -1498,7 +1495,7 @@
val columnHeightDp = 250.dp
val drawLatch = CountDownLatch(1)
- lateinit var columnSize: PxSize
+ lateinit var columnSize: IntPxSize
show {
Center {
ConstrainedBox(constraints = DpConstraints(maxHeight = columnHeightDp)) {
@@ -1521,7 +1518,7 @@
assertEquals(
min(root.height.ipx, columnHeightDp.toIntPx()),
- columnSize.height.round()
+ columnSize.height
)
}
@@ -1531,7 +1528,7 @@
val columnHeightDp = 250.dp
val drawLatch = CountDownLatch(1)
- lateinit var columnSize: PxSize
+ lateinit var columnSize: IntPxSize
show {
Center {
ConstrainedBox(constraints = DpConstraints(maxHeight = columnHeightDp)) {
@@ -1554,7 +1551,7 @@
assertEquals(
min(root.height.ipx, columnHeightDp.toIntPx()),
- columnSize.height.round()
+ columnSize.height
)
}
@@ -1564,7 +1561,7 @@
val columnHeightDp = 250.dp
val drawLatch = CountDownLatch(1)
- lateinit var columnSize: PxSize
+ lateinit var columnSize: IntPxSize
show {
Center {
ConstrainedBox(constraints = DpConstraints(minHeight = columnHeightDp)) {
@@ -1587,7 +1584,7 @@
assertEquals(
columnHeightDp.toIntPx(),
- columnSize.height.round()
+ columnSize.height
)
}
@@ -1597,7 +1594,7 @@
val columnWidthDp = 250.dp
val drawLatch = CountDownLatch(1)
- lateinit var columnSize: PxSize
+ lateinit var columnSize: IntPxSize
show {
Center {
ConstrainedBox(constraints = DpConstraints(maxWidth = columnWidthDp)) {
@@ -1620,7 +1617,7 @@
assertEquals(
min(root.width.ipx, columnWidthDp.toIntPx()),
- columnSize.width.round()
+ columnSize.width
)
}
@@ -1630,7 +1627,7 @@
val columnWidthDp = 150.dp
val drawLatch = CountDownLatch(1)
- lateinit var columnSize: PxSize
+ lateinit var columnSize: IntPxSize
show {
Center {
ConstrainedBox(constraints = DpConstraints(minWidth = columnWidthDp)) {
@@ -1653,7 +1650,7 @@
assertEquals(
columnWidthDp.toIntPx(),
- columnSize.width.round()
+ columnSize.width
)
}
@@ -1666,8 +1663,8 @@
val columnHeight = columnHeightDp.toIntPx()
val drawLatch = CountDownLatch(2)
- lateinit var columnSize: PxSize
- lateinit var expandedChildSize: PxSize
+ lateinit var columnSize: IntPxSize
+ lateinit var expandedChildSize: IntPxSize
show {
Center {
ConstrainedBox(constraints = DpConstraints(minHeight = columnHeightDp)) {
@@ -1693,11 +1690,11 @@
waitForDraw(root)
assertEquals(
- PxSize(size, columnHeight),
+ IntPxSize(size, columnHeight),
columnSize
)
assertEquals(
- PxSize(size, columnHeight),
+ IntPxSize(size, columnHeight),
expandedChildSize
)
}
@@ -1713,11 +1710,11 @@
ConstrainedBox(DpConstraints(minHeight = columnMinHeight)) {
Column {
WithConstraints { constraints ->
- Assert.assertEquals(Constraints(), constraints)
+ assertEquals(Constraints(), constraints)
FixedSizeLayout(0.ipx, inflexibleChildHeight.toIntPx(), mapOf())
}
WithConstraints { constraints ->
- Assert.assertEquals(Constraints(), constraints)
+ assertEquals(Constraints(), constraints)
FixedSizeLayout(0.ipx, inflexibleChildHeight.toIntPx(), mapOf())
}
Layout({}, LayoutFlexible(1f)) { _, constraints ->
@@ -1757,7 +1754,7 @@
) {
Column {
WithConstraints { constraints ->
- Assert.assertEquals(
+ assertEquals(
Constraints(
maxWidth = availableWidth.toIntPx(),
maxHeight = availableHeight.toIntPx()
@@ -1767,7 +1764,7 @@
FixedSizeLayout(childWidth.toIntPx(), childHeight.toIntPx(), mapOf())
}
WithConstraints { constraints ->
- Assert.assertEquals(
+ assertEquals(
Constraints(
maxWidth = availableWidth.toIntPx(),
maxHeight = availableHeight.toIntPx() - childHeight.toIntPx()
@@ -2391,7 +2388,7 @@
val childSize = childSizeDp.toIntPx()
val layoutLatch = CountDownLatch(1)
- val containerSize = Ref<PxSize>()
+ val containerSize = Ref<IntPxSize>()
show {
Center {
ConstrainedBox(
@@ -2410,7 +2407,7 @@
}
assertTrue(layoutLatch.await(1, TimeUnit.SECONDS))
- assertEquals(PxSize(childSize, childSize), containerSize.value)
+ assertEquals(IntPxSize(childSize, childSize), containerSize.value)
}
@Test
@@ -2420,7 +2417,7 @@
val childSize = childSizeDp.toIntPx()
val layoutLatch = CountDownLatch(1)
- val containerSize = Ref<PxSize>()
+ val containerSize = Ref<IntPxSize>()
show {
Center {
ConstrainedBox(
@@ -2439,7 +2436,7 @@
}
assertTrue(layoutLatch.await(1, TimeUnit.SECONDS))
- assertEquals(PxSize(childSize, childSize), containerSize.value)
+ assertEquals(IntPxSize(childSize, childSize), containerSize.value)
}
// endregion
@@ -2899,7 +2896,7 @@
@Test
fun testFlexModifiersChain_leftMostWins() = withDensity(density) {
val positionedLatch = CountDownLatch(1)
- val containerHeight = Ref<Px>()
+ val containerHeight = Ref<IntPx>()
val columnHeight = 24.ipx
show {
@@ -2921,13 +2918,13 @@
positionedLatch.await(1, TimeUnit.SECONDS)
assertNotNull(containerHeight.value)
- Assert.assertEquals(columnHeight.toPx() * 2 / 3, containerHeight.value)
+ assertEquals(columnHeight * 2 / 3, containerHeight.value)
}
@Test
fun testRelativeToSiblingsModifiersChain_leftMostWins() = withDensity(density) {
val positionedLatch = CountDownLatch(1)
- val containerSize = Ref<PxSize>()
+ val containerSize = Ref<IntPxSize>()
val containerPosition = Ref<PxPosition>()
val size = 40.dp
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/FlowTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/FlowTest.kt
index d10aba4..6037e11 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/FlowTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/FlowTest.kt
@@ -29,10 +29,11 @@
import androidx.ui.layout.FlowRow
import androidx.ui.layout.SizeMode
import androidx.ui.unit.IntPx
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.PxSize
import androidx.ui.unit.ipx
import androidx.ui.unit.withDensity
+import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith
@@ -51,8 +52,8 @@
val flowWidth = 256.ipx
val flowWidthDp = flowWidth.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -82,12 +83,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = size * 5, height = size * 3),
+ IntPxSize(width = size * 5, height = size * 3),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -105,8 +106,8 @@
val flowWidth = 256.ipx
val flowWidthDp = flowWidth.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -136,12 +137,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = size * 5, height = size * 3),
+ IntPxSize(width = size * 5, height = size * 3),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -159,8 +160,8 @@
val flowWidth = 256.ipx
val flowWidthDp = flowWidth.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -190,12 +191,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = flowWidth, height = size * 3),
+ IntPxSize(width = flowWidth, height = size * 3),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -213,8 +214,8 @@
val flowWidth = 256.ipx
val flowWidthDp = flowWidth.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -247,12 +248,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = flowWidth, height = size * 3),
+ IntPxSize(width = flowWidth, height = size * 3),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -270,8 +271,8 @@
val flowWidth = 256.ipx
val flowWidthDp = flowWidth.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -304,12 +305,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = flowWidth, height = size * 3),
+ IntPxSize(width = flowWidth, height = size * 3),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -327,8 +328,8 @@
val flowWidth = 256.ipx
val flowWidthDp = flowWidth.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -361,12 +362,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = flowWidth, height = size * 3),
+ IntPxSize(width = flowWidth, height = size * 3),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -384,8 +385,8 @@
val flowWidth = 256.ipx
val flowWidthDp = flowWidth.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -418,12 +419,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = flowWidth, height = size * 3),
+ IntPxSize(width = flowWidth, height = size * 3),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -444,8 +445,8 @@
val flowWidth = 256.ipx
val flowWidthDp = flowWidth.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -478,12 +479,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = flowWidth, height = size * 3),
+ IntPxSize(width = flowWidth, height = size * 3),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -504,8 +505,8 @@
val flowWidth = 256.ipx
val flowWidthDp = flowWidth.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -538,12 +539,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = flowWidth, height = size * 3),
+ IntPxSize(width = flowWidth, height = size * 3),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -564,8 +565,8 @@
val flowWidth = 256.ipx
val flowWidthDp = flowWidth.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -599,12 +600,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(flowWidth, size * 3),
+ IntPxSize(flowWidth, size * 3),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -629,8 +630,8 @@
val flowWidth = 256.ipx
val flowWidthDp = flowWidth.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -664,12 +665,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(flowWidth, size * 3),
+ IntPxSize(flowWidth, size * 3),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -694,8 +695,8 @@
val flowWidth = 256.ipx
val flowWidthDp = flowWidth.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -729,12 +730,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(flowWidth, size * 3),
+ IntPxSize(flowWidth, size * 3),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -761,8 +762,8 @@
val flowWidth = 256.ipx
val flowWidthDp = flowWidth.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -792,12 +793,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = size * 3 + spacing * 2, height = size * 5),
+ IntPxSize(width = size * 3 + spacing * 2, height = size * 5),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -815,8 +816,8 @@
val flowWidth = 256.ipx
val flowWidthDp = flowWidth.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -849,12 +850,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = size * 5, height = size * 6),
+ IntPxSize(width = size * 5, height = size * 6),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(
+ IntPxSize(
width = size,
height = if (i % 2 == 0) size else size * 2
),
@@ -878,8 +879,8 @@
val flowWidth = 256.ipx
val flowWidthDp = flowWidth.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -912,12 +913,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = size * 5, height = size * 6),
+ IntPxSize(width = size * 5, height = size * 6),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(
+ IntPxSize(
width = size,
height = if (i % 2 == 0) size else size * 2
),
@@ -938,8 +939,8 @@
val flowWidth = 256.ipx
val flowWidthDp = flowWidth.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -972,12 +973,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = size * 5, height = size * 6),
+ IntPxSize(width = size * 5, height = size * 6),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(
+ IntPxSize(
width = size,
height = if (i % 2 == 0) size else size * 2
),
@@ -1003,8 +1004,8 @@
val flowWidth = 256.ipx
val flowWidthDp = flowWidth.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -1034,12 +1035,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = size * 5, height = size * 3 + spacing * 2),
+ IntPxSize(width = size * 5, height = size * 3 + spacing * 2),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -1057,8 +1058,8 @@
val flowHeight = 256.ipx
val flowHeightDp = flowHeight.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -1088,12 +1089,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = size * 3, height = size * 5),
+ IntPxSize(width = size * 3, height = size * 5),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -1111,8 +1112,8 @@
val flowHeight = 256.ipx
val flowHeightDp = flowHeight.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -1142,12 +1143,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = size * 3, height = size * 5),
+ IntPxSize(width = size * 3, height = size * 5),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -1165,8 +1166,8 @@
val flowHeight = 256.ipx
val flowHeightDp = flowHeight.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -1196,12 +1197,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = size * 3, height = flowHeight),
+ IntPxSize(width = size * 3, height = flowHeight),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -1219,8 +1220,8 @@
val flowHeight = 256.ipx
val flowHeightDp = flowHeight.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -1253,12 +1254,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = size * 3, height = flowHeight),
+ IntPxSize(width = size * 3, height = flowHeight),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -1276,8 +1277,8 @@
val flowHeight = 256.ipx
val flowHeightDp = flowHeight.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -1310,12 +1311,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = size * 3, height = flowHeight),
+ IntPxSize(width = size * 3, height = flowHeight),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -1333,8 +1334,8 @@
val flowHeight = 256.ipx
val flowHeightDp = flowHeight.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -1367,12 +1368,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = size * 3, height = flowHeight),
+ IntPxSize(width = size * 3, height = flowHeight),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -1390,8 +1391,8 @@
val flowHeight = 256.ipx
val flowHeightDp = flowHeight.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -1424,12 +1425,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = size * 3, height = flowHeight),
+ IntPxSize(width = size * 3, height = flowHeight),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -1450,8 +1451,8 @@
val flowHeight = 256.ipx
val flowHeightDp = flowHeight.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -1484,12 +1485,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = size * 3, height = flowHeight),
+ IntPxSize(width = size * 3, height = flowHeight),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -1510,8 +1511,8 @@
val flowHeight = 256.ipx
val flowHeightDp = flowHeight.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -1544,12 +1545,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = size * 3, height = flowHeight),
+ IntPxSize(width = size * 3, height = flowHeight),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -1570,8 +1571,8 @@
val flowHeight = 256.ipx
val flowHeightDp = flowHeight.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -1605,12 +1606,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(size * 3, flowHeight),
+ IntPxSize(size * 3, flowHeight),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -1635,8 +1636,8 @@
val flowHeight = 256.ipx
val flowHeightDp = flowHeight.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -1670,12 +1671,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(size * 3, flowHeight),
+ IntPxSize(size * 3, flowHeight),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -1700,8 +1701,8 @@
val flowHeight = 256.ipx
val flowHeightDp = flowHeight.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -1735,12 +1736,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(size * 3, flowHeight),
+ IntPxSize(size * 3, flowHeight),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -1767,8 +1768,8 @@
val flowHeight = 256.ipx
val flowHeightDp = flowHeight.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -1798,12 +1799,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = size * 5, height = size * 3 + spacing * 2),
+ IntPxSize(width = size * 5, height = size * 3 + spacing * 2),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
@@ -1821,8 +1822,8 @@
val flowHeight = 256.ipx
val flowHeightDp = flowHeight.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -1855,12 +1856,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = size * 6, height = size * 5),
+ IntPxSize(width = size * 6, height = size * 5),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(
+ IntPxSize(
width = if (i % 2 == 0) size else size * 2,
height = size
),
@@ -1884,8 +1885,8 @@
val flowHeight = 256.ipx
val flowHeightDp = flowHeight.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -1918,12 +1919,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = size * 6, height = size * 5),
+ IntPxSize(width = size * 6, height = size * 5),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = if (i % 2 == 0) size else size * 2, height = size),
+ IntPxSize(width = if (i % 2 == 0) size else size * 2, height = size),
childSize[i].value
)
assertEquals(
@@ -1941,8 +1942,8 @@
val flowHeight = 256.ipx
val flowHeightDp = flowHeight.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -1975,12 +1976,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = size * 6, height = size * 5),
+ IntPxSize(width = size * 6, height = size * 5),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(
+ IntPxSize(
width = if (i % 2 == 0) size else size * 2,
height = size
),
@@ -2006,8 +2007,8 @@
val flowHeight = 256.ipx
val flowHeightDp = flowHeight.toDp()
- val flowSize = Ref<PxSize>()
- val childSize = Array(numberOfSquares) { Ref<PxSize>() }
+ val flowSize = Ref<IntPxSize>()
+ val childSize = Array(numberOfSquares) { Ref<IntPxSize>() }
val childPosition = Array(numberOfSquares) { Ref<PxPosition>() }
val positionedLatch = CountDownLatch(numberOfSquares + 1)
@@ -2037,12 +2038,12 @@
assertTrue(positionedLatch.await(1, TimeUnit.SECONDS))
assertEquals(
- PxSize(width = size * 3 + spacing * 2, height = size * 5),
+ IntPxSize(width = size * 3 + spacing * 2, height = size * 5),
flowSize.value
)
for (i in 0 until numberOfSquares) {
assertEquals(
- PxSize(width = size, height = size),
+ IntPxSize(width = size, height = size),
childSize[i].value
)
assertEquals(
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/IntrinsicTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/IntrinsicTest.kt
index dd014a6..9c8b7f1 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/IntrinsicTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/IntrinsicTest.kt
@@ -29,12 +29,13 @@
import androidx.ui.layout.MinIntrinsicHeight
import androidx.ui.layout.MinIntrinsicWidth
import androidx.ui.unit.Dp
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.PxSize
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
import androidx.ui.unit.px
import androidx.ui.unit.withDensity
+import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
@@ -47,8 +48,8 @@
@Test
fun testMinIntrinsicWidth() = withDensity(density) {
val positionedLatch = CountDownLatch(2)
- val minIntrinsicWidthSize = Ref<PxSize>()
- val childSize = Ref<PxSize>()
+ val minIntrinsicWidthSize = Ref<IntPxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Align(alignment = Alignment.TopLeft) {
@@ -70,16 +71,16 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(10.dp.toIntPx(), 50.dp.toIntPx()), minIntrinsicWidthSize.value)
- assertEquals(PxSize(10.dp.toIntPx(), 50.dp.toIntPx()), childSize.value)
+ assertEquals(IntPxSize(10.dp.toIntPx(), 50.dp.toIntPx()), minIntrinsicWidthSize.value)
+ assertEquals(IntPxSize(10.dp.toIntPx(), 50.dp.toIntPx()), childSize.value)
assertEquals(PxPosition(0.px, 0.px), childPosition.value)
}
@Test
fun testMinIntrinsicHeight() = withDensity(density) {
val positionedLatch = CountDownLatch(2)
- val minIntrinsicHeightSize = Ref<PxSize>()
- val childSize = Ref<PxSize>()
+ val minIntrinsicHeightSize = Ref<IntPxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Align(alignment = Alignment.TopLeft) {
@@ -101,16 +102,16 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(20.dp.toIntPx(), 40.dp.toIntPx()), minIntrinsicHeightSize.value)
- assertEquals(PxSize(20.dp.toIntPx(), 40.dp.toIntPx()), childSize.value)
+ assertEquals(IntPxSize(20.dp.toIntPx(), 40.dp.toIntPx()), minIntrinsicHeightSize.value)
+ assertEquals(IntPxSize(20.dp.toIntPx(), 40.dp.toIntPx()), childSize.value)
assertEquals(PxPosition(0.px, 0.px), childPosition.value)
}
@Test
fun testMaxIntrinsicWidth() = withDensity(density) {
val positionedLatch = CountDownLatch(2)
- val maxIntrinsicWidthSize = Ref<PxSize>()
- val childSize = Ref<PxSize>()
+ val maxIntrinsicWidthSize = Ref<IntPxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Align(alignment = Alignment.TopLeft) {
@@ -132,16 +133,16 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(30.dp.toIntPx(), 50.dp.toIntPx()), maxIntrinsicWidthSize.value)
- assertEquals(PxSize(30.dp.toIntPx(), 50.dp.toIntPx()), childSize.value)
+ assertEquals(IntPxSize(30.dp.toIntPx(), 50.dp.toIntPx()), maxIntrinsicWidthSize.value)
+ assertEquals(IntPxSize(30.dp.toIntPx(), 50.dp.toIntPx()), childSize.value)
assertEquals(PxPosition(0.px, 0.px), childPosition.value)
}
@Test
fun testMaxIntrinsicHeight() = withDensity(density) {
val positionedLatch = CountDownLatch(2)
- val maxIntrinsicHeightSize = Ref<PxSize>()
- val childSize = Ref<PxSize>()
+ val maxIntrinsicHeightSize = Ref<IntPxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Align(alignment = Alignment.TopLeft) {
@@ -163,16 +164,16 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(20.dp.toIntPx(), 60.dp.toIntPx()), maxIntrinsicHeightSize.value)
- assertEquals(PxSize(20.dp.toIntPx(), 60.dp.toIntPx()), childSize.value)
+ assertEquals(IntPxSize(20.dp.toIntPx(), 60.dp.toIntPx()), maxIntrinsicHeightSize.value)
+ assertEquals(IntPxSize(20.dp.toIntPx(), 60.dp.toIntPx()), childSize.value)
assertEquals(PxPosition(0.px, 0.px), childPosition.value)
}
@Test
fun testMinIntrinsicWidth_respectsIncomingMaxConstraints() = withDensity(density) {
val positionedLatch = CountDownLatch(2)
- val minIntrinsicWidthSize = Ref<PxSize>()
- val childSize = Ref<PxSize>()
+ val minIntrinsicWidthSize = Ref<IntPxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Align(alignment = Alignment.TopLeft) {
@@ -196,16 +197,16 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(5.dp.toIntPx(), 50.dp.toIntPx()), minIntrinsicWidthSize.value)
- assertEquals(PxSize(5.dp.toIntPx(), 50.dp.toIntPx()), childSize.value)
+ assertEquals(IntPxSize(5.dp.toIntPx(), 50.dp.toIntPx()), minIntrinsicWidthSize.value)
+ assertEquals(IntPxSize(5.dp.toIntPx(), 50.dp.toIntPx()), childSize.value)
assertEquals(PxPosition(0.px, 0.px), childPosition.value)
}
@Test
fun testMinIntrinsicWidth_respectsIncomingMinConstraints() = withDensity(density) {
val positionedLatch = CountDownLatch(2)
- val minIntrinsicWidthSize = Ref<PxSize>()
- val childSize = Ref<PxSize>()
+ val minIntrinsicWidthSize = Ref<IntPxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Align(alignment = Alignment.TopLeft) {
@@ -229,16 +230,16 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(15.dp.toIntPx(), 50.dp.toIntPx()), minIntrinsicWidthSize.value)
- assertEquals(PxSize(15.dp.toIntPx(), 50.dp.toIntPx()), childSize.value)
+ assertEquals(IntPxSize(15.dp.toIntPx(), 50.dp.toIntPx()), minIntrinsicWidthSize.value)
+ assertEquals(IntPxSize(15.dp.toIntPx(), 50.dp.toIntPx()), childSize.value)
assertEquals(PxPosition(0.px, 0.px), childPosition.value)
}
@Test
fun testMinIntrinsicHeight_respectsMaxIncomingConstraints() = withDensity(density) {
val positionedLatch = CountDownLatch(2)
- val minIntrinsicHeightSize = Ref<PxSize>()
- val childSize = Ref<PxSize>()
+ val minIntrinsicHeightSize = Ref<IntPxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Align(alignment = Alignment.TopLeft) {
@@ -262,16 +263,16 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(20.dp.toIntPx(), 35.dp.toIntPx()), minIntrinsicHeightSize.value)
- assertEquals(PxSize(20.dp.toIntPx(), 35.dp.toIntPx()), childSize.value)
+ assertEquals(IntPxSize(20.dp.toIntPx(), 35.dp.toIntPx()), minIntrinsicHeightSize.value)
+ assertEquals(IntPxSize(20.dp.toIntPx(), 35.dp.toIntPx()), childSize.value)
assertEquals(PxPosition(0.px, 0.px), childPosition.value)
}
@Test
fun testMinIntrinsicHeight_respectsMinIncomingConstraints() = withDensity(density) {
val positionedLatch = CountDownLatch(2)
- val minIntrinsicHeightSize = Ref<PxSize>()
- val childSize = Ref<PxSize>()
+ val minIntrinsicHeightSize = Ref<IntPxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Align(alignment = Alignment.TopLeft) {
@@ -295,16 +296,16 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(20.dp.toIntPx(), 45.dp.toIntPx()), minIntrinsicHeightSize.value)
- assertEquals(PxSize(20.dp.toIntPx(), 45.dp.toIntPx()), childSize.value)
+ assertEquals(IntPxSize(20.dp.toIntPx(), 45.dp.toIntPx()), minIntrinsicHeightSize.value)
+ assertEquals(IntPxSize(20.dp.toIntPx(), 45.dp.toIntPx()), childSize.value)
assertEquals(PxPosition(0.px, 0.px), childPosition.value)
}
@Test
fun testMaxIntrinsicWidth_respectsMaxIncomingConstraints() = withDensity(density) {
val positionedLatch = CountDownLatch(2)
- val maxIntrinsicWidthSize = Ref<PxSize>()
- val childSize = Ref<PxSize>()
+ val maxIntrinsicWidthSize = Ref<IntPxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Align(alignment = Alignment.TopLeft) {
@@ -328,16 +329,16 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(25.dp.toIntPx(), 50.dp.toIntPx()), maxIntrinsicWidthSize.value)
- assertEquals(PxSize(25.dp.toIntPx(), 50.dp.toIntPx()), childSize.value)
+ assertEquals(IntPxSize(25.dp.toIntPx(), 50.dp.toIntPx()), maxIntrinsicWidthSize.value)
+ assertEquals(IntPxSize(25.dp.toIntPx(), 50.dp.toIntPx()), childSize.value)
assertEquals(PxPosition(0.px, 0.px), childPosition.value)
}
@Test
fun testMaxIntrinsicWidth_respectsMinIncomingConstraints() = withDensity(density) {
val positionedLatch = CountDownLatch(2)
- val maxIntrinsicWidthSize = Ref<PxSize>()
- val childSize = Ref<PxSize>()
+ val maxIntrinsicWidthSize = Ref<IntPxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Align(alignment = Alignment.TopLeft) {
@@ -361,16 +362,16 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(35.dp.toIntPx(), 50.dp.toIntPx()), maxIntrinsicWidthSize.value)
- assertEquals(PxSize(35.dp.toIntPx(), 50.dp.toIntPx()), childSize.value)
+ assertEquals(IntPxSize(35.dp.toIntPx(), 50.dp.toIntPx()), maxIntrinsicWidthSize.value)
+ assertEquals(IntPxSize(35.dp.toIntPx(), 50.dp.toIntPx()), childSize.value)
assertEquals(PxPosition(0.px, 0.px), childPosition.value)
}
@Test
fun testMaxIntrinsicHeight_respectsMaxIncomingConstraints() = withDensity(density) {
val positionedLatch = CountDownLatch(2)
- val maxIntrinsicHeightSize = Ref<PxSize>()
- val childSize = Ref<PxSize>()
+ val maxIntrinsicHeightSize = Ref<IntPxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Align(alignment = Alignment.TopLeft) {
@@ -394,16 +395,16 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(20.dp.toIntPx(), 55.dp.toIntPx()), maxIntrinsicHeightSize.value)
- assertEquals(PxSize(20.dp.toIntPx(), 55.dp.toIntPx()), childSize.value)
+ assertEquals(IntPxSize(20.dp.toIntPx(), 55.dp.toIntPx()), maxIntrinsicHeightSize.value)
+ assertEquals(IntPxSize(20.dp.toIntPx(), 55.dp.toIntPx()), childSize.value)
assertEquals(PxPosition(0.px, 0.px), childPosition.value)
}
@Test
fun testMaxIntrinsicHeight_respectsMinIncomingConstraints() = withDensity(density) {
val positionedLatch = CountDownLatch(2)
- val maxIntrinsicHeightSize = Ref<PxSize>()
- val childSize = Ref<PxSize>()
+ val maxIntrinsicHeightSize = Ref<IntPxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Align(alignment = Alignment.TopLeft) {
@@ -427,8 +428,8 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(20.dp.toIntPx(), 65.dp.toIntPx()), maxIntrinsicHeightSize.value)
- assertEquals(PxSize(20.dp.toIntPx(), 65.dp.toIntPx()), childSize.value)
+ assertEquals(IntPxSize(20.dp.toIntPx(), 65.dp.toIntPx()), maxIntrinsicHeightSize.value)
+ assertEquals(IntPxSize(20.dp.toIntPx(), 65.dp.toIntPx()), childSize.value)
assertEquals(PxPosition(0.px, 0.px), childPosition.value)
}
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutPaddingTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutPaddingTest.kt
index 2dfa834..af2e30c3 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutPaddingTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutPaddingTest.kt
@@ -28,8 +28,8 @@
import androidx.ui.layout.LayoutPadding
import androidx.ui.unit.Dp
import androidx.ui.unit.IntPx
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.PxSize
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
import androidx.ui.unit.min
@@ -37,6 +37,7 @@
import androidx.ui.unit.toPx
import androidx.ui.unit.withDensity
import org.junit.Assert
+import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
@@ -176,7 +177,7 @@
val paddingPx = padding.toIntPx()
val drawLatch = CountDownLatch(1)
- var childSize = PxSize(-1.px, -1.px)
+ var childSize = IntPxSize(-1.ipx, -1.ipx)
var childPosition = PxPosition(-1.px, -1.px)
show {
Center {
@@ -201,7 +202,7 @@
waitForDraw(root)
val innerSize = (size - paddingPx * 2)
- assertEquals(PxSize(innerSize, innerSize), childSize)
+ assertEquals(IntPxSize(innerSize, innerSize), childSize)
val left = ((root.width.ipx - size) / 2) + paddingPx
val top = ((root.height.ipx - size) / 2) + paddingPx
assertEquals(
@@ -221,7 +222,7 @@
val size = sizeDp.toIntPx()
val drawLatch = CountDownLatch(1)
- var childSize = PxSize(-1.px, -1.px)
+ var childSize = IntPxSize(-1.ipx, -1.ipx)
var childPosition = PxPosition(-1.px, -1.px)
show {
Center {
@@ -250,7 +251,7 @@
val paddingTop = top.toIntPx()
val paddingBottom = bottom.toIntPx()
assertEquals(
- PxSize(
+ IntPxSize(
size - paddingLeft - paddingRight,
size - paddingTop - paddingBottom
),
@@ -273,7 +274,7 @@
val paddingPx = padding.toIntPx()
val drawLatch = CountDownLatch(1)
- var childSize = PxSize(-1.px, -1.px)
+ var childSize = IntPxSize(-1.ipx, -1.ipx)
var childPosition = PxPosition(-1.px, -1.px)
show {
Center {
@@ -295,7 +296,7 @@
val root = findAndroidComposeView()
waitForDraw(root)
- assertEquals(PxSize(0.px, 0.px), childSize)
+ assertEquals(IntPxSize(0.ipx, 0.ipx), childSize)
val left = ((root.width.ipx - size) / 2) + paddingPx
val top = ((root.height.ipx - size) / 2) + paddingPx
assertEquals(PxPosition(left.toPx(), top.toPx()), childPosition)
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutTest.kt
index 140e8fe..f63bcf9 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/LayoutTest.kt
@@ -36,6 +36,7 @@
import androidx.ui.layout.DpConstraints
import androidx.ui.unit.Density
import androidx.ui.unit.IntPx
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
import androidx.ui.unit.PxSize
import androidx.ui.unit.ipx
@@ -127,12 +128,12 @@
@Composable
internal fun SaveLayoutInfo(
- size: Ref<PxSize>,
+ size: Ref<IntPxSize>,
position: Ref<PxPosition>,
positionedLatch: CountDownLatch
) {
OnPositioned( coordinates ->
- size.value = PxSize(coordinates.size.width, coordinates.size.height)
+ size.value = IntPxSize(coordinates.size.width, coordinates.size.height)
position.value = coordinates.localToGlobal(PxPosition(0.px, 0.px))
positionedLatch.countDown()
})
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/OnPositionedTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/OnPositionedTest.kt
index 80510fb..bef7fe8 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/OnPositionedTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/OnPositionedTest.kt
@@ -33,6 +33,7 @@
import androidx.ui.layout.Container
import androidx.ui.layout.Padding
import androidx.ui.layout.Row
+import androidx.ui.test.positionInParent
import androidx.ui.unit.Px
import androidx.ui.unit.PxPosition
import androidx.ui.unit.dp
@@ -65,8 +66,8 @@
Padding(left = paddingLeftPx.toDp(), top = paddingTopPx.toDp()) {
Container(expanded = true) {
OnPositioned(>
- realLeft = it.position.x
- realTop = it.position.y
+ realLeft = it.positionInParent.x
+ realTop = it.positionInParent.y
positionedLatch.countDown()
})
}
@@ -89,8 +90,8 @@
show {
Padding(left = paddingLeftPx.toDp(), top = paddingTopPx.toDp()) {
OnChildPositioned(>
- realLeft = it.position.x
- realTop = it.position.y
+ realLeft = it.positionInParent.x
+ realTop = it.positionInParent.y
positionedLatch.countDown()
}) {
Container(expanded = true) {}
@@ -139,7 +140,7 @@
val gpPos = gpCoordinates!!.childToLocal(childCoordinates!!, PxPosition.Origin).x
assertThat(gpPos).isEqualTo(secondPaddingPx + thirdPaddingPx)
// local position
- assertThat(childCoordinates!!.position.x).isEqualTo(thirdPaddingPx)
+ assertThat(childCoordinates!!.positionInParent.x).isEqualTo(thirdPaddingPx)
}
@Test
@@ -168,8 +169,8 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertThat(0.px).isEqualTo(firstCoordinates!!.position.x)
- assertThat(size).isEqualTo(secondCoordinates!!.position.x)
+ assertThat(0.px).isEqualTo(firstCoordinates!!.positionInParent.x)
+ assertThat(size).isEqualTo(secondCoordinates!!.positionInParent.x)
}
@Test
@@ -234,7 +235,7 @@
Center {
Padding(left = modelLeft.size) {
OnChildPositioned(>
- realLeft = it.position.x
+ realLeft = it.positionInParent.x
positionedLatch.countDown()
}) {
Container(expanded = true) {}
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/PaddingTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/PaddingTest.kt
index 8f625fa..0454dcd 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/PaddingTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/PaddingTest.kt
@@ -27,13 +27,14 @@
import androidx.ui.layout.Padding
import androidx.ui.unit.Dp
import androidx.ui.unit.IntPx
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.PxSize
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
import androidx.ui.unit.px
import androidx.ui.unit.toPx
import androidx.ui.unit.withDensity
+import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
@@ -131,7 +132,7 @@
val paddingPx = padding.toIntPx()
val drawLatch = CountDownLatch(1)
- var childSize = PxSize(-1.px, -1.px)
+ var childSize = IntPxSize(-1.ipx, -1.ipx)
var childPosition = PxPosition(-1.px, -1.px)
show {
Center {
@@ -156,7 +157,7 @@
waitForDraw(root)
val innerSize = (size - paddingPx * 2)
- assertEquals(PxSize(innerSize, innerSize), childSize)
+ assertEquals(IntPxSize(innerSize, innerSize), childSize)
val left = ((root.width.ipx - size) / 2) + paddingPx
val top = ((root.height.ipx - size) / 2) + paddingPx
assertEquals(
@@ -176,7 +177,7 @@
val size = sizeDp.toIntPx()
val drawLatch = CountDownLatch(1)
- var childSize = PxSize(-1.px, -1.px)
+ var childSize = IntPxSize(-1.ipx, -1.ipx)
var childPosition = PxPosition(-1.px, -1.px)
show {
Center {
@@ -205,7 +206,7 @@
val paddingTop = top.toIntPx()
val paddingBottom = bottom.toIntPx()
assertEquals(
- PxSize(
+ IntPxSize(
size - paddingLeft - paddingRight,
size - paddingTop - paddingBottom
),
@@ -229,7 +230,7 @@
val paddingPx = padding.toIntPx()
val drawLatch = CountDownLatch(1)
- var childSize = PxSize(-1.px, -1.px)
+ var childSize = IntPxSize(-1.ipx, -1.ipx)
var childPosition = PxPosition(-1.px, -1.px)
show {
Center {
@@ -253,7 +254,7 @@
val root = findAndroidComposeView()
waitForDraw(root)
- assertEquals(PxSize(0.px, 0.px), childSize)
+ assertEquals(IntPxSize(0.ipx, 0.ipx), childSize)
val left = ((root.width.ipx - size) / 2) + paddingPx
val top = ((root.height.ipx - size) / 2) + paddingPx
assertEquals(PxPosition(left.toPx(), top.toPx()), childPosition)
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/SizeModifiersTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/SizeModifiersTest.kt
index 94106ad..f81d8bf 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/SizeModifiersTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/SizeModifiersTest.kt
@@ -31,11 +31,12 @@
import androidx.ui.layout.Row
import androidx.ui.unit.Dp
import androidx.ui.unit.IntPx
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.PxSize
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
import androidx.ui.unit.withDensity
+import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
@@ -52,7 +53,7 @@
val sizeIpx = sizeDp.toIntPx()
val positionedLatch = CountDownLatch(6)
- val size = MutableList(6) { Ref<PxSize>() }
+ val size = MutableList(6) { Ref<IntPxSize>() }
val position = MutableList(6) { Ref<PxPosition>() }
show {
Align(alignment = Alignment.TopLeft) {
@@ -86,22 +87,22 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(sizeIpx, sizeIpx), size[0].value)
+ assertEquals(IntPxSize(sizeIpx, sizeIpx), size[0].value)
assertEquals(PxPosition.Origin, position[0].value)
- assertEquals(PxSize(0.ipx, sizeIpx), size[1].value)
+ assertEquals(IntPxSize(0.ipx, sizeIpx), size[1].value)
assertEquals(PxPosition(0.ipx, sizeIpx), position[1].value)
- assertEquals(PxSize(sizeIpx, sizeIpx), size[2].value)
+ assertEquals(IntPxSize(sizeIpx, sizeIpx), size[2].value)
assertEquals(PxPosition(0.ipx, sizeIpx * 2), position[2].value)
- assertEquals(PxSize(sizeIpx, sizeIpx), size[3].value)
+ assertEquals(IntPxSize(sizeIpx, sizeIpx), size[3].value)
assertEquals(PxPosition(0.ipx, sizeIpx * 3), position[3].value)
- assertEquals(PxSize((sizeDp * 2).toIntPx(), sizeIpx), size[4].value)
+ assertEquals(IntPxSize((sizeDp * 2).toIntPx(), sizeIpx), size[4].value)
assertEquals(PxPosition(0.ipx, sizeIpx * 4), position[4].value)
- assertEquals(PxSize(sizeIpx, sizeIpx), size[5].value)
+ assertEquals(IntPxSize(sizeIpx, sizeIpx), size[5].value)
assertEquals(PxPosition(0.ipx, sizeIpx * 5), position[5].value)
}
@@ -111,7 +112,7 @@
val sizeIpx = sizeDp.toIntPx()
val positionedLatch = CountDownLatch(6)
- val size = MutableList(6) { Ref<PxSize>() }
+ val size = MutableList(6) { Ref<IntPxSize>() }
val position = MutableList(6) { Ref<PxPosition>() }
show {
Align(alignment = Alignment.TopLeft) {
@@ -142,22 +143,22 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(sizeIpx, sizeIpx), size[0].value)
+ assertEquals(IntPxSize(sizeIpx, sizeIpx), size[0].value)
assertEquals(PxPosition.Origin, position[0].value)
- assertEquals(PxSize(sizeIpx, 0.ipx), size[1].value)
+ assertEquals(IntPxSize(sizeIpx, 0.ipx), size[1].value)
assertEquals(PxPosition(sizeIpx, 0.ipx), position[1].value)
- assertEquals(PxSize(sizeIpx, sizeIpx), size[2].value)
+ assertEquals(IntPxSize(sizeIpx, sizeIpx), size[2].value)
assertEquals(PxPosition(sizeIpx * 2, 0.ipx), position[2].value)
- assertEquals(PxSize(sizeIpx, sizeIpx), size[3].value)
+ assertEquals(IntPxSize(sizeIpx, sizeIpx), size[3].value)
assertEquals(PxPosition(sizeIpx * 3, 0.ipx), position[3].value)
- assertEquals(PxSize(sizeIpx, (sizeDp * 2).toIntPx()), size[4].value)
+ assertEquals(IntPxSize(sizeIpx, (sizeDp * 2).toIntPx()), size[4].value)
assertEquals(PxPosition(sizeIpx * 4, 0.ipx), position[4].value)
- assertEquals(PxSize(sizeIpx, sizeIpx), size[5].value)
+ assertEquals(IntPxSize(sizeIpx, sizeIpx), size[5].value)
assertEquals(PxPosition(sizeIpx * 5, 0.ipx), position[5].value)
}
@@ -167,7 +168,7 @@
val sizeIpx = sizeDp.toIntPx()
val positionedLatch = CountDownLatch(5)
- val size = MutableList(5) { Ref<PxSize>() }
+ val size = MutableList(5) { Ref<IntPxSize>() }
val position = MutableList(5) { Ref<PxPosition>() }
show {
Align(alignment = Alignment.TopLeft) {
@@ -192,19 +193,19 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(sizeIpx, sizeIpx), size[0].value)
+ assertEquals(IntPxSize(sizeIpx, sizeIpx), size[0].value)
assertEquals(PxPosition.Origin, position[0].value)
- assertEquals(PxSize(sizeIpx, sizeIpx), size[1].value)
+ assertEquals(IntPxSize(sizeIpx, sizeIpx), size[1].value)
assertEquals(PxPosition(sizeIpx, 0.ipx), position[1].value)
- assertEquals(PxSize(sizeIpx, sizeIpx), size[2].value)
+ assertEquals(IntPxSize(sizeIpx, sizeIpx), size[2].value)
assertEquals(PxPosition(sizeIpx * 2, 0.ipx), position[2].value)
- assertEquals(PxSize((sizeDp * 2).toIntPx(), (sizeDp * 2).toIntPx()), size[3].value)
+ assertEquals(IntPxSize((sizeDp * 2).toIntPx(), (sizeDp * 2).toIntPx()), size[3].value)
assertEquals(PxPosition(sizeIpx * 3, 0.ipx), position[3].value)
- assertEquals(PxSize(sizeIpx, sizeIpx), size[4].value)
+ assertEquals(IntPxSize(sizeIpx, sizeIpx), size[4].value)
assertEquals(PxPosition((sizeDp * 5).toIntPx(), 0.ipx), position[4].value)
}
@@ -214,8 +215,8 @@
val size = sizeDp.toIntPx()
val positionedLatch = CountDownLatch(2)
- val constrainedBoxSize = Ref<PxSize>()
- val childSize = Ref<PxSize>()
+ val constrainedBoxSize = Ref<IntPxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Align(alignment = Alignment.TopLeft) {
@@ -239,8 +240,8 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(size, size), constrainedBoxSize.value)
- assertEquals(PxSize(size, size), childSize.value)
+ assertEquals(IntPxSize(size, size), constrainedBoxSize.value)
+ assertEquals(IntPxSize(size, size), childSize.value)
assertEquals(PxPosition.Origin, childPosition.value)
}
@@ -250,7 +251,7 @@
val sizeIpx = sizeDp.toIntPx()
val positionedLatch = CountDownLatch(4)
- val size = MutableList(4) { Ref<PxSize>() }
+ val size = MutableList(4) { Ref<IntPxSize>() }
val position = MutableList(4) { Ref<PxPosition>() }
show {
Align(alignment = Alignment.TopLeft) {
@@ -281,10 +282,10 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(sizeIpx, sizeIpx), size[0].value)
- assertEquals(PxSize(sizeIpx, sizeIpx), size[1].value)
- assertEquals(PxSize(sizeIpx, sizeIpx), size[2].value)
- assertEquals(PxSize(sizeIpx, sizeIpx), size[3].value)
+ assertEquals(IntPxSize(sizeIpx, sizeIpx), size[0].value)
+ assertEquals(IntPxSize(sizeIpx, sizeIpx), size[1].value)
+ assertEquals(IntPxSize(sizeIpx, sizeIpx), size[2].value)
+ assertEquals(IntPxSize(sizeIpx, sizeIpx), size[3].value)
}
@Test
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/SpacerTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/SpacerTest.kt
index 558e8cf..e3194ff 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/SpacerTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/SpacerTest.kt
@@ -25,10 +25,9 @@
import androidx.ui.layout.LayoutSize
import androidx.ui.layout.LayoutWidth
import androidx.ui.layout.Spacer
-import androidx.ui.unit.PxSize
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
-import androidx.ui.unit.round
import androidx.ui.unit.withDensity
import com.google.common.truth.Truth
import org.junit.Test
@@ -48,7 +47,7 @@
@Test
fun fixedSpacer_Sizes() {
- var size: PxSize? = null
+ var size: IntPxSize? = null
val width = 40.dp
val height = 71.dp
@@ -66,14 +65,14 @@
drawLatch.await(1, TimeUnit.SECONDS)
withDensity(density) {
- Truth.assertThat(size?.height?.round()).isEqualTo(height.toIntPx())
- Truth.assertThat(size?.width?.round()).isEqualTo(width.toIntPx())
+ Truth.assertThat(size?.height).isEqualTo(height.toIntPx())
+ Truth.assertThat(size?.width).isEqualTo(width.toIntPx())
}
}
@Test
fun fixedSpacer_Sizes_WithSmallerContainer() {
- var size: PxSize? = null
+ var size: IntPxSize? = null
val width = 40.dp
val height = 71.dp
@@ -100,14 +99,14 @@
drawLatch.await(1, TimeUnit.SECONDS)
withDensity(density) {
- Truth.assertThat(size?.height?.round()).isEqualTo(containerHeight.toIntPx())
- Truth.assertThat(size?.width?.round()).isEqualTo(containerWidth.toIntPx())
+ Truth.assertThat(size?.height).isEqualTo(containerHeight.toIntPx())
+ Truth.assertThat(size?.width).isEqualTo(containerWidth.toIntPx())
}
}
@Test
fun widthSpacer_Sizes() {
- var size: PxSize? = null
+ var size: IntPxSize? = null
val width = 71.dp
val drawLatch = CountDownLatch(1)
@@ -124,14 +123,14 @@
drawLatch.await(1, TimeUnit.SECONDS)
withDensity(density) {
- Truth.assertThat(size?.height?.round()).isEqualTo(0.ipx)
- Truth.assertThat(size?.width?.round()).isEqualTo(width.toIntPx())
+ Truth.assertThat(size?.height).isEqualTo(0.ipx)
+ Truth.assertThat(size?.width).isEqualTo(width.toIntPx())
}
}
@Test
fun widthSpacer_Sizes_WithSmallerContainer() {
- var size: PxSize? = null
+ var size: IntPxSize? = null
val width = 40.dp
val drawLatch = CountDownLatch(1)
@@ -157,14 +156,14 @@
drawLatch.await(1, TimeUnit.SECONDS)
withDensity(density) {
- Truth.assertThat(size?.height?.round()).isEqualTo(0.ipx)
- Truth.assertThat(size?.width?.round()).isEqualTo(containerWidth.toIntPx())
+ Truth.assertThat(size?.height).isEqualTo(0.ipx)
+ Truth.assertThat(size?.width).isEqualTo(containerWidth.toIntPx())
}
}
@Test
fun heightSpacer_Sizes() {
- var size: PxSize? = null
+ var size: IntPxSize? = null
val height = 7.dp
val drawLatch = CountDownLatch(1)
@@ -181,14 +180,14 @@
drawLatch.await(1, TimeUnit.SECONDS)
withDensity(density) {
- Truth.assertThat(size?.height?.round()).isEqualTo(height.toIntPx())
- Truth.assertThat(size?.width?.round()).isEqualTo(0.ipx)
+ Truth.assertThat(size?.height).isEqualTo(height.toIntPx())
+ Truth.assertThat(size?.width).isEqualTo(0.ipx)
}
}
@Test
fun heightSpacer_Sizes_WithSmallerContainer() {
- var size: PxSize? = null
+ var size: IntPxSize? = null
val height = 23.dp
val drawLatch = CountDownLatch(1)
@@ -214,8 +213,8 @@
drawLatch.await(1, TimeUnit.SECONDS)
withDensity(density) {
- Truth.assertThat(size?.height?.round()).isEqualTo(containerHeight.toIntPx())
- Truth.assertThat(size?.width?.round()).isEqualTo(0.ipx)
+ Truth.assertThat(size?.height).isEqualTo(containerHeight.toIntPx())
+ Truth.assertThat(size?.width).isEqualTo(0.ipx)
}
}
}
\ No newline at end of file
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/StackTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/StackTest.kt
index 757377f..3075805 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/StackTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/StackTest.kt
@@ -30,12 +30,13 @@
import androidx.ui.layout.LayoutSize
import androidx.ui.layout.Stack
import androidx.ui.unit.IntPx
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.PxSize
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
import androidx.ui.unit.px
import androidx.ui.unit.withDensity
+import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
@@ -51,10 +52,10 @@
val size = sizeDp.toIntPx()
val positionedLatch = CountDownLatch(3)
- val stackSize = Ref<PxSize>()
- val alignedChildSize = Ref<PxSize>()
+ val stackSize = Ref<IntPxSize>()
+ val alignedChildSize = Ref<IntPxSize>()
val alignedChildPosition = Ref<PxPosition>()
- val positionedChildSize = Ref<PxSize>()
+ val positionedChildSize = Ref<IntPxSize>()
val positionedChildPosition = Ref<PxPosition>()
show {
Align(alignment = Alignment.TopLeft) {
@@ -84,10 +85,10 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(size, size), stackSize.value)
- assertEquals(PxSize(size, size), alignedChildSize.value)
+ assertEquals(IntPxSize(size, size), stackSize.value)
+ assertEquals(IntPxSize(size, size), alignedChildSize.value)
assertEquals(PxPosition(0.px, 0.px), alignedChildPosition.value)
- assertEquals(PxSize(30.dp.toIntPx(), 30.dp.toIntPx()), positionedChildSize.value)
+ assertEquals(IntPxSize(30.dp.toIntPx(), 30.dp.toIntPx()), positionedChildSize.value)
assertEquals(PxPosition(10.dp.toIntPx(), 10.dp.toIntPx()), positionedChildPosition.value)
}
@@ -99,8 +100,8 @@
val doubleSize = (sizeDp * 2).toIntPx()
val positionedLatch = CountDownLatch(3)
- val stackSize = Ref<PxSize>()
- val childSize = arrayOf(Ref<PxSize>(), Ref<PxSize>())
+ val stackSize = Ref<IntPxSize>()
+ val childSize = arrayOf(Ref<IntPxSize>(), Ref<IntPxSize>())
val childPosition = arrayOf(Ref<PxPosition>(), Ref<PxPosition>())
show {
Align(alignment = Alignment.TopLeft) {
@@ -135,10 +136,10 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(doubleSize, doubleSize), stackSize.value)
- assertEquals(PxSize(size, size), childSize[0].value)
+ assertEquals(IntPxSize(doubleSize, doubleSize), stackSize.value)
+ assertEquals(IntPxSize(size, size), childSize[0].value)
assertEquals(PxPosition(size, size), childPosition[0].value)
- assertEquals(PxSize(doubleSize, doubleSize), childSize[1].value)
+ assertEquals(IntPxSize(doubleSize, doubleSize), childSize[1].value)
assertEquals(PxPosition(0.px, 0.px), childPosition[1].value)
}
@@ -151,8 +152,8 @@
val insetDp = inset.toDp()
val positionedLatch = CountDownLatch(6)
- val stackSize = Ref<PxSize>()
- val childSize = Array(5) { Ref<PxSize>() }
+ val stackSize = Ref<IntPxSize>()
+ val childSize = Array(5) { Ref<IntPxSize>() }
val childPosition = Array(5) { Ref<PxPosition>() }
show {
Align(alignment = Alignment.TopLeft) {
@@ -229,16 +230,16 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(size, size), stackSize.value)
- assertEquals(PxSize(size, size), childSize[0].value)
+ assertEquals(IntPxSize(size, size), stackSize.value)
+ assertEquals(IntPxSize(size, size), childSize[0].value)
assertEquals(PxPosition(0.px, 0.px), childPosition[0].value)
- assertEquals(PxSize(size - inset, size - inset), childSize[1].value)
+ assertEquals(IntPxSize(size - inset, size - inset), childSize[1].value)
assertEquals(PxPosition(inset, inset), childPosition[1].value)
- assertEquals(PxSize(size - inset, size - inset), childSize[2].value)
+ assertEquals(IntPxSize(size - inset, size - inset), childSize[2].value)
assertEquals(PxPosition(0.px, 0.px), childPosition[2].value)
- assertEquals(PxSize(size - inset * 2, size), childSize[3].value)
+ assertEquals(IntPxSize(size - inset * 2, size), childSize[3].value)
assertEquals(PxPosition(inset, 0.ipx), childPosition[3].value)
- assertEquals(PxSize(size, size - inset * 2), childSize[4].value)
+ assertEquals(IntPxSize(size, size - inset * 2), childSize[4].value)
assertEquals(PxPosition(0.ipx, inset), childPosition[4].value)
}
@@ -250,8 +251,8 @@
val halfSizeDp = halfSize.toDp()
val positionedLatch = CountDownLatch(3)
- val stackSize = Ref<PxSize>()
- val childSize = Array(2) { Ref<PxSize>() }
+ val stackSize = Ref<IntPxSize>()
+ val childSize = Array(2) { Ref<IntPxSize>() }
val childPosition = Array(2) { Ref<PxPosition>() }
show {
Align(alignment = Alignment.TopLeft) {
@@ -286,10 +287,10 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(size, size), stackSize.value)
- assertEquals(PxSize(size, size), childSize[0].value)
+ assertEquals(IntPxSize(size, size), stackSize.value)
+ assertEquals(IntPxSize(size, size), childSize[0].value)
assertEquals(PxPosition(0.px, 0.px), childPosition[0].value)
- assertEquals(PxSize(halfSize, halfSize), childSize[1].value)
+ assertEquals(IntPxSize(halfSize, halfSize), childSize[1].value)
assertEquals(PxPosition(size - halfSize, size - halfSize), childPosition[1].value)
}
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/TableTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/TableTest.kt
index 7b58d35..b40f06d 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/TableTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/TableTest.kt
@@ -30,12 +30,13 @@
import androidx.ui.layout.TableMeasurable
import androidx.ui.unit.Density
import androidx.ui.unit.IntPx
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.PxSize
import androidx.ui.unit.ipx
import androidx.ui.unit.max
import androidx.ui.unit.min
import androidx.ui.unit.withDensity
+import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
@@ -57,8 +58,8 @@
val tableWidth = 256.ipx
val tableWidthDp = tableWidth.toDp()
- val tableSize = Ref<PxSize>()
- val childSize = Array(rows) { Array(columns) { Ref<PxSize>() } }
+ val tableSize = Ref<IntPxSize>()
+ val childSize = Array(rows) { Array(columns) { Ref<IntPxSize>() } }
val childPosition = Array(rows) { Array(columns) { Ref<PxPosition>() } }
val positionedLatch = CountDownLatch(rows * columns + 1)
@@ -92,13 +93,13 @@
positionedLatch.await(1, TimeUnit.SECONDS)
assertEquals(
- PxSize(tableWidth, size * rows),
+ IntPxSize(tableWidth, size * rows),
tableSize.value
)
for (i in 0 until rows) {
for (j in 0 until columns) {
assertEquals(
- PxSize(tableWidth / columns, size),
+ IntPxSize(tableWidth / columns, size),
childSize[i][j].value
)
assertEquals(
@@ -119,8 +120,8 @@
val tableWidth = 256.ipx
val tableWidthDp = tableWidth.toDp()
- val tableSize = Ref<PxSize>()
- val childSize = Array(rows) { Array(columns) { Ref<PxSize>() } }
+ val tableSize = Ref<IntPxSize>()
+ val childSize = Array(rows) { Array(columns) { Ref<IntPxSize>() } }
val childPosition = Array(rows) { Array(columns) { Ref<PxPosition>() } }
val positionedLatch = CountDownLatch(rows * columns + 1)
@@ -159,13 +160,13 @@
positionedLatch.await(1, TimeUnit.SECONDS)
assertEquals(
- PxSize(tableWidth, size * rows),
+ IntPxSize(tableWidth, size * rows),
tableSize.value
)
for (i in 0 until rows) {
for (j in 0 until columns) {
assertEquals(
- PxSize(tableWidth * flexes[j] / totalFlex, size),
+ IntPxSize(tableWidth * flexes[j] / totalFlex, size),
childSize[i][j].value
)
assertEquals(
@@ -184,8 +185,8 @@
val size = 64.ipx
val sizeDp = size.toDp()
- val tableSize = Ref<PxSize>()
- val childSize = Array(rows) { Array(columns) { Ref<PxSize>() } }
+ val tableSize = Ref<IntPxSize>()
+ val childSize = Array(rows) { Array(columns) { Ref<IntPxSize>() } }
val childPosition = Array(rows) { Array(columns) { Ref<PxPosition>() } }
val positionedLatch = CountDownLatch(rows * columns + 1)
@@ -217,13 +218,13 @@
positionedLatch.await(1, TimeUnit.SECONDS)
assertEquals(
- PxSize(size * columns, size * rows),
+ IntPxSize(size * columns, size * rows),
tableSize.value
)
for (i in 0 until rows) {
for (j in 0 until columns) {
assertEquals(
- PxSize(size, size),
+ IntPxSize(size, size),
childSize[i][j].value
)
assertEquals(
@@ -244,8 +245,8 @@
val tableWidth = 256.ipx
val tableWidthDp = tableWidth.toDp()
- val tableSize = Ref<PxSize>()
- val childSize = Array(rows) { Array(columns) { Ref<PxSize>() } }
+ val tableSize = Ref<IntPxSize>()
+ val childSize = Array(rows) { Array(columns) { Ref<IntPxSize>() } }
val childPosition = Array(rows) { Array(columns) { Ref<PxPosition>() } }
val positionedLatch = CountDownLatch(rows * columns + 1)
@@ -286,13 +287,13 @@
val availableSpace = (tableWidth - size * columns).coerceAtLeast(IntPx.Zero)
assertEquals(
- PxSize(size * columns, size * rows),
+ IntPxSize(size * columns, size * rows),
tableSize.value
)
for (i in 0 until rows) {
for (j in 0 until columns) {
assertEquals(
- PxSize(size, size),
+ IntPxSize(size, size),
childSize[i][j].value
)
assertEquals(
@@ -313,8 +314,8 @@
val size = 64.ipx
val sizeDp = size.toDp()
- val tableSize = Ref<PxSize>()
- val childSize = Array(rows) { Array(columns) { Ref<PxSize>() } }
+ val tableSize = Ref<IntPxSize>()
+ val childSize = Array(rows) { Array(columns) { Ref<IntPxSize>() } }
val childPosition = Array(rows) { Array(columns) { Ref<PxPosition>() } }
val positionedLatch = CountDownLatch(rows * columns + 1)
@@ -349,13 +350,13 @@
positionedLatch.await(1, TimeUnit.SECONDS)
assertEquals(
- PxSize(size * columns, size * rows),
+ IntPxSize(size * columns, size * rows),
tableSize.value
)
for (i in 0 until rows) {
for (j in 0 until columns) {
assertEquals(
- PxSize(size, size),
+ IntPxSize(size, size),
childSize[i][j].value
)
assertEquals(
@@ -374,8 +375,8 @@
val size = 64.ipx
val sizeDp = size.toDp()
- val tableSize = Ref<PxSize>()
- val childSize = Array(rows) { Array(columns) { Ref<PxSize>() } }
+ val tableSize = Ref<IntPxSize>()
+ val childSize = Array(rows) { Array(columns) { Ref<IntPxSize>() } }
val childPosition = Array(rows) { Array(columns) { Ref<PxPosition>() } }
val positionedLatch = CountDownLatch(rows * columns + 1)
@@ -410,13 +411,13 @@
positionedLatch.await(1, TimeUnit.SECONDS)
assertEquals(
- PxSize(size * columns, size * rows),
+ IntPxSize(size * columns, size * rows),
tableSize.value
)
for (i in 0 until rows) {
for (j in 0 until columns) {
assertEquals(
- PxSize(size, size),
+ IntPxSize(size, size),
childSize[i][j].value
)
assertEquals(
@@ -435,8 +436,8 @@
val size = 64.ipx
val sizeDp = size.toDp()
- val tableSize = Ref<PxSize>()
- val childSize = Array(rows) { Array(columns) { Ref<PxSize>() } }
+ val tableSize = Ref<IntPxSize>()
+ val childSize = Array(rows) { Array(columns) { Ref<IntPxSize>() } }
val childPosition = Array(rows) { Array(columns) { Ref<PxPosition>() } }
val positionedLatch = CountDownLatch(rows * columns + 1)
@@ -471,13 +472,13 @@
positionedLatch.await(1, TimeUnit.SECONDS)
assertEquals(
- PxSize(size * columns, size * rows),
+ IntPxSize(size * columns, size * rows),
tableSize.value
)
for (i in 0 until rows) {
for (j in 0 until columns) {
assertEquals(
- PxSize(size, size),
+ IntPxSize(size, size),
childSize[i][j].value
)
assertEquals(
@@ -498,8 +499,8 @@
val tableWidth = 256.ipx
val tableWidthDp = tableWidth.toDp()
- val tableSize = Ref<PxSize>()
- val childSize = Array(rows) { Array(columns) { Ref<PxSize>() } }
+ val tableSize = Ref<IntPxSize>()
+ val childSize = Array(rows) { Array(columns) { Ref<IntPxSize>() } }
val childPosition = Array(rows) { Array(columns) { Ref<PxPosition>() } }
val positionedLatch = CountDownLatch(rows * columns + 1)
@@ -537,13 +538,13 @@
positionedLatch.await(1, TimeUnit.SECONDS)
assertEquals(
- PxSize(tableWidth * fractions.sum(), size * rows),
+ IntPxSize(tableWidth * fractions.sum(), size * rows),
tableSize.value
)
for (i in 0 until rows) {
for (j in 0 until columns) {
assertEquals(
- PxSize(tableWidth * fractions[j], size),
+ IntPxSize(tableWidth * fractions[j], size),
childSize[i][j].value
)
assertEquals(
@@ -566,8 +567,8 @@
val tableWidth = 256.ipx
val tableWidthDp = tableWidth.toDp()
- val tableSize = Ref<PxSize>()
- val childSize = Array(rows) { Array(columns) { Ref<PxSize>() } }
+ val tableSize = Ref<IntPxSize>()
+ val childSize = Array(rows) { Array(columns) { Ref<IntPxSize>() } }
val childPosition = Array(rows) { Array(columns) { Ref<PxPosition>() } }
val positionedLatch = CountDownLatch(rows * columns + 1)
@@ -612,13 +613,13 @@
}
assertEquals(
- PxSize(expectedWidths.sum(), size * rows),
+ IntPxSize(expectedWidths.sum(), size * rows),
tableSize.value
)
for (i in 0 until rows) {
for (j in 0 until columns) {
assertEquals(
- PxSize(expectedWidths[j], size),
+ IntPxSize(expectedWidths[j], size),
childSize[i][j].value
)
assertEquals(
@@ -641,8 +642,8 @@
val tableWidth = 256.ipx
val tableWidthDp = tableWidth.toDp()
- val tableSize = Ref<PxSize>()
- val childSize = Array(rows) { Array(columns) { Ref<PxSize>() } }
+ val tableSize = Ref<IntPxSize>()
+ val childSize = Array(rows) { Array(columns) { Ref<IntPxSize>() } }
val childPosition = Array(rows) { Array(columns) { Ref<PxPosition>() } }
val positionedLatch = CountDownLatch(rows * columns + 1)
@@ -687,13 +688,13 @@
}
assertEquals(
- PxSize(expectedWidths.sum(), size * rows),
+ IntPxSize(expectedWidths.sum(), size * rows),
tableSize.value
)
for (i in 0 until rows) {
for (j in 0 until columns) {
assertEquals(
- PxSize(expectedWidths[j], size),
+ IntPxSize(expectedWidths[j], size),
childSize[i][j].value
)
assertEquals(
@@ -714,8 +715,8 @@
val halfSize = 32.ipx
val halfSizeDp = halfSize.toDp()
- val tableSize = Ref<PxSize>()
- val childSize = Array(rows) { Array(columns) { Ref<PxSize>() } }
+ val tableSize = Ref<IntPxSize>()
+ val childSize = Array(rows) { Array(columns) { Ref<IntPxSize>() } }
val childPosition = Array(rows) { Array(columns) { Ref<PxPosition>() } }
val positionedLatch = CountDownLatch(rows * columns + 1)
@@ -752,13 +753,13 @@
positionedLatch.await(1, TimeUnit.SECONDS)
assertEquals(
- PxSize(halfSize * columns, size * rows),
+ IntPxSize(halfSize * columns, size * rows),
tableSize.value
)
for (i in 0 until rows) {
for (j in 0 until columns) {
assertEquals(
- PxSize(halfSize, size),
+ IntPxSize(halfSize, size),
childSize[i][j].value
)
assertEquals(
@@ -779,8 +780,8 @@
val halfSize = 32.ipx
val halfSizeDp = halfSize.toDp()
- val tableSize = Ref<PxSize>()
- val childSize = Array(rows) { Array(columns) { Ref<PxSize>() } }
+ val tableSize = Ref<IntPxSize>()
+ val childSize = Array(rows) { Array(columns) { Ref<IntPxSize>() } }
val childPosition = Array(rows) { Array(columns) { Ref<PxPosition>() } }
val positionedLatch = CountDownLatch(rows * columns + 1)
@@ -817,13 +818,13 @@
positionedLatch.await(1, TimeUnit.SECONDS)
assertEquals(
- PxSize(size * columns, size * rows),
+ IntPxSize(size * columns, size * rows),
tableSize.value
)
for (i in 0 until rows) {
for (j in 0 until columns) {
assertEquals(
- PxSize(halfSize, size),
+ IntPxSize(halfSize, size),
childSize[i][j].value
)
assertEquals(
@@ -842,8 +843,8 @@
val size = 64.ipx
val sizeDp = size.toDp()
- val tableSize = Ref<PxSize>()
- val childSize = Array(rows) { Array(columns) { Ref<PxSize>() } }
+ val tableSize = Ref<IntPxSize>()
+ val childSize = Array(rows) { Array(columns) { Ref<IntPxSize>() } }
val childPosition = Array(rows) { Array(columns) { Ref<PxPosition>() } }
val positionedLatch = CountDownLatch(rows * columns + 1)
@@ -877,13 +878,13 @@
positionedLatch.await(1, TimeUnit.SECONDS)
assertEquals(
- PxSize(size * columns, size * rows),
+ IntPxSize(size * columns, size * rows),
tableSize.value
)
for (i in 0 until rows) {
for (j in 0 until columns) {
assertEquals(
- PxSize(size, size),
+ IntPxSize(size, size),
childSize[i][j].value
)
assertEquals(
@@ -902,8 +903,8 @@
val size = 64.ipx
val sizeDp = size.toDp()
- val tableSize = Ref<PxSize>()
- val childSize = Array(rows) { Array(columns) { Ref<PxSize>() } }
+ val tableSize = Ref<IntPxSize>()
+ val childSize = Array(rows) { Array(columns) { Ref<IntPxSize>() } }
val childPosition = Array(rows) { Array(columns) { Ref<PxPosition>() } }
val positionedLatch = CountDownLatch(rows * columns + 1)
@@ -937,13 +938,13 @@
positionedLatch.await(1, TimeUnit.SECONDS)
assertEquals(
- PxSize(size * columns, size * rows),
+ IntPxSize(size * columns, size * rows),
tableSize.value
)
for (i in 0 until rows) {
for (j in 0 until columns) {
assertEquals(
- PxSize(size, size),
+ IntPxSize(size, size),
childSize[i][j].value
)
assertEquals(
@@ -964,8 +965,8 @@
val halfSize = 32.ipx
val halfSizeDp = halfSize.toDp()
- val tableSize = Ref<PxSize>()
- val childSize = Array(rows) { Array(columns) { Ref<PxSize>() } }
+ val tableSize = Ref<IntPxSize>()
+ val childSize = Array(rows) { Array(columns) { Ref<IntPxSize>() } }
val childPosition = Array(rows) { Array(columns) { Ref<PxPosition>() } }
val positionedLatch = CountDownLatch(rows * columns + 1)
@@ -1010,13 +1011,13 @@
positionedLatch.await(1, TimeUnit.SECONDS)
assertEquals(
- PxSize(size * columns, size * rows),
+ IntPxSize(size * columns, size * rows),
tableSize.value
)
for (i in 0 until rows) {
for (j in 0 until columns) {
assertEquals(
- PxSize(if (i == 0) size else halfSize, size),
+ IntPxSize(if (i == 0) size else halfSize, size),
childSize[i][j].value
)
assertEquals(
@@ -1039,8 +1040,8 @@
val tableWidth = 256.ipx
val tableWidthDp = tableWidth.toDp()
- val tableSize = Ref<PxSize>()
- val childSize = Array(rows) { Array(columns) { Ref<PxSize>() } }
+ val tableSize = Ref<IntPxSize>()
+ val childSize = Array(rows) { Array(columns) { Ref<IntPxSize>() } }
val childPosition = Array(rows) { Array(columns) { Ref<PxPosition>() } }
val positionedLatch = CountDownLatch(rows * columns + 1)
@@ -1077,13 +1078,13 @@
positionedLatch.await(1, TimeUnit.SECONDS)
assertEquals(
- PxSize(tableWidth, size * rows),
+ IntPxSize(tableWidth, size * rows),
tableSize.value
)
for (i in 0 until rows) {
for (j in 0 until columns) {
assertEquals(
- PxSize(tableWidth / columns, if (j % 2 == 0) size else halfSize),
+ IntPxSize(tableWidth / columns, if (j % 2 == 0) size else halfSize),
childSize[i][j].value
)
assertEquals(
@@ -1106,8 +1107,8 @@
val tableWidth = 256.ipx
val tableWidthDp = tableWidth.toDp()
- val tableSize = Ref<PxSize>()
- val childSize = Array(rows) { Array(columns) { Ref<PxSize>() } }
+ val tableSize = Ref<IntPxSize>()
+ val childSize = Array(rows) { Array(columns) { Ref<IntPxSize>() } }
val childPosition = Array(rows) { Array(columns) { Ref<PxPosition>() } }
val positionedLatch = CountDownLatch(rows * columns + 1)
@@ -1153,13 +1154,13 @@
positionedLatch.await(1, TimeUnit.SECONDS)
assertEquals(
- PxSize(tableWidth, size * rows),
+ IntPxSize(tableWidth, size * rows),
tableSize.value
)
for (i in 0 until rows) {
// Wrap column 0
assertEquals(
- PxSize(halfSize, size),
+ IntPxSize(halfSize, size),
childSize[i][0].value
)
assertEquals(
@@ -1168,7 +1169,7 @@
)
// Flex column 1
assertEquals(
- PxSize((tableWidth / 2 - size - halfSize) / 4, size),
+ IntPxSize((tableWidth / 2 - size - halfSize) / 4, size),
childSize[i][1].value
)
assertEquals(
@@ -1177,7 +1178,7 @@
)
// Flex column 2
assertEquals(
- PxSize((tableWidth / 2 - size - halfSize) * 3 / 4, size),
+ IntPxSize((tableWidth / 2 - size - halfSize) * 3 / 4, size),
childSize[i][2].value
)
assertEquals(
@@ -1186,7 +1187,7 @@
)
// Fixed column 3
assertEquals(
- PxSize(size, size),
+ IntPxSize(size, size),
childSize[i][3].value
)
assertEquals(
@@ -1195,7 +1196,7 @@
)
// Fraction column 4
assertEquals(
- PxSize(tableWidth / 2, size),
+ IntPxSize(tableWidth / 2, size),
childSize[i][4].value
)
assertEquals(
@@ -1216,10 +1217,10 @@
val tableWidth = 256.ipx
val tableWidthDp = tableWidth.toDp()
- val tableSize = Ref<PxSize>()
- val decorationSize = Array(decorations) { Ref<PxSize>() }
+ val tableSize = Ref<IntPxSize>()
+ val decorationSize = Array(decorations) { Ref<IntPxSize>() }
val decorationPosition = Array(decorations) { Ref<PxPosition>() }
- val childSize = Array(rows) { Array(columns) { Ref<PxSize>() } }
+ val childSize = Array(rows) { Array(columns) { Ref<IntPxSize>() } }
val childPosition = Array(rows) { Array(columns) { Ref<PxPosition>() } }
val tableLatch = CountDownLatch(1)
val decorationsLatch = CountDownLatch(decorations)
@@ -1268,12 +1269,12 @@
itemsLatch.await(1, TimeUnit.SECONDS)
assertEquals(
- PxSize(tableWidth, size * rows),
+ IntPxSize(tableWidth, size * rows),
tableSize.value
)
for (i in 0 until decorations) {
assertEquals(
- PxSize(tableWidth, size * rows),
+ IntPxSize(tableWidth, size * rows),
decorationSize[i].value
)
assertEquals(
@@ -1284,7 +1285,7 @@
for (i in 0 until rows) {
for (j in 0 until columns) {
assertEquals(
- PxSize(tableWidth / columns, size),
+ IntPxSize(tableWidth / columns, size),
childSize[i][j].value
)
assertEquals(
diff --git a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/WrapTest.kt b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/WrapTest.kt
index baf3c92..6522a43 100644
--- a/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/WrapTest.kt
+++ b/ui/ui-layout/src/androidTest/java/androidx/ui/layout/test/WrapTest.kt
@@ -34,11 +34,12 @@
import androidx.ui.layout.LayoutWrapped
import androidx.ui.layout.Wrap
import androidx.ui.unit.IntPx
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.PxSize
import androidx.ui.unit.dp
import androidx.ui.unit.px
import androidx.ui.unit.withDensity
+import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.runners.JUnit4
@@ -54,8 +55,8 @@
val size = sizeDp.toIntPx()
val positionedLatch = CountDownLatch(2)
- val wrapSize = Ref<PxSize>()
- val childSize = Ref<PxSize>()
+ val wrapSize = Ref<IntPxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Align(alignment = Alignment.TopLeft) {
@@ -77,8 +78,8 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(size, size), wrapSize.value)
- assertEquals(PxSize(size, size), childSize.value)
+ assertEquals(IntPxSize(size, size), wrapSize.value)
+ assertEquals(IntPxSize(size, size), childSize.value)
assertEquals(PxPosition(0.px, 0.px), childPosition.value)
}
@@ -88,7 +89,7 @@
val size = sizeDp.toIntPx()
val positionedLatch = CountDownLatch(2)
- val wrapSize = Ref<PxSize>()
+ val wrapSize = Ref<IntPxSize>()
show {
Container(LayoutWrapped) {
OnPositioned( coordinates ->
@@ -100,7 +101,7 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(size, size), wrapSize.value)
+ assertEquals(IntPxSize(size, size), wrapSize.value)
}
@Test
@@ -111,8 +112,8 @@
val doubleSize = doubleSizeDp.toIntPx()
val positionedLatch = CountDownLatch(2)
- val wrapSize = Ref<PxSize>()
- val childSize = Ref<PxSize>()
+ val wrapSize = Ref<IntPxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Align(alignment = Alignment.TopLeft) {
@@ -138,8 +139,8 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(doubleSize, doubleSize), wrapSize.value)
- assertEquals(PxSize(size, size), childSize.value)
+ assertEquals(IntPxSize(doubleSize, doubleSize), wrapSize.value)
+ assertEquals(IntPxSize(size, size), childSize.value)
assertEquals(PxPosition(0.px, 0.px), childPosition.value)
}
@@ -151,8 +152,8 @@
val doubleSize = doubleSizeDp.toIntPx()
val positionedLatch = CountDownLatch(2)
- val wrapSize = Ref<PxSize>()
- val childSize = Ref<PxSize>()
+ val wrapSize = Ref<IntPxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Container(LayoutAlign.TopLeft) {
@@ -187,8 +188,8 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(doubleSize, doubleSize), wrapSize.value)
- assertEquals(PxSize(size, size), childSize.value)
+ assertEquals(IntPxSize(doubleSize, doubleSize), wrapSize.value)
+ assertEquals(IntPxSize(size, size), childSize.value)
assertEquals(
PxPosition((doubleSize - size) / 2, (doubleSize - size) / 2),
childPosition.value
@@ -203,8 +204,8 @@
val doubleSize = doubleSizeDp.toIntPx()
val positionedLatch = CountDownLatch(2)
- val wrapSize = Ref<PxSize>()
- val childSize = Ref<PxSize>()
+ val wrapSize = Ref<IntPxSize>()
+ val childSize = Ref<IntPxSize>()
val childPosition = Ref<PxPosition>()
show {
Align(alignment = Alignment.TopLeft) {
@@ -232,8 +233,8 @@
}
positionedLatch.await(1, TimeUnit.SECONDS)
- assertEquals(PxSize(doubleSize, doubleSize), wrapSize.value)
- assertEquals(PxSize(size, size), childSize.value)
+ assertEquals(IntPxSize(doubleSize, doubleSize), wrapSize.value)
+ assertEquals(IntPxSize(size, size), childSize.value)
assertEquals(PxPosition(size / 2, size / 2), childPosition.value)
}
diff --git a/ui/ui-material/api/0.1.0-dev04.txt b/ui/ui-material/api/0.1.0-dev04.txt
index 86ed512..c012ab5 100644
--- a/ui/ui-material/api/0.1.0-dev04.txt
+++ b/ui/ui-material/api/0.1.0-dev04.txt
@@ -23,8 +23,8 @@
}
public static final class BottomAppBar.FabConfiguration {
- ctor public BottomAppBar.FabConfiguration(internal androidx.ui.unit.PxSize fabSize, internal androidx.ui.unit.PxPosition fabTopLeftPosition, internal androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
- method public androidx.ui.material.BottomAppBar.FabConfiguration copy(androidx.ui.unit.PxSize fabSize, androidx.ui.unit.PxPosition fabTopLeftPosition, androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
+ ctor public BottomAppBar.FabConfiguration(internal androidx.ui.unit.IntPxSize fabSize, internal androidx.ui.unit.PxPosition fabTopLeftPosition, internal androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
+ method public androidx.ui.material.BottomAppBar.FabConfiguration copy(androidx.ui.unit.IntPxSize fabSize, androidx.ui.unit.PxPosition fabTopLeftPosition, androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
}
public enum BottomAppBar.FabDockedPosition {
diff --git a/ui/ui-material/api/current.txt b/ui/ui-material/api/current.txt
index 86ed512..c012ab5 100644
--- a/ui/ui-material/api/current.txt
+++ b/ui/ui-material/api/current.txt
@@ -23,8 +23,8 @@
}
public static final class BottomAppBar.FabConfiguration {
- ctor public BottomAppBar.FabConfiguration(internal androidx.ui.unit.PxSize fabSize, internal androidx.ui.unit.PxPosition fabTopLeftPosition, internal androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
- method public androidx.ui.material.BottomAppBar.FabConfiguration copy(androidx.ui.unit.PxSize fabSize, androidx.ui.unit.PxPosition fabTopLeftPosition, androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
+ ctor public BottomAppBar.FabConfiguration(internal androidx.ui.unit.IntPxSize fabSize, internal androidx.ui.unit.PxPosition fabTopLeftPosition, internal androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
+ method public androidx.ui.material.BottomAppBar.FabConfiguration copy(androidx.ui.unit.IntPxSize fabSize, androidx.ui.unit.PxPosition fabTopLeftPosition, androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
}
public enum BottomAppBar.FabDockedPosition {
diff --git a/ui/ui-material/api/public_plus_experimental_0.1.0-dev04.txt b/ui/ui-material/api/public_plus_experimental_0.1.0-dev04.txt
index 86ed512..c012ab5 100644
--- a/ui/ui-material/api/public_plus_experimental_0.1.0-dev04.txt
+++ b/ui/ui-material/api/public_plus_experimental_0.1.0-dev04.txt
@@ -23,8 +23,8 @@
}
public static final class BottomAppBar.FabConfiguration {
- ctor public BottomAppBar.FabConfiguration(internal androidx.ui.unit.PxSize fabSize, internal androidx.ui.unit.PxPosition fabTopLeftPosition, internal androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
- method public androidx.ui.material.BottomAppBar.FabConfiguration copy(androidx.ui.unit.PxSize fabSize, androidx.ui.unit.PxPosition fabTopLeftPosition, androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
+ ctor public BottomAppBar.FabConfiguration(internal androidx.ui.unit.IntPxSize fabSize, internal androidx.ui.unit.PxPosition fabTopLeftPosition, internal androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
+ method public androidx.ui.material.BottomAppBar.FabConfiguration copy(androidx.ui.unit.IntPxSize fabSize, androidx.ui.unit.PxPosition fabTopLeftPosition, androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
}
public enum BottomAppBar.FabDockedPosition {
diff --git a/ui/ui-material/api/public_plus_experimental_current.txt b/ui/ui-material/api/public_plus_experimental_current.txt
index 86ed512..c012ab5 100644
--- a/ui/ui-material/api/public_plus_experimental_current.txt
+++ b/ui/ui-material/api/public_plus_experimental_current.txt
@@ -23,8 +23,8 @@
}
public static final class BottomAppBar.FabConfiguration {
- ctor public BottomAppBar.FabConfiguration(internal androidx.ui.unit.PxSize fabSize, internal androidx.ui.unit.PxPosition fabTopLeftPosition, internal androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
- method public androidx.ui.material.BottomAppBar.FabConfiguration copy(androidx.ui.unit.PxSize fabSize, androidx.ui.unit.PxPosition fabTopLeftPosition, androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
+ ctor public BottomAppBar.FabConfiguration(internal androidx.ui.unit.IntPxSize fabSize, internal androidx.ui.unit.PxPosition fabTopLeftPosition, internal androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
+ method public androidx.ui.material.BottomAppBar.FabConfiguration copy(androidx.ui.unit.IntPxSize fabSize, androidx.ui.unit.PxPosition fabTopLeftPosition, androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
}
public enum BottomAppBar.FabDockedPosition {
diff --git a/ui/ui-material/api/restricted_0.1.0-dev04.txt b/ui/ui-material/api/restricted_0.1.0-dev04.txt
index 86ed512..c012ab5 100644
--- a/ui/ui-material/api/restricted_0.1.0-dev04.txt
+++ b/ui/ui-material/api/restricted_0.1.0-dev04.txt
@@ -23,8 +23,8 @@
}
public static final class BottomAppBar.FabConfiguration {
- ctor public BottomAppBar.FabConfiguration(internal androidx.ui.unit.PxSize fabSize, internal androidx.ui.unit.PxPosition fabTopLeftPosition, internal androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
- method public androidx.ui.material.BottomAppBar.FabConfiguration copy(androidx.ui.unit.PxSize fabSize, androidx.ui.unit.PxPosition fabTopLeftPosition, androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
+ ctor public BottomAppBar.FabConfiguration(internal androidx.ui.unit.IntPxSize fabSize, internal androidx.ui.unit.PxPosition fabTopLeftPosition, internal androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
+ method public androidx.ui.material.BottomAppBar.FabConfiguration copy(androidx.ui.unit.IntPxSize fabSize, androidx.ui.unit.PxPosition fabTopLeftPosition, androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
}
public enum BottomAppBar.FabDockedPosition {
diff --git a/ui/ui-material/api/restricted_current.txt b/ui/ui-material/api/restricted_current.txt
index 86ed512..c012ab5 100644
--- a/ui/ui-material/api/restricted_current.txt
+++ b/ui/ui-material/api/restricted_current.txt
@@ -23,8 +23,8 @@
}
public static final class BottomAppBar.FabConfiguration {
- ctor public BottomAppBar.FabConfiguration(internal androidx.ui.unit.PxSize fabSize, internal androidx.ui.unit.PxPosition fabTopLeftPosition, internal androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
- method public androidx.ui.material.BottomAppBar.FabConfiguration copy(androidx.ui.unit.PxSize fabSize, androidx.ui.unit.PxPosition fabTopLeftPosition, androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
+ ctor public BottomAppBar.FabConfiguration(internal androidx.ui.unit.IntPxSize fabSize, internal androidx.ui.unit.PxPosition fabTopLeftPosition, internal androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
+ method public androidx.ui.material.BottomAppBar.FabConfiguration copy(androidx.ui.unit.IntPxSize fabSize, androidx.ui.unit.PxPosition fabTopLeftPosition, androidx.ui.material.BottomAppBar.FabDockedPosition fabDockedPosition);
}
public enum BottomAppBar.FabDockedPosition {
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/AppBarTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/AppBarTest.kt
index eb56b05..f057a9d 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/AppBarTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/AppBarTest.kt
@@ -38,13 +38,12 @@
import androidx.ui.test.findAllByTag
import androidx.ui.test.findByText
import androidx.ui.text.TextStyle
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.Px
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.PxSize
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
import androidx.ui.unit.px
-import androidx.ui.unit.round
import androidx.ui.unit.sp
import androidx.ui.unit.toPx
import com.google.common.truth.Truth.assertThat
@@ -148,7 +147,7 @@
val actionPositionX = actionCoords!!.localToGlobal(PxPosition.Origin).x
val actionExpectedPositionX =
appBarCoords!!.size.width - 16.dp.toIntPx() - 24.dp.toIntPx()
- assertThat(actionPositionX).isEqualTo(actionExpectedPositionX)
+ assertThat(actionPositionX).isEqualTo(actionExpectedPositionX.toPx())
}
}
@@ -191,7 +190,7 @@
val actionPositionX = actionCoords!!.localToGlobal(PxPosition.Origin).x
val actionExpectedPositionX =
appBarCoords!!.size.width - 16.dp.toIntPx() - 24.dp.toIntPx()
- assertThat(actionPositionX).isEqualTo(actionExpectedPositionX)
+ assertThat(actionPositionX).isEqualTo(actionExpectedPositionX.toPx())
}
}
@@ -291,7 +290,7 @@
composeTestRule.runOnIdleComposeWithDensity {
// Action should still be placed at the end, even though there is no navigation icon
val actionPositionX = actionCoords!!.localToGlobal(PxPosition.Origin).x
- val actionExpectedPositionX = appBarCoords!!.size.width.round().toPx() -
+ val actionExpectedPositionX = appBarCoords!!.size.width.toPx() -
16.dp.toIntPx().toPx() - 24.dp.toIntPx().toPx()
assertThat(actionPositionX).isEqualTo(actionExpectedPositionX)
}
@@ -334,7 +333,7 @@
// Action should be placed at the end
val actionPositionX = actionCoords!!.localToGlobal(PxPosition.Origin).x
- val actionExpectedPositionX = appBarCoords!!.size.width.round().toPx() -
+ val actionExpectedPositionX = appBarCoords!!.size.width.toPx() -
16.dp.toIntPx().toPx() - 24.dp.toIntPx().toPx()
assertThat(actionPositionX).isEqualTo(actionExpectedPositionX)
}
@@ -379,7 +378,7 @@
// Action should be placed at the end
val actionPositionX = actionCoords!!.localToGlobal(PxPosition.Origin).x
- val actionExpectedPositionX = appBarCoords!!.size.width.round().toPx() -
+ val actionExpectedPositionX = appBarCoords!!.size.width.toPx() -
16.dp.toIntPx().toPx() - 24.dp.toIntPx().toPx()
assertThat(actionPositionX).isEqualTo(actionExpectedPositionX)
}
@@ -425,7 +424,7 @@
// Action should be placed at the end
val actionPositionX = actionCoords!!.localToGlobal(PxPosition.Origin).x
- val actionExpectedPositionX = appBarCoords!!.size.width.round().toPx() -
+ val actionExpectedPositionX = appBarCoords!!.size.width.toPx() -
16.dp.toIntPx().toPx() - 24.dp.toIntPx().toPx()
assertThat(actionPositionX).isEqualTo(actionExpectedPositionX)
}
@@ -536,7 +535,7 @@
private fun createFabConfiguration(position: FabDockedPosition) =
FabConfiguration(
- fabSize = PxSize(100.px, 100.px),
+ fabSize = IntPxSize(100.ipx, 100.ipx),
fabTopLeftPosition = PxPosition(0.px, 0.px),
// all what matters here is a fabDockedPosition, as it will decide the layout
fabDockedPosition = position
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerTest.kt
index 6e14874..8bd5384 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerTest.kt
@@ -30,9 +30,9 @@
import androidx.ui.test.findByTag
import androidx.ui.test.globalBounds
import androidx.ui.test.sendClick
-import androidx.ui.unit.Px
+import androidx.ui.unit.IntPx
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.PxSize
import androidx.ui.unit.dp
import androidx.ui.unit.height
import androidx.ui.unit.px
@@ -94,7 +94,7 @@
@Test
fun modalDrawer_testEndPadding_whenOpened() {
- var size: PxSize? = null
+ var size: IntPxSize? = null
composeTestRule.setMaterialContent {
ModalDrawerLayout(DrawerState.Opened, {}, drawerContent = {
Container(expanded = true) {
@@ -107,7 +107,7 @@
val width = composeTestRule.displayMetrics.widthPixels
composeTestRule.runOnIdleComposeWithDensity {
- assertThat(size!!.width.round().value)
+ assertThat(size!!.width.value)
.isEqualTo(width - 56.dp.toPx().round().value)
}
}
@@ -165,7 +165,7 @@
@Test
fun modalDrawer_openAndClose() {
- var contentWidth: Px? = null
+ var contentWidth: IntPx? = null
var openedLatch: CountDownLatch? = null
var closedLatch: CountDownLatch? = CountDownLatch(1)
val drawerState = DrawerStateHolder(DrawerState.Closed)
@@ -175,11 +175,11 @@
ModalDrawerLayout(drawerState.state, { drawerState.state = it },
drawerContent = {
OnChildPositioned({ info ->
- val pos = info.localToGlobal(info.position)
+ val pos = info.localToGlobal(PxPosition.Origin)
if (pos.x == 0.px) {
// If fully opened, mark the openedLatch if present
openedLatch?.countDown()
- } else if (-pos.x == contentWidth) {
+ } else if (-pos.x.round() == contentWidth) {
// If fully closed, mark the closedLatch if present
closedLatch?.countDown()
}
@@ -265,8 +265,8 @@
@Test
fun bottomDrawer_openAndClose() {
- var contentHeight: Px? = null
- var openedHeight: Px? = null
+ var contentHeight: IntPx? = null
+ var openedHeight: IntPx? = null
var openedLatch: CountDownLatch? = null
var closedLatch: CountDownLatch? = CountDownLatch(1)
val drawerState = DrawerStateHolder(DrawerState.Closed)
@@ -276,11 +276,11 @@
BottomDrawerLayout(drawerState.state, { drawerState.state = it },
drawerContent = {
OnChildPositioned({ info ->
- val pos = info.localToGlobal(info.position)
- if (pos.y == openedHeight) {
+ val pos = info.localToGlobal(PxPosition.Origin)
+ if (pos.y.round() == openedHeight) {
// If fully opened, mark the openedLatch if present
openedLatch?.countDown()
- } else if (pos.y == contentHeight) {
+ } else if (pos.y.round() == contentHeight) {
// If fully closed, mark the closedLatch if present
closedLatch?.countDown()
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ListItemTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/ListItemTest.kt
index 0f6f6621..a61d676 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/ListItemTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/ListItemTest.kt
@@ -28,13 +28,12 @@
import androidx.ui.layout.Container
import androidx.ui.test.createComposeRule
import androidx.ui.unit.Dp
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.Px
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.PxSize
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
import androidx.ui.unit.px
-import androidx.ui.unit.round
import androidx.ui.unit.toPx
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
@@ -192,9 +191,9 @@
val expectedRightPadding = 16.dp
val textPosition = Ref<PxPosition>()
- val textSize = Ref<PxSize>()
+ val textSize = Ref<IntPxSize>()
val trailingPosition = Ref<PxPosition>()
- val trailingSize = Ref<PxSize>()
+ val trailingSize = Ref<IntPxSize>()
composeTestRule.setMaterialContent {
Container(alignment = Alignment.TopLeft) {
ListItem(
@@ -208,7 +207,7 @@
composeTestRule.runOnIdleComposeWithDensity {
assertThat(textPosition.value!!.x).isEqualTo(expectedLeftPadding.toIntPx().toPx())
assertThat(textPosition.value!!.y).isEqualTo(
- ((listItemHeight.toIntPx() - textSize.value!!.height.round()) / 2).toPx()
+ ((listItemHeight.toIntPx() - textSize.value!!.height) / 2).toPx()
)
val dm = composeTestRule.displayMetrics
assertThat(trailingPosition.value!!.x).isEqualTo(
@@ -216,7 +215,7 @@
expectedRightPadding.toIntPx().toPx()
)
assertThat(trailingPosition.value!!.y).isEqualTo(
- ((listItemHeight.toIntPx() - trailingSize.value!!.height.round()) / 2).toPx()
+ ((listItemHeight.toIntPx() - trailingSize.value!!.height) / 2).toPx()
)
}
}
@@ -228,9 +227,9 @@
val expectedTextLeftPadding = 32.dp
val textPosition = Ref<PxPosition>()
- val textSize = Ref<PxSize>()
+ val textSize = Ref<IntPxSize>()
val iconPosition = Ref<PxPosition>()
- val iconSize = Ref<PxSize>()
+ val iconSize = Ref<IntPxSize>()
composeTestRule.setMaterialContent {
Container(alignment = Alignment.TopLeft) {
ListItem(
@@ -242,14 +241,14 @@
composeTestRule.runOnIdleComposeWithDensity {
assertThat(iconPosition.value!!.x).isEqualTo(expectedLeftPadding.toIntPx().toPx())
assertThat(iconPosition.value!!.y).isEqualTo(
- ((listItemHeight.toIntPx() - iconSize.value!!.height.round()) / 2).toPx()
+ ((listItemHeight.toIntPx() - iconSize.value!!.height) / 2).toPx()
)
assertThat(textPosition.value!!.x).isEqualTo(
expectedLeftPadding.toIntPx().toPx() + iconSize.value!!.width +
expectedTextLeftPadding.toIntPx().toPx()
)
assertThat(textPosition.value!!.y).isEqualTo(
- ((listItemHeight.toIntPx() - textSize.value!!.height.round()) / 2).toPx()
+ ((listItemHeight.toIntPx() - textSize.value!!.height) / 2).toPx()
)
}
}
@@ -263,13 +262,13 @@
val textPosition = Ref<PxPosition>()
val textBaseline = Ref<Px>()
- val textSize = Ref<PxSize>()
+ val textSize = Ref<IntPxSize>()
val secondaryTextPosition = Ref<PxPosition>()
val secondaryTextBaseline = Ref<Px>()
- val secondaryTextSize = Ref<PxSize>()
+ val secondaryTextSize = Ref<IntPxSize>()
val trailingPosition = Ref<PxPosition>()
val trailingBaseline = Ref<Px>()
- val trailingSize = Ref<PxSize>()
+ val trailingSize = Ref<IntPxSize>()
composeTestRule.setMaterialContent {
Container(alignment = Alignment.TopLeft) {
ListItem(
@@ -326,12 +325,12 @@
val textPosition = Ref<PxPosition>()
val textBaseline = Ref<Px>()
- val textSize = Ref<PxSize>()
+ val textSize = Ref<IntPxSize>()
val secondaryTextPosition = Ref<PxPosition>()
val secondaryTextBaseline = Ref<Px>()
- val secondaryTextSize = Ref<PxSize>()
+ val secondaryTextSize = Ref<IntPxSize>()
val iconPosition = Ref<PxPosition>()
- val iconSize = Ref<PxSize>()
+ val iconSize = Ref<IntPxSize>()
composeTestRule.setMaterialContent {
Container(alignment = Alignment.TopLeft) {
ListItem(
@@ -388,14 +387,14 @@
val textPosition = Ref<PxPosition>()
val textBaseline = Ref<Px>()
- val textSize = Ref<PxSize>()
+ val textSize = Ref<IntPxSize>()
val secondaryTextPosition = Ref<PxPosition>()
val secondaryTextBaseline = Ref<Px>()
- val secondaryTextSize = Ref<PxSize>()
+ val secondaryTextSize = Ref<IntPxSize>()
val iconPosition = Ref<PxPosition>()
- val iconSize = Ref<PxSize>()
+ val iconSize = Ref<IntPxSize>()
val trailingPosition = Ref<PxPosition>()
- val trailingSize = Ref<PxSize>()
+ val trailingSize = Ref<IntPxSize>()
composeTestRule.setMaterialContent {
Container(alignment = Alignment.TopLeft) {
ListItem(
@@ -446,7 +445,7 @@
expectedRightPadding.toIntPx().toPx()
)
assertThat(trailingPosition.value!!.y).isEqualTo(
- ((listItemHeight.toIntPx() - trailingSize.value!!.height.round()) / 2).toPx()
+ ((listItemHeight.toIntPx() - trailingSize.value!!.height) / 2).toPx()
)
}
}
@@ -462,14 +461,14 @@
val textPosition = Ref<PxPosition>()
val textBaseline = Ref<Px>()
- val textSize = Ref<PxSize>()
+ val textSize = Ref<IntPxSize>()
val secondaryTextPosition = Ref<PxPosition>()
val secondaryTextBaseline = Ref<Px>()
- val secondaryTextSize = Ref<PxSize>()
+ val secondaryTextSize = Ref<IntPxSize>()
val iconPosition = Ref<PxPosition>()
- val iconSize = Ref<PxSize>()
+ val iconSize = Ref<IntPxSize>()
val trailingPosition = Ref<PxPosition>()
- val trailingSize = Ref<PxSize>()
+ val trailingSize = Ref<IntPxSize>()
composeTestRule.setMaterialContent {
Container(alignment = Alignment.TopLeft) {
ListItem(
@@ -538,17 +537,17 @@
val textPosition = Ref<PxPosition>()
val textBaseline = Ref<Px>()
- val textSize = Ref<PxSize>()
+ val textSize = Ref<IntPxSize>()
val overlineTextPosition = Ref<PxPosition>()
val overlineTextBaseline = Ref<Px>()
- val overlineTextSize = Ref<PxSize>()
+ val overlineTextSize = Ref<IntPxSize>()
val secondaryTextPosition = Ref<PxPosition>()
val secondaryTextBaseline = Ref<Px>()
- val secondaryTextSize = Ref<PxSize>()
+ val secondaryTextSize = Ref<IntPxSize>()
val iconPosition = Ref<PxPosition>()
- val iconSize = Ref<PxSize>()
+ val iconSize = Ref<IntPxSize>()
val trailingPosition = Ref<PxPosition>()
- val trailingSize = Ref<PxSize>()
+ val trailingSize = Ref<IntPxSize>()
val trailingBaseline = Ref<Px>()
composeTestRule.setMaterialContent {
Container(alignment = Alignment.TopLeft) {
@@ -636,7 +635,7 @@
@Composable
private fun SaveLayout(
coords: Ref<PxPosition>,
- size: Ref<PxSize>,
+ size: Ref<IntPxSize>,
baseline: Ref<Px> = Ref(),
children: @Composable() () -> Unit
) {
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt
index b004687..48945d7 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/ScaffoldTest.kt
@@ -27,10 +27,11 @@
import androidx.ui.test.createComposeRule
import androidx.ui.test.doGesture
import androidx.ui.test.findByTag
+import androidx.ui.test.positionInParent
import androidx.ui.test.sendSwipeLeft
import androidx.ui.test.sendSwipeRight
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.PxSize
import androidx.ui.unit.dp
import androidx.ui.unit.px
import com.google.common.truth.Truth.assertThat
@@ -69,12 +70,12 @@
composeTestRule.setMaterialContent {
Scaffold {
OnChildPositioned({ positioned ->
- child1 = positioned.position
+ child1 = positioned.positionInParent
}) {
Text("One")
}
OnChildPositioned({ positioned ->
- child2 = positioned.position
+ child2 = positioned.positionInParent
}) {
Text("Two")
}
@@ -87,13 +88,13 @@
@Test
fun scaffold_AppbarAndContent_inColumn() {
lateinit var appbarPosition: PxPosition
- lateinit var appbarSize: PxSize
+ lateinit var appbarSize: IntPxSize
lateinit var contentPosition: PxPosition
composeTestRule.setMaterialContent {
Scaffold(
topAppBar = {
OnChildPositioned({ positioned ->
- appbarPosition = positioned.localToGlobal(positioned.position)
+ appbarPosition = positioned.localToGlobal(PxPosition.Origin)
appbarSize = positioned.size
}) {
ColoredRect(Color.Red, height = 50.dp)
@@ -101,7 +102,7 @@
}
) {
OnChildPositioned({ positioned ->
- contentPosition = positioned.localToGlobal(positioned.position)
+ contentPosition = positioned.localToGlobal(PxPosition.Origin)
}) {
ColoredRect(Color.Blue, height = 50.dp)
}
@@ -113,14 +114,14 @@
@Test
fun scaffold_bottomBarAndContent_inStack() {
lateinit var appbarPosition: PxPosition
- lateinit var appbarSize: PxSize
+ lateinit var appbarSize: IntPxSize
lateinit var contentPosition: PxPosition
- lateinit var contentSize: PxSize
+ lateinit var contentSize: IntPxSize
composeTestRule.setMaterialContent {
Scaffold(
bottomAppBar = {
OnChildPositioned({ positioned ->
- appbarPosition = positioned.position
+ appbarPosition = positioned.positionInParent
appbarSize = positioned.size
}) {
ColoredRect(Color.Red, height = 50.dp)
@@ -128,7 +129,7 @@
}
) {
OnChildPositioned({ positioned ->
- contentPosition = positioned.position
+ contentPosition = positioned.positionInParent
contentSize = positioned.size
}) {
ColoredRect(Color.Blue, height = 50.dp)
@@ -152,7 +153,7 @@
scaffoldState = scaffoldState,
drawerContent = {
OnChildPositioned({ positioned ->
- drawerChildPosition = positioned.position
+ drawerChildPosition = positioned.positionInParent
}) {
ColoredRect(Color.Blue, height = 50.dp)
}
@@ -199,7 +200,7 @@
scaffoldState = scaffoldState,
drawerContent = {
OnChildPositioned({ positioned ->
- drawerChildPosition = positioned.position
+ drawerChildPosition = positioned.positionInParent
}) {
ColoredRect(Color.Blue, height = 50.dp)
}
@@ -252,14 +253,14 @@
@Test
fun scaffold_centerDockedFab_position() {
lateinit var fabPosition: PxPosition
- lateinit var fabSize: PxSize
+ lateinit var fabSize: IntPxSize
lateinit var bottomBarPosition: PxPosition
composeTestRule.setContent {
Scaffold(
floatingActionButton = {
OnChildPositioned({ positioned ->
fabSize = positioned.size
- fabPosition = positioned.localToGlobal(positioned.position)
+ fabPosition = positioned.localToGlobal(positioned.positionInParent)
}) {
FloatingActionButton("text")
}
@@ -267,7 +268,7 @@
floatingActionButtonPosition = Scaffold.FabPosition.CenterDocked,
bottomAppBar = {
OnChildPositioned({ positioned ->
- bottomBarPosition = positioned.localToGlobal(positioned.position)
+ bottomBarPosition = positioned.localToGlobal(positioned.positionInParent)
}) {
ColoredRect(Color.Red, height = 100.dp)
}
@@ -283,14 +284,14 @@
@Test
fun scaffold_endDockedFab_position() {
lateinit var fabPosition: PxPosition
- lateinit var fabSize: PxSize
+ lateinit var fabSize: IntPxSize
lateinit var bottomBarPosition: PxPosition
composeTestRule.setContent {
Scaffold(
floatingActionButton = {
OnChildPositioned({ positioned ->
fabSize = positioned.size
- fabPosition = positioned.localToGlobal(positioned.position)
+ fabPosition = positioned.localToGlobal(positioned.positionInParent)
}) {
FloatingActionButton("text")
}
@@ -298,7 +299,7 @@
floatingActionButtonPosition = Scaffold.FabPosition.EndDocked,
bottomAppBar = {
OnChildPositioned({ positioned ->
- bottomBarPosition = positioned.localToGlobal(positioned.position)
+ bottomBarPosition = positioned.localToGlobal(positioned.positionInParent)
}) {
ColoredRect(Color.Red, height = 100.dp)
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/SnackbarTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/SnackbarTest.kt
index f235524..fb3fd3b 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/SnackbarTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/SnackbarTest.kt
@@ -29,10 +29,12 @@
import androidx.ui.test.createComposeRule
import androidx.ui.test.doClick
import androidx.ui.test.findByText
+import androidx.ui.test.positionInParent
import androidx.ui.unit.IntPx
import androidx.ui.unit.PxPosition
import androidx.ui.unit.dp
import androidx.ui.unit.round
+import androidx.ui.unit.toPx
import androidx.ui.unit.withDensity
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
@@ -95,7 +97,7 @@
assertThat(alignmentLines.get(FirstBaseline)).isNotEqualTo(IntPx.Zero)
assertThat(alignmentLines.get(FirstBaseline))
.isEqualTo(alignmentLines.get(LastBaseline))
- assertThat(it.position.y.round() + alignmentLines.getValue(FirstBaseline))
+ assertThat(it.positionInParent.y.round() + alignmentLines.getValue(FirstBaseline))
.isEqualTo(30.dp.toIntPx())
}
}
@@ -190,7 +192,7 @@
assertThat(alignmentLines.get(LastBaseline)).isNotEqualTo(IntPx.Zero)
assertThat(alignmentLines.get(FirstBaseline))
.isNotEqualTo(alignmentLines.get(LastBaseline))
- assertThat(it.position.y.round() + alignmentLines.getValue(FirstBaseline))
+ assertThat(it.positionInParent.y.round() + alignmentLines.getValue(FirstBaseline))
.isEqualTo(30.dp.toIntPx())
}
}
@@ -246,7 +248,7 @@
textAlignmentLines.getValue(FirstBaseline)
).isEqualTo(30.dp.toIntPx())
- assertThat(buttonCenter).isEqualTo(localSnackCoords.size.height / 2)
+ assertThat(buttonCenter).isEqualTo((localSnackCoords.size.height / 2).toPx())
}
}
}
@@ -300,13 +302,13 @@
).isEqualTo(18.dp.toIntPx())
assertThat(
- localSnackCoords.size.height.round() - buttonPositionInSnack.y.round() -
- localButtonCoords.size.height.round()
+ localSnackCoords.size.height - buttonPositionInSnack.y.round() -
+ localButtonCoords.size.height
).isEqualTo(8.dp.toIntPx())
assertThat(
- localSnackCoords.size.width.round() - buttonPositionInSnack.x.round() -
- localButtonCoords.size.width.round()
+ localSnackCoords.size.width - buttonPositionInSnack.x.round() -
+ localButtonCoords.size.width
).isEqualTo(8.dp.toIntPx())
}
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/TabTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/TabTest.kt
index 7ea9408..db4b514 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/TabTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/TabTest.kt
@@ -145,7 +145,7 @@
assertThat(indicatorPositionX).isEqualTo(expectedPositionX)
val indicatorPositionY = indicatorCoords!!.localToGlobal(PxPosition.Origin).y
- val expectedPositionY = tabRowHeight - indicatorHeight.toIntPx().toPx()
+ val expectedPositionY = (tabRowHeight - indicatorHeight.toIntPx()).toPx()
assertThat(indicatorPositionY).isEqualTo(expectedPositionY)
tabRowWidth to tabRowHeight
@@ -160,10 +160,10 @@
withDensity(composeTestRule.density) {
val indicatorPositionX = indicatorCoords!!.localToGlobal(PxPosition.Origin).x
val expectedPositionX = tabRowWidth / 2
- assertThat(indicatorPositionX).isEqualTo(expectedPositionX)
+ assertThat(indicatorPositionX).isEqualTo(expectedPositionX.toPx())
val indicatorPositionY = indicatorCoords!!.localToGlobal(PxPosition.Origin).y
- val expectedPositionY = tabRowHeight - indicatorHeight.toIntPx().toPx()
+ val expectedPositionY = (tabRowHeight - indicatorHeight.toIntPx()).toPx()
assertThat(indicatorPositionY).isEqualTo(expectedPositionY)
}
}
@@ -216,7 +216,7 @@
assertThat(indicatorPositionX).isEqualTo(expectedPositionX)
val indicatorPositionY = indicatorCoords!!.localToGlobal(PxPosition.Origin).y
- val expectedPositionY = tabRowHeight - indicatorHeight.toIntPx().toPx()
+ val expectedPositionY = (tabRowHeight - indicatorHeight.toIntPx()).toPx()
assertThat(indicatorPositionY).isEqualTo(expectedPositionY)
tabRowHeight
@@ -233,7 +233,7 @@
assertThat(indicatorPositionX).isEqualTo(expectedPositionX)
val indicatorPositionY = indicatorCoords!!.localToGlobal(PxPosition.Origin).y
- val expectedPositionY = tabRowHeight - indicatorHeight.toIntPx().toPx()
+ val expectedPositionY = (tabRowHeight - indicatorHeight.toIntPx()).toPx()
assertThat(indicatorPositionY).isEqualTo(expectedPositionY)
}
}
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/AppBar.kt b/ui/ui-material/src/main/java/androidx/ui/material/AppBar.kt
index 56554f0..7f2af30 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/AppBar.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/AppBar.kt
@@ -55,10 +55,12 @@
import androidx.ui.text.TextStyle
import androidx.ui.unit.Density
import androidx.ui.unit.Dp
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxPosition
import androidx.ui.unit.PxSize
import androidx.ui.unit.dp
import androidx.ui.unit.sp
+import androidx.ui.unit.toPxSize
import androidx.ui.unit.withDensity
import kotlin.math.sqrt
@@ -201,7 +203,7 @@
*/
@Immutable
data class FabConfiguration(
- internal val fabSize: PxSize,
+ internal val fabSize: IntPxSize,
internal val fabTopLeftPosition: PxPosition,
internal val fabDockedPosition: FabDockedPosition
)
@@ -298,7 +300,9 @@
val shape =
if (cutoutShape != null) {
BottomAppBarCutoutShape(
- cutoutShape, fabConfiguration.fabTopLeftPosition, fabConfiguration.fabSize
+ cutoutShape,
+ fabConfiguration.fabTopLeftPosition,
+ fabConfiguration.fabSize.toPxSize()
)
} else {
RectangleShape
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/Scaffold.kt b/ui/ui-material/src/main/java/androidx/ui/material/Scaffold.kt
index 2a50615..e4d3f1c 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/Scaffold.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/Scaffold.kt
@@ -37,7 +37,8 @@
import androidx.ui.material.Scaffold.FabPosition
import androidx.ui.material.surface.Surface
import androidx.ui.unit.IntPx
-import androidx.ui.unit.PxSize
+import androidx.ui.unit.IntPxSize
+import androidx.ui.unit.PxPosition
import androidx.ui.unit.dp
import androidx.ui.unit.withDensity
@@ -59,7 +60,7 @@
// TODO: add showSnackbar() method here
internal var fabConfiguration: FabConfiguration? = null
- internal var bottomBarSize: PxSize? = null
+ internal var bottomBarSize: IntPxSize? = null
}
object Scaffold {
@@ -293,13 +294,16 @@
) {
onDispose(callback = { scaffoldState.fabConfiguration = null })
OnChildPositioned( coords ->
+ // TODO(mount): This should probably use bounding box rather than position/size
+ val position = coords.parentCoordinates?.childToLocal(coords, PxPosition.Origin)
+ ?: PxPosition.Origin
val config =
when (fabPos) {
FabPosition.CenterDocked -> {
- FabConfiguration(coords.size, coords.position, FabDockedPosition.Center)
+ FabConfiguration(coords.size, position, FabDockedPosition.Center)
}
FabPosition.EndDocked -> {
- FabConfiguration(coords.size, coords.position, FabDockedPosition.End)
+ FabConfiguration(coords.size, position, FabDockedPosition.End)
}
else -> {
null
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/ripple/DefaultRippleEffect.kt b/ui/ui-material/src/main/java/androidx/ui/material/ripple/DefaultRippleEffect.kt
index 92190e1..4ddbe7f 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/ripple/DefaultRippleEffect.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/ripple/DefaultRippleEffect.kt
@@ -43,6 +43,7 @@
import androidx.ui.unit.max
import androidx.ui.unit.milliseconds
import androidx.ui.unit.toOffset
+import androidx.ui.unit.toPxSize
import androidx.ui.unit.toRect
import androidx.ui.unit.withDensity
@@ -114,13 +115,13 @@
private val paint = Paint()
init {
- val surfaceSize = coordinates.size
+ val surfaceSize = coordinates.size.toPxSize()
val startRadius = getRippleStartRadius(surfaceSize)
val targetRadius = withDensity(density) {
radius?.toPx() ?: getRippleTargetRadius(surfaceSize)
}
- val center = coordinates.size.center()
+ val center = coordinates.size.toPxSize().center()
animation = RippleTransition.definition(
startRadius = startRadius,
endRadius = targetRadius,
@@ -154,7 +155,7 @@
if (clipped) {
canvas.save()
- canvas.clipRect(coordinates.size.toRect())
+ canvas.clipRect(coordinates.size.toPxSize().toRect())
}
val centerOffset = animation[RippleTransition.Center].toOffset()
diff --git a/ui/ui-material/src/main/java/androidx/ui/material/ripple/Ripple.kt b/ui/ui-material/src/main/java/androidx/ui/material/ripple/Ripple.kt
index ca5cc0f..269cc90 100644
--- a/ui/ui-material/src/main/java/androidx/ui/material/ripple/Ripple.kt
+++ b/ui/ui-material/src/main/java/androidx/ui/material/ripple/Ripple.kt
@@ -18,19 +18,20 @@
import androidx.compose.Composable
import androidx.compose.Recompose
-import androidx.compose.remember
import androidx.compose.onDispose
+import androidx.compose.remember
import androidx.ui.animation.transitionsEnabled
-import androidx.ui.unit.Density
-import androidx.ui.unit.Dp
import androidx.ui.core.Draw
import androidx.ui.core.LayoutCoordinates
import androidx.ui.core.OnChildPositioned
import androidx.ui.core.ambientDensity
import androidx.ui.core.gesture.PressIndicatorGestureDetector
import androidx.ui.graphics.Color
+import androidx.ui.unit.Density
+import androidx.ui.unit.Dp
import androidx.ui.unit.PxPosition
import androidx.ui.unit.center
+import androidx.ui.unit.toPxSize
/**
* Ripple is a visual indicator for a pressed state.
@@ -79,7 +80,8 @@
val finalColor = (color ?: theme.defaultColor()).copy(alpha = theme.opacity())
Draw { canvas, _ ->
if (state.effects.isNotEmpty()) {
- val position = state.coordinates!!.position
+ val position = state.coordinates!!.parentCoordinates
+ ?.childToLocal(state.coordinates!!, PxPosition.Origin) ?: PxPosition.Origin
canvas.translate(position.x.value, position.y.value)
state.effects.forEach { it.draw(canvas, finalColor) }
canvas.translate(-position.x.value, -position.y.value)
@@ -111,7 +113,7 @@
val coordinates = checkNotNull(coordinates) {
"handleStart() called before the layout coordinates were provided!"
}
- val position = if (bounded) touchPosition else coordinates.size.center()
+ val position = if (bounded) touchPosition else coordinates.size.toPxSize().center()
val effect: RippleEffect ->
effects.remove(effect)
if (currentEffect == effect) {
diff --git a/ui/ui-platform/api/0.1.0-dev04.txt b/ui/ui-platform/api/0.1.0-dev04.txt
index 21678a8..b4463d6 100644
--- a/ui/ui-platform/api/0.1.0-dev04.txt
+++ b/ui/ui-platform/api/0.1.0-dev04.txt
@@ -431,7 +431,7 @@
method public boolean getHasChildren();
method public int getId();
method public androidx.ui.core.semantics.SemanticsNode? getParent();
- method public androidx.ui.unit.PxSize getSize();
+ method public androidx.ui.unit.IntPxSize getSize();
method public java.util.List<androidx.ui.core.semantics.SemanticsNode> getUnmergedChildren();
method public androidx.ui.core.semantics.SemanticsConfiguration getUnmergedConfig();
method public boolean isSemanticBoundary();
@@ -445,7 +445,7 @@
property public final boolean hasChildren;
property public final boolean isSemanticBoundary;
property public final androidx.ui.core.semantics.SemanticsNode? parent;
- property public final androidx.ui.unit.PxSize size;
+ property public final androidx.ui.unit.IntPxSize size;
property public final java.util.List<androidx.ui.core.semantics.SemanticsNode> unmergedChildren;
property public final androidx.ui.core.semantics.SemanticsConfiguration unmergedConfig;
field public static final androidx.ui.core.semantics.SemanticsNode.Companion! Companion;
diff --git a/ui/ui-platform/api/current.txt b/ui/ui-platform/api/current.txt
index 21678a8..b4463d6 100644
--- a/ui/ui-platform/api/current.txt
+++ b/ui/ui-platform/api/current.txt
@@ -431,7 +431,7 @@
method public boolean getHasChildren();
method public int getId();
method public androidx.ui.core.semantics.SemanticsNode? getParent();
- method public androidx.ui.unit.PxSize getSize();
+ method public androidx.ui.unit.IntPxSize getSize();
method public java.util.List<androidx.ui.core.semantics.SemanticsNode> getUnmergedChildren();
method public androidx.ui.core.semantics.SemanticsConfiguration getUnmergedConfig();
method public boolean isSemanticBoundary();
@@ -445,7 +445,7 @@
property public final boolean hasChildren;
property public final boolean isSemanticBoundary;
property public final androidx.ui.core.semantics.SemanticsNode? parent;
- property public final androidx.ui.unit.PxSize size;
+ property public final androidx.ui.unit.IntPxSize size;
property public final java.util.List<androidx.ui.core.semantics.SemanticsNode> unmergedChildren;
property public final androidx.ui.core.semantics.SemanticsConfiguration unmergedConfig;
field public static final androidx.ui.core.semantics.SemanticsNode.Companion! Companion;
diff --git a/ui/ui-platform/api/public_plus_experimental_0.1.0-dev04.txt b/ui/ui-platform/api/public_plus_experimental_0.1.0-dev04.txt
index c910e08..6e50bef 100644
--- a/ui/ui-platform/api/public_plus_experimental_0.1.0-dev04.txt
+++ b/ui/ui-platform/api/public_plus_experimental_0.1.0-dev04.txt
@@ -433,7 +433,7 @@
method public boolean getHasChildren();
method public int getId();
method public androidx.ui.core.semantics.SemanticsNode? getParent();
- method public androidx.ui.unit.PxSize getSize();
+ method public androidx.ui.unit.IntPxSize getSize();
method public java.util.List<androidx.ui.core.semantics.SemanticsNode> getUnmergedChildren();
method public androidx.ui.core.semantics.SemanticsConfiguration getUnmergedConfig();
method public boolean isSemanticBoundary();
@@ -447,7 +447,7 @@
property public final boolean hasChildren;
property public final boolean isSemanticBoundary;
property public final androidx.ui.core.semantics.SemanticsNode? parent;
- property public final androidx.ui.unit.PxSize size;
+ property public final androidx.ui.unit.IntPxSize size;
property public final java.util.List<androidx.ui.core.semantics.SemanticsNode> unmergedChildren;
property public final androidx.ui.core.semantics.SemanticsConfiguration unmergedConfig;
field public static final androidx.ui.core.semantics.SemanticsNode.Companion! Companion;
diff --git a/ui/ui-platform/api/public_plus_experimental_current.txt b/ui/ui-platform/api/public_plus_experimental_current.txt
index c910e08..6e50bef 100644
--- a/ui/ui-platform/api/public_plus_experimental_current.txt
+++ b/ui/ui-platform/api/public_plus_experimental_current.txt
@@ -433,7 +433,7 @@
method public boolean getHasChildren();
method public int getId();
method public androidx.ui.core.semantics.SemanticsNode? getParent();
- method public androidx.ui.unit.PxSize getSize();
+ method public androidx.ui.unit.IntPxSize getSize();
method public java.util.List<androidx.ui.core.semantics.SemanticsNode> getUnmergedChildren();
method public androidx.ui.core.semantics.SemanticsConfiguration getUnmergedConfig();
method public boolean isSemanticBoundary();
@@ -447,7 +447,7 @@
property public final boolean hasChildren;
property public final boolean isSemanticBoundary;
property public final androidx.ui.core.semantics.SemanticsNode? parent;
- property public final androidx.ui.unit.PxSize size;
+ property public final androidx.ui.unit.IntPxSize size;
property public final java.util.List<androidx.ui.core.semantics.SemanticsNode> unmergedChildren;
property public final androidx.ui.core.semantics.SemanticsConfiguration unmergedConfig;
field public static final androidx.ui.core.semantics.SemanticsNode.Companion! Companion;
diff --git a/ui/ui-platform/api/restricted_0.1.0-dev04.txt b/ui/ui-platform/api/restricted_0.1.0-dev04.txt
index 98bb890..44d23f4 100644
--- a/ui/ui-platform/api/restricted_0.1.0-dev04.txt
+++ b/ui/ui-platform/api/restricted_0.1.0-dev04.txt
@@ -435,7 +435,7 @@
method public boolean getHasChildren();
method public int getId();
method public androidx.ui.core.semantics.SemanticsNode? getParent();
- method public androidx.ui.unit.PxSize getSize();
+ method public androidx.ui.unit.IntPxSize getSize();
method public java.util.List<androidx.ui.core.semantics.SemanticsNode> getUnmergedChildren();
method public androidx.ui.core.semantics.SemanticsConfiguration getUnmergedConfig();
method public boolean isSemanticBoundary();
@@ -449,7 +449,7 @@
property public final boolean hasChildren;
property public final boolean isSemanticBoundary;
property public final androidx.ui.core.semantics.SemanticsNode? parent;
- property public final androidx.ui.unit.PxSize size;
+ property public final androidx.ui.unit.IntPxSize size;
property public final java.util.List<androidx.ui.core.semantics.SemanticsNode> unmergedChildren;
property public final androidx.ui.core.semantics.SemanticsConfiguration unmergedConfig;
field public static final androidx.ui.core.semantics.SemanticsNode.Companion! Companion;
diff --git a/ui/ui-platform/api/restricted_current.txt b/ui/ui-platform/api/restricted_current.txt
index 98bb890..44d23f4 100644
--- a/ui/ui-platform/api/restricted_current.txt
+++ b/ui/ui-platform/api/restricted_current.txt
@@ -435,7 +435,7 @@
method public boolean getHasChildren();
method public int getId();
method public androidx.ui.core.semantics.SemanticsNode? getParent();
- method public androidx.ui.unit.PxSize getSize();
+ method public androidx.ui.unit.IntPxSize getSize();
method public java.util.List<androidx.ui.core.semantics.SemanticsNode> getUnmergedChildren();
method public androidx.ui.core.semantics.SemanticsConfiguration getUnmergedConfig();
method public boolean isSemanticBoundary();
@@ -449,7 +449,7 @@
property public final boolean hasChildren;
property public final boolean isSemanticBoundary;
property public final androidx.ui.core.semantics.SemanticsNode? parent;
- property public final androidx.ui.unit.PxSize size;
+ property public final androidx.ui.unit.IntPxSize size;
property public final java.util.List<androidx.ui.core.semantics.SemanticsNode> unmergedChildren;
property public final androidx.ui.core.semantics.SemanticsConfiguration unmergedConfig;
field public static final androidx.ui.core.semantics.SemanticsNode.Companion! Companion;
diff --git a/ui/ui-platform/src/main/java/androidx/ui/core/ComponentNodes.kt b/ui/ui-platform/src/main/java/androidx/ui/core/ComponentNodes.kt
index 3cc074e..c1b3d6d 100644
--- a/ui/ui-platform/src/main/java/androidx/ui/core/ComponentNodes.kt
+++ b/ui/ui-platform/src/main/java/androidx/ui/core/ComponentNodes.kt
@@ -46,7 +46,6 @@
import androidx.ui.unit.dp
import androidx.ui.unit.ipx
import androidx.ui.unit.toPx
-import androidx.ui.unit.toPxPosition
import androidx.ui.unit.toPxSize
import kotlin.properties.ReadWriteProperty
import kotlin.reflect.KProperty
@@ -2192,9 +2191,7 @@
private val layoutNode: LayoutNode
) : LayoutCoordinates {
- override val position get() = layoutNode.contentPosition.toPxPosition()
-
- override val size get() = layoutNode.contentSize.toPxSize()
+ override val size get() = layoutNode.contentSize
override val providedAlignmentLines get() = layoutNode.providedAlignmentLines
diff --git a/ui/ui-platform/src/main/java/androidx/ui/core/semantics/SemanticsNode.kt b/ui/ui-platform/src/main/java/androidx/ui/core/semantics/SemanticsNode.kt
index e0b6d4d..c553cd3 100644
--- a/ui/ui-platform/src/main/java/androidx/ui/core/semantics/SemanticsNode.kt
+++ b/ui/ui-platform/src/main/java/androidx/ui/core/semantics/SemanticsNode.kt
@@ -26,8 +26,8 @@
import androidx.ui.core.requireFirstLayoutNodeInTree
import androidx.ui.semantics.AccessibilityAction
import androidx.ui.semantics.SemanticsPropertyKey
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxBounds
-import androidx.ui.unit.PxSize
/**
* Signature for a function that is called for each [SemanticsNode].
@@ -102,7 +102,7 @@
// GEOMETRY
/** The size of the bounding box for this node */
- val size: PxSize
+ val size: IntPxSize
get() {
val layoutNode = componentNode.requireFirstLayoutNodeInTree()
return layoutNode.coordinates.size
diff --git a/ui/ui-test/api/0.1.0-dev04.txt b/ui/ui-test/api/0.1.0-dev04.txt
index a03ad41..afc645d 100644
--- a/ui/ui-test/api/0.1.0-dev04.txt
+++ b/ui/ui-test/api/0.1.0-dev04.txt
@@ -148,7 +148,7 @@
public final class GestureScopeKt {
method public static androidx.ui.unit.PxPosition getCenter(androidx.ui.test.GestureScope);
method public static androidx.ui.unit.PxBounds getGlobalBounds(androidx.ui.test.GestureScope);
- method public static androidx.ui.unit.PxSize getSize(androidx.ui.test.GestureScope);
+ method public static androidx.ui.unit.IntPxSize getSize(androidx.ui.test.GestureScope);
method public static androidx.ui.unit.PxPosition localToGlobal(androidx.ui.test.GestureScope, androidx.ui.unit.PxPosition position);
method public static void sendClick(androidx.ui.test.GestureScope, androidx.ui.unit.PxPosition position);
method public static void sendClick(androidx.ui.test.GestureScope);
@@ -170,6 +170,10 @@
method public static androidx.ui.core.semantics.SemanticsConfiguration createFullSemantics(Boolean? isEnabled = null, String? value = null, androidx.ui.foundation.selection.ToggleableState? toggleableState = null, Boolean? inMutuallyExclusiveGroup = null, Boolean? isSelected = null);
}
+ public final class LayoutCoordinatesHelperKt {
+ method public static androidx.ui.unit.PxPosition getPositionInParent(androidx.ui.core.LayoutCoordinates);
+ }
+
public final class OutputKt {
method public static void dumpSemantics(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super java.lang.String,kotlin.Unit> consumer);
}
diff --git a/ui/ui-test/api/current.txt b/ui/ui-test/api/current.txt
index a03ad41..afc645d 100644
--- a/ui/ui-test/api/current.txt
+++ b/ui/ui-test/api/current.txt
@@ -148,7 +148,7 @@
public final class GestureScopeKt {
method public static androidx.ui.unit.PxPosition getCenter(androidx.ui.test.GestureScope);
method public static androidx.ui.unit.PxBounds getGlobalBounds(androidx.ui.test.GestureScope);
- method public static androidx.ui.unit.PxSize getSize(androidx.ui.test.GestureScope);
+ method public static androidx.ui.unit.IntPxSize getSize(androidx.ui.test.GestureScope);
method public static androidx.ui.unit.PxPosition localToGlobal(androidx.ui.test.GestureScope, androidx.ui.unit.PxPosition position);
method public static void sendClick(androidx.ui.test.GestureScope, androidx.ui.unit.PxPosition position);
method public static void sendClick(androidx.ui.test.GestureScope);
@@ -170,6 +170,10 @@
method public static androidx.ui.core.semantics.SemanticsConfiguration createFullSemantics(Boolean? isEnabled = null, String? value = null, androidx.ui.foundation.selection.ToggleableState? toggleableState = null, Boolean? inMutuallyExclusiveGroup = null, Boolean? isSelected = null);
}
+ public final class LayoutCoordinatesHelperKt {
+ method public static androidx.ui.unit.PxPosition getPositionInParent(androidx.ui.core.LayoutCoordinates);
+ }
+
public final class OutputKt {
method public static void dumpSemantics(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super java.lang.String,kotlin.Unit> consumer);
}
diff --git a/ui/ui-test/api/public_plus_experimental_0.1.0-dev04.txt b/ui/ui-test/api/public_plus_experimental_0.1.0-dev04.txt
index a03ad41..afc645d 100644
--- a/ui/ui-test/api/public_plus_experimental_0.1.0-dev04.txt
+++ b/ui/ui-test/api/public_plus_experimental_0.1.0-dev04.txt
@@ -148,7 +148,7 @@
public final class GestureScopeKt {
method public static androidx.ui.unit.PxPosition getCenter(androidx.ui.test.GestureScope);
method public static androidx.ui.unit.PxBounds getGlobalBounds(androidx.ui.test.GestureScope);
- method public static androidx.ui.unit.PxSize getSize(androidx.ui.test.GestureScope);
+ method public static androidx.ui.unit.IntPxSize getSize(androidx.ui.test.GestureScope);
method public static androidx.ui.unit.PxPosition localToGlobal(androidx.ui.test.GestureScope, androidx.ui.unit.PxPosition position);
method public static void sendClick(androidx.ui.test.GestureScope, androidx.ui.unit.PxPosition position);
method public static void sendClick(androidx.ui.test.GestureScope);
@@ -170,6 +170,10 @@
method public static androidx.ui.core.semantics.SemanticsConfiguration createFullSemantics(Boolean? isEnabled = null, String? value = null, androidx.ui.foundation.selection.ToggleableState? toggleableState = null, Boolean? inMutuallyExclusiveGroup = null, Boolean? isSelected = null);
}
+ public final class LayoutCoordinatesHelperKt {
+ method public static androidx.ui.unit.PxPosition getPositionInParent(androidx.ui.core.LayoutCoordinates);
+ }
+
public final class OutputKt {
method public static void dumpSemantics(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super java.lang.String,kotlin.Unit> consumer);
}
diff --git a/ui/ui-test/api/public_plus_experimental_current.txt b/ui/ui-test/api/public_plus_experimental_current.txt
index a03ad41..afc645d 100644
--- a/ui/ui-test/api/public_plus_experimental_current.txt
+++ b/ui/ui-test/api/public_plus_experimental_current.txt
@@ -148,7 +148,7 @@
public final class GestureScopeKt {
method public static androidx.ui.unit.PxPosition getCenter(androidx.ui.test.GestureScope);
method public static androidx.ui.unit.PxBounds getGlobalBounds(androidx.ui.test.GestureScope);
- method public static androidx.ui.unit.PxSize getSize(androidx.ui.test.GestureScope);
+ method public static androidx.ui.unit.IntPxSize getSize(androidx.ui.test.GestureScope);
method public static androidx.ui.unit.PxPosition localToGlobal(androidx.ui.test.GestureScope, androidx.ui.unit.PxPosition position);
method public static void sendClick(androidx.ui.test.GestureScope, androidx.ui.unit.PxPosition position);
method public static void sendClick(androidx.ui.test.GestureScope);
@@ -170,6 +170,10 @@
method public static androidx.ui.core.semantics.SemanticsConfiguration createFullSemantics(Boolean? isEnabled = null, String? value = null, androidx.ui.foundation.selection.ToggleableState? toggleableState = null, Boolean? inMutuallyExclusiveGroup = null, Boolean? isSelected = null);
}
+ public final class LayoutCoordinatesHelperKt {
+ method public static androidx.ui.unit.PxPosition getPositionInParent(androidx.ui.core.LayoutCoordinates);
+ }
+
public final class OutputKt {
method public static void dumpSemantics(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super java.lang.String,kotlin.Unit> consumer);
}
diff --git a/ui/ui-test/api/restricted_0.1.0-dev04.txt b/ui/ui-test/api/restricted_0.1.0-dev04.txt
index a03ad41..afc645d 100644
--- a/ui/ui-test/api/restricted_0.1.0-dev04.txt
+++ b/ui/ui-test/api/restricted_0.1.0-dev04.txt
@@ -148,7 +148,7 @@
public final class GestureScopeKt {
method public static androidx.ui.unit.PxPosition getCenter(androidx.ui.test.GestureScope);
method public static androidx.ui.unit.PxBounds getGlobalBounds(androidx.ui.test.GestureScope);
- method public static androidx.ui.unit.PxSize getSize(androidx.ui.test.GestureScope);
+ method public static androidx.ui.unit.IntPxSize getSize(androidx.ui.test.GestureScope);
method public static androidx.ui.unit.PxPosition localToGlobal(androidx.ui.test.GestureScope, androidx.ui.unit.PxPosition position);
method public static void sendClick(androidx.ui.test.GestureScope, androidx.ui.unit.PxPosition position);
method public static void sendClick(androidx.ui.test.GestureScope);
@@ -170,6 +170,10 @@
method public static androidx.ui.core.semantics.SemanticsConfiguration createFullSemantics(Boolean? isEnabled = null, String? value = null, androidx.ui.foundation.selection.ToggleableState? toggleableState = null, Boolean? inMutuallyExclusiveGroup = null, Boolean? isSelected = null);
}
+ public final class LayoutCoordinatesHelperKt {
+ method public static androidx.ui.unit.PxPosition getPositionInParent(androidx.ui.core.LayoutCoordinates);
+ }
+
public final class OutputKt {
method public static void dumpSemantics(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super java.lang.String,kotlin.Unit> consumer);
}
diff --git a/ui/ui-test/api/restricted_current.txt b/ui/ui-test/api/restricted_current.txt
index a03ad41..afc645d 100644
--- a/ui/ui-test/api/restricted_current.txt
+++ b/ui/ui-test/api/restricted_current.txt
@@ -148,7 +148,7 @@
public final class GestureScopeKt {
method public static androidx.ui.unit.PxPosition getCenter(androidx.ui.test.GestureScope);
method public static androidx.ui.unit.PxBounds getGlobalBounds(androidx.ui.test.GestureScope);
- method public static androidx.ui.unit.PxSize getSize(androidx.ui.test.GestureScope);
+ method public static androidx.ui.unit.IntPxSize getSize(androidx.ui.test.GestureScope);
method public static androidx.ui.unit.PxPosition localToGlobal(androidx.ui.test.GestureScope, androidx.ui.unit.PxPosition position);
method public static void sendClick(androidx.ui.test.GestureScope, androidx.ui.unit.PxPosition position);
method public static void sendClick(androidx.ui.test.GestureScope);
@@ -170,6 +170,10 @@
method public static androidx.ui.core.semantics.SemanticsConfiguration createFullSemantics(Boolean? isEnabled = null, String? value = null, androidx.ui.foundation.selection.ToggleableState? toggleableState = null, Boolean? inMutuallyExclusiveGroup = null, Boolean? isSelected = null);
}
+ public final class LayoutCoordinatesHelperKt {
+ method public static androidx.ui.unit.PxPosition getPositionInParent(androidx.ui.core.LayoutCoordinates);
+ }
+
public final class OutputKt {
method public static void dumpSemantics(androidx.ui.test.SemanticsNodeInteraction, kotlin.jvm.functions.Function1<? super java.lang.String,kotlin.Unit> consumer);
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/LayoutCoordinatesHelperTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/LayoutCoordinatesHelperTest.kt
new file mode 100644
index 0000000..ada56c3
--- /dev/null
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/LayoutCoordinatesHelperTest.kt
@@ -0,0 +1,87 @@
+/*
+ * 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.test
+
+import androidx.test.filters.MediumTest
+import androidx.ui.core.OnChildPositioned
+import androidx.ui.core.WithDensity
+import androidx.ui.layout.Column
+import androidx.ui.layout.Container
+import androidx.ui.layout.LayoutGravity
+import androidx.ui.layout.LayoutWidth
+import androidx.ui.unit.PxPosition
+import androidx.ui.unit.dp
+import androidx.ui.unit.ipx
+import androidx.ui.unit.px
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertTrue
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+import java.util.concurrent.CountDownLatch
+import java.util.concurrent.TimeUnit
+
+@MediumTest
+@RunWith(JUnit4::class)
+class LayoutCoordinatesHelperTest {
+
+ @get:Rule
+ val composeTestRule = createComposeRule(disableTransitions = true)
+
+ @Test
+ fun positionInParent_noOffset() {
+ val latch = CountDownLatch(1)
+ composeTestRule.setContent {
+ Column {
+ OnChildPositioned( coordinates ->
+ assertEquals(PxPosition.Origin, coordinates.positionInParent)
+ latch.countDown()
+ }) {
+ Container(width = 10.dp, height = 10.dp, modifier = LayoutGravity.Start) {}
+ }
+ }
+ }
+
+ assertTrue(latch.await(1, TimeUnit.SECONDS))
+ }
+
+ @Test
+ fun positionInParent_centered() {
+ val latch = CountDownLatch(1)
+ composeTestRule.setContent {
+ WithDensity {
+ Container(LayoutWidth(40.ipx.toDp())) {
+ Column(LayoutWidth(20.ipx.toDp())) {
+ OnChildPositioned( coordinates ->
+ assertEquals(PxPosition(5.px, 0.px), coordinates.positionInParent)
+ latch.countDown()
+ }) {
+ Container(
+ width = 10.ipx.toDp(),
+ height = 10.ipx.toDp(),
+ modifier = LayoutGravity.Center
+ ) {}
+ }
+ }
+ }
+ }
+ }
+
+ assertTrue(latch.await(1, TimeUnit.SECONDS))
+ }
+}
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/GestureScope.kt b/ui/ui-test/src/main/java/androidx/ui/test/GestureScope.kt
index 6efc4d1..b282126 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/GestureScope.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/GestureScope.kt
@@ -19,12 +19,13 @@
import androidx.annotation.FloatRange
import androidx.ui.core.gesture.LongPressTimeout
import androidx.ui.unit.Duration
+import androidx.ui.unit.IntPxSize
import androidx.ui.unit.PxBounds
import androidx.ui.unit.PxPosition
-import androidx.ui.unit.PxSize
import androidx.ui.unit.inMilliseconds
import androidx.ui.unit.milliseconds
import androidx.ui.unit.px
+import androidx.ui.unit.toPx
import androidx.ui.util.lerp
import kotlin.math.atan2
import kotlin.math.cos
@@ -67,7 +68,7 @@
/**
* Returns the size of the component we're interacting with
*/
-val GestureScope.size: PxSize
+val GestureScope.size: IntPxSize
get() = semanticsNode.size
/**
@@ -266,7 +267,7 @@
val x = center.x
val y0 = size.height * (1 - edgeFuzzFactor)
val y1 = 0.px
- val start = PxPosition(x, y0)
+ val start = PxPosition(x, y0.toPx())
val end = PxPosition(x, y1)
sendSwipe(start, end, 200.milliseconds)
}
@@ -281,8 +282,8 @@
val x = center.x
val y0 = size.height * edgeFuzzFactor
val y1 = size.height
- val start = PxPosition(x, y0)
- val end = PxPosition(x, y1)
+ val start = PxPosition(x, y0.toPx())
+ val end = PxPosition(x, y1.toPx())
sendSwipe(start, end, 200.milliseconds)
}
@@ -296,7 +297,7 @@
val x0 = size.width * (1 - edgeFuzzFactor)
val x1 = 0.px
val y = center.y
- val start = PxPosition(x0, y)
+ val start = PxPosition(x0.toPx(), y)
val end = PxPosition(x1, y)
sendSwipe(start, end, 200.milliseconds)
}
@@ -311,8 +312,8 @@
val x0 = size.width * edgeFuzzFactor
val x1 = size.width
val y = center.y
- val start = PxPosition(x0, y)
- val end = PxPosition(x1, y)
+ val start = PxPosition(x0.toPx(), y)
+ val end = PxPosition(x1.toPx(), y)
sendSwipe(start, end, 200.milliseconds)
}
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/LayoutCoordinatesHelper.kt b/ui/ui-test/src/main/java/androidx/ui/test/LayoutCoordinatesHelper.kt
new file mode 100644
index 0000000..3aeb2b7
--- /dev/null
+++ b/ui/ui-test/src/main/java/androidx/ui/test/LayoutCoordinatesHelper.kt
@@ -0,0 +1,28 @@
+/*
+ * 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.test
+
+import androidx.ui.core.LayoutCoordinates
+import androidx.ui.unit.PxPosition
+
+/**
+ * Returns the position relative to the parent's LayoutCoordinate. This is useful for testing,
+ * but should not be used in public API. The parent could be an arbitrary modifier and won't
+ * necessarily be a position relative to the parent layout.
+ */
+val LayoutCoordinates.positionInParent: PxPosition
+ get() = parentCoordinates?.childToLocal(this, PxPosition.Origin) ?: PxPosition.Origin
\ No newline at end of file
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/SizesTesting.kt b/ui/ui-test/src/main/java/androidx/ui/test/SizesTesting.kt
index 75bfd4b..a3be2c7 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/SizesTesting.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/SizesTesting.kt
@@ -30,6 +30,7 @@
import androidx.ui.layout.Stack
import androidx.ui.layout.Wrap
import androidx.ui.unit.round
+import androidx.ui.unit.toPxSize
import kotlin.math.abs
/**
@@ -59,7 +60,7 @@
LayoutSize.Max(parentConstraints.maxWidth, parentConstraints.maxHeight)
) {
OnChildPositioned(
- coordinates -> realSize = coordinates.size },
+ coordinates -> realSize = coordinates.size.toPxSize() },
children = children
)
}