1 /* 2 * Copyright (C) 2021 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.hilt.android; 18 19 /** 20 * Utility methods for tests that verify which generated component is used to inject the test class. 21 */ 22 public abstract class UsesComponentHelper { 23 defaultComponentName()24 public static String defaultComponentName() { 25 return "dagger.hilt.android.internal.testing.root." 26 + "DaggerDefault_HiltComponents_SingletonC$SingletonCImpl"; 27 } 28 29 /** 30 * Returns the name of a component that cannot use the default component. Does not handle deduping 31 * if test class names clash. 32 */ perTestComponentName(Object testInstance)33 public static String perTestComponentName(Object testInstance) { 34 return "dagger.hilt.android.internal.testing.root.Dagger" 35 + testInstance.getClass().getSimpleName() 36 + "_HiltComponents_SingletonC$SingletonCImpl"; 37 } 38 39 /** 40 * Returns the name of a component that cannot use the default component, including the expected 41 * prefix applied by Hilt to dedupe clashing class names. 42 */ perTestComponentNameWithDedupePrefix( String expectedPrefix, Object testInstance)43 public static String perTestComponentNameWithDedupePrefix( 44 String expectedPrefix, Object testInstance) { 45 return "dagger.hilt.android.internal.testing.root.Dagger" 46 + expectedPrefix 47 + testInstance.getClass().getSimpleName() 48 + "_HiltComponents_SingletonC$SingletonCImpl"; 49 } 50 UsesComponentHelper()51 private UsesComponentHelper() {} 52 } 53