diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/ImmediatePainterTestCase.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/ImmediatePainterTestCase.java index 71b787d45cb0..0691c5c3af21 100644 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/ImmediatePainterTestCase.java +++ b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/ImmediatePainterTestCase.java @@ -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; diff --git a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/MockFocusManager.java b/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/MockFocusManager.java deleted file mode 100644 index 8d444e41bebd..000000000000 --- a/platform/platform-tests/testSrc/com/intellij/openapi/editor/impl/MockFocusManager.java +++ /dev/null @@ -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; - } -} diff --git a/platform/testFramework/src/com/intellij/mock/MockFocusManager.java b/platform/testFramework/src/com/intellij/mock/MockFocusManager.java new file mode 100644 index 000000000000..eb793c7d8a4a --- /dev/null +++ b/platform/testFramework/src/com/intellij/mock/MockFocusManager.java @@ -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; + } +} 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 08e6d9413559..81c811c547d5 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 @@ -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 }