# ComponentNameMatchers

Summary:[Methods](https://developer.android.com/reference/android/support/test/espresso/intent/matcher/ComponentNameMatchers#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/test/espresso/intent/matcher/ComponentNameMatchers#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/test/espresso/intent/matcher/ComponentNameMatchers#)  

# ComponentNameMatchers

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public

final

class
ComponentNameMatchers
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object.html)`


``


`

|---|--------------------------------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) ||
| ↳ | android.support.test.espresso.intent.matcher.ComponentNameMatchers |

<br />

*** ** * ** ***

A collection of hamcrest matchers to match[ComponentName](https://developer.android.com/reference/android/content/ComponentName.html)objects.

## Summary

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

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/test/espresso/intent/matcher/ComponentNameMatchers#)From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object.html)` ` |-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object.html)          | ` clone() `                                                                                | | ` boolean`                                                                          | ` equals(`[Object](https://developer.android.com/reference/java/lang/Object.html)` arg0) ` | | ` void`                                                                             | ` finalize() `                                                                             | | ` final `[Class](https://developer.android.com/reference/java/lang/Class.html)`<?>` | ` getClass() `                                                                             | | ` int`                                                                              | ` hashCode() `                                                                             | | ` final void`                                                                       | ` notify() `                                                                               | | ` final void`                                                                       | ` notifyAll() `                                                                            | | ` `[String](https://developer.android.com/reference/java/lang/String.html)          | ` toString() `                                                                             | | ` final void`                                                                       | ` wait(long arg0, int arg1) `                                                              | | ` final void`                                                                       | ` wait(long arg0) `                                                                        | | ` final void`                                                                       | ` wait() `                                                                                 | ||

## Public methods

### hasClassName

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

<br />

<br />

|              Parameters              ||
|--------------------|------------------|
| `classNameMatcher` | `Matcher` <br /> |

|                                                     Returns                                                      ||
|----------------------------------------------------------------------------------------------------------|--------|
| `Matcher<`[ComponentName](https://developer.android.com/reference/android/content/ComponentName.html)`>` | <br /> |

### hasClassName

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

<br />

<br />

|          Parameters          ||
|-------------|-----------------|
| `className` | `String` <br /> |

|                                                     Returns                                                      ||
|----------------------------------------------------------------------------------------------------------|--------|
| `Matcher<`[ComponentName](https://developer.android.com/reference/android/content/ComponentName.html)`>` | <br /> |

### hasMyPackageName

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

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

<br />

|                                                     Returns                                                      ||
|----------------------------------------------------------------------------------------------------------|--------|
| `Matcher<`[ComponentName](https://developer.android.com/reference/android/content/ComponentName.html)`>` | <br /> |

### hasPackageName

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

<br />

<br />

|           Parameters           ||
|---------------|-----------------|
| `packageName` | `String` <br /> |

|                                                     Returns                                                      ||
|----------------------------------------------------------------------------------------------------------|--------|
| `Matcher<`[ComponentName](https://developer.android.com/reference/android/content/ComponentName.html)`>` | <br /> |

### hasPackageName

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

<br />

<br />

|               Parameters               ||
|----------------------|------------------|
| `packageNameMatcher` | `Matcher` <br /> |

|                                                     Returns                                                      ||
|----------------------------------------------------------------------------------------------------------|--------|
| `Matcher<`[ComponentName](https://developer.android.com/reference/android/content/ComponentName.html)`>` | <br /> |

### hasShortClassName

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

<br />

<br />

|                Parameters                 ||
|-------------------------|------------------|
| `shortClassNameMatcher` | `Matcher` <br /> |

|                                                     Returns                                                      ||
|----------------------------------------------------------------------------------------------------------|--------|
| `Matcher<`[ComponentName](https://developer.android.com/reference/android/content/ComponentName.html)`>` | <br /> |

### hasShortClassName

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

<br />

<br />

|            Parameters             ||
|------------------|-----------------|
| `shortClassName` | `String` <br /> |

|                                                     Returns                                                      ||
|----------------------------------------------------------------------------------------------------------|--------|
| `Matcher<`[ComponentName](https://developer.android.com/reference/android/content/ComponentName.html)`>` | <br /> |

-

  ## Classes

  - [BundleMatchers](https://developer.android.com/reference/android/support/test/espresso/intent/matcher/BundleMatchers)
  - [ComponentNameMatchers](https://developer.android.com/reference/android/support/test/espresso/intent/matcher/ComponentNameMatchers)
  - [IntentMatchers](https://developer.android.com/reference/android/support/test/espresso/intent/matcher/IntentMatchers)
  - [UriMatchers](https://developer.android.com/reference/android/support/test/espresso/intent/matcher/UriMatchers)