aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test
diff options
context:
space:
mode:
authorKamil Doległo <kamilok1965@interia.pl>2020-08-19 11:20:13 +0200
committerSebastian Sellmair <34319766+sellmair@users.noreply.github.com>2020-08-19 13:34:10 +0200
commitbe9614ff2d5ab4a65f0e2dbc2d33c884de8e12e2 (patch)
tree0c1ec0cebcc8a2722a37899a5e06890518583e32 /plugins/base/src/test
parent6d22fac04d7a5e22379485ed62731f45f6b2d618 (diff)
downloaddokka-be9614ff2d5ab4a65f0e2dbc2d33c884de8e12e2.tar.gz
dokka-be9614ff2d5ab4a65f0e2dbc2d33c884de8e12e2.tar.bz2
dokka-be9614ff2d5ab4a65f0e2dbc2d33c884de8e12e2.zip
Add a test for the DefaultExternalLocationProvider
Diffstat (limited to 'plugins/base/src/test')
-rw-r--r--plugins/base/src/test/kotlin/locationProvider/DefaultExternalLocationProviderTest.kt64
-rw-r--r--plugins/base/src/test/resources/locationProvider/stdlib-package-list67
2 files changed, 131 insertions, 0 deletions
diff --git a/plugins/base/src/test/kotlin/locationProvider/DefaultExternalLocationProviderTest.kt b/plugins/base/src/test/kotlin/locationProvider/DefaultExternalLocationProviderTest.kt
new file mode 100644
index 00000000..e6546311
--- /dev/null
+++ b/plugins/base/src/test/kotlin/locationProvider/DefaultExternalLocationProviderTest.kt
@@ -0,0 +1,64 @@
+package locationProvider
+
+import org.jetbrains.dokka.base.resolvers.external.DefaultExternalLocationProvider
+import org.jetbrains.dokka.base.resolvers.external.Dokka010ExternalLocationProvider
+import org.jetbrains.dokka.plugability.DokkaContext
+import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation
+import org.jetbrains.dokka.base.resolvers.shared.PackageList
+import org.jetbrains.dokka.links.Callable
+import org.jetbrains.dokka.links.DRI
+import org.jetbrains.dokka.links.TypeConstructor
+import org.jetbrains.dokka.links.TypeReference
+import org.jetbrains.dokka.testApi.testRunner.AbstractCoreTest
+import org.junit.jupiter.api.Assertions
+import org.junit.jupiter.api.Assertions.assertEquals
+import org.junit.jupiter.api.Test
+import java.net.URL
+
+class DefaultExternalLocationProviderTest : AbstractCoreTest() {
+ private val testDataDir = getTestDataDir("locationProvider").toAbsolutePath()
+ private val kotlinLang = "https://kotlinlang.org/api/latest/jvm/stdlib"
+ private val packageListURL = URL("file://$testDataDir/stdlib-package-list")
+ private val configuration = dokkaConfiguration {
+ sourceSets {
+ sourceSet {
+ sourceRoots = listOf("src/")
+ classpath += jvmStdlibPath!!
+ externalDocumentationLink(kotlinLang, packageListURL.toString())
+ }
+ }
+ }
+
+ private fun getTestLocationProvider(context: DokkaContext? = null): DefaultExternalLocationProvider {
+ val dokkaContext = context ?: DokkaContext.create(configuration, logger, emptyList())
+ val packageList = PackageList.load(packageListURL, 8, true)!!
+ val externalDocumentation =
+ ExternalDocumentation(URL(kotlinLang), packageList)
+ return DefaultExternalLocationProvider(externalDocumentation, ".html", dokkaContext)
+ }
+
+ @Test
+ fun `ordinary link`() {
+ val locationProvider = getTestLocationProvider()
+ val dri = DRI("kotlin.reflect", "KVisibility")
+
+ assertEquals("$kotlinLang/kotlin.reflect/-k-visibility/index.html", locationProvider.resolve(dri))
+ }
+
+ @Test
+ fun `relocation in package list`() {
+ val locationProvider = getTestLocationProvider()
+ val dri = DRI(
+ "",
+ "",
+ Callable(
+ "longArray",
+ null,
+ listOf(TypeConstructor("kotlin.Int", emptyList()),
+ TypeConstructor("kotlin.Any", emptyList()))
+ )
+ )
+
+ assertEquals("$kotlinLang/kotlin-stdlib/[JS root]/long-array.html", locationProvider.resolve(dri))
+ }
+}
diff --git a/plugins/base/src/test/resources/locationProvider/stdlib-package-list b/plugins/base/src/test/resources/locationProvider/stdlib-package-list
new file mode 100644
index 00000000..298321aa
--- /dev/null
+++ b/plugins/base/src/test/resources/locationProvider/stdlib-package-list
@@ -0,0 +1,67 @@
+$dokka.format:html-v1
+$dokka.linkExtension:html
+$dokka.location://arrayWithFun/#kotlin.Int#kotlin.Function1[kotlin.Int,TypeParam(bounds=[kotlin.Any?])]/PointingToDeclaration/kotlin-stdlib/[JS root]/array-with-fun.html
+$dokka.location://booleanArray/#kotlin.Int#kotlin.Any/PointingToDeclaration/kotlin-stdlib/[JS root]/boolean-array.html
+$dokka.location://booleanArrayWithFun/#kotlin.Int#kotlin.Function1[kotlin.Int,kotlin.Boolean]/PointingToDeclaration/kotlin-stdlib/[JS root]/boolean-array-with-fun.html
+$dokka.location://charArray/#kotlin.Int#kotlin.Any/PointingToDeclaration/kotlin-stdlib/[JS root]/char-array.html
+$dokka.location://charArrayWithFun/#kotlin.Int#kotlin.Function1[kotlin.Int,kotlin.Char]/PointingToDeclaration/kotlin-stdlib/[JS root]/char-array-with-fun.html
+$dokka.location://fillArrayFun/#kotlin.Array[TypeParam(bounds=[kotlin.Any?])]#kotlin.Function1[kotlin.Int,TypeParam(bounds=[kotlin.Any?])]/PointingToDeclaration/kotlin-stdlib/[JS root]/fill-array-fun.html
+$dokka.location://longArray/#kotlin.Int#kotlin.Any/PointingToDeclaration/kotlin-stdlib/[JS root]/long-array.html
+$dokka.location://longArrayWithFun/#kotlin.Int#kotlin.Function1[kotlin.Int,kotlin.Long]/PointingToDeclaration/kotlin-stdlib/[JS root]/long-array-with-fun.html
+$dokka.location://newArray/#kotlin.Int#TypeParam(bounds=[kotlin.Any?])/PointingToDeclaration/kotlin-stdlib/[JS root]/new-array.html
+$dokka.location://untypedCharArrayWithFun/#kotlin.Int#kotlin.Function1[kotlin.Int,kotlin.Char]/PointingToDeclaration/kotlin-stdlib/[JS root]/untyped-char-array-with-fun.html
+kotlin
+kotlin.annotation
+kotlin.browser
+kotlin.collections
+kotlin.comparisons
+kotlin.concurrent
+kotlin.contracts
+kotlin.coroutines
+kotlin.coroutines.cancellation
+kotlin.coroutines.intrinsics
+kotlin.dom
+kotlin.experimental
+kotlin.io
+kotlin.js
+kotlin.jvm
+kotlin.math
+kotlin.native
+kotlin.native.concurrent
+kotlin.native.ref
+kotlin.properties
+kotlin.random
+kotlin.ranges
+kotlin.reflect
+kotlin.reflect.full
+kotlin.reflect.jvm
+kotlin.sequences
+kotlin.streams
+kotlin.system
+kotlin.text
+kotlin.time
+kotlinx.browser
+kotlinx.cinterop
+kotlinx.cinterop.internal
+kotlinx.dom
+kotlinx.wasm.jsinterop
+org.khronos.webgl
+org.w3c.css.masking
+org.w3c.dom
+org.w3c.dom.clipboard
+org.w3c.dom.css
+org.w3c.dom.encryptedmedia
+org.w3c.dom.events
+org.w3c.dom.mediacapture
+org.w3c.dom.mediasource
+org.w3c.dom.parsing
+org.w3c.dom.pointerevents
+org.w3c.dom.svg
+org.w3c.dom.url
+org.w3c.fetch
+org.w3c.files
+org.w3c.notifications
+org.w3c.performance
+org.w3c.workers
+org.w3c.xhr
+