From 869e1f7e2ccda0ef0dda192269b44995a9d40975 Mon Sep 17 00:00:00 2001 From: "Maxim.Kolmakov" Date: Mon, 19 Jun 2017 20:01:14 +0200 Subject: [PATCH] GUI-17 Bound label can't be found in case it's not located in the direct parent --- .../testGuiFramework/generators/Generators.kt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/generators/Generators.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/generators/Generators.kt index 63875109481f..39b34567aaab 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/generators/Generators.kt +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/generators/Generators.kt @@ -610,16 +610,16 @@ object Utils { */ fun getBoundedLabel(hierarchyLevel: Int, component: Component): JLabel { - var currentComponent = component + var currentComponentParent = component.parent if (hierarchyLevel < 1) throw Exception( "Hierarchy level (actual is $hierarchyLevel) should starts from 1 to see bounded label for a component itself") for (i in 1..hierarchyLevel) { - val boundedLabel = findBoundedLabel(currentComponent) + val boundedLabel = findBoundedLabel(component, currentComponentParent.parent) if (boundedLabel != null) return boundedLabel else { - if (currentComponent.parent == null) break - currentComponent = currentComponent.parent + if (currentComponentParent.parent == null) break + currentComponentParent = currentComponentParent.parent } } @@ -627,13 +627,13 @@ object Utils { } - private fun findBoundedLabel(component: Component): JLabel? { + private fun findBoundedLabel(component: Component, componentParent: Component): JLabel? { return withRobot { robot -> var resultLabel: JLabel? if (component is LabeledComponent<*>) resultLabel = component.label else { try { - resultLabel = robot.finder().find(component.parent as Container, object : GenericTypeMatcher(JLabel::class.java) { + resultLabel = robot.finder().find(componentParent as Container, object : GenericTypeMatcher(JLabel::class.java) { override fun isMatching(label: JLabel) = (label.labelFor != null && label.labelFor == component) }) }