Signifies that a public API (public class, method or field) is subject to
+ incompatible changes, or even removal, in a future release. An API bearing
+ this annotation is exempt from any compatibility guarantees made by its
+ containing library. Note that the presence of this annotation implies nothing
+ about the quality or performance of the API in question, only the fact that
+ it is not "API-frozen."
+
This annotation should be used along with UiThreadTestRule
+ or with any rule that inherits from it. When the annotation is present, the test method is
+ executed on the application's UI thread (or main thread).
+
+ Note, due to current JUnit limitation, methods annotated with
+ Before and
+ After will
+ also be executed on the UI Thread. Consider using
+ runOnUiThread(Runnable) if this is an
+ issue.
+
+
+
+
@@ -1615,6 +1653,11 @@ From class
strictly required, that this method will be called at test setup time prior to any interaction
with the application under test. When registering more than one resource, ensure that each has
a unique name. If any of the given resources is already registered, a warning is logged.
+
+
Returns
+
true if all resources were successfully registered
+
+
@@ -1772,6 +1815,11 @@ From class
Unregisters one or more IdlingResources. If any of the given resources are not already
registered, a warning is logged.
+
+
Returns
+
true if all resources were successfully unregistered
+
A mechanism for ViewActions to specify what type of views they can operate on.
- A ViewAction can demand that the view passed to perform meets certain constraints. For example
+ A ViewAction can demand that the view passed to perform meets certain constraints. For example
it may want to ensure the view is already in the viewable physical screen of the device or is
of a certain type.
A mechanism for ViewActions to specify what type of views they can operate on.
- A ViewAction can demand that the view passed to perform meets certain constraints. For example
+ A ViewAction can demand that the view passed to perform meets certain constraints. For example
it may want to ensure the view is already in the viewable physical screen of the device or is
of a certain type.
A mechanism for ViewActions to specify what type of views they can operate on.
- A ViewAction can demand that the view passed to perform meets certain constraints. For example
+ A ViewAction can demand that the view passed to perform meets certain constraints. For example
it may want to ensure the view is already in the viewable physical screen of the device or is
of a certain type.
A mechanism for ViewActions to specify what type of views they can operate on.
- A ViewAction can demand that the view passed to perform meets certain constraints. For example
+ A ViewAction can demand that the view passed to perform meets certain constraints. For example
it may want to ensure the view is already in the viewable physical screen of the device or is
of a certain type.
A mechanism for ViewActions to specify what type of views they can operate on.
- A ViewAction can demand that the view passed to perform meets certain constraints. For example
+ A ViewAction can demand that the view passed to perform meets certain constraints. For example
it may want to ensure the view is already in the viewable physical screen of the device or is
of a certain type.
A mechanism for ViewActions to specify what type of views they can operate on.
- A ViewAction can demand that the view passed to perform meets certain constraints. For example
+ A ViewAction can demand that the view passed to perform meets certain constraints. For example
it may want to ensure the view is already in the viewable physical screen of the device or is
of a certain type.
A mechanism for ViewActions to specify what type of views they can operate on.
- A ViewAction can demand that the view passed to perform meets certain constraints. For example
+ A ViewAction can demand that the view passed to perform meets certain constraints. For example
it may want to ensure the view is already in the viewable physical screen of the device or is
of a certain type.
A mechanism for ViewActions to specify what type of views they can operate on.
- A ViewAction can demand that the view passed to perform meets certain constraints. For example
+ A ViewAction can demand that the view passed to perform meets certain constraints. For example
it may want to ensure the view is already in the viewable physical screen of the device or is
of a certain type.
A mechanism for ViewActions to specify what type of views they can operate on.
- A ViewAction can demand that the view passed to perform meets certain constraints. For example
+ A ViewAction can demand that the view passed to perform meets certain constraints. For example
it may want to ensure the view is already in the viewable physical screen of the device or is
of a certain type.
A mechanism for ViewActions to specify what type of views they can operate on.
- A ViewAction can demand that the view passed to perform meets certain constraints. For example
+ A ViewAction can demand that the view passed to perform meets certain constraints. For example
it may want to ensure the view is already in the viewable physical screen of the device or is
of a certain type.
A mechanism for ViewActions to specify what type of views they can operate on.
- A ViewAction can demand that the view passed to perform meets certain constraints. For example
+ A ViewAction can demand that the view passed to perform meets certain constraints. For example
it may want to ensure the view is already in the viewable physical screen of the device or is
of a certain type.
- Same as openLink(Matcher linkTextMatcher, Matcher uriMatcher), but uses
- any(String.class) as the linkTextMatcher.
+ Returns an action that clicks the back button.
@@ -1040,10 +1167,11 @@ Summary:
ViewAction
- Returns an action that clicks the back button.
+ Returns an action that presses the current action button (next, done, search, etc) on the IME
+ (Input Method Editor).
@@ -1063,11 +1191,10 @@ Summary:
ViewAction
- Returns an action that presses the current action button (next, done, search, etc) on the IME
- (Input Method Editor).
+ Returns an action that presses the key specified by the keyCode (eg.
@@ -1110,10 +1237,10 @@ Summary:
ViewAction
- Returns an action that presses the key specified by the keyCode (eg.
+ Returns an action that presses the hardware menu key.
@@ -1130,13 +1257,13 @@ Summary:
static
- ViewAction
+ void
- Returns an action that presses the hardware menu key.
+ Removes the given assertion from the set of assertions to be run before actions are performed.
@@ -1590,6 +1717,138 @@ From class
+
+
+
@@ -681,7 +719,7 @@ Summary:
the RecyclerView. In this case the default behaviour is to expect that the matcher matches 1
and only one item within the RecyclerView.
- This interface gives users the ability to override that type of behaviour and explicitly
+
This interface gives users the ability to override that type of behaviour and explicitly
select an item in the RecyclerView at a given position. This is similar to on the
onData(...).atPosition() api for AdapterViews.
@@ -955,6 +993,10 @@ From interface
+
+
Returns
+
PositionableRecyclerViewAction a new ViewAction focused on a particular position.
Intents enables validation and stubbing of intents sent out by the application under test.
+
An example test that simply validates an outgoing intent:
+
+
+
+ public void testValidateIntentSentToPackage() {
+ // User action that results in an external "phone" activity being launched.
+ user.clickOnView(system.getView(R.id.callButton));
+
+ // Using a canned RecordedIntentMatcher to validate that an intent resolving
+ // to the "phone" activity has been sent.
+ intended(toPackage("com.android.phone"));
+ }
+
+
+
An example test with intent stubbing:
+
+
+
+ public void testActivityResultIsHandledProperly() {
+ // Build a result to return when a particular activity is launched.
+ Intent resultData = new Intent();
+ String phoneNumber = "123-345-6789";
+ resultData.putExtra("phone", phoneNumber);
+ ActivityResult result = new ActivityResult(Activity.RESULT_OK, resultData);
+
+ // Set up result stubbing when an intent sent to "contacts" is seen.
+ intending(toPackage("com.android.contacts")).respondWith(result));
+
+ // User action that results in "contacts" activity being launched.
+ // Launching activity expects phoneNumber to be returned and displays it on the screen.
+ user.clickOnView(system.getView(R.id.pickButton));
+
+ // Assert that data we set up above is shown.
+ assertTrue(user.waitForText(phoneNumber));
+ }
+
Asserts that Intents does not have any unverified intents. You can use this method after you
+ have verified your intents to make sure that nothing unexpected was sent out. This is an
+ equivalent of verifyNoMoreInteractions() in Mockito.
+
+
+
+
+
+
+
+
+
+
+
+ public
+ static
+
+
+
+ void
+
+ init
+ ()
+
+
+
+
+
+
+
+
+
+
+
+
+
Initializes Intents and begins recording intents. Must be called prior to triggering any
+ actions that send out intents which need to be verified or stubbed. This is similar to
+ MockitoAnnotations.initMocks.
+
Asserts that the given matcher matches one and only one intent sent by the application under
+ test. This is an equivalent of verify(mock, times(1)) in Mockito. Verification does not have to
+ occur in the same order as the intents were sent. Intents are recorded from the time that
+ Intents.init is called.
Asserts that the given matcher matches a specified number of intents sent by the application
+ under test. This is an equivalent of verify(mock, times(num)) in Mockito. Verification does
+ not have to occur in the same order as the intents were sent. Intents are recorded from the
+ time that Intents.init is called.
Enables stubbing intent responses. This method is similar to Mockito.when and is particularly
+ useful when the activity launching the intent expects data to be returned (and especially in
+ the case when the destination activity is external). In this case, the test author can call
+ intending(matcher).thenRespond(myResponse) and validate that the launching activity handles the
+ result correctly. Note: the destination activity will not be launched.
+
+
Parameters
+
+
+
matcher
+
the Matcher that matches intents for which stubbed response should be
+ provided
A sneaky singleton object used to respond to intents with fake responses.
+ This interface is not meant for public consumption. Test authors should use Intents
+ instead.
+
+ Sets the result that will be returned to the intent sender (if the sender expects the
+ result), next time an intent matched by the given matcher is launched.
+
+
+
+
Sets the result that will be returned to the intent sender (if the sender expects the
+ result), next time an intent matched by the given matcher is launched.
+
+ Sets the result that will be returned to the intent sender (if the sender expects the
+ result), next time an intent matched by the given matcher is launched.
+
+
+
+
+ Sets the result that will be returned to the intent sender (if the sender expects the
+ result), next time an intent matched by the given matcher is launched.
+
+
+
+
Returns the first matching stubbed result for the given activity if stubbed result was set
+ by test author. The method searches the list of existing matcher/response pairs in reverse
+ order of which they were entered; i.e. the last stubbing has the highest priority. If no
+ stubbed result matching the given intent is found, null is returned.
+
+ Must be called on main thread.
+
+
+
+
+
+
+
+
+
+
+
+ public
+
+
+
+
+ void
+
+ initialize
+ ()
+
+
+
+
+
+
+
+
+
+
+
+
+
Marks this spy as initialized. Once initialized, ResettingStubber begins recording intents
+ and provides intent stubbing.
+
Sets the result that will be returned to the intent sender (if the sender expects the
+ result), next time an intent matched by the given matcher is launched.
+
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
+
a componentName that has the target class specified
+
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").
This rule makes it easy to use Espresso-Intents APIs in functional UI tests. This class is an
+ extension of ActivityTestRule, which initializes Espresso-Intents before each test
+ annotated with
+ Test and releases
+ Espresso-Intents after each test run. The Activity will be terminated after each test and this
+ rule can be used in the same way as ActivityTestRule.
+
+
+ Espresso-Intents APIs can be used in two ways:
+
+ Override this method to execute any code that should run after your Activity is
+ launched, but before any test code is run including any method annotated with
+ Before.
+
+
+
+
+ Override this method to execute any code that should run after your Activity is
+ launched, but before any test code is run including any method annotated with
+ Before.
+
+
+
+
Override this method to execute any code that should run after your Activity is
+ finished.
+ This method is called after each test method, including any method annotated with
+ After.
+
Override this method to execute any code that should run after your Activity is
+ launched, but before any test code is run including any method annotated with
+ Before.
+
+ Prefer
+ Before
+ over this method. This method should usually not be overwritten directly in tests and only be
+ used by subclasses of ActivityTestRule to get notified when the activity is created and
+ visible but test runs.
+
Allows test authors to override whether the the matcher should throw an
+ IllegalArgumentException if the column name/count is not valid. This is useful in the
+ case where a cursor may iterates over a data set with variable columns. By default, the
+ checks are on.
+
@@ -598,6 +637,9 @@ type="text/css">
Summary:
+ Nested Classes
+
+
@@ -608,7 +650,7 @@ Summary:
- Methods
+ | Methods
@@ -693,8 +735,8 @@ Summary:
AdapterViews that are backed by a Cursor are very common. This class contains
Matchers that can be used together with
- onData(Matcher) to match a data row in a
- Cursor.
+ onData(Matcher) to match a
+ data row in a Cursor.
The Matchers can only operate on a single data row of the cursor and Espresso
internally moves the Cursor to the correct adapter position.
@@ -729,6 +771,31 @@ Summary:
+
+
- Returns a
- Matcher that matches a byte[] at a given column index in a Cursors
- data row.
+ Returns a matcher that matches a byte[] at a given column index
+ in a Cursors data row.
@@ -791,15 +857,14 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a byte[] at a given column index in a
- Cursors data row.
+ Returns a matcher that matches a byte[] at a given column index
+ in a Cursors data row.
@@ -816,15 +881,14 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a byte[] at a given column index in a
- Cursors data row.
+ Returns a matcher that matches a byte[] at a given column index
+ in a Cursors data row.
@@ -841,15 +905,14 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a byte[] at a given column index in a
- Cursors data row.
+ Returns a matcher that matches a byte[] at a given column index
+ in a Cursors data row.
@@ -866,15 +929,14 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a byte[] at a given column index in a
- Cursors data row.
+ Returns a matcher that matches a byte[] at a given column index
+ in a Cursors data row.
@@ -891,15 +953,14 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a Double value at a given column index in a
- Cursors data row.
+ Returns a matcher that matches a Double value at a given column index
+ in a Cursors data row.
@@ -916,15 +977,14 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a Double value at a given column index in a
- Cursors data row.
+ Returns a matcher that matches a Double value at a given column index
+ in a Cursors data row.
@@ -941,15 +1001,14 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a Double value at a given column index in a
- Cursors data row.
+ Returns a matcher that matches a Double value at a given column index
+ in a Cursors data row.
@@ -966,15 +1025,14 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a Double value at a given column index in a
- Cursors data row.
+ Returns a matcher that matches a Double value at a given column index
+ in a Cursors data row.
@@ -991,15 +1049,14 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a Double value at a given column index in a
- Cursors data row.
+ Returns a matcher that matches a Double value at a given column index
+ in a Cursors data row.
@@ -1016,14 +1073,13 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a Float value at a given column index
+ Returns a matcher that matches a Float value at a given column index
in a Cursors data row.
@@ -1041,14 +1097,13 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a Float value at a given column index
+ Returns a matcher that matches a Float value at a given column index
in a Cursors data row.
@@ -1066,14 +1121,13 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a Matcher that matches a Float value at a given column index
+ Returns a matcher that matches a Float value at a given column index
in a Cursors data row.
@@ -1091,14 +1145,13 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a Float value at a given column index
+ Returns a matcher that matches a Float value at a given column index
in a Cursors data row.
@@ -1116,14 +1169,13 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a Float value at a given column index
+ Returns a matcher that matches a Float value at a given column index
in a Cursors data row.
@@ -1141,14 +1193,13 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a Integer value at a given column index
+ Returns a matcher that matches a Integer value at a given column index
in a Cursors data row.
@@ -1166,14 +1217,13 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a Integer value at a given column index
+ Returns a matcher that matches a Integer value at a given column index
in a Cursors data row.
@@ -1191,14 +1241,13 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a Integer value at a given column index
+ Returns a matcher that matches a Integer value at a given column index
in a Cursors data row.
@@ -1216,14 +1265,13 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a Integer value at a given column index
+ Returns a matcher that matches a Integer value at a given column index
in a Cursors data row.
@@ -1241,14 +1289,13 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a Integer value at a given column index
+ Returns a matcher that matches a Integer value at a given column index
in a Cursors data row.
@@ -1266,14 +1313,13 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a Long value at a given column index
+ Returns a matcher that matches a Long value at a given column index
in a Cursors data row.
@@ -1291,15 +1337,14 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a Long value at a given column index in a
- Cursors data row.
+ Returns a matcher that matches a Long value at a given column index
+ in a Cursors data row.
@@ -1316,14 +1361,13 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a Long value at a given column index
+ Returns a matcher that matches a Long value at a given column index
in a Cursors data row.
@@ -1341,15 +1385,14 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a Long value at a given column index
- in a Cursors data row.
+ Returns a matcher that matches a Long value at a given column index in a
+ Cursors data row.
@@ -1366,14 +1409,13 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a Long value at a given column index
+ Returns a matcher that matches a Long value at a given column index
in a Cursors data row.
@@ -1391,14 +1433,13 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a Short value at a given column index
+ Returns a matcher that matches a Short value at a given column index
in a Cursors data row.
@@ -1416,14 +1457,13 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a Short value at a given column index
+ Returns a matcher that matches a Short value at a given column index
in a Cursors data row.
@@ -1441,14 +1481,13 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a Short value at a given column index
+ Returns a matcher that matches a Short value at a given column index
in a Cursors data row.
@@ -1466,14 +1505,13 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a Short value at a given column index
+ Returns a matcher that matches a Short value at a given column index
in a Cursors data row.
@@ -1491,14 +1529,13 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a Short value at a given column index
+ Returns a matcher that matches a Short value at a given column index
in a Cursors data row.
@@ -1516,14 +1553,13 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a String value at a given column index
+ Returns a matcher that matches a String value at a given column index
in a Cursors data row.
@@ -1541,14 +1577,13 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a String value at a given column index
+ Returns a matcher that matches a String value at a given column index
in a Cursors data row.
@@ -1566,14 +1601,13 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a String value at a given column index
+ Returns a matcher that matches a String value at a given column index
in a Cursors data row.
@@ -1591,14 +1625,13 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a String value at a given column index
+ Returns a matcher that matches a String value at a given column index
in a Cursors data row.
@@ -1616,14 +1649,13 @@ Summary:
static
- Matcher<Object>
+ CursorMatchers.CursorMatcher
- Returns a
- Matcher that matches a String value at a given column index
+ Returns a matcher that matches a String value at a given column index
in a Cursors data row.
@@ -1901,7 +1933,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowBlob(String columnName, byte[] value)
@@ -1917,9 +1949,8 @@ From class
-
Returns a
- Matcher that matches a byte[] at a given column index in a Cursors
- data row.
+
Returns a matcher that matches a byte[] at a given column index
+ in a Cursors data row.
Parameters
@@ -1950,7 +1981,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowBlob(int columnIndex, Matcher<byte[]> valueMatcher)
@@ -1966,9 +1997,8 @@ From class
-
Returns a
- Matcher that matches a byte[] at a given column index in a
- Cursors data row.
+
Returns a matcher that matches a byte[] at a given column index
+ in a Cursors data row.
@@ -2000,7 +2031,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowBlob(int columnIndex, byte[] value)
@@ -2016,9 +2047,8 @@ From class
-
Returns a
- Matcher that matches a byte[] at a given column index in a
- Cursors data row.
+
Returns a matcher that matches a byte[] at a given column index
+ in a Cursors data row.
Parameters
@@ -2049,7 +2079,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowBlob(String columnName, Matcher<byte[]> valueMatcher)
@@ -2065,9 +2095,8 @@ From class
-
Returns a
- Matcher that matches a byte[] at a given column index in a
- Cursors data row.
+
Returns a matcher that matches a byte[] at a given column index
+ in a Cursors data row.
@@ -2099,7 +2129,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowBlob(Matcher<String> columnPicker, Matcher<byte[]> valueMatcher)
@@ -2115,22 +2145,23 @@ From class
-
Returns a
- Matcher that matches a byte[] at a given column index in a
- Cursors data row.
+
Returns a matcher that matches a byte[] at a given column index
+ in a Cursors data row.
@@ -2150,7 +2181,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowDouble(String columnName, double value)
@@ -2166,9 +2197,8 @@ From class
-
Returns a
- Matcher that matches a Double value at a given column index in a
- Cursors data row.
+
Returns a matcher that matches a Double value at a given column index
+ in a Cursors data row.
Parameters
@@ -2199,7 +2229,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowDouble(String columnName, Matcher<Double> valueMatcher)
@@ -2215,9 +2245,8 @@ From class
-
Returns a
- Matcher that matches a Double value at a given column index in a
- Cursors data row.
+
Returns a matcher that matches a Double value at a given column index
+ in a Cursors data row.
@@ -2249,7 +2279,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowDouble(int columnIndex, double value)
@@ -2265,9 +2295,8 @@ From class
-
Returns a
- Matcher that matches a Double value at a given column index in a
- Cursors data row.
+
Returns a matcher that matches a Double value at a given column index
+ in a Cursors data row.
Parameters
@@ -2298,7 +2327,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowDouble(Matcher<String> columnNameMatcher, Matcher<Double> valueMatcher)
@@ -2314,22 +2343,23 @@ From class
-
Returns a
- Matcher that matches a Double value at a given column index in a
- Cursors data row.
+
Returns a matcher that matches a Double value at a given column index
+ in a Cursors data row.
@@ -2349,7 +2379,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowDouble(int columnIndex, Matcher<Double> valueMatcher)
@@ -2365,9 +2395,8 @@ From class
-
Returns a
- Matcher that matches a Double value at a given column index in a
- Cursors data row.
+
Returns a matcher that matches a Double value at a given column index
+ in a Cursors data row.
@@ -2399,7 +2429,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowFloat(String columnName, Matcher<Float> valueMatcher)
@@ -2415,8 +2445,7 @@ From class
-
Returns a
- Matcher that matches a Float value at a given column index
+
Returns a matcher that matches a Float value at a given column index
in a Cursors data row.
@@ -2449,7 +2479,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowFloat(int columnIndex, float value)
@@ -2465,8 +2495,7 @@ From class
-
Returns a
- Matcher that matches a Float value at a given column index
+
Returns a matcher that matches a Float value at a given column index
in a Cursors data row.
@@ -2498,7 +2527,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowFloat(String columnName, float value)
@@ -2514,8 +2543,7 @@ From class
-
Returns a Matcher that matches a Float value at a given column index
+
Returns a matcher that matches a Float value at a given column index
in a Cursors data row.
@@ -2547,7 +2575,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowFloat(Matcher<String> columnNameMatcher, Matcher<Float> valueMatcher)
@@ -2563,8 +2591,7 @@ From class
-
Returns a
- Matcher that matches a Float value at a given column index
+
Returns a matcher that matches a Float value at a given column index
in a Cursors data row.
@@ -2598,7 +2627,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowFloat(int columnIndex, Matcher<Float> valueMatcher)
@@ -2614,8 +2643,7 @@ From class
-
Returns a
- Matcher that matches a Float value at a given column index
+
Returns a matcher that matches a Float value at a given column index
in a Cursors data row.
@@ -2648,7 +2677,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowInt(String columnName, Matcher<Integer> valueMatcher)
@@ -2664,8 +2693,7 @@ From class
-
Returns a
- Matcher that matches a Integer value at a given column index
+
Returns a matcher that matches a Integer value at a given column index
in a Cursors data row.
@@ -2698,7 +2727,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowInt(int columnIndex, int value)
@@ -2714,8 +2743,7 @@ From class
-
Returns a
- Matcher that matches a Integer value at a given column index
+
Returns a matcher that matches a Integer value at a given column index
in a Cursors data row.
@@ -2747,7 +2775,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowInt(String columnName, int value)
@@ -2763,8 +2791,7 @@ From class
-
Returns a
- Matcher that matches a Integer value at a given column index
+
Returns a matcher that matches a Integer value at a given column index
in a Cursors data row.
@@ -2796,7 +2823,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowInt(int columnIndex, Matcher<Integer> valueMatcher)
@@ -2812,8 +2839,7 @@ From class
-
Returns a
- Matcher that matches a Integer value at a given column index
+
Returns a matcher that matches a Integer value at a given column index
in a Cursors data row.
@@ -2846,7 +2873,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowInt(Matcher<String> columnNameMatcher, Matcher<Integer> valueMatcher)
@@ -2862,8 +2889,7 @@ From class
-
Returns a
- Matcher that matches a Integer value at a given column index
+
Returns a matcher that matches a Integer value at a given column index
in a Cursors data row.
@@ -2897,7 +2925,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowLong(int columnIndex, Matcher<Long> valueMatcher)
@@ -2913,8 +2941,7 @@ From class
-
Returns a
- Matcher that matches a Long value at a given column index
+
Returns a matcher that matches a Long value at a given column index
in a Cursors data row.
@@ -2947,7 +2975,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowLong(int columnIndex, long value)
@@ -2963,9 +2991,8 @@ From class
-
Returns a
- Matcher that matches a Long value at a given column index in a
- Cursors data row.
+
Returns a matcher that matches a Long value at a given column index
+ in a Cursors data row.
Parameters
@@ -2996,7 +3023,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowLong(String columnName, long value)
@@ -3012,8 +3039,7 @@ From class
-
Returns a
- Matcher that matches a Long value at a given column index
+
Returns a matcher that matches a Long value at a given column index
in a Cursors data row.
@@ -3045,7 +3071,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowLong(String columnName, Matcher<Long> valueMatcher)
@@ -3061,9 +3087,8 @@ From class
-
Returns a
- Matcher that matches a Long value at a given column index
- in a Cursors data row.
+
Returns a matcher that matches a Long value at a given column index in a
+ Cursors data row.
@@ -3095,7 +3121,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowLong(Matcher<String> columnNameMatcher, Matcher<Long> valueMatcher)
@@ -3111,8 +3137,7 @@ From class
-
Returns a
- Matcher that matches a Long value at a given column index
+
Returns a matcher that matches a Long value at a given column index
in a Cursors data row.
@@ -3146,7 +3173,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowShort(int columnIndex, Matcher<Short> valueMatcher)
@@ -3162,8 +3189,7 @@ From class
-
Returns a
- Matcher that matches a Short value at a given column index
+
Returns a matcher that matches a Short value at a given column index
in a Cursors data row.
@@ -3196,7 +3223,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowShort(String columnName, Matcher<Short> valueMatcher)
@@ -3212,8 +3239,7 @@ From class
-
Returns a
- Matcher that matches a Short value at a given column index
+
Returns a matcher that matches a Short value at a given column index
in a Cursors data row.
@@ -3246,7 +3273,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowShort(String columnName, short value)
@@ -3262,8 +3289,7 @@ From class
-
Returns a
- Matcher that matches a Short value at a given column index
+
Returns a matcher that matches a Short value at a given column index
in a Cursors data row.
@@ -3295,7 +3321,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowShort(Matcher<String> columnNameMatcher, Matcher<Short> valueMatcher)
@@ -3311,8 +3337,7 @@ From class
-
Returns a
- Matcher that matches a Short value at a given column index
+
Returns a matcher that matches a Short value at a given column index
in a Cursors data row.
@@ -3346,7 +3373,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowShort(int columnIndex, short value)
@@ -3362,8 +3389,7 @@ From class
-
Returns a
- Matcher that matches a Short value at a given column index
+
Returns a matcher that matches a Short value at a given column index
in a Cursors data row.
@@ -3395,7 +3421,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowString(String columnName, String value)
@@ -3411,8 +3437,7 @@ From class
-
Returns a
- Matcher that matches a String value at a given column index
+
Returns a matcher that matches a String value at a given column index
in a Cursors data row.
@@ -3444,7 +3469,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowString(int columnIndex, Matcher<String> valueMatcher)
@@ -3460,8 +3485,7 @@ From class
-
Returns a
- Matcher that matches a String value at a given column index
+
Returns a matcher that matches a String value at a given column index
in a Cursors data row.
@@ -3494,7 +3519,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowString(int columnIndex, String value)
@@ -3510,8 +3535,7 @@ From class
-
Returns a
- Matcher that matches a String value at a given column index
+
Returns a matcher that matches a String value at a given column index
in a Cursors data row.
@@ -3543,7 +3567,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowString(String columnName, Matcher<String> valueMatcher)
@@ -3559,8 +3583,7 @@ From class
-
Returns a
- Matcher that matches a String value at a given column index
+
Returns a matcher that matches a String value at a given column index
in a Cursors data row.
@@ -3593,7 +3617,7 @@ From class
- Matcher<Object>
+ CursorMatchers.CursorMatcherwithRowString(Matcher<String> columnPicker, Matcher<String> valueMatcher)
@@ -3609,8 +3633,7 @@ From class
-
Returns a
- Matcher that matches a String value at a given column index
+
Returns a matcher that matches a String value at a given column index
in a Cursors data row.
- Returns a matcher that matches Views based on the presence of a descendant in its
- view hierarchy.
+ Returns a matcher that matches Views based on the presence of a descendant in its view
+ hierarchy.
@@ -1023,8 +1062,8 @@ Summary:
isChecked()
- Returns a matcher that accepts if and only if the view is a CompoundButton (or subtype of)
- and is in checked state.
+ Returns a matcher that accepts if and only if the view is a CompoundButton (or subtype of) and
+ is in checked state.
@@ -1117,8 +1156,8 @@ Summary:
isDisplayed()
- Returns a matcher that matches Views that are currently displayed on the screen to
- the user.
+ Returns a matcher that matches Views that are currently displayed on the screen to the
+ user.
@@ -1234,8 +1273,8 @@ Summary:
isNotChecked()
- Returns a matcher that accepts if and only if the view is a CompoundButton (or subtype of)
- and is not in checked state.
+ Returns a matcher that accepts if and only if the view is a CompoundButton (or subtype of) and
+ is not in checked state.
@@ -1375,8 +1414,8 @@ Summary:
Returns an
- Matcher that matches Views based on content description
- property value.
+ Matcher that matches Views based on content description property
+ value.
@@ -1400,8 +1439,8 @@ Summary:
Returns an
- Matcher that matches Views based on content description
- property value.
+ Matcher that matches Views based on content description property
+ value.
@@ -1421,11 +1460,12 @@ Summary:
Matcher<View>
- Returns a matcher that matches Views that have "effective" visibility set to the
- given value.
+ Returns a
+ Matcher that matches Views based on content description property
+ value.
@@ -1440,6 +1480,30 @@ Summary:
+ static
+
+ Matcher<View>
+
Returns a matcher that matches Views based on the presence of a descendant in its
- view hierarchy.
+
Returns a matcher that matches Views based on the presence of a descendant in its view
+ hierarchy.
Parameters
@@ -2397,16 +2461,17 @@ From class
Matcher that matches Views based on their siblings.
This may be particularly useful when a view cannot be uniquely selected on properties such as
- text or R.id. For example: a call button is repeated several times in a contacts layout
- and the only way to differentiate the call button view is by what appears next to it (e.g.
- the unique name of the contact).
+ text or R.id. For example: a call button is repeated several times in a contacts layout and the
+ only way to differentiate the call button view is by what appears next to it (e.g. the unique
+ name of the contact).
Returns a matcher that accepts if and only if the view is a CompoundButton (or subtype of)
- and is in checked state.
+
Returns a matcher that accepts if and only if the view is a CompoundButton (or subtype of) and
+ is in checked state.
@@ -2546,7 +2611,7 @@ From class
Returns a matcher which only accepts a view whose height and width fit perfectly within
the currently displayed region of this view.
-
+
There exist views (such as ScrollViews) whose height and width are larger then the physical
device screen by design. Such views will _never_ be completely displayed.
@@ -2623,13 +2688,12 @@ From class
-
Returns a matcher that matches Views that are currently displayed on the screen to
- the user.
-
- Note: isDisplayed will select views that are partially displayed (eg: the full
- height/width of the view is greater then the height/width of the visible rectangle).
- If you wish to ensure the entire rectangle this view draws is displayed to the user use
- isCompletelyDisplayed.
+
Returns a matcher that matches Views that are currently displayed on the screen to the
+ user.
+
+ Note: isDisplayed will select views that are partially displayed (eg: the full height/width of
+ the view is greater then the height/width of the visible rectangle). If you wish to ensure the
+ entire rectangle this view draws is displayed to the user use isCompletelyDisplayed.
@@ -2670,7 +2734,7 @@ From class
areaPercentage
an integer ranging from (0, 100] indicating how much percent of the
- surface area of the view must be shown to the user to be accepted.
+ surface area of the view must be shown to the user to be accepted.
@@ -2805,8 +2869,8 @@ From class
-
Returns a matcher that accepts if and only if the view is a CompoundButton (or subtype of)
- and is not in checked state.
+
Returns a matcher that accepts if and only if the view is a CompoundButton (or subtype of) and
+ is not in checked state.
@@ -3015,8 +3079,8 @@ From class
Returns an
- Matcher that matches Views based on content description
- property value. Sugar for withContentDescription(is("string")).
+ Matcher that matches Views based on content description property
+ value. Sugar for withContentDescription(is("string")).
Parameters
@@ -3059,15 +3123,60 @@ From class
Returns an
- Matcher that matches Views based on content description
- property value.
+ Matcher that matches Views based on content description property
+ value.
Returns a
+ Matcher that matches Views based on content description property
+ value.
+
+
Parameters
+
+
+
resourceId
+
the resource id of the content description to match on.
@@ -3103,15 +3212,16 @@ From class
-
Returns a matcher that matches Views that have "effective" visibility set to the
- given value. Effective visibility takes into account not only the view's visibility value,
- but also that of its ancestors. In case of View.VISIBLE, this means that the view and all of
- its ancestors have visibility=VISIBLE. In case of GONE and INVISIBLE, it's the opposite -
- any GONE or INVISIBLE parent will make all of its children have their effective visibility.
-
+
Returns a matcher that matches Views that have "effective" visibility set to the given
+ value. Effective visibility takes into account not only the view's visibility value, but also
+ that of its ancestors. In case of View.VISIBLE, this means that the view and all of its
+ ancestors have visibility=VISIBLE. In case of GONE and INVISIBLE, it's the opposite - any GONE
+ or INVISIBLE parent will make all of its children have their effective visibility.
+
+
+
Note: Contrary to what the name may imply, view visibility does not directly translate into
- whether the view is displayed on screen (use isDisplayed() for that). For example,
- the view and
+ whether the view is displayed on screen (use isDisplayed() for that). For example, the view and
all of its ancestors can have visibility=VISIBLE, but the view may need to be scrolled to in
order to be actually visible to the user. Unless you're specifically targeting the visibility
value with your test, use isDisplayed.
@@ -3198,7 +3308,7 @@ From class
Returns a matcher that matches Views based on resource ids. Note: Android resource
- ids are not guaranteed to be unique. You may have to pair this matcher with another one to
+
Returns a matcher that matches Views based on resource ids. Note: Android resource ids
+ are not guaranteed to be unique. You may have to pair this matcher with another one to
guarantee a unique view selection.
Parameters
@@ -3401,7 +3521,7 @@ From class
Returns a matcher that matches Spinner based on it's selected item's toString value.
-
Returns a matcher that matches TextViews based on text property value. Note: View's
- text property is never null. If you setText(null) it will still be "". Do not use null
- matcher.
+ text property is never null. If you setText(null) it will still be "". Do not use null matcher.
+ This rule makes it easy to use Espresso-Intents APIs in functional UI tests.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Class Overview
+
This rule provides functional testing of a single activity. The activity under test will be
+ launched before each test annotated with
+ Test and before
+ methods annotated with
+ Before. It
+ will be terminated after the test is completed and methods annotated with
+ After are
+ finished. During the duration of the test you will be able to manipulate your Activity directly.
+ Override this method to execute any code that should run after your Activity is
+ launched, but before any test code is run including any method annotated with
+ Before.
+
+
+
+
Similar to ActivityTestRule(Class, boolean, boolean) but defaults to launch the
+ activity under test once per
+ Test method.
+ It is launched before the first
+ Before
+ method, and terminated after the last
+ After
+ method.
+
+
Parameters
+
+
+
activityClass
+
The activity under test. This must be a class in the instrumentation
+ targetPackage specified in the AndroidManifest.xml
+
+
+
initialTouchMode
+
true if the Activity should be placed into "touch mode" when started
The activity under test. This must be a class in the instrumentation
+ targetPackage specified in the AndroidManifest.xml
+
+
+
initialTouchMode
+
true if the Activity should be placed into "touch mode" when started
+
+
+
launchActivity
+
true if the Activity should be launched once per
+
+ Test method. It will be launched before the first
+
+ Before method, and terminated after the last
+
+ After method.
+
+
+ public
+
+
+
+
+ T
+
+ launchActivity
+ (Intent startIntent)
+
+
+
+
+
+
+
+
+
+
+
+
+
Launches the Activity under test.
+
+ Don't call this method directly, unless you explicitly requested not to launch the Activity
+ manually using the launchActivity flag in
+ ActivityTestRule(Class, boolean, boolean).
+
+ Usage:
+
+ @Test
+ public void customIntentToStartActivity() {
+ Intent intent = new Intent(Intent.ACTION_PICK);
+ mActivity = mActivityRule.launchActivity(intent);
+ }
+
+
+
Parameters
+
+
+
startIntent
+
The Intent that will be used to start the Activity under test. If
+ startIntent is null, the Intent returned by
+ getActivityIntent() is used.
Override this method to execute any code that should run after your Activity is
+ finished.
+ This method is called after each test method, including any method annotated with
+ After.
+
Override this method to execute any code that should run after your Activity is
+ launched, but before any test code is run including any method annotated with
+ Before.
+
+ Prefer
+ Before
+ over this method. This method should usually not be overwritten directly in tests and only be
+ used by subclasses of ActivityTestRule to get notified when the activity is created and
+ visible but test runs.
+
Override this method to execute any code that should run before your Activity is
+ created and launched.
+ This method is called before each test method, including any method annotated with
+ Before.
+
+ The default Intent (if this method returns null or is not overwritten) is:
+ action = ACTION_MAIN
+ flags = FLAG_ACTIVITY_NEW_TASK
+ All other intent fields are null or empty.
A JUnit rule that provides a simplified mechanism to start and shutdown your service before
+ and after the duration of your test. It also guarantees that the service is successfully
+ connected when starting (or binding to) a service. The service can be started
+ (or bound) using one of the helper methods. It will automatically be stopped (or unbound) after
+ the test completes and any methods annotated with
+ After are
+ finished.
+
+ Note: This rule doesn't support IntentService because it's automatically
+ destroyed when onHandleIntent(android.content.Intent) finishes
+ all outstanding commands. So there is no guarantee to establish a successful connection
+ in a timely manner.
+
+
+ Usage:
+
+ @Rule
+ public final ServiceTestRule mServiceRule = new ServiceTestRule();
+
+ @Test
+ public void testWithStartedService() {
+ mServiceRule.startService(
+ new Intent(InstrumentationRegistry.getTargetContext(), MyService.class));
+ //do something
+ }
+
+ @Test
+ public void testWithBoundService() {
+ IBinder binder = mServiceRule.bindService(
+ new Intent(InstrumentationRegistry.getTargetContext(), MyService.class));
+ MyService service = ((MyService.LocalBinder) binder).getService();
+ assertTrue("True wasn't returned", service.doSomethingToReturnTrue());
+ }
+
+ Starts the service under test and blocks until the service is connected, in the same way as
+ if it were started by Context.startService(Intent) with an Intent that identifies a
+ service.
+
+
+
+
Identifies the service to connect to. The Intent may
+ specify either an explicit component name, or a logical
+ description (action, category, etc) to match an
+ IntentFilter published by a service.
+
+
+
connection
+
Receives information as the service is started and stopped.
+ This must be a valid ServiceConnection object; it must not be null.
Starts the service under test and blocks until the service is connected, in the same way as
+ if it were started by Context.startService(Intent) with an Intent that identifies a
+ service. If you use this method to start the service, it is automatically stopped at the
+ end of the test run. However, it also binds to the service and waits for
+ onServiceConnected(android.content.ComponentName, android.os.IBinder) to be called to ensure successful connection.
Override this method to do your own service specific clean up after the service is shutdown.
+ The method is called after each test method is executed including any method annotated with
+ After
+ and after necessary calls to stop (or unbind) the service under test were called.
+
Override this method to do your own service specific initialization before starting or
+ binding to the service. The method is called before each test method is executed including
+ any method annotated with
+ Before.
+ Do not start or bind to a service from here!
+
Helper for running portions of a test on the UI thread.
+
+ Note, in most cases it is simpler to annotate the test method with
+ UiThreadTest, which will run the entire test method including methods annotated with
+ Before
+ and
+ After on the UI thread.
+
+ Use this method if you need to switch in and out of the UI thread to perform your test.
@@ -836,11 +870,6 @@ Summary:
RunListeners to observe the test run:
-e listener com.foo.Listener,com.foo.Listener2
- OR, specify the multiple listeners in the AndroidManifest via a meta-data tag:
- instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" ...
- meta-data android:name="listener"
- android:value="com.foo.Listener,com.foo.Listener2"
-
Set timeout (in milliseconds) that will be applied to each test:
-e timeout_msec 5000
@@ -857,6 +886,18 @@ Summary:
To disable Google Analytics:
-e disableAnalytics true
+
+ In order to make sure we are on the right track with each new release,
+ the test runner collects analytics. More specifically, it uploads a hash of the package name
+ of the application under test for each invocation. This allows us to measure both the count of
+ unique packages using this library as well as the volume of usage.
+
+ All arguments can also be specified in the in the AndroidManifest via a meta-data tag:
+ eg. using listeners:
+ instrumentation android:name="android.support.test.runner.AndroidJUnitRunner" ...
+ meta-data android:name="listener"
+ android:value="com.foo.Listener,com.foo.Listener2"
+ Arguments specified via shell will take override manifest specified arguments.
@@ -897,27 +938,6 @@ Summary:
-
-
- This implementation of onStart() will guarantee that the Application's onCreate method
- has completed when it returns.
+ Sets up lifecycle monitoring, and argument registry.
@@ -1395,13 +1487,53 @@ From class
Returns the first matching stubbed result for the given activity if stubbed result was set
+ by test author. The method searches the list of existing matcher/response pairs in reverse
+ order of which they were entered; i.e. the last stubbing has the highest priority. If no
+ stubbed result matching the given intent is found, null is returned.
+
+ Called on after an application has processed its lifecycle change event
+ (for example onCreate)
+ These callbacks may occur on main thread so implementers should limit the amount of
+ processing performed
+
+
+
+
Called on after an application has processed its lifecycle change event
+ (for example onCreate)
+ These callbacks may occur on main thread so implementers should limit the amount of
+ processing performed
Interface for tests to use when they need to be informed of the application lifecycle state.
+
+ Retrieve instances of the monitor thru ApplicationLifecycleMonitorRegistry.
+
+
+ Detecting these lifecycle states requires support from Instrumentation, therefore do not expect
+ an instance to be present under any arbitrary instrumentation.
+
Adds a new callback that will be notified when lifecycle changes occur.
+
+ Implementors will not hold a strong ref to the callback, the code which registers callbacks
+ is responsible for this. Code which registers callbacks should responsibly
+ remove their callback when it is no longer needed.
+
+
+ Callbacks may be executed on the main thread of the application, and should take care not to
+ block or otherwise perform expensive operations as it will directly impact the application.
+