1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-04-22 19:15:46 +02:00

Remove IdeaVimTestCase and replace it with VimTestCase

This commit is contained in:
Alex Plate 2025-02-21 13:03:23 +02:00
parent 564ab7d75e
commit 3866565e51
No known key found for this signature in database
GPG Key ID: 0B97153C8FFEC09F
8 changed files with 45 additions and 47 deletions
src
test/java/org/jetbrains/plugins/ideavim/option
testFixtures/kotlin/org/jetbrains/plugins/ideavim
tests
java-tests/src/test/kotlin/org/jetbrains/plugins/ideavim
property-tests/src/test/kotlin/org/jetbrains/plugins/ideavim/propertybased

View File

@ -33,7 +33,7 @@ import com.maddyhome.idea.vim.vimscript.model.datatypes.VimInt
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString
import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
import org.jetbrains.plugins.ideavim.IdeaVimTestCase
import org.jetbrains.plugins.ideavim.VimTestCase
import org.jetbrains.plugins.ideavim.waitUntil
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
@ -46,7 +46,7 @@ private const val defaultValue = "defaultValue"
private const val defaultNumberValue = 10
@TestWithoutNeovim(reason = SkipNeovimReason.OPTION)
class EffectiveOptionChangeListenerTest : IdeaVimTestCase() {
class EffectiveOptionChangeListenerTest : VimTestCase() {
private val optionName = "test"
private lateinit var manager: FileEditorManagerImpl
private lateinit var otherBufferWindow: Editor

View File

@ -30,7 +30,7 @@ import com.maddyhome.idea.vim.options.StringOption
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString
import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
import org.jetbrains.plugins.ideavim.IdeaVimTestCase
import org.jetbrains.plugins.ideavim.VimTestCase
import org.jetbrains.plugins.ideavim.waitUntil
import org.junit.jupiter.api.AfterEach
import org.junit.jupiter.api.BeforeEach
@ -43,7 +43,7 @@ import kotlin.test.assertEquals
// Tests the implementation of global, local to buffer, local to window and global-local
@TestWithoutNeovim(reason = SkipNeovimReason.OPTION)
class OptionDeclaredScopeTest : IdeaVimTestCase() {
class OptionDeclaredScopeTest : VimTestCase() {
private val optionName = "test"
private val defaultValue = VimString("defaultValue")
private val setValue = VimString("setValue")

View File

@ -27,7 +27,7 @@ import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory
import com.intellij.testFramework.replaceService
import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
import org.jetbrains.plugins.ideavim.IdeaVimTestCase
import org.jetbrains.plugins.ideavim.VimTestCase
import org.jetbrains.plugins.ideavim.waitUntil
import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Assertions.assertTrue
@ -38,7 +38,7 @@ import javax.swing.SwingConstants
import kotlin.test.assertEquals
@TestWithoutNeovim(reason = SkipNeovimReason.NOT_VIM_TESTING)
class TextWidthOptionMapperTest : IdeaVimTestCase() {
class TextWidthOptionMapperTest : VimTestCase() {
// IntelliJ can have a margin set, but not act on it. We want to maintain this, not least because the right margin
// visual guide is shown by default

View File

@ -111,42 +111,11 @@ import kotlin.test.assertTrue
* To plugin writers: this class is internal, thus not allowed to be used by third-party plugins.
* This is done as we have no mechanism to guarantee compatibility as we update this test case.
* Feel free to copy this class into your plugin, or copy just needed functions.
*
* The tests are started on non-EDT thread without any locks.
*/
@ApiStatus.Internal
abstract class VimTestCase : IdeaVimTestCase() {
object Checks {
var caretShape: Boolean = true
val neoVim = NeoVim()
var keyHandler = KeyHandlerMethod.VIA_IDE
fun reset() {
caretShape = true
neoVim.reset()
keyHandler = KeyHandlerMethod.VIA_IDE
}
class NeoVim {
var ignoredRegisters: Set<Char> = setOf()
var exitOnTearDown = true
fun reset() {
ignoredRegisters = setOf()
exitOnTearDown = true
}
}
enum class KeyHandlerMethod {
VIA_IDE,
DIRECT_TO_VIM,
}
}
}
@ApiStatus.Internal
abstract class IdeaVimTestCase {
abstract class VimTestCase {
protected lateinit var fixture: CodeInsightTestFixture
lateinit var testInfo: TestInfo
@ -1055,6 +1024,36 @@ abstract class IdeaVimTestCase {
class EditorAction(val name: String) : CharType
}
object Checks {
var caretShape: Boolean = true
val neoVim = NeoVim()
var keyHandler = KeyHandlerMethod.VIA_IDE
fun reset() {
caretShape = true
neoVim.reset()
keyHandler = KeyHandlerMethod.VIA_IDE
}
class NeoVim {
var ignoredRegisters: Set<Char> = setOf()
var exitOnTearDown = true
fun reset() {
ignoredRegisters = setOf()
exitOnTearDown = true
}
}
enum class KeyHandlerMethod {
VIA_IDE,
DIRECT_TO_VIM,
}
}
companion object {
const val c = EditorTestUtil.CARET_TAG
const val s = EditorTestUtil.SELECTION_START_TAG

View File

@ -10,6 +10,6 @@ package org.jetbrains.plugins.ideavim
import com.intellij.ide.highlighter.JavaFileType
abstract class VimJavaTestCase : IdeaVimTestCase() {
abstract class VimJavaTestCase : VimTestCase() {
protected fun configureByJavaText(content: String) = configureByText(JavaFileType.INSTANCE, content)
}

View File

@ -18,7 +18,6 @@ import org.jetbrains.jetCheck.PropertyChecker
import org.jetbrains.plugins.ideavim.NeovimTesting
import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
import org.jetbrains.plugins.ideavim.IdeaVimTestCase
import org.jetbrains.plugins.ideavim.VimTestCase
import org.junit.jupiter.api.Test
import kotlin.math.absoluteValue
@ -76,7 +75,7 @@ private class IncrementDecrementActions(private val editor: Editor, val test: Vi
val key = env.generateValue(generator, null)
val action = injector.parser.parseKeys(key).single()
env.logMessage("Use command: ${injector.parser.toKeyNotation(action)}.")
IdeaVimTestCase.typeText(listOf(action), editor, editor.project)
VimTestCase.typeText(listOf(action), editor, editor.project)
NeovimTesting.typeCommand(key, test.testInfo, editor)
IdeEventQueue.getInstance().flushQueue()

View File

@ -18,7 +18,7 @@ import com.maddyhome.idea.vim.newapi.vim
import org.jetbrains.jetCheck.Generator
import org.jetbrains.jetCheck.ImperativeCommand
import org.jetbrains.jetCheck.PropertyChecker
import org.jetbrains.plugins.ideavim.IdeaVimTestCase
import org.jetbrains.plugins.ideavim.VimTestCase
import org.jetbrains.plugins.ideavim.propertybased.samples.javaText
import org.jetbrains.plugins.ideavim.propertybased.samples.loremText
import org.junit.jupiter.api.Test
@ -108,7 +108,7 @@ private class AvailableActions(private val editor: Editor) : ImperativeCommand {
val usedKey = env.generateValue(keyGenerator, null)
val node = trie.getTrieNode(currentKeys + usedKey)
env.logMessage("Use command: ${injector.parser.toKeyNotation(currentKeys + usedKey)}. ${if (node?.data != null) "Action: ${node.data!!.actionId}" else ""}")
IdeaVimTestCase.typeText(listOf(usedKey), editor, editor.project)
VimTestCase.typeText(listOf(usedKey), editor, editor.project)
IdeEventQueue.getInstance().flushQueue()
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()

View File

@ -15,7 +15,7 @@ import com.maddyhome.idea.vim.api.injector
import org.jetbrains.jetCheck.Generator
import org.jetbrains.jetCheck.ImperativeCommand
import org.jetbrains.jetCheck.PropertyChecker
import org.jetbrains.plugins.ideavim.IdeaVimTestCase
import org.jetbrains.plugins.ideavim.VimTestCase
import org.jetbrains.plugins.ideavim.propertybased.samples.loremText
import org.junit.jupiter.api.Test
@ -41,7 +41,7 @@ private class YankDeleteActions(private val editor: Editor) : ImperativeCommand
val key = env.generateValue(Generator.sampledFrom(keysList), null)
env.logMessage("Use command: $key")
IdeaVimTestCase.typeText(injector.parser.parseKeys(key), editor, editor.project)
VimTestCase.typeText(injector.parser.parseKeys(key), editor, editor.project)
IdeEventQueue.getInstance().flushQueue()
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()