[gui-test] improved selectedWithKeyboard to work both when tree is expanded and no

This commit is contained in:
Viktoria.Shirunova
2018-04-26 18:59:10 +03:00
parent c466312def
commit e3fa6dbd9a
3 changed files with 15 additions and 9 deletions
@@ -48,8 +48,8 @@ class CreateKotlinMPProjectGuiTest : KotlinGuiTestCase() {
kotlinVersion,
expectedJars
)
checkFacetInOneModule(defaultFacetSettings[TargetPlatform.Common]!!, "$projectName(0)", "${projectName}_main", "Kotlin")
checkFacetInOneModule(defaultFacetSettings[TargetPlatform.Common]!!, "$projectName(0)", "${projectName}_test", "Kotlin")
checkFacetInOneModule(defaultFacetSettings[TargetPlatform.Common]!!, "$projectName", "${projectName}_main", "Kotlin")
checkFacetInOneModule(defaultFacetSettings[TargetPlatform.Common]!!, "$projectName", "${projectName}_test", "Kotlin")
if (setOfMPPModules.contains(KotlinKind.JS)) {
checkFacetInOneModule(defaultFacetSettings[TargetPlatform.JavaScript]!!, "${projectName}-js", "${projectName}-js_main", "Kotlin")
checkFacetInOneModule(defaultFacetSettings[TargetPlatform.JavaScript]!!, "${projectName}-js", "${projectName}-js_test", "Kotlin")
@@ -24,13 +24,19 @@ fun KotlinGuiTestCase.checkFacetInOneModule(expectedFacet: FacetStructure, varar
}
fun ExtendedTreeFixture.selectWithKeyboard(testCase: GuiTestCase, vararg path: String) {
fun currentValue(): String {
val selectedRow = target().selectionRows.first()
return valueAt(selectedRow) ?: throw IllegalStateException("Nothing is selected in the tree")
}
click()
testCase.shortcut(Key.HOME) // select the top row
for (step in 0 until path.size) {
val regex = Regex("""(.*)\(\d+\)""")
val clearedPathStep = if (regex.matches(path[step])) regex.matchEntire(path[step])!!.groups[1]?.value ?: path[step] else path[step]
testCase.typeText(clearedPathStep)
testCase.shortcut(Key.RIGHT)
for((index, step) in path.withIndex()){
if(currentValue() != step) {
testCase.typeText(step)
while (currentValue() != step)
testCase.shortcut(Key.DOWN)
}
if(index < path.size -1) testCase.shortcut(Key.RIGHT)
}
}
@@ -888,11 +888,11 @@ fun KotlinGuiTestCase.checkInProjectStructureGradleExplicitModuleGroups(
)
checkFacetInOneModule(
expectedFacet,
"$projectName(0)", "${projectName}_main", "Kotlin"
"$projectName", "${projectName}_main", "Kotlin"
)
checkFacetInOneModule(
expectedFacet,
"$projectName(0)", "${projectName}_test", "Kotlin"
"$projectName", "${projectName}_test", "Kotlin"
)
}
}