mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[terminal] IJPL-220311 Test Java completion spec in both Reworked and Experimental terminals
GitOrigin-RevId: 144bc856846f012f293886b0ffde8fc59803e14c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
23fe717328
commit
2261aceb3b
+33
-12
@@ -7,19 +7,28 @@ import com.intellij.java.terminal.JavaShellCommandUtils
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.terminal.completion.spec.ShellCommandResult
|
||||
import com.intellij.terminal.completion.spec.ShellCompletionSuggestion
|
||||
import com.intellij.terminal.completion.spec.ShellFileInfo
|
||||
import com.intellij.testFramework.UsefulTestCase
|
||||
import com.intellij.testFramework.fixtures.BasePlatformTestCase
|
||||
import com.intellij.testFramework.replaceService
|
||||
import junit.framework.TestCase
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.jetbrains.plugins.terminal.TerminalEngine
|
||||
import org.jetbrains.plugins.terminal.block.completion.spec.ShellFileSystemSupport
|
||||
import org.jetbrains.plugins.terminal.testFramework.completion.ShellCompletionTestFixture
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.junit.runners.JUnit4
|
||||
import org.junit.runners.Parameterized
|
||||
import java.util.concurrent.CompletableFuture
|
||||
|
||||
@RunWith(JUnit4::class)
|
||||
class JavaShellCommandSpecsProviderTest : BasePlatformTestCase() {
|
||||
@RunWith(Parameterized::class)
|
||||
class JavaShellCommandSpecsProviderTest(private val engine: TerminalEngine) : BasePlatformTestCase() {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
@Parameterized.Parameters(name = "{0}")
|
||||
fun engine(): List<TerminalEngine> = listOf(TerminalEngine.REWORKED, TerminalEngine.NEW_TERMINAL)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `default options are present`() = runBlocking {
|
||||
val fixture = ShellCompletionTestFixture.builder(project).mockShellCommandResults { _ ->
|
||||
@@ -123,17 +132,29 @@ class JavaShellCommandSpecsProviderTest : BasePlatformTestCase() {
|
||||
|
||||
private fun createFixture(javaVersion: Int = 11): ShellCompletionTestFixture {
|
||||
ApplicationManager.getApplication().replaceService(VMOptionsService::class.java, MockVMOptionsService(), testRootDisposable)
|
||||
val fixture = ShellCompletionTestFixture.builder(project).mockShellCommandResults { command ->
|
||||
if (command == JavaShellCommandContext.JAVA_SHOW_SETTINGS_PROPERTIES_VERSION_COMMAND) {
|
||||
return@mockShellCommandResults ShellCommandResult.create("java.home = /jre/home\njava.version = ${javaVersion}", exitCode = 0)
|
||||
}
|
||||
val fixture = ShellCompletionTestFixture.builder(project)
|
||||
.setIsReworkedTerminal(engine == TerminalEngine.REWORKED)
|
||||
.mockShellCommandResults { command ->
|
||||
if (command == JavaShellCommandContext.JAVA_SHOW_SETTINGS_PROPERTIES_VERSION_COMMAND) {
|
||||
return@mockShellCommandResults ShellCommandResult.create("java.home = /jre/home\njava.version = ${javaVersion}", exitCode = 0)
|
||||
}
|
||||
|
||||
if (command.startsWith("__jetbrains_intellij_get_directory_files")) {
|
||||
return@mockShellCommandResults ShellCommandResult.create("file1.jar\nfile2.jar\ndir1/", exitCode = 0)
|
||||
}
|
||||
if (command.startsWith("__jetbrains_intellij_get_directory_files")) {
|
||||
return@mockShellCommandResults ShellCommandResult.create("file1.jar\nfile2.jar\ndir1/", exitCode = 0)
|
||||
}
|
||||
|
||||
return@mockShellCommandResults ShellCommandResult.create("", exitCode = 1)
|
||||
}.build()
|
||||
return@mockShellCommandResults ShellCommandResult.create("", exitCode = 1)
|
||||
}
|
||||
.mockFileSystemSupport(object : ShellFileSystemSupport {
|
||||
override suspend fun listDirectoryFiles(path: String): List<ShellFileInfo> {
|
||||
return listOf(
|
||||
ShellFileInfo.create("file1.jar", ShellFileInfo.Type.FILE),
|
||||
ShellFileInfo.create("file2.jar", ShellFileInfo.Type.FILE),
|
||||
ShellFileInfo.create("dir1", ShellFileInfo.Type.DIRECTORY),
|
||||
)
|
||||
}
|
||||
})
|
||||
.build()
|
||||
return fixture
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user