{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}
public final class IntentMatchers
A collection of hamcrest matchers for matching Intent objects.
Public constructors |
|
|---|---|
Public methods |
|
|---|---|
static Matcher<Intent> |
|
static Matcher<Intent> |
|
static Matcher<Intent> |
doesNotHaveExtraWithKey(Matcher<String> keyMatcher) |
static Matcher<Intent> |
filterEquals(Intent expectedIntent)Matches an intent if it Intent#filterEquals(Intent) the expected intent. |
static Matcher<Intent> |
|
static Matcher<Intent> |
hasAction(Matcher<String> actionMatcher) |
static Matcher<Intent> |
hasCategories(Set<String> categories) |
static Matcher<Intent> |
hasCategories( |
static Matcher<Intent> |
hasComponent(String className)Returns a matcher that will only match intents targeted to a single class by using hasClassName. |
static Matcher<Intent> |
hasComponent(ComponentName componentName)Returns a matcher that will only match intents targeted to the componentName's class, {@see * ComponentName#getClassName}. |
static Matcher<Intent> |
hasComponent(Matcher<ComponentName> componentMatcher)Can match an intent by class name, package name or short class name. |
static Matcher<Intent> |
|
static Matcher<Intent> |
hasData(Uri uri) |
static Matcher<Intent> |
hasData(Matcher<Uri> uriMatcher) |
static Matcher<Intent> |
hasDataString(Matcher<String> stringMatcher) |
static Matcher<Intent> |
|
static Matcher<Intent> |
|
static Matcher<Intent> |
hasExtra(Matcher<String> keyMatcher, Matcher<?> valueMatcher) |
static Matcher<Intent> |
hasExtraWithKey(String key) |
static Matcher<Intent> |
hasExtraWithKey(Matcher<String> keyMatcher) |
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> |
|
static Matcher<Intent> |
hasType(Matcher<String> typeMatcher) |
static Matcher<Intent> |
Matches an intent if its package is the same as the target package for the instrumentation test. |
static Matcher<Intent> |
Matches an intent based on the package of activity which can handle the intent. |
public static Matcher<Intent> doesNotHaveExtraWithKey(Matcher<String> keyMatcher)
public static Matcher<Intent> filterEquals(Intent expectedIntent)
Matches an intent if it Intent#filterEquals(Intent) the expected intent.
public static Matcher<Intent> hasCategories(
Matcher<? extends Iterable<? super String>> categoriesMatcher
)
public static Matcher<Intent> hasComponent(String className)
Returns a matcher that will only match intents targeted to a single class by using hasClassName. The input string must contain the package name + short class name. For example hasComponent("com.google.provider.NotePad").
| Parameters | |
|---|---|
String className |
complete class path |
public static Matcher<Intent> hasComponent(ComponentName componentName)
Returns a matcher that will only match intents targeted to the componentName's class, {@see * ComponentName#getClassName}. 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 |
public static Matcher<Intent> hasComponent(Matcher<ComponentName> componentMatcher)
Can match an intent by class name, package name or short class name.
| Parameters | |
|---|---|
Matcher<ComponentName> componentMatcher |
can be the value of ComponentNameMatchers#hasClassName, hasPackageName or ComponentNameMatchers#hasShortClassName |
public static Matcher<Intent> hasExtra(Matcher<String> keyMatcher, Matcher<?> valueMatcher)
public static Matcher<Intent> isInternal()
Matches an intent if its package is the same as the target package for the instrumentation test.