|
| 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