public final class

IntentCorrespondences

extends java.lang.Object

 java.lang.Object

↳androidx.test.ext.truth.content.IntentCorrespondences

Gradle dependencies

compile group: 'androidx.test.ext', name: 'truth', version: '1.5.0-alpha06'

  • groupId: androidx.test.ext
  • artifactId: truth
  • version: 1.5.0-alpha06

Artifact androidx.test.ext:truth:1.5.0-alpha06 it located at Google repository (https://maven.google.com/)

Overview

Collection of helpers for asserting lists of s.

Summary

Methods
public static <any>action()

public static <any>all(<any> correspondences[])

public static <any>data()

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods

public static <any> action()

public static <any> data()

public static <any> all(<any> correspondences[])

Source

package androidx.test.ext.truth.content;

import android.content.Intent;
import com.google.common.annotations.Beta;
import com.google.common.base.Objects;
import com.google.common.truth.Correspondence;

/**
 * Collection of {@link com.google.common.truth.Correspondence} helpers for asserting lists of
 * {@link Intent}s.
 *
 * @see {@link com.google.common.truth.IterableSubject#comparingElementsUsing(Correspondence)}
 */
public final class IntentCorrespondences {

  private IntentCorrespondences() {}

  public static Correspondence<Intent, Intent> action() {
    return Correspondence.from(
        (actual, expected) -> Objects.equal(actual.getAction(), expected.getAction()),
        "has getAction() equal to");
  }

  public static Correspondence<Intent, Intent> data() {
    return Correspondence.from(
        (actual, expected) -> Objects.equal(actual.getData(), expected.getData()),
        "has getData() equal to");
  }

  @Beta
  public static Correspondence<Intent, Intent> all(
      final Correspondence<Intent, Intent>... correspondences) {
    StringBuilder combinedString = new StringBuilder();
    for (int i = 0; i < correspondences.length; i++) {
      combinedString.append(correspondences[i]);
      if ((i + 1) < correspondences.length) {
        combinedString.append(" and ");
      }
    }
    return Correspondence.from(
        (actual, expected) -> {
          for (Correspondence<Intent, Intent> innerCorrespondence : correspondences) {
            if (!innerCorrespondence.compare(actual, expected)) {
              return false;
            }
          }
          return true;
        },
        combinedString.toString());
  }
}