From df5648590860af3d7a15991ef143dde64ef53acb Mon Sep 17 00:00:00 2001 From: Sergey Karashevich Date: Sat, 1 Jul 2017 15:36:24 +0300 Subject: [PATCH] [gui-test] project view fix for generators --- .../com/intellij/testGuiFramework/generators/Generators.kt | 7 +++++-- .../generators/LocalContextCodeGenerator.kt | 3 +++ .../intellij/testGuiFramework/recorder/ContextChecker.kt | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/generators/Generators.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/generators/Generators.kt index bd00f291b185..e638fd745da9 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/generators/Generators.kt +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/generators/Generators.kt @@ -339,7 +339,8 @@ class IdeFrameGenerator : GlobalContextCodeGenerator() { class ProjectViewGenerator : LocalContextCodeGenerator() { - override fun priority() = 2 + override fun priority() = 0 + override fun isLastContext() = true override fun acceptor(): (Component) -> Boolean = { component -> component.javaClass.name.endsWith("ProjectViewImpl\$MyPanel") } override fun generate(cmp: JPanel) = "projectView {" @@ -347,6 +348,8 @@ class ProjectViewGenerator : LocalContextCodeGenerator() { class ToolWindowGenerator : LocalContextCodeGenerator() { + override fun priority() = 1 + private fun Component.containsLocationOnScreen(locationOnScreen: Point): Boolean { val rectangle = this.bounds rectangle.location = this.locationOnScreen @@ -386,7 +389,7 @@ class ToolWindowGenerator : LocalContextCodeGenerator() { class ToolWindowContextGenerator : LocalContextCodeGenerator() { - override fun priority() = 1 + override fun priority() = 2 private fun Component.containsLocationOnScreen(locationOnScreen: Point): Boolean { val rectangle = this.bounds diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/generators/LocalContextCodeGenerator.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/generators/LocalContextCodeGenerator.kt index b625fe23190d..ae247f0be93f 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/generators/LocalContextCodeGenerator.kt +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/generators/LocalContextCodeGenerator.kt @@ -38,6 +38,9 @@ abstract class LocalContextCodeGenerator : ContextCodeGenerator ProjectView + open fun isLastContext(): Boolean = false + abstract fun acceptor(): (Component) -> Boolean override fun accept(cmp: Component) = (findComponentInHierarchy(cmp) != null) diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/ContextChecker.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/ContextChecker.kt index e54a78f3a116..4283cd5207b1 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/ContextChecker.kt +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/recorder/ContextChecker.kt @@ -88,7 +88,10 @@ private class ContextTree(val writeFun: (String) -> Unit) { } fun addContexts(localContextList: List) { - localContextList.forEach { addContext(it) } + for(context in localContextList) { + addContext(context) + if (context.originalGenerator is LocalContextCodeGenerator && context.originalGenerator.isLastContext()) break + } } private fun Context.inContextTree(): Boolean =