aboutsummaryrefslogtreecommitdiff
path: root/plugins/kotlin-as-java/src/test/kotlin
diff options
context:
space:
mode:
authorVadim Mishenev <vad-mishenev@yandex.ru>2023-02-24 17:44:24 +0200
committerGitHub <noreply@github.com>2023-02-24 17:44:24 +0200
commit1040288ca76e070445f1400df2fcc5a56310be28 (patch)
tree52bed40e8a320f0835540b0cd38ea1899800e395 /plugins/kotlin-as-java/src/test/kotlin
parent8d23340d1c377b8f490cdee3c2c874453d321dd8 (diff)
downloaddokka-1040288ca76e070445f1400df2fcc5a56310be28.tar.gz
dokka-1040288ca76e070445f1400df2fcc5a56310be28.tar.bz2
dokka-1040288ca76e070445f1400df2fcc5a56310be28.zip
Reorganize tabs for Classlike (#2764)
Diffstat (limited to 'plugins/kotlin-as-java/src/test/kotlin')
-rw-r--r--plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt64
1 files changed, 35 insertions, 29 deletions
diff --git a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt
index 24c58e8e..031f5ee8 100644
--- a/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt
+++ b/plugins/kotlin-as-java/src/test/kotlin/KotlinAsJavaPluginTest.kt
@@ -9,23 +9,18 @@ import org.jetbrains.dokka.model.Annotations
import org.jetbrains.dokka.model.GenericTypeConstructor
import org.jetbrains.dokka.model.dfs
import org.jetbrains.dokka.pages.*
-import org.jetbrains.kotlin.utils.addToStdlib.cast
import org.junit.Assert
import org.junit.jupiter.api.Assertions
import org.junit.jupiter.api.Test
-import signatures.Parameter
-import signatures.Parameters
-import signatures.firstSignature
-import signatures.renderedContent
-import utils.A
-import utils.TestOutputWriterPlugin
-import utils.match
+import signatures.*
+import utils.*
import kotlin.test.assertEquals
+import kotlin.test.assertNotNull
class KotlinAsJavaPluginTest : BaseAbstractTest() {
@Test
- fun topLevelTest() {
+ fun `top-level functions should be generated`() {
val configuration = dokkaConfiguration {
sourceSets {
sourceSet {
@@ -53,15 +48,19 @@ class KotlinAsJavaPluginTest : BaseAbstractTest() {
pagesGenerationStage = { root ->
val content = (root.children.single().children.first { it.name == "TestKt" } as ContentPage).content
- val children = content.mainContents.first().cast<ContentGroup>()
- .children.filterIsInstance<ContentTable>()
- .filter { it.children.isNotEmpty() }
+ val functionRows = content.findTableWithKind(kind = ContentKind.Functions).children
+ functionRows.assertCount(6)
- children.assertCount(2)
+ val propRows = content.findTableWithKind(kind = ContentKind.Properties).children
+ propRows.assertCount(1)
}
}
}
+ private fun ContentNode.findTableWithKind(kind: ContentKind): ContentNode = dfs { node ->
+ node is ContentTable && node.dci.kind === kind
+ }.let { assertNotNull(it, "the table with kind $kind") }
+
@Test
fun topLevelWithClassTest() {
val configuration = dokkaConfiguration {
@@ -90,15 +89,17 @@ class KotlinAsJavaPluginTest : BaseAbstractTest() {
pagesGenerationStage = { root ->
val contentList = root.children
.flatMap { it.children<ContentPage>() }
- .map { it.content }
- val children = contentList.flatMap { content ->
- content.mainContents.single { it is ContentGroup }.children
- .filterIsInstance<ContentTable>()
- .filter { it.children.isNotEmpty() }
+ contentList.find {it.name == "Test"}.apply {
+ assertNotNull(this)
+ content.findTableWithKind(ContentKind.Functions).children.assertCount(2)
+ content.findTableWithKind(ContentKind.Properties).children.assertCount(1)
+ }
+ contentList.find {it.name == "TestKt"}.apply {
+ assertNotNull(this)
+ content.findTableWithKind(ContentKind.Functions).children.assertCount(2)
+ content.findTableWithKind(ContentKind.Properties).children.assertCount(1)
}
-
- children.assertCount(4)
}
}
}
@@ -233,10 +234,9 @@ class KotlinAsJavaPluginTest : BaseAbstractTest() {
pagesGenerationStage = { root ->
val testClass = root.dfs { it.name == "TestJ" } as? ClasslikePageNode
assert(testClass != null)
- (testClass!!.content as ContentGroup).children.last().assertNode {
- skipAllNotMatching()
+ (testClass!!.content as ContentGroup).children.last().children.last().assertNode {
group {
- header(2) {
+ header(2){
+"Properties"
}
table {
@@ -244,11 +244,17 @@ class KotlinAsJavaPluginTest : BaseAbstractTest() {
link {
+"publicProperty"
}
- platformHinted {
- group {
- +"public Int"
- link {
- +"publicProperty"
+ divergentGroup {
+ divergentInstance {
+ divergent {
+ group {
+ group {
+ +"public Int"
+ link {
+ +"publicProperty"
+ }
+ }
+ }
}
}
}
@@ -602,4 +608,4 @@ class KotlinAsJavaPluginTest : BaseAbstractTest() {
private val ContentNode.mainContents: List<ContentNode>
get() = (this as ContentGroup).children
.filterIsInstance<ContentGroup>()
- .single { it.dci.kind == ContentKind.Main }.children
+ .single { it.dci.kind == ContentKind.Main }.children[0].let { it.children[0] }.children