blob: 067fe2b357546fede9cbd24862ef75b3c43dd43f [file] [log] [blame]
Avi Drissmandfd880852022-09-15 20:11:091# Copyright 2016 The Chromium Authors
smaier05c799ee2016-07-14 17:09:362# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
smaierd50624e2016-08-05 14:21:105# This file is for proguard flags which are applied to the combined test and
6# tested code. Do not put any flags in this file which might affect the
7# correctness of the .apk we are testing, since it will apply to that .apk as
8# well.
smaier05c799ee2016-07-14 17:09:369
Andrew Grievefc9e7a92017-09-16 02:35:1210# Keep all junit3 classes and tests
Andrew Grievebc228162023-06-12 14:51:0311-keep class !cr_allowunused,junit.** { *; }
12-keep class !cr_allowunused,** extends junit.** { *; }
smaier385a49f02016-07-20 13:22:4713
Joseph Chao7ef35432022-01-25 22:28:3214# Keep all junit4 and hamcrest classes and tests
Andrew Grievebc228162023-06-12 14:51:0315-keep class !cr_allowunused,org.hamcrest.** { *; }
16-keep class !cr_allowunused,org.junit.** { *; }
17-keep class !cr_allowunused,* extends org.hamcrest.** { *; }
18-keep class !cr_allowunused,* extends org.junit.** { *; }
Andrew Grievefc9e7a92017-09-16 02:35:1219-keep @**.RunWith class * { *; }
yolandyan435f2592017-03-22 06:41:0020
Sam Maierd83d0172019-05-02 19:59:3021# Keep classes implementing ParameterProvider -- these will be instantiated
22# via reflection.
Andrew Grievebc228162023-06-12 14:51:0323-keep class !cr_allowunused,** implements org.chromium.base.test.params.ParameterProvider {
Sam Maierd83d0172019-05-02 19:59:3024 *;
25}
26
Andrew Grieve5a693e92017-09-18 19:39:5227# Keep all classes that are in test packages. There is no benefit in testing
28# Proguarding of test classes, but this is as close as we can get to selecting
29# all classes from the test apk.
Andrew Grieve09c8eeae2024-09-05 15:00:1230-keep,allowcodereplacement class !cr_allowunused,**.test.** { *; }
yolandyan435f2592017-03-22 06:41:0031
Andrew Grievef329e602021-10-29 19:30:4432# Keep all interfaces that are mocked by Mockito. Since Mockito generates these
33# mocks at runtime, R8 doesn't know to preserve them (without these rules).
Andrew Grievebc228162023-06-12 14:51:0334-if class ** {
Sam Maier36ab7512019-01-03 18:47:5935 @org.mockito.Mock ** *;
36}
Andrew Grieve09c8eeae2024-09-05 15:00:1237-keep,allowcodereplacement class <2> {
Sam Maier36ab7512019-01-03 18:47:5938 <methods>;
39}
40
Andrew Grievebc228162023-06-12 14:51:0341-if class ** {
Andrew Grievef329e602021-10-29 19:30:4442 @org.mockito.Spy ** *;
43}
Andrew Grieve09c8eeae2024-09-05 15:00:1244-keep,allowcodereplacement class <2> {
Andrew Grievef329e602021-10-29 19:30:4445 <methods>;
46}
47
Andrew Grievebc228162023-06-12 14:51:0348-if class ** {
Andrew Grievef329e602021-10-29 19:30:4449 @org.mockito.Captor ** *;
50}
Andrew Grieve09c8eeae2024-09-05 15:00:1251-keep,allowcodereplacement class <2> {
Andrew Grievef329e602021-10-29 19:30:4452 <methods>;
53}
54
Sam Maierf58c1b62020-02-27 21:12:1755# This is a workaround for b/147584922 - otherwise, R8 would generate a synthetic
56# abstract method for the subsclass FeedOfflineIndicator, which Mockito would not
57# mock.
Andrew Grieve09c8eeae2024-09-05 15:00:1258-keep,allowcodereplacement,allowobfuscation @interface org.chromium.build.annotations.MockedInTests
59-keep,allowcodereplacement @org.chromium.build.annotations.MockedInTests class ** {
Peter Wen81c3fcc2022-09-12 19:47:3160 <methods>;
61}
Sam Maierf58c1b62020-02-27 21:12:1762
Andrew Grieve5a693e92017-09-18 19:39:5263# Keep all enum members since they might be reflectively called by JUnit4 runner
Andrew Grieve09c8eeae2024-09-05 15:00:1264-keepclassmembers,allowcodereplacement enum !cr_allowunused,** { *; }
Yoland Yan4b523c12017-07-25 02:37:1665
Andrew Grievefc9e7a92017-09-16 02:35:1266# Keep any annotation used by tests for instrumentation runner to list out
Yoland Yan2909d202017-08-03 20:49:2567# test annotation information
Yoland Yan2909d202017-08-03 20:49:2568-keepattributes *Annotation*
69
Sam Maiercd629792018-11-16 21:37:5170# These are Java classes which aren't part of the Android sdk. They are
71# referenced by some test-only libraries.
72-dontwarn java.lang.ClassValue
73-dontwarn java.lang.instrument.ClassFileTransformer
74
smaierd50624e2016-08-05 14:21:1075# We have some "library class WebView depends on program class SslCertificate"
76# warnings, and they don't affect us.
77-dontwarn android.webkit.WebView*