This repository has been archived by the owner on Oct 11, 2022. It is now read-only.
forked from AdevintaSpain/Barista
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add BaristaClickableAssertions (AdevintaSpain#277)
* Add new methods for asserting whether or not views are clickable * Write tests for assertClickable and assertNotClickable * Add clickable assertions * Remove IdRes annotation from resId parameters The resId parameter value can be either a view ID or a string resource ID, therefore it does not make sense for it to be annotated with IdRes.
- Loading branch information
Showing
4 changed files
with
98 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
30 changes: 30 additions & 0 deletions
30
library/src/main/java/com/schibsted/spain/barista/assertion/BaristaClickableAssertions.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,30 @@ | ||
package com.schibsted.spain.barista.assertion | ||
|
||
import android.support.test.espresso.matcher.ViewMatchers.isClickable | ||
import android.support.test.espresso.matcher.ViewMatchers.withText | ||
import com.schibsted.spain.barista.internal.assertAny | ||
import com.schibsted.spain.barista.internal.util.resourceMatcher | ||
import org.hamcrest.Matchers.not | ||
|
||
object BaristaClickableAssertions { | ||
|
||
@JvmStatic | ||
fun assertClickable(resId: Int) { | ||
resId.resourceMatcher().assertAny(isClickable()) | ||
} | ||
|
||
@JvmStatic | ||
fun assertClickable(text: String) { | ||
withText(text).assertAny(isClickable()) | ||
} | ||
|
||
@JvmStatic | ||
fun assertNotClickable(resId: Int) { | ||
resId.resourceMatcher().assertAny(not(isClickable())) | ||
} | ||
|
||
@JvmStatic | ||
fun assertNotClickable(text: String) { | ||
withText(text).assertAny(not(isClickable())) | ||
} | ||
} |
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