Skip to content

Commit aff9392

Browse files
committed
Add ImageVectorGutterTest
1 parent d90b5b9 commit aff9392

File tree

2 files changed

+126
-1
lines changed

2 files changed

+126
-1
lines changed

tools/idea-plugin/build.gradle.kts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import io.github.composegears.valkyrie.excludeAndroidBuildTools
22
import org.jetbrains.changelog.Changelog
33
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
4+
import org.jetbrains.intellij.platform.gradle.TestFrameworkType
45
import org.jetbrains.intellij.platform.gradle.tasks.VerifyPluginTask.FailureLevel
56
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
67

@@ -68,12 +69,23 @@ dependencies {
6869
implementation(libs.leviathan.compose)
6970
implementation(libs.tiamat)
7071

72+
testImplementation(testFixtures(projects.sdk.intellij.testFixtures))
7173
testImplementation(libs.bundles.kmp.test)
72-
testImplementation(libs.junit4)
74+
testImplementation(libs.junit5.jupiter)
75+
testRuntimeOnly(libs.junit.launcher)
7376

7477
intellijPlatform {
7578
zipSigner()
7679
pluginVerifier()
80+
81+
testFramework(TestFrameworkType.Platform)
82+
testFramework(TestFrameworkType.JUnit5)
83+
}
84+
}
85+
86+
configurations {
87+
testImplementation {
88+
exclude(group = "org.jetbrains.kotlinx")
7789
}
7890
}
7991

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
package io.github.composegears.valkyrie.gutter
2+
3+
import assertk.assertThat
4+
import assertk.assertions.hasSize
5+
import com.intellij.testFramework.runInEdtAndGet
6+
import io.github.composegears.valkyrie.sdk.intellij.testfixtures.KotlinCodeInsightTest
7+
import org.junit.jupiter.api.Test
8+
9+
class ImageVectorGutterTest : KotlinCodeInsightTest() {
10+
11+
@Test
12+
fun `single gutter icon in file`() = runInEdtAndGet {
13+
myFixture.configureByText(
14+
"WithoutPath.kt",
15+
"""
16+
package io.github.composegears.valkyrie.icons
17+
18+
import androidx.compose.ui.graphics.vector.ImageVector
19+
import androidx.compose.ui.unit.dp
20+
21+
val WithoutPath: ImageVector
22+
get() {
23+
if (_WithoutPath != null) {
24+
return _WithoutPath!!
25+
}
26+
_WithoutPath = ImageVector.Builder(
27+
name = "WithoutPath",
28+
defaultWidth = 24.dp,
29+
defaultHeight = 24.dp,
30+
viewportWidth = 18f,
31+
viewportHeight = 18f
32+
).build()
33+
34+
return _WithoutPath!!
35+
}
36+
37+
@Suppress("ObjectPropertyName")
38+
private var _WithoutPath: ImageVector? = null
39+
""".trimIndent()
40+
)
41+
42+
val gutters = myFixture.findAllGutters()
43+
assertThat(gutters).hasSize(1)
44+
45+
val gutter = gutters.first()
46+
assertEquals("WithoutPath", gutter.tooltipText)
47+
assertNotNull(gutter.icon)
48+
}
49+
50+
@Test
51+
fun `multiple gutter icons in file`() = runInEdtAndGet {
52+
myFixture.configureByText(
53+
"WithoutPathIcons.kt",
54+
"""
55+
package io.github.composegears.valkyrie.icons
56+
57+
import androidx.compose.ui.graphics.vector.ImageVector
58+
import androidx.compose.ui.unit.dp
59+
60+
val WithoutPath: ImageVector
61+
get() {
62+
if (_WithoutPath != null) {
63+
return _WithoutPath!!
64+
}
65+
_WithoutPath = ImageVector.Builder(
66+
name = "WithoutPath",
67+
defaultWidth = 24.dp,
68+
defaultHeight = 24.dp,
69+
viewportWidth = 18f,
70+
viewportHeight = 18f
71+
).build()
72+
73+
return _WithoutPath!!
74+
}
75+
76+
@Suppress("ObjectPropertyName")
77+
private var _WithoutPath: ImageVector? = null
78+
79+
val MyPath: ImageVector
80+
get() {
81+
if (_MyPath != null) {
82+
return _MyPath!!
83+
}
84+
_MyPath = ImageVector.Builder(
85+
name = "MyPath",
86+
defaultWidth = 24.dp,
87+
defaultHeight = 24.dp,
88+
viewportWidth = 18f,
89+
viewportHeight = 18f
90+
).build()
91+
92+
return _MyPath!!
93+
}
94+
95+
@Suppress("ObjectPropertyName")
96+
private var _MyPath: ImageVector? = null
97+
98+
""".trimIndent()
99+
)
100+
101+
val gutters = myFixture.findAllGutters()
102+
assertThat(gutters).hasSize(2)
103+
104+
gutters[0].run {
105+
assertEquals("WithoutPath", tooltipText)
106+
assertNotNull(icon)
107+
}
108+
gutters[1].run {
109+
assertEquals("MyPath", tooltipText)
110+
assertNotNull(icon)
111+
}
112+
}
113+
}

0 commit comments

Comments
 (0)