[gui-test] make CreateJdkGuiTest accessible for all editions

This commit is contained in:
Viktoria.Shirunova
2018-12-01 13:17:05 +03:00
parent a27b457553
commit a63f799e72
5 changed files with 91 additions and 34 deletions
@@ -9,6 +9,7 @@ import com.intellij.testGuiFramework.framework.GuiTestSuiteRunner
import com.intellij.testGuiFramework.framework.RunWithIde
import com.intellij.testGuiFramework.launcher.ide.CommunityIde
import com.intellij.testGuiFramework.launcher.ide.CommunityIdeFirstStart
import com.intellij.testGuiFramework.testCases.CreateJdkGuiTest
import org.junit.runner.RunWith
import org.junit.runners.Suite
@@ -73,6 +74,7 @@ class ConfigureKotlinReleaseGuiTestSuite : GuiTestSuite()
@Suite.SuiteClasses(
InstallPluginGuiTest::class
, CreateSdksGuiTest::class
, CreateJdkGuiTest::class
)
class PreparationSteps
@@ -13,33 +13,7 @@ import org.junit.Ignore
import org.junit.Test
class CreateSdksGuiTest : KotlinGuiTestCase() {
val dialogName = "Project Structure for New Projects"
@Test
@Ignore
fun createJdk(){
logTestStep("Create a JDK on the path `${KotlinTestProperties.jdk_path}`")
welcomeFrame {
actionLink("Configure").click()
// starting from 191
popupMenu("Structure for New Projects").clickSearchedItem()
logUIStep("Open `$dialogName` dialog")
dialog(dialogName) {
jList("SDKs").clickItem("SDKs")
actionButton("Add New SDK").click()
popupMenu("JDK").clickSearchedItem()
logUIStep("Open `Select Home Directory for JDK` dialog")
dialog("Select Home Directory for JDK") {
actionButton("Refresh").click()
logUIStep("Type the path `${KotlinTestProperties.jdk_path}`")
typeText(KotlinTestProperties.jdk_path)
logUIStep("Close `Select Home Directory for JDK` dialog with OK")
button("OK").click()
}
logUIStep("Close `Default Project Structure` dialog with OK")
button("OK").click()
}
}
}
private val dialogName = "Project Structure for New Projects"
@Test
fun createKotlinSdk(){
@@ -81,10 +81,4 @@ object KotlinTestProperties {
val kotlin_plugin_version_full: String
get() = "v${getPropertyValue("kotlin.plugin.version.full")}"
/**
* @return path where the Java is installed
*/
val jdk_path: String
get() = getPropertyValue("JAVA_HOME")
}
@@ -19,6 +19,7 @@ import org.hamcrest.Matcher
import org.junit.Assert.assertTrue
import org.junit.rules.ErrorCollector
import java.awt.IllegalComponentStateException
import javax.swing.JTree
fun <T> ErrorCollector.checkThat(value: T, matcher: Matcher<T>, reason: () -> String) {
checkThat(reason(), value, matcher)
@@ -106,7 +107,7 @@ fun GuiTestCase.waitAMoment() {
fun GuiTestCase.testTreeItemExist(name: String, vararg expectedItem: String, predicate: FinderPredicate = Predicate.equality) {
ideFrame {
logInfo("Check that $name -> ${expectedItem.joinToString(" -> ")} exists in a tree element")
kotlin.assert(exists { jTree(*expectedItem, predicate = predicate, timeout = Timeouts.seconds03) }) { "$name '${expectedItem.joinToString(", ")}' not found" }
kotlin.assert(exists { jTree(*expectedItem, predicate = predicate) }) { "$name '${expectedItem.joinToString(", ")}' not found" }
}
}
@@ -325,3 +326,46 @@ fun GuiTestCase.checkGutterIcons(gutterIcon: GutterFixture.GutterIcon,
}
}
}
fun GuiTestCase.createJdk(jdkPath: String, jdkName: String = ""): String{
val dialogName = "Project Structure for New Projects"
logTestStep("Create a JDK on the path `$jdkPath`")
lateinit var installedJdkName: String
welcomeFrame {
actionLink("Configure").click()
popupMenu("Project Defaults").clickSearchedItem()
popupMenu("Project Structure").clickSearchedItem()
logUIStep("Open `$dialogName` dialog")
dialog(dialogName) {
jList("SDKs").clickItem("SDKs")
val sdkTree: ExtendedJTreePathFixture = jTree()
fun JTree.getListOfInstalledSdks(): List<String> {
val root = model.root
return (0 until model.getChildCount(root))
.map { model.getChild(root, it).toString() }.toList()
}
val preInstalledSdks = sdkTree.tree.getListOfInstalledSdks()
installedJdkName = if(jdkName.isEmpty() || preInstalledSdks.contains(jdkName).not()){
actionButton("Add New SDK").click()
popupMenu("JDK").clickSearchedItem()
logUIStep("Open `Select Home Directory for JDK` dialog")
dialog("Select Home Directory for JDK") {
actionButton("Refresh").click()
logUIStep("Type the path `$jdkPath`")
typeText(jdkPath)
logUIStep("Close `Select Home Directory for JDK` dialog with OK")
button("OK").click()
}
val postInstalledSdks = sdkTree.tree.getListOfInstalledSdks()
postInstalledSdks.first { preInstalledSdks.contains(it).not() }
}
else jdkName
logUIStep("Close `Default Project Structure` dialog with OK")
button("OK").click()
} // dialog Project Structure
} // ideFrame
return installedJdkName
}
@@ -0,0 +1,43 @@
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.testGuiFramework.testCases
import com.intellij.testGuiFramework.impl.GuiTestCase
import com.intellij.testGuiFramework.impl.createJdk
import org.junit.Ignore
import org.junit.Test
class CreateJdkGuiTest : GuiTestCase() {
private val javaHome = "JAVA_HOME"
private val java18Home = "JAVA18_HOME"
private val java11Home = "JAVA11_HOME"
private fun getProperty(name: String) = System.getenv(name) ?: throw IllegalStateException("Property `$name` not set in Environment!")
@Test
fun createJdk18() {
val expectedJdk = "1.8"
val installedJdk = createJdk(getProperty(java18Home), expectedJdk)
assert(expectedJdk == installedJdk) {
"Expected JDK 1.8 to be installed, but $installedJdk discovered"
}
}
@Test
@Ignore
fun createJdk11() {
val expectedJdk = "11"
val installedJdk = createJdk(getProperty(java11Home), expectedJdk)
assert(expectedJdk == installedJdk) {
"Expected JDK 11 to be installed, but $installedJdk discovered"
}
}
@Test
@Ignore
fun createJdkFromHome() {
createJdk(getProperty(javaHome))
}
override fun isIdeFrameRun() = false
}