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/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 {