From f85d215486e90ddf7d0d2bec2b1ea1e4bd414832 Mon Sep 17 00:00:00 2001 From: "Viktoria.Shirunova" Date: Wed, 21 Nov 2018 14:42:02 +0300 Subject: [PATCH] [gui-test] CheckboxTreeFixture.setCheckboxValue: added attempts to repeat the click if previous click wasn't successful --- .../fixtures/CheckboxTreeFixture.kt | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/CheckboxTreeFixture.kt b/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/CheckboxTreeFixture.kt index 80361c6e147f..d02098928c24 100644 --- a/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/CheckboxTreeFixture.kt +++ b/platform/testGuiFramework/src/com/intellij/testGuiFramework/fixtures/CheckboxTreeFixture.kt @@ -2,13 +2,13 @@ package com.intellij.testGuiFramework.fixtures import com.intellij.testGuiFramework.driver.CheckboxTreeDriver -import com.intellij.testGuiFramework.util.FinderPredicate import com.intellij.testGuiFramework.fixtures.extended.ExtendedJTreePathFixture import com.intellij.testGuiFramework.impl.GuiRobotHolder +import com.intellij.testGuiFramework.util.FinderPredicate import com.intellij.testGuiFramework.util.Predicate -import com.intellij.testGuiFramework.util.currentTimeInHumanString import com.intellij.ui.CheckboxTree import org.fest.swing.core.Robot +import org.fest.swing.timing.Pause class CheckboxTreeFixture( checkboxTree: CheckboxTree, @@ -27,15 +27,16 @@ class CheckboxTreeFixture( private fun getCheckboxComponent() = myDriver.getCheckboxComponent(target() as CheckboxTree, path) private fun setCheckboxValue(value: Boolean) { + val maxNumberOfAttempts = 3 + var currentAttempt = maxNumberOfAttempts clickPath() - val checkbox = getCheckboxComponent() - if (checkbox != null && checkbox.isSelected != value) { + while (currentAttempt > 0 && value != isSelected()) { clickCheckbox() - val actualValue = getCheckboxComponent()?.isSelected - assert(actualValue == value) { - "Checkbox at path $path: actual value is $actualValue, but expected is $value" - } + currentAttempt-- + Pause.pause(500) // let's wait for animation of check drawing finishing } + val actualValue = isSelected() + assert(actualValue == value) {"Checkbox at path $path: actual value is $actualValue, but expected is $value, after ${maxNumberOfAttempts - currentAttempt} attempts"} } fun check() = setCheckboxValue(true)