IntentMatchers

public final class IntentMatchers
extends Object

java.lang.Object
   ↳ android.support.test.espresso.intent.matcher.IntentMatchers


用于匹配 Intent对象的一系列Hamcrest匹配器。

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)

通过使用 hasClassName(String)返回一个匹配器,该匹配器只匹配针对单个类的 hasClassName(String)

static Matcher<Intent> hasComponent(Matcher<ComponentName> componentMatcher)

可以通过类名,包名或简短的类名匹配意图。

static Matcher<Intent> hasComponent(ComponentName componentName)

返回匹配器,该匹配器只匹配定位到componentName类的intent。

static Matcher<Intent> hasData(Matcher<Uri> uriMatcher)
static Matcher<Intent> hasData(String uri)
static Matcher<Intent> hasData(Uri uri)
static Matcher<Intent> 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()

如果它的包与用于检测测试的目标包相同,则匹配意图。

static Matcher<Intent> toPackage(String packageName)

匹配基于可处理意图的活动包的意图。

Inherited methods

From class java.lang.Object

Public methods

anyIntent

Matcher<Intent> anyIntent ()

Returns
Matcher<Intent>

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)

通过使用hasClassName(String)返回匹配器,该匹配器仅匹配定位到单个类的hasClassName(String) 输入字符串必须包含软件包名称和短名称。 例如hasComponent(“com.google.provider.NotePad”)。

Parameters
className String: complete class path
Returns
Matcher<Intent>

hasComponent

Matcher<Intent> hasComponent (Matcher<ComponentName> componentMatcher)

可以通过类名,包名或简短的类名匹配意图。

Parameters
componentMatcher Matcher: can be the value of hasClassName(String), hasPackageName(String) or hasShortClassName(String)
Returns
Matcher<Intent>

hasComponent

Matcher<Intent> hasComponent (ComponentName componentName)

返回匹配器,该匹配器只匹配定位到componentName类的intent。 例如:Intent intent = new Intent().setComponentName(new ComponentName(“com.google.provider”,“com.google.provider.Notepad”)); 将匹配针对Notepad.java的所有意图。

Parameters
componentName ComponentName: a componentName that has the target class specified
Returns
Matcher<Intent>

也可以看看:

hasData

Matcher<Intent> hasData (Matcher<Uri> uriMatcher)

Parameters
uriMatcher Matcher
Returns
Matcher<Intent>

hasData

Matcher<Intent> hasData (String uri)

Parameters
uri String
Returns
Matcher<Intent>

hasData

Matcher<Intent> hasData (Uri uri)

Parameters
uri Uri
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>

hasFlag

Matcher<Intent> hasFlag (int flag)

Parameters
flag int
Returns
Matcher<Intent>

hasFlags

Matcher<Intent> hasFlags (int flags)

Parameters
flags int
Returns
Matcher<Intent>

hasFlags

Matcher<Intent> hasFlags (int... flags)

Parameters
flags int
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>

hasType

Matcher<Intent> hasType (String type)

Parameters
type String
Returns
Matcher<Intent>

isInternal

Matcher<Intent> isInternal ()

如果它的包与用于检测测试的目标包相同,则匹配意图。

Returns
Matcher<Intent>

toPackage

Matcher<Intent> toPackage (String packageName)

匹配基于可处理意图的活动包的意图。

Parameters
packageName String: packages of activity that can handle the intent
Returns
Matcher<Intent>