aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin/locationProvider
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/base/src/test/kotlin/locationProvider')
-rw-r--r--plugins/base/src/test/kotlin/locationProvider/AndroidExternalLocationProviderTest.kt109
-rw-r--r--plugins/base/src/test/kotlin/locationProvider/DefaultExternalLocationProviderTest.kt78
-rw-r--r--plugins/base/src/test/kotlin/locationProvider/Dokka010ExternalLocationProviderTest.kt123
-rw-r--r--plugins/base/src/test/kotlin/locationProvider/DokkaLocationProviderTest.kt126
-rw-r--r--plugins/base/src/test/kotlin/locationProvider/JavadocExternalLocationProviderTest.kt85
-rw-r--r--plugins/base/src/test/kotlin/locationProvider/MultiModuleLinkingTest.kt74
6 files changed, 0 insertions, 595 deletions
diff --git a/plugins/base/src/test/kotlin/locationProvider/AndroidExternalLocationProviderTest.kt b/plugins/base/src/test/kotlin/locationProvider/AndroidExternalLocationProviderTest.kt
deleted file mode 100644
index 1d107947..00000000
--- a/plugins/base/src/test/kotlin/locationProvider/AndroidExternalLocationProviderTest.kt
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package locationProvider
-
-import org.jetbrains.dokka.base.resolvers.external.DefaultExternalLocationProvider
-import org.jetbrains.dokka.base.resolvers.external.javadoc.AndroidExternalLocationProvider
-import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation
-import org.jetbrains.dokka.base.resolvers.shared.PackageList
-import org.jetbrains.dokka.base.resolvers.shared.RecognizedLinkFormat
-import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
-import org.jetbrains.dokka.links.Callable
-import org.jetbrains.dokka.links.DRI
-import org.jetbrains.dokka.links.TypeConstructor
-import org.jetbrains.dokka.plugability.DokkaContext
-import java.net.URL
-import kotlin.test.Test
-import kotlin.test.assertEquals
-
-class AndroidExternalLocationProviderTest : BaseAbstractTest() {
- private val android = ExternalDocumentation(
- URL("https://developer.android.com/reference/kotlin"),
- PackageList(
- RecognizedLinkFormat.DokkaHtml,
- mapOf("" to setOf("android.content", "android.net")),
- emptyMap(),
- URL("file://not-used")
- )
- )
- private val androidx = ExternalDocumentation(
- URL("https://developer.android.com/reference/kotlin"),
- PackageList(
- RecognizedLinkFormat.DokkaHtml,
- mapOf("" to setOf("androidx.appcompat.app")),
- emptyMap(),
- URL("file://not-used")
- )
- )
- private val configuration = dokkaConfiguration {
- sourceSets {
- sourceSet {
- sourceRoots = listOf("src/")
- classpath += jvmStdlibPath!!
- }
- }
- }
-
- private fun getTestLocationProvider(
- externalDocumentation: ExternalDocumentation,
- context: DokkaContext? = null
- ): DefaultExternalLocationProvider {
- val dokkaContext = context ?: DokkaContext.create(configuration, logger, emptyList())
- return AndroidExternalLocationProvider(externalDocumentation, dokkaContext)
- }
-
- @Test
- fun `#1230 anchor to a method from AndroidX`() {
- val locationProvider = getTestLocationProvider(androidx)
- val dri = DRI(
- "androidx.appcompat.app",
- "AppCompatActivity",
- Callable("findViewById", null, listOf(TypeConstructor("kotlin.Int", emptyList())))
- )
-
- assertEquals(
- "${androidx.documentationURL}/androidx/appcompat/app/AppCompatActivity.html#findviewbyid",
- locationProvider.resolve(dri)
- )
- }
-
- @Test
- fun `anchor to a method from Android`() {
- val locationProvider = getTestLocationProvider(android)
- val dri = DRI(
- "android.content",
- "ContextWrapper",
- Callable(
- "checkCallingUriPermission",
- null,
- listOf(
- TypeConstructor("android.net.Uri", emptyList()),
- TypeConstructor("kotlin.Int", emptyList())
- )
- )
- )
-
- assertEquals(
- "${android.documentationURL}/android/content/ContextWrapper.html#checkcallinguripermission",
- locationProvider.resolve(dri)
- )
- }
-
- @Test
- fun `should return null for method not in list`() {
- val locationProvider = getTestLocationProvider(android)
- val dri = DRI(
- "foo",
- "Bar",
- Callable(
- "baz",
- null,
- emptyList()
- )
- )
-
- assertEquals(null, locationProvider.resolve(dri))
- }
-}
diff --git a/plugins/base/src/test/kotlin/locationProvider/DefaultExternalLocationProviderTest.kt b/plugins/base/src/test/kotlin/locationProvider/DefaultExternalLocationProviderTest.kt
deleted file mode 100644
index c4c3c1e4..00000000
--- a/plugins/base/src/test/kotlin/locationProvider/DefaultExternalLocationProviderTest.kt
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package locationProvider
-
-import org.jetbrains.dokka.base.resolvers.external.DefaultExternalLocationProvider
-import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation
-import org.jetbrains.dokka.base.resolvers.shared.PackageList
-import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
-import org.jetbrains.dokka.links.Callable
-import org.jetbrains.dokka.links.DRI
-import org.jetbrains.dokka.links.TypeConstructor
-import org.jetbrains.dokka.plugability.DokkaContext
-import java.net.URL
-import kotlin.test.Test
-import kotlin.test.assertEquals
-
-class DefaultExternalLocationProviderTest : BaseAbstractTest() {
- private val testDataDir =
- getTestDataDir("locationProvider").toAbsolutePath().toString().removePrefix("/").let { "/$it" }
- 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!!
- }
- }
- }
-
- 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))
- }
-
- @Test
- fun `should return null for class not in list`() {
- val locationProvider = getTestLocationProvider()
- val dri = DRI(
- "foo",
- "Bar"
- )
-
- assertEquals(null, locationProvider.resolve(dri))
- }
-}
diff --git a/plugins/base/src/test/kotlin/locationProvider/Dokka010ExternalLocationProviderTest.kt b/plugins/base/src/test/kotlin/locationProvider/Dokka010ExternalLocationProviderTest.kt
deleted file mode 100644
index 338e7495..00000000
--- a/plugins/base/src/test/kotlin/locationProvider/Dokka010ExternalLocationProviderTest.kt
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package locationProvider
-
-import org.jetbrains.dokka.base.resolvers.external.Dokka010ExternalLocationProvider
-import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation
-import org.jetbrains.dokka.base.resolvers.shared.PackageList
-import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
-import org.jetbrains.dokka.links.Callable
-import org.jetbrains.dokka.links.DRI
-import org.jetbrains.dokka.links.TypeConstructor
-import org.jetbrains.dokka.plugability.DokkaContext
-import java.net.URL
-import kotlin.test.Test
-import kotlin.test.assertEquals
-
-class Dokka010ExternalLocationProviderTest : BaseAbstractTest() {
- private val testDataDir =
- getTestDataDir("locationProvider").toAbsolutePath().toString().removePrefix("/").let { "/$it" }
- private val kotlinLang = "https://kotlinlang.org/api/latest/jvm/stdlib"
- private val packageListURL = URL("file://$testDataDir/old-package-list")
- private val configuration = dokkaConfiguration {
- sourceSets {
- sourceSet {
- sourceRoots = listOf("src/")
- classpath += jvmStdlibPath!!
- }
- }
- }
-
- private fun getTestLocationProvider(context: DokkaContext? = null): Dokka010ExternalLocationProvider {
- val dokkaContext = context ?: DokkaContext.create(configuration, logger, emptyList())
- val packageList = PackageList.load(packageListURL, 8, true)!!
- val externalDocumentation =
- ExternalDocumentation(URL(kotlinLang), packageList)
- return Dokka010ExternalLocationProvider(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("kotlin.text", "StringBuilder")
-
- assertEquals("$kotlinLang/kotlin.relocated.text/-string-builder/index.html", locationProvider.resolve(dri))
- }
-
- @Test
- fun `method relocation in package list`() {
- val locationProvider = getTestLocationProvider()
- val dri = DRI(
- "kotlin",
- "",
- Callable(
- "minus",
- null,
- listOf(
- TypeConstructor("java.math.BigDecimal", emptyList()),
- TypeConstructor("java.math.BigDecimal", emptyList())
- )
- )
- )
-
- assertEquals("$kotlinLang/kotlin/java.math.-big-decimal/minus.html", locationProvider.resolve(dri))
- }
-
- @Test
- fun `#1268 companion part should be stripped`() {
- val locationProvider = getTestLocationProvider()
- val dri = DRI(
- "kotlin",
- "Int.Companion",
- Callable(
- "MIN_VALUE",
- null,
- emptyList()
- )
- )
-
- assertEquals("$kotlinLang/kotlin/-int/-m-i-n_-v-a-l-u-e.html", locationProvider.resolve(dri))
- }
-
- @Test
- fun `companion part should be stripped in relocations`() {
- val locationProvider = getTestLocationProvider()
- val dri = DRI(
- "kotlin",
- "Int.Companion",
- Callable(
- "MAX_VALUE",
- null,
- emptyList()
- )
- )
-
- assertEquals("$kotlinLang/kotlin/-int/max-value.html", locationProvider.resolve(dri))
- }
-
- @Test
- fun `should return null for method not in list`() {
- val locationProvider = getTestLocationProvider()
- val dri = DRI(
- "foo",
- "Bar",
- Callable(
- "baz",
- null,
- emptyList()
- )
- )
-
- assertEquals(null, locationProvider.resolve(dri))
- }
-}
diff --git a/plugins/base/src/test/kotlin/locationProvider/DokkaLocationProviderTest.kt b/plugins/base/src/test/kotlin/locationProvider/DokkaLocationProviderTest.kt
deleted file mode 100644
index dce19f70..00000000
--- a/plugins/base/src/test/kotlin/locationProvider/DokkaLocationProviderTest.kt
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package locationProvider
-
-import org.jetbrains.dokka.base.resolvers.local.DokkaLocationProvider
-import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
-import org.jetbrains.dokka.links.DRI
-import org.jetbrains.dokka.pages.*
-import org.jetbrains.dokka.plugability.DokkaContext
-import kotlin.test.Test
-import kotlin.test.assertEquals
-
-class DokkaLocationProviderTest : BaseAbstractTest() {
-
- private val configuration = dokkaConfiguration {
- sourceSets {
- sourceSet {
- sourceRoots = listOf("src/")
- classpath += jvmStdlibPath!!
- }
- }
- }
-
- private fun getTestLocationProvider(root: RootPageNode, context: DokkaContext? = null): DokkaLocationProvider {
- val dokkaContext = context ?: DokkaContext.create(configuration, logger, emptyList())
- return DokkaLocationProvider(root, dokkaContext, ".html")
- }
-
- @DslMarker
- annotation class TestNavigationDSL
-
- @TestNavigationDSL
- class NavigationDSL {
- companion object {
- private val stubDCI = DCI(
- setOf(
- DRI("kotlin", "Any")
- ),
- ContentKind.Comment
- )
- val stubContentNode = ContentText("", stubDCI, emptySet())
- }
-
- operator fun invoke(name: String, fn: ModulesDsl.() -> Unit): RendererSpecificRootPage {
- val modules = ModulesDsl().also { it.fn() }
- return RendererSpecificRootPage(name = name, children = modules.pages, RenderingStrategy.DoNothing)
- }
-
- @TestNavigationDSL
- class ModulesDsl(val pages: MutableList<ModulePageNode> = mutableListOf()) {
- fun modulePage(name: String, fn: PackageDsl.() -> Unit) {
- val packages = PackageDsl().also { it.fn() }
- pages.add(
- ModulePageNode(
- name = name,
- children = packages.pages,
- content = stubContentNode
- )
- )
- }
- }
-
- @TestNavigationDSL
- class PackageDsl(val pages: MutableList<PackagePageNode> = mutableListOf()) {
- fun packagePage(name: String, fn: ClassDsl.() -> Unit) {
- val packages = ClassDsl().also { it.fn() }
- pages.add(
- PackagePageNode(
- name = name,
- children = packages.pages,
- content = stubContentNode,
- dri = emptySet()
- )
- )
- }
- }
-
- @TestNavigationDSL
- class ClassDsl(val pages: MutableList<ClasslikePageNode> = mutableListOf()) {
- fun classPage(name: String) {
- pages.add(
- ClasslikePageNode(
- name = name,
- children = emptyList(),
- content = stubContentNode,
- dri = emptySet()
- )
- )
- }
- }
- }
-
- @Test
- fun `links to a package with or without a class`() {
- val root = NavigationDSL()("Root") {
- modulePage("Module") {
- packagePage("Package") {}
- }
- }
- val packagePage = root.children.first().children.first() as PackagePageNode
- val locationProvider = getTestLocationProvider(root)
- val resolvedLink = locationProvider.resolve(packagePage)
- val localToRoot = locationProvider.pathToRoot(packagePage)
-
- val rootWithClass = NavigationDSL()("Root") {
- modulePage("Module") {
- packagePage("Package") {
- classPage("ClassA")
- }
- }
- }
- val packagePageWithClass = rootWithClass.children.first().children.first() as PackagePageNode
-
- val locationProviderWithClass = getTestLocationProvider(rootWithClass)
- val localToRootWithClass = locationProviderWithClass.pathToRoot(packagePageWithClass)
- val resolvedLinkWithClass = locationProviderWithClass.resolve(packagePageWithClass)
-
- assertEquals("-module/Package.html", resolvedLink)
- assertEquals("../", localToRoot)
-
- assertEquals("-module/Package/index.html", resolvedLinkWithClass)
- assertEquals("../../", localToRootWithClass)
- }
-}
diff --git a/plugins/base/src/test/kotlin/locationProvider/JavadocExternalLocationProviderTest.kt b/plugins/base/src/test/kotlin/locationProvider/JavadocExternalLocationProviderTest.kt
deleted file mode 100644
index 1a747429..00000000
--- a/plugins/base/src/test/kotlin/locationProvider/JavadocExternalLocationProviderTest.kt
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package locationProvider
-
-import org.jetbrains.dokka.base.resolvers.external.DefaultExternalLocationProvider
-import org.jetbrains.dokka.base.resolvers.external.javadoc.JavadocExternalLocationProvider
-import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation
-import org.jetbrains.dokka.base.resolvers.shared.PackageList
-import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
-import org.jetbrains.dokka.links.DRI
-import org.jetbrains.dokka.links.DRIExtraContainer
-import org.jetbrains.dokka.links.EnumEntryDRIExtra
-import org.jetbrains.dokka.links.PointingToDeclaration
-import org.jetbrains.dokka.plugability.DokkaContext
-import java.net.URL
-import kotlin.test.Test
-import kotlin.test.assertEquals
-
-class JavadocExternalLocationProviderTest : BaseAbstractTest() {
- private val testDataDir =
- getTestDataDir("locationProvider").toAbsolutePath().toString().removePrefix("/").let { "/$it" }
-
- private val jdk = "https://docs.oracle.com/javase/8/docs/api/"
- private val jdkPackageListURL = URL("file://$testDataDir/jdk8-package-list")
-
- private val configuration = dokkaConfiguration {
- sourceSets {
- sourceSet {
- sourceRoots = listOf("src/")
- classpath += jvmStdlibPath!!
- }
- }
- }
-
- private fun getTestLocationProvider(context: DokkaContext? = null): DefaultExternalLocationProvider {
- val dokkaContext = context ?: DokkaContext.create(configuration, logger, emptyList())
- val packageList = PackageList.load(jdkPackageListURL, 8, true)!!
- val externalDocumentation =
- ExternalDocumentation(URL(jdk), packageList)
- return JavadocExternalLocationProvider(externalDocumentation, "--", "-", dokkaContext)
- }
-
- @Test
- fun `link to enum entity of javadoc`() {
- val locationProvider = getTestLocationProvider()
- val ktDri = DRI(
- "java.nio.file",
- "StandardOpenOption.CREATE",
- extra = DRIExtraContainer().also { it[EnumEntryDRIExtra] = EnumEntryDRIExtra }.encode()
- )
- val javaDri = DRI(
- "java.nio.file",
- "StandardOpenOption.CREATE",
- null,
- PointingToDeclaration,
- DRIExtraContainer().also { it[EnumEntryDRIExtra] = EnumEntryDRIExtra }.encode()
- )
-
- assertEquals(
- "https://docs.oracle.com/javase/8/docs/api/java/nio/file/StandardOpenOption.html#CREATE",
- locationProvider.resolve(ktDri)
- )
-
- assertEquals(
- "https://docs.oracle.com/javase/8/docs/api/java/nio/file/StandardOpenOption.html#CREATE",
- locationProvider.resolve(javaDri)
- )
- }
-
- @Test
- fun `link to nested class of javadoc`() {
- val locationProvider = getTestLocationProvider()
- val dri = DRI(
- "java.rmi.activation",
- "ActivationGroupDesc.CommandEnvironment"
- )
-
- assertEquals(
- "https://docs.oracle.com/javase/8/docs/api/java/rmi/activation/ActivationGroupDesc.CommandEnvironment.html",
- locationProvider.resolve(dri)
- )
- }
-}
diff --git a/plugins/base/src/test/kotlin/locationProvider/MultiModuleLinkingTest.kt b/plugins/base/src/test/kotlin/locationProvider/MultiModuleLinkingTest.kt
deleted file mode 100644
index 17327c4c..00000000
--- a/plugins/base/src/test/kotlin/locationProvider/MultiModuleLinkingTest.kt
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
- */
-
-package locationProvider
-
-import org.jetbrains.dokka.base.resolvers.external.DefaultExternalLocationProvider
-import org.jetbrains.dokka.base.resolvers.shared.ExternalDocumentation
-import org.jetbrains.dokka.base.resolvers.shared.PackageList
-import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
-import org.jetbrains.dokka.links.DRI
-import org.jetbrains.dokka.plugability.DokkaContext
-import java.net.URL
-import kotlin.test.Test
-import kotlin.test.assertEquals
-
-class MultiModuleLinkingTest : BaseAbstractTest() {
- private val testDataDir =
- getTestDataDir("locationProvider").toAbsolutePath().toString().removePrefix("/").let { "/$it" }
- private val exampleDomain = "https://example.com"
- private val packageListURL = URL("file://$testDataDir/multi-module-package-list")
- private val kotlinLang = "https://kotlinlang.org/api/latest/jvm/stdlib"
- private val stdlibPackageListURL = URL("file://$testDataDir/stdlib-package-list")
- private val configuration = dokkaConfiguration {
- sourceSets {
- sourceSet {
- sourceRoots = listOf("src/")
- classpath += jvmStdlibPath!!
- }
- }
- }
-
- 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(exampleDomain), packageList)
- return DefaultExternalLocationProvider(externalDocumentation, ".html", dokkaContext)
- }
-
- private fun getStdlibTestLocationProvider(context: DokkaContext? = null): DefaultExternalLocationProvider {
- val dokkaContext = context ?: DokkaContext.create(configuration, logger, emptyList())
- val packageList = PackageList.load(stdlibPackageListURL, 8, true)!!
- val externalDocumentation =
- ExternalDocumentation(URL(kotlinLang), packageList)
- return DefaultExternalLocationProvider(externalDocumentation, ".html", dokkaContext)
- }
-
- @Test
- fun `should link to a multi-module declaration`() {
- val locationProvider = getTestLocationProvider()
- val dri = DRI("baz", "BazClass")
-
- assertEquals("$exampleDomain/moduleB/baz/-baz-class/index.html", locationProvider.resolve(dri))
- }
-
- @Test
- fun `should not fail on non-present package`() {
- val stdlibLocationProvider = getStdlibTestLocationProvider()
- val locationProvider = getTestLocationProvider()
- val dri = DRI("baz", "BazClass")
-
- assertEquals(null, stdlibLocationProvider.resolve(dri))
- assertEquals("$exampleDomain/moduleB/baz/-baz-class/index.html", locationProvider.resolve(dri))
- }
-
- @Test
- fun `should handle relocations`() {
- val locationProvider = getTestLocationProvider()
- val dri = DRI("", "NoPackageClass")
-
- assertEquals("$exampleDomain/moduleB/[root]/-no-package-class/index.html", locationProvider.resolve(dri))
- }
-}