This repository has been archived by the owner on May 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #210 from Unlimity/nested-scroll-view-support
Add NestedScrollView support in scrollTo()
- Loading branch information
Showing
5 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
kakao/src/main/kotlin/com/agoda/kakao/common/actions/NestedScrollToAction.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.agoda.kakao.common.actions | ||
|
||
import android.view.View | ||
import android.widget.HorizontalScrollView | ||
import android.widget.ListView | ||
import android.widget.ScrollView | ||
import androidx.core.widget.NestedScrollView | ||
import androidx.test.espresso.ViewAction | ||
import androidx.test.espresso.action.ScrollToAction | ||
import androidx.test.espresso.matcher.ViewMatchers | ||
import androidx.test.espresso.matcher.ViewMatchers.isAssignableFrom | ||
import androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA | ||
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility | ||
import org.hamcrest.Matcher | ||
import org.hamcrest.Matchers.allOf | ||
import org.hamcrest.Matchers.anyOf | ||
|
||
/** | ||
* Scrolls to a given view with [NestedScrollView] support. | ||
*/ | ||
class NestedScrollToAction : ViewAction by ScrollToAction() { | ||
override fun getConstraints(): Matcher<View> = allOf( | ||
withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE), | ||
isDescendantOfA( | ||
anyOf( | ||
isAssignableFrom(ScrollView::class.java), | ||
isAssignableFrom(HorizontalScrollView::class.java), | ||
isAssignableFrom(NestedScrollView::class.java), | ||
isAssignableFrom(ListView::class.java) | ||
) | ||
) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,6 +150,10 @@ class TestActivityTest { | |
swipeSwitchThumb(RIGHT) | ||
isChecked() | ||
} | ||
|
||
nestedTextView { | ||
scrollTo() | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters