mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-04-30 22:34:04 +02:00
Remove IdeaVimTestCase and replace it with VimTestCase
This commit is contained in:
parent
564ab7d75e
commit
3866565e51
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
@ -33,7 +33,7 @@ import com.maddyhome.idea.vim.vimscript.model.datatypes.VimInt
|
|||||||
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString
|
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString
|
||||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
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.jetbrains.plugins.ideavim.waitUntil
|
||||||
import org.junit.jupiter.api.AfterEach
|
import org.junit.jupiter.api.AfterEach
|
||||||
import org.junit.jupiter.api.BeforeEach
|
import org.junit.jupiter.api.BeforeEach
|
||||||
@ -46,7 +46,7 @@ private const val defaultValue = "defaultValue"
|
|||||||
private const val defaultNumberValue = 10
|
private const val defaultNumberValue = 10
|
||||||
|
|
||||||
@TestWithoutNeovim(reason = SkipNeovimReason.OPTION)
|
@TestWithoutNeovim(reason = SkipNeovimReason.OPTION)
|
||||||
class EffectiveOptionChangeListenerTest : IdeaVimTestCase() {
|
class EffectiveOptionChangeListenerTest : VimTestCase() {
|
||||||
private val optionName = "test"
|
private val optionName = "test"
|
||||||
private lateinit var manager: FileEditorManagerImpl
|
private lateinit var manager: FileEditorManagerImpl
|
||||||
private lateinit var otherBufferWindow: Editor
|
private lateinit var otherBufferWindow: Editor
|
||||||
|
@ -30,7 +30,7 @@ import com.maddyhome.idea.vim.options.StringOption
|
|||||||
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString
|
import com.maddyhome.idea.vim.vimscript.model.datatypes.VimString
|
||||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
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.jetbrains.plugins.ideavim.waitUntil
|
||||||
import org.junit.jupiter.api.AfterEach
|
import org.junit.jupiter.api.AfterEach
|
||||||
import org.junit.jupiter.api.BeforeEach
|
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
|
// Tests the implementation of global, local to buffer, local to window and global-local
|
||||||
@TestWithoutNeovim(reason = SkipNeovimReason.OPTION)
|
@TestWithoutNeovim(reason = SkipNeovimReason.OPTION)
|
||||||
class OptionDeclaredScopeTest : IdeaVimTestCase() {
|
class OptionDeclaredScopeTest : VimTestCase() {
|
||||||
private val optionName = "test"
|
private val optionName = "test"
|
||||||
private val defaultValue = VimString("defaultValue")
|
private val defaultValue = VimString("defaultValue")
|
||||||
private val setValue = VimString("setValue")
|
private val setValue = VimString("setValue")
|
||||||
|
@ -27,7 +27,7 @@ import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory
|
|||||||
import com.intellij.testFramework.replaceService
|
import com.intellij.testFramework.replaceService
|
||||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
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.jetbrains.plugins.ideavim.waitUntil
|
||||||
import org.junit.jupiter.api.Assertions.assertFalse
|
import org.junit.jupiter.api.Assertions.assertFalse
|
||||||
import org.junit.jupiter.api.Assertions.assertTrue
|
import org.junit.jupiter.api.Assertions.assertTrue
|
||||||
@ -38,7 +38,7 @@ import javax.swing.SwingConstants
|
|||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
|
||||||
@TestWithoutNeovim(reason = SkipNeovimReason.NOT_VIM_TESTING)
|
@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
|
// 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
|
// visual guide is shown by default
|
||||||
|
@ -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.
|
* 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.
|
* 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.
|
* 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
|
@ApiStatus.Internal
|
||||||
abstract class VimTestCase : IdeaVimTestCase() {
|
abstract class VimTestCase {
|
||||||
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 {
|
|
||||||
protected lateinit var fixture: CodeInsightTestFixture
|
protected lateinit var fixture: CodeInsightTestFixture
|
||||||
|
|
||||||
lateinit var testInfo: TestInfo
|
lateinit var testInfo: TestInfo
|
||||||
@ -1055,6 +1024,36 @@ abstract class IdeaVimTestCase {
|
|||||||
class EditorAction(val name: String) : CharType
|
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 {
|
companion object {
|
||||||
const val c = EditorTestUtil.CARET_TAG
|
const val c = EditorTestUtil.CARET_TAG
|
||||||
const val s = EditorTestUtil.SELECTION_START_TAG
|
const val s = EditorTestUtil.SELECTION_START_TAG
|
||||||
|
@ -10,6 +10,6 @@ package org.jetbrains.plugins.ideavim
|
|||||||
|
|
||||||
import com.intellij.ide.highlighter.JavaFileType
|
import com.intellij.ide.highlighter.JavaFileType
|
||||||
|
|
||||||
abstract class VimJavaTestCase : IdeaVimTestCase() {
|
abstract class VimJavaTestCase : VimTestCase() {
|
||||||
protected fun configureByJavaText(content: String) = configureByText(JavaFileType.INSTANCE, content)
|
protected fun configureByJavaText(content: String) = configureByText(JavaFileType.INSTANCE, content)
|
||||||
}
|
}
|
@ -18,7 +18,6 @@ import org.jetbrains.jetCheck.PropertyChecker
|
|||||||
import org.jetbrains.plugins.ideavim.NeovimTesting
|
import org.jetbrains.plugins.ideavim.NeovimTesting
|
||||||
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
import org.jetbrains.plugins.ideavim.SkipNeovimReason
|
||||||
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
|
||||||
import org.jetbrains.plugins.ideavim.IdeaVimTestCase
|
|
||||||
import org.jetbrains.plugins.ideavim.VimTestCase
|
import org.jetbrains.plugins.ideavim.VimTestCase
|
||||||
import org.junit.jupiter.api.Test
|
import org.junit.jupiter.api.Test
|
||||||
import kotlin.math.absoluteValue
|
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 key = env.generateValue(generator, null)
|
||||||
val action = injector.parser.parseKeys(key).single()
|
val action = injector.parser.parseKeys(key).single()
|
||||||
env.logMessage("Use command: ${injector.parser.toKeyNotation(action)}.")
|
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)
|
NeovimTesting.typeCommand(key, test.testInfo, editor)
|
||||||
|
|
||||||
IdeEventQueue.getInstance().flushQueue()
|
IdeEventQueue.getInstance().flushQueue()
|
||||||
|
@ -18,7 +18,7 @@ import com.maddyhome.idea.vim.newapi.vim
|
|||||||
import org.jetbrains.jetCheck.Generator
|
import org.jetbrains.jetCheck.Generator
|
||||||
import org.jetbrains.jetCheck.ImperativeCommand
|
import org.jetbrains.jetCheck.ImperativeCommand
|
||||||
import org.jetbrains.jetCheck.PropertyChecker
|
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.javaText
|
||||||
import org.jetbrains.plugins.ideavim.propertybased.samples.loremText
|
import org.jetbrains.plugins.ideavim.propertybased.samples.loremText
|
||||||
import org.junit.jupiter.api.Test
|
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 usedKey = env.generateValue(keyGenerator, null)
|
||||||
val node = trie.getTrieNode(currentKeys + usedKey)
|
val node = trie.getTrieNode(currentKeys + usedKey)
|
||||||
env.logMessage("Use command: ${injector.parser.toKeyNotation(currentKeys + usedKey)}. ${if (node?.data != null) "Action: ${node.data!!.actionId}" else ""}")
|
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()
|
IdeEventQueue.getInstance().flushQueue()
|
||||||
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
|
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
|
||||||
|
@ -15,7 +15,7 @@ import com.maddyhome.idea.vim.api.injector
|
|||||||
import org.jetbrains.jetCheck.Generator
|
import org.jetbrains.jetCheck.Generator
|
||||||
import org.jetbrains.jetCheck.ImperativeCommand
|
import org.jetbrains.jetCheck.ImperativeCommand
|
||||||
import org.jetbrains.jetCheck.PropertyChecker
|
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.jetbrains.plugins.ideavim.propertybased.samples.loremText
|
||||||
import org.junit.jupiter.api.Test
|
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)
|
val key = env.generateValue(Generator.sampledFrom(keysList), null)
|
||||||
|
|
||||||
env.logMessage("Use command: $key")
|
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()
|
IdeEventQueue.getInstance().flushQueue()
|
||||||
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
|
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue()
|
||||||
|
Loading…
Reference in New Issue
Block a user