From 45ca7ca6c3de9a8cbe7da6655a67e24674cdcb5a Mon Sep 17 00:00:00 2001 From: "Gregory.Shrago" Date: Sat, 23 Mar 2024 04:24:49 +0400 Subject: [PATCH] expand action groups in tests as in production GitOrigin-RevId: 8404b35e80ae99add0a99be47eb831a29fe6fe8d --- .../kotlin/idea/run/KotlinJUnitLightTest.kt | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/run/KotlinJUnitLightTest.kt b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/run/KotlinJUnitLightTest.kt index 7654750edb7b..b5fa79a5bf1b 100644 --- a/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/run/KotlinJUnitLightTest.kt +++ b/plugins/kotlin/idea/tests/test/org/jetbrains/kotlin/idea/run/KotlinJUnitLightTest.kt @@ -16,7 +16,10 @@ import com.intellij.execution.junit2.ui.properties.JUnitConsoleProperties import com.intellij.execution.lineMarker.RunLineMarkerProvider import com.intellij.execution.testframework.JavaTestLocator import com.intellij.execution.testframework.sm.runner.SMTestProxy -import com.intellij.openapi.actionSystem.AnAction +import com.intellij.openapi.actionSystem.ActionGroup +import com.intellij.openapi.actionSystem.ActionPlaces +import com.intellij.openapi.actionSystem.impl.PresentationFactory +import com.intellij.openapi.actionSystem.impl.Utils import com.intellij.openapi.application.impl.NonBlockingReadActionImpl import com.intellij.openapi.editor.markup.GutterIconRenderer import com.intellij.openapi.fileEditor.OpenFileDescriptor @@ -27,7 +30,6 @@ import com.intellij.psi.util.PsiTreeUtil import com.intellij.testFramework.TestActionEvent import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase import com.intellij.util.ThreeState -import com.intellij.util.containers.ContainerUtil import org.jetbrains.kotlin.asJava.toLightMethods import org.jetbrains.kotlin.idea.junit.JunitKotlinTestFrameworkProvider import org.jetbrains.kotlin.psi.KtFunction @@ -219,18 +221,19 @@ fun main(args: Array) {} val marks = myFixture.findGuttersAtCaret() assertEquals(1, marks.size) val mark = marks[0] as GutterIconRenderer - val group = mark.popupMenuActions + val group = mark.popupMenuActions as ActionGroup assertNotNull(group) - val event = TestActionEvent.createTestEvent() - val list = ContainerUtil.findAll(group!!.getChildren(event)) { action: AnAction -> - val actionEvent = TestActionEvent.createTestEvent() - action.update(actionEvent) - val text = actionEvent.presentation.text - text != null && text.startsWith("Run '") && text.endsWith("'") + val presentations = PresentationFactory() + val dataContext = TestActionEvent.createTestEvent().dataContext + val children = Utils.expandActionGroup( + group, presentations, dataContext, ActionPlaces.EDITOR_GUTTER_POPUP) + val list = children.filter { + presentations.getPresentation(it).text.run { + startsWith("Run '") && endsWith("'") + } } assertEquals(list.toString(), 1, list.size) - list[0].update(event) - assertEquals("Run 'ATest'", event.presentation.text) + assertEquals("Run 'ATest'", presentations.getPresentation(list[0]).text) myFixture.testAction(list[0]) NonBlockingReadActionImpl.waitForAsyncTaskCompletion() val selectedConfiguration = getInstance(project).selectedConfiguration