Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared tests #981

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Extract some VimTestCaseBase logic to VimTestCase
  • Loading branch information
lippfi committed Aug 30, 2024
commit d46276c447ce22e54ad2af1a29ed1ff02b942d18
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ dependencies {
testFixturesImplementation("org.junit.jupiter:junit-jupiter-engine:5.10.3")
testFixturesImplementation("org.junit.jupiter:junit-jupiter-params:5.10.3")
testImplementation(project(":vim-engine", "testArtifacts"))
testFixturesImplementation(project(":vim-engine", "testArtifacts"))

// Temp workaround suggested in https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-faq.html#junit5-test-framework-refers-to-junit4
// Can be removed when IJPL-159134 is fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.intellij.idea.TestFor
import com.maddyhome.idea.vim.KeyHandler
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.newapi.ij
import com.maddyhome.idea.vim.state.mode.Mode
import org.jetbrains.plugins.ideavim.SkipNeovimReason
import org.jetbrains.plugins.ideavim.TestWithoutNeovim
Expand Down Expand Up @@ -184,7 +185,7 @@ class CopyActionTest : VimTestCaseBase() {

""".trimIndent(),
)
kotlin.test.assertEquals(0, editor.caretModel.offset)
kotlin.test.assertEquals(0, editor.ij.caretModel.offset)
}

// VIM-632 |CTRL-V| |v_y| |p|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import com.maddyhome.idea.vim.action.motion.search.SearchWholeWordForwardAction
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.common.TextRange
import com.maddyhome.idea.vim.newapi.IjVimEditor
import com.maddyhome.idea.vim.newapi.ij
import com.maddyhome.idea.vim.newapi.vim
import com.maddyhome.idea.vim.state.mode.SelectionType
import org.jetbrains.plugins.ideavim.VimBehaviorDiffers
Expand Down Expand Up @@ -40,7 +41,7 @@ class MultipleCaretsTest : VimTestCaseBase() {
@Test
fun testMovementMerging() {
val editor = typeTextInFile(injector.parser.parseKeys("2h"), "o${c}n${c}e")
kotlin.test.assertEquals(1, editor.caretModel.caretCount)
kotlin.test.assertEquals(1, editor.ij.caretModel.caretCount)
assertState("${c}one")
}

Expand Down Expand Up @@ -2173,7 +2174,7 @@ rtyfg${c}hzxc"""
val editor = configureByText(before)
injector.registerGroup.storeText('*', "fgh")
VimPlugin.getRegister()
.storeText(IjVimEditor(editor), editor.vim.primaryCaret(), TextRange(16, 19), SelectionType.CHARACTER_WISE, false)
.storeText(editor, editor.primaryCaret(), TextRange(16, 19), SelectionType.CHARACTER_WISE, false)
typeText(injector.parser.parseKeys("\"*P"))
val after = "fg${c}hqfg${c}hwe asd zxc rty fg${c}hfgh vbn"
assertState(after)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import com.intellij.testFramework.ExtensionTestUtil
import com.maddyhome.idea.vim.VimPlugin
import com.maddyhome.idea.vim.api.globalOptions
import com.maddyhome.idea.vim.api.injector
import com.maddyhome.idea.vim.newapi.ij
import com.maddyhome.idea.vim.newapi.vim
import com.maddyhome.idea.vim.options.OptionConstants
import com.maddyhome.idea.vim.state.mode.Mode
Expand Down Expand Up @@ -86,9 +87,8 @@ class PutTestAfterCursorActionTest : VimTestCaseBase() {
hard by the ${c}torrent of a mountain pass.
""".trimIndent()
val editor = configureByText(before)
val vimEditor = editor.vim
VimPlugin.getRegister()
.storeText(vimEditor, vimEditor.primaryCaret(), before rangeOf "A Discovery\n", SelectionType.LINE_WISE, false)
.storeText(editor, editor.primaryCaret(), before rangeOf "A Discovery\n", SelectionType.LINE_WISE, false)
typeText(injector.parser.parseKeys("p"))
val after = """
A Discovery
Expand Down Expand Up @@ -120,7 +120,7 @@ class PutTestAfterCursorActionTest : VimTestCaseBase() {
I found it in a legendary land
all rocks and lavender and tufted grass,
""".trimIndent()
val editor = configureByText(before)
val editor = configureByText(before).ij
// Add Guard to simulate Notebook behaviour. See (VIM-2577)
val guardRange = before rangeOf "\nGUARD\n"
editor.document.createGuardedBlock(guardRange.startOffset, guardRange.endOffset)
Expand Down Expand Up @@ -155,9 +155,8 @@ class PutTestAfterCursorActionTest : VimTestCaseBase() {
${c}hard by the torrent of a mountain pass.
""".trimIndent()
val editor = configureByText(before)
val vimEditor = editor.vim
VimPlugin.getRegister()
.storeText(vimEditor, vimEditor.primaryCaret(), before rangeOf "Discovery", SelectionType.CHARACTER_WISE, false)
.storeText(editor, editor.primaryCaret(), before rangeOf "Discovery", SelectionType.CHARACTER_WISE, false)
typeText(injector.parser.parseKeys("vep"))
val after = """
A Discovery
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ class PutTextBeforeCursorActionTest : VimTestCaseBase() {
hard by the torrent of a mountain pass.
""".trimIndent()
val editor = configureByText(before)
val vimEditor = editor.vim
injector.registerGroup.storeText(vimEditor, vimEditor.primaryCaret(), before rangeOf "Discovery", SelectionType.CHARACTER_WISE, false)
injector.registerGroup.storeText(editor, editor.primaryCaret(), before rangeOf "Discovery", SelectionType.CHARACTER_WISE, false)
typeText(injector.parser.parseKeys("V" + "P"))
typeText(injector.parser.parseKeys("V" + "P"))
val after = """
Expand Down
Loading