aboutsummaryrefslogtreecommitdiff
path: root/dokka-subprojects/plugin-base/src/test/kotlin/locationProvider/AndroidExternalLocationProviderTest.kt
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2023-11-10 11:46:54 +0100
committerGitHub <noreply@github.com>2023-11-10 11:46:54 +0100
commit8e5c63d035ef44a269b8c43430f43f5c8eebfb63 (patch)
tree1b915207b2b9f61951ddbf0ff2e687efd053d555 /dokka-subprojects/plugin-base/src/test/kotlin/locationProvider/AndroidExternalLocationProviderTest.kt
parenta44efd4ba0c2e4ab921ff75e0f53fc9335aa79db (diff)
downloaddokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.gz
dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.tar.bz2
dokka-8e5c63d035ef44a269b8c43430f43f5c8eebfb63.zip
Restructure the project to utilize included builds (#3174)
* Refactor and simplify artifact publishing * Update Gradle to 8.4 * Refactor and simplify convention plugins and build scripts Fixes #3132 --------- Co-authored-by: Adam <897017+aSemy@users.noreply.github.com> Co-authored-by: Oleg Yukhnevich <whyoleg@gmail.com>
Diffstat (limited to 'dokka-subprojects/plugin-base/src/test/kotlin/locationProvider/AndroidExternalLocationProviderTest.kt')
-rw-r--r--dokka-subprojects/plugin-base/src/test/kotlin/locationProvider/AndroidExternalLocationProviderTest.kt109
1 files changed, 109 insertions, 0 deletions
diff --git a/dokka-subprojects/plugin-base/src/test/kotlin/locationProvider/AndroidExternalLocationProviderTest.kt b/dokka-subprojects/plugin-base/src/test/kotlin/locationProvider/AndroidExternalLocationProviderTest.kt
new file mode 100644
index 00000000..1d107947
--- /dev/null
+++ b/dokka-subprojects/plugin-base/src/test/kotlin/locationProvider/AndroidExternalLocationProviderTest.kt
@@ -0,0 +1,109 @@
+/*
+ * 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))
+ }
+}