[gui-test] fix first start

This commit is contained in:
Vladislav Shishov
2019-01-17 14:46:37 +03:00
parent 2eed470f0f
commit fc2fcfca59
@@ -42,8 +42,6 @@ abstract class FirstStart(val ideType: IdeType) {
private val FIRST_START_ROBOT_THREAD = "First Start Robot Thread" private val FIRST_START_ROBOT_THREAD = "First Start Robot Thread"
private val LOG = Logger.getInstance(this.javaClass.name)
val myRobot: Robot val myRobot: Robot
private val robotThread: Thread = thread(start = false, name = FIRST_START_ROBOT_THREAD) { private val robotThread: Thread = thread(start = false, name = FIRST_START_ROBOT_THREAD) {
@@ -85,7 +83,7 @@ abstract class FirstStart(val ideType: IdeType) {
init { init {
myRobot = SmartWaitRobot() myRobot = SmartWaitRobot()
LOG.info("Starting separated thread: '$FIRST_START_ROBOT_THREAD' to complete initial installation") println("Starting separated thread: '$FIRST_START_ROBOT_THREAD' to complete initial installation")
robotThread.start() robotThread.start()
} }
@@ -111,7 +109,7 @@ abstract class FirstStart(val ideType: IdeType) {
fun Frame.close() = myRobot.close(this) fun Frame.close() = myRobot.close(this)
fun findWelcomeFrame(seconds: Int = 5): Frame? { fun findWelcomeFrame(seconds: Int = 5): Frame? {
LOG.info("Waiting for a Welcome Frame") println("Waiting for a Welcome Frame")
silentWaitUntil("Welcome Frame to show up", seconds) { silentWaitUntil("Welcome Frame to show up", seconds) {
Frame.getFrames().any { checkIsWelcomeFrame(it) } Frame.getFrames().any { checkIsWelcomeFrame(it) }
} }
@@ -135,28 +133,29 @@ abstract class FirstStart(val ideType: IdeType) {
open fun acceptAgreement() { open fun acceptAgreement() {
if (!needToShowAgreement()) return if (!needToShowAgreement()) return
try { try {
LOG.info("Waiting for License Agreement/Privacy Policy dialog") println("Waiting for License Agreement/Privacy Policy dialog")
findPrivacyPolicyDialogOrLicenseAgreement() findPrivacyPolicyDialogOrLicenseAgreement()
with(JDialogFixture(myRobot, findPrivacyPolicyDialogOrLicenseAgreement())) { with(JDialogFixture(myRobot, findPrivacyPolicyDialogOrLicenseAgreement())) {
click() click()
checkboxContainingText("i confirm", true, Timeouts.noTimeout).select() checkboxContainingText("i confirm", true, Timeouts.noTimeout).select()
LOG.info("Accept License Agreement/Privacy Policy dialog") println("Accept License Agreement/Privacy Policy dialog")
button("Continue", Timeouts.seconds05).click() button("Continue", Timeouts.seconds05).click()
} }
} }
catch (e: WaitTimedOutError) { catch (e: WaitTimedOutError) {
LOG.warn("'License Agreement/Privacy Policy dialog hasn't been shown. Check registry...") println("'License Agreement/Privacy Policy dialog hasn't been shown. Check registry...")
} }
} }
open fun completeInstallation() { open fun completeInstallation() {
if (!needToShowCompleteInstallation()) return if (!needToShowCompleteInstallation()) return
with(myRobot) { with(myRobot) {
val title = "Complete Installation" println("Waiting for 'import settings' dialog")
LOG.info("Waiting for '$title' dialog") val dialogFixture = dialog {
val dialogFixture = dialog(title) it.startsWith("Import")
}
LOG.info("Click OK on 'Do not import settings'") println("Click OK on 'Do not import settings'")
dialogFixture.radioButton("Do not import settings").select() dialogFixture.radioButton("Do not import settings").select()
repeatUntil( repeatUntil(
@@ -168,15 +167,15 @@ abstract class FirstStart(val ideType: IdeType) {
open fun acceptDataSharing() { open fun acceptDataSharing() {
with(myRobot) { with(myRobot) {
LOG.info("Accepting Data Sharing") println("Accepting Data Sharing")
val title = "Data Sharing" val title = "Data Sharing"
try { try {
dialog(title, timeout = Timeouts.seconds05) dialog(title, timeout = Timeouts.seconds05)
button("Send Usage Statistics").click() button("Send Usage Statistics").click()
LOG.info("Data sharing accepted") println("Data sharing accepted")
} }
catch (e: WaitTimedOutError) { catch (e: WaitTimedOutError) {
LOG.info("Data sharing dialog hasn't been shown") println("Data sharing dialog hasn't been shown")
return return
} }
} }
@@ -186,10 +185,10 @@ abstract class FirstStart(val ideType: IdeType) {
if (!needToShowCustomizeWizard()) return if (!needToShowCustomizeWizard()) return
with(myRobot) { with(myRobot) {
val title = "Customize $ideName" val title = "Customize $ideName"
LOG.info("Waiting for '$title' dialog") println("Waiting for '$title' dialog")
dialog(title) dialog(title)
val buttonText = "Skip Remaining and Set Defaults" val buttonText = "Skip Remaining and Set Defaults"
LOG.info("Click '$buttonText'") println("Click '$buttonText'")
button(buttonText).click() button(buttonText).click()
} }
} }
@@ -197,20 +196,20 @@ abstract class FirstStart(val ideType: IdeType) {
open fun evaluateLicense(ideName: String, robot: Robot) { open fun evaluateLicense(ideName: String, robot: Robot) {
with(robot) { with(robot) {
val licenseActivationFrameTitle = "$ideName License Activation" val licenseActivationFrameTitle = "$ideName License Activation"
LOG.info("Waiting for '$licenseActivationFrameTitle' dialog") println("Waiting for '$licenseActivationFrameTitle' dialog")
try { try {
waitFrame(licenseActivationFrameTitle) { it == licenseActivationFrameTitle } waitFrame(licenseActivationFrameTitle) { it == licenseActivationFrameTitle }
radioButton("Evaluate for free").select() radioButton("Evaluate for free").select()
val evaluateButton = button("Evaluate") val evaluateButton = button("Evaluate")
GuiTestUtilKt.waitUntil("activate button will be enabled") { evaluateButton.isEnabled } GuiTestUtilKt.waitUntil("activate button will be enabled") { evaluateButton.isEnabled }
LOG.info("Click '${evaluateButton.text()}'") println("Click '${evaluateButton.text()}'")
evaluateButton.click() evaluateButton.click()
dialog(timeout = Timeouts.seconds10) { it.startsWith("License Agreement for") } dialog(timeout = Timeouts.seconds10) { it.startsWith("License Agreement for") }
button("Accept").click() button("Accept").click()
} }
catch (waitTimedOutError: WaitTimedOutError) { catch (waitTimedOutError: WaitTimedOutError) {
LOG.info("No License Activation dialog has been found") println("No License Activation dialog has been found")
} }
} }
} }