public interface

ResettingStubber

implements IntentStubber

 androidx.test.espresso.intent.ResettingStubber

Subclasses:

ResettingStubberImpl

Gradle dependencies

compile group: 'androidx.test.espresso', name: 'espresso-intents', version: '3.6.1'

  • groupId: androidx.test.espresso
  • artifactId: espresso-intents
  • version: 3.6.1

Artifact androidx.test.espresso:espresso-intents:3.6.1 it located at Google repository (https://maven.google.com/)

Androidx artifact mapping:

androidx.test.espresso:espresso-intents com.android.support.test.espresso:espresso-intents

Androidx class mapping:

androidx.test.espresso.intent.ResettingStubber android.support.test.espresso.intent.ResettingStubber

Overview

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.

Summary

Methods
public voidinitialize()

Marks this spy as initialized.

public booleanisInitialized()

public voidreset()

Clears state (initialization, expected responses).

public voidsetActivityResultForIntent(<any> matcher, ActivityResult result)

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.

public voidsetActivityResultFunctionForIntent(<any> matcher, ActivityResultFunction result)

Sets a result function that will be called by the intent sender (if the sender expects the result), next time an intent matched by the given matcher is launched.

Methods

public void setActivityResultForIntent(<any> matcher, ActivityResult result)

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.

public void setActivityResultFunctionForIntent(<any> matcher, ActivityResultFunction result)

Sets a result function that will be called by the intent sender (if the sender expects the result), next time an intent matched by the given matcher is launched.

public void initialize()

Marks this spy as initialized. Once initialized, ResettingStubber begins recording intents and provides intent stubbing.

public boolean isInitialized()

Returns:

true if this spy is initialized

public void reset()

Clears state (initialization, expected responses).

Must be called on main thread.

Source

/*
 * Copyright (C) 2015 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.test.espresso.intent;

import android.app.Instrumentation.ActivityResult;
import android.content.Intent;
import androidx.test.runner.intent.IntentStubber;
import org.hamcrest.Matcher;

/**
 * A sneaky singleton object used to respond to intents with fake responses. This interface is not
 * meant for public consumption. Test authors should use {@link Intents} instead.
 */
public interface ResettingStubber extends IntentStubber {

  /**
   * 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.
   */
  public void setActivityResultForIntent(Matcher<Intent> matcher, ActivityResult result);

  /**
   * Sets a result function that will be called by the intent sender (if the sender expects the
   * result), next time an intent matched by the given matcher is launched.
   */
  public void setActivityResultFunctionForIntent(
      Matcher<Intent> matcher, ActivityResultFunction result);

  /**
   * Marks this spy as initialized. Once initialized, ResettingStubber begins recording intents and
   * provides intent stubbing.
   */
  public void initialize();

  /** @return {@code true} if this spy is initialized */
  public boolean isInitialized();

  /**
   * Clears state (initialization, expected responses).
   *
   * <p>Must be called on main thread.
   */
  public void reset();
}