Add test for renaming string literal with -adaptclassstrings

Bug: 210699098
Bug: 210809120
Change-Id: I0ea685bceae1f5eae46028ad7643cf464c50f624
diff --git a/src/test/java/com/android/tools/r8/naming/RepackageMinificationNameClashTest.java b/src/test/java/com/android/tools/r8/naming/RepackageMinificationNameClashTest.java
new file mode 100644
index 0000000..0145ebd
--- /dev/null
+++ b/src/test/java/com/android/tools/r8/naming/RepackageMinificationNameClashTest.java
@@ -0,0 +1,49 @@
+// Copyright (c) 2021, the R8 project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+package com.android.tools.r8.naming;
+
+import com.android.tools.r8.TestBase;
+import com.android.tools.r8.TestParameters;
+import com.android.tools.r8.TestParametersCollection;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameter;
+import org.junit.runners.Parameterized.Parameters;
+
+@RunWith(Parameterized.class)
+/** This is a regression test for b/210699098 */
+public class RepackageMinificationNameClashTest extends TestBase {
+
+  @Parameter() public TestParameters parameters;
+
+  @Parameters(name = "{0}")
+  public static TestParametersCollection data() {
+    return getTestParameters().withAllRuntimesAndApiLevels().build();
+  }
+
+  @Test
+  public void testR8() throws Exception {
+    testForR8(parameters.getBackend())
+        .addInnerClasses(getClass())
+        .setMinApi(parameters.getApiLevel())
+        .addKeepRules("-repackageclasses ''")
+        .addKeepRules("-adaptclassstrings")
+        .addKeepClassRulesWithAllowObfuscation(Foo.class)
+        .addKeepMainRule(Main.class)
+        .run(parameters.getRuntime(), Main.class)
+        // TODO(b/210699098): Should be RepackageMinificationNameClashTest$Foo.
+        .assertSuccessWithOutputLines("a");
+  }
+
+  public static class Foo {}
+
+  public static class Main {
+
+    public static void main(String[] args) {
+      System.out.println("RepackageMinificationNameClashTest$Foo");
+    }
+  }
+}