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-test/src/androidTest/java/androidx/ui/test/AssertExistsTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/AssertExistsTest.kt
index 9902d3a..dd2f27a 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/AssertExistsTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/AssertExistsTest.kt
@@ -61,28 +61,28 @@
}
}
- findByText("Hello")
+ onNodeWithText("Hello")
.assertExists()
expectAssertionError(true) {
- findByText("Hello")
+ onNodeWithText("Hello")
.assertDoesNotExist()
}
- val cachedResult = findByText("Hello")
+ val cachedResult = onNodeWithText("Hello")
// Hide
- findByTag("MyButton")
- .doClick()
+ onNodeWithTag("MyButton")
+ .performClick()
- findByText("Hello")
+ onNodeWithText("Hello")
.assertDoesNotExist()
cachedResult
.assertDoesNotExist()
expectAssertionError(true) {
- findByText("Hello")
+ onNodeWithText("Hello")
.assertExists()
}
@@ -91,14 +91,14 @@
}
// Show
- findByTag("MyButton")
- .doClick()
+ onNodeWithTag("MyButton")
+ .performClick()
- findByText("Hello")
+ onNodeWithText("Hello")
.assertExists()
expectAssertionError(true) {
- findByText("Hello")
+ onNodeWithText("Hello")
.assertDoesNotExist()
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/AssertsTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/AssertsTest.kt
index 9eb6a66..8bde3ad 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/AssertsTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/AssertsTest.kt
@@ -41,7 +41,7 @@
BoundaryNode { testTag = "test"; hidden = false }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsNotHidden()
}
@@ -51,7 +51,7 @@
BoundaryNode { testTag = "test"; hidden = true }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsNotHidden()
}
@@ -61,7 +61,7 @@
BoundaryNode { testTag = "test"; hidden = true }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsHidden()
}
@@ -71,7 +71,7 @@
BoundaryNode { testTag = "test"; hidden = false }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsHidden()
}
@@ -81,7 +81,7 @@
BoundaryNode { testTag = "test"; toggleableState = ToggleableState.On }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsOn()
}
@@ -91,7 +91,7 @@
BoundaryNode { testTag = "test"; toggleableState = ToggleableState.Off }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsOn()
}
@@ -101,7 +101,7 @@
BoundaryNode { testTag = "test" }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsOn()
}
@@ -111,7 +111,7 @@
BoundaryNode { testTag = "test"; toggleableState = ToggleableState.On }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsOff()
}
@@ -121,7 +121,7 @@
BoundaryNode { testTag = "test"; toggleableState = ToggleableState.Off }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsOff()
}
@@ -131,7 +131,7 @@
BoundaryNode { testTag = "test"; }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsOff()
}
@@ -141,7 +141,7 @@
BoundaryNode { testTag = "test"; selected = false }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsSelected()
}
@@ -151,7 +151,7 @@
BoundaryNode { testTag = "test"; selected = true }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsSelected()
}
@@ -161,7 +161,7 @@
BoundaryNode { testTag = "test"; }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsSelected()
}
@@ -171,7 +171,7 @@
BoundaryNode { testTag = "test"; selected = true }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsUnselected()
}
@@ -181,7 +181,7 @@
BoundaryNode { testTag = "test"; selected = false }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsUnselected()
}
@@ -191,7 +191,7 @@
BoundaryNode { testTag = "test"; }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsUnselected()
}
@@ -201,7 +201,7 @@
BoundaryNode { testTag = "test"; inMutuallyExclusiveGroup = false }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsInMutuallyExclusiveGroup()
}
@@ -211,7 +211,7 @@
BoundaryNode { testTag = "test"; }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsInMutuallyExclusiveGroup()
}
@@ -221,7 +221,7 @@
BoundaryNode { testTag = "test"; inMutuallyExclusiveGroup = true }
}
- findByTag("test")
+ onNodeWithTag("test")
.assertIsInMutuallyExclusiveGroup()
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/BitmapCapturingTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/BitmapCapturingTest.kt
index e5a0e3d..e51c8d3 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/BitmapCapturingTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/BitmapCapturingTest.kt
@@ -79,7 +79,7 @@
composeCheckerboard()
var calledCount = 0
- findByTag(tag11)
+ onNodeWithTag(tag11)
.captureToBitmap()
.assertPixels(expectedSize = IntSize(100, 50)) {
calledCount++
@@ -87,17 +87,17 @@
}
assertThat(calledCount).isEqualTo(100 * 50)
- findByTag(tag12)
+ onNodeWithTag(tag12)
.captureToBitmap()
.assertPixels(expectedSize = IntSize(100, 50)) {
color12
}
- findByTag(tag21)
+ onNodeWithTag(tag21)
.captureToBitmap()
.assertPixels(expectedSize = IntSize(100, 50)) {
color21
}
- findByTag(tag22)
+ onNodeWithTag(tag22)
.captureToBitmap()
.assertPixels(expectedSize = IntSize(100, 50)) {
color22
@@ -108,7 +108,7 @@
fun captureRootContainer_checkSizeAndColors() {
composeCheckerboard()
- findByTag(rootTag)
+ onNodeWithTag(rootTag)
.captureToBitmap()
.assertPixels(expectedSize = IntSize(200, 100)) {
if (it.y >= 100 || it.x >= 200) {
@@ -122,7 +122,7 @@
fun assertWrongColor_expectException() {
composeCheckerboard()
- findByTag(tag11)
+ onNodeWithTag(tag11)
.captureToBitmap()
.assertPixels(expectedSize = IntSize(100, 50)) {
color22 // Assuming wrong color
@@ -133,7 +133,7 @@
fun assertWrongSize_expectException() {
composeCheckerboard()
- findByTag(tag11)
+ onNodeWithTag(tag11)
.captureToBitmap()
.assertPixels(expectedSize = IntSize(10, 10)) {
color21
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/CallSemanticsActionTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/CallSemanticsActionTest.kt
index 920fa85..301adaf 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/CallSemanticsActionTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/CallSemanticsActionTest.kt
@@ -48,14 +48,14 @@
}
}
- findByLabel("Nothing")
+ onNodeWithLabel("Nothing")
.assertExists()
- .callSemanticsAction(MyActions.SetString) { it("Hello") }
+ .performSemanticsAction(MyActions.SetString) { it("Hello") }
- findByLabel("Nothing")
+ onNodeWithLabel("Nothing")
.assertDoesNotExist()
- findByLabel("Hello")
+ onNodeWithLabel("Hello")
.assertExists()
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/CustomActivityTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/CustomActivityTest.kt
index e789401..15cae35 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/CustomActivityTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/CustomActivityTest.kt
@@ -59,6 +59,6 @@
@Test
fun launchCustomActivity() {
- findByText("Hello").assertExists()
+ onNodeWithText("Hello").assertExists()
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/ErrorMessagesTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/ErrorMessagesTest.kt
index e43d92d..60afce4 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/ErrorMessagesTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/ErrorMessagesTest.kt
@@ -59,7 +59,7 @@
"Has 1 sibling\n" +
"Selector used: (TestTag = 'MyButton')"
) {
- findByTag("MyButton")
+ onNodeWithTag("MyButton")
.assertHasClickAction()
}
}
@@ -75,7 +75,7 @@
"Reason: Expected exactly '1' node but could not find any node that satisfies: " +
"(TestTag = 'MyButton3')"
) {
- findByTag("MyButton3")
+ onNodeWithTag("MyButton3")
.assertExists()
}
}
@@ -91,8 +91,8 @@
"Reason: Expected exactly '1' node but could not find any node that satisfies: " +
"(TestTag = 'MyButton3')"
) {
- findByTag("MyButton3")
- .doClick()
+ onNodeWithTag("MyButton3")
+ .performClick()
}
}
@@ -107,8 +107,8 @@
"Reason: Expected exactly '1' node but could not find any node that satisfies: " +
"((TestTag = 'MyButton3') && (OnClick is defined))"
) {
- find(hasTestTag("MyButton3") and hasClickAction())
- .doClick()
+ onNode(hasTestTag("MyButton3") and hasClickAction())
+ .performClick()
}
}
@@ -125,8 +125,8 @@
"Nodes found:\n" +
"1) Node #X at (X, X, X, X)px, Tag: 'MyButton'"
) {
- findByText("Toggle")
- .doClick()
+ onNodeWithText("Toggle")
+ .performClick()
}
}
@@ -137,11 +137,11 @@
}
expectErrorMessageStartsWith("" +
- "Failed to call OnClick action as it is not defined on the node.\n" +
+ "Failed to perform OnClick action as it is not defined on the node.\n" +
"Semantics of the node:"
) {
- findByTag("MyButton")
- .callSemanticsAction(SemanticsActions.OnClick)
+ onNodeWithTag("MyButton")
+ .performSemanticsAction(SemanticsActions.OnClick)
}
}
@@ -152,12 +152,12 @@
}
expectErrorMessageStartsWith("" +
- "Failed to call OnClick action.\n" +
+ "Failed to perform OnClick action.\n" +
"Reason: Expected exactly '1' node but could not find any node that satisfies: " +
"(TestTag = 'MyButton3')"
) {
- findByTag("MyButton3")
- .callSemanticsAction(SemanticsActions.OnClick)
+ onNodeWithTag("MyButton3")
+ .performSemanticsAction(SemanticsActions.OnClick)
}
}
@@ -174,7 +174,7 @@
"Node found:\n" +
"Node #X at (X, X, X, X)px, Tag: 'MyButton'"
) {
- findByTag("MyButton")
+ onNodeWithTag("MyButton")
.assertDoesNotExist()
}
}
@@ -192,7 +192,7 @@
"Nodes found:\n" +
"1) Node #X at (X, X, X, X)px"
) {
- findAllByText("Toggle")
+ onAllNodesWithText("Toggle")
.assertCountEquals(3)
}
}
@@ -208,7 +208,7 @@
"Reason: Expected '3' nodes but could not find any node that satisfies: " +
"(Text = 'Toggle2' (ignoreCase: false))"
) {
- findAllByText("Toggle2")
+ onAllNodesWithText("Toggle2")
.assertCountEquals(3)
}
}
@@ -219,11 +219,11 @@
ComposeTextToHideCase()
}
- val node = findByText("Hello")
+ val node = onNodeWithText("Hello")
.assertExists()
- findByTag("MyButton")
- .doClick()
+ onNodeWithTag("MyButton")
+ .performClick()
expectErrorMessage("" +
"Failed to perform a gesture.\n" +
@@ -233,7 +233,7 @@
"Has 1 sibling\n" +
"Original selector: Text = 'Hello' (ignoreCase: false)"
) {
- node.doClick()
+ node.performClick()
}
}
@@ -243,12 +243,12 @@
ComposeTextToHideCase()
}
- val node = findByText("Hello")
+ val node = onNodeWithText("Hello")
.assertExists()
// Hide text
- findByTag("MyButton")
- .doClick()
+ onNodeWithTag("MyButton")
+ .performClick()
expectErrorMessage("" +
"Failed: assertExists.\n" +
@@ -268,12 +268,12 @@
ComposeTextToHideCase()
}
- val node = findByText("Hello")
+ val node = onNodeWithText("Hello")
.assertExists()
// Hide text
- findByTag("MyButton")
- .doClick()
+ onNodeWithTag("MyButton")
+ .performClick()
expectErrorMessage("" +
"Failed to assert the following: (OnClick is defined)\n" +
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/FindAllTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/FindAllTest.kt
index 821f6f3..494ac91 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/FindAllTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/FindAllTest.kt
@@ -47,7 +47,7 @@
}
}
- findAll(isOn())
+ onAllNodes(isOn())
.assertCountEquals(2)
.apply {
get(0).assertIsOn()
@@ -76,14 +76,14 @@
}
}
- findAll(isToggleable())
+ onAllNodes(isToggleable())
.assertCountEquals(2)
.apply {
get(0)
- .doClick()
+ .performClick()
.assertIsOn()
get(1)
- .doClick()
+ .performClick()
.assertIsOn()
}
}
@@ -101,7 +101,7 @@
}
}
- findAll(isOff())
+ onAllNodes(isOff())
.assertCountEquals(0)
}
@@ -127,9 +127,9 @@
}
}
- findAll(isToggleable()).apply {
+ onAllNodes(isToggleable()).apply {
get(0)
- .doClick()
+ .performClick()
.assertIsOn()
get(1)
.assertIsOff()
@@ -168,15 +168,15 @@
}
}
- findAll(isToggleable())
+ onAllNodes(isToggleable())
.assertCountEquals(2).apply {
get(0)
.assertIsOff()
- .doClick()
+ .performClick()
.assertIsOn()
}
- findAll(isToggleable())
+ onAllNodes(isToggleable())
.assertCountEquals(3).apply {
get(2)
.assertIsOff()
@@ -209,12 +209,12 @@
}
}
- findAll(isToggleable())
+ onAllNodes(isToggleable())
.assertCountEquals(2)
.apply {
get(0)
.assertIsOff()
- .doClick()
+ .performClick()
.assertIsOn()
get(1)
.assertDoesNotExist()
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/FindInPopupTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/FindInPopupTest.kt
index 326cbcc..655a4702 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/FindInPopupTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/FindInPopupTest.kt
@@ -45,7 +45,7 @@
Box(Modifier.testTag(popupTag))
}
}
- findByTag(contentTag).assertExists()
- findByTag(popupTag).assertExists()
+ onNodeWithTag(contentTag).assertExists()
+ onNodeWithTag(popupTag).assertExists()
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/FindersTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/FindersTest.kt
index 4a2ceb7..94af34e 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/FindersTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/FindersTest.kt
@@ -45,7 +45,7 @@
BoundaryNode { testTag = "not_myTestTag" }
}
- findAll(hasTestTag("myTestTag")).assertCountEquals(0)
+ onAllNodes(hasTestTag("myTestTag")).assertCountEquals(0)
}
@Test
@@ -55,9 +55,9 @@
BoundaryNode { testTag = "myTestTag2" }
}
- findAll(hasTestTag("myTestTag"))
+ onAllNodes(hasTestTag("myTestTag"))
.assertCountEquals(1)
- .first()
+ .onFirst()
.assert(hasTestTag("myTestTag"))
}
@@ -68,7 +68,7 @@
BoundaryNode { testTag = "myTestTag" }
}
- findAll(hasTestTag("myTestTag"))
+ onAllNodes(hasTestTag("myTestTag"))
.assertCountEquals(2)
.apply {
get(0).assert(hasTestTag("myTestTag"))
@@ -82,7 +82,7 @@
BoundaryNode { accessibilityLabel = "Hello World" }
}
- findByText("Hello World")
+ onNodeWithText("Hello World")
}
@Test(expected = AssertionError::class)
@@ -92,7 +92,7 @@
}
// Need to assert exists or it won't fail
- findByText("World").assertExists()
+ onNodeWithText("World").assertExists()
}
@Test
@@ -101,7 +101,7 @@
BoundaryNode { text = AnnotatedString("Hello World") }
}
- findBySubstring("World")
+ onNodeWithSubstring("World")
}
@Test
@@ -110,7 +110,7 @@
BoundaryNode { text = AnnotatedString("Hello World") }
}
- findBySubstring("world", ignoreCase = true)
+ onNodeWithSubstring("world", ignoreCase = true)
}
@Test
@@ -121,7 +121,7 @@
expectError<AssertionError> {
// Need to assert exists or it won't fetch nodes
- findBySubstring("world").assertExists()
+ onNodeWithSubstring("world").assertExists()
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/IsDisplayedTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/IsDisplayedTest.kt
index d2eef00..9a0085d 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/IsDisplayedTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/IsDisplayedTest.kt
@@ -113,7 +113,7 @@
}
}
- findByTag("item0")
+ onNodeWithTag("item0")
.assertIsDisplayed()
}
@@ -125,7 +125,7 @@
}
}
- findByTag("item4")
+ onNodeWithTag("item4")
.assertIsNotDisplayed()
}
@@ -140,14 +140,14 @@
}
}
- findByTag("item0")
+ onNodeWithTag("item0")
.assertIsDisplayed()
runOnIdleCompose {
place = false
}
- findByTag("item0")
+ onNodeWithTag("item0")
.assertIsNotDisplayed()
}
@@ -164,14 +164,14 @@
}
}
- findByTag("item0")
+ onNodeWithTag("item0")
.assertIsDisplayed()
runOnIdleCompose {
place = false
}
- findByTag("item0")
+ onNodeWithTag("item0")
.assertIsNotDisplayed()
}
@@ -183,7 +183,7 @@
}
}
- findByTag("item9")
+ onNodeWithTag("item9")
.assertIsNotDisplayed()
}
@@ -208,14 +208,14 @@
}
onComposeView().check(matches(isDisplayed()))
- findByTag("item0").assertIsDisplayed()
+ onNodeWithTag("item0").assertIsDisplayed()
runOnIdleCompose {
androidComposeView.visibility = View.GONE
}
onComposeView().check(matches(not(isDisplayed())))
- findByTag("item0").assertIsNotDisplayed()
+ onNodeWithTag("item0").assertIsNotDisplayed()
}
@Test
@@ -240,13 +240,13 @@
}
onComposeView().check(matches(isDisplayed()))
- findByTag("item0").assertIsDisplayed()
+ onNodeWithTag("item0").assertIsDisplayed()
runOnIdleCompose {
composeContainer.visibility = View.GONE
}
onComposeView().check(matches(not(isDisplayed())))
- findByTag("item0").assertIsNotDisplayed()
+ onNodeWithTag("item0").assertIsNotDisplayed()
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/LateSetContentTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/LateSetContentTest.kt
index aa37c23..52f0e3f 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/LateSetContentTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/LateSetContentTest.kt
@@ -34,7 +34,7 @@
@Test
fun test() {
- findByTag("Node").assertExists()
+ onNodeWithTag("Node").assertExists()
}
class Activity : ComponentActivity() {
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/MultipleActivitiesClickTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/MultipleActivitiesClickTest.kt
index d40a5ed..ab19cad 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/MultipleActivitiesClickTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/MultipleActivitiesClickTest.kt
@@ -43,7 +43,7 @@
lateinit var activity1: Activity1
composeTestRule.activityRule.scenario.onActivity { activity1 = it }
activity1.startNewActivity()
- findByTag("activity2").doGesture { sendClick() }
+ onNodeWithTag("activity2").performGesture { click() }
val activity2 = getCurrentActivity() as Activity2
assertThat(activity1.recorder.events).isEmpty()
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/MultipleActivitiesFindTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/MultipleActivitiesFindTest.kt
index 2ba48e4..47d2453 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/MultipleActivitiesFindTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/MultipleActivitiesFindTest.kt
@@ -35,8 +35,8 @@
@Test
fun test() {
composeTestRule.activityRule.scenario.onActivity { it.startNewActivity() }
- findByTag("activity1").assertDoesNotExist()
- findByTag("activity2").assertExists()
+ onNodeWithTag("activity1").assertDoesNotExist()
+ onNodeWithTag("activity2").assertExists()
}
class Activity1 : TaggedActivity("activity1")
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/MultipleComposeRootsTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/MultipleComposeRootsTest.kt
index a3f79e6..c20e9f8d 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/MultipleComposeRootsTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/MultipleComposeRootsTest.kt
@@ -142,21 +142,21 @@
Espresso.onView(withText("Compose 1")).check(matches(isDisplayed()))
Espresso.onView(withText("Compose 2")).check(matches(isDisplayed()))
- findByTag("checkbox1")
- .doClick()
+ onNodeWithTag("checkbox1")
+ .performClick()
.assertIsOn()
- findByTag("checkbox2")
+ onNodeWithTag("checkbox2")
.assertIsOff()
Espresso.onView(withText("Compose 1 - On")).check(matches(isDisplayed()))
Espresso.onView(withText("Compose 2 - Off")).check(matches(isDisplayed()))
- findByTag("checkbox2")
- .doClick()
+ onNodeWithTag("checkbox2")
+ .performClick()
.assertIsOn()
- findByTag("checkbox1")
+ onNodeWithTag("checkbox1")
.assertIsOff()
Espresso.onView(withText("Compose 1 - Off")).check(matches(isDisplayed()))
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/PrintToStringTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/PrintToStringTest.kt
index a997989..fead412 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/PrintToStringTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/PrintToStringTest.kt
@@ -53,7 +53,7 @@
"Failed: assertExists.\n" +
"Reason: Expected exactly '1' node but could not find any node that satisfies:"
) {
- findByText("Oops").printToString()
+ onNodeWithText("Oops").printToString()
}
}
@@ -63,7 +63,7 @@
ComposeSimpleCase()
}
- val result = findByText("Hello")
+ val result = onNodeWithText("Hello")
.printToString(maxDepth = 0)
assertThat(obfuscateNodesInfo(result)).isEqualTo("" +
@@ -78,8 +78,8 @@
ComposeSimpleCase()
}
- val result = findRoot()
- .children()
+ val result = onRoot()
+ .onChildren()
.printToString()
assertThat(obfuscateNodesInfo(result)).isEqualTo("" +
@@ -104,7 +104,7 @@
}
}
- val result = findRoot()
+ val result = onRoot()
.printToString()
assertThat(obfuscateNodesInfo(result)).isEqualTo("" +
@@ -138,8 +138,8 @@
}
}
- val result = findRoot()
- .children()
+ val result = onRoot()
+ .onChildren()
.printToString(maxDepth = 1)
assertThat(obfuscateNodesInfo(result)).isEqualTo("" +
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/ScrollToTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/ScrollToTest.kt
index d59a833..2d198e6 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/ScrollToTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/ScrollToTest.kt
@@ -56,8 +56,8 @@
Assert.assertTrue(!wasScrollToCalled)
}
- findByTag(tag)
- .doScrollTo()
+ onNodeWithTag(tag)
+ .performScrollTo()
runOnIdleCompose {
Assert.assertTrue(wasScrollToCalled)
@@ -104,8 +104,8 @@
Truth.assertThat(currentScrollPositionX).isEqualTo(0.0f)
}
- findByTag(tag)
- .doScrollTo() // scroll to third element
+ onNodeWithTag(tag)
+ .performScrollTo() // scroll to third element
runOnIdleCompose {
val expected = elementHeight * 2
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/SynchronizationMethodsTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/SynchronizationMethodsTest.kt
index 9c4369f..ad4e374 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/SynchronizationMethodsTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/SynchronizationMethodsTest.kt
@@ -77,7 +77,7 @@
withAndroidOwnerRegistry {
runOnIdleCompose {
expectError<IllegalStateException> {
- findByTag("dummy").assertExists()
+ onNodeWithTag("dummy").assertExists()
}
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/TextActionsTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/TextActionsTest.kt
index 967c45b..e507eeca 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/TextActionsTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/TextActionsTest.kt
@@ -70,15 +70,15 @@
}
}
- findByTag(fieldTag)
- .doSendText("Hello!")
+ onNodeWithTag(fieldTag)
+ .performTextInput("Hello!")
runOnIdleCompose {
assertThat(lastSeenText).isEqualTo("Hello!")
}
- findByTag(fieldTag)
- .doClearText(alreadyHasFocus = true)
+ onNodeWithTag(fieldTag)
+ .performTextClearance(alreadyHasFocus = true)
runOnIdleCompose {
assertThat(lastSeenText).isEqualTo("")
@@ -94,11 +94,11 @@
}
}
- findByTag(fieldTag)
- .doSendText("Hello ")
+ onNodeWithTag(fieldTag)
+ .performTextInput("Hello ")
- findByTag(fieldTag)
- .doSendText("world!", alreadyHasFocus = true)
+ onNodeWithTag(fieldTag)
+ .performTextInput("world!", alreadyHasFocus = true)
runOnIdleCompose {
assertThat(lastSeenText).isEqualTo("Hello world!")
@@ -114,14 +114,14 @@
}
}
- findByTag(fieldTag)
- .doSendText("Hello")
+ onNodeWithTag(fieldTag)
+ .performTextInput("Hello")
// This helps. So there must be some timing issue.
// Thread.sleep(3000)
- findByTag(fieldTag)
- .doSendText(" world!", alreadyHasFocus = true)
+ onNodeWithTag(fieldTag)
+ .performTextInput(" world!", alreadyHasFocus = true)
runOnIdleCompose {
assertThat(lastSeenText).isEqualTo("Hello world!")
@@ -135,8 +135,8 @@
}
expectError<IllegalStateException> {
- findByTag(fieldTag)
- .doSendText("Hello!", alreadyHasFocus = true)
+ onNodeWithTag(fieldTag)
+ .performTextInput("Hello!", alreadyHasFocus = true)
}
}
@@ -149,15 +149,15 @@
}
}
- findByTag(fieldTag)
- .doSendText("Hello")
+ onNodeWithTag(fieldTag)
+ .performTextInput("Hello")
runOnIdleCompose {
assertThat(lastSeenText).isEqualTo("Hello")
}
- findByTag(fieldTag)
- .doReplaceText("world", alreadyHasFocus = true)
+ onNodeWithTag(fieldTag)
+ .performTextReplacement("world", alreadyHasFocus = true)
runOnIdleCompose {
assertThat(lastSeenText).isEqualTo("world")
@@ -173,8 +173,8 @@
}
assertThat(actionPerformed).isEqualTo(ImeAction.Unspecified)
- findByTag(fieldTag)
- .doSendImeAction()
+ onNodeWithTag(fieldTag)
+ .performImeAction()
runOnIdleCompose {
assertThat(actionPerformed).isEqualTo(ImeAction.Search)
@@ -191,11 +191,11 @@
assertThat(actionPerformed).isEqualTo(ImeAction.Unspecified)
expectErrorMessageStartsWith("" +
- "Failed to send IME action as current node does not specify any.\n" +
+ "Failed to perform IME action as current node does not specify any.\n" +
"Semantics of the node:"
) {
- findByTag(fieldTag)
- .doSendImeAction()
+ onNodeWithTag(fieldTag)
+ .performImeAction()
}
}
@@ -206,12 +206,12 @@
}
expectErrorMessageStartsWith("" +
- "Failed to send IME action.\n" +
+ "Failed to perform IME action.\n" +
"Failed to assert the following: (SupportsInputMethods = 'true')\n" +
"Semantics of the node:"
) {
- findByTag("node")
- .doSendImeAction()
+ onNodeWithTag("node")
+ .performImeAction()
}
}
}
\ No newline at end of file
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/TimeOutTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/TimeOutTest.kt
index 2fe01a7..011e46a 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/TimeOutTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/TimeOutTest.kt
@@ -117,13 +117,13 @@
}
}
- findByText("Hello 0").assertExists()
+ onNodeWithText("Hello 0").assertExists()
count.value++ // Start infinite re-compositions
IdlingPolicies.setMasterPolicyTimeout(300, TimeUnit.MILLISECONDS)
expectError<ComposeNotIdleException>(expectedMessage = expectedErrorDueToRecompositions) {
- findByText("Hello").assertExists()
+ onNodeWithText("Hello").assertExists()
}
}
@@ -167,7 +167,7 @@
}
// No timeout should happen this time
- findByText("Hello").assertExists()
+ onNodeWithText("Hello").assertExists()
}
private object InfiniteResource : IdlingResource {
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/assertions/AssertAllTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/assertions/AssertAllTest.kt
index 09a6ed4..518222e 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/assertions/AssertAllTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/assertions/AssertAllTest.kt
@@ -19,9 +19,9 @@
import androidx.test.filters.MediumTest
import androidx.ui.test.assertAll
import androidx.ui.test.assertCountEquals
-import androidx.ui.test.children
+import androidx.ui.test.onChildren
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.hasTestTag
import androidx.ui.test.util.BoundaryNode
import androidx.ui.test.util.expectErrorMessageStartsWith
@@ -47,8 +47,8 @@
}
}
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.assertAll(hasTestTag("Child1") or hasTestTag("Child2"))
}
@@ -66,8 +66,8 @@
"Found '1' node not matching:\n" +
"Node #X"
) {
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.assertAll(hasTestTag("Child1"))
}
}
@@ -87,8 +87,8 @@
"Found '2' nodes not matching:\n" +
"1) "
) {
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.assertAll(hasTestTag("Child1"))
}
}
@@ -99,8 +99,8 @@
BoundaryNode(testTag = "Parent")
}
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.assertCountEquals(0)
.assertAll(hasTestTag("Child"))
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/assertions/AssertAnyTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/assertions/AssertAnyTest.kt
index 7cede74..0f94a36 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/assertions/AssertAnyTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/assertions/AssertAnyTest.kt
@@ -18,9 +18,9 @@
import androidx.test.filters.MediumTest
import androidx.ui.test.assertAny
-import androidx.ui.test.children
+import androidx.ui.test.onChildren
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.hasTestTag
import androidx.ui.test.util.BoundaryNode
import androidx.ui.test.util.expectErrorMessageStartsWith
@@ -46,12 +46,12 @@
}
}
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.assertAny(hasTestTag("Child1"))
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.assertAny(hasTestTag("Child1") or hasTestTag("Child2"))
}
@@ -68,8 +68,8 @@
"Failed to assertAny(TestTag = 'Child3')\n" +
"None of the following nodes match:\n" +
"1) ") {
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.assertAny(hasTestTag("Child3"))
}
}
@@ -84,8 +84,8 @@
"Failed to assertAny(TestTag = 'Child')\n" +
"Assert needs to receive at least 1 node but 0 nodes were found for selector: " +
"'(TestTag = 'Parent').children'") {
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.assertAny(hasTestTag("Child"))
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/assertions/BoundsAssertionsTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/assertions/BoundsAssertionsTest.kt
index c4234df..26ca383 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/assertions/BoundsAssertionsTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/assertions/BoundsAssertionsTest.kt
@@ -37,7 +37,7 @@
import androidx.ui.test.assertWidthIsAtLeast
import androidx.ui.test.assertWidthIsEqualTo
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.util.expectError
import androidx.ui.unit.dp
import org.junit.Rule
@@ -102,7 +102,7 @@
fun assertEquals() {
composeBox()
- findByTag(tag)
+ onNodeWithTag(tag)
.assertWidthIsEqualTo(80.dp)
.assertHeightIsEqualTo(100.dp)
}
@@ -111,7 +111,7 @@
fun assertAtLeast() {
composeBox()
- findByTag(tag)
+ onNodeWithTag(tag)
.assertWidthIsAtLeast(80.dp)
.assertWidthIsAtLeast(79.dp)
.assertHeightIsAtLeast(100.dp)
@@ -123,12 +123,12 @@
composeBox()
expectError<AssertionError> {
- findByTag(tag)
+ onNodeWithTag(tag)
.assertWidthIsEqualTo(70.dp)
}
expectError<AssertionError> {
- findByTag(tag)
+ onNodeWithTag(tag)
.assertHeightIsEqualTo(90.dp)
}
}
@@ -138,12 +138,12 @@
composeBox()
expectError<AssertionError> {
- findByTag(tag)
+ onNodeWithTag(tag)
.assertWidthIsAtLeast(81.dp)
}
expectError<AssertionError> {
- findByTag(tag)
+ onNodeWithTag(tag)
.assertHeightIsAtLeast(101.dp)
}
}
@@ -152,7 +152,7 @@
fun assertPosition() {
composeBox()
- findByTag(tag)
+ onNodeWithTag(tag)
.assertPositionInRootIsEqualTo(expectedLeft = 50.dp, expectedTop = 100.dp)
.assertLeftPositionInRootIsEqualTo(50.dp)
.assertTopPositionInRootIsEqualTo(100.dp)
@@ -163,12 +163,12 @@
composeBox()
expectError<AssertionError> {
- findByTag(tag)
+ onNodeWithTag(tag)
.assertPositionInRootIsEqualTo(expectedLeft = 51.dp, expectedTop = 101.dp)
}
expectError<AssertionError> {
- findByTag(tag)
+ onNodeWithTag(tag)
.assertPositionInRootIsEqualTo(expectedLeft = 49.dp, expectedTop = 99.dp)
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/PositionsTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/PositionsTest.kt
index e4a018c..9d2b331 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/PositionsTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/PositionsTest.kt
@@ -29,8 +29,8 @@
import androidx.ui.test.centerX
import androidx.ui.test.centerY
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.height
import androidx.ui.test.left
import androidx.ui.test.right
@@ -55,7 +55,7 @@
fun testCornersEdgesAndCenter() {
composeTestRule.setContent { ClickableTestBox(width = 3f, height = 100f) }
- findByTag(defaultTag).doGesture {
+ onNodeWithTag(defaultTag).performGesture {
assertThat(width).isEqualTo(3)
assertThat(height).isEqualTo(100)
@@ -83,7 +83,7 @@
fun testRelativeOffset() {
composeTestRule.setContent { ClickableTestBox() }
- findByTag(defaultTag).doGesture {
+ onNodeWithTag(defaultTag).performGesture {
assertThat(percentOffset(.1f, .1f)).isEqualTo(Offset(10f, 10f))
assertThat(percentOffset(-.2f, 0f)).isEqualTo(Offset(-20f, 0f))
assertThat(percentOffset(.25f, -.5f)).isEqualTo(Offset(25f, -50f))
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendClickTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendClickTest.kt
index b4e1492..bdbea41 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendClickTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendClickTest.kt
@@ -28,10 +28,10 @@
import androidx.ui.layout.Column
import androidx.ui.test.ActivityWithActionBar
import androidx.ui.test.android.AndroidComposeTestRule
-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.sendClick
+import androidx.ui.test.click
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.RecordingFilter
import com.google.common.truth.Truth.assertThat
@@ -126,11 +126,11 @@
}
private fun click(tag: String) {
- findByTag(tag).doGesture {
+ onNodeWithTag(tag).performGesture {
if (config.position != null) {
- sendClick(config.position)
+ click(config.position)
} else {
- sendClick()
+ click()
}
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendDoubleClickTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendDoubleClickTest.kt
index 2c194a6..fcd5823 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendDoubleClickTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendDoubleClickTest.kt
@@ -23,9 +23,9 @@
import androidx.ui.test.InputDispatcher.Companion.eventPeriod
import androidx.ui.test.InputDispatcher.InputDispatcherTestRule
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doGesture
-import androidx.ui.test.findByTag
-import androidx.ui.test.sendDoubleClick
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.doubleClick
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.ClickableTestBox.defaultSize
import androidx.ui.test.util.ClickableTestBox.defaultTag
@@ -89,15 +89,15 @@
}
// When we inject a double click
- findByTag(defaultTag).doGesture {
+ onNodeWithTag(defaultTag).performGesture {
if (config.position != null && config.delay != null) {
- sendDoubleClick(config.position, config.delay)
+ doubleClick(config.position, config.delay)
} else if (config.position != null) {
- sendDoubleClick(config.position)
+ doubleClick(config.position)
} else if (config.delay != null) {
- sendDoubleClick(delay = config.delay)
+ doubleClick(delay = config.delay)
} else {
- sendDoubleClick()
+ doubleClick()
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendLongClickTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendLongClickTest.kt
index 5cbd19e..2f92087 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendLongClickTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendLongClickTest.kt
@@ -25,9 +25,9 @@
import androidx.ui.layout.fillMaxSize
import androidx.ui.layout.wrapContentSize
import androidx.ui.test.createComposeRule
-import androidx.ui.test.doGesture
-import androidx.ui.test.findByTag
-import androidx.ui.test.sendLongClick
+import androidx.ui.test.performGesture
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.longClick
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.ClickableTestBox.defaultSize
import androidx.ui.test.util.ClickableTestBox.defaultTag
@@ -44,7 +44,7 @@
import org.junit.runners.Parameterized
/**
- * Tests [sendLongClick] with arguments. Verifies that the click is in the middle
+ * Tests [longClick] with arguments. Verifies that the click is in the middle
* of the component, that the gesture has a duration of 600 milliseconds and that all input
* events were on the same location.
*/
@@ -93,15 +93,15 @@
}
// When we inject a long click
- findByTag(defaultTag).doGesture {
+ onNodeWithTag(defaultTag).performGesture {
if (config.position != null && config.duration != null) {
- sendLongClick(config.position, config.duration)
+ longClick(config.position, config.duration)
} else if (config.position != null) {
- sendLongClick(config.position)
+ longClick(config.position)
} else if (config.duration != null) {
- sendLongClick(duration = config.duration)
+ longClick(duration = config.duration)
} else {
- sendLongClick()
+ longClick()
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendPinchTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendPinchTest.kt
index e28dac9..257102a 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendPinchTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendPinchTest.kt
@@ -23,10 +23,10 @@
import androidx.ui.layout.fillMaxSize
import androidx.ui.test.InputDispatcher.Companion.eventPeriod
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.sendPinch
+import androidx.ui.test.pinch
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.MultiPointerInputRecorder
import androidx.ui.test.util.assertTimestampsAreIncreasing
@@ -65,8 +65,8 @@
val end1 = Offset(92f, 50f)
val duration = 400.milliseconds
- findByTag(TAG).doGesture {
- sendPinch(start0, end0, start1, end1, duration)
+ onNodeWithTag(TAG).performGesture {
+ pinch(start0, end0, start1, end1, duration)
}
runOnIdleCompose {
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeTest.kt
index b81d6d6..6d67ef1 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeTest.kt
@@ -26,14 +26,14 @@
import androidx.ui.layout.wrapContentSize
import androidx.ui.test.bottomRight
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.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.swipe
+import androidx.ui.test.swipeDown
+import androidx.ui.test.swipeLeft
+import androidx.ui.test.swipeRight
+import androidx.ui.test.swipeUp
import androidx.ui.test.topLeft
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.SinglePointerInputRecorder
@@ -72,7 +72,7 @@
@Test
fun swipeUp() {
composeTestRule.setContent { Ui(Alignment.TopStart) }
- findByTag(tag).doGesture { sendSwipeUp() }
+ onNodeWithTag(tag).performGesture { swipeUp() }
runOnIdleCompose {
recorder.run {
assertTimestampsAreIncreasing()
@@ -85,7 +85,7 @@
@Test
fun swipeDown() {
composeTestRule.setContent { Ui(Alignment.TopEnd) }
- findByTag(tag).doGesture { sendSwipeDown() }
+ onNodeWithTag(tag).performGesture { swipeDown() }
runOnIdleCompose {
recorder.run {
assertTimestampsAreIncreasing()
@@ -98,7 +98,7 @@
@Test
fun swipeLeft() {
composeTestRule.setContent { Ui(Alignment.BottomEnd) }
- findByTag(tag).doGesture { sendSwipeLeft() }
+ onNodeWithTag(tag).performGesture { swipeLeft() }
runOnIdleCompose {
recorder.run {
assertTimestampsAreIncreasing()
@@ -111,7 +111,7 @@
@Test
fun swipeRight() {
composeTestRule.setContent { Ui(Alignment.BottomStart) }
- findByTag(tag).doGesture { sendSwipeRight() }
+ onNodeWithTag(tag).performGesture { swipeRight() }
runOnIdleCompose {
recorder.run {
assertTimestampsAreIncreasing()
@@ -124,7 +124,7 @@
@Test
fun swipeShort() {
composeTestRule.setContent { Ui(Alignment.Center) }
- findByTag(tag).doGesture { sendSwipe(topLeft, bottomRight, 1.milliseconds) }
+ onNodeWithTag(tag).performGesture { swipe(topLeft, bottomRight, 1.milliseconds) }
runOnIdleCompose {
recorder.run {
assertTimestampsAreIncreasing()
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeVelocityTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeVelocityTest.kt
index 2739718..9fad642 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeVelocityTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/gesturescope/SendSwipeVelocityTest.kt
@@ -25,10 +25,10 @@
import androidx.ui.layout.wrapContentSize
import androidx.ui.test.InputDispatcher.InputDispatcherTestRule
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.sendSwipeWithVelocity
+import androidx.ui.test.swipeWithVelocity
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.SinglePointerInputRecorder
import androidx.ui.test.util.assertOnlyLastEventIsUp
@@ -136,8 +136,8 @@
}
}
- findByTag(tag).doGesture {
- sendSwipeWithVelocity(start, end, velocity, duration)
+ onNodeWithTag(tag).performGesture {
+ swipeWithVelocity(start, end, velocity, duration)
}
runOnIdleCompose {
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/Common.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/Common.kt
index 6c0c86c..243b09a 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/Common.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/Common.kt
@@ -17,12 +17,12 @@
package androidx.ui.test.partialgesturescope
import androidx.ui.test.PartialGestureScope
-import androidx.ui.test.doPartialGesture
-import androidx.ui.test.findByTag
+import androidx.ui.test.performPartialGesture
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.util.ClickableTestBox.defaultTag
object Common {
fun partialGesture(block: PartialGestureScope.() -> Unit) {
- findByTag(defaultTag).doPartialGesture(block)
+ onNodeWithTag(defaultTag).performPartialGesture(block)
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendCancelTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendCancelTest.kt
index 388bd24..404f59d 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendCancelTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendCancelTest.kt
@@ -23,9 +23,9 @@
import androidx.ui.test.inputdispatcher.verifyNoGestureInProgress
import androidx.ui.test.partialgesturescope.Common.partialGesture
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendCancel
-import androidx.ui.test.sendDown
-import androidx.ui.test.sendUp
+import androidx.ui.test.cancel
+import androidx.ui.test.down
+import androidx.ui.test.up
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.MultiPointerInputRecorder
import androidx.ui.test.util.assertTimestampsAreIncreasing
@@ -37,7 +37,7 @@
import org.junit.rules.TestRule
/**
- * Tests if [sendCancel] works
+ * Tests if [cancel] works
*/
@MediumTest
class SendCancelTest {
@@ -65,8 +65,8 @@
@Test
fun onePointer() {
// When we inject a down event followed by a cancel event
- partialGesture { sendDown(downPosition1) }
- partialGesture { sendCancel() }
+ partialGesture { down(downPosition1) }
+ partialGesture { cancel() }
runOnIdleCompose {
recorder.run {
@@ -83,9 +83,9 @@
@Test
fun twoPointers() {
// When we inject two down events followed by a cancel event
- partialGesture { sendDown(1, downPosition1) }
- partialGesture { sendDown(2, downPosition2) }
- partialGesture { sendCancel() }
+ partialGesture { down(1, downPosition1) }
+ partialGesture { down(2, downPosition2) }
+ partialGesture { cancel() }
runOnIdleCompose {
recorder.run {
@@ -102,25 +102,25 @@
@Test
fun cancelWithoutDown() {
expectError<IllegalStateException> {
- partialGesture { sendCancel() }
+ partialGesture { cancel() }
}
}
@Test
fun cancelAfterUp() {
- partialGesture { sendDown(downPosition1) }
- partialGesture { sendUp() }
+ partialGesture { down(downPosition1) }
+ partialGesture { up() }
expectError<IllegalStateException> {
- partialGesture { sendCancel() }
+ partialGesture { cancel() }
}
}
@Test
fun cancelAfterCancel() {
- partialGesture { sendDown(downPosition1) }
- partialGesture { sendCancel() }
+ partialGesture { down(downPosition1) }
+ partialGesture { cancel() }
expectError<IllegalStateException> {
- partialGesture { sendCancel() }
+ partialGesture { cancel() }
}
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendDownTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendDownTest.kt
index 9e2d7a0..1a06cd5 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendDownTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendDownTest.kt
@@ -23,7 +23,7 @@
import androidx.ui.test.createComposeRule
import androidx.ui.test.partialgesturescope.Common.partialGesture
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendDown
+import androidx.ui.test.down
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.MultiPointerInputRecorder
import androidx.ui.test.util.assertTimestampsAreIncreasing
@@ -36,7 +36,7 @@
import org.junit.rules.TestRule
/**
- * Tests if [sendDown] works
+ * Tests if [down] works
*/
@MediumTest
class SendDownTest {
@@ -64,7 +64,7 @@
@Test
fun onePointer() {
// When we put a pointer down
- partialGesture { sendDown(position1) }
+ partialGesture { down(position1) }
runOnIdleCompose {
recorder.run {
@@ -80,9 +80,9 @@
@Test
fun twoPointers() {
// When we put two pointers down
- partialGesture { sendDown(1, position1) }
+ partialGesture { down(1, position1) }
sleep(20) // (with some time in between)
- partialGesture { sendDown(2, position2) }
+ partialGesture { down(2, position2) }
runOnIdleCompose {
recorder.run {
@@ -109,10 +109,10 @@
@Test
fun duplicatePointers() {
// When we inject two down events with the same pointer id
- partialGesture { sendDown(1, position1) }
+ partialGesture { down(1, position1) }
// Then the second throws an exception
expectError<IllegalArgumentException> {
- partialGesture { sendDown(1, position1) }
+ partialGesture { down(1, position1) }
}
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveByTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveByTest.kt
index 8fcfe89..73b9ed4 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveByTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveByTest.kt
@@ -24,11 +24,11 @@
import androidx.ui.test.movePointerBy
import androidx.ui.test.partialgesturescope.Common.partialGesture
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendCancel
-import androidx.ui.test.sendDown
-import androidx.ui.test.sendMove
-import androidx.ui.test.sendMoveBy
-import androidx.ui.test.sendUp
+import androidx.ui.test.cancel
+import androidx.ui.test.down
+import androidx.ui.test.move
+import androidx.ui.test.moveBy
+import androidx.ui.test.up
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.MultiPointerInputRecorder
import androidx.ui.test.util.assertTimestampsAreIncreasing
@@ -42,7 +42,7 @@
import org.junit.rules.TestRule
/**
- * Tests if [sendMoveBy] and [movePointerBy] work
+ * Tests if [moveBy] and [movePointerBy] work
*/
@MediumTest
class SendMoveByTest {
@@ -72,9 +72,9 @@
@Test
fun onePointer() {
// When we inject a down event followed by a move event
- partialGesture { sendDown(downPosition1) }
+ partialGesture { down(downPosition1) }
sleep(20) // (with some time in between)
- partialGesture { sendMoveBy(delta1) }
+ partialGesture { moveBy(delta1) }
runOnIdleCompose {
recorder.run {
@@ -95,10 +95,10 @@
@Test
fun twoPointers() {
// When we inject two down events followed by two move events
- partialGesture { sendDown(1, downPosition1) }
- partialGesture { sendDown(2, downPosition2) }
- partialGesture { sendMoveBy(1, delta1) }
- partialGesture { sendMoveBy(2, delta2) }
+ partialGesture { down(1, downPosition1) }
+ partialGesture { down(2, downPosition2) }
+ partialGesture { moveBy(1, delta1) }
+ partialGesture { moveBy(2, delta2) }
runOnIdleCompose {
recorder.run {
@@ -126,12 +126,12 @@
@Test
fun twoPointers_oneMoveEvent() {
// When we inject two down events followed by one move events
- partialGesture { sendDown(1, downPosition1) }
- partialGesture { sendDown(2, downPosition2) }
+ partialGesture { down(1, downPosition1) }
+ partialGesture { down(2, downPosition2) }
sleep(20) // (with some time in between)
partialGesture { movePointerBy(1, delta1) }
partialGesture { movePointerBy(2, delta2) }
- partialGesture { sendMove() }
+ partialGesture { move() }
runOnIdleCompose {
recorder.run {
@@ -154,33 +154,33 @@
@Test
fun moveByWithoutDown() {
expectError<IllegalStateException> {
- partialGesture { sendMoveBy(delta1) }
+ partialGesture { moveBy(delta1) }
}
}
@Test
fun moveByWrongPointerId() {
- partialGesture { sendDown(1, downPosition1) }
+ partialGesture { down(1, downPosition1) }
expectError<IllegalArgumentException> {
- partialGesture { sendMoveBy(2, delta1) }
+ partialGesture { moveBy(2, delta1) }
}
}
@Test
fun moveByAfterUp() {
- partialGesture { sendDown(downPosition1) }
- partialGesture { sendUp() }
+ partialGesture { down(downPosition1) }
+ partialGesture { up() }
expectError<IllegalStateException> {
- partialGesture { sendMoveBy(delta1) }
+ partialGesture { moveBy(delta1) }
}
}
@Test
fun moveByAfterCancel() {
- partialGesture { sendDown(downPosition1) }
- partialGesture { sendCancel() }
+ partialGesture { down(downPosition1) }
+ partialGesture { cancel() }
expectError<IllegalStateException> {
- partialGesture { sendMoveBy(delta1) }
+ partialGesture { moveBy(delta1) }
}
}
@@ -193,7 +193,7 @@
@Test
fun movePointerByWrongPointerId() {
- partialGesture { sendDown(1, downPosition1) }
+ partialGesture { down(1, downPosition1) }
expectError<IllegalArgumentException> {
partialGesture { movePointerBy(2, delta1) }
}
@@ -201,8 +201,8 @@
@Test
fun movePointerByAfterUp() {
- partialGesture { sendDown(1, downPosition1) }
- partialGesture { sendUp(1) }
+ partialGesture { down(1, downPosition1) }
+ partialGesture { up(1) }
expectError<IllegalStateException> {
partialGesture { movePointerBy(1, delta1) }
}
@@ -210,8 +210,8 @@
@Test
fun movePointerByAfterCancel() {
- partialGesture { sendDown(1, downPosition1) }
- partialGesture { sendCancel() }
+ partialGesture { down(1, downPosition1) }
+ partialGesture { cancel() }
expectError<IllegalStateException> {
partialGesture { movePointerBy(1, delta1) }
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveTest.kt
index bd7e890..f73435e 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveTest.kt
@@ -21,10 +21,10 @@
import androidx.ui.test.InputDispatcher.InputDispatcherTestRule
import androidx.ui.test.createComposeRule
import androidx.ui.test.partialgesturescope.Common.partialGesture
-import androidx.ui.test.sendCancel
-import androidx.ui.test.sendDown
-import androidx.ui.test.sendMove
-import androidx.ui.test.sendUp
+import androidx.ui.test.cancel
+import androidx.ui.test.down
+import androidx.ui.test.move
+import androidx.ui.test.up
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.expectError
import org.junit.Before
@@ -33,7 +33,7 @@
import org.junit.rules.TestRule
/**
- * Tests the error states of [sendMove] that are not tested in [SendMoveToTest] and [SendMoveByTest]
+ * Tests the error states of [move] that are not tested in [SendMoveToTest] and [SendMoveByTest]
*/
@MediumTest
class SendMoveTest() {
@@ -58,25 +58,25 @@
@Test
fun moveWithoutDown() {
expectError<IllegalStateException> {
- partialGesture { sendMove() }
+ partialGesture { move() }
}
}
@Test
fun moveAfterUp() {
- partialGesture { sendDown(downPosition1) }
- partialGesture { sendUp() }
+ partialGesture { down(downPosition1) }
+ partialGesture { up() }
expectError<IllegalStateException> {
- partialGesture { sendMove() }
+ partialGesture { move() }
}
}
@Test
fun moveAfterCancel() {
- partialGesture { sendDown(downPosition1) }
- partialGesture { sendCancel() }
+ partialGesture { down(downPosition1) }
+ partialGesture { cancel() }
expectError<IllegalStateException> {
- partialGesture { sendMove() }
+ partialGesture { move() }
}
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveToTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveToTest.kt
index 599bfa3..3978213 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveToTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendMoveToTest.kt
@@ -24,11 +24,11 @@
import androidx.ui.test.movePointerTo
import androidx.ui.test.partialgesturescope.Common.partialGesture
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendCancel
-import androidx.ui.test.sendDown
-import androidx.ui.test.sendMove
-import androidx.ui.test.sendMoveTo
-import androidx.ui.test.sendUp
+import androidx.ui.test.cancel
+import androidx.ui.test.down
+import androidx.ui.test.move
+import androidx.ui.test.moveTo
+import androidx.ui.test.up
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.MultiPointerInputRecorder
import androidx.ui.test.util.assertTimestampsAreIncreasing
@@ -42,7 +42,7 @@
import org.junit.rules.TestRule
/**
- * Tests if [sendMoveTo] and [movePointerTo] work
+ * Tests if [moveTo] and [movePointerTo] work
*/
@MediumTest
class SendMoveToTest() {
@@ -72,9 +72,9 @@
@Test
fun onePointer() {
// When we inject a down event followed by a move event
- partialGesture { sendDown(downPosition1) }
+ partialGesture { down(downPosition1) }
sleep(20) // (with some time in between)
- partialGesture { sendMoveTo(moveToPosition1) }
+ partialGesture { moveTo(moveToPosition1) }
runOnIdleCompose {
recorder.run {
@@ -95,10 +95,10 @@
@Test
fun twoPointers_separateMoveEvents() {
// When we inject two down events followed by two move events
- partialGesture { sendDown(1, downPosition1) }
- partialGesture { sendDown(2, downPosition2) }
- partialGesture { sendMoveTo(1, moveToPosition1) }
- partialGesture { sendMoveTo(2, moveToPosition2) }
+ partialGesture { down(1, downPosition1) }
+ partialGesture { down(2, downPosition2) }
+ partialGesture { moveTo(1, moveToPosition1) }
+ partialGesture { moveTo(2, moveToPosition2) }
runOnIdleCompose {
recorder.run {
@@ -126,12 +126,12 @@
@Test
fun twoPointers_oneMoveEvent() {
// When we inject two down events followed by one move events
- partialGesture { sendDown(1, downPosition1) }
- partialGesture { sendDown(2, downPosition2) }
+ partialGesture { down(1, downPosition1) }
+ partialGesture { down(2, downPosition2) }
sleep(20) // (with some time in between)
partialGesture { movePointerTo(1, moveToPosition1) }
partialGesture { movePointerTo(2, moveToPosition2) }
- partialGesture { sendMove() }
+ partialGesture { move() }
runOnIdleCompose {
recorder.run {
@@ -154,33 +154,33 @@
@Test
fun moveToWithoutDown() {
expectError<IllegalStateException> {
- partialGesture { sendMoveTo(moveToPosition1) }
+ partialGesture { moveTo(moveToPosition1) }
}
}
@Test
fun moveToWrongPointerId() {
- partialGesture { sendDown(1, downPosition1) }
+ partialGesture { down(1, downPosition1) }
expectError<IllegalArgumentException> {
- partialGesture { sendMoveTo(2, moveToPosition1) }
+ partialGesture { moveTo(2, moveToPosition1) }
}
}
@Test
fun moveToAfterUp() {
- partialGesture { sendDown(downPosition1) }
- partialGesture { sendUp() }
+ partialGesture { down(downPosition1) }
+ partialGesture { up() }
expectError<IllegalStateException> {
- partialGesture { sendMoveTo(moveToPosition1) }
+ partialGesture { moveTo(moveToPosition1) }
}
}
@Test
fun moveToAfterCancel() {
- partialGesture { sendDown(downPosition1) }
- partialGesture { sendCancel() }
+ partialGesture { down(downPosition1) }
+ partialGesture { cancel() }
expectError<IllegalStateException> {
- partialGesture { sendMoveTo(moveToPosition1) }
+ partialGesture { moveTo(moveToPosition1) }
}
}
@@ -193,7 +193,7 @@
@Test
fun movePointerToWrongPointerId() {
- partialGesture { sendDown(1, downPosition1) }
+ partialGesture { down(1, downPosition1) }
expectError<IllegalArgumentException> {
partialGesture { movePointerTo(2, moveToPosition1) }
}
@@ -201,8 +201,8 @@
@Test
fun movePointerToAfterUp() {
- partialGesture { sendDown(1, downPosition1) }
- partialGesture { sendUp(1) }
+ partialGesture { down(1, downPosition1) }
+ partialGesture { up(1) }
expectError<IllegalStateException> {
partialGesture { movePointerTo(1, moveToPosition1) }
}
@@ -210,8 +210,8 @@
@Test
fun movePointerToAfterCancel() {
- partialGesture { sendDown(1, downPosition1) }
- partialGesture { sendCancel() }
+ partialGesture { down(1, downPosition1) }
+ partialGesture { cancel() }
expectError<IllegalStateException> {
partialGesture { movePointerTo(1, moveToPosition1) }
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendUpTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendUpTest.kt
index fc6da04..9a9c3f5 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendUpTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/partialgesturescope/SendUpTest.kt
@@ -24,9 +24,9 @@
import androidx.ui.test.inputdispatcher.verifyNoGestureInProgress
import androidx.ui.test.partialgesturescope.Common.partialGesture
import androidx.ui.test.runOnIdleCompose
-import androidx.ui.test.sendCancel
-import androidx.ui.test.sendDown
-import androidx.ui.test.sendUp
+import androidx.ui.test.cancel
+import androidx.ui.test.down
+import androidx.ui.test.up
import androidx.ui.test.util.ClickableTestBox
import androidx.ui.test.util.MultiPointerInputRecorder
import androidx.ui.test.util.assertTimestampsAreIncreasing
@@ -39,7 +39,7 @@
import org.junit.rules.TestRule
/**
- * Tests if [sendUp] works
+ * Tests if [up] works
*/
@MediumTest
class SendUpTest {
@@ -67,9 +67,9 @@
@Test
fun onePointer() {
// When we inject a down event followed by an up event
- partialGesture { sendDown(downPosition1) }
+ partialGesture { down(downPosition1) }
sleep(20) // (with some time in between)
- partialGesture { sendUp() }
+ partialGesture { up() }
runOnIdleCompose {
recorder.run {
@@ -92,10 +92,10 @@
@Test
fun twoPointers() {
// When we inject two down events followed by two up events
- partialGesture { sendDown(1, downPosition1) }
- partialGesture { sendDown(2, downPosition2) }
- partialGesture { sendUp(1) }
- partialGesture { sendUp(2) }
+ partialGesture { down(1, downPosition1) }
+ partialGesture { down(2, downPosition2) }
+ partialGesture { up(1) }
+ partialGesture { up(2) }
runOnIdleCompose {
recorder.run {
@@ -123,33 +123,33 @@
@Test
fun upWithoutDown() {
expectError<IllegalStateException> {
- partialGesture { sendUp() }
+ partialGesture { up() }
}
}
@Test
fun upWrongPointerId() {
- partialGesture { sendDown(1, downPosition1) }
+ partialGesture { down(1, downPosition1) }
expectError<IllegalArgumentException> {
- partialGesture { sendUp(2) }
+ partialGesture { up(2) }
}
}
@Test
fun upAfterUp() {
- partialGesture { sendDown(downPosition1) }
- partialGesture { sendUp() }
+ partialGesture { down(downPosition1) }
+ partialGesture { up() }
expectError<IllegalStateException> {
- partialGesture { sendUp() }
+ partialGesture { up() }
}
}
@Test
fun upAfterCancel() {
- partialGesture { sendDown(downPosition1) }
- partialGesture { sendCancel() }
+ partialGesture { down(downPosition1) }
+ partialGesture { cancel() }
expectError<IllegalStateException> {
- partialGesture { sendUp() }
+ partialGesture { up() }
}
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnyAncestorTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnyAncestorTest.kt
index bff8537..c612c5d 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnyAncestorTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnyAncestorTest.kt
@@ -20,9 +20,9 @@
import androidx.ui.test.assert
import androidx.ui.test.assertCountEquals
import androidx.ui.test.createComposeRule
-import androidx.ui.test.find
-import androidx.ui.test.findAll
-import androidx.ui.test.hasAnyAncestorThat
+import androidx.ui.test.onNode
+import androidx.ui.test.onAllNodes
+import androidx.ui.test.hasAnyAncestor
import androidx.ui.test.hasTestTag
import androidx.ui.test.util.BoundaryNode
import org.junit.Rule
@@ -47,7 +47,7 @@
}
}
- find(hasAnyAncestorThat(hasTestTag("Parent")))
+ onNode(hasAnyAncestor(hasTestTag("Parent")))
.assert(hasTestTag("Child"))
}
@@ -63,7 +63,7 @@
}
}
- findAll(hasAnyAncestorThat(hasTestTag("Parent")))
+ onAllNodes(hasAnyAncestor(hasTestTag("Parent")))
.assertCountEquals(2)
}
@@ -78,7 +78,7 @@
}
}
- find(hasAnyAncestorThat(hasTestTag("Grandparent"))
+ onNode(hasAnyAncestor(hasTestTag("Grandparent"))
and !hasTestTag("Parent"))
.assert(hasTestTag("Child"))
}
@@ -94,7 +94,7 @@
}
}
- findAll(hasAnyAncestorThat(hasTestTag("Parent") or hasTestTag("Grandparent")))
+ onAllNodes(hasAnyAncestor(hasTestTag("Parent") or hasTestTag("Grandparent")))
.assertCountEquals(2)
}
@@ -104,7 +104,7 @@
BoundaryNode(testTag = "Node")
}
- find(hasAnyAncestorThat(hasTestTag("Node")))
+ onNode(hasAnyAncestor(hasTestTag("Node")))
.assertDoesNotExist()
}
@@ -116,7 +116,7 @@
}
}
- find(hasAnyAncestorThat(hasTestTag("Child")))
+ onNode(hasAnyAncestor(hasTestTag("Child")))
.assertDoesNotExist()
}
}
\ No newline at end of file
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnyChildTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnyChildTest.kt
index eac72bf..ade55ac 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnyChildTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnyChildTest.kt
@@ -20,9 +20,9 @@
import androidx.ui.test.assert
import androidx.ui.test.assertCountEquals
import androidx.ui.test.createComposeRule
-import androidx.ui.test.find
-import androidx.ui.test.findAll
-import androidx.ui.test.hasAnyChildThat
+import androidx.ui.test.onNode
+import androidx.ui.test.onAllNodes
+import androidx.ui.test.hasAnyChild
import androidx.ui.test.hasTestTag
import androidx.ui.test.util.BoundaryNode
import org.junit.Rule
@@ -47,7 +47,7 @@
}
}
- find(hasAnyChildThat(hasTestTag("Child")))
+ onNode(hasAnyChild(hasTestTag("Child")))
.assert(hasTestTag("Parent"))
}
@@ -69,11 +69,11 @@
}
}
- findAll(hasAnyChildThat(hasTestTag("Child1")))
+ onAllNodes(hasAnyChild(hasTestTag("Child1")))
.assertCountEquals(2)
- findAll(hasAnyChildThat(hasTestTag("Child2")))
+ onAllNodes(hasAnyChild(hasTestTag("Child2")))
.assertCountEquals(3)
- findAll(hasAnyChildThat(hasTestTag("Child3")))
+ onAllNodes(hasAnyChild(hasTestTag("Child3")))
.assertCountEquals(1)
}
@@ -83,7 +83,7 @@
BoundaryNode(testTag = "Child")
}
- find(hasAnyChildThat(hasTestTag("Child")))
+ onNode(hasAnyChild(hasTestTag("Child")))
.assertExists() // The root node
}
@@ -97,7 +97,7 @@
}
}
- find(hasAnyChildThat(hasTestTag("Child"))
+ onNode(hasAnyChild(hasTestTag("Child"))
and hasTestTag("Parent"))
.assertDoesNotExist()
}
@@ -112,7 +112,7 @@
}
}
- find(hasAnyChildThat(hasAnyChildThat(hasTestTag("Child"))))
+ onNode(hasAnyChild(hasAnyChild(hasTestTag("Child"))))
.assert(hasTestTag("Parent"))
}
}
\ No newline at end of file
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnyDescendantTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnyDescendantTest.kt
index 0fa8b93..d39bd5f 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnyDescendantTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnyDescendantTest.kt
@@ -20,9 +20,9 @@
import androidx.ui.test.assert
import androidx.ui.test.assertCountEquals
import androidx.ui.test.createComposeRule
-import androidx.ui.test.find
-import androidx.ui.test.findAll
-import androidx.ui.test.hasAnyDescendantThat
+import androidx.ui.test.onNode
+import androidx.ui.test.onAllNodes
+import androidx.ui.test.hasAnyDescendant
import androidx.ui.test.hasTestTag
import androidx.ui.test.util.BoundaryNode
import org.junit.Rule
@@ -47,7 +47,7 @@
}
}
- find(hasAnyDescendantThat(hasTestTag("Child")) and hasTestTag("Parent"))
+ onNode(hasAnyDescendant(hasTestTag("Child")) and hasTestTag("Parent"))
.assert(hasTestTag("Parent"))
}
@@ -62,7 +62,7 @@
}
}
- find(hasAnyDescendantThat(hasTestTag("Child")) and !hasTestTag("Parent")
+ onNode(hasAnyDescendant(hasTestTag("Child")) and !hasTestTag("Parent")
and hasTestTag("Grandparent"))
.assert(hasTestTag("Grandparent"))
}
@@ -73,7 +73,7 @@
BoundaryNode(testTag = "Node")
}
- find(hasAnyDescendantThat(hasTestTag("Node")))
+ onNode(hasAnyDescendant(hasTestTag("Node")))
.assertExists() // Root node
}
@@ -89,7 +89,7 @@
}
}
- findAll(hasAnyDescendantThat(hasTestTag("Child")))
+ onAllNodes(hasAnyDescendant(hasTestTag("Child")))
.assertCountEquals(3) // Parent, Parent2 and root
}
}
\ No newline at end of file
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnySiblingTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnySiblingTest.kt
index c1b4a80..ab87d0f 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnySiblingTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasAnySiblingTest.kt
@@ -20,10 +20,10 @@
import androidx.ui.test.assert
import androidx.ui.test.assertCountEquals
import androidx.ui.test.createComposeRule
-import androidx.ui.test.find
-import androidx.ui.test.findAll
-import androidx.ui.test.hasAnySiblingThat
-import androidx.ui.test.hasParentThat
+import androidx.ui.test.onNode
+import androidx.ui.test.onAllNodes
+import androidx.ui.test.hasAnySibling
+import androidx.ui.test.hasParent
import androidx.ui.test.hasTestTag
import androidx.ui.test.util.BoundaryNode
import org.junit.Rule
@@ -49,7 +49,7 @@
}
}
- find(hasAnySiblingThat(hasTestTag("Sibling")))
+ onNode(hasAnySibling(hasTestTag("Sibling")))
.assert(hasTestTag("Me"))
}
@@ -64,7 +64,7 @@
}
}
- findAll(hasAnySiblingThat(hasTestTag("Sibling")))
+ onAllNodes(hasAnySibling(hasTestTag("Sibling")))
.assertCountEquals(2)
}
@@ -78,7 +78,7 @@
}
}
- findAll(hasAnySiblingThat(hasTestTag("Sibling")))
+ onAllNodes(hasAnySibling(hasTestTag("Sibling")))
.assertCountEquals(2)
}
@@ -96,7 +96,7 @@
}
}
- findAll(hasAnySiblingThat(hasTestTag("Sibling")))
+ onAllNodes(hasAnySibling(hasTestTag("Sibling")))
.assertCountEquals(2)
}
@@ -108,7 +108,7 @@
}
}
- find(hasAnySiblingThat(hasTestTag("Me")))
+ onNode(hasAnySibling(hasTestTag("Me")))
.assertDoesNotExist()
}
@@ -121,7 +121,7 @@
}
}
- find(hasAnySiblingThat(hasTestTag("Sibling2")))
+ onNode(hasAnySibling(hasTestTag("Sibling2")))
.assertDoesNotExist()
}
@@ -137,7 +137,7 @@
}
}
- find(hasAnySiblingThat(hasTestTag("Sibling")) and hasTestTag("Me"))
+ onNode(hasAnySibling(hasTestTag("Sibling")) and hasTestTag("Me"))
.assertDoesNotExist()
}
@@ -154,7 +154,7 @@
}
}
- find(hasParentThat(hasAnySiblingThat(hasTestTag("ParentSibling"))))
+ onNode(hasParent(hasAnySibling(hasTestTag("ParentSibling"))))
.assert(hasTestTag("Me"))
}
}
\ No newline at end of file
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasParentTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasParentTest.kt
index d371c54..ec9982ad 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasParentTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/predicates/HasParentTest.kt
@@ -20,9 +20,9 @@
import androidx.ui.test.assert
import androidx.ui.test.assertCountEquals
import androidx.ui.test.createComposeRule
-import androidx.ui.test.find
-import androidx.ui.test.findAll
-import androidx.ui.test.hasParentThat
+import androidx.ui.test.onNode
+import androidx.ui.test.onAllNodes
+import androidx.ui.test.hasParent
import androidx.ui.test.hasTestTag
import androidx.ui.test.util.BoundaryNode
import org.junit.Rule
@@ -47,7 +47,7 @@
}
}
- find(hasParentThat(hasTestTag("Parent")))
+ onNode(hasParent(hasTestTag("Parent")))
.assert(hasTestTag("Child"))
}
@@ -61,7 +61,7 @@
}
}
- findAll(hasParentThat(hasTestTag("Parent")))
+ onAllNodes(hasParent(hasTestTag("Parent")))
.assertCountEquals(2)
}
@@ -79,7 +79,7 @@
}
}
- findAll(hasParentThat(hasTestTag("Parent")))
+ onAllNodes(hasParent(hasTestTag("Parent")))
.assertCountEquals(4)
}
@@ -93,7 +93,7 @@
}
}
- find(hasParentThat(hasTestTag("Parent"))
+ onNode(hasParent(hasTestTag("Parent"))
and hasTestTag("Child"))
.assertDoesNotExist()
}
@@ -108,7 +108,7 @@
}
}
- find(hasParentThat(hasParentThat(hasTestTag("Parent"))))
+ onNode(hasParent(hasParent(hasTestTag("Parent"))))
.assert(hasTestTag("Child"))
}
}
\ No newline at end of file
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/AddIndexSelectorTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/AddIndexSelectorTest.kt
index f76ab14..023c898 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/AddIndexSelectorTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/AddIndexSelectorTest.kt
@@ -18,11 +18,11 @@
import androidx.test.filters.MediumTest
import androidx.ui.test.assert
-import androidx.ui.test.childAt
-import androidx.ui.test.children
+import androidx.ui.test.onChildAt
+import androidx.ui.test.onChildren
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
-import androidx.ui.test.first
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.onFirst
import androidx.ui.test.hasTestTag
import androidx.ui.test.util.BoundaryNode
import androidx.ui.test.util.expectErrorMessageStartsWith
@@ -47,9 +47,9 @@
}
}
- findByTag("Parent")
- .children()
- .first()
+ onNodeWithTag("Parent")
+ .onChildren()
+ .onFirst()
.assert(hasTestTag("Child1"))
}
@@ -62,8 +62,8 @@
}
}
- findByTag("Parent")
- .childAt(1)
+ onNodeWithTag("Parent")
+ .onChildAt(1)
.assert(hasTestTag("Child2"))
}
@@ -80,8 +80,8 @@
"Failed: assertExists.\n" +
"Can't retrieve node at index '2' of '(TestTag = 'Parent').children'\n" +
"There are '2' nodes only:") {
- findByTag("Parent")
- .childAt(2)
+ onNodeWithTag("Parent")
+ .onChildAt(2)
.assertExists()
}
}
@@ -92,8 +92,8 @@
BoundaryNode(testTag = "Parent")
}
- findByTag("Parent")
- .childAt(2)
+ onNodeWithTag("Parent")
+ .onChildAt(2)
.assertDoesNotExist()
}
@@ -107,8 +107,8 @@
"Failed: assertExists.\n" +
"Can't retrieve node at index '2' of '(TestTag = 'Parent').children'\n" +
"There are no existing nodes for that selector.") {
- findByTag("Parent")
- .childAt(2)
+ onNodeWithTag("Parent")
+ .onChildAt(2)
.assertExists()
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/AncestorsSelectorTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/AncestorsSelectorTest.kt
index b223997..0e1f9b4 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/AncestorsSelectorTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/AncestorsSelectorTest.kt
@@ -17,14 +17,14 @@
package androidx.ui.test.selectors
import androidx.test.filters.MediumTest
-import androidx.ui.test.ancestors
+import androidx.ui.test.onAncestors
import androidx.ui.test.assert
import androidx.ui.test.assertCountEquals
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
-import androidx.ui.test.first
+import androidx.ui.test.onNodeWithTag
+import androidx.ui.test.onFirst
import androidx.ui.test.hasTestTag
-import androidx.ui.test.parent
+import androidx.ui.test.onParent
import androidx.ui.test.util.BoundaryNode
import org.junit.Rule
import org.junit.Test
@@ -50,8 +50,8 @@
}
}
- findByTag("NodeD")
- .ancestors()
+ onNodeWithTag("NodeD")
+ .onAncestors()
.assertCountEquals(4)
.apply {
get(0).assert(hasTestTag("NodeC"))
@@ -72,10 +72,10 @@
}
}
- findByTag("NodeD")
- .ancestors()
- .first()
- .ancestors()
+ onNodeWithTag("NodeD")
+ .onAncestors()
+ .onFirst()
+ .onAncestors()
.assertCountEquals(3)
.apply {
get(0).assert(hasTestTag("NodeB"))
@@ -89,9 +89,9 @@
BoundaryNode(testTag = "Node")
}
- findByTag("Node")
- .parent()
- .ancestors()
+ onNodeWithTag("Node")
+ .onParent()
+ .onAncestors()
.assertCountEquals(0)
}
}
\ No newline at end of file
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/ChildSelectorTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/ChildSelectorTest.kt
index 0ae4de0..92edb12 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/ChildSelectorTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/ChildSelectorTest.kt
@@ -18,9 +18,9 @@
import androidx.test.filters.MediumTest
import androidx.ui.test.assert
-import androidx.ui.test.child
+import androidx.ui.test.onChild
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.hasTestTag
import androidx.ui.test.util.BoundaryNode
import androidx.ui.test.util.expectErrorMessageStartsWith
@@ -44,8 +44,8 @@
}
}
- findByTag("Parent")
- .child()
+ onNodeWithTag("Parent")
+ .onChild()
.assert(hasTestTag("Child"))
}
@@ -55,8 +55,8 @@
BoundaryNode(testTag = "Parent")
}
- findByTag("Parent")
- .child()
+ onNodeWithTag("Parent")
+ .onChild()
.assertDoesNotExist()
}
@@ -66,8 +66,8 @@
BoundaryNode(testTag = "Parent")
}
- findByTag("Parent")
- .child()
+ onNodeWithTag("Parent")
+ .onChild()
.assertExists()
}
@@ -86,8 +86,8 @@
"((TestTag = 'Parent').child)\n" +
"Nodes found:"
) {
- findByTag("Parent")
- .child()
+ onNodeWithTag("Parent")
+ .onChild()
.assertExists()
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/ChildrenSelectorTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/ChildrenSelectorTest.kt
index d03732d..cb78014 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/ChildrenSelectorTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/ChildrenSelectorTest.kt
@@ -19,9 +19,9 @@
import androidx.test.filters.MediumTest
import androidx.ui.test.assert
import androidx.ui.test.assertCountEquals
-import androidx.ui.test.children
+import androidx.ui.test.onChildren
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.hasTestTag
import androidx.ui.test.util.BoundaryNode
import org.junit.Rule
@@ -45,8 +45,8 @@
}
}
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.assertCountEquals(2)
.apply {
get(0).assert(hasTestTag("Child1"))
@@ -60,8 +60,8 @@
BoundaryNode(testTag = "Parent")
}
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.assertCountEquals(0)
}
}
\ No newline at end of file
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/FilterSelectorTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/FilterSelectorTest.kt
index 871533af..9345588 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/FilterSelectorTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/FilterSelectorTest.kt
@@ -19,10 +19,10 @@
import androidx.test.filters.MediumTest
import androidx.ui.test.assert
import androidx.ui.test.assertCountEquals
-import androidx.ui.test.children
+import androidx.ui.test.onChildren
import androidx.ui.test.createComposeRule
import androidx.ui.test.filter
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.hasTestTag
import androidx.ui.test.util.BoundaryNode
import org.junit.Rule
@@ -46,8 +46,8 @@
}
}
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.filter(hasTestTag("Child1"))
.assertCountEquals(1)
.apply {
@@ -64,8 +64,8 @@
}
}
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.filter(hasTestTag("Child1") or hasTestTag("Child2"))
.assertCountEquals(2)
.apply {
@@ -83,8 +83,8 @@
}
}
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.filter(hasTestTag("Child"))
.assertCountEquals(0)
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/FilterToOneSelectorTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/FilterToOneSelectorTest.kt
index 5772435..735f3a9 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/FilterToOneSelectorTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/FilterToOneSelectorTest.kt
@@ -18,10 +18,10 @@
import androidx.test.filters.MediumTest
import androidx.ui.test.assert
-import androidx.ui.test.children
+import androidx.ui.test.onChildren
import androidx.ui.test.createComposeRule
import androidx.ui.test.filterToOne
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.hasTestTag
import androidx.ui.test.util.BoundaryNode
import androidx.ui.test.util.expectErrorMessageStartsWith
@@ -46,8 +46,8 @@
}
}
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.filterToOne(hasTestTag("Child1"))
.assert(hasTestTag("Child1"))
}
@@ -69,8 +69,8 @@
"Nodes found:\n" +
"1) "
) {
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.filterToOne(hasTestTag("Child1") or hasTestTag("Child2"))
.assertExists()
}
@@ -85,8 +85,8 @@
}
}
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.filterToOne(hasTestTag("Child"))
.assertDoesNotExist()
}
@@ -104,8 +104,8 @@
"Failed: assertExists.\n" +
"Reason: Expected exactly '1' node but could not find any node that satisfies: " +
"(((TestTag = 'Parent').children).filterToOne(TestTag = 'Child'))") {
- findByTag("Parent")
- .children()
+ onNodeWithTag("Parent")
+ .onChildren()
.filterToOne(hasTestTag("Child"))
.assertExists()
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/LastNodeSelectorTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/LastNodeSelectorTest.kt
index c779481..1ebcc152 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/LastNodeSelectorTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/LastNodeSelectorTest.kt
@@ -18,11 +18,11 @@
import androidx.test.filters.MediumTest
import androidx.ui.test.assert
-import androidx.ui.test.children
+import androidx.ui.test.onChildren
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.hasTestTag
-import androidx.ui.test.last
+import androidx.ui.test.onLast
import androidx.ui.test.util.BoundaryNode
import androidx.ui.test.util.expectErrorMessageStartsWith
import org.junit.Rule
@@ -46,9 +46,9 @@
}
}
- findByTag("Parent")
- .children()
- .last()
+ onNodeWithTag("Parent")
+ .onChildren()
+ .onLast()
.assert(hasTestTag("Child2"))
}
@@ -58,9 +58,9 @@
BoundaryNode(testTag = "Parent")
}
- findByTag("Parent")
- .children()
- .last()
+ onNodeWithTag("Parent")
+ .onChildren()
+ .onLast()
.assertDoesNotExist()
}
@@ -74,9 +74,9 @@
"Failed: assertExists.\n" +
"Reason: Expected exactly '1' node but could not find any node that satisfies: " +
"(((TestTag = 'Parent').children).last)") {
- findByTag("Parent")
- .children()
- .last()
+ onNodeWithTag("Parent")
+ .onChildren()
+ .onLast()
.assertExists()
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/ParentSelectorTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/ParentSelectorTest.kt
index 60baee2..2cec2b7 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/ParentSelectorTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/ParentSelectorTest.kt
@@ -19,9 +19,9 @@
import androidx.test.filters.MediumTest
import androidx.ui.test.assert
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.hasTestTag
-import androidx.ui.test.parent
+import androidx.ui.test.onParent
import androidx.ui.test.util.BoundaryNode
import androidx.ui.test.util.expectErrorMessage
import org.junit.Rule
@@ -44,8 +44,8 @@
}
}
- findByTag("Child")
- .parent()
+ onNodeWithTag("Child")
+ .onParent()
.assert(hasTestTag("Parent"))
}
@@ -55,9 +55,9 @@
BoundaryNode(testTag = "Node")
}
- findByTag("Node")
- .parent()
- .parent()
+ onNodeWithTag("Node")
+ .onParent()
+ .onParent()
.assertDoesNotExist()
}
@@ -72,9 +72,9 @@
"Reason: Expected exactly '1' node but could not find any node that satisfies: " +
"(((TestTag = 'Node').parent).parent)"
) {
- findByTag("Node")
- .parent()
- .parent()
+ onNodeWithTag("Node")
+ .onParent()
+ .onParent()
.assertExists()
}
}
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/SiblingSelectorTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/SiblingSelectorTest.kt
index d4f4796..f019c5f 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/SiblingSelectorTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/SiblingSelectorTest.kt
@@ -19,9 +19,9 @@
import androidx.test.filters.MediumTest
import androidx.ui.test.assert
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.hasTestTag
-import androidx.ui.test.sibling
+import androidx.ui.test.onSibling
import androidx.ui.test.util.BoundaryNode
import androidx.ui.test.util.expectErrorMessageStartsWith
import org.junit.Rule
@@ -45,8 +45,8 @@
}
}
- findByTag("Child1")
- .sibling()
+ onNodeWithTag("Child1")
+ .onSibling()
.assert(hasTestTag("Child2"))
}
@@ -67,8 +67,8 @@
"Nodes found:"
) {
- findByTag("Child1")
- .sibling()
+ onNodeWithTag("Child1")
+ .onSibling()
.assert(hasTestTag("Child2"))
}
}
@@ -81,8 +81,8 @@
}
}
- findByTag("Child")
- .sibling()
+ onNodeWithTag("Child")
+ .onSibling()
.assertDoesNotExist()
}
@@ -94,8 +94,8 @@
}
}
- findByTag("Child")
- .sibling()
+ onNodeWithTag("Child")
+ .onSibling()
.assertExists()
}
}
\ No newline at end of file
diff --git a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/SiblingsSelectorTest.kt b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/SiblingsSelectorTest.kt
index 568481b..124ad9f 100644
--- a/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/SiblingsSelectorTest.kt
+++ b/ui/ui-test/src/androidTest/java/androidx/ui/test/selectors/SiblingsSelectorTest.kt
@@ -20,9 +20,9 @@
import androidx.ui.test.assert
import androidx.ui.test.assertCountEquals
import androidx.ui.test.createComposeRule
-import androidx.ui.test.findByTag
+import androidx.ui.test.onNodeWithTag
import androidx.ui.test.hasTestTag
-import androidx.ui.test.siblings
+import androidx.ui.test.onSiblings
import androidx.ui.test.util.BoundaryNode
import org.junit.Rule
import org.junit.Test
@@ -44,8 +44,8 @@
}
}
- findByTag("Child")
- .siblings()
+ onNodeWithTag("Child")
+ .onSiblings()
.assertCountEquals(0)
}
@@ -58,8 +58,8 @@
}
}
- findByTag("Child1")
- .siblings()
+ onNodeWithTag("Child1")
+ .onSiblings()
.assertCountEquals(1)
}
@@ -73,8 +73,8 @@
}
}
- findByTag("Child2")
- .siblings()
+ onNodeWithTag("Child2")
+ .onSiblings()
.assertCountEquals(2)
.apply {
get(0).assert(hasTestTag("Child1"))
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/Actions.kt b/ui/ui-test/src/main/java/androidx/ui/test/Actions.kt
index 9543c65..96b92f0 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/Actions.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/Actions.kt
@@ -24,9 +24,9 @@
import androidx.ui.semantics.SemanticsPropertyKey
/**
- * Performs a click action on the given component.
+ * Performs a click action on the element represented by the given semantics node.
*/
-fun SemanticsNodeInteraction.doClick(): SemanticsNodeInteraction {
+fun SemanticsNodeInteraction.performClick(): SemanticsNodeInteraction {
// TODO(jellefresen): Replace with semantics action when semantics merging is done
// The problem we currently have is that the click action might be defined on a different
// semantics node than we're interacting with now, even though it is "semantically" the same.
@@ -35,22 +35,22 @@
// Since in general the intended click action can be on a wrapping node or a child node, we
// can't just forward to the correct node, as we don't know if we should search up or down the
// tree.
- return doGesture {
- sendClick()
+ return performGesture {
+ click()
}
}
/**
- * Scrolls to a component using SemanticsActions. It first identifies a parent component with a
+ * Scrolls to a node using SemanticsActions. It first identifies a parent semantics node with a
* Semantics ScrollTo action, then it retrieves the location of the current element and computes
* the relative coordinates that will be used by the scroller.
*
- * Throws [AssertionError] if there is no parent component with ScrollTo SemanticsAction, the
- * current semantics component doesn't have a bounding rectangle set or if a layout node used to
+ * Throws [AssertionError] if there is no parent node with ScrollTo SemanticsAction, the
+ * current semantics node doesn't have a bounding rectangle set or if a layout node used to
* compute the relative coordinates to be fed to the ScrollTo action can't be found.
*/
-fun SemanticsNodeInteraction.doScrollTo(): SemanticsNodeInteraction {
- // find containing component with scroll action
+fun SemanticsNodeInteraction.performScrollTo(): SemanticsNodeInteraction {
+ // find containing node with scroll action
val errorMessageOnFail = "Failed to perform doScrollTo."
val node = fetchSemanticsNode(errorMessageOnFail)
val scrollableSemanticsNode = node.findClosestParentNode {
@@ -82,13 +82,13 @@
*
* Example usage:
* ```
- * findByTag("myWidget")
+ * onNodeWithTag("myWidget")
* .doGesture {
* sendSwipeUp()
* }
* ```
*/
-fun SemanticsNodeInteraction.doGesture(
+fun SemanticsNodeInteraction.performGesture(
block: GestureScope.() -> Unit
): SemanticsNodeInteraction {
val node = fetchSemanticsNode("Failed to perform a gesture.")
@@ -107,19 +107,19 @@
* complete and can be resumed later. It is the responsibility of the caller to make sure partial
* gestures don't leave the test in an inconsistent state.
*
- * When [sending the down event][sendDown], a token is returned which needs to be used in all
+ * When [sending the down event][down], a token is returned which needs to be used in all
* subsequent events of this gesture.
*
* Example usage:
* ```
* val position = Offset(10f, 10f)
- * findByTag("myWidget")
- * .doPartialGesture { sendDown(position) }
+ * onNodeWithTag("myWidget")
+ * .performPartialGesture { sendDown(position) }
* .assertHasClickAction()
- * .doPartialGesture { sendUp(position) }
+ * .performPartialGesture { sendUp(position) }
* ```
*/
-fun SemanticsNodeInteraction.doPartialGesture(
+fun SemanticsNodeInteraction.performPartialGesture(
block: PartialGestureScope.() -> Unit
): SemanticsNodeInteraction {
val node = fetchSemanticsNode("Failed to perform a partial gesture.")
@@ -148,15 +148,15 @@
*
* @throws AssertionError If the semantics action is not defined on this node.
*/
-fun <T : Function<Boolean>> SemanticsNodeInteraction.callSemanticsAction(
+fun <T : Function<Boolean>> SemanticsNodeInteraction.performSemanticsAction(
key: SemanticsPropertyKey<AccessibilityAction<T>>,
invocation: (T) -> Unit
) {
- val node = fetchSemanticsNode("Failed to call ${key.name} action.")
+ val node = fetchSemanticsNode("Failed to perform ${key.name} action.")
if (key !in node.config) {
throw AssertionError(
buildGeneralErrorMessage(
- "Failed to call ${key.name} action as it is not defined on the node.",
+ "Failed to perform ${key.name} action as it is not defined on the node.",
selector, node)
)
}
@@ -179,8 +179,111 @@
*
* @throws AssertionError If the semantics action is not defined on this node.
*/
-fun SemanticsNodeInteraction.callSemanticsAction(
+fun SemanticsNodeInteraction.performSemanticsAction(
key: SemanticsPropertyKey<AccessibilityAction<() -> Boolean>>
) {
- callSemanticsAction(key) { it.invoke() }
+ performSemanticsAction(key) { it.invoke() }
}
+
+// DEPRECATED APIs SECTION
+
+/**
+ * Performs a click action on the given component.
+ */
+@Deprecated("Renamed to performClick",
+ replaceWith = ReplaceWith("performClick()"))
+fun SemanticsNodeInteraction.doClick(): SemanticsNodeInteraction = performClick()
+
+/**
+ * Scrolls to a component using SemanticsActions. It first identifies a parent component with a
+ * Semantics ScrollTo action, then it retrieves the location of the current element and computes
+ * the relative coordinates that will be used by the scroller.
+ *
+ * Throws [AssertionError] if there is no parent component with ScrollTo SemanticsAction, the
+ * current semantics component doesn't have a bounding rectangle set or if a layout node used to
+ * compute the relative coordinates to be fed to the ScrollTo action can't be found.
+ */
+@Deprecated("Renamed to performScrollTo",
+ replaceWith = ReplaceWith("performScrollTo()"))
+fun SemanticsNodeInteraction.doScrollTo(): SemanticsNodeInteraction = performScrollTo()
+
+/**
+ * Executes the gestures specified in the given block.
+ *
+ * Example usage:
+ * ```
+ * onNodeWithTag("myWidget")
+ * .doGesture {
+ * sendSwipeUp()
+ * }
+ * ```
+ */
+@Deprecated("Renamed to performGesture",
+ replaceWith = ReplaceWith("performGesture(block)"))
+fun SemanticsNodeInteraction.doGesture(
+ block: GestureScope.() -> Unit
+): SemanticsNodeInteraction = performGesture(block)
+
+/**
+ * Executes the (partial) gesture specified in the given block. The gesture doesn't need to be
+ * complete and can be resumed later. It is the responsibility of the caller to make sure partial
+ * gestures don't leave the test in an inconsistent state.
+ *
+ * When [sending the down event][down], a token is returned which needs to be used in all
+ * subsequent events of this gesture.
+ *
+ * Example usage:
+ * ```
+ * val position = Offset(10f, 10f)
+ * onNodeWithTag("myWidget")
+ * .doPartialGesture { sendDown(position) }
+ * .assertHasClickAction()
+ * .doPartialGesture { sendUp(position) }
+ * ```
+ */
+@Deprecated("Renamed to performPartialGesture",
+ replaceWith = ReplaceWith("performPartialGesture(block)"))
+fun SemanticsNodeInteraction.doPartialGesture(
+ block: PartialGestureScope.() -> Unit
+): SemanticsNodeInteraction = performPartialGesture(block)
+
+/**
+ * Provides support to call custom semantics actions on this node.
+ *
+ * This method is supposed to be used for actions with parameters.
+ *
+ * This will properly verify that the actions exists and provide clear error message in case it
+ * does not. It also handle synchronization and performing the action on the UI thread. This call
+ * is blocking until the action is performed
+ *
+ * @param key Key of the action to be performed.
+ * @param invocation Place where you call your action. In the argument is provided the underlying
+ * action from the given Semantics action.
+ *
+ * @throws AssertionError If the semantics action is not defined on this node.
+ */
+@Deprecated("Renamed to performSemanticsAction",
+ replaceWith = ReplaceWith("performSemanticsAction(key, invocation)"))
+fun <T : Function<Boolean>> SemanticsNodeInteraction.callSemanticsAction(
+ key: SemanticsPropertyKey<AccessibilityAction<T>>,
+ invocation: (T) -> Unit
+) = performSemanticsAction(key, invocation)
+
+/**
+ * Provides support to call custom semantics actions on this node.
+ *
+ * This method is for calling actions that have no parameters.
+ *
+ * This will properly verify that the actions exists and provide clear error message in case it
+ * does not. It also handle synchronization and performing the action on the UI thread. This call
+ * is blocking until the action is performed
+ *
+ * @param key Key of the action to be performed.
+ *
+ * @throws AssertionError If the semantics action is not defined on this node.
+ */
+@Deprecated("Renamed to performSemanticsAction",
+ replaceWith = ReplaceWith("performSemanticsAction(key)"))
+fun SemanticsNodeInteraction.callSemanticsAction(
+ key: SemanticsPropertyKey<AccessibilityAction<() -> Boolean>>
+) = performSemanticsAction(key)
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/Assertions.kt b/ui/ui-test/src/main/java/androidx/ui/test/Assertions.kt
index 7e72a19..a5641aa 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/Assertions.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/Assertions.kt
@@ -31,31 +31,31 @@
import androidx.ui.unit.width
/**
- * Asserts that the current component has hidden property set to true.
+ * Asserts that the current semantics node has hidden property set to true.
*
- * Note that this does not verify parents of the component. For stronger guarantees of visibility
- * see [assertIsNotDisplayed]. If you want to assert that the component is not even in the hierarchy
+ * Note that this does not verify parents of the node. For stronger guarantees of visibility
+ * see [assertIsNotDisplayed]. If you want to assert that the node is not even in the hierarchy
* use [SemanticsNodeInteraction.assertDoesNotExist].
*
- * Throws [AssertionError] if the component is not hidden.
+ * Throws [AssertionError] if the node is not hidden.
*/
fun SemanticsNodeInteraction.assertIsHidden(): SemanticsNodeInteraction = assert(isHidden())
/**
- * Asserts that the current component has hidden property set to false.
+ * Asserts that the current semantics node has hidden property set to false.
*
- * Note that this does not verify parents of the component. For stronger guarantees of visibility
- * see [assertIsDisplayed]. If you only want to assert that the component is in the hierarchy use
+ * Note that this does not verify parents of the node. For stronger guarantees of visibility
+ * see [assertIsDisplayed]. If you only want to assert that the node is in the hierarchy use
* [SemanticsNodeInteraction.assertExists]
*
- * Throws [AssertionError] if the component is hidden.
+ * Throws [AssertionError] if the node is hidden.
*/
fun SemanticsNodeInteraction.assertIsNotHidden(): SemanticsNodeInteraction = assert(isNotHidden())
/**
- * Asserts that the current component is displayed on screen.
+ * Asserts that the current semantics node is displayed on screen.
*
- * Throws [AssertionError] if the component is not displayed.
+ * Throws [AssertionError] if the node is not displayed.
*/
fun SemanticsNodeInteraction.assertIsDisplayed(): SemanticsNodeInteraction {
// TODO(b/143607231): check semantics hidden property
@@ -69,9 +69,9 @@
}
/**
- * Asserts that the current component is not displayed on screen.
+ * Asserts that the current semantics node is not displayed on screen.
*
- * Throws [AssertionError] if the component is displayed.
+ * Throws [AssertionError] if the node is displayed.
*/
fun SemanticsNodeInteraction.assertIsNotDisplayed(): SemanticsNodeInteraction {
// TODO(b/143607231): check semantics hidden property
@@ -85,73 +85,73 @@
}
/**
- * Asserts that the current component is enabled.
+ * Asserts that the current semantics node is enabled.
*
- * Throws [AssertionError] if the component is not enabled or does not define the property at all.
+ * Throws [AssertionError] if the node is not enabled or does not define the property at all.
*/
fun SemanticsNodeInteraction.assertIsEnabled(): SemanticsNodeInteraction = assert(isEnabled())
/**
- * Asserts that the current component is not enabled.
+ * Asserts that the current semantics node is not enabled.
*
- * Throws [AssertionError] if the component is enabled or does not defined the property at all.
+ * Throws [AssertionError] if the node is enabled or does not defined the property at all.
*/
fun SemanticsNodeInteraction.assertIsNotEnabled(): SemanticsNodeInteraction = assert(isNotEnabled())
/**
- * Asserts that the current component is checked.
+ * Asserts that the current semantics node is checked.
*
- * Throws [AssertionError] if the component is not unchecked, indeterminate, or not toggleable.
+ * Throws [AssertionError] if the node is not unchecked, indeterminate, or not toggleable.
*/
fun SemanticsNodeInteraction.assertIsOn(): SemanticsNodeInteraction = assert(isOn())
/**
- * Asserts that the current component is unchecked.
+ * Asserts that the current semantics node is unchecked.
*
- * Throws [AssertionError] if the component is checked, indeterminate, or not toggleable.
+ * Throws [AssertionError] if the node is checked, indeterminate, or not toggleable.
*/
fun SemanticsNodeInteraction.assertIsOff(): SemanticsNodeInteraction = assert(isOff())
/**
- * Asserts that the current component is selected.
+ * Asserts that the current semantics node is selected.
*
- * Throws [AssertionError] if the component is unselected or not selectable.
+ * Throws [AssertionError] if the node is unselected or not selectable.
*/
fun SemanticsNodeInteraction.assertIsSelected(): SemanticsNodeInteraction = assert(isSelected())
/**
- * Asserts that the current component is unselected.
+ * Asserts that the current semantics node is unselected.
*
- * Throws [AssertionError] if the component is selected or not selectable.
+ * Throws [AssertionError] if the node is selected or not selectable.
*/
fun SemanticsNodeInteraction.assertIsUnselected(): SemanticsNodeInteraction =
assert(isUnselected())
/**
- * Asserts that the current component is toggleable.
+ * Asserts that the current semantics node is toggleable.
*
- * Throws [AssertionError] if the component is not toggleable.
+ * Throws [AssertionError] if the node is not toggleable.
*/
fun SemanticsNodeInteraction.assertIsToggleable(): SemanticsNodeInteraction =
assert(isToggleable())
/**
- * Asserts that the current component is selectable.
+ * Asserts that the current semantics node is selectable.
*
- * Throws [AssertionError] if the component is not selectable.
+ * Throws [AssertionError] if the node is not selectable.
*/
fun SemanticsNodeInteraction.assertIsSelectable(): SemanticsNodeInteraction =
assert(isSelectable())
/**
- * Asserts the component is in a mutually exclusive group. This is used by radio groups to assert
- * only one is selected at a given time.
+ * Asserts the semantics node is in a mutually exclusive group. This is used by radio groups to
+ * assert only one is selected at a given time.
*/
fun SemanticsNodeInteraction.assertIsInMutuallyExclusiveGroup(): SemanticsNodeInteraction =
assert(isInMutuallyExclusiveGroup())
/**
- * Asserts the component's label equals the given String.
+ * Asserts the node's label equals the given String.
* For further details please check [SemanticsProperties.AccessibilityLabel].
* Throws [AssertionError] if the node's value is not equal to `value`, or if the node has no value
*/
@@ -159,7 +159,7 @@
assert(hasLabel(value))
/**
- * Asserts the component's text equals the given String.
+ * Asserts the node's text equals the given String.
* For further details please check [SemanticsProperties.Text].
* Throws [AssertionError] if the node's value is not equal to `value`, or if the node has no value
*/
@@ -167,7 +167,7 @@
assert(hasText(value))
/**
- * Asserts the component's value equals the given value.
+ * Asserts the node's value equals the given value.
*
* For further details please check [SemanticsProperties.AccessibilityValue].
* Throws [AssertionError] if the node's value is not equal to `value`, or if the node has no value
@@ -176,7 +176,7 @@
assert(hasValue(value))
/**
- * Asserts the component's range info equals the given value.
+ * Asserts the node's range info equals the given value.
*
* For further details please check [SemanticsProperties.AccessibilityRangeInfo].
* Throws [AssertionError] if the node's value is not equal to `value`, or if the node has no value
@@ -186,17 +186,17 @@
assert(hasRangeInfo(value))
/**
- * Asserts that the current component has a click action.
+ * Asserts that the current semantics node has a click action.
*
- * Throws [AssertionError] if the component is doesn't have a click action.
+ * Throws [AssertionError] if the node is doesn't have a click action.
*/
fun SemanticsNodeInteraction.assertHasClickAction(): SemanticsNodeInteraction =
assert(hasClickAction())
/**
- * Asserts that the current component doesn't have a click action.
+ * Asserts that the current semantics node has doesn't have a click action.
*
- * Throws [AssertionError] if the component has a click action.
+ * Throws [AssertionError] if the node has a click action.
*/
fun SemanticsNodeInteraction.assertHasNoClickAction(): SemanticsNodeInteraction =
assert(hasNoClickAction())
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/BitmapHelpers.kt b/ui/ui-test/src/main/java/androidx/ui/test/BitmapHelpers.kt
index 822aeb2..6f2b904 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/BitmapHelpers.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/BitmapHelpers.kt
@@ -43,9 +43,9 @@
import kotlin.math.roundToInt
/**
- * Captures the underlying component's surface into bitmap.
+ * Captures the underlying semantics node's surface into bitmap.
*
- * This has a limitation that if there is another window covering part of this component, such a
+ * This has a limitation that if there is another window covering part of this node, such a
* window won't occur in this bitmap.
*/
@RequiresApi(Build.VERSION_CODES.O)
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/Filters.kt b/ui/ui-test/src/main/java/androidx/ui/test/Filters.kt
index eba23b0..fb073fa 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/Filters.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/Filters.kt
@@ -28,7 +28,7 @@
import androidx.ui.util.fastAny
/**
- * Returns whether the component is enabled.
+ * Returns whether the node is enabled.
*
* @see SemanticsProperties.Enabled
*/
@@ -36,7 +36,7 @@
SemanticsMatcher.expectValue(SemanticsProperties.Enabled, true)
/**
- * Returns whether the component is not enabled.
+ * Returns whether the node is not enabled.
*
* @see SemanticsProperties.Enabled
*/
@@ -44,7 +44,7 @@
SemanticsMatcher.expectValue(SemanticsProperties.Enabled, false)
/**
- * Return whether the component is checkable.
+ * Return whether the node is checkable.
*
* @see FoundationSemanticsProperties.ToggleableState
*/
@@ -52,7 +52,7 @@
SemanticsMatcher.keyIsDefined(FoundationSemanticsProperties.ToggleableState)
/**
- * Returns whether the component is toggled.
+ * Returns whether the node is toggled.
*
* @see FoundationSemanticsProperties.ToggleableState
*/
@@ -60,7 +60,7 @@
FoundationSemanticsProperties.ToggleableState, ToggleableState.On)
/**
- * Returns whether the component is not toggled.
+ * Returns whether the node is not toggled.
*
* @see FoundationSemanticsProperties.ToggleableState
*/
@@ -68,7 +68,7 @@
FoundationSemanticsProperties.ToggleableState, ToggleableState.Off)
/**
- * Return whether the component is selectable.
+ * Return whether the node is selectable.
*
* @see FoundationSemanticsProperties.Selected
*/
@@ -76,7 +76,7 @@
SemanticsMatcher.keyIsDefined(FoundationSemanticsProperties.Selected)
/**
- * Returns whether the component is selected.
+ * Returns whether the node is selected.
*
* @see FoundationSemanticsProperties.Selected
*/
@@ -84,7 +84,7 @@
SemanticsMatcher.expectValue(FoundationSemanticsProperties.Selected, true)
/**
- * Returns whether the component is not selected.
+ * Returns whether the node is not selected.
*
* @see FoundationSemanticsProperties.Selected
*/
@@ -92,7 +92,7 @@
SemanticsMatcher.expectValue(FoundationSemanticsProperties.Selected, false)
/**
- * Return whether the component has a semantics click action defined.
+ * Return whether the node has a semantics click action defined.
*
* @see SemanticsActions.OnClick
*/
@@ -100,7 +100,7 @@
SemanticsMatcher.keyIsDefined(SemanticsActions.OnClick)
/**
- * Return whether the component has no semantics click action defined.
+ * Return whether the node has no semantics click action defined.
*
* @see SemanticsActions.OnClick
*/
@@ -108,7 +108,7 @@
SemanticsMatcher.keyNotDefined(SemanticsActions.OnClick)
/**
- * Return whether the component has a semantics scrollable action defined.
+ * Return whether the node has a semantics scrollable action defined.
*
* @see SemanticsActions.ScrollTo
*/
@@ -116,7 +116,7 @@
SemanticsMatcher.keyIsDefined(SemanticsActions.ScrollTo)
/**
- * Return whether the component has no semantics scrollable action defined.
+ * Return whether the node has no semantics scrollable action defined.
*
* @see SemanticsActions.ScrollTo
*/
@@ -124,7 +124,7 @@
SemanticsMatcher.keyNotDefined(SemanticsActions.ScrollTo)
/**
- * Returns whether the component's label matches exactly to the given text.
+ * Returns whether the node's label matches exactly to the given text.
*
* @param label Text to match.
* @param ignoreCase Whether case should be ignored.
@@ -140,7 +140,7 @@
}
/**
- * Returns whether the component's text matches exactly to the given text.
+ * Returns whether the node's text matches exactly to the given text.
*
* @param text Text to match.
* @param ignoreCase Whether case should be ignored.
@@ -157,7 +157,7 @@
}
/**
- * Returns whether the component's text contains the given substring.
+ * Returns whether the node's text contains the given substring.
*
* @param substring Substring to check.
* @param ignoreCase Whether case should be ignored.
@@ -176,7 +176,7 @@
}
/**
- * Returns whether the component's value matches exactly to the given accessibility value.
+ * Returns whether the node's value matches exactly to the given accessibility value.
*
* @param value Value to match.
*
@@ -186,7 +186,7 @@
SemanticsProperties.AccessibilityValue, value)
/**
- * Returns whether the component's range info matches exactly to the given accessibility range info.
+ * Returns whether the node's range info matches exactly to the given accessibility range info.
*
* @param rangeInfo range info to match.
*
@@ -196,7 +196,7 @@
.expectValue(SemanticsProperties.AccessibilityRangeInfo, rangeInfo)
/**
- * Returns whether the component is annotated by the given test tag.
+ * Returns whether the node is annotated by the given test tag.
*
* @param testTag Value to match.
*
@@ -207,7 +207,7 @@
// TODO(ryanmentley/pavlis): Do we want these convenience functions?
/**
- * Verifies that the component is in a mutually exclusive group - that is,
+ * Verifies that the node is in a mutually exclusive group - that is,
* that [FoundationSemanticsProperties.InMutuallyExclusiveGroup] is set to true
*
*/
@@ -215,9 +215,9 @@
SemanticsMatcher.expectValue(FoundationSemanticsProperties.InMutuallyExclusiveGroup, true)
/**
- * Returns whether the component is hidden.
+ * Returns whether the node is hidden.
*
- * This checks only the property of the component itself. Ignoring parents visibility.
+ * This checks only the property of the node itself. Ignoring parents visibility.
*
* @see SemanticsProperties.Hidden
*/
@@ -225,9 +225,9 @@
SemanticsMatcher.expectValue(SemanticsProperties.Hidden, true)
/**
- * Returns whether the component is not hidden.
+ * Returns whether the node is not hidden.
*
- * This checks only the property of the component itself. Ignoring parents visibility.
+ * This checks only the property of the node itself. Ignoring parents visibility.
*
* @see SemanticsProperties.Hidden
*/
@@ -235,9 +235,9 @@
SemanticsMatcher.expectValue(SemanticsProperties.Hidden, false)
/**
- * Returns whether the component is a dialog.
+ * Returns whether the node is a dialog.
*
- * This only checks if the component itself is a dialog, not if it is _part of_ a dialog. Use
+ * This only checks if the node itself is a dialog, not if it is _part of_ a dialog. Use
* `hasAnyAncestorThat(isDialog())` for that.
*
* @see FoundationSemanticsProperties.IsDialog
@@ -245,9 +245,9 @@
fun isDialog(): SemanticsMatcher =
SemanticsMatcher.keyIsDefined(FoundationSemanticsProperties.IsDialog)
-/** Returns whether the component is a popup.
+/** Returns whether the node is a popup.
*
- * This only checks if the component itself is a popup, not if it is _part of_ a popup. Use
+ * This only checks if the node itself is a popup, not if it is _part of_ a popup. Use
* `hasAnyAncestorThat(isPopup())` for that.
*
* @see SemanticsProperties.IsPopup
@@ -256,7 +256,7 @@
SemanticsMatcher.keyIsDefined(SemanticsProperties.IsPopup)
/**
- * Returns whether the component defines the given IME action.
+ * Returns whether the node defines the given IME action.
*
* @param actionType the action to match.
*/
@@ -264,30 +264,30 @@
SemanticsMatcher.expectValue(TextSemanticsProperties.ImeAction, actionType)
/**
- * Return whether the component supports input methods.
+ * Return whether the node supports input methods.
*
- * Supporting input methods means that the component provides a connection to IME (keyboard) and is
- * able to accept input from it. This is however not enforced and relies on the components to
+ * Supporting input methods means that the node provides a connection to IME (keyboard) and is
+ * able to accept input from it. This is however not enforced and relies on the nodes to
* properly add this to semantics when they provide input. Note that this is not related to
* gestures input but only to IME. This can be used to for instance filter out all text fields.
*/
fun hasInputMethodsSupport() =
SemanticsMatcher.expectValue(TextSemanticsProperties.SupportsInputMethods, true)
-/*
- * Return whether the component is the root semantics node.
+/**
+ * Return whether the node is the root semantics node.
*
- * There is always one root in every component tree, added implicitly by Compose.
+ * There is always one root in every node tree, added implicitly by Compose.
*/
fun isRoot() =
SemanticsMatcher("isRoot") { it.isRoot }
/**
- * Returns whether the component's parent satisfies the given matcher.
+ * Returns whether the node's parent satisfies the given matcher.
*
* Returns false if no parent exists.
*/
-fun hasParentThat(matcher: SemanticsMatcher): SemanticsMatcher {
+fun hasParent(matcher: SemanticsMatcher): SemanticsMatcher {
// TODO(b/150292800): If this is used in assert we should print the parent's node semantics
// in the error message or say that no parent was found.
return SemanticsMatcher("hasParentThat(${matcher.description})") {
@@ -296,9 +296,9 @@
}
/**
- * Returns whether the component has at least one child that satisfies the given matcher.
+ * Returns whether the node has at least one child that satisfies the given matcher.
*/
-fun hasAnyChildThat(matcher: SemanticsMatcher): SemanticsMatcher {
+fun hasAnyChild(matcher: SemanticsMatcher): SemanticsMatcher {
// TODO(b/150292800): If this is used in assert we should print the children nodes semantics
// in the error message or say that no children were found.
return SemanticsMatcher("hasAnyChildThat(${matcher.description})") {
@@ -307,11 +307,11 @@
}
/**
- * Returns whether the component has at least one sibling that satisfies the given matcher.
+ * Returns whether the node has at least one sibling that satisfies the given matcher.
*
* Sibling is defined as a any other node that shares the same parent.
*/
-fun hasAnySiblingThat(matcher: SemanticsMatcher): SemanticsMatcher {
+fun hasAnySibling(matcher: SemanticsMatcher): SemanticsMatcher {
// TODO(b/150292800): If this is used in assert we should print the sibling nodes semantics
// in the error message or say that no siblings were found.
return SemanticsMatcher("hasAnySiblingThat(${matcher.description})"
@@ -323,7 +323,7 @@
}
/**
- * Returns whether the component has at least one ancestor that satisfies the given matcher.
+ * Returns whether the node has at least one ancestor that satisfies the given matcher.
*
* Example: For the following tree
* |-X
@@ -333,7 +333,7 @@
* |-C2
* In case of C1, we would check the matcher against A and B
*/
-fun hasAnyAncestorThat(matcher: SemanticsMatcher): SemanticsMatcher {
+fun hasAnyAncestor(matcher: SemanticsMatcher): SemanticsMatcher {
// TODO(b/150292800): If this is used in assert we should print the ancestor nodes semantics
// in the error message or say that no ancestors were found.
return SemanticsMatcher("hasAnyAncestorThat(${matcher.description})") {
@@ -342,7 +342,7 @@
}
/**
- * Returns whether the component has at least one descendant that satisfies the given matcher.
+ * Returns whether the node has at least one descendant that satisfies the given matcher.
*
* Example: For the following tree
* |-X
@@ -352,7 +352,7 @@
* |-C2
* In case of A, we would check the matcher against B,C1 and C2
*/
-fun hasAnyDescendantThat(matcher: SemanticsMatcher): SemanticsMatcher {
+fun hasAnyDescendant(matcher: SemanticsMatcher): SemanticsMatcher {
// TODO(b/150292800): If this is used in assert we could consider printing the whole subtree but
// it might be too much to show. But we could at least warn if there were no ancestors found.
fun checkIfSubtreeMatches(matcher: SemanticsMatcher, node: SemanticsNode): Boolean {
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/Finders.kt b/ui/ui-test/src/main/java/androidx/ui/test/Finders.kt
index fd37af3..95650cb 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/Finders.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/Finders.kt
@@ -17,18 +17,170 @@
package androidx.ui.test
/**
+ * Finds a semantics node identified by the given tag.
+ *
+ * For usage patterns and semantics concepts see [SemanticsNodeInteraction]
+ *
+ * @param useUnmergedTree Find within merged composables like Buttons.
+ *
+ * @see onNode for general find method.
+ */
+fun onNodeWithTag(
+ testTag: String,
+ useUnmergedTree: Boolean = false
+): SemanticsNodeInteraction = onNode(hasTestTag(testTag), useUnmergedTree)
+
+/**
+ * Finds all semantics nodes identified by the given tag.
+ *
+ * For usage patterns and semantics concepts see [SemanticsNodeInteraction]
+ *
+ * @param useUnmergedTree Find within merged composables like Buttons.
+ *
+ * @see onAllNodes for general find method.
+ */
+fun onAllNodesWithTag(
+ testTag: String,
+ useUnmergedTree: Boolean = false
+): SemanticsNodeInteractionCollection = onAllNodes(hasTestTag(testTag), useUnmergedTree)
+
+/**
+ * Finds a semantics node with the given label as its accessibilityLabel.
+ *
+ * For usage patterns and semantics concepts see [SemanticsNodeInteraction]
+ *
+ * @param useUnmergedTree Find within merged composables like Buttons.
+ *
+ * @see onNode for general find method.
+ */
+fun onNodeWithLabel(
+ label: String,
+ ignoreCase: Boolean = false,
+ useUnmergedTree: Boolean = false
+): SemanticsNodeInteraction = onNode(hasLabel(label, ignoreCase), useUnmergedTree)
+
+/**
+ * Finds a semantincs node with the given text.
+ *
+ * For usage patterns and semantics concepts see [SemanticsNodeInteraction]
+ *
+ * @param useUnmergedTree Find within merged composables like Buttons.
+ * @see onNodeWithSubstring to search by substring instead of via exact match.
+ * @see onNode for general find method.
+ */
+fun onNodeWithText(
+ text: String,
+ ignoreCase: Boolean = false,
+ useUnmergedTree: Boolean = false
+): SemanticsNodeInteraction = onNode(hasText(text, ignoreCase), useUnmergedTree)
+
+/**
+ * Finds a semantics node with text that contains the given substring.
+ *
+ * For usage patterns and semantics concepts see [SemanticsNodeInteraction]
+ *
+ * @param useUnmergedTree Find within merged composables like Buttons.
+ * @see onNodeWithText to perform exact matches.
+ * @see onNode for general find method.
+ */
+fun onNodeWithSubstring(
+ text: String,
+ ignoreCase: Boolean = false,
+ useUnmergedTree: Boolean = false
+): SemanticsNodeInteraction = onNode(hasSubstring(text, ignoreCase), useUnmergedTree)
+
+/**
+ * Finds all semantics nodes with the given text.
+ *
+ * For usage patterns and semantics concepts see [SemanticsNodeInteraction]
+ *
+ * @param useUnmergedTree Find within merged composables like Buttons.
+ */
+fun onAllNodesWithText(
+ text: String,
+ ignoreCase: Boolean = false,
+ useUnmergedTree: Boolean = false
+): SemanticsNodeInteractionCollection = onAllNodes(hasText(text, ignoreCase), useUnmergedTree)
+
+/**
+ * Finds all semantics nodes with the given label as AccessibilityLabel.
+ *
+ * For usage patterns and semantics concepts see [SemanticsNodeInteraction]
+ *
+ * @param useUnmergedTree Find within merged composables like Buttons.
+ */
+fun onAllNodesWithLabel(
+ label: String,
+ ignoreCase: Boolean = false,
+ useUnmergedTree: Boolean = false
+): SemanticsNodeInteractionCollection = onAllNodes(hasLabel(label, ignoreCase), useUnmergedTree)
+
+/**
+ * Finds the root semantics node of the Compose tree.
+ *
+ * Useful for example for screenshot tests of the entire scene.
+ *
+ * For usage patterns and semantics concepts see [SemanticsNodeInteraction]
+ *
+ * @param useUnmergedTree Find within merged composables like Buttons.
+ */
+fun onRoot(useUnmergedTree: Boolean = false): SemanticsNodeInteraction =
+ onNode(isRoot(), useUnmergedTree)
+
+/**
+ * Finds a semantics node that matches the given condition.
+ *
+ * Any subsequent operation on its result will expect exactly one element found (unless
+ * [SemanticsNodeInteraction.assertDoesNotExist] is used) and will throw [AssertionError] if
+ * none or more than one element is found.
+ *
+ * For usage patterns and semantics concepts see [SemanticsNodeInteraction]
+ *
+ * @param useUnmergedTree Find within merged composables like Buttons.
+ * @see onAllNodes to work with multiple elements
+ */
+fun onNode(
+ matcher: SemanticsMatcher,
+ useUnmergedTree: Boolean = false
+): SemanticsNodeInteraction {
+ return SemanticsNodeInteraction(useUnmergedTree, SemanticsSelector(matcher))
+}
+
+/**
+ * Finds all semantics nodes that match the given condition.
+ *
+ * If you are working with elements that are not supposed to occur multiple times use [onNode]
+ * instead.
+ *
+ * For usage patterns and semantics concepts see [SemanticsNodeInteraction]
+ *
+ * @param useUnmergedTree Find within merged composables like Buttons.
+ * @see onNode
+ */
+fun onAllNodes(
+ matcher: SemanticsMatcher,
+ useUnmergedTree: Boolean = false
+): SemanticsNodeInteractionCollection {
+ return SemanticsNodeInteractionCollection(useUnmergedTree, SemanticsSelector(matcher))
+}
+
+// DEPRECATED APIs SECTION
+
+/**
* Finds a component identified by the given tag.
*
* For usage patterns and semantics concepts see [SemanticsNodeInteraction]
*
* @param useUnmergedTree Find within merged composables like Buttons.
*
- * @see find for general find method.
+ * @see onNode for general find method.
*/
+@Deprecated("Renamed to onNodeWithTag",
+ replaceWith = ReplaceWith("onNodeWithTag(testTag, useUnmergedTree)"))
fun findByTag(
testTag: String,
useUnmergedTree: Boolean = false
-): SemanticsNodeInteraction = find(hasTestTag(testTag), useUnmergedTree)
+): SemanticsNodeInteraction = onNodeWithTag(testTag, useUnmergedTree)
/**
* Finds all components identified by the given tag.
@@ -37,12 +189,14 @@
*
* @param useUnmergedTree Find within merged composables like Buttons.
*
- * @see findAll for general find method.
+ * @see onAllNodes for general find method.
*/
+@Deprecated("Renamed to onAllNodesWithTag",
+ replaceWith = ReplaceWith("onAllNodesWithTag(testTag, useUnmergedTree)"))
fun findAllByTag(
testTag: String,
useUnmergedTree: Boolean = false
-): SemanticsNodeInteractionCollection = findAll(hasTestTag(testTag), useUnmergedTree)
+): SemanticsNodeInteractionCollection = onAllNodesWithTag(testTag, useUnmergedTree)
/**
* Finds a component with the given label as its accessibilityLabel.
@@ -51,13 +205,15 @@
*
* @param useUnmergedTree Find within merged composables like Buttons.
*
- * @see find for general find method.
+ * @see onNode for general find method.
*/
+@Deprecated("Renamed to onNodeWithLabel",
+ replaceWith = ReplaceWith("onNodeWithLabel(label, ignoreCase, useUnmergedTree)"))
fun findByLabel(
label: String,
ignoreCase: Boolean = false,
useUnmergedTree: Boolean = false
-): SemanticsNodeInteraction = find(hasLabel(label, ignoreCase), useUnmergedTree)
+): SemanticsNodeInteraction = onNodeWithLabel(label, ignoreCase, useUnmergedTree)
/**
* Finds a component with the given text.
@@ -65,14 +221,16 @@
* For usage patterns and semantics concepts see [SemanticsNodeInteraction]
*
* @param useUnmergedTree Find within merged composables like Buttons.
- * @see findBySubstring to search by substring instead of via exact match.
- * @see find for general find method.
+ * @see onNodeWithSubstring to search by substring instead of via exact match.
+ * @see onNode for general find method.
*/
+@Deprecated("Renamed to onNodeWithText",
+ replaceWith = ReplaceWith("onNodeWithText(text, ignoreCase, useUnmergedTree)"))
fun findByText(
text: String,
ignoreCase: Boolean = false,
useUnmergedTree: Boolean = false
-): SemanticsNodeInteraction = find(hasText(text, ignoreCase), useUnmergedTree)
+): SemanticsNodeInteraction = onNodeWithText(text, ignoreCase, useUnmergedTree)
/**
* Finds a component with text that contains the given substring.
@@ -80,14 +238,16 @@
* For usage patterns and semantics concepts see [SemanticsNodeInteraction]
*
* @param useUnmergedTree Find within merged composables like Buttons.
- * @see findByText to perform exact matches.
- * @see find for general find method.
+ * @see onNodeWithText to perform exact matches.
+ * @see onNode for general find method.
*/
+@Deprecated("Renamed to onNodeWithSubstring",
+ replaceWith = ReplaceWith("onNodeWithSubstring(text, ignoreCase, useUnmergedTree)"))
fun findBySubstring(
text: String,
ignoreCase: Boolean = false,
useUnmergedTree: Boolean = false
-): SemanticsNodeInteraction = find(hasSubstring(text, ignoreCase), useUnmergedTree)
+): SemanticsNodeInteraction = onNodeWithSubstring(text, ignoreCase, useUnmergedTree)
/**
* Finds all components with the given text.
@@ -96,11 +256,13 @@
*
* @param useUnmergedTree Find within merged composables like Buttons.
*/
+@Deprecated("Renamed to onAllNodesWithText",
+ replaceWith = ReplaceWith("onAllNodesWithText(text, ignoreCase, useUnmergedTree)"))
fun findAllByText(
text: String,
ignoreCase: Boolean = false,
useUnmergedTree: Boolean = false
-): SemanticsNodeInteractionCollection = findAll(hasText(text, ignoreCase), useUnmergedTree)
+): SemanticsNodeInteractionCollection = onAllNodesWithText(text, ignoreCase, useUnmergedTree)
/**
* Finds all components with the given label as AccessibilityLabel.
@@ -109,11 +271,13 @@
*
* @param useUnmergedTree Find within merged composables like Buttons.
*/
+@Deprecated("Renamed to onAllNodesWithLabel",
+ replaceWith = ReplaceWith("onAllNodesWithLabel(label, ignoreCase, useUnmergedTree)"))
fun findAllByLabel(
label: String,
ignoreCase: Boolean = false,
useUnmergedTree: Boolean = false
-): SemanticsNodeInteractionCollection = findAll(hasLabel(label, ignoreCase), useUnmergedTree)
+): SemanticsNodeInteractionCollection = onAllNodesWithLabel(label, ignoreCase, useUnmergedTree)
/**
* Finds the root semantics node of the Compose tree. Useful for example for screenshot tests
@@ -123,8 +287,10 @@
*
* @param useUnmergedTree Find within merged composables like Buttons.
*/
+@Deprecated("Renamed to onRoot",
+ replaceWith = ReplaceWith("onRoot(useUnmergedTree)"))
fun findRoot(useUnmergedTree: Boolean = false): SemanticsNodeInteraction =
- find(isRoot(), useUnmergedTree)
+ onRoot(useUnmergedTree)
/**
* Finds a component that matches the given condition.
@@ -136,14 +302,14 @@
* For usage patterns and semantics concepts see [SemanticsNodeInteraction]
*
* @param useUnmergedTree Find within merged composables like Buttons.
- * @see findAll to work with multiple elements
+ * @see onAllNodes to work with multiple elements
*/
+@Deprecated("Renamed to onNode",
+ replaceWith = ReplaceWith("onNode(matcher, useUnmergedTree)"))
fun find(
matcher: SemanticsMatcher,
useUnmergedTree: Boolean = false
-): SemanticsNodeInteraction {
- return SemanticsNodeInteraction(useUnmergedTree, SemanticsSelector(matcher))
-}
+): SemanticsNodeInteraction = onNode(matcher, useUnmergedTree)
/**
* Finds all components that match the given condition.
@@ -154,11 +320,11 @@
* For usage patterns and semantics concepts see [SemanticsNodeInteraction]
*
* @param useUnmergedTree Find within merged composables like Buttons.
- * @see find
+ * @see onNode
*/
+@Deprecated("Renamed to onAllNodes",
+ replaceWith = ReplaceWith("onAllNodes(matcher, useUnmergedTree)"))
fun findAll(
matcher: SemanticsMatcher,
useUnmergedTree: Boolean = false
-): SemanticsNodeInteractionCollection {
- return SemanticsNodeInteractionCollection(useUnmergedTree, SemanticsSelector(matcher))
-}
+): SemanticsNodeInteractionCollection = onAllNodes(matcher, useUnmergedTree)
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 40f5775..560b917 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
@@ -78,7 +78,7 @@
}
/**
- * Returns the size of the component we're interacting with
+ * Returns the size of the node we're interacting with
*/
val BaseGestureScope.size: IntSize
get() = semanticsNode.size
@@ -96,38 +96,38 @@
get() = size.height
/**
- * Returns the x-coordinate for the left edge of the component we're interacting with, in the
- * component's local coordinate system, where (0, 0) is the top left corner of the component.
+ * Returns the x-coordinate for the left edge of the node we're interacting with, in the
+ * node's local coordinate system, where (0, 0) is the top left corner of the node.
*/
@Suppress("unused")
inline val BaseGestureScope.left: Float
get() = 0f
/**
- * Returns the y-coordinate for the bottom of the component we're interacting with, in the
- * component's local coordinate system, where (0, 0) is the top left corner of the component.
+ * Returns the y-coordinate for the bottom of the node we're interacting with, in the
+ * node's local coordinate system, where (0, 0) is the top left corner of the node.
*/
@Suppress("unused")
inline val BaseGestureScope.top: Float
get() = 0f
/**
- * Returns the x-coordinate for the center of the component we're interacting with, in the
- * component's local coordinate system, where (0, 0) is the top left corner of the component.
+ * Returns the x-coordinate for the center of the node we're interacting with, in the
+ * node's local coordinate system, where (0, 0) is the top left corner of the node.
*/
inline val BaseGestureScope.centerX: Float
get() = width / 2f
/**
- * Returns the y-coordinate for the center of the component we're interacting with, in the
- * component's local coordinate system, where (0, 0) is the top left corner of the component.
+ * Returns the y-coordinate for the center of the node we're interacting with, in the
+ * node's local coordinate system, where (0, 0) is the top left corner of the node.
*/
inline val BaseGestureScope.centerY: Float
get() = height / 2f
/**
- * Returns the x-coordinate for the right edge of the component we're interacting with, in the
- * component's local coordinate system, where (0, 0) is the top left corner of the component.
+ * Returns the x-coordinate for the right edge of the node we're interacting with, in the
+ * node's local coordinate system, where (0, 0) is the top left corner of the node.
* Note that, unless `width == 0`, `right != width`. In particular, `right == width - 1f`, because
* pixels are 0-based. If `width == 0`, `right == 0` too.
*/
@@ -135,8 +135,8 @@
get() = width.let { if (it == 0) 0f else it - 1f }
/**
- * Returns the y-coordinate for the bottom of the component we're interacting with, in the
- * component's local coordinate system, where (0, 0) is the top left corner of the component.
+ * Returns the y-coordinate for the bottom of the node we're interacting with, in the
+ * node's local coordinate system, where (0, 0) is the top left corner of the node.
* Note that, unless `height == 0`, `bottom != height`. In particular, `bottom == height - 1f`,
* because pixels are 0-based. If `height == 0`, `bottom == 0` too.
*/
@@ -144,76 +144,76 @@
get() = height.let { if (it == 0) 0f else it - 1f }
/**
- * Returns the top left corner of the component we're interacting with, in the component's
- * local coordinate system, where (0, 0) is the top left corner of the component.
+ * Returns the top left corner of the node we're interacting with, in the node's
+ * local coordinate system, where (0, 0) is the top left corner of the node.
*/
@Suppress("unused")
val BaseGestureScope.topLeft: Offset
get() = Offset(left, top)
/**
- * Returns the center of the top edge of the component we're interacting with, in the component's
- * local coordinate system, where (0, 0) is the top left corner of the component.
+ * Returns the center of the top edge of the node we're interacting with, in the node's
+ * local coordinate system, where (0, 0) is the top left corner of the node.
*/
val BaseGestureScope.topCenter: Offset
get() = Offset(centerX, top)
/**
- * Returns the top right corner of the component we're interacting with, in the component's
- * local coordinate system, where (0, 0) is the top left corner of the component. Note that
+ * Returns the top right corner of the node we're interacting with, in the node's
+ * local coordinate system, where (0, 0) is the top left corner of the node. Note that
* `topRight.x != width`, see [right].
*/
val BaseGestureScope.topRight: Offset
get() = Offset(right, top)
/**
- * Returns the center of the left edge of the component we're interacting with, in the
- * component's local coordinate system, where (0, 0) is the top left corner of the component.
+ * Returns the center of the left edge of the node we're interacting with, in the
+ * node's local coordinate system, where (0, 0) is the top left corner of the node.
*/
val BaseGestureScope.centerLeft: Offset
get() = Offset(left, centerY)
/**
- * Returns the center of the component we're interacting with, in the component's
- * local coordinate system, where (0, 0) is the top left corner of the component.
+ * Returns the center of the node we're interacting with, in the node's
+ * local coordinate system, where (0, 0) is the top left corner of the node.
*/
val BaseGestureScope.center: Offset
get() = Offset(centerX, centerY)
/**
- * Returns the center of the right edge of the component we're interacting with, in the
- * component's local coordinate system, where (0, 0) is the top left corner of the component.
+ * Returns the center of the right edge of the node we're interacting with, in the
+ * node's local coordinate system, where (0, 0) is the top left corner of the node.
* Note that `centerRight.x != width`, see [right].
*/
val BaseGestureScope.centerRight: Offset
get() = Offset(right, centerY)
/**
- * Returns the bottom left corner of the component we're interacting with, in the component's
- * local coordinate system, where (0, 0) is the top left corner of the component. Note that
+ * Returns the bottom left corner of the node we're interacting with, in the node's
+ * local coordinate system, where (0, 0) is the top left corner of the node. Note that
* `bottomLeft.y != height`, see [bottom].
*/
val BaseGestureScope.bottomLeft: Offset
get() = Offset(left, bottom)
/**
- * Returns the center of the bottom edge of the component we're interacting with, in the component's
- * local coordinate system, where (0, 0) is the top left corner of the component. Note that
+ * Returns the center of the bottom edge of the node we're interacting with, in the node's
+ * local coordinate system, where (0, 0) is the top left corner of the node. Note that
* `bottomCenter.y != height`, see [bottom].
*/
val BaseGestureScope.bottomCenter: Offset
get() = Offset(centerX, bottom)
/**
- * Returns the bottom right corner of the component we're interacting with, in the component's
- * local coordinate system, where (0, 0) is the top left corner of the component. Note that
+ * Returns the bottom right corner of the node we're interacting with, in the node's
+ * local coordinate system, where (0, 0) is the top left corner of the node. Note that
* `bottomRight.x != width` and `bottomRight.y != height`, see [right] and [bottom].
*/
val BaseGestureScope.bottomRight: Offset
get() = Offset(right, bottom)
/**
- * Creates an [Offset] relative to the size of the component we're interacting with. [x] and [y]
+ * Creates an [Offset] relative to the size of the node we're interacting with. [x] and [y]
* are fractions of the [width] and [height]. Note that `percentOffset(1f, 1f) != bottomRight`,
* see [right] and [bottom].
*
@@ -230,7 +230,7 @@
}
/**
- * Returns the global bounds of the component we're interacting with
+ * Returns the global bounds of the node we're interacting with
*/
val BaseGestureScope.globalBounds: PxBounds
get() = semanticsNode.globalBounds
@@ -248,13 +248,13 @@
/**
* The receiver scope for injecting gestures on the [semanticsNode] identified by the
* corresponding [SemanticsNodeInteraction]. Gestures can be injected by calling methods defined
- * on [GestureScope], such as [sendSwipeUp]. The [SemanticsNodeInteraction] can be found by one
- * of the finder methods such as [findByTag].
+ * on [GestureScope], such as [swipeUp]. The [SemanticsNodeInteraction] can be found by one
+ * of the finder methods such as [onNodeWithTag].
*
* Example usage:
* ```
- * findByTag("myWidget")
- * .doGesture {
+ * onNodeWithTag("myWidget")
+ * .performGesture {
* sendSwipeUp()
* }
* ```
@@ -264,50 +264,50 @@
) : BaseGestureScope(semanticsNode)
/**
- * Performs a click gesture at the given [position] on the associated component, or in the center
- * if the [position] is omitted. The [position] is in the component's local coordinate system,
- * where (0, 0) is the top left corner of the component. The default [position] is the
- * center of the component.
+ * Performs a click gesture at the given [position] on the associated node, or in the center
+ * if the [position] is omitted. The [position] is in the node's local coordinate system,
+ * where (0, 0) is the top left corner of the node. The default [position] is the
+ * center of the node.
*
- * @param position The position where to click, in the component's local coordinate system. If
+ * @param position The position where to click, in the node's local coordinate system. If
* omitted, the center position will be used.
*/
-fun GestureScope.sendClick(position: Offset = center) {
+fun GestureScope.click(position: Offset = center) {
inputDispatcher.sendClick(localToGlobal(position))
}
/**
- * Performs a long click gesture at the given [position] on the associated component, or in the
+ * Performs a long click gesture at the given [position] on the associated node, or in the
* center if the [position] is omitted. By default, the [duration] of the press is
- * [LongPressTimeout] + 100 milliseconds. The [position] is in the component's local coordinate
- * system, where (0, 0) is the top left corner of the component.
+ * [LongPressTimeout] + 100 milliseconds. The [position] is in the node's local coordinate
+ * system, where (0, 0) is the top left corner of the node.
*
- * @param position The position of the long click, in the component's local coordinate system. If
+ * @param position The position of the long click, in the node's local coordinate system. If
* omitted, the center position will be used.
* @param duration The time between the down and the up event
*/
-fun GestureScope.sendLongClick(
+fun GestureScope.longClick(
position: Offset = center,
duration: Duration = LongPressTimeout + 100.milliseconds
) {
require(duration >= LongPressTimeout) {
"Long click must have a duration of at least ${LongPressTimeout.inMilliseconds()}ms"
}
- sendSwipe(position, position, duration)
+ swipe(position, position, duration)
}
/**
- * Performs a double click gesture at the given [position] on the associated component, or in the
+ * Performs a double click gesture at the given [position] on the associated node, or in the
* center if the [position] is omitted. By default, the [delay] between the first and the second
- * click is 145 milliseconds (empirically established). The [position] is in the component's
- * local coordinate system, where (0, 0) is the top left corner of the component.
+ * click is 145 milliseconds (empirically established). The [position] is in the node's
+ * local coordinate system, where (0, 0) is the top left corner of the node.
*
- * @param position The position of the double click, in the component's local coordinate system.
+ * @param position The position of the double click, in the node's local coordinate system.
* If omitted, the center position will be used.
* @param delay The time between the up event of the first click and the down event of the second
* click
*/
-fun GestureScope.sendDoubleClick(
+fun GestureScope.doubleClick(
position: Offset = center,
delay: Duration = doubleClickDelay
) {
@@ -321,16 +321,16 @@
}
/**
- * Performs the swipe gesture on the associated component. The motion events are linearly
- * interpolated between [start] and [end]. The coordinates are in the component's local
- * coordinate system, where (0, 0) is the top left corner of the component. The default
+ * Performs the swipe gesture on the associated node. The motion events are linearly
+ * interpolated between [start] and [end]. The coordinates are in the node's local
+ * coordinate system, where (0, 0) is the top left corner of the node. The default
* duration is 200 milliseconds.
*
- * @param start The start position of the gesture, in the component's local coordinate system
- * @param end The end position of the gesture, in the component's local coordinate system
+ * @param start The start position of the gesture, in the node's local coordinate system
+ * @param end The end position of the gesture, in the node's local coordinate system
* @param duration The duration of the gesture
*/
-fun GestureScope.sendSwipe(
+fun GestureScope.swipe(
start: Offset,
end: Offset,
duration: Duration = 200.milliseconds
@@ -341,19 +341,19 @@
}
/**
- * Performs a pinch gesture on the associated component.
+ * Performs a pinch gesture on the associated node.
*
* For each pair of start and end [Offset]s, the motion events are linearly interpolated. The
- * coordinates are in the component's local coordinate system where (0, 0) is the top left
- * corner of the component. The default duration is 400 milliseconds.
+ * coordinates are in the node's local coordinate system where (0, 0) is the top left
+ * corner of the node. The default duration is 400 milliseconds.
*
- * @param start0 The start position of the first gesture in the component's local coordinate system
- * @param end0 The end position of the first gesture in the component's local coordinate system
- * @param start1 The start position of the second gesture in the component's local coordinate system
- * @param end1 The end position of the second gesture in the component's local coordinate system
+ * @param start0 The start position of the first gesture in the node's local coordinate system
+ * @param end0 The end position of the first gesture in the node's local coordinate system
+ * @param start1 The start position of the second gesture in the node's local coordinate system
+ * @param end1 The end position of the second gesture in the node's local coordinate system
* @param duration the duration of the gesture
*/
-fun GestureScope.sendPinch(
+fun GestureScope.pinch(
start0: Offset,
end0: Offset,
start1: Offset,
@@ -376,22 +376,22 @@
}
/**
- * Performs the swipe gesture on the associated component, such that the velocity when the
+ * Performs the swipe gesture on the associated node, such that the velocity when the
* gesture is finished is roughly equal to [endVelocity]. The MotionEvents are linearly
- * interpolated between [start] and [end]. The coordinates are in the component's
- * local coordinate system, where (0, 0) is the top left corner of the component. The
+ * interpolated between [start] and [end]. The coordinates are in the node's
+ * local coordinate system, where (0, 0) is the top left corner of the node. The
* default duration is 200 milliseconds.
*
* Note that due to imprecisions, no guarantees can be made on the precision of the actual
* velocity at the end of the gesture, but generally it is within 0.1% of the desired velocity.
*
- * @param start The start position of the gesture, in the component's local coordinate system
- * @param end The end position of the gesture, in the component's local coordinate system
+ * @param start The start position of the gesture, in the node's local coordinate system
+ * @param end The end position of the gesture, in the node's local coordinate system
* @param endVelocity The velocity of the gesture at the moment it ends. Must be positive.
* @param duration The duration of the gesture. Must be long enough that at least 3 input events
* are generated, which happens with a duration of 25ms or more.
*/
-fun GestureScope.sendSwipeWithVelocity(
+fun GestureScope.swipeWithVelocity(
start: Offset,
end: Offset,
@FloatRange(from = 0.0) endVelocity: Float,
@@ -436,55 +436,55 @@
}
/**
- * Performs a swipe up gesture on the associated component. The gesture starts slightly above the
- * bottom of the component and ends at the top.
+ * Performs a swipe up gesture on the associated node. The gesture starts slightly above the
+ * bottom of the node and ends at the top.
*/
-fun GestureScope.sendSwipeUp() {
+fun GestureScope.swipeUp() {
val x = center.x
val y0 = (size.height * (1 - edgeFuzzFactor)).roundToInt().toFloat()
val y1 = 0.0f
val start = Offset(x, y0)
val end = Offset(x, y1)
- sendSwipe(start, end, 200.milliseconds)
+ swipe(start, end, 200.milliseconds)
}
/**
- * Performs a swipe down gesture on the associated component. The gesture starts slightly below the
- * top of the component and ends at the bottom.
+ * Performs a swipe down gesture on the associated node. The gesture starts slightly below the
+ * top of the node and ends at the bottom.
*/
-fun GestureScope.sendSwipeDown() {
+fun GestureScope.swipeDown() {
val x = center.x
val y0 = (size.height * edgeFuzzFactor).roundToInt().toFloat()
val y1 = size.height.toFloat()
val start = Offset(x, y0)
val end = Offset(x, y1)
- sendSwipe(start, end, 200.milliseconds)
+ swipe(start, end, 200.milliseconds)
}
/**
- * Performs a swipe left gesture on the associated component. The gesture starts slightly left of
- * the right side of the component and ends at the left side.
+ * Performs a swipe left gesture on the associated node. The gesture starts slightly left of
+ * the right side of the node and ends at the left side.
*/
-fun GestureScope.sendSwipeLeft() {
+fun GestureScope.swipeLeft() {
val x0 = (size.width * (1 - edgeFuzzFactor)).toFloat()
val x1 = 0.0f
val y = center.y
val start = Offset(x0, y)
val end = Offset(x1, y)
- sendSwipe(start, end, 200.milliseconds)
+ swipe(start, end, 200.milliseconds)
}
/**
- * Performs a swipe right gesture on the associated component. The gesture starts slightly right of
- * the left side of the component and ends at the right side.
+ * Performs a swipe right gesture on the associated node. The gesture starts slightly right of
+ * the left side of the node and ends at the right side.
*/
-fun GestureScope.sendSwipeRight() {
+fun GestureScope.swipeRight() {
val x0 = (size.width * edgeFuzzFactor).roundToInt().toFloat()
val x1 = size.width.toFloat()
val y = center.y
val start = Offset(x0, y)
val end = Offset(x1, y)
- sendSwipe(start, end, 200.milliseconds)
+ swipe(start, end, 200.milliseconds)
}
/**
@@ -552,16 +552,16 @@
/**
* The receiver scope for injecting partial gestures on the [semanticsNode] identified by the
* corresponding [SemanticsNodeInteraction]. Gestures can be injected by calling methods defined
- * on [PartialGestureScope], such as [sendDown]. The [SemanticsNodeInteraction] can be found by
- * one of the finder methods such as [findByTag].
+ * on [PartialGestureScope], such as [down]. The [SemanticsNodeInteraction] can be found by
+ * one of the finder methods such as [onNodeWithTag].
*
* Example usage:
* ```
* val position = Offset(10.px, 10.px)
- * findByTag("myWidget")
- * .doPartialGesture { sendDown(position) }
+ * onNodeWithTag("myWidget")
+ * .performPartialGesture { sendDown(position) }
* .assertIsDisplayed()
- * .doPartialGesture { sendUp(position) }
+ * .performPartialGesture { sendUp(position) }
* ```
*/
class PartialGestureScope internal constructor(
@@ -570,20 +570,20 @@
/**
* Sends a down event for the pointer with the given [pointerId] at [position] on the associated
- * component. The [position] is in the component's local coordinate system, where (0, 0) is
- * the top left corner of the component.
+ * node. The [position] is in the node's local coordinate system, where (0, 0) is
+ * the top left corner of the node.
*
* If no pointers are down yet, this will start a new partial gesture. If a partial gesture is
* already in progress, this event is sent with at the same timestamp as the last event. If the
* given pointer is already down, an [IllegalArgumentException] will be thrown.
*
* This gesture is considered _partial_, because the entire gesture can be spread over several
- * invocations of [doPartialGesture]. An entire gesture starts with a [down][sendDown] event,
- * followed by several down, move or up events, and ends with an [up][sendUp] or a
- * [cancel][sendCancel] event. Movement can be expressed with [sendMoveTo] and [sendMoveBy] to
+ * invocations of [performPartialGesture]. An entire gesture starts with a [down][down] event,
+ * followed by several down, move or up events, and ends with an [up][up] or a
+ * [cancel][cancel] event. Movement can be expressed with [moveTo] and [moveBy] to
* move a single pointer at a time, or [movePointerTo] and [movePointerBy] to move multiple
* pointers at a time. The `movePointer[To|By]` methods do not send the move event directly, use
- * [sendMove] to send the move event. Some other methods can send a move event as well. All
+ * [move] to send the move event. Some other methods can send a move event as well. All
* events, regardless the method used, will always contain the current position of _all_ pointers.
*
* Down and up events are sent at the same time as the previous event, but will send an extra
@@ -592,7 +592,7 @@
* cancel event will contain the up to date position of all pointers. Move and cancel events will
* advance the event time by 10 milliseconds.
*
- * Because partial gestures don't have to be defined all in the same [doPartialGesture] block,
+ * Because partial gestures don't have to be defined all in the same [performPartialGesture] block,
* keep in mind that while the gesture is not complete, all code you execute in between
* blocks that progress the gesture, will be executed while imaginary fingers are actively
* touching the screen.
@@ -601,66 +601,66 @@
* event, if the test ends before it expects the finger to be lifted from the screen.
*
* @param pointerId The id of the pointer, can be any number not yet in use by another pointer
- * @param position The position of the down event, in the component's local coordinate system
+ * @param position The position of the down event, in the node's local coordinate system
*/
-fun PartialGestureScope.sendDown(pointerId: Int, position: Offset) {
+fun PartialGestureScope.down(pointerId: Int, position: Offset) {
val globalPosition = localToGlobal(position)
inputDispatcher.sendDown(pointerId, globalPosition)
}
/**
- * Sends a down event for the default pointer at [position] on the associated component. The
- * [position] is in the component's local coordinate system, where (0, 0) is the top left
- * corner of the component. The default pointer has `pointerId = 0`.
+ * Sends a down event for the default pointer at [position] on the associated node. The
+ * [position] is in the node's local coordinate system, where (0, 0) is the top left
+ * corner of the node. The default pointer has `pointerId = 0`.
*
* If no pointers are down yet, this will start a new partial gesture. If a partial gesture is
* already in progress, this event is sent with at the same timestamp as the last event. If the
* default pointer is already down, an [IllegalArgumentException] will be thrown.
*
- * @param position The position of the down event, in the component's local coordinate system
+ * @param position The position of the down event, in the node's local coordinate system
*/
-fun PartialGestureScope.sendDown(position: Offset) {
- sendDown(0, position)
+fun PartialGestureScope.down(position: Offset) {
+ down(0, position)
}
/**
- * Sends a move event on the associated component, with the position of the pointer with the
- * given [pointerId] updated to [position]. The [position] is in the component's local coordinate
- * system, where (0, 0) is the top left corner of the component.
+ * Sends a move event on the associated node, with the position of the pointer with the
+ * given [pointerId] updated to [position]. The [position] is in the node's local coordinate
+ * system, where (0, 0) is the top left corner of the node.
*
* If the pointer is not yet down, an [IllegalArgumentException] will be thrown.
*
- * @param pointerId The id of the pointer to move, as supplied in [sendDown]
- * @param position The new position of the pointer, in the component's local coordinate system
+ * @param pointerId The id of the pointer to move, as supplied in [down]
+ * @param position The new position of the pointer, in the node's local coordinate system
*/
-fun PartialGestureScope.sendMoveTo(pointerId: Int, position: Offset) {
+fun PartialGestureScope.moveTo(pointerId: Int, position: Offset) {
movePointerTo(pointerId, position)
- sendMove()
+ move()
}
/**
- * Sends a move event on the associated component, with the position of the default pointer
- * updated to [position]. The [position] is in the component's local coordinate system, where
- * (0, 0) is the top left corner of the component. The default pointer has `pointerId = 0`.
+ * Sends a move event on the associated node, with the position of the default pointer
+ * updated to [position]. The [position] is in the node's local coordinate system, where
+ * (0, 0) is the top left corner of the node. The default pointer has `pointerId = 0`.
*
* If the default pointer is not yet down, an [IllegalArgumentException] will be thrown.
*
- * @param position The new position of the pointer, in the component's local coordinate system
+ * @param position The new position of the pointer, in the node's local coordinate system
*/
-fun PartialGestureScope.sendMoveTo(position: Offset) {
- sendMoveTo(0, position)
+fun PartialGestureScope.moveTo(position: Offset) {
+ moveTo(0, position)
}
/**
* Updates the position of the pointer with the given [pointerId] to the given [position], but
- * does not send a move event. The move event can be sent with [sendMove]. The [position] is in
- * the component's local coordinate system, where (0.px, 0.px) is the top left corner of the
- * component.
+ * does not send a move event. The move event can be sent with [move]. The [position] is in
+ * the node's local coordinate system, where (0.px, 0.px) is the top left corner of the
+ * node.
*
* If the pointer is not yet down, an [IllegalArgumentException] will be thrown.
*
- * @param pointerId The id of the pointer to move, as supplied in [sendDown]
- * @param position The new position of the pointer, in the component's local coordinate system
+ * @param pointerId The id of the pointer to move, as supplied in [down]
+ * @param position The new position of the pointer, in the node's local coordinate system
*/
fun PartialGestureScope.movePointerTo(pointerId: Int, position: Offset) {
val globalPosition = localToGlobal(position)
@@ -668,23 +668,23 @@
}
/**
- * Sends a move event on the associated component, with the position of the pointer with the
+ * Sends a move event on the associated node, with the position of the pointer with the
* given [pointerId] moved by the given [delta].
*
* If the pointer is not yet down, an [IllegalArgumentException] will be thrown.
*
- * @param pointerId The id of the pointer to move, as supplied in [sendDown]
+ * @param pointerId The id of the pointer to move, as supplied in [down]
* @param delta The position for this move event, relative to the last sent position of the
* pointer. For example, `delta = Offset(10.px, -10.px) will add 10.px to the pointer's last
* x-position, and subtract 10.px from the pointer's last y-position.
*/
-fun PartialGestureScope.sendMoveBy(pointerId: Int, delta: Offset) {
+fun PartialGestureScope.moveBy(pointerId: Int, delta: Offset) {
movePointerBy(pointerId, delta)
- sendMove()
+ move()
}
/**
- * Sends a move event on the associated component, with the position of the default pointer
+ * Sends a move event on the associated node, with the position of the default pointer
* moved by the given [delta]. The default pointer has `pointerId = 0`.
*
* If the pointer is not yet down, an [IllegalArgumentException] will be thrown.
@@ -693,17 +693,17 @@
* pointer. For example, `delta = Offset(10.px, -10.px) will add 10.px to the pointer's last
* x-position, and subtract 10.px from the pointer's last y-position.
*/
-fun PartialGestureScope.sendMoveBy(delta: Offset) {
- sendMoveBy(0, delta)
+fun PartialGestureScope.moveBy(delta: Offset) {
+ moveBy(0, delta)
}
/**
* Moves the position of the pointer with the given [pointerId] by the given [delta], but does
- * not send a move event. The move event can be sent with [sendMove].
+ * not send a move event. The move event can be sent with [move].
*
* If the pointer is not yet down, an [IllegalArgumentException] will be thrown.
*
- * @param pointerId The id of the pointer to move, as supplied in [sendDown]
+ * @param pointerId The id of the pointer to move, as supplied in [down]
* @param delta The position for this move event, relative to the last sent position of the
* pointer. For example, `delta = Offset(10.px, -10.px) will add 10.px to the pointer's last
* x-position, and subtract 10.px from the pointer's last y-position.
@@ -720,26 +720,313 @@
* batching movement of multiple pointers together, which can be done with [movePointerTo] and
* [movePointerBy].
*/
-fun PartialGestureScope.sendMove() {
+fun PartialGestureScope.move() {
inputDispatcher.sendMove()
}
/**
* Sends an up event for the pointer with the given [pointerId], or the default pointer if
+ * [pointerId] is omitted, on the associated node. If any pointers have been moved with
+ * [movePointerTo] or [movePointerBy] and no move event has been sent yet, a move event will be
+ * sent right before the up event.
+ *
+ * @param pointerId The id of the pointer to lift up, as supplied in [down]
+ */
+fun PartialGestureScope.up(pointerId: Int = 0) {
+ inputDispatcher.sendUp(pointerId)
+}
+
+/**
+ * Sends a cancel event to cancel the current partial gesture. The cancel event contains the
+ * current position of all active pointers.
+ */
+fun PartialGestureScope.cancel() {
+ inputDispatcher.sendCancel()
+}
+
+// DEPRECATED APIs SECTION
+
+/**
+ * Performs a click gesture at the given [position] on the associated component, or in the center
+ * if the [position] is omitted. The [position] is in the component's local coordinate system,
+ * where (0, 0) is the top left corner of the component. The default [position] is the
+ * center of the component.
+ *
+ * @param position The position where to click, in the component's local coordinate system. If
+ * omitted, the center position will be used.
+ */
+@Deprecated("Renamed to click",
+ replaceWith = ReplaceWith("click(position)"))
+fun GestureScope.sendClick(position: Offset = center) = click(position)
+
+/**
+ * Performs a long click gesture at the given [position] on the associated component, or in the
+ * center if the [position] is omitted. By default, the [duration] of the press is
+ * [LongPressTimeout] + 100 milliseconds. The [position] is in the component's local coordinate
+ * system, where (0, 0) is the top left corner of the component.
+ *
+ * @param position The position of the long click, in the component's local coordinate system. If
+ * omitted, the center position will be used.
+ * @param duration The time between the down and the up event
+ */
+@Deprecated("Renamed to longClick",
+ replaceWith = ReplaceWith("longClick(position, duration)"))
+fun GestureScope.sendLongClick(
+ position: Offset = center,
+ duration: Duration = LongPressTimeout + 100.milliseconds
+) = longClick(position, duration)
+
+/**
+ * Performs a double click gesture at the given [position] on the associated component, or in the
+ * center if the [position] is omitted. By default, the [delay] between the first and the second
+ * click is 145 milliseconds (empirically established). The [position] is in the component's
+ * local coordinate system, where (0, 0) is the top left corner of the component.
+ *
+ * @param position The position of the double click, in the component's local coordinate system.
+ * If omitted, the center position will be used.
+ * @param delay The time between the up event of the first click and the down event of the second
+ * click
+ */
+@Deprecated("Renamed to doubleClick",
+ replaceWith = ReplaceWith("doubleClick(position, delay)"))
+fun GestureScope.sendDoubleClick(
+ position: Offset = center,
+ delay: Duration = doubleClickDelay
+) = doubleClick(position, delay)
+
+/**
+ * Performs the swipe gesture on the associated component. The motion events are linearly
+ * interpolated between [start] and [end]. The coordinates are in the component's local
+ * coordinate system, where (0, 0) is the top left corner of the component. The default
+ * duration is 200 milliseconds.
+ *
+ * @param start The start position of the gesture, in the component's local coordinate system
+ * @param end The end position of the gesture, in the component's local coordinate system
+ * @param duration The duration of the gesture
+ */
+@Deprecated("Renamed to swipe",
+ replaceWith = ReplaceWith("swipe(start, end, duration)"))
+fun GestureScope.sendSwipe(
+ start: Offset,
+ end: Offset,
+ duration: Duration = 200.milliseconds
+) = swipe(start, end, duration)
+
+/**
+ * Performs a pinch gesture on the associated component.
+ *
+ * For each pair of start and end [Offset]s, the motion events are linearly interpolated. The
+ * coordinates are in the component's local coordinate system where (0, 0) is the top left
+ * corner of the component. The default duration is 400 milliseconds.
+ *
+ * @param start0 The start position of the first gesture in the component's local coordinate system
+ * @param end0 The end position of the first gesture in the component's local coordinate system
+ * @param start1 The start position of the second gesture in the component's local coordinate system
+ * @param end1 The end position of the second gesture in the component's local coordinate system
+ * @param duration the duration of the gesture
+ */
+@Deprecated("Renamed to pinch",
+ replaceWith = ReplaceWith("pinch(start0, end0, start1, end0, duration)"))
+fun GestureScope.sendPinch(
+ start0: Offset,
+ end0: Offset,
+ start1: Offset,
+ end1: Offset,
+ duration: Duration = 400.milliseconds
+) = pinch(start0, end0, start1, end1, duration)
+
+/**
+ * Performs the swipe gesture on the associated component, such that the velocity when the
+ * gesture is finished is roughly equal to [endVelocity]. The MotionEvents are linearly
+ * interpolated between [start] and [end]. The coordinates are in the component's
+ * local coordinate system, where (0, 0) is the top left corner of the component. The
+ * default duration is 200 milliseconds.
+ *
+ * Note that due to imprecisions, no guarantees can be made on the precision of the actual
+ * velocity at the end of the gesture, but generally it is within 0.1% of the desired velocity.
+ *
+ * @param start The start position of the gesture, in the component's local coordinate system
+ * @param end The end position of the gesture, in the component's local coordinate system
+ * @param endVelocity The velocity of the gesture at the moment it ends. Must be positive.
+ * @param duration The duration of the gesture. Must be long enough that at least 3 input events
+ * are generated, which happens with a duration of 25ms or more.
+ */
+@Deprecated("Renamed to swipeWithVelocity",
+ replaceWith = ReplaceWith("swipeWithVelocity(start, end, endVelocity, duration)"))
+fun GestureScope.sendSwipeWithVelocity(
+ start: Offset,
+ end: Offset,
+ @FloatRange(from = 0.0) endVelocity: Float,
+ duration: Duration = 200.milliseconds
+) = swipeWithVelocity(start, end, endVelocity, duration)
+
+/**
+ * Performs a swipe up gesture on the associated component. The gesture starts slightly above the
+ * bottom of the component and ends at the top.
+ */
+@Deprecated("Renamed to swipeUp",
+ replaceWith = ReplaceWith("swipeUp()"))
+fun GestureScope.sendSwipeUp() = swipeUp()
+
+/**
+ * Performs a swipe down gesture on the associated component. The gesture starts slightly below the
+ * top of the component and ends at the bottom.
+ */
+@Deprecated("Renamed to swipeDown",
+ replaceWith = ReplaceWith("swipeDown()"))
+fun GestureScope.sendSwipeDown() = swipeDown()
+
+/**
+ * Performs a swipe left gesture on the associated component. The gesture starts slightly left of
+ * the right side of the component and ends at the left side.
+ */
+@Deprecated("Renamed to swipeLeft",
+ replaceWith = ReplaceWith("swipeLeft()"))
+fun GestureScope.sendSwipeLeft() = swipeLeft()
+
+/**
+ * Performs a swipe right gesture on the associated component. The gesture starts slightly right of
+ * the left side of the component and ends at the right side.
+ */
+@Deprecated("Renamed to swipeRight",
+ replaceWith = ReplaceWith("swipeRight()"))
+fun GestureScope.sendSwipeRight() = swipeRight()
+
+/**
+ * Sends a down event for the pointer with the given [pointerId] at [position] on the associated
+ * component. The [position] is in the component's local coordinate system, where (0, 0) is
+ * the top left corner of the component.
+ *
+ * If no pointers are down yet, this will start a new partial gesture. If a partial gesture is
+ * already in progress, this event is sent with at the same timestamp as the last event. If the
+ * given pointer is already down, an [IllegalArgumentException] will be thrown.
+ *
+ * This gesture is considered _partial_, because the entire gesture can be spread over several
+ * invocations of [performPartialGesture]. An entire gesture starts with a [down][sendDown] event,
+ * followed by several down, move or up events, and ends with an [up][sendUp] or a
+ * [cancel][sendCancel] event. Movement can be expressed with [sendMoveTo] and [sendMoveBy] to
+ * move a single pointer at a time, or [movePointerTo] and [movePointerBy] to move multiple
+ * pointers at a time. The `movePointer[To|By]` methods do not send the move event directly, use
+ * [sendMove] to send the move event. Some other methods can send a move event as well. All
+ * events, regardless the method used, will always contain the current position of _all_ pointers.
+ *
+ * Down and up events are sent at the same time as the previous event, but will send an extra
+ * move event just before the down or up event if [movePointerTo] or [movePointerBy] has been
+ * called and no move event has been sent yet. This does not happen for cancel events, but the
+ * cancel event will contain the up to date position of all pointers. Move and cancel events will
+ * advance the event time by 10 milliseconds.
+ *
+ * Because partial gestures don't have to be defined all in the same [performPartialGesture] block,
+ * keep in mind that while the gesture is not complete, all code you execute in between
+ * blocks that progress the gesture, will be executed while imaginary fingers are actively
+ * touching the screen.
+ *
+ * In the context of testing, it is not necessary to complete a gesture with an up or cancel
+ * event, if the test ends before it expects the finger to be lifted from the screen.
+ *
+ * @param pointerId The id of the pointer, can be any number not yet in use by another pointer
+ * @param position The position of the down event, in the component's local coordinate system
+ */
+@Deprecated("Renamed to down",
+ replaceWith = ReplaceWith("down(pointerId, position)"))
+fun PartialGestureScope.sendDown(pointerId: Int, position: Offset) = down(pointerId, position)
+
+/**
+ * Sends a down event for the default pointer at [position] on the associated component. The
+ * [position] is in the component's local coordinate system, where (0, 0) is the top left
+ * corner of the component. The default pointer has `pointerId = 0`.
+ *
+ * If no pointers are down yet, this will start a new partial gesture. If a partial gesture is
+ * already in progress, this event is sent with at the same timestamp as the last event. If the
+ * default pointer is already down, an [IllegalArgumentException] will be thrown.
+ *
+ * @param position The position of the down event, in the component's local coordinate system
+ */
+@Deprecated("Renamed to down",
+ replaceWith = ReplaceWith("down(position)"))
+fun PartialGestureScope.sendDown(position: Offset) = down(position)
+
+/**
+ * Sends a move event on the associated component, with the position of the pointer with the
+ * given [pointerId] updated to [position]. The [position] is in the component's local coordinate
+ * system, where (0, 0) is the top left corner of the component.
+ *
+ * If the pointer is not yet down, an [IllegalArgumentException] will be thrown.
+ *
+ * @param pointerId The id of the pointer to move, as supplied in [sendDown]
+ * @param position The new position of the pointer, in the component's local coordinate system
+ */
+@Deprecated("Renamed to moveTo",
+ replaceWith = ReplaceWith("moveTo(pointerId, position)"))
+fun PartialGestureScope.sendMoveTo(pointerId: Int, position: Offset) = moveTo(pointerId, position)
+
+/**
+ * Sends a move event on the associated component, with the position of the default pointer
+ * updated to [position]. The [position] is in the component's local coordinate system, where
+ * (0, 0) is the top left corner of the component. The default pointer has `pointerId = 0`.
+ *
+ * If the default pointer is not yet down, an [IllegalArgumentException] will be thrown.
+ *
+ * @param position The new position of the pointer, in the component's local coordinate system
+ */
+@Deprecated("Renamed to moveTo",
+ replaceWith = ReplaceWith("moveTo(position)"))
+fun PartialGestureScope.sendMoveTo(position: Offset) = moveTo(position)
+
+/**
+ * Sends a move event on the associated component, with the position of the pointer with the
+ * given [pointerId] moved by the given [delta].
+ *
+ * If the pointer is not yet down, an [IllegalArgumentException] will be thrown.
+ *
+ * @param pointerId The id of the pointer to move, as supplied in [sendDown]
+ * @param delta The position for this move event, relative to the last sent position of the
+ * pointer. For example, `delta = Offset(10.px, -10.px) will add 10.px to the pointer's last
+ * x-position, and subtract 10.px from the pointer's last y-position.
+ */
+@Deprecated("Renamed to moveBy",
+ replaceWith = ReplaceWith("moveBy(pointerId, delta)"))
+fun PartialGestureScope.sendMoveBy(pointerId: Int, delta: Offset) = moveBy(pointerId, delta)
+
+/**
+ * Sends a move event on the associated component, with the position of the default pointer
+ * moved by the given [delta]. The default pointer has `pointerId = 0`.
+ *
+ * If the pointer is not yet down, an [IllegalArgumentException] will be thrown.
+ *
+ * @param delta The position for this move event, relative to the last sent position of the
+ * pointer. For example, `delta = Offset(10.px, -10.px) will add 10.px to the pointer's last
+ * x-position, and subtract 10.px from the pointer's last y-position.
+ */
+@Deprecated("Renamed to moveBy",
+ replaceWith = ReplaceWith("moveBy(delta)"))
+fun PartialGestureScope.sendMoveBy(delta: Offset) = moveBy(delta)
+
+/**
+ * Sends a move event without updating any of the pointer positions. This can be useful when
+ * batching movement of multiple pointers together, which can be done with [movePointerTo] and
+ * [movePointerBy].
+ */
+@Deprecated("Renamed to move",
+ replaceWith = ReplaceWith("move()"))
+fun PartialGestureScope.sendMove() = move()
+
+/**
+ * Sends an up event for the pointer with the given [pointerId], or the default pointer if
* [pointerId] is omitted, on the associated component. If any pointers have been moved with
* [movePointerTo] or [movePointerBy] and no move event has been sent yet, a move event will be
* sent right before the up event.
*
* @param pointerId The id of the pointer to lift up, as supplied in [sendDown]
*/
-fun PartialGestureScope.sendUp(pointerId: Int = 0) {
- inputDispatcher.sendUp(pointerId)
-}
+@Deprecated("Renamed to up",
+ replaceWith = ReplaceWith("up(pointerId)"))
+fun PartialGestureScope.sendUp(pointerId: Int = 0) = up(pointerId)
/**
* Sends a cancel event to cancel the current partial gesture. The cancel event contains the
* current position of all active pointers.
*/
-fun PartialGestureScope.sendCancel() {
- inputDispatcher.sendCancel()
-}
+@Deprecated("Renamed to cancel",
+ replaceWith = ReplaceWith("cancel()"))
+fun PartialGestureScope.sendCancel() = cancel()
\ No newline at end of file
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/InputDispatcher.kt b/ui/ui-test/src/main/java/androidx/ui/test/InputDispatcher.kt
index e66e165..b19a2e4 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/InputDispatcher.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/InputDispatcher.kt
@@ -133,7 +133,7 @@
* Generates the downTime of the next gesture with the given [duration]. The gesture's
* [duration] is necessary to facilitate chaining of gestures: if another gesture is made
* after the next one, it will start exactly [duration] after the start of the next gesture.
- * Always use this method to determine the downTime of the [down event][sendDown] of a gesture.
+ * Always use this method to determine the downTime of the [down event][down] of a gesture.
*
* If the duration is unknown when calling this method, use a duration of zero and update
* with [moveNextDownTime] when the duration is known, or use [moveNextDownTime]
@@ -174,8 +174,8 @@
* same [InputDispatcher] instance as the one used to end the last gesture.
*
* Note: this does not affect the time of the next event for the _current_ partial gesture,
- * using [sendMove], [sendUp] and [sendCancel], but it will affect the time of the _next_
- * gesture (including partial gestures started with [sendDown]).
+ * using [move], [up] and [cancel], but it will affect the time of the _next_
+ * gesture (including partial gestures started with [down]).
*
* @param duration The duration of the delay. Must be positive
*/
@@ -353,18 +353,18 @@
* for that pointer. Pointer ids may be reused during the same gesture. This method blocks
* until the input event has been dispatched.
*
- * It is possible to mix partial gestures with full gestures (e.g. send a [click][sendClick]
+ * It is possible to mix partial gestures with full gestures (e.g. send a [click][click]
* during a partial gesture), as long as you make sure that the default pointer id (id=0) is
* free to be used by the full gesture.
*
* A full gesture starts with a down event at some position (with this method) that indicates
- * a finger has started touching the screen, followed by zero or more [down][sendDown],
- * [move][sendMove] and [up][sendUp] events that respectively indicate that another finger
+ * a finger has started touching the screen, followed by zero or more [down][down],
+ * [move][move] and [up][up] events that respectively indicate that another finger
* started touching the screen, a finger moved around or a finger was lifted up from the
- * screen. A gesture is finished when [up][sendUp] lifts the last remaining finger from the
- * screen, or when a single [cancel][sendCancel] event is sent.
+ * screen. A gesture is finished when [up][up] lifts the last remaining finger from the
+ * screen, or when a single [cancel][cancel] event is sent.
*
- * Partial gestures don't have to be defined all in the same [doPartialGesture] block, but
+ * Partial gestures don't have to be defined all in the same [performPartialGesture] block, but
* keep in mind that while the gesture is not complete, all code you execute in between
* blocks that progress the gesture, will be executed while imaginary fingers are actively
* touching the screen.
@@ -376,9 +376,9 @@
* @param position The coordinate of the down event
*
* @see movePointer
- * @see sendMove
- * @see sendUp
- * @see sendCancel
+ * @see move
+ * @see up
+ * @see cancel
*/
fun sendDown(pointerId: Int, position: Offset) {
var gesture = partialGesture
@@ -406,18 +406,18 @@
* Updates the position of the pointer with the given [pointerId] to the given [position],
* but does not send a move event. Use this to move multiple pointers simultaneously. To send
* the next move event, which will contain the current position of _all_ pointers (not just
- * the moved ones), call [sendMove] without arguments. If you move one or more pointers and
- * then call [sendDown] or [sendUp], without calling [sendMove] first, a move event will be
- * sent right before that down or up event. See [sendDown] for more information on how to make
+ * the moved ones), call [move] without arguments. If you move one or more pointers and
+ * then call [down] or [up], without calling [move] first, a move event will be
+ * sent right before that down or up event. See [down] for more information on how to make
* complete gestures from partial gestures.
*
- * @param pointerId The id of the pointer to move, as supplied in [sendDown]
+ * @param pointerId The id of the pointer to move, as supplied in [down]
* @param position The position to move the pointer to
*
- * @see sendDown
- * @see sendMove
- * @see sendUp
- * @see sendCancel
+ * @see down
+ * @see move
+ * @see up
+ * @see cancel
*/
fun movePointer(pointerId: Int, position: Offset) {
val gesture = partialGesture
@@ -438,7 +438,7 @@
* Sends a move event [delay] milliseconds after the previous injected event of this gesture,
* without moving any of the pointers. The default [delay] is [10][eventPeriod] milliseconds.
* Use this to commit all changes in pointer location made with [movePointer]. The sent event
- * will contain the current position of all pointers. See [sendDown] for more information on
+ * will contain the current position of all pointers. See [down] for more information on
* how to make complete gestures from partial gestures.
*
* @param delay The time in milliseconds between the previously injected event and the move
@@ -461,16 +461,16 @@
* Sends an up event for the given [pointerId] at the current position of that pointer,
* [delay] milliseconds after the previous injected event of this gesture. The default
* [delay] is 0 milliseconds. This method blocks until the input event has been dispatched.
- * See [sendDown] for more information on how to make complete gestures from partial gestures.
+ * See [down] for more information on how to make complete gestures from partial gestures.
*
- * @param pointerId The id of the pointer to lift up, as supplied in [sendDown]
+ * @param pointerId The id of the pointer to lift up, as supplied in [down]
* @param delay The time in milliseconds between the previously injected event and the move
* event. 0 milliseconds by default.
*
- * @see sendDown
+ * @see down
* @see movePointer
- * @see sendMove
- * @see sendCancel
+ * @see move
+ * @see cancel
*/
fun sendUp(pointerId: Int, delay: Long = 0) {
val gesture = partialGesture
@@ -502,16 +502,16 @@
/**
* Sends a cancel event [delay] milliseconds after the previous injected event of this
* gesture. The default [delay] is [10][eventPeriod] milliseconds. This method blocks until
- * the input event has been dispatched. See [sendDown] for more information on how to make
+ * the input event has been dispatched. See [down] for more information on how to make
* complete gestures from partial gestures.
*
* @param delay The time in milliseconds between the previously injected event and the cancel
* event. [10][eventPeriod] milliseconds by default.
*
- * @see sendDown
+ * @see down
* @see movePointer
- * @see sendMove
- * @see sendUp
+ * @see move
+ * @see up
*/
fun sendCancel(delay: Long = eventPeriod) {
val gesture = checkNotNull(partialGesture) {
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/KeyInputHelpers.kt b/ui/ui-test/src/main/java/androidx/ui/test/KeyInputHelpers.kt
index 44e0e61..c8b1401 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/KeyInputHelpers.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/KeyInputHelpers.kt
@@ -26,7 +26,7 @@
* @return true if the event was consumed. False otherwise.
*/
@OptIn(ExperimentalKeyInput::class)
-fun SemanticsNodeInteraction.doSendKeyEvent(keyEvent: KeyEvent2): Boolean {
+fun SemanticsNodeInteraction.performKeyPress(keyEvent: KeyEvent2): Boolean {
val semanticsNode = fetchSemanticsNode("Failed to send key Event (${keyEvent.key})")
@OptIn(ExperimentalLayoutNodeApi::class)
val owner = semanticsNode.componentNode.owner
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/Selectors.kt b/ui/ui-test/src/main/java/androidx/ui/test/Selectors.kt
index 8df024c..146fbd4 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/Selectors.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/Selectors.kt
@@ -31,7 +31,7 @@
* [SemanticsNodeInteraction.assertDoesNotExist] is used) and will throw [AssertionError] if
* none or more than one element is found.
*/
-fun SemanticsNodeInteraction.parent(): SemanticsNodeInteraction {
+fun SemanticsNodeInteraction.onParent(): SemanticsNodeInteraction {
return SemanticsNodeInteraction(
useUnmergedTree,
selector.addSelectionFromSingleNode("parent") { listOfNotNull(it.parent) }
@@ -41,7 +41,7 @@
/**
* Returns children of this node.
*/
-fun SemanticsNodeInteraction.children(): SemanticsNodeInteractionCollection {
+fun SemanticsNodeInteraction.onChildren(): SemanticsNodeInteractionCollection {
return SemanticsNodeInteractionCollection(
useUnmergedTree,
selector.addSelectionFromSingleNode("children") { it.children }
@@ -57,7 +57,7 @@
* [SemanticsNodeInteraction.assertDoesNotExist] is used) and will throw [AssertionError] if
* none or more than one element is found.
*/
-fun SemanticsNodeInteraction.child(): SemanticsNodeInteraction {
+fun SemanticsNodeInteraction.onChild(): SemanticsNodeInteraction {
return SemanticsNodeInteraction(
useUnmergedTree,
selector.addSelectionFromSingleNode("child") { it.children }
@@ -69,7 +69,7 @@
*
* This is just a shortcut for "children[index]".
*/
-fun SemanticsNodeInteraction.childAt(index: Int): SemanticsNodeInteraction = children()[index]
+fun SemanticsNodeInteraction.onChildAt(index: Int): SemanticsNodeInteraction = onChildren()[index]
/**
* Returns all siblings of this node.
@@ -83,7 +83,7 @@
* Returns B1, B3
* ```
*/
-fun SemanticsNodeInteraction.siblings(): SemanticsNodeInteractionCollection {
+fun SemanticsNodeInteraction.onSiblings(): SemanticsNodeInteractionCollection {
return SemanticsNodeInteractionCollection(
useUnmergedTree,
selector.addSelectionFromSingleNode("siblings") { it.siblings }
@@ -99,7 +99,7 @@
* [SemanticsNodeInteraction.assertDoesNotExist] is used) and will throw [AssertionError] if
* none or more than one element is found.
*/
-fun SemanticsNodeInteraction.sibling(): SemanticsNodeInteraction {
+fun SemanticsNodeInteraction.onSibling(): SemanticsNodeInteraction {
return SemanticsNodeInteraction(
useUnmergedTree,
selector.addSelectionFromSingleNode("sibling") { it.siblings }
@@ -117,7 +117,7 @@
* Returns B, A
* ```
*/
-fun SemanticsNodeInteraction.ancestors(): SemanticsNodeInteractionCollection {
+fun SemanticsNodeInteraction.onAncestors(): SemanticsNodeInteractionCollection {
return SemanticsNodeInteractionCollection(
useUnmergedTree,
selector.addSelectionFromSingleNode("ancestors") { it.ancestors.toList() }
@@ -131,7 +131,7 @@
* [SemanticsNodeInteraction.assertDoesNotExist] is used) and will throw [AssertionError] if
* no element is found.
*/
-fun SemanticsNodeInteractionCollection.first(): SemanticsNodeInteraction {
+fun SemanticsNodeInteractionCollection.onFirst(): SemanticsNodeInteraction {
return get(0)
}
@@ -142,7 +142,7 @@
* [SemanticsNodeInteraction.assertDoesNotExist] is used) and will throw [AssertionError] if
* no element is found.
*/
-fun SemanticsNodeInteractionCollection.last(): SemanticsNodeInteraction {
+fun SemanticsNodeInteractionCollection.onLast(): SemanticsNodeInteraction {
return SemanticsNodeInteraction(useUnmergedTree, selector.addLastNodeSelector())
}
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/SemanticsNodeInteraction.kt b/ui/ui-test/src/main/java/androidx/ui/test/SemanticsNodeInteraction.kt
index b795657..b5e5289 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/SemanticsNodeInteraction.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/SemanticsNodeInteraction.kt
@@ -21,15 +21,15 @@
/**
* Represents a semantics node and the path to fetch it from the semantics tree. One can interact
- * with this node by performing actions such as [doClick], assertions such as
- * [assertHasClickAction], or navigate to other nodes such as [children].
+ * with this node by performing actions such as [performClick], assertions such as
+ * [assertHasClickAction], or navigate to other nodes such as [onChildren].
*
- * This is usually obtained from methods like [findByTag], [find].
+ * This is usually obtained from methods like [onNodeWithTag], [onNode].
*
* Example usage:
* ```
- * findByTag("myCheckbox")
- * .doClick()
+ * onNodeWithTag("myCheckbox")
+ * .performClick()
* .assertIsOn()
* ````
*
@@ -47,7 +47,7 @@
* // Assert that MyIcon is at the expected position inside the IconButton.
* // Without useUnmergedTree, then the test would check the position of the IconButton (0, 0)
* // instead of the position of the Icon (30, 30).
- * findByTag("icon", useUnmergedTree = true)
+ * onNodeWithTag("icon", useUnmergedTree = true)
* .assertLeftPosition(30.dp)
* .assertTopPosition(30.dp)
* ````
@@ -165,11 +165,11 @@
* One can interact with these nodes by performing assertions such as [assertCountEquals], or
* navigate to other nodes such as [get].
*
- * This is usually obtained from methods like [findAll] or chains of [find].[children].
+ * This is usually obtained from methods like [onAllNodes] or chains of [onNode].[onChildren].
*
* Example usage:
* ```
- * findAll(isClickable())
+ * onAllNodes(isClickable())
* .assertCountEquals(2)
* ````
*/
diff --git a/ui/ui-test/src/main/java/androidx/ui/test/TextActions.kt b/ui/ui-test/src/main/java/androidx/ui/test/TextActions.kt
index ec3b9ab..f9c4c3b 100644
--- a/ui/ui-test/src/main/java/androidx/ui/test/TextActions.kt
+++ b/ui/ui-test/src/main/java/androidx/ui/test/TextActions.kt
@@ -32,9 +32,9 @@
* @param alreadyHasFocus Whether the node already has a focus and thus does not need to be
* clicked on.
*/
-fun SemanticsNodeInteraction.doClearText(alreadyHasFocus: Boolean = false) {
+fun SemanticsNodeInteraction.performTextClearance(alreadyHasFocus: Boolean = false) {
if (!alreadyHasFocus) {
- doClick()
+ performClick()
}
// TODO: There should be some assertion on focus in the future.
@@ -48,9 +48,9 @@
* @param alreadyHasFocus Whether the node already has a focus and thus does not need to be
* clicked on.
*/
-fun SemanticsNodeInteraction.doSendText(text: String, alreadyHasFocus: Boolean = false) {
+fun SemanticsNodeInteraction.performTextInput(text: String, alreadyHasFocus: Boolean = false) {
if (!alreadyHasFocus) {
- doClick()
+ performClick()
}
// TODO: There should be some assertion on focus in the future.
@@ -66,9 +66,12 @@
* @param alreadyHasFocus Whether the node already has a focus and thus does not need to be
* clicked on.
*/
-fun SemanticsNodeInteraction.doReplaceText(text: String, alreadyHasFocus: Boolean = false) {
+fun SemanticsNodeInteraction.performTextReplacement(
+ text: String,
+ alreadyHasFocus: Boolean = false
+) {
if (!alreadyHasFocus) {
- doClick()
+ performClick()
}
// TODO: There should be some assertion on focus in the future.
@@ -88,12 +91,12 @@
* @throws IllegalStateException if tne node did not establish input connection (e.g. is not
* focused)
*/
-fun SemanticsNodeInteraction.doSendImeAction(alreadyHasFocus: Boolean = false) {
+fun SemanticsNodeInteraction.performImeAction(alreadyHasFocus: Boolean = false) {
if (!alreadyHasFocus) {
- doClick()
+ performClick()
}
- val errorOnFail = "Failed to send IME action."
+ val errorOnFail = "Failed to perform IME action."
val node = fetchSemanticsNode(errorOnFail)
assert(hasInputMethodsSupport()) { errorOnFail }
@@ -103,7 +106,7 @@
}
if (actionSpecified == ImeAction.Unspecified) {
throw AssertionError(buildGeneralErrorMessage(
- "Failed to send IME action as current node does not specify any.", selector, node))
+ "Failed to perform IME action as current node does not specify any.", selector, node))
}
@OptIn(ExperimentalLayoutNodeApi::class)
@@ -120,7 +123,7 @@
}
internal fun SemanticsNodeInteraction.sendTextInputCommand(command: List<EditOperation>) {
- val errorOnFail = "Failed to send text input."
+ val errorOnFail = "Failed to perform text input."
val node = fetchSemanticsNode(errorOnFail)
@OptIn(ExperimentalLayoutNodeApi::class)
val owner = node.componentNode.owner as AndroidOwner
@@ -141,4 +144,62 @@
return this.textInputService as TextInputServiceForTests?
?: throw IllegalStateException ("Text input service wrapper not set up! Did you use " +
"ComposeTestRule?")
-}
\ No newline at end of file
+}
+
+// DEPRECATED APIs SECTION
+
+/**
+ * Clears the text in this node in similar way to IME.
+ *
+ * Note performing this operation requires to get a focus.
+ *
+ * @param alreadyHasFocus Whether the node already has a focus and thus does not need to be
+ * clicked on.
+ */
+@Deprecated("Renamed to performTextClearance",
+ replaceWith = ReplaceWith("performTextClearance(alreadyHasFocus)"))
+fun SemanticsNodeInteraction.doClearText(alreadyHasFocus: Boolean = false) =
+ performTextClearance(alreadyHasFocus)
+
+/**
+ * Sends the given text to this node in similar way to IME.
+ *
+ * @param text Text to send.
+ * @param alreadyHasFocus Whether the node already has a focus and thus does not need to be
+ * clicked on.
+ */
+@Deprecated("Renamed to performTextInput",
+ replaceWith = ReplaceWith("performTextInput(text, alreadyHasFocus)"))
+fun SemanticsNodeInteraction.doSendText(text: String, alreadyHasFocus: Boolean = false) =
+ performTextInput(text, alreadyHasFocus)
+
+/**
+ * Replaces existing text with the given text in this node in similar way to IME.
+ *
+ * This does not reflect text selection. All the text gets cleared out and new inserted.
+ *
+ * @param text Text to send.
+ * @param alreadyHasFocus Whether the node already has a focus and thus does not need to be
+ * clicked on.
+ */
+@Deprecated("Renamed to performTextReplacement",
+ replaceWith = ReplaceWith("performTextReplacement(text, alreadyHasFocus)"))
+fun SemanticsNodeInteraction.doReplaceText(text: String, alreadyHasFocus: Boolean = false) =
+ performTextReplacement(text, alreadyHasFocus)
+
+/**
+ * Sends to this node the IME action associated with it in similar way to IME.
+ *
+ * The node needs to define its IME action in semantics.
+ *
+ * @param alreadyHasFocus Whether the node already has a focus and thus does not need to be
+ * clicked on.
+ *
+ * @throws AssertionError if the node does not support input or does not define IME action.
+ * @throws IllegalStateException if tne node did not establish input connection (e.g. is not
+ * focused)
+ */
+@Deprecated("Renamed to performImeAction",
+ replaceWith = ReplaceWith("performImeAction(alreadyHasFocus)"))
+fun SemanticsNodeInteraction.doSendImeAction(alreadyHasFocus: Boolean = false) =
+ performImeAction(alreadyHasFocus)