diff --git a/plugins/terminal/tests/src/com/intellij/terminal/tests/reworked/frontend/TerminalCopyOnSelectionTest.kt b/plugins/terminal/tests/src/com/intellij/terminal/tests/reworked/frontend/TerminalCopyOnSelectionTest.kt index 0ef117e0378e..ff22def8526d 100644 --- a/plugins/terminal/tests/src/com/intellij/terminal/tests/reworked/frontend/TerminalCopyOnSelectionTest.kt +++ b/plugins/terminal/tests/src/com/intellij/terminal/tests/reworked/frontend/TerminalCopyOnSelectionTest.kt @@ -3,7 +3,6 @@ package com.intellij.terminal.tests.reworked.frontend import com.intellij.mock.MockFocusManager import com.intellij.openapi.editor.Editor import com.intellij.openapi.editor.LogicalPosition -import com.intellij.openapi.ide.CopyPasteManager import com.intellij.openapi.util.Disposer import com.intellij.platform.util.coroutines.childScope import com.intellij.terminal.JBTerminalSystemSettingsProviderBase @@ -11,6 +10,8 @@ import com.intellij.terminal.frontend.view.impl.TerminalEditorFactory import com.intellij.terminal.tests.reworked.util.TerminalTestUtil import com.intellij.testFramework.fixtures.BasePlatformTestCase import kotlinx.coroutines.cancel +import org.assertj.core.api.Assertions.assertThat +import org.jetbrains.plugins.terminal.block.ui.getClipboardText import org.jetbrains.plugins.terminal.util.terminalProjectScope import org.junit.Assume import org.junit.Before @@ -18,7 +19,6 @@ import org.junit.Test import org.junit.jupiter.api.condition.OS import org.junit.runner.RunWith import org.junit.runners.JUnit4 -import java.awt.datatransfer.DataFlavor @RunWith(JUnit4::class) internal class TerminalCopyOnSelectionTest : BasePlatformTestCase() { @@ -40,15 +40,11 @@ internal class TerminalCopyOnSelectionTest : BasePlatformTestCase() { // Select "first" editor.selectionModel.setSelection(0, 5) - val copied = copiedTransferable() - assertNotNull(copied) - assertEquals("first", copied!!.getTransferData(DataFlavor.stringFlavor)) + assertThat(getClipboardText()).isEqualTo("first") // Clearing the selection fires a selection change event with an empty selection. editor.selectionModel.removeSelection() - val afterClear = copiedTransferable() - assertNotNull(afterClear) - assertEquals("first", afterClear!!.getTransferData(DataFlavor.stringFlavor)) + assertThat(getClipboardText()).isEqualTo("first") } @Test @@ -64,17 +60,13 @@ internal class TerminalCopyOnSelectionTest : BasePlatformTestCase() { // A vertical (block) selection is copied to the clipboard. editor.selectionModel.setBlockSelection(LogicalPosition(0, 1), LogicalPosition(2, 4)) - val copied = copiedTransferable() - assertNotNull(copied) - assertEquals("irs\neco\nhir", copied!!.getTransferData(DataFlavor.stringFlavor)) + assertThat(getClipboardText()).isEqualTo("irs\neco\nhir") // Clearing the block selection collapses back to a single caret (as a click does) and fires a // selection change event with an empty selection. It must not overwrite the clipboard. editor.caretModel.removeSecondaryCarets() editor.selectionModel.removeSelection(true) - val afterClear = copiedTransferable() - assertNotNull(afterClear) - assertEquals("irs\neco\nhir", afterClear!!.getTransferData(DataFlavor.stringFlavor)) + assertThat(getClipboardText()).isEqualTo("irs\neco\nhir") } private fun createTerminalEditor(): Editor { @@ -95,6 +87,4 @@ internal class TerminalCopyOnSelectionTest : BasePlatformTestCase() { ) return editor } - - private fun copiedTransferable() = CopyPasteManager.getInstance().let { it.systemSelectionContents ?: it.contents } }