Avi Drissman | dfd88085 | 2022-09-15 20:11:09 | [diff] [blame] | 1 | # Copyright 2016 The Chromium Authors |
smaier | 05c799ee | 2016-07-14 17:09:36 | [diff] [blame] | 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
smaier | d50624e | 2016-08-05 14:21:10 | [diff] [blame] | 5 | # 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. |
smaier | 05c799ee | 2016-07-14 17:09:36 | [diff] [blame] | 9 | |
Andrew Grieve | fc9e7a9 | 2017-09-16 02:35:12 | [diff] [blame] | 10 | # Keep all junit3 classes and tests |
Andrew Grieve | bc22816 | 2023-06-12 14:51:03 | [diff] [blame] | 11 | -keep class !cr_allowunused,junit.** { *; } |
| 12 | -keep class !cr_allowunused,** extends junit.** { *; } |
smaier | 385a49f0 | 2016-07-20 13:22:47 | [diff] [blame] | 13 | |
Joseph Chao | 7ef3543 | 2022-01-25 22:28:32 | [diff] [blame] | 14 | # Keep all junit4 and hamcrest classes and tests |
Andrew Grieve | bc22816 | 2023-06-12 14:51:03 | [diff] [blame] | 15 | -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 Grieve | fc9e7a9 | 2017-09-16 02:35:12 | [diff] [blame] | 19 | -keep @**.RunWith class * { *; } |
yolandyan | 435f259 | 2017-03-22 06:41:00 | [diff] [blame] | 20 | |
Sam Maier | d83d017 | 2019-05-02 19:59:30 | [diff] [blame] | 21 | # Keep classes implementing ParameterProvider -- these will be instantiated |
| 22 | # via reflection. |
Andrew Grieve | bc22816 | 2023-06-12 14:51:03 | [diff] [blame] | 23 | -keep class !cr_allowunused,** implements org.chromium.base.test.params.ParameterProvider { |
Sam Maier | d83d017 | 2019-05-02 19:59:30 | [diff] [blame] | 24 | *; |
| 25 | } |
| 26 | |
Andrew Grieve | 5a693e9 | 2017-09-18 19:39:52 | [diff] [blame] | 27 | # 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 Grieve | 09c8eeae | 2024-09-05 15:00:12 | [diff] [blame] | 30 | -keep,allowcodereplacement class !cr_allowunused,**.test.** { *; } |
yolandyan | 435f259 | 2017-03-22 06:41:00 | [diff] [blame] | 31 | |
Andrew Grieve | f329e60 | 2021-10-29 19:30:44 | [diff] [blame] | 32 | # 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 Grieve | bc22816 | 2023-06-12 14:51:03 | [diff] [blame] | 34 | -if class ** { |
Sam Maier | 36ab751 | 2019-01-03 18:47:59 | [diff] [blame] | 35 | @org.mockito.Mock ** *; |
| 36 | } |
Andrew Grieve | 09c8eeae | 2024-09-05 15:00:12 | [diff] [blame] | 37 | -keep,allowcodereplacement class <2> { |
Sam Maier | 36ab751 | 2019-01-03 18:47:59 | [diff] [blame] | 38 | <methods>; |
| 39 | } |
| 40 | |
Andrew Grieve | bc22816 | 2023-06-12 14:51:03 | [diff] [blame] | 41 | -if class ** { |
Andrew Grieve | f329e60 | 2021-10-29 19:30:44 | [diff] [blame] | 42 | @org.mockito.Spy ** *; |
| 43 | } |
Andrew Grieve | 09c8eeae | 2024-09-05 15:00:12 | [diff] [blame] | 44 | -keep,allowcodereplacement class <2> { |
Andrew Grieve | f329e60 | 2021-10-29 19:30:44 | [diff] [blame] | 45 | <methods>; |
| 46 | } |
| 47 | |
Andrew Grieve | bc22816 | 2023-06-12 14:51:03 | [diff] [blame] | 48 | -if class ** { |
Andrew Grieve | f329e60 | 2021-10-29 19:30:44 | [diff] [blame] | 49 | @org.mockito.Captor ** *; |
| 50 | } |
Andrew Grieve | 09c8eeae | 2024-09-05 15:00:12 | [diff] [blame] | 51 | -keep,allowcodereplacement class <2> { |
Andrew Grieve | f329e60 | 2021-10-29 19:30:44 | [diff] [blame] | 52 | <methods>; |
| 53 | } |
| 54 | |
Sam Maier | f58c1b6 | 2020-02-27 21:12:17 | [diff] [blame] | 55 | # 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 Grieve | 09c8eeae | 2024-09-05 15:00:12 | [diff] [blame] | 58 | -keep,allowcodereplacement,allowobfuscation @interface org.chromium.build.annotations.MockedInTests |
| 59 | -keep,allowcodereplacement @org.chromium.build.annotations.MockedInTests class ** { |
Peter Wen | 81c3fcc | 2022-09-12 19:47:31 | [diff] [blame] | 60 | <methods>; |
| 61 | } |
Sam Maier | f58c1b6 | 2020-02-27 21:12:17 | [diff] [blame] | 62 | |
Andrew Grieve | 5a693e9 | 2017-09-18 19:39:52 | [diff] [blame] | 63 | # Keep all enum members since they might be reflectively called by JUnit4 runner |
Andrew Grieve | 09c8eeae | 2024-09-05 15:00:12 | [diff] [blame] | 64 | -keepclassmembers,allowcodereplacement enum !cr_allowunused,** { *; } |
Yoland Yan | 4b523c1 | 2017-07-25 02:37:16 | [diff] [blame] | 65 | |
Andrew Grieve | fc9e7a9 | 2017-09-16 02:35:12 | [diff] [blame] | 66 | # Keep any annotation used by tests for instrumentation runner to list out |
Yoland Yan | 2909d20 | 2017-08-03 20:49:25 | [diff] [blame] | 67 | # test annotation information |
Yoland Yan | 2909d20 | 2017-08-03 20:49:25 | [diff] [blame] | 68 | -keepattributes *Annotation* |
| 69 | |
Sam Maier | cd62979 | 2018-11-16 21:37:51 | [diff] [blame] | 70 | # 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 | |
smaier | d50624e | 2016-08-05 14:21:10 | [diff] [blame] | 75 | # We have some "library class WebView depends on program class SslCertificate" |
| 76 | # warnings, and they don't affect us. |
| 77 | -dontwarn android.webkit.WebView* |