From 852a6ce6c0f43c9b2044320dcceb4c6cc0a3b302 Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Tue, 11 Aug 2020 21:47:26 +0200 Subject: Refactor location providers --- .../it/gradle/Android0GradleIntegrationTest.kt | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'integration-tests/gradle/src') diff --git a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Android0GradleIntegrationTest.kt b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Android0GradleIntegrationTest.kt index 6d71f161..c24ca75b 100644 --- a/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Android0GradleIntegrationTest.kt +++ b/integration-tests/gradle/src/integrationTest/kotlin/org/jetbrains/dokka/it/gradle/Android0GradleIntegrationTest.kt @@ -62,6 +62,13 @@ class Android0GradleIntegrationTest(override val versions: BuildVersions) : Abst "Expected html files in html output directory" ) + htmlOutputDir.allHtmlFiles().forEach { file -> + assertContainsNoErrorClass(file) + assertNoUnresolvedLinksIgnoringKnown(file) + assertNoHrefToMissingLocalFileOrDirectory(file) + assertNoEmptyLinks(file) + } + assertTrue( htmlOutputDir.allHtmlFiles().any { file -> "https://developer.android.com/reference/android/content/Context.html" in file.readText() @@ -81,4 +88,22 @@ class Android0GradleIntegrationTest(override val versions: BuildVersions) : Abst assertNoHrefToMissingLocalFileOrDirectory(file) } } + + // TODO: use [assertNoUnresolvedLinks] instead when https://github.com/Kotlin/dokka/issues/1306 is closed + private fun assertNoUnresolvedLinksIgnoringKnown(file: File) { + 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)/" + ) + val fileText = file.readText() + val regex = Regex("""data-unresolved-link="\[(.+?(?=]"))""") + val match = regex.findAll(fileText).map { it.groups[1]!!.value } + + assertTrue( + match.filterNot { it in knownUnresolvedDRIs }.toList().isEmpty(), + "Unexpected unresolved link in ${file.path}\n" + fileText + ) + } } -- cgit