1 /*
2  * Copyright 2020 The Android Open Source Project
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 androidx.startup.lint
18 
19 import com.android.tools.lint.checks.infrastructure.TestFile
20 import com.android.tools.lint.checks.infrastructure.TestFiles.java
21 import com.android.tools.lint.checks.infrastructure.TestFiles.kotlin
22 
23 object Stubs {
24     val TEST_INITIALIZER: TestFile =
25         kotlin(
26                 "com/example/TestInitializer.kt",
27                 """
28             package com.example
29 
30             import androidx.startup.Initializer
31 
32             class TestInitializer: Initializer<Unit> {
33                 override fun dependencies(): List<Class<out Initializer<*>>> = emptyList()
34             }
35         """
36             )
37             .indented()
38             .within("src")
39 
40     val TEST_INITIALIZER_WITH_DEPENDENCIES: TestFile =
41         kotlin(
42                 "com/example/TestInitializer.kt",
43                 """
44             package com.example
45 
46             import androidx.startup.Initializer
47 
48             class TestInitializer: Initializer<Unit> {
49                 override fun dependencies(): List<Class<out Initializer<*>>> = listOf(
50                     SecondInitializer::class.java
51                 )
52             }
53         """
54             )
55             .indented()
56             .within("src")
57 
58     val TEST_INITIALIZER_2: TestFile =
59         kotlin(
60                 "com/example/SecondInitializer.kt",
61                 """
62             package com.example
63 
64             import androidx.startup.Initializer
65 
66             class SecondInitializer: Initializer<Unit> {
67                 override fun dependencies(): List<Class<out Initializer<*>>> = emptyList()
68             }
69         """
70             )
71             .indented()
72             .within("src")
73 
74     /** The Test Initializer in Java. */
75     val TEST_INITIALIZER_JAVA: TestFile =
76         java(
77                 "com/example/TestInitializer.java",
78                 """
79             package com.example;
80 
81             import androidx.startup.Initializer;
82 
83             class TestInitializer extends Initializer<Void> {
84 
85             }
86         """
87             )
88             .indented()
89             .within("src")
90 
91     /** The Initializer. */
92     val INITIALIZER: TestFile =
93         kotlin(
94                 "androidx/startup/Initializer.kt",
95                 """
96             package androidx.startup
97             interface Initializer<out T : Any> {
dependenciesnull98                 fun dependencies(): List<Class<out Initializer<*>>>
99             }
100         """
101             )
102             .indented()
103             .within("src")
104 }
105