[terminal] IJPL-248564 Refactor TerminalCopyOnSelectionTest: extract MockFocusManager to the test framework

(cherry picked from commit c212ebb5184cb5c10bcdbf2441a461276e6833a3)

IJ-CR-211956

GitOrigin-RevId: ceefc3a5f841533b03ed65f4bad48d6b53e6f9ea
This commit is contained in:
Konstantin Hudyakov
2026-07-29 18:11:10 +00:00
committed by intellij-monorepo-bot
parent fbe874b42b
commit a94d9eaa8c
4 changed files with 21 additions and 37 deletions
@@ -3,6 +3,7 @@ package com.intellij.openapi.editor.impl;
import com.intellij.ide.ui.AntialiasingType;
import com.intellij.ide.ui.UISettings;
import com.intellij.mock.MockFocusManager;
import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.colors.EditorColors;
@@ -1,32 +0,0 @@
/*
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.openapi.editor.impl;
import javax.swing.FocusManager;
import java.awt.Component;
class MockFocusManager extends FocusManager {
private final Component myFocusOwner;
MockFocusManager(Component focusOwner) {
myFocusOwner = focusOwner;
}
@Override
public Component getFocusOwner() {
return myFocusOwner;
}
}
@@ -0,0 +1,18 @@
// Copyright 2000-2026 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.mock;
import javax.swing.FocusManager;
import java.awt.Component;
public final class MockFocusManager extends FocusManager {
private final Component myFocusOwner;
public MockFocusManager(Component focusOwner) {
myFocusOwner = focusOwner;
}
@Override
public Component getFocusOwner() {
return myFocusOwner;
}
}
@@ -1,5 +1,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
@@ -18,8 +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.Component
import java.awt.DefaultKeyboardFocusManager
import java.awt.datatransfer.DataFlavor
@RunWith(JUnit4::class)
@@ -93,9 +92,7 @@ internal class TerminalCopyOnSelectionTest : BasePlatformTestCase() {
// Copy on selection only works if terminal is the focus owner.
TerminalTestUtil.replaceKeyboardFocusManager(
testRootDisposable,
object : DefaultKeyboardFocusManager() {
override fun getFocusOwner(): Component = editor.contentComponent
}
MockFocusManager(editor.contentComponent)
)
return editor
}