Refactor testing APIs to the final proposal.
Bug: 161116353
Test: N/A
Relnote: "Several testing APIs were renamed to be more intuitive. All
findXYZ APIs were renamed to onNodeXYZ. All doXYZ APIs were renamed to
performXYZ."
Change-Id: I7f164b42b04196f023c4a2153d66825487998de4
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 a3a3c71..dc4f5ac 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
@@ -31,8 +31,8 @@
import androidx.ui.test.assertLeftPositionInRootIsEqualTo
import androidx.ui.test.assertTopPositionInRootIsEqualTo
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
-import androidx.ui.test.findByText
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.onNodeWithText
import androidx.ui.test.getBoundsInRoot
import androidx.ui.text.TextStyle
import androidx.ui.unit.Dp
@@ -70,7 +70,7 @@
composeTestRule.setMaterialContent {
TopAppBar(title = { Text(title) })
}
- findByText(title).assertIsDisplayed()
+ onNodeWithText(title).assertIsDisplayed()
}
@Test
@@ -91,25 +91,25 @@
}
}
- val appBarBounds = findByTag("bar").getBoundsInRoot()
- val titleBounds = findByTag("title").getBoundsInRoot()
+ val appBarBounds = onNodeWithTag("bar").getBoundsInRoot()
+ val titleBounds = onNodeWithTag("title").getBoundsInRoot()
val appBarBottomEdgeY = appBarBounds.top + appBarBounds.height
- findByTag("navigationIcon")
+ onNodeWithTag("navigationIcon")
// Navigation icon should be 4.dp from the start
.assertLeftPositionInRootIsEqualTo(AppBarStartAndEndPadding)
// Navigation icon should be 4.dp from the bottom
.assertTopPositionInRootIsEqualTo(
appBarBottomEdgeY - AppBarStartAndEndPadding - FakeIconSize)
- findByTag("title")
+ onNodeWithTag("title")
// Title should be 72.dp from the start
// 4.dp padding for the whole app bar + 68.dp inset
.assertLeftPositionInRootIsEqualTo(4.dp + 68.dp)
// Title should be vertically centered
.assertTopPositionInRootIsEqualTo((appBarBounds.height - titleBounds.height) / 2)
- findByTag("action")
+ onNodeWithTag("action")
// Action should be placed at the end
.assertLeftPositionInRootIsEqualTo(expectedActionPosition(appBarBounds.width))
// Action should be 4.dp from the bottom
@@ -132,14 +132,14 @@
}
}
- val appBarBounds = findByTag("bar").getBoundsInRoot()
+ val appBarBounds = onNodeWithTag("bar").getBoundsInRoot()
- findByTag("title")
+ onNodeWithTag("title")
// Title should now be placed 16.dp from the start, as there is no navigation icon
// 4.dp padding for the whole app bar + 12.dp inset
.assertLeftPositionInRootIsEqualTo(4.dp + 12.dp)
- findByTag("action")
+ onNodeWithTag("action")
// Action should still be placed at the end
.assertLeftPositionInRootIsEqualTo(expectedActionPosition(appBarBounds.width))
}
@@ -181,10 +181,10 @@
}
}
- val appBarBounds = findByTag("bar").getBoundsInRoot()
+ val appBarBounds = onNodeWithTag("bar").getBoundsInRoot()
val appBarBottomEdgeY = appBarBounds.top + appBarBounds.height
- findByTag("icon")
+ onNodeWithTag("icon")
// Child icon should be 4.dp from the start
.assertLeftPositionInRootIsEqualTo(AppBarStartAndEndPadding)
// Child icon should be 4.dp from the bottom
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/BottomNavigationTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/BottomNavigationTest.kt
index 359cbd3..8e0f172 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/BottomNavigationTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/BottomNavigationTest.kt
@@ -36,10 +36,10 @@
import androidx.ui.test.assertLeftPositionInRootIsEqualTo
import androidx.ui.test.assertTopPositionInRootIsEqualTo
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.findAll
-import androidx.ui.test.findByTag
-import androidx.ui.test.findByText
+import androidx.ui.test.performClick
+import androidx.ui.test.onAllNodes
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.onNodeWithText
import androidx.ui.test.getBoundsInRoot
import androidx.ui.test.isInMutuallyExclusiveGroup
import androidx.ui.unit.dp
@@ -133,16 +133,16 @@
}
}
- val itemBounds = findByTag("item").getBoundsInRoot()
- val iconBounds = findByTag("icon", useUnmergedTree = true).getBoundsInRoot()
- val textBounds = findByText("ItemText").getBoundsInRoot()
+ val itemBounds = onNodeWithTag("item").getBoundsInRoot()
+ val iconBounds = onNodeWithTag("icon", useUnmergedTree = true).getBoundsInRoot()
+ val textBounds = onNodeWithText("ItemText").getBoundsInRoot()
// Distance from the bottom to the text baseline and from the text baseline to the
// bottom of the icon
val textBaseline = 12.dp
// Relative position of the baseline to the top of text
- val relativeTextBaseline = findByText("ItemText").getLastBaselinePosition()
+ val relativeTextBaseline = onNodeWithText("ItemText").getLastBaselinePosition()
// Absolute y position of the text baseline
val absoluteTextBaseline = textBounds.top + relativeTextBaseline
@@ -150,7 +150,7 @@
// Text baseline should be 12.dp from the bottom of the item
absoluteTextBaseline.assertIsEqualTo(itemBottom - textBaseline)
- findByTag("icon", useUnmergedTree = true)
+ onNodeWithTag("icon", useUnmergedTree = true)
// The icon should be centered in the item
.assertLeftPositionInRootIsEqualTo((itemBounds.width - iconBounds.width) / 2)
// The bottom of the icon is 12.dp above the text baseline
@@ -182,12 +182,12 @@
// The text should not be placed, since the item is not selected and alwaysShowLabels
// is false
- findByText("ItemText", useUnmergedTree = true).assertIsNotDisplayed()
+ onNodeWithText("ItemText", useUnmergedTree = true).assertIsNotDisplayed()
- val itemBounds = findByTag("item").getBoundsInRoot()
- val iconBounds = findByTag("icon", useUnmergedTree = true).getBoundsInRoot()
+ val itemBounds = onNodeWithTag("item").getBoundsInRoot()
+ val iconBounds = onNodeWithTag("icon", useUnmergedTree = true).getBoundsInRoot()
- findByTag("icon", useUnmergedTree = true)
+ onNodeWithTag("icon", useUnmergedTree = true)
.assertLeftPositionInRootIsEqualTo((itemBounds.width - iconBounds.width) / 2)
.assertTopPositionInRootIsEqualTo((itemBounds.height - iconBounds.height) / 2)
}
@@ -212,11 +212,11 @@
}
}
- val itemBounds = findByTag("item").getBoundsInRoot()
- val iconBounds = findByTag("icon", useUnmergedTree = true).getBoundsInRoot()
+ val itemBounds = onNodeWithTag("item").getBoundsInRoot()
+ val iconBounds = onNodeWithTag("icon", useUnmergedTree = true).getBoundsInRoot()
// The icon should be centered in the item, as there is no text placeable provided
- findByTag("icon", useUnmergedTree = true)
+ onNodeWithTag("icon", useUnmergedTree = true)
.assertLeftPositionInRootIsEqualTo((itemBounds.width - iconBounds.width) / 2)
.assertTopPositionInRootIsEqualTo((itemBounds.height - iconBounds.height) / 2)
}
@@ -228,7 +228,7 @@
}
// Find all items and ensure there are 3
- findAll(isInMutuallyExclusiveGroup())
+ onAllNodes(isInMutuallyExclusiveGroup())
.assertCountEquals(3)
// Ensure semantics match for selected state of the items
.apply {
@@ -238,7 +238,7 @@
}
// Click the last item
.apply {
- get(2).doClick()
+ get(2).performClick()
}
.apply {
get(0).assertIsUnselected()
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonScreenshotTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonScreenshotTest.kt
index 6901f48..5da9d7e 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonScreenshotTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonScreenshotTest.kt
@@ -28,13 +28,13 @@
import androidx.ui.test.captureToBitmap
import androidx.ui.test.center
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doPartialGesture
-import androidx.ui.test.find
-import androidx.ui.test.findByText
-import androidx.ui.test.findRoot
+import androidx.ui.test.performPartialGesture
+import androidx.ui.test.onNode
+import androidx.ui.test.onNodeWithText
import androidx.ui.unit.dp
import androidx.ui.test.hasClickAction
-import androidx.ui.test.sendDown
+import androidx.ui.test.down
+import androidx.ui.test.onRoot
import androidx.ui.test.waitForIdle
import org.junit.Rule
import org.junit.Test
@@ -60,7 +60,7 @@
}
}
- find(hasClickAction())
+ onNode(hasClickAction())
.captureToBitmap()
.assertAgainstGolden(screenshotRule, "button_default")
}
@@ -73,7 +73,7 @@
}
}
- findByText("Button")
+ onNodeWithText("Button")
.captureToBitmap()
.assertAgainstGolden(screenshotRule, "button_disabled")
}
@@ -89,14 +89,14 @@
composeTestRule.clockTestRule.pauseClock()
// Start ripple
- find(hasClickAction())
- .doPartialGesture { sendDown(center) }
+ onNode(hasClickAction())
+ .performPartialGesture { down(center) }
// Let ripple propagate
waitForIdle()
composeTestRule.clockTestRule.advanceClock(50)
- findRoot()
+ onRoot()
.captureToBitmap()
.assertAgainstGolden(screenshotRule, "button_ripple")
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonTest.kt
index 5556d88..b45304d 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/ButtonTest.kt
@@ -64,10 +64,10 @@
import androidx.ui.test.assertWidthIsEqualTo
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.find
-import androidx.ui.test.findByTag
-import androidx.ui.test.findByText
+import androidx.ui.test.performClick
+import androidx.ui.test.onNode
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.onNodeWithText
import androidx.ui.test.hasClickAction
import androidx.ui.test.runOnIdleCompose
import androidx.ui.unit.Dp
@@ -101,7 +101,7 @@
}
}
- findByTag("myButton")
+ onNodeWithTag("myButton")
.assertIsEnabled()
}
@@ -115,7 +115,7 @@
}
}
- findByTag("myButton")
+ onNodeWithTag("myButton")
.assertIsNotEnabled()
}
@@ -135,8 +135,8 @@
// TODO(b/129400818): this actually finds the text, not the button as
// merge semantics aren't implemented yet
- findByText(text)
- .doClick()
+ onNodeWithText(text)
+ .performClick()
runOnIdleCompose {
assertThat(counter).isEqualTo(1)
@@ -157,11 +157,11 @@
}
}
}
- findByTag(tag)
+ onNodeWithTag(tag)
// Confirm the button starts off enabled, with a click action
.assertHasClickAction()
.assertIsEnabled()
- .doClick()
+ .performClick()
// Then confirm it's disabled with no click action after clicking it
.assertHasNoClickAction()
.assertIsNotEnabled()
@@ -190,16 +190,16 @@
}
}
- findByTag(button1Tag)
- .doClick()
+ onNodeWithTag(button1Tag)
+ .performClick()
runOnIdleCompose {
assertThat(button1Counter).isEqualTo(1)
assertThat(button2Counter).isEqualTo(0)
}
- findByTag(button2Tag)
- .doClick()
+ onNodeWithTag(button2Tag)
+ .performClick()
runOnIdleCompose {
assertThat(button1Counter).isEqualTo(1)
@@ -220,7 +220,7 @@
}
}
- find(hasClickAction())
+ onNode(hasClickAction())
.assertHeightIsEqualTo(36.dp)
}
@@ -235,7 +235,7 @@
}
}
- find(hasClickAction())
+ onNode(hasClickAction())
.assertHeightIsAtLeast(37.dp)
}
@@ -303,7 +303,7 @@
}
}
- findByTag("myButton")
+ onNodeWithTag("myButton")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
@@ -377,7 +377,7 @@
}
}
- findByTag("myButton")
+ onNodeWithTag("myButton")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
@@ -410,7 +410,7 @@
}
}
- findByTag("myButton")
+ onNodeWithTag("myButton")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
@@ -440,7 +440,7 @@
}
}
- findByTag("myButton")
+ onNodeWithTag("myButton")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
@@ -467,7 +467,7 @@
}
}
- findByTag("myButton")
+ onNodeWithTag("myButton")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
@@ -581,7 +581,7 @@
}
}
- findByTag("stack")
+ onNodeWithTag("stack")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
@@ -600,7 +600,7 @@
}
}
- findByTag("button")
+ onNodeWithTag("button")
.assertWidthIsEqualTo(20.dp)
.assertHeightIsEqualTo(15.dp)
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/CardTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/CardTest.kt
index 6c9e136..f3fcca5 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/CardTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/CardTest.kt
@@ -31,7 +31,7 @@
import androidx.ui.test.assertShape
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.unit.dp
import org.junit.Rule
import org.junit.Test
@@ -68,7 +68,7 @@
}
}
- findByTag("card")
+ onNodeWithTag("card")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxScreenshotTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxScreenshotTest.kt
index f10d795..7fe300b 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxScreenshotTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxScreenshotTest.kt
@@ -31,12 +31,12 @@
import androidx.ui.test.captureToBitmap
import androidx.ui.test.center
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.doPartialGesture
-import androidx.ui.test.find
-import androidx.ui.test.findByTag
+import androidx.ui.test.performClick
+import androidx.ui.test.performPartialGesture
+import androidx.ui.test.onNode
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.isToggleable
-import androidx.ui.test.sendDown
+import androidx.ui.test.down
import androidx.ui.test.waitForIdle
import org.junit.Rule
import org.junit.Test
@@ -87,8 +87,8 @@
Checkbox(modifier = wrap, checked = false, })
}
}
- findByTag(wrapperTestTag).doPartialGesture {
- sendDown(center)
+ onNodeWithTag(wrapperTestTag).performPartialGesture {
+ down(center)
}
assertToggeableAgainstGolden("checkbox_pressed")
}
@@ -155,8 +155,8 @@
composeTestRule.clockTestRule.pauseClock()
- find(isToggleable())
- .doClick()
+ onNode(isToggleable())
+ .performClick()
waitForIdle()
@@ -180,8 +180,8 @@
composeTestRule.clockTestRule.pauseClock()
- find(isToggleable())
- .doClick()
+ onNode(isToggleable())
+ .performClick()
waitForIdle()
@@ -192,7 +192,7 @@
private fun assertToggeableAgainstGolden(goldenName: String) {
// TODO: replace with find(isToggeable()) after b/157687898 is fixed
- findByTag(wrapperTestTag)
+ onNodeWithTag(wrapperTestTag)
.captureToBitmap()
.assertAgainstGolden(screenshotRule, goldenName)
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxUiTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxUiTest.kt
index 41c052f..04ad106 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxUiTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/CheckboxUiTest.kt
@@ -31,8 +31,8 @@
import androidx.ui.test.assertIsOn
import androidx.ui.test.assertValueEquals
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.findByTag
+import androidx.ui.test.performClick
+import androidx.ui.test.onNodeWithTag
import androidx.ui.unit.dp
import org.junit.Rule
import org.junit.Test
@@ -57,12 +57,12 @@
}
}
- findByTag("checkboxUnchecked")
+ onNodeWithTag("checkboxUnchecked")
.assertIsEnabled()
.assertIsOff()
.assertValueEquals(Strings.Unchecked)
- findByTag("checkboxChecked")
+ onNodeWithTag("checkboxChecked")
.assertIsEnabled()
.assertIsOn()
.assertValueEquals(Strings.Checked)
@@ -75,9 +75,9 @@
Checkbox(checked, onCheckedChange, modifier = Modifier.testTag(defaultTag))
}
- findByTag(defaultTag)
+ onNodeWithTag(defaultTag)
.assertIsOff()
- .doClick()
+ .performClick()
.assertIsOn()
}
@@ -88,11 +88,11 @@
Checkbox(checked, onCheckedChange, modifier = Modifier.testTag(defaultTag))
}
- findByTag(defaultTag)
+ onNodeWithTag(defaultTag)
.assertIsOff()
- .doClick()
+ .performClick()
.assertIsOn()
- .doClick()
+ .performClick()
.assertIsOff()
}
@@ -104,7 +104,7 @@
Checkbox(checked, {}, enabled = false, modifier = Modifier.testTag(defaultTag))
}
- findByTag(defaultTag)
+ onNodeWithTag(defaultTag)
.assertHasNoClickAction()
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerScreenshotTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerScreenshotTest.kt
index 57d6209..e402322 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerScreenshotTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/DrawerScreenshotTest.kt
@@ -30,7 +30,7 @@
import androidx.ui.test.ComposeTestRule
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.unit.dp
import org.junit.Rule
import org.junit.Test
@@ -99,7 +99,7 @@
}
private fun assertScreenshotAgainstGolden(goldenName: String) {
- findByTag("container")
+ onNodeWithTag("container")
.captureToBitmap()
.assertAgainstGolden(screenshotRule, goldenName)
}
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 1e6e627..47c2ec9 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
@@ -38,17 +38,17 @@
import androidx.ui.test.assertWidthIsEqualTo
import androidx.ui.test.center
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doGesture
-import androidx.ui.test.findByTag
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.globalBounds
import androidx.ui.test.runOnIdleCompose
import androidx.ui.test.runOnUiThread
-import androidx.ui.test.sendClick
-import androidx.ui.test.sendSwipe
-import androidx.ui.test.sendSwipeDown
-import androidx.ui.test.sendSwipeLeft
-import androidx.ui.test.sendSwipeRight
-import androidx.ui.test.sendSwipeUp
+import androidx.ui.test.click
+import androidx.ui.test.swipe
+import androidx.ui.test.swipeDown
+import androidx.ui.test.swipeLeft
+import androidx.ui.test.swipeRight
+import androidx.ui.test.swipeUp
import androidx.ui.unit.dp
import androidx.ui.unit.height
import androidx.ui.unit.width
@@ -77,7 +77,7 @@
}, bodyContent = emptyContent())
}
- findByTag("content")
+ onNodeWithTag("content")
.assertLeftPositionInRootIsEqualTo(0.dp)
}
@@ -106,7 +106,7 @@
}, bodyContent = emptyContent())
}
- findByTag("content")
+ onNodeWithTag("content")
.assertWidthIsEqualTo(rootWidth() - 56.dp)
}
@@ -121,7 +121,7 @@
val width = rootWidth()
val height = rootHeight()
val expectedHeight = if (width > height) 0.dp else (height / 2)
- findByTag("content")
+ onNodeWithTag("content")
.assertTopPositionInRootIsEqualTo(expectedHeight)
}
@@ -213,7 +213,7 @@
}
// Click in the middle of the drawer (which is the middle of the body)
- findByTag("Drawer").doGesture { sendClick() }
+ onNodeWithTag("Drawer").performGesture { click() }
runOnIdleCompose {
assertThat(drawerClicks).isEqualTo(0)
@@ -224,10 +224,10 @@
sleep(100) // TODO(147586311): remove this sleep when opening the drawer triggers a wait
// Click on the left-center pixel of the drawer
- findByTag("Drawer").doGesture {
+ onNodeWithTag("Drawer").performGesture {
val left = 1.0f
val centerY = (globalBounds.height / 2)
- sendClick(Offset(left, centerY))
+ click(Offset(left, centerY))
}
runOnIdleCompose {
@@ -309,7 +309,7 @@
}
// Click in the middle of the drawer (which is the middle of the body)
- findByTag("Drawer").doGesture { sendClick() }
+ onNodeWithTag("Drawer").performGesture { click() }
runOnIdleCompose {
assertThat(drawerClicks).isEqualTo(0)
@@ -322,11 +322,11 @@
sleep(100) // TODO(147586311): remove this sleep when opening the drawer triggers a wait
// Click on the bottom-center pixel of the drawer
- findByTag("Drawer").doGesture {
+ onNodeWithTag("Drawer").performGesture {
val bounds = globalBounds
val centerX = bounds.width / 2
val bottom = bounds.height - 1.0f
- sendClick(Offset(centerX, bottom))
+ click(Offset(centerX, bottom))
}
assertThat(drawerClicks).isEqualTo(1)
@@ -349,15 +349,15 @@
}
}
- findByTag("Drawer")
- .doGesture { sendSwipeRight() }
+ onNodeWithTag("Drawer")
+ .performGesture { swipeRight() }
runOnIdleCompose {
assertThat(drawerState.value).isEqualTo(DrawerState.Opened)
}
- findByTag("Drawer")
- .doGesture { sendSwipeLeft() }
+ onNodeWithTag("Drawer")
+ .performGesture { swipeLeft() }
runOnIdleCompose {
assertThat(drawerState.value).isEqualTo(DrawerState.Closed)
@@ -380,15 +380,15 @@
}
}
- findByTag("Drawer")
- .doGesture { sendSwipeLeft() }
+ onNodeWithTag("Drawer")
+ .performGesture { swipeLeft() }
runOnIdleCompose {
assertThat(drawerState.value).isEqualTo(DrawerState.Opened)
}
- findByTag("Drawer")
- .doGesture { sendSwipeRight() }
+ onNodeWithTag("Drawer")
+ .performGesture { swipeRight() }
runOnIdleCompose {
assertThat(drawerState.value).isEqualTo(DrawerState.Closed)
@@ -411,15 +411,15 @@
}
}
- findByTag("Drawer")
- .doGesture { sendSwipeUp() }
+ onNodeWithTag("Drawer")
+ .performGesture { swipeUp() }
runOnIdleCompose {
assertThat(drawerState.value).isEqualTo(BottomDrawerState.Expanded)
}
- findByTag("Drawer")
- .doGesture { sendSwipeDown() }
+ onNodeWithTag("Drawer")
+ .performGesture { swipeDown() }
runOnIdleCompose {
assertThat(drawerState.value).isEqualTo(BottomDrawerState.Closed)
@@ -443,68 +443,68 @@
}
val threshold = with (composeTestRule.density) { BottomDrawerThreshold.toPx() }
- findByTag("Drawer")
- .doGesture { sendSwipeUpBy(threshold / 2) }
+ onNodeWithTag("Drawer")
+ .performGesture { swipeUpBy(threshold / 2) }
runOnIdleCompose {
assertThat(drawerState.value).isEqualTo(BottomDrawerState.Closed)
}
- findByTag("Drawer")
- .doGesture { sendSwipeUpBy(threshold) }
+ onNodeWithTag("Drawer")
+ .performGesture { swipeUpBy(threshold) }
runOnIdleCompose {
assertThat(drawerState.value).isEqualTo(BottomDrawerState.Opened)
}
- findByTag("Drawer")
- .doGesture { sendSwipeUpBy(threshold / 2) }
+ onNodeWithTag("Drawer")
+ .performGesture { swipeUpBy(threshold / 2) }
runOnIdleCompose {
assertThat(drawerState.value).isEqualTo(BottomDrawerState.Opened)
}
- findByTag("Drawer")
- .doGesture { sendSwipeUpBy(threshold) }
+ onNodeWithTag("Drawer")
+ .performGesture { swipeUpBy(threshold) }
runOnIdleCompose {
assertThat(drawerState.value).isEqualTo(BottomDrawerState.Expanded)
}
- findByTag("Drawer")
- .doGesture { sendSwipeDownBy(threshold / 2) }
+ onNodeWithTag("Drawer")
+ .performGesture { swipeDownBy(threshold / 2) }
runOnIdleCompose {
assertThat(drawerState.value).isEqualTo(BottomDrawerState.Expanded)
}
- findByTag("Drawer")
- .doGesture { sendSwipeDownBy(threshold) }
+ onNodeWithTag("Drawer")
+ .performGesture { swipeDownBy(threshold) }
runOnIdleCompose {
assertThat(drawerState.value).isEqualTo(BottomDrawerState.Opened)
}
- findByTag("Drawer")
- .doGesture { sendSwipeDownBy(threshold / 2) }
+ onNodeWithTag("Drawer")
+ .performGesture { swipeDownBy(threshold / 2) }
runOnIdleCompose {
assertThat(drawerState.value).isEqualTo(BottomDrawerState.Opened)
}
- findByTag("Drawer")
- .doGesture { sendSwipeDownBy(threshold) }
+ onNodeWithTag("Drawer")
+ .performGesture { swipeDownBy(threshold) }
runOnIdleCompose {
assertThat(drawerState.value).isEqualTo(BottomDrawerState.Closed)
}
}
- private fun GestureScope.sendSwipeUpBy(offset: Float) {
- sendSwipe(center, center.copy(y = center.y - offset))
+ private fun GestureScope.swipeUpBy(offset: Float) {
+ swipe(center, center.copy(y = center.y - offset))
}
- private fun GestureScope.sendSwipeDownBy(offset: Float) {
- sendSwipe(center, center.copy(y = center.y + offset))
+ private fun GestureScope.swipeDownBy(offset: Float) {
+ swipe(center, center.copy(y = center.y + offset))
}
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ElevationOverlayTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/ElevationOverlayTest.kt
index 203aec8..e04243b 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/ElevationOverlayTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/ElevationOverlayTest.kt
@@ -27,7 +27,7 @@
import androidx.ui.test.assertPixels
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.unit.Dp
import androidx.ui.unit.IntSize
import androidx.ui.unit.dp
@@ -70,7 +70,7 @@
fun correctElevationOverlayInDarkTheme() {
setupSurfaceForTesting(elevation!!, darkColorPalette())
- findByTag(Tag)
+ onNodeWithTag(Tag)
.captureToBitmap()
.assertPixels(SurfaceSize) {
expectedOverlayColor
@@ -84,7 +84,7 @@
// No overlay should be applied in light theme
val expectedSurfaceColor = Color.White
- findByTag(Tag)
+ onNodeWithTag(Tag)
.captureToBitmap()
.assertPixels(SurfaceSize) {
expectedSurfaceColor
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/FloatingActionButtonTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/FloatingActionButtonTest.kt
index 99fcc38..75a32e6 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/FloatingActionButtonTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/FloatingActionButtonTest.kt
@@ -41,9 +41,9 @@
import androidx.ui.test.assertWidthIsEqualTo
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.findByTag
-import androidx.ui.test.findByText
+import androidx.ui.test.performClick
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.onNodeWithText
import androidx.ui.test.runOnIdleCompose
import androidx.ui.unit.center
import androidx.ui.unit.dp
@@ -72,7 +72,7 @@
}
}
- findByTag("myButton")
+ onNodeWithTag("myButton")
.assertIsEnabled()
}
@@ -88,8 +88,8 @@
}
}
- findByText(text)
- .doClick()
+ onNodeWithText(text)
+ .performClick()
runOnIdleCompose {
assertThat(counter).isEqualTo(1)
@@ -118,7 +118,7 @@
)
}
- findByTag("FAB")
+ onNodeWithTag("FAB")
.assertHeightIsEqualTo(48.dp)
.assertWidthIsAtLeast(48.dp)
}
@@ -133,7 +133,7 @@
)
}
- findByTag("FAB")
+ onNodeWithTag("FAB")
.assertWidthIsEqualTo(48.dp)
.assertHeightIsEqualTo(48.dp)
}
@@ -161,7 +161,7 @@
}
}
- findByTag("myButton")
+ onNodeWithTag("myButton")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
@@ -194,7 +194,7 @@
}
}
- findByTag("myButton")
+ onNodeWithTag("myButton")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/IconButtonTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/IconButtonTest.kt
index 60256a7..84ace1d 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/IconButtonTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/IconButtonTest.kt
@@ -30,9 +30,9 @@
import androidx.ui.test.assertTopPositionInRootIsEqualTo
import androidx.ui.test.assertWidthIsEqualTo
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.find
-import androidx.ui.test.findByTag
+import androidx.ui.test.performClick
+import androidx.ui.test.onNode
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.isToggleable
import androidx.ui.unit.dp
import org.junit.Rule
@@ -76,7 +76,7 @@
}
// Icon should be centered inside the IconButton
- findByTag("icon", useUnmergedTree = true)
+ onNodeWithTag("icon", useUnmergedTree = true)
.assertLeftPositionInRootIsEqualTo(24.dp / 2)
.assertTopPositionInRootIsEqualTo(24.dp / 2)
}
@@ -97,7 +97,7 @@
}
// Icon should be centered inside the IconButton
- findByTag("icon", useUnmergedTree = true)
+ onNodeWithTag("icon", useUnmergedTree = true)
.assertLeftPositionInRootIsEqualTo((48.dp - width) / 2)
.assertTopPositionInRootIsEqualTo((48.dp - height) / 2)
}
@@ -129,7 +129,7 @@
}
// Icon should be centered inside the IconButton
- findByTag("icon", useUnmergedTree = true)
+ onNodeWithTag("icon", useUnmergedTree = true)
.assertLeftPositionInRootIsEqualTo(24.dp / 2)
.assertTopPositionInRootIsEqualTo(24.dp / 2)
}
@@ -149,7 +149,7 @@
}
// Icon should be centered inside the IconButton
- findByTag("icon", useUnmergedTree = true)
+ onNodeWithTag("icon", useUnmergedTree = true)
.assertLeftPositionInRootIsEqualTo((48.dp - width) / 2)
.assertTopPositionInRootIsEqualTo((48.dp - height) / 2)
}
@@ -159,9 +159,9 @@
composeTestRule.setMaterialContent {
IconToggleButtonSample()
}
- find(isToggleable()).apply {
+ onNode(isToggleable()).apply {
assertIsOff()
- doClick()
+ performClick()
assertIsOn()
}
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/MaterialTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/MaterialTest.kt
index b9cf4aa..64d21ff 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/MaterialTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/MaterialTest.kt
@@ -29,8 +29,8 @@
import androidx.ui.test.assertHeightIsEqualTo
import androidx.ui.test.assertIsEqualTo
import androidx.ui.test.assertWidthIsEqualTo
-import androidx.ui.test.findByTag
-import androidx.ui.test.findRoot
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.onRoot
import androidx.ui.test.getAlignmentLinePosition
import androidx.ui.test.runOnIdleCompose
import androidx.ui.text.FirstBaseline
@@ -77,7 +77,7 @@
}
fun rootWidth(): Dp {
- val nodeInteraction = findRoot()
+ val nodeInteraction = onRoot()
val node = nodeInteraction.fetchSemanticsNode("Failed to get screen width")
@OptIn(ExperimentalLayoutNodeApi::class)
val owner = node.componentNode.owner as AndroidOwner
@@ -88,7 +88,7 @@
}
fun rootHeight(): Dp {
- val nodeInteraction = findRoot()
+ val nodeInteraction = onRoot()
val node = nodeInteraction.fetchSemanticsNode("Failed to get screen height")
@OptIn(ExperimentalLayoutNodeApi::class)
val owner = node.componentNode.owner as AndroidOwner
@@ -121,5 +121,5 @@
}
}
- return findByTag("containerForSizeAssertion")
+ return onNodeWithTag("containerForSizeAssertion")
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt
index ffbe7fd..7af020c 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/MenuTest.kt
@@ -34,10 +34,10 @@
import androidx.ui.layout.preferredSize
import androidx.ui.layout.size
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.find
-import androidx.ui.test.findByTag
-import androidx.ui.test.hasAnyDescendantThat
+import androidx.ui.test.performClick
+import androidx.ui.test.onNode
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.hasAnyDescendant
import androidx.ui.test.hasTestTag
import androidx.ui.test.isPopup
import androidx.ui.test.runOnIdleCompose
@@ -78,22 +78,22 @@
}
}
}
- findByTag("MenuContent").assertDoesNotExist()
+ onNodeWithTag("MenuContent").assertDoesNotExist()
runOnIdleCompose { expanded = true }
waitForIdle()
composeTestRule.clockTestRule.advanceClock(InTransitionDuration.toLong())
- findByTag("MenuContent").assertExists()
+ onNodeWithTag("MenuContent").assertExists()
runOnIdleCompose { expanded = false }
waitForIdle()
composeTestRule.clockTestRule.advanceClock(OutTransitionDuration.toLong())
- findByTag("MenuContent").assertDoesNotExist()
+ onNodeWithTag("MenuContent").assertDoesNotExist()
runOnIdleCompose { expanded = true }
waitForIdle()
composeTestRule.clockTestRule.advanceClock(InTransitionDuration.toLong())
- findByTag("MenuContent").assertExists()
+ onNodeWithTag("MenuContent").assertExists()
}
@Test
@@ -113,11 +113,11 @@
}
}
- findByTag("MenuContent1").assertExists()
- findByTag("MenuContent2").assertExists()
- val node = find(
- isPopup() and hasAnyDescendantThat(hasTestTag("MenuContent1")) and
- hasAnyDescendantThat(hasTestTag("MenuContent2"))
+ onNodeWithTag("MenuContent1").assertExists()
+ onNodeWithTag("MenuContent2").assertExists()
+ val node = onNode(
+ isPopup() and hasAnyDescendant(hasTestTag("MenuContent1")) and
+ hasAnyDescendant(hasTestTag("MenuContent2"))
).assertExists().fetchSemanticsNode()
with(composeTestRule.density) {
assertThat(node.size.width).isEqualTo(130 + MenuElevationInset.toIntPx() * 2)
@@ -316,7 +316,7 @@
}
}
- findByTag("MenuItem").doClick()
+ onNodeWithTag("MenuItem").performClick()
runOnIdleCompose {
assertThat(clicked).isTrue()
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ProgressIndicatorTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/ProgressIndicatorTest.kt
index 095ad0e..d000aff 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/ProgressIndicatorTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/ProgressIndicatorTest.kt
@@ -27,7 +27,7 @@
import androidx.ui.test.assertValueEquals
import androidx.ui.test.assertWidthIsEqualTo
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnUiThread
import androidx.ui.unit.dp
import org.junit.Ignore
@@ -56,7 +56,7 @@
LinearProgressIndicator(modifier = Modifier.testTag(tag), progress = progress.value)
}
- findByTag(tag)
+ onNodeWithTag(tag)
.assertIsDisplayed()
.assertValueEquals("0 percent")
.assertRangeInfoEquals(AccessibilityRangeInfo(0f, 0f..1f))
@@ -65,7 +65,7 @@
progress.value = 0.5f
}
- findByTag(tag)
+ onNodeWithTag(tag)
.assertIsDisplayed()
.assertValueEquals("50 percent")
.assertRangeInfoEquals(AccessibilityRangeInfo(0.5f, 0f..1f))
@@ -91,7 +91,7 @@
LinearProgressIndicator(modifier = Modifier.testTag(tag))
}
- findByTag(tag)
+ onNodeWithTag(tag)
.assertValueEquals(Strings.InProgress)
}
@@ -119,7 +119,7 @@
)
}
- findByTag(tag)
+ onNodeWithTag(tag)
.assertIsDisplayed()
.assertValueEquals("0 percent")
.assertRangeInfoEquals(AccessibilityRangeInfo(0f, 0f..1f))
@@ -128,7 +128,7 @@
progress.value = 0.5f
}
- findByTag(tag)
+ onNodeWithTag(tag)
.assertIsDisplayed()
.assertValueEquals("50 percent")
.assertRangeInfoEquals(AccessibilityRangeInfo(0.5f, 0f..1f))
@@ -153,7 +153,7 @@
CircularProgressIndicator(modifier = Modifier.testTag(tag))
}
- findByTag(tag)
+ onNodeWithTag(tag)
.assertValueEquals(Strings.InProgress)
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonScreenshotTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonScreenshotTest.kt
index 104ae67..f3be708 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonScreenshotTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonScreenshotTest.kt
@@ -31,12 +31,12 @@
import androidx.ui.test.captureToBitmap
import androidx.ui.test.center
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.doPartialGesture
-import androidx.ui.test.find
-import androidx.ui.test.findByTag
+import androidx.ui.test.performClick
+import androidx.ui.test.performPartialGesture
+import androidx.ui.test.onNode
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.isInMutuallyExclusiveGroup
-import androidx.ui.test.sendDown
+import androidx.ui.test.down
import androidx.ui.test.waitForIdle
import org.junit.Rule
import org.junit.Test
@@ -87,8 +87,8 @@
RadioButton(selected = false, >
}
}
- findByTag(wrapperTestTag).doPartialGesture {
- sendDown(center)
+ onNodeWithTag(wrapperTestTag).performPartialGesture {
+ down(center)
}
assertSelectableAgainstGolden("radioButton_pressed")
}
@@ -127,8 +127,8 @@
composeTestRule.clockTestRule.pauseClock()
- find(isInMutuallyExclusiveGroup())
- .doClick()
+ onNode(isInMutuallyExclusiveGroup())
+ .performClick()
waitForIdle()
@@ -151,8 +151,8 @@
composeTestRule.clockTestRule.pauseClock()
- find(isInMutuallyExclusiveGroup())
- .doClick()
+ onNode(isInMutuallyExclusiveGroup())
+ .performClick()
waitForIdle()
@@ -163,7 +163,7 @@
private fun assertSelectableAgainstGolden(goldenName: String) {
// TODO: replace with find(isInMutuallyExclusiveGroup()) after b/157687898 is fixed
- findByTag(wrapperTestTag)
+ onNodeWithTag(wrapperTestTag)
.captureToBitmap()
.assertAgainstGolden(screenshotRule, goldenName)
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonTest.kt
index cd48273..0f5f167 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/RadioButtonTest.kt
@@ -28,8 +28,8 @@
import androidx.ui.test.assertIsUnselected
import androidx.ui.test.assertValueEquals
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.findByTag
+import androidx.ui.test.performClick
+import androidx.ui.test.onNodeWithTag
import androidx.ui.unit.dp
import org.junit.Rule
import org.junit.Test
@@ -75,9 +75,9 @@
}
}
- findByTag(itemOne).assertHasSelectedSemantics()
- findByTag(itemTwo).assertHasUnSelectedSemantics()
- findByTag(itemThree).assertHasUnSelectedSemantics()
+ onNodeWithTag(itemOne).assertHasSelectedSemantics()
+ onNodeWithTag(itemTwo).assertHasUnSelectedSemantics()
+ onNodeWithTag(itemThree).assertHasUnSelectedSemantics()
}
@Test
@@ -96,15 +96,15 @@
}
}
- findByTag(itemOne)
+ onNodeWithTag(itemOne)
.assertHasSelectedSemantics()
- .doClick()
+ .performClick()
.assertHasSelectedSemantics()
- findByTag(itemTwo)
+ onNodeWithTag(itemTwo)
.assertHasUnSelectedSemantics()
- findByTag(itemThree)
+ onNodeWithTag(itemThree)
.assertHasUnSelectedSemantics()
}
@@ -122,15 +122,15 @@
}
}
}
- findByTag(itemTwo)
+ onNodeWithTag(itemTwo)
.assertHasUnSelectedSemantics()
- .doClick()
+ .performClick()
.assertHasSelectedSemantics()
- findByTag(itemOne)
+ onNodeWithTag(itemOne)
.assertHasUnSelectedSemantics()
- findByTag(itemThree)
+ onNodeWithTag(itemThree)
.assertHasUnSelectedSemantics()
}
@@ -150,23 +150,23 @@
}
}
- findByTag(itemTwo)
+ onNodeWithTag(itemTwo)
.assertHasUnSelectedSemantics()
- .doClick()
+ .performClick()
.assertHasSelectedSemantics()
- findByTag(itemOne)
+ onNodeWithTag(itemOne)
.assertHasUnSelectedSemantics()
- findByTag(itemThree)
+ onNodeWithTag(itemThree)
.assertHasUnSelectedSemantics()
- .doClick()
+ .performClick()
.assertHasSelectedSemantics()
- findByTag(itemOne)
+ onNodeWithTag(itemOne)
.assertHasUnSelectedSemantics()
- findByTag(itemTwo)
+ onNodeWithTag(itemTwo)
.assertHasUnSelectedSemantics()
}
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 3c55c35..f18e253 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
@@ -46,12 +46,12 @@
import androidx.ui.test.assertWidthIsEqualTo
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doGesture
-import androidx.ui.test.findByTag
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnIdleCompose
import androidx.ui.test.runOnUiThread
-import androidx.ui.test.sendSwipeLeft
-import androidx.ui.test.sendSwipeRight
+import androidx.ui.test.swipeLeft
+import androidx.ui.test.swipeRight
import androidx.ui.unit.IntSize
import androidx.ui.unit.dp
import androidx.ui.unit.toSize
@@ -200,12 +200,12 @@
}
}
assertThat(drawerChildPosition.x).isLessThan(0f)
- findByTag(scaffoldTag).doGesture {
- sendSwipeRight()
+ onNodeWithTag(scaffoldTag).performGesture {
+ swipeRight()
}
assertThat(drawerChildPosition.x).isLessThan(0f)
- findByTag(scaffoldTag).doGesture {
- sendSwipeLeft()
+ onNodeWithTag(scaffoldTag).performGesture {
+ swipeLeft()
}
assertThat(drawerChildPosition.x).isLessThan(0f)
@@ -213,12 +213,12 @@
scaffoldState.isDrawerGesturesEnabled = true
}
- findByTag(scaffoldTag).doGesture {
- sendSwipeRight()
+ onNodeWithTag(scaffoldTag).performGesture {
+ swipeRight()
}
assertThat(drawerChildPosition.x).isEqualTo(0f)
- findByTag(scaffoldTag).doGesture {
- sendSwipeLeft()
+ onNodeWithTag(scaffoldTag).performGesture {
+ swipeLeft()
}
assertThat(drawerChildPosition.x).isLessThan(0f)
}
@@ -367,7 +367,7 @@
}
}
- findByTag("Scaffold")
+ onNodeWithTag("Scaffold")
.captureToBitmap().apply {
// asserts the appbar(top half part) has the shadow
val yPos = height / 2 + 2
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/SliderTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/SliderTest.kt
index 4fc7d44..732e0ea 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/SliderTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/SliderTest.kt
@@ -39,15 +39,15 @@
import androidx.ui.test.centerX
import androidx.ui.test.centerY
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doPartialGesture
-import androidx.ui.test.findByTag
+import androidx.ui.test.performPartialGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.left
import androidx.ui.test.right
import androidx.ui.test.runOnIdleCompose
import androidx.ui.test.runOnUiThread
-import androidx.ui.test.sendDown
-import androidx.ui.test.sendMoveBy
-import androidx.ui.test.sendUp
+import androidx.ui.test.down
+import androidx.ui.test.moveBy
+import androidx.ui.test.up
import androidx.ui.unit.dp
import com.google.common.truth.Truth
import org.junit.Assert.assertEquals
@@ -83,11 +83,11 @@
runOnIdleCompose {
state.value = 2f
}
- findByTag(tag).assertValueEquals("100 percent")
+ onNodeWithTag(tag).assertValueEquals("100 percent")
runOnIdleCompose {
state.value = -123145f
}
- findByTag(tag).assertValueEquals("0 percent")
+ onNodeWithTag(tag).assertValueEquals("0 percent")
}
@Test(expected = IllegalArgumentException::class)
@@ -107,14 +107,14 @@
state.value = it })
}
- findByTag(tag)
+ onNodeWithTag(tag)
.assertValueEquals("0 percent")
runOnUiThread {
state.value = 0.5f
}
- findByTag(tag)
+ onNodeWithTag(tag)
.assertValueEquals("50 percent")
}
@@ -137,11 +137,11 @@
var expected = 0f
- findByTag(tag)
- .doPartialGesture {
- sendDown(center)
- sendMoveBy(Offset(100f, 0f))
- sendUp()
+ onNodeWithTag(tag)
+ .performPartialGesture {
+ down(center)
+ moveBy(Offset(100f, 0f))
+ up()
expected = calculateFraction(left, right, centerX + 100)
}
runOnIdleCompose {
@@ -168,10 +168,10 @@
var expected = 0f
- findByTag(tag)
- .doPartialGesture {
- sendDown(Offset(centerX + 50, centerY))
- sendUp()
+ onNodeWithTag(tag)
+ .performPartialGesture {
+ down(Offset(centerX + 50, centerY))
+ up()
expected = calculateFraction(left, right, centerX + 50)
}
runOnIdleCompose {
@@ -198,11 +198,11 @@
var expected = 0f
- findByTag(tag)
- .doPartialGesture {
- sendDown(center)
- sendMoveBy(Offset(100f, 0f))
- sendUp()
+ onNodeWithTag(tag)
+ .performPartialGesture {
+ down(center)
+ moveBy(Offset(100f, 0f))
+ up()
// subtract here as we're in rtl and going in the opposite direction
expected = calculateFraction(left, right, centerX - 100)
}
@@ -230,10 +230,10 @@
var expected = 0f
- findByTag(tag)
- .doPartialGesture {
- sendDown(Offset(centerX + 50, centerY))
- sendUp()
+ onNodeWithTag(tag)
+ .performPartialGesture {
+ down(Offset(centerX + 50, centerY))
+ up()
expected = calculateFraction(left, right, centerX - 50)
}
runOnIdleCompose {
@@ -273,7 +273,7 @@
)
}
- findByTag(sliderTag).captureToBitmap().apply {
+ onNodeWithTag(sliderTag).captureToBitmap().apply {
assertNotEquals(0, thumbStrokeWidth)
assertNotEquals(0, thumbPx)
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 d91be77..13cadce 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
@@ -37,9 +37,9 @@
import androidx.ui.test.assertWidthIsEqualTo
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.findByTag
-import androidx.ui.test.findByText
+import androidx.ui.test.performClick
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.onNodeWithText
import androidx.ui.test.getAlignmentLinePosition
import androidx.ui.test.getBoundsInRoot
import androidx.ui.text.FirstBaseline
@@ -77,13 +77,13 @@
}
}
- findByText("Message")
+ onNodeWithText("Message")
.assertExists()
assertThat(clicked).isFalse()
- findByText("UNDO")
- .doClick()
+ onNodeWithText("UNDO")
+ .performClick()
assertThat(clicked).isTrue()
}
@@ -102,13 +102,13 @@
.assertWidthIsEqualTo(300.dp)
.assertHeightIsEqualTo(48.dp)
- val firstBaseLine = findByText("Message").getAlignmentLinePosition(FirstBaseline)
- val lastBaseLine = findByText("Message").getAlignmentLinePosition(LastBaseline)
+ val firstBaseLine = onNodeWithText("Message").getAlignmentLinePosition(FirstBaseline)
+ val lastBaseLine = onNodeWithText("Message").getAlignmentLinePosition(LastBaseline)
firstBaseLine.assertIsNotEqualTo(0.dp, "first baseline")
firstBaseLine.assertIsEqualTo(lastBaseLine, "first baseline")
val snackBounds = snackbar.getBoundsInRoot()
- val textBounds = findByText("Message").getBoundsInRoot()
+ val textBounds = onNodeWithText("Message").getBoundsInRoot()
val textTopOffset = textBounds.top - snackBounds.top
val textBottomOffset = textBounds.top - snackBounds.top
@@ -129,13 +129,13 @@
}
.assertWidthIsEqualTo(300.dp)
- val firstBaseLine = findByText("Message").getAlignmentLinePosition(FirstBaseline)
- val lastBaseLine = findByText("Message").getAlignmentLinePosition(LastBaseline)
+ val firstBaseLine = onNodeWithText("Message").getAlignmentLinePosition(FirstBaseline)
+ val lastBaseLine = onNodeWithText("Message").getAlignmentLinePosition(LastBaseline)
firstBaseLine.assertIsNotEqualTo(0.dp, "first baseline")
firstBaseLine.assertIsEqualTo(lastBaseLine, "first baseline")
val snackBounds = snackbar.getBoundsInRoot()
- val textBounds = findByText("Message").getBoundsInRoot()
+ val textBounds = onNodeWithText("Message").getBoundsInRoot()
val textTopOffset = textBounds.top - snackBounds.top
val textBottomOffset = textBounds.top - snackBounds.top
@@ -165,14 +165,14 @@
.assertWidthIsEqualTo(300.dp)
.assertHeightIsEqualTo(48.dp)
- val textBaseLine = findByText("Message").getAlignmentLinePosition(FirstBaseline)
- val buttonBaseLine = findByTag("button").getAlignmentLinePosition(FirstBaseline)
+ val textBaseLine = onNodeWithText("Message").getAlignmentLinePosition(FirstBaseline)
+ val buttonBaseLine = onNodeWithTag("button").getAlignmentLinePosition(FirstBaseline)
textBaseLine.assertIsNotEqualTo(0.dp, "text baseline")
buttonBaseLine.assertIsNotEqualTo(0.dp, "button baseline")
val snackBounds = snackbar.getBoundsInRoot()
- val textBounds = findByText("Message").getBoundsInRoot()
- val buttonBounds = findByText("Undo").getBoundsInRoot()
+ val textBounds = onNodeWithText("Message").getBoundsInRoot()
+ val buttonBounds = onNodeWithText("Undo").getBoundsInRoot()
val buttonTopOffset = buttonBounds.top - snackBounds.top
val textTopOffset = textBounds.top - snackBounds.top
@@ -203,14 +203,14 @@
)
}
- val textBaseLine = findByText("Message").getAlignmentLinePosition(FirstBaseline)
- val buttonBaseLine = findByTag("button").getAlignmentLinePosition(FirstBaseline)
+ val textBaseLine = onNodeWithText("Message").getAlignmentLinePosition(FirstBaseline)
+ val buttonBaseLine = onNodeWithTag("button").getAlignmentLinePosition(FirstBaseline)
textBaseLine.assertIsNotEqualTo(0.dp, "text baseline")
buttonBaseLine.assertIsNotEqualTo(0.dp, "button baseline")
val snackBounds = snackbar.getBoundsInRoot()
- val textBounds = findByText("Message").getBoundsInRoot()
- val buttonBounds = findByText("Undo").getBoundsInRoot()
+ val textBounds = onNodeWithText("Message").getBoundsInRoot()
+ val buttonBounds = onNodeWithText("Undo").getBoundsInRoot()
val buttonTopOffset = buttonBounds.top - snackBounds.top
val textTopOffset = textBounds.top - snackBounds.top
@@ -234,15 +234,15 @@
.assertWidthIsEqualTo(300.dp)
.assertHeightIsEqualTo(68.dp)
- val firstBaseline = findByTag("text").getFirstBaselinePosition()
- val lastBaseline = findByTag("text").getLastBaselinePosition()
+ val firstBaseline = onNodeWithTag("text").getFirstBaselinePosition()
+ val lastBaseline = onNodeWithTag("text").getLastBaselinePosition()
firstBaseline.assertIsNotEqualTo(0.dp, "first baseline")
lastBaseline.assertIsNotEqualTo(0.dp, "last baseline")
firstBaseline.assertIsNotEqualTo(lastBaseline, "first baseline")
val snackBounds = snackbar.getBoundsInRoot()
- val textBounds = findByTag("text").getBoundsInRoot()
+ val textBounds = onNodeWithTag("text").getBoundsInRoot()
val textTopOffset = textBounds.top - snackBounds.top
val textBottomOffset = textBounds.top - snackBounds.top
@@ -272,17 +272,17 @@
.assertWidthIsEqualTo(300.dp)
.assertHeightIsEqualTo(68.dp)
- val textFirstBaseLine = findByTag("text").getFirstBaselinePosition()
- val textLastBaseLine = findByTag("text").getLastBaselinePosition()
+ val textFirstBaseLine = onNodeWithTag("text").getFirstBaselinePosition()
+ val textLastBaseLine = onNodeWithTag("text").getLastBaselinePosition()
textFirstBaseLine.assertIsNotEqualTo(0.dp, "first baseline")
textLastBaseLine.assertIsNotEqualTo(0.dp, "last baseline")
textFirstBaseLine.assertIsNotEqualTo(textLastBaseLine, "first baseline")
- findByTag("text")
+ onNodeWithTag("text")
.assertTopPositionInRootIsEqualTo(30.dp - textFirstBaseLine)
- val buttonBounds = findByTag("button").getBoundsInRoot()
+ val buttonBounds = onNodeWithTag("button").getBoundsInRoot()
val snackBounds = snackbar.getBoundsInRoot()
val buttonCenter = buttonBounds.top + (buttonBounds.height / 2)
@@ -310,15 +310,15 @@
)
}
- val textFirstBaseLine = findByText("Message").getFirstBaselinePosition()
- val textLastBaseLine = findByText("Message").getLastBaselinePosition()
- val textBounds = findByText("Message").getBoundsInRoot()
- val buttonBounds = findByTag("button").getBoundsInRoot()
+ val textFirstBaseLine = onNodeWithText("Message").getFirstBaselinePosition()
+ val textLastBaseLine = onNodeWithText("Message").getLastBaselinePosition()
+ val textBounds = onNodeWithText("Message").getBoundsInRoot()
+ val buttonBounds = onNodeWithTag("button").getBoundsInRoot()
- findByText("Message")
+ onNodeWithText("Message")
.assertTopPositionInRootIsEqualTo(30.dp - textFirstBaseLine)
- findByTag("button")
+ onNodeWithTag("button")
.assertTopPositionInRootIsEqualTo(18.dp + textBounds.top + textLastBaseLine)
snackbar
@@ -349,7 +349,7 @@
}
}
- findByTag("snackbar")
+ onNodeWithTag("snackbar")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/SurfaceTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/SurfaceTest.kt
index 22af85e..538796d 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/SurfaceTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/SurfaceTest.kt
@@ -33,7 +33,7 @@
import androidx.ui.test.assertShape
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.unit.dp
import org.junit.Rule
import org.junit.Test
@@ -64,7 +64,7 @@
}
}
- findByTag("stack")
+ onNodeWithTag("stack")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
@@ -91,7 +91,7 @@
}
}
- findByTag("stack")
+ onNodeWithTag("stack")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
@@ -116,7 +116,7 @@
}
}
- findByTag("stack")
+ onNodeWithTag("stack")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
@@ -141,7 +141,7 @@
}
}
- findByTag("stack")
+ onNodeWithTag("stack")
.captureToBitmap()
.assertShape(
density = composeTestRule.density,
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/SwitchScreenshotTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/SwitchScreenshotTest.kt
index 2170258..17401b2 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/SwitchScreenshotTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/SwitchScreenshotTest.kt
@@ -32,12 +32,12 @@
import androidx.ui.test.captureToBitmap
import androidx.ui.test.center
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.doPartialGesture
-import androidx.ui.test.find
-import androidx.ui.test.findByTag
+import androidx.ui.test.performClick
+import androidx.ui.test.performPartialGesture
+import androidx.ui.test.onNode
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.isToggleable
-import androidx.ui.test.sendDown
+import androidx.ui.test.down
import androidx.ui.test.waitForIdle
import org.junit.Rule
import org.junit.Test
@@ -121,8 +121,8 @@
}
}
- findByTag(wrapperTestTag).doPartialGesture {
- sendDown(center)
+ onNodeWithTag(wrapperTestTag).performPartialGesture {
+ down(center)
}
assertToggeableAgainstGolden("switch_pressed")
}
@@ -161,8 +161,8 @@
composeTestRule.clockTestRule.pauseClock()
- find(isToggleable())
- .doClick()
+ onNode(isToggleable())
+ .performClick()
waitForIdle()
@@ -185,8 +185,8 @@
composeTestRule.clockTestRule.pauseClock()
- find(isToggleable())
- .doClick()
+ onNode(isToggleable())
+ .performClick()
waitForIdle()
@@ -197,7 +197,7 @@
private fun assertToggeableAgainstGolden(goldenName: String) {
// TODO: replace with find(isToggeable()) after b/157687898 is fixed
- findByTag(wrapperTestTag)
+ onNodeWithTag(wrapperTestTag)
.captureToBitmap()
.assertAgainstGolden(screenshotRule, goldenName)
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/SwitchTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/SwitchTest.kt
index 19f3247..0419d2b 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/SwitchTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/SwitchTest.kt
@@ -33,12 +33,12 @@
import androidx.ui.test.assertValueEquals
import androidx.ui.test.assertWidthIsEqualTo
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.doGesture
-import androidx.ui.test.findByTag
+import androidx.ui.test.performClick
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendSwipeLeft
-import androidx.ui.test.sendSwipeRight
+import androidx.ui.test.swipeLeft
+import androidx.ui.test.swipeRight
import androidx.ui.unit.dp
import com.google.common.truth.Truth
import org.junit.Rule
@@ -68,11 +68,11 @@
}
}
- findByTag("checked")
+ onNodeWithTag("checked")
.assertIsEnabled()
.assertIsOn()
.assertValueEquals(Strings.Checked)
- findByTag("unchecked")
+ onNodeWithTag("unchecked")
.assertIsEnabled()
.assertIsOff()
.assertValueEquals(Strings.Unchecked)
@@ -92,9 +92,9 @@
)
}
}
- findByTag(defaultSwitchTag)
+ onNodeWithTag(defaultSwitchTag)
.assertIsOff()
- .doClick()
+ .performClick()
.assertIsOn()
}
@@ -112,11 +112,11 @@
)
}
}
- findByTag(defaultSwitchTag)
+ onNodeWithTag(defaultSwitchTag)
.assertIsOff()
- .doClick()
+ .performClick()
.assertIsOn()
- .doClick()
+ .performClick()
.assertIsOff()
}
@@ -131,7 +131,7 @@
enabled = false
)
}
- findByTag(defaultSwitchTag)
+ onNodeWithTag(defaultSwitchTag)
.assertHasNoClickAction()
}
@@ -160,15 +160,15 @@
}
}
- findByTag(defaultSwitchTag)
- .doGesture { sendSwipeRight() }
+ onNodeWithTag(defaultSwitchTag)
+ .performGesture { swipeRight() }
runOnIdleCompose {
Truth.assertThat(state.value).isEqualTo(true)
}
- findByTag(defaultSwitchTag)
- .doGesture { sendSwipeLeft() }
+ onNodeWithTag(defaultSwitchTag)
+ .performGesture { swipeLeft() }
runOnIdleCompose {
Truth.assertThat(state.value).isEqualTo(false)
@@ -190,15 +190,15 @@
}
}
- findByTag(defaultSwitchTag)
- .doGesture { sendSwipeLeft() }
+ onNodeWithTag(defaultSwitchTag)
+ .performGesture { swipeLeft() }
runOnIdleCompose {
Truth.assertThat(state.value).isEqualTo(true)
}
- findByTag(defaultSwitchTag)
- .doGesture { sendSwipeRight() }
+ onNodeWithTag(defaultSwitchTag)
+ .performGesture { swipeRight() }
runOnIdleCompose {
Truth.assertThat(state.value).isEqualTo(false)
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 27958ae..be7c851 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
@@ -40,9 +40,9 @@
import androidx.ui.test.assertIsUnselected
import androidx.ui.test.assertPositionInRootIsEqualTo
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.findAll
-import androidx.ui.test.findByTag
+import androidx.ui.test.performClick
+import androidx.ui.test.onAllNodes
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.getBoundsInRoot
import androidx.ui.test.isInMutuallyExclusiveGroup
import androidx.ui.unit.dp
@@ -133,20 +133,20 @@
}
}
- val tabRowBounds = findByTag("tabRow").getBoundsInRoot()
+ val tabRowBounds = onNodeWithTag("tabRow").getBoundsInRoot()
- findByTag("indicator")
+ onNodeWithTag("indicator")
.assertPositionInRootIsEqualTo(
expectedLeft = 0.dp,
expectedTop = tabRowBounds.height - indicatorHeight
)
// Click the second tab
- findAll(isInMutuallyExclusiveGroup())[1].doClick()
+ onAllNodes(isInMutuallyExclusiveGroup())[1].performClick()
// Indicator should now be placed in the bottom left of the second tab, so its x coordinate
// should be in the middle of the TabRow
- findByTag("indicator")
+ onNodeWithTag("indicator")
.assertPositionInRootIsEqualTo(
expectedLeft = (tabRowBounds.width / 2),
expectedTop = tabRowBounds.height - indicatorHeight
@@ -180,9 +180,9 @@
val indicatorHeight = 2.dp
val expectedBaselineDistance = expectedBaseline + indicatorHeight
- val tabRowBounds = findByTag("tabRow").getBoundsInRoot()
- val textBounds = findByTag("text").getBoundsInRoot()
- val textBaselinePos = findByTag("text").getLastBaselinePosition()
+ val tabRowBounds = onNodeWithTag("tabRow").getBoundsInRoot()
+ val textBounds = onNodeWithTag("text").getBoundsInRoot()
+ val textBaselinePos = onNodeWithTag("text").getLastBaselinePosition()
val baselinePositionY = textBounds.top + textBaselinePos
val expectedPositionY = tabRowBounds.height - expectedBaselineDistance
@@ -217,9 +217,9 @@
val indicatorHeight = 2.dp
val expectedBaselineDistance = expectedBaseline + indicatorHeight
- val tabRowBounds = findByTag("tabRow").getBoundsInRoot()
- val textBounds = findByTag("text").getBoundsInRoot()
- val textBaselinePos = findByTag("text").getLastBaselinePosition()
+ val tabRowBounds = onNodeWithTag("tabRow").getBoundsInRoot()
+ val textBounds = onNodeWithTag("text").getBoundsInRoot()
+ val textBaselinePos = onNodeWithTag("text").getLastBaselinePosition()
val baselinePositionY = textBounds.top + textBaselinePos
val expectedPositionY = tabRowBounds.height - expectedBaselineDistance
@@ -252,9 +252,9 @@
val expectedBaseline = 10.dp
val indicatorHeight = 2.dp
- val tabRowBounds = findByTag("tabRow").getBoundsInRoot()
- val textBounds = findByTag("text").getBoundsInRoot()
- val textBaselinePos = findByTag("text").getLastBaselinePosition()
+ val tabRowBounds = onNodeWithTag("tabRow").getBoundsInRoot()
+ val textBounds = onNodeWithTag("text").getBoundsInRoot()
+ val textBaselinePos = onNodeWithTag("text").getLastBaselinePosition()
val expectedBaselineDistance = expectedBaseline + indicatorHeight
@@ -301,10 +301,10 @@
}
}
- val tabRowBounds = findByTag("tabRow").getBoundsInRoot()
+ val tabRowBounds = onNodeWithTag("tabRow").getBoundsInRoot()
// Indicator should be placed in the bottom left of the first tab
- findByTag("indicator")
+ onNodeWithTag("indicator")
.assertPositionInRootIsEqualTo(
// Tabs in a scrollable tab row are offset 52.dp from each end
expectedLeft = scrollableTabRowOffset,
@@ -312,11 +312,11 @@
)
// Click the second tab
- findAll(isInMutuallyExclusiveGroup())[1].doClick()
+ onAllNodes(isInMutuallyExclusiveGroup())[1].performClick()
// Indicator should now be placed in the bottom left of the second tab, so its x coordinate
// should be in the middle of the TabRow
- findByTag("indicator")
+ onNodeWithTag("indicator")
.assertPositionInRootIsEqualTo(
expectedLeft = scrollableTabRowOffset + minimumTabWidth,
expectedTop = tabRowBounds.height - indicatorHeight
@@ -331,7 +331,7 @@
}
// Only the first tab should be selected
- findAll(isInMutuallyExclusiveGroup())
+ onAllNodes(isInMutuallyExclusiveGroup())
.assertCountEquals(3)
.apply {
get(0).assertIsSelected()
@@ -348,7 +348,7 @@
}
// Only the first tab should be selected
- findAll(isInMutuallyExclusiveGroup())
+ onAllNodes(isInMutuallyExclusiveGroup())
.assertCountEquals(3)
.apply {
get(0).assertIsSelected()
@@ -357,10 +357,10 @@
}
// Click the last tab
- findAll(isInMutuallyExclusiveGroup())[2].doClick()
+ onAllNodes(isInMutuallyExclusiveGroup())[2].performClick()
// Now only the last tab should be selected
- findAll(isInMutuallyExclusiveGroup())
+ onAllNodes(isInMutuallyExclusiveGroup())
.assertCountEquals(3)
.apply {
get(0).assertIsUnselected()
@@ -377,7 +377,7 @@
}
// Only the first tab should be selected
- findAll(isInMutuallyExclusiveGroup())
+ onAllNodes(isInMutuallyExclusiveGroup())
.assertCountEquals(10)
.apply {
get(0).assertIsSelected()
@@ -395,7 +395,7 @@
}
// Only the first tab should be selected
- findAll(isInMutuallyExclusiveGroup())
+ onAllNodes(isInMutuallyExclusiveGroup())
.assertCountEquals(10)
.apply {
get(0).assertIsSelected()
@@ -405,10 +405,10 @@
}
// Click the second tab
- findAll(isInMutuallyExclusiveGroup())[1].doClick()
+ onAllNodes(isInMutuallyExclusiveGroup())[1].performClick()
// Now only the second tab should be selected
- findAll(isInMutuallyExclusiveGroup())
+ onAllNodes(isInMutuallyExclusiveGroup())
.assertCountEquals(10)
.apply {
get(0).assertIsUnselected()
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/ripple/RippleIndicationTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/ripple/RippleIndicationTest.kt
index d52810d..8b8ed07 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/ripple/RippleIndicationTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/ripple/RippleIndicationTest.kt
@@ -51,7 +51,7 @@
import androidx.ui.test.ComposeTestRule
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnUiThread
import androidx.ui.test.waitForIdle
import androidx.ui.unit.dp
@@ -529,7 +529,7 @@
interactionState.addInteraction(Interaction.Pressed, Offset(10f, 10f))
}
- with(findByTag(Tag)) {
+ with(onNodeWithTag(Tag)) {
val centerPixel = captureToBitmap()
.run {
getPixel(width / 2, height / 2)
@@ -548,7 +548,7 @@
rippleTheme = createRippleTheme(newColor, newAlpha)
}
- with(findByTag(Tag)) {
+ with(onNodeWithTag(Tag)) {
val centerPixel = captureToBitmap()
.run {
getPixel(width / 2, height / 2)
@@ -594,7 +594,7 @@
composeTestRule.clockTestRule.advanceClock(50)
// Capture and compare screenshots
- findByTag(Tag)
+ onNodeWithTag(Tag)
.captureToBitmap()
.assertAgainstGolden(screenshotRule, goldenIdentifier)
@@ -604,7 +604,7 @@
waitForIdle()
// Compare expected and actual pixel color
- val centerPixel = findByTag(Tag)
+ val centerPixel = onNodeWithTag(Tag)
.captureToBitmap()
.run {
getPixel(width / 2, height / 2)
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/FilledTextFieldTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/FilledTextFieldTest.kt
index ad0d24d..85ad37b 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/FilledTextFieldTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/FilledTextFieldTest.kt
@@ -55,12 +55,12 @@
import androidx.ui.test.assertShape
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.doGesture
-import androidx.ui.test.doSendImeAction
-import androidx.ui.test.findByTag
+import androidx.ui.test.performClick
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendClick
+import androidx.ui.test.click
+import androidx.ui.test.performImeAction
import androidx.ui.test.waitForIdle
import androidx.ui.text.FirstBaseline
import androidx.ui.text.SoftwareKeyboardController
@@ -136,14 +136,14 @@
}
}
- findByTag(textField1Tag).doClick()
+ onNodeWithTag(textField1Tag).performClick()
runOnIdleCompose {
assertThat(textField1Focused).isTrue()
assertThat(textField2Focused).isFalse()
}
- findByTag(textField2Tag).doClick()
+ onNodeWithTag(textField2Tag).performClick()
runOnIdleCompose {
assertThat(textField1Focused).isFalse()
@@ -167,8 +167,8 @@
}
// Click on (2, 2) which is Surface area and outside input area
- findByTag(TextfieldTag).doGesture {
- sendClick(Offset(2f, 2f))
+ onNodeWithTag(TextfieldTag).performGesture {
+ click(Offset(2f, 2f))
}
testRule.runOnIdleComposeWithDensity {
@@ -465,7 +465,7 @@
}
// click to focus
- findByTag(TextfieldTag).doClick()
+ onNodeWithTag(TextfieldTag).performClick()
}
@Test
@@ -677,7 +677,7 @@
)
}
- findByTag(TextfieldTag)
+ onNodeWithTag(TextfieldTag)
.captureToBitmap()
.assertShape(
density = testRule.density,
@@ -714,7 +714,7 @@
val expectedColor = Color.Blue.copy(alpha = 0.12f).compositeOver(Color.White)
- findByTag(TextfieldTag)
+ onNodeWithTag(TextfieldTag)
.captureToBitmap()
.assertShape(
density = testRule.density,
@@ -725,10 +725,10 @@
shapeOverlapPixelCount = with(testRule.density) { 1.dp.toPx() }
)
- findByTag(TextfieldTag).doClick()
+ onNodeWithTag(TextfieldTag).performClick()
assert(latch.await(1, TimeUnit.SECONDS))
- findByTag(TextfieldTag)
+ onNodeWithTag(TextfieldTag)
.captureToBitmap()
.assertShape(
density = testRule.density,
@@ -757,8 +757,8 @@
}
assertThat(controller).isNull()
- findByTag(TextfieldTag)
- .doClick()
+ onNodeWithTag(TextfieldTag)
+ .performClick()
runOnIdleCompose {
assertThat(controller).isNotNull()
@@ -783,8 +783,8 @@
}
assertThat(controller).isNull()
- findByTag(TextfieldTag)
- .doSendImeAction()
+ onNodeWithTag(TextfieldTag)
+ .performImeAction()
runOnIdleCompose {
assertThat(controller).isNotNull()
@@ -792,7 +792,7 @@
}
private fun clickAndAdvanceClock(tag: String, time: Long) {
- findByTag(tag).doClick()
+ onNodeWithTag(tag).performClick()
waitForIdle()
testRule.clockTestRule.pauseClock()
testRule.clockTestRule.advanceClock(time)
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/OutlinedTextFieldTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/OutlinedTextFieldTest.kt
index b728ad7..6137d4c 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/OutlinedTextFieldTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/OutlinedTextFieldTest.kt
@@ -50,12 +50,12 @@
import androidx.ui.test.assertShape
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.doGesture
-import androidx.ui.test.doSendImeAction
-import androidx.ui.test.findByTag
+import androidx.ui.test.performClick
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendClick
+import androidx.ui.test.click
+import androidx.ui.test.performImeAction
import androidx.ui.test.waitForIdle
import androidx.ui.text.SoftwareKeyboardController
import androidx.ui.unit.IntSize
@@ -112,14 +112,14 @@
}
}
- findByTag(textField1Tag).doClick()
+ onNodeWithTag(textField1Tag).performClick()
runOnIdleCompose {
assertThat(textField1Focused).isTrue()
assertThat(textField2Focused).isFalse()
}
- findByTag(textField2Tag).doClick()
+ onNodeWithTag(textField2Tag).performClick()
runOnIdleCompose {
assertThat(textField1Focused).isFalse()
@@ -143,8 +143,8 @@
}
// Click on (2, 2) which is a background area and outside input area
- findByTag(TextfieldTag).doGesture {
- sendClick(Offset(2f, 2f))
+ onNodeWithTag(TextfieldTag).performGesture {
+ click(Offset(2f, 2f))
}
testRule.runOnIdleComposeWithDensity {
@@ -388,7 +388,7 @@
}
// click to focus
- findByTag(TextfieldTag).doClick()
+ onNodeWithTag(TextfieldTag).performClick()
}
@Test
@@ -593,7 +593,7 @@
}
}
- findByTag(TextfieldTag)
+ onNodeWithTag(TextfieldTag)
.captureToBitmap()
.assertShape(
density = testRule.density,
@@ -622,8 +622,8 @@
}
assertThat(controller).isNull()
- findByTag(TextfieldTag)
- .doClick()
+ onNodeWithTag(TextfieldTag)
+ .performClick()
runOnIdleCompose {
assertThat(controller).isNotNull()
@@ -648,8 +648,8 @@
}
assertThat(controller).isNull()
- findByTag(TextfieldTag)
- .doSendImeAction()
+ onNodeWithTag(TextfieldTag)
+ .performImeAction()
runOnIdleCompose {
assertThat(controller).isNotNull()
@@ -657,7 +657,7 @@
}
private fun clickAndAdvanceClock(tag: String, time: Long) {
- findByTag(tag).doClick()
+ onNodeWithTag(tag).performClick()
waitForIdle()
testRule.clockTestRule.pauseClock()
testRule.clockTestRule.advanceClock(time)
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldScreenshotTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldScreenshotTest.kt
index 38893bc..c8aafd2 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldScreenshotTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldScreenshotTest.kt
@@ -33,8 +33,8 @@
import androidx.ui.material.setMaterialContent
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doClick
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.performClick
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -95,8 +95,8 @@
}
}
- findByTag(TextFieldTag)
- .doClick()
+ onNodeWithTag(TextFieldTag)
+ .performClick()
assertAgainstGolden("outlined_textField_focused")
}
@@ -113,8 +113,8 @@
}
}
- findByTag(TextFieldTag)
- .doClick()
+ onNodeWithTag(TextFieldTag)
+ .performClick()
assertAgainstGolden("outlined_textField_focused_rtl")
}
@@ -161,8 +161,8 @@
}
}
- findByTag(TextFieldTag)
- .doClick()
+ onNodeWithTag(TextFieldTag)
+ .performClick()
assertAgainstGolden("filled_textField_focused")
}
@@ -179,14 +179,14 @@
}
}
- findByTag(TextFieldTag)
- .doClick()
+ onNodeWithTag(TextFieldTag)
+ .performClick()
assertAgainstGolden("filled_textField_focused_rtl")
}
private fun assertAgainstGolden(goldenIdentifier: String) {
- findByTag(TextFieldTag)
+ onNodeWithTag(TextFieldTag)
.captureToBitmap()
.assertAgainstGolden(screenshotRule, goldenIdentifier)
}
diff --git a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldTest.kt b/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldTest.kt
index 0e9c6a5..7283d7e 100644
--- a/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldTest.kt
+++ b/ui/ui-material/src/androidTest/java/androidx/ui/material/textfield/TextFieldTest.kt
@@ -35,11 +35,11 @@
import androidx.ui.test.assertPixels
import androidx.ui.test.captureToBitmap
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doGesture
-import androidx.ui.test.findByTag
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendSwipeDown
-import androidx.ui.test.sendSwipeUp
+import androidx.ui.test.swipeDown
+import androidx.ui.test.swipeUp
import androidx.ui.unit.IntSize
import androidx.ui.unit.dp
import com.google.common.truth.Truth.assertThat
@@ -140,7 +140,7 @@
runOnIdleCompose {}
- findByTag(TextfieldTag)
+ onNodeWithTag(TextfieldTag)
.captureToBitmap()
.assertPixels(expectedSize = IntSize(parentSize, parentSize)) { position ->
if (position.x > textFieldSize && position.y > textFieldSize) Color.White else null
@@ -169,16 +169,16 @@
assertThat(scrollerPosition.current).isEqualTo(0f)
}
- findByTag(TextfieldTag)
- .doGesture { sendSwipeDown() }
+ onNodeWithTag(TextfieldTag)
+ .performGesture { swipeDown() }
val firstSwipePosition = runOnIdleCompose {
scrollerPosition.current
}
assertThat(firstSwipePosition).isGreaterThan(0f)
- findByTag(TextfieldTag)
- .doGesture { sendSwipeUp() }
+ onNodeWithTag(TextfieldTag)
+ .performGesture { swipeUp() }
runOnIdleCompose {
assertThat(scrollerPosition.current).isLessThan(firstSwipePosition)
}
@@ -206,8 +206,8 @@
}
}
- findByTag(TextfieldTag)
- .doGesture { sendSwipeDown() }
+ onNodeWithTag(TextfieldTag)
+ .performGesture { swipeDown() }
val swipePosition = runOnIdleCompose {
scrollerPosition.current