Skip to content

Commit

Permalink
Fix tests for performGesture changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbutcher authored and JoseAlcerreca committed Oct 14, 2021
1 parent 116a93c commit 2a51548
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
Expand Up @@ -56,7 +56,7 @@ import androidx.compose.ui.test.captureToImage
import androidx.compose.ui.test.junit4.ComposeContentTestRule
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performGesture
import androidx.compose.ui.test.performTouchInput
import androidx.compose.ui.test.swipeLeft
import androidx.compose.ui.test.swipeRight
import androidx.compose.ui.unit.Dp
Expand Down Expand Up @@ -239,11 +239,11 @@ class ScaffoldTest {
}
}
assertThat(drawerChildPosition.x).isLessThan(0f)
rule.onNodeWithTag(scaffoldTag).performGesture {
rule.onNodeWithTag(scaffoldTag).performTouchInput {
swipeRight()
}
assertThat(drawerChildPosition.x).isLessThan(0f)
rule.onNodeWithTag(scaffoldTag).performGesture {
rule.onNodeWithTag(scaffoldTag).performTouchInput {
swipeLeft()
}
assertThat(drawerChildPosition.x).isLessThan(0f)
Expand All @@ -252,11 +252,11 @@ class ScaffoldTest {
drawerGesturedEnabledState.value = true
}

rule.onNodeWithTag(scaffoldTag).performGesture {
rule.onNodeWithTag(scaffoldTag).performTouchInput {
swipeRight()
}
assertThat(drawerChildPosition.x).isEqualTo(0f)
rule.onNodeWithTag(scaffoldTag).performGesture {
rule.onNodeWithTag(scaffoldTag).performTouchInput {
swipeLeft()
}
assertThat(drawerChildPosition.x).isLessThan(0f)
Expand Down
Expand Up @@ -81,7 +81,7 @@ class HorizontalPagerScrollingContentTest {
// Perform a very quick, high velocity scroll which will scroll the inner content to it's
// opposite/end edge
rule.onNodeWithTag(TestTag)
.swipeAcrossCenterWithVelocity(velocityPerSec = 5_000.dp, distancePercentageX = -0.5f)
.swipeAcrossCenterWithVelocity(velocityPerSec = 2_000.dp, distancePercentageX = -0.5f)

// Wait for the flings to end
rule.waitForIdle()
Expand Down
Expand Up @@ -22,8 +22,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalLayoutDirection
import androidx.compose.ui.test.SemanticsNodeInteraction
import androidx.compose.ui.test.junit4.ComposeContentTestRule
import androidx.compose.ui.test.percentOffset
import androidx.compose.ui.test.performGesture
import androidx.compose.ui.test.performTouchInput
import androidx.compose.ui.test.swipe
import androidx.compose.ui.test.swipeWithVelocity
import androidx.compose.ui.unit.Dp
Expand All @@ -49,7 +48,7 @@ internal fun SemanticsNodeInteraction.swipeAcrossCenterWithVelocity(
velocityPerSec: Dp,
distancePercentageX: Float = 0f,
distancePercentageY: Float = 0f,
): SemanticsNodeInteraction = performGesture {
): SemanticsNodeInteraction = performTouchInput {
val startOffset = percentOffset(
x = 0.5f - distancePercentageX / 2,
y = 0.5f - distancePercentageY / 2
Expand Down
Expand Up @@ -80,7 +80,7 @@ class VerticalPagerScrollingContentTest {
// Perform a very quick, high velocity scroll which will scroll the inner content to it's
// opposite/end edge
rule.onNodeWithTag(TestTag)
.swipeAcrossCenterWithVelocity(velocityPerSec = 5_000.dp, distancePercentageY = -0.5f)
.swipeAcrossCenterWithVelocity(velocityPerSec = 2_000.dp, distancePercentageY = -0.5f)

// Wait for the flings to end
rule.waitForIdle()
Expand Down
Expand Up @@ -32,7 +32,7 @@ import androidx.compose.ui.test.assertIsNotDisplayed
import androidx.compose.ui.test.getUnclippedBoundsInRoot
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performGesture
import androidx.compose.ui.test.performTouchInput
import androidx.compose.ui.test.swipeDown
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.common.truth.Truth.assertThat
Expand Down Expand Up @@ -60,7 +60,7 @@ class SwipeRefreshTest {
}

// Swipe down on the swipe refresh
swipeRefreshNode.performGesture { swipeDown() }
swipeRefreshNode.performTouchInput { swipeDown() }

// Assert that the onRefresh lambda was called once, and that we're refreshing
assertThat(refreshCallCount).isEqualTo(1)
Expand Down Expand Up @@ -116,7 +116,7 @@ class SwipeRefreshTest {
val restingBounds = indicatorNode.getUnclippedBoundsInRoot()

// Now swipe down. The indicator should react visually
swipeRefreshNode.performGesture { swipeDown() }
swipeRefreshNode.performTouchInput { swipeDown() }

// Assert that the indicator returns back to it's 'resting' position
assertThat(indicatorNode.getUnclippedBoundsInRoot()).isEqualTo(restingBounds)
Expand Down

0 comments on commit 2a51548

Please sign in to comment.