1 /* 2 * Copyright (C) 2020 The Dagger Authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package dagger.android; 18 19 import static com.google.common.truth.Truth.assertThat; 20 21 import dagger.android.internal.AndroidInjectionKeys; 22 import java.net.URL; 23 import org.junit.Test; 24 import org.junit.runner.RunWith; 25 import org.robolectric.RobolectricTestRunner; 26 27 @RunWith(RobolectricTestRunner.class) 28 public class AndroidProguardTest { 29 30 @Test checkLegacyProguardRules()31 public void checkLegacyProguardRules() { 32 URL resUrl = 33 AndroidInjectionKeys.class 34 .getClassLoader() 35 .getResource("META-INF/proguard/dagger-android.pro"); 36 assertThat(resUrl).isNotNull(); 37 } 38 39 // The com.android.tools files are only used outside Google, in Gradle projects. 40 @Test checkProguardRules()41 public void checkProguardRules() { 42 URL resUrl = 43 AndroidInjectionKeys.class 44 .getClassLoader() 45 .getResource("META-INF/com.android.tools/proguard/dagger-android.pro"); 46 assertThat(resUrl).isNotNull(); 47 } 48 49 @Test checkR8Rules()50 public void checkR8Rules() { 51 URL resUrl = 52 AndroidInjectionKeys.class 53 .getClassLoader() 54 .getResource("META-INF/com.android.tools/r8/dagger-android.pro"); 55 assertThat(resUrl).isNotNull(); 56 } 57 } 58