public final class

SwipeRemoteMessage

extends java.lang.Object

implements EspressoRemoteMessage.To<ViewActions.SwipeViewActionProto.Swipe>

 java.lang.Object

↳androidx.test.espresso.action.SwipeRemoteMessage

Gradle dependencies

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

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

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

Androidx artifact mapping:

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

Androidx class mapping:

androidx.test.espresso.action.SwipeRemoteMessage android.support.test.espresso.action.SwipeRemoteMessage

Overview

and implementation of Swipe.

Summary

Fields
public static final EspressoRemoteMessage.From<Swiper, ViewActions.SwipeViewActionProto.Swipe>FROM

This field is used to create an instance of Tapper from its unwrapped proto message.

Constructors
publicSwipeRemoteMessage(Swipe swipe)

Methods
public ViewActions.SwipeViewActionProto.SwipetoProto()

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

Fields

public static final EspressoRemoteMessage.From<Swiper, ViewActions.SwipeViewActionProto.Swipe> FROM

This field is used to create an instance of Tapper from its unwrapped proto message.

Constructors

public SwipeRemoteMessage(Swipe swipe)

Methods

Source

/*
 * Copyright (C) 2017 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.action;

import static androidx.test.internal.util.Checks.checkNotNull;

import androidx.annotation.NonNull;
import androidx.test.espresso.proto.action.ViewActions.SwipeViewActionProto;
import androidx.test.espresso.remote.EspressoRemoteMessage;
import androidx.test.espresso.remote.ProtoUtils;
import java.util.Locale;

/**
 * {@link EspressoRemoteMessage.To} and {@link EspressoRemoteMessage.From} implementation of {@link
 * Swipe}.
 */
public final class SwipeRemoteMessage
    implements EspressoRemoteMessage.To<SwipeViewActionProto.Swipe> {

  /**
   * This field is used to create an instance of {@link Tapper} from its unwrapped proto message.
   */
  public static final EspressoRemoteMessage.From<Swiper, SwipeViewActionProto.Swipe> FROM =
      new EspressoRemoteMessage.From<Swiper, SwipeViewActionProto.Swipe>() {
        @Override
        public Swiper fromProto(SwipeViewActionProto.Swipe swipe) {
          return getTapperFromTapProto(swipe);
        }
      };

  private final Swipe swipe;

  public SwipeRemoteMessage(@NonNull Swipe swipe) {
    this.swipe = checkNotNull(swipe);
  }

  private static Swiper getTapperFromTapProto(SwipeViewActionProto.Swipe swipe) {
    return ProtoUtils.checkedGetEnumForProto(swipe.getNumber(), Swipe.class);
  }

  @Override
  public SwipeViewActionProto.Swipe toProto() {
    switch (swipe) {
      case FAST:
        return SwipeViewActionProto.Swipe.FAST;
      case SLOW:
        return SwipeViewActionProto.Swipe.SLOW;
      default:
        throw new IllegalArgumentException(
            String.format(Locale.ROOT, "Swipe proto enum for swipe: %s not found!", swipe));
    }
  }
}