MaterialDesignLibrary icon indicating copy to clipboard operation
MaterialDesignLibrary copied to clipboard

ButtonRectangle espresso click action

Open jaydp17 opened this issue 10 years ago • 4 comments

ButtonRectangle doesn't get clicked when using espresso.

onView(withId(R.id.enterBtn)).perform(click());

Here's what happens screenshot_2015-02-13-15-46-37 01

It stays like that, and test times out

jaydp17 avatar Feb 13 '15 10:02 jaydp17

Yes, I have noticed the same issue. Is there a workaround or a fix in the horizon?

I really hope testing is taken much more seriously, as far as I am concerned, this is a showstopper, it's pretty but broken.

appmath avatar Apr 23 '15 02:04 appmath

It's not perfect, but I've been calling the onClick function directly (specified in my layout xml) instead of via the button.

e.g. for the following (simplified) xml:

<ButtonRectangle
            android:id="@+id/register"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:onClick="signupWithEmail">

I'll just do the following in my test: mainActivity.getActivity().signupWithEmail(null); instead of the usual: onView(withId(R.id.register)).perform(click());

andrewcross avatar Oct 20 '15 16:10 andrewcross

Hi @jaydeep17, @andrewcross and @appmath,

I have managed to create a workaround for this library to disable button ripple effect when the app is under test.

My workaround requires that a indicator class named 'TestingIndicator', be created within the 'src/androidTest' folder whose classes are only loaded when app is being tested. This class must have package name the same as that of the app under test.

When a button (extends CustomView) is instantiated, we check for presence of 'TestingIndicator' using Class.forName method. If it exists, set variable to define app is under test and from that variable, disable ripple effect.

See commit here to my fork: https://github.com/wilson208/MaterialDesignLibrary/commit/2450808b99e51413404d4b62dcb27b0b0bbbccb2

I am looking for your guys opinions as to whether this is a viable solution to create a pull request, I know its a little hacky but cant think of another way to do this at the moment.

Wilson.

wilson208 avatar May 13 '16 00:05 wilson208

Any update with this? considering changing buttons over this issue.

blackcolt avatar Feb 25 '19 16:02 blackcolt