pull/696/head
Mattia Iavarone 6 years ago
parent 14c8a4d6b8
commit c2c7f86562
  1. 4
      cameraview/src/androidTest/java/com/otaliastudios/cameraview/tools/Retry.java
  2. 12
      cameraview/src/androidTest/java/com/otaliastudios/cameraview/tools/RetryRule.java

@ -4,4 +4,6 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface Retry {}
public @interface Retry {
boolean emulatorOnly() default false;
}

@ -1,5 +1,7 @@
package com.otaliastudios.cameraview.tools;
import android.os.Build;
import com.otaliastudios.cameraview.CameraLogger;
import org.junit.rules.TestRule;
@ -24,7 +26,8 @@ public class RetryRule implements TestRule {
return new Statement() {
@Override
public void evaluate() throws Throwable {
if (description.getAnnotation(Retry.class) == null) {
Retry retry = description.getAnnotation(Retry.class);
if (retry == null || retry.emulatorOnly() && !isEmulator()) {
base.evaluate();
} else {
Throwable caught = null;
@ -45,4 +48,11 @@ public class RetryRule implements TestRule {
}
};
}
private boolean isEmulator() {
// From Android's RequiresDeviceFilter
return Build.HARDWARE.equals("goldfish")
|| Build.HARDWARE.equals("ranchu")
|| Build.HARDWARE.equals("gce_x86");
}
}
Loading…
Cancel
Save