# ComponentNameMatchers

Artifact: [androidx.test.espresso:espresso-intents](https://developer.android.com/jetpack/androidx/releases/test-espresso) [View Source](https://cs.android.com/search?q=file:androidx/test/espresso/intent/matcher/ComponentNameMatchers.java+class:androidx.test.espresso.intent.matcher.ComponentNameMatchers)

*** ** * ** ***


```
@CheckReturnValue
public final class ComponentNameMatchers
```

<br />

*** ** * ** ***

A collection of hamcrest matchers to match `https://developer.android.com/reference/android/content/ComponentName.html` objects.

## Summary

| ### Public methods |
|---|---|
| `static https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html<https://developer.android.com/reference/android/content/ComponentName.html>` | `https://developer.android.com/reference/androidx/test/espresso/intent/matcher/ComponentNameMatchers#hasClassName(org.hamcrest.Matcher<java.lang.String>)(https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html<https://developer.android.com/reference/java/lang/String.html> classNameMatcher)` |
| `static https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html<https://developer.android.com/reference/android/content/ComponentName.html>` | `https://developer.android.com/reference/androidx/test/espresso/intent/matcher/ComponentNameMatchers#hasClassName(java.lang.String)(https://developer.android.com/reference/java/lang/String.html className)` |
| `static https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html<https://developer.android.com/reference/android/content/ComponentName.html>` | `https://developer.android.com/reference/androidx/test/espresso/intent/matcher/ComponentNameMatchers#hasMyPackageName()()` Matches a component based on the target package name found through the Instrumentation Registry for the test. |
| `static https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html<https://developer.android.com/reference/android/content/ComponentName.html>` | `https://developer.android.com/reference/androidx/test/espresso/intent/matcher/ComponentNameMatchers#hasPackageName(org.hamcrest.Matcher<java.lang.String>)(https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html<https://developer.android.com/reference/java/lang/String.html> packageNameMatcher)` |
| `static https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html<https://developer.android.com/reference/android/content/ComponentName.html>` | `https://developer.android.com/reference/androidx/test/espresso/intent/matcher/ComponentNameMatchers#hasPackageName(java.lang.String)(https://developer.android.com/reference/java/lang/String.html packageName)` |
| `static https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html<https://developer.android.com/reference/android/content/ComponentName.html>` | `https://developer.android.com/reference/androidx/test/espresso/intent/matcher/ComponentNameMatchers#hasShortClassName(org.hamcrest.Matcher<java.lang.String>)(https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html<https://developer.android.com/reference/java/lang/String.html> shortClassNameMatcher)` |
| `static https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html<https://developer.android.com/reference/android/content/ComponentName.html>` | `https://developer.android.com/reference/androidx/test/espresso/intent/matcher/ComponentNameMatchers#hasShortClassName(java.lang.String)(https://developer.android.com/reference/java/lang/String.html shortClassName)` |

## Public methods

### hasClassName

```
public static Matcher<ComponentName> hasClassName(Matcher<String> classNameMatcher)
```

### hasClassName

```
public static Matcher<ComponentName> hasClassName(String className)
```

### hasMyPackageName

```
public static Matcher<ComponentName> hasMyPackageName()
```

Matches a component based on the target package name found through the Instrumentation Registry for the test.

### hasPackageName

```
public static Matcher<ComponentName> hasPackageName(Matcher<String> packageNameMatcher)
```

### hasPackageName

```
public static Matcher<ComponentName> hasPackageName(String packageName)
```

### hasShortClassName

```
public static Matcher<ComponentName> hasShortClassName(Matcher<String> shortClassNameMatcher)
```

### hasShortClassName

```
public static Matcher<ComponentName> hasShortClassName(String shortClassName)
```