/
Android0GradleIntegrationTest.kt
91 lines (77 loc) · 3.89 KB
/
Android0GradleIntegrationTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package org.jetbrains.dokka.it.gradle
import org.gradle.testkit.runner.TaskOutcome
import org.jetbrains.dokka.test.assumeAndroidSdkInstalled
import org.junit.runners.Parameterized.Parameters
import java.io.File
import kotlin.test.*
class Android0GradleIntegrationTest(override val versions: BuildVersions) : AbstractGradleIntegrationTest() {
companion object {
@get:JvmStatic
@get:Parameters(name = "{0}")
val versions = BuildVersions.permutations(
gradleVersions = listOf("6.6", *ifExhaustive("5.6.4")),
kotlinVersions = listOf("1.4.0", *ifExhaustive("1.3.72")),
androidGradlePluginVersions = listOf("3.5.3", *ifExhaustive("3.6.3"))
) + BuildVersions.permutations(
gradleVersions = listOf("6.6", *ifExhaustive("6.1.1")),
kotlinVersions = listOf("1.4.0", *ifExhaustive("1.3.72")),
androidGradlePluginVersions = listOf("4.0.0")
) + BuildVersions.permutations(
gradleVersions = listOf("7.3"),
kotlinVersions = listOf("1.6.10", "1.6.0", "1.5.31", *ifExhaustive("1.4.0", "1.3.72")),
androidGradlePluginVersions = listOf("7.0.0")
)
}
@BeforeTest
fun prepareProjectFiles() {
assumeAndroidSdkInstalled()
val templateProjectDir = File("projects", "it-android-0")
templateProjectDir.listFiles().orEmpty()
.filter { it.isFile }
.filterNot { it.name == "local.properties" }
.filterNot { it.name.startsWith("gradlew") }
.forEach { topLevelFile -> topLevelFile.copyTo(File(projectDir, topLevelFile.name)) }
File(templateProjectDir, "src").copyRecursively(File(projectDir, "src"))
}
@Test
fun execute() {
val result = createGradleRunner("dokkaHtml", "-i", "-s").buildRelaxed()
assertEquals(TaskOutcome.SUCCESS, assertNotNull(result.task(":dokkaHtml")).outcome)
val htmlOutputDir = File(projectDir, "build/dokka/html")
assertTrue(htmlOutputDir.isDirectory, "Missing html output directory")
assertTrue(
htmlOutputDir.allHtmlFiles().count() > 0,
"Expected html files in html output directory"
)
htmlOutputDir.allHtmlFiles().forEach { file ->
assertContainsNoErrorClass(file)
assertNoUnresolvedLinks(file, knownUnresolvedDRIs)
assertNoHrefToMissingLocalFileOrDirectory(file)
assertNoEmptyLinks(file)
assertNoEmptySpans(file)
}
assertTrue(
htmlOutputDir.allHtmlFiles().any { file ->
"https://developer.android.com/reference/kotlin/android/content/Context.html" in file.readText()
}, "Expected link to developer.android.com"
)
assertTrue(
htmlOutputDir.allHtmlFiles().any { file ->
"https://developer.android.com/reference/kotlin/androidx/appcompat/app/AppCompatActivity.html" in
file.readText()
}, "Expected link to developer.android.com/.../androidx/"
)
htmlOutputDir.allHtmlFiles().forEach { file ->
assertContainsNoErrorClass(file)
assertNoUnresolvedLinks(file)
assertNoHrefToMissingLocalFileOrDirectory(file)
}
}
// TODO: remove this list when https://github.com/Kotlin/dokka/issues/1306 is closed
private val knownUnresolvedDRIs = setOf(
"it.android/IntegrationTestActivity/findViewById/#kotlin.Int/PointingToGenericParameters(0)/",
"it.android/IntegrationTestActivity/getExtraData/#java.lang.Class[TypeParam(bounds=[androidx.core.app.ComponentActivity.ExtraData])]/PointingToGenericParameters(0)/",
"it.android/IntegrationTestActivity/getSystemService/#java.lang.Class[TypeParam(bounds=[kotlin.Any])]/PointingToGenericParameters(0)/",
"it.android/IntegrationTestActivity/requireViewById/#kotlin.Int/PointingToGenericParameters(0)/"
)
}