Move isCuttlefish() to helper classes
We skip some tests when running on Cuttlefish, typically because nested
virtualization is too slow and the tests time out, but logic has been
duplicated across multiple test files. Clean things up by adding a new
common host/device helper VirtualizationTestHelper and make both the
MicrodroidHostTestCaseBase and MicrodroidDeviceTestBase share the same
logic.
Test: m MicrodroidTestApp ComposBenchmarkApp MicrodroidHostTestCases
Change-Id: Ibb9d25fc40818ffeb971d366dea409f8ee55ef48
diff --git a/compos/benchmark/Android.bp b/compos/benchmark/Android.bp
index 10f8015..9353771 100644
--- a/compos/benchmark/Android.bp
+++ b/compos/benchmark/Android.bp
@@ -11,6 +11,7 @@
static_libs: [
"androidx.test.runner",
"androidx.test.ext.junit",
+ "MicroroidDeviceTestHelper",
"truth-prebuilt",
],
platform_apis: true,
diff --git a/compos/benchmark/src/java/com/android/compos/benchmark/ComposBenchmark.java b/compos/benchmark/src/java/com/android/compos/benchmark/ComposBenchmark.java
index 3244031..b4f55f9 100644
--- a/compos/benchmark/src/java/com/android/compos/benchmark/ComposBenchmark.java
+++ b/compos/benchmark/src/java/com/android/compos/benchmark/ComposBenchmark.java
@@ -24,9 +24,10 @@
import android.app.Instrumentation;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
-import android.os.SystemProperties;
import android.util.Log;
+import com.android.microdroid.test.MicrodroidDeviceTestBase;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -45,7 +46,7 @@
@RunWith(JUnit4.class)
-public class ComposBenchmark {
+public class ComposBenchmark extends MicrodroidDeviceTestBase {
private static final String TAG = "ComposBenchmark";
private static final int BUFFER_SIZE = 1024;
private static final int ROUND_COUNT = 5;
@@ -54,15 +55,6 @@
private Instrumentation mInstrumentation;
- private boolean isCuttlefish() {
- String productName = SystemProperties.get("ro.product.name");
- return (null != productName)
- && (productName.startsWith("aosp_cf_x86")
- || productName.startsWith("aosp_cf_arm")
- || productName.startsWith("cf_x86")
- || productName.startsWith("cf_arm"));
- }
-
@Before
public void setup() {
mInstrumentation = getInstrumentation();