Migrate legacy test B124357885Test
Bug: 167145686
Change-Id: I317a7cfb596052ea6dc944bb6e6fd03ce26d0868
diff --git a/src/test/java/com/android/tools/r8/naming/b124357885/B124357885Test.java b/src/test/java/com/android/tools/r8/naming/b124357885/B124357885Test.java
index 18d0719..8757685 100644
--- a/src/test/java/com/android/tools/r8/naming/b124357885/B124357885Test.java
+++ b/src/test/java/com/android/tools/r8/naming/b124357885/B124357885Test.java
@@ -14,9 +14,11 @@
import com.android.tools.r8.R8TestCompileResult;
import com.android.tools.r8.TestBase;
+import com.android.tools.r8.TestParameters;
import com.android.tools.r8.graph.DexAnnotationElement;
import com.android.tools.r8.graph.DexValue;
import com.android.tools.r8.graph.DexValue.DexValueArray;
+import com.android.tools.r8.shaking.ProguardKeepAttributes;
import com.android.tools.r8.utils.BooleanUtils;
import com.android.tools.r8.utils.DescriptorUtils;
import com.android.tools.r8.utils.StringUtils;
@@ -25,20 +27,26 @@
import com.android.tools.r8.utils.codeinspector.MethodSubject;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
+import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
@RunWith(Parameterized.class)
public class B124357885Test extends TestBase {
- public final boolean minification;
- @Parameterized.Parameters(name = "Minification: {0}")
- public static Boolean[] data() {
- return BooleanUtils.values();
+ private final TestParameters parameters;
+ private final boolean minification;
+
+ @Parameters(name = "{0}, minification: {1}")
+ public static List<Object[]> data() {
+ return buildParameters(
+ getTestParameters().withAllRuntimesAndApiLevels().build(), BooleanUtils.values());
}
- public B124357885Test(boolean minification) {
+ public B124357885Test(TestParameters parameters, boolean minification) {
+ this.parameters = parameters;
this.minification = minification;
}
@@ -69,11 +77,15 @@
@Test
public void test() throws Exception {
R8TestCompileResult compileResult =
- testForR8(Backend.DEX)
+ testForR8(parameters.getBackend())
.addProgramClasses(Main.class, Service.class, Foo.class, FooImpl.class)
.addKeepMainRule(Main.class)
- .addKeepRules("-keepattributes Signature,InnerClasses,EnclosingMethod")
+ .addKeepAttributes(
+ ProguardKeepAttributes.SIGNATURE,
+ ProguardKeepAttributes.INNER_CLASSES,
+ ProguardKeepAttributes.ENCLOSING_METHOD)
.minification(minification)
+ .setMinApi(parameters.getApiLevel())
.compile()
.inspect(
inspector -> {
@@ -88,31 +100,31 @@
checkSignatureAnnotation(inspector, signature);
});
- String fooImplFinalName = compileResult.inspector().clazz(FooImpl.class).getFinalName();
+ String fooImplFinalName = compileResult.inspector().clazz(FooImpl.class).getFinalName();
- compileResult
- .run(Main.class)
- .assertSuccessWithOutput(StringUtils.lines(fooImplFinalName, fooImplFinalName));
+ compileResult
+ .run(parameters.getRuntime(), Main.class)
+ .assertSuccessWithOutput(StringUtils.lines(fooImplFinalName, fooImplFinalName));
}
-}
-class Main {
- public static void main(String... args) throws Exception {
- Method method = Service.class.getMethod("fooList");
- ParameterizedType type = (ParameterizedType) method.getGenericReturnType();
- Class<?> rawType = (Class<?>) type.getRawType();
- System.out.println(rawType.getName());
+ public static class Main {
+ public static void main(String... args) throws Exception {
+ Method method = Service.class.getMethod("fooList");
+ ParameterizedType type = (ParameterizedType) method.getGenericReturnType();
+ Class<?> rawType = (Class<?>) type.getRawType();
+ System.out.println(rawType.getName());
- // Convince R8 we only use subtypes to get class merging of Foo into FooImpl.
- Foo<String> foo = new FooImpl<>();
- System.out.println(foo.getClass().getCanonicalName());
+ // Convince R8 we only use subtypes to get class merging of Foo into FooImpl.
+ Foo<String> foo = new FooImpl<>();
+ System.out.println(foo.getClass().getCanonicalName());
+ }
}
+
+ interface Service {
+ Foo<String> fooList();
+ }
+
+ interface Foo<T> {}
+
+ public static class FooImpl<T> implements Foo<T> {}
}
-
-interface Service {
- Foo<String> fooList();
-}
-
-interface Foo<T> {}
-
-class FooImpl<T> implements Foo<T> {}