19
19
import static com .google .common .truth .Truth .assertThat ;
20
20
import static org .junit .Assert .assertThrows ;
21
21
import static org .junit .Assert .fail ;
22
- import static org .junit .Assume .assumeTrue ;
22
+ import static org .junit .Assume .assumeFalse ;
23
23
24
24
import com .example .UnusedClass ;
25
25
import java .lang .reflect .InvocationTargetException ;
@@ -61,6 +61,11 @@ public void verifyJarExists() {
61
61
}
62
62
}
63
63
64
+ /** Returns whether the test is currently running for ProGuard, instead of R8 */
65
+ private boolean isTestingProGuard () {
66
+ return jarToTest .equals (PROGUARD_RESULT_PATH );
67
+ }
68
+
64
69
@ FunctionalInterface
65
70
interface TestAction {
66
71
void run (Class <?> c ) throws Exception ;
@@ -216,6 +221,10 @@ public void test() throws Exception {
216
221
"Read: Using Generic TypeToken" ,
217
222
"{g={t=read-1}}" ,
218
223
"===" ,
224
+ "Read: Interface implementation" ,
225
+ // TODO: Currently only works for ProGuard but not R8
226
+ isTestingProGuard () ? "value" : "ClassCastException" ,
227
+ "===" ,
219
228
"" ));
220
229
}
221
230
@@ -226,7 +235,7 @@ public void testNoSerializedName_NoArgsConstructor() throws Exception {
226
235
c -> {
227
236
Method m = c .getMethod ("runTestNoArgsConstructor" );
228
237
229
- if (jarToTest . equals ( PROGUARD_RESULT_PATH )) {
238
+ if (isTestingProGuard ( )) {
230
239
Object result = m .invoke (null );
231
240
assertThat (result ).isEqualTo ("value" );
232
241
} else {
@@ -251,7 +260,7 @@ public void testNoSerializedName_NoArgsConstructorNoJdkUnsafe() throws Exception
251
260
c -> {
252
261
Method m = c .getMethod ("runTestNoJdkUnsafe" );
253
262
254
- if (jarToTest . equals ( PROGUARD_RESULT_PATH )) {
263
+ if (isTestingProGuard ( )) {
255
264
Object result = m .invoke (null );
256
265
assertThat (result ).isEqualTo ("value" );
257
266
} else {
@@ -278,7 +287,7 @@ public void testNoSerializedName_HasArgsConstructor() throws Exception {
278
287
c -> {
279
288
Method m = c .getMethod ("runTestHasArgsConstructor" );
280
289
281
- if (jarToTest . equals ( PROGUARD_RESULT_PATH )) {
290
+ if (isTestingProGuard ( )) {
282
291
Object result = m .invoke (null );
283
292
assertThat (result ).isEqualTo ("value" );
284
293
} else {
@@ -300,7 +309,7 @@ public void testNoSerializedName_HasArgsConstructor() throws Exception {
300
309
public void testUnusedClassRemoved () throws Exception {
301
310
// For some reason this test only works for R8 but not for ProGuard; ProGuard keeps the unused
302
311
// class
303
- assumeTrue ( jarToTest . equals ( R8_RESULT_PATH ));
312
+ assumeFalse ( isTestingProGuard ( ));
304
313
305
314
String className = UnusedClass .class .getName ();
306
315
ClassNotFoundException e =
0 commit comments