IntentMatchers
public
final
class
IntentMatchers
extends Object
java.lang.Object | |
↳ | android.support.test.espresso.intent.matcher.IntentMatchers |
A collection of hamcrest matchers for matching Intent
objects.
Summary
Public methods | |
---|---|
static
Matcher<Intent>
|
anyIntent()
|
static
Matcher<Intent>
|
hasAction(String action)
|
static
Matcher<Intent>
|
)">hasAction(Matcher<String> actionMatcher)
|
static
Matcher<Intent>
|
)">hasCategories(Set<String> categories)
|
static
Matcher<Intent>
|
>)">hasCategories(Matcher<? extends Iterable<? super String>> categoriesMatcher)
|
static
Matcher<Intent>
|
hasComponent(String className)
Returns a matcher that will only match intents targeted to a single class by using |
static
Matcher<Intent>
|
)">hasComponent(Matcher<ComponentName> componentMatcher)
Can match an intent by class name, package name or short class name. |
static
Matcher<Intent>
|
hasComponent(ComponentName componentName)
Returns a matcher that will only match intents targeted to the componentName's class, . |
static
Matcher<Intent>
|
)">hasData(Matcher<Uri> uriMatcher)
|
static
Matcher<Intent>
|
hasData(String uri)
|
static
Matcher<Intent>
|
hasData(Uri uri)
|
static
Matcher<Intent>
|
, org.hamcrest.Matcher>)">hasExtra(Matcher<String> keyMatcher, Matcher<?> valueMatcher)
|
static
<T>
Matcher<Intent>
|
hasExtra(String key, T value)
|
static
Matcher<Intent>
|
)">hasExtraWithKey(Matcher<String> keyMatcher)
|
static
Matcher<Intent>
|
hasExtraWithKey(String key)
|
static
Matcher<Intent>
|
)">hasExtras(Matcher<Bundle> bundleMatcher)
|
static
Matcher<Intent>
|
hasFlag(int flag)
|
static
Matcher<Intent>
|
hasFlags(int flags)
|
static
Matcher<Intent>
|
hasFlags(int... flags)
|
static
Matcher<Intent>
|
)">hasPackage(Matcher<String> packageMatcher)
|
static
Matcher<Intent>
|
hasPackage(String packageName)
|
static
Matcher<Intent>
|
)">hasType(Matcher<String> typeMatcher)
|
static
Matcher<Intent>
|
hasType(String type)
|
static
Matcher<Intent>
|
isInternal()
Matches an intent if its package is the same as the target package for the instrumentation test. |
static
Matcher<Intent>
|
toPackage(String packageName)
Matches an intent based on the package of activity which can handle the intent. |
Inherited methods | |
---|---|
From
class
java.lang.Object
|
Public methods
hasAction
Matcher<Intent> hasAction (String action)
Parameters | |
---|---|
action |
String |
Returns | |
---|---|
Matcher<Intent> |
hasAction
Matcher<Intent> hasAction (Matcher<String> actionMatcher)
Parameters | |
---|---|
actionMatcher |
Matcher |
Returns | |
---|---|
Matcher<Intent> |
hasCategories
Matcher<Intent> hasCategories (Set<String> categories)
Parameters | |
---|---|
categories |
Set |
Returns | |
---|---|
Matcher<Intent> |
hasCategories
Matcher<Intent> hasCategories (Matcher<? extends Iterable<? super String>> categoriesMatcher)
Parameters | |
---|---|
categoriesMatcher |
Matcher |
Returns | |
---|---|
Matcher<Intent> |
hasComponent
Matcher<Intent> hasComponent (String className)
Returns a matcher that will only match intents targeted to a single class by using hasClassName(String)
. The input string must contain the package name + short
class name. For example hasComponent("com.google.provider.NotePad").
Parameters | |
---|---|
className |
String : complete class path
|
Returns | |
---|---|
Matcher<Intent> |
hasComponent
Matcher<Intent> hasComponent (Matcher<ComponentName> componentMatcher)
Can match an intent by class name, package name or short class name.
Parameters | |
---|---|
componentMatcher |
Matcher : can be the value of hasClassName(String) , hasPackageName(String) or hasShortClassName(String)
|
Returns | |
---|---|
Matcher<Intent> |
hasComponent
Matcher<Intent> hasComponent (ComponentName componentName)
Returns a matcher that will only match intents targeted to the componentName's class, . For example: Intent intent = new Intent() .setComponentName(new ComponentName("com.google.provider", "com.google.provider.Notepad")); will match all intents targeted to Notepad.java.
Parameters | |
---|---|
componentName |
ComponentName : a componentName that has the target class specified
|
Returns | |
---|---|
Matcher<Intent> |
See also:
hasData
Matcher<Intent> hasData (Matcher<Uri> uriMatcher)
Parameters | |
---|---|
uriMatcher |
Matcher |
Returns | |
---|---|
Matcher<Intent> |
hasExtra
Matcher<Intent> hasExtra (Matcher<String> keyMatcher, Matcher<?> valueMatcher)
Parameters | |
---|---|
keyMatcher |
Matcher |
valueMatcher |
Matcher |
Returns | |
---|---|
Matcher<Intent> |
hasExtra
Matcher<Intent> hasExtra (String key, T value)
Parameters | |
---|---|
key |
String |
value |
T |
Returns | |
---|---|
Matcher<Intent> |
hasExtraWithKey
Matcher<Intent> hasExtraWithKey (Matcher<String> keyMatcher)
Parameters | |
---|---|
keyMatcher |
Matcher |
Returns | |
---|---|
Matcher<Intent> |
hasExtraWithKey
Matcher<Intent> hasExtraWithKey (String key)
Parameters | |
---|---|
key |
String |
Returns | |
---|---|
Matcher<Intent> |
hasExtras
Matcher<Intent> hasExtras (Matcher<Bundle> bundleMatcher)
Parameters | |
---|---|
bundleMatcher |
Matcher |
Returns | |
---|---|
Matcher<Intent> |
hasPackage
Matcher<Intent> hasPackage (Matcher<String> packageMatcher)
Parameters | |
---|---|
packageMatcher |
Matcher |
Returns | |
---|---|
Matcher<Intent> |
hasPackage
Matcher<Intent> hasPackage (String packageName)
Parameters | |
---|---|
packageName |
String |
Returns | |
---|---|
Matcher<Intent> |
hasType
Matcher<Intent> hasType (Matcher<String> typeMatcher)
Parameters | |
---|---|
typeMatcher |
Matcher |
Returns | |
---|---|
Matcher<Intent> |
isInternal
Matcher<Intent> isInternal ()
Matches an intent if its package is the same as the target package for the instrumentation test.
Returns | |
---|---|
Matcher<Intent> |