Giter Site home page Giter Site logo

Comments (4)

minibugdev avatar minibugdev commented on May 19, 2024 2

I resolved by create custom action like

class NestedScrollActions(private val original: ScrollToAction = ScrollToAction()) : ViewAction by original {

    override fun getConstraints(): Matcher<View> = CoreMatchers.anyOf(
            CoreMatchers.allOf(
                    withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE),
                    isDescendantOfA(isAssignableFrom(NestedScrollView::class.java)))
            , original.constraints
    )
}

and use act for perform it

button {
    act {
        NestedScrollActions()
    }
    click()
}

Anyway, I'm not sure this is good enough solution for make a PR.

from kakao.

Unlimity avatar Unlimity commented on May 19, 2024 2

Maybe the problem was with how you matched your button. It is possible that you need to match your button as a child of nested scroll view in your screen class. Cheers!

from kakao.

Unlimity avatar Unlimity commented on May 19, 2024

Hello there! Can you provide more info? Stacktrace at least?
And by the way, your button in provided example is named snackbarButton. Are you actually calling snackbar? If so, snackbar is added to your root view and there is no need to scroll to it. Also please provide your screen class, maybe matching is wrong.

from kakao.

minibugdev avatar minibugdev commented on May 19, 2024

Hi, sorry to have confused you.
I try to scroll to button, which inside NestedScrollView and click it
and lastly assert SnackBar should display

Updated code as below
Layout

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
	xmlns:android="http://schemas.android.com/apk/res/android"
	android:id="@+id/content"
	android:layout_width="match_parent"
	android:layout_height="match_parent">

	<LinearLayout
		android:layout_width="match_parent"
		android:layout_height="match_parent"
		android:orientation="vertical">

		<Space
			android:layout_width="wrap_content"
			android:layout_height="600dp"
			android:textColor="@color/background_color" />

		<Button
			android:id="@+id/button"
			android:layout_width="wrap_content"
			android:layout_height="wrap_content"
			android:text="BUTTON" />
	</LinearLayout>
</android.support.v4.widget.NestedScrollView>

Screen

    val content: KView = KView { withId(R.id.content) }
    val button: KButton = KButton { withId(R.id.button) }

    val snackbar: KSnackbar = KSnackbar()

Test

    @Test
    fun testContentScreen() {
        screen {
            content {
                isVisible()
            }

            button {
                scrollTo()
                click()
            }

            snackbar {
                isDisplayed()
            }
        }
    }

An exception

android.support.test.espresso.PerformException: Error performing 'scroll to' on view '(with id: com.agoda.sample:id/button)'.
at android.support.test.espresso.PerformException$Builder.build(PerformException.java:84)
at android.support.test.espresso.base.DefaultFailureHandler.getUserFriendlyError(DefaultFailureHandler.java:81)
at android.support.test.espresso.base.DefaultFailureHandler.handle(DefaultFailureHandler.java:52)
at android.support.test.espresso.ViewInteraction.waitForAndHandleInteractionResults(ViewInteraction.java:312)
at android.support.test.espresso.ViewInteraction.desugaredPerform(ViewInteraction.java:167)
at android.support.test.espresso.ViewInteraction.perform(ViewInteraction.java:110)
at com.agoda.kakao.BaseActions$DefaultImpls.scrollTo(Actions.kt:148)
at com.agoda.kakao.KBaseView.scrollTo(Views.kt:30)
at com.agoda.sample.NestedScrollViewActivityTest$testContentScreen$1$2.invoke(NestedScrollViewActivityTest.kt:26)
at com.agoda.sample.NestedScrollViewActivityTest$testContentScreen$1$2.invoke(NestedScrollViewActivityTest.kt:11)

from kakao.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.