From 52b713bda5238620179dec92a88909b8bb035db2 Mon Sep 17 00:00:00 2001 From: Sergey Karashevich Date: Mon, 26 Mar 2018 20:22:23 +0300 Subject: [PATCH] [gui-test] replace create project with import project --- .../tests/community/CommunityProjectCreator.kt | 12 +++++++++++- .../tests/community/focus/FocusIssuesSuite.kt | 2 +- .../tests/community/focus/GoToClassFocusTest.kt | 2 +- .../community/focus/GoToClassTwiceFocusTest.kt | 16 +++++++++------- .../community/focus/InlineVariableFocusTest.kt | 2 +- .../focus/InputMethodJapaneseFocusTest.kt | 2 +- .../focus/KeyMapSettingsTestFocusTest.kt | 2 +- .../community/focus/ReplaceInPathFocusTest.kt | 5 +++-- .../community/focus/SearchEverywhereFocusTest.kt | 2 +- .../tests/community/focus/TypeAheadTest.kt | 2 +- .../src/org/fest/swing/core/SmartWaitRobot.kt | 4 ++++ 11 files changed, 34 insertions(+), 17 deletions(-) diff --git a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/CommunityProjectCreator.kt b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/CommunityProjectCreator.kt index 15c104b3c535..6a655883cf70 100644 --- a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/CommunityProjectCreator.kt +++ b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/CommunityProjectCreator.kt @@ -1,6 +1,7 @@ // 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.tests.community +import com.intellij.ide.IdeBundle import com.intellij.openapi.diagnostic.Logger import com.intellij.testGuiFramework.impl.GuiTestCase import com.intellij.testGuiFramework.impl.GuiTestUtilKt @@ -11,6 +12,7 @@ import com.intellij.testGuiFramework.util.Modifier.META import com.intellij.testGuiFramework.util.plus import com.intellij.testGuiFramework.utils.TestUtilsClass import com.intellij.testGuiFramework.utils.TestUtilsClassCompanion +import org.fest.swing.exception.ComponentLookupException import org.fest.swing.exception.WaitTimedOutError import org.junit.Assert import java.io.File @@ -41,6 +43,7 @@ class CommunityProjectCreator(guiTestCase: GuiTestCase) : TestUtilsClass(guiTest jList("Command Line App").clickItem("Command Line App") button("Next").click() typeText(projectName) + checkFileAlreadyExistsDialog() //confirm overwriting already created project button("Finish").click() } } @@ -49,6 +52,13 @@ class CommunityProjectCreator(guiTestCase: GuiTestCase) : TestUtilsClass(guiTest } } + private fun GuiTestCase.checkFileAlreadyExistsDialog() { + try { + val dialogFixture = dialog(IdeBundle.message("title.file.already.exists"), false, 10L) + dialogFixture.button("Yes").click() + } catch (cle: ComponentLookupException) { /*do nothing here */ } + } + private fun GuiTestCase.openMainInCommandLineProject() { ideFrame { projectView { @@ -69,7 +79,7 @@ class CommunityProjectCreator(guiTestCase: GuiTestCase) : TestUtilsClass(guiTest private fun GuiTestCase.waitForFirstIndexing() { ideFrame { - val secondToWaitIndexing = 300 + val secondToWaitIndexing = 10 try { waitForStartingIndexing(secondToWaitIndexing) //let's wait for 2 minutes until indexing bar will appeared } diff --git a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/FocusIssuesSuite.kt b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/FocusIssuesSuite.kt index 3a934dcc563d..75ff2c11ffe2 100644 --- a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/FocusIssuesSuite.kt +++ b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/FocusIssuesSuite.kt @@ -13,7 +13,7 @@ import org.junit.runners.Suite @RunWithIde(CommunityIde::class) @FirstStartWith(CommunityIdeFirstStart::class) @Suite.SuiteClasses(CompletionFocusTest::class, - TypeAheadTest::class, +// TypeAheadTest::class, GoToClassFocusTest::class, GoToClassTwiceFocusTest::class, InlineVariableFocusTest::class, diff --git a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/GoToClassFocusTest.kt b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/GoToClassFocusTest.kt index 62b4b57eae7a..a5e8fbeece34 100644 --- a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/GoToClassFocusTest.kt +++ b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/GoToClassFocusTest.kt @@ -26,7 +26,7 @@ class GoToClassFocusTest : GuiTestCase() { @Test fun testGoToClassFocus() { - CommunityProjectCreator.createCommandLineProject() + CommunityProjectCreator.importCommandLineAppAndOpenMain() Pause.pause(1000) ideFrame { focusOnEditor() diff --git a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/GoToClassTwiceFocusTest.kt b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/GoToClassTwiceFocusTest.kt index 627a1d220a5b..5d632b3570be 100644 --- a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/GoToClassTwiceFocusTest.kt +++ b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/GoToClassTwiceFocusTest.kt @@ -1,16 +1,14 @@ // 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.tests.community.focus -import com.intellij.openapi.actionSystem.ActionManager +import com.intellij.openapi.actionSystem.ShortcutSet import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.keymap.KeymapUtil import com.intellij.testGuiFramework.fixtures.IdeFrameFixture import com.intellij.testGuiFramework.impl.GuiTestCase import com.intellij.testGuiFramework.impl.GuiTestUtilKt import com.intellij.testGuiFramework.tests.community.CommunityProjectCreator -import com.intellij.testGuiFramework.util.Key import com.intellij.testGuiFramework.util.Key.ESCAPE -import com.intellij.testGuiFramework.util.Modifier -import com.intellij.testGuiFramework.util.plus import org.fest.swing.core.SmartWaitRobot import org.fest.swing.exception.ComponentLookupException import org.fest.swing.timing.Pause @@ -26,11 +24,15 @@ import javax.swing.KeyStroke class GoToClassTwiceFocusTest : GuiTestCase() { private val typedString = "hefuihwefwehrf;werfwerfw" - private val actionKeyStroke: KeyStroke by lazy { ActionManager.getInstance().getKeyboardShortcut("GotoClass")!!.firstKeyStroke } + private val actionKeyStroke: KeyStroke by lazy { + val activeKeymapShortcuts: ShortcutSet = KeymapUtil.getActiveKeymapShortcuts("GotoClass") + KeymapUtil.getKeyStroke(activeKeymapShortcuts)!! + } + @Test fun testGoToClassFocusTwice() { - CommunityProjectCreator.createCommandLineProject() + CommunityProjectCreator.importCommandLineAppAndOpenMain() Pause.pause(1000) ideFrame { focusOnEditor() @@ -74,7 +76,7 @@ class GoToClassTwiceFocusTest : GuiTestCase() { private fun openGoToClassSearchAndType(guiTestCase: GuiTestCase) { val smartRobot = guiTestCase.robot() as SmartWaitRobot - guiTestCase.shortcut(Modifier.CONTROL + Key.N, Modifier.META + Key.N) + smartRobot.shortcut(actionKeyStroke) smartRobot.shortcutAndTypeString(actionKeyStroke, typedString, 100) Pause.pause(500) checkSearchWindow(guiTestCase) diff --git a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/InlineVariableFocusTest.kt b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/InlineVariableFocusTest.kt index f099fa457fb4..a93e7b431430 100644 --- a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/InlineVariableFocusTest.kt +++ b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/InlineVariableFocusTest.kt @@ -44,7 +44,7 @@ public class Test { @Test fun testInlineVariableFocus() { - CommunityProjectCreator.createCommandLineProject() + CommunityProjectCreator.importCommandLineAppAndOpenMain() Pause.pause(1000) CommunityProjectCreator.createJavaClass(pasteCode, "Test") ideFrame { diff --git a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/InputMethodJapaneseFocusTest.kt b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/InputMethodJapaneseFocusTest.kt index 405e625efb8c..3f718570d400 100644 --- a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/InputMethodJapaneseFocusTest.kt +++ b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/InputMethodJapaneseFocusTest.kt @@ -33,7 +33,7 @@ class InputMethodJapaneseFocusTest : GuiTestCase() { */ @Test fun testGoToClassFocus() { - CommunityProjectCreator.createCommandLineProject() + CommunityProjectCreator.importCommandLineAppAndOpenMain() Pause.pause(1000) ideFrame { focusOnEditor() diff --git a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/KeyMapSettingsTestFocusTest.kt b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/KeyMapSettingsTestFocusTest.kt index 2feed1f85a72..5f4433afd0fc 100644 --- a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/KeyMapSettingsTestFocusTest.kt +++ b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/KeyMapSettingsTestFocusTest.kt @@ -20,7 +20,7 @@ class KeyMapSettingsTestFocusTest : GuiTestCase() { @Test fun testKeyMapSettingsTestFocus() { - CommunityProjectCreator.createCommandLineProject() + CommunityProjectCreator.importCommandLineAppAndOpenMain() Pause.pause(1000) ideFrame { waitForBackgroundTasksToFinish() diff --git a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/ReplaceInPathFocusTest.kt b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/ReplaceInPathFocusTest.kt index 1bc0145d1f81..5168d29e19d3 100644 --- a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/ReplaceInPathFocusTest.kt +++ b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/ReplaceInPathFocusTest.kt @@ -12,6 +12,7 @@ import com.intellij.testGuiFramework.util.plus import org.fest.swing.exception.ComponentLookupException import org.fest.swing.exception.WaitTimedOutError import org.fest.swing.timing.Pause +import org.junit.Ignore import org.junit.Test import java.util.concurrent.TimeUnit @@ -24,7 +25,7 @@ class ReplaceInPathFocusTest : GuiTestCase() { */ @Test fun testReplaceInPathDumbModeFocus() { - CommunityProjectCreator.createCommandLineProject(projectName = "replace-in-path-dumb-mode") + CommunityProjectCreator.importCommandLineAppAndOpenMain() Pause.pause(1000) ideFrame { dumbMode { @@ -39,7 +40,7 @@ class ReplaceInPathFocusTest : GuiTestCase() { * IDEA-188229 * Fixed by 6bd20c4a483a78713c08e426316d29d3cfd1f6a5 */ - @Test + @Test @Ignore fun testReplaceInPathFocus() { CommunityProjectCreator.importCommandLineAppAndOpenMain() Pause.pause(1000) diff --git a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/SearchEverywhereFocusTest.kt b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/SearchEverywhereFocusTest.kt index 10434c9327a5..ef5ede4b510a 100644 --- a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/SearchEverywhereFocusTest.kt +++ b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/SearchEverywhereFocusTest.kt @@ -24,7 +24,7 @@ class SearchEverywhereFocusTest : GuiTestCase() { @Test fun testSearchEverywhereFocus() { - CommunityProjectCreator.createCommandLineProject() + CommunityProjectCreator.importCommandLineAppAndOpenMain() Pause.pause(1000) ideFrame { focusOnEditor() diff --git a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/TypeAheadTest.kt b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/TypeAheadTest.kt index fd9e02d8403d..a45fcf20cd19 100644 --- a/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/TypeAheadTest.kt +++ b/community-guitests/testSrc/com/intellij/testGuiFramework/tests/community/focus/TypeAheadTest.kt @@ -15,7 +15,7 @@ class TypeAheadTest : GuiTestCase() { @Test fun testTypeAhead() { - CommunityProjectCreator.createCommandLineProject("type-ahead-problem") + CommunityProjectCreator.importCommandLineAppAndOpenMain() ideFrame { waitForBackgroundTasksToFinish() configurationList { diff --git a/platform/testGuiFramework/src/org/fest/swing/core/SmartWaitRobot.kt b/platform/testGuiFramework/src/org/fest/swing/core/SmartWaitRobot.kt index dfea7d3a7c86..2e6a8e7a3027 100644 --- a/platform/testGuiFramework/src/org/fest/swing/core/SmartWaitRobot.kt +++ b/platform/testGuiFramework/src/org/fest/swing/core/SmartWaitRobot.kt @@ -150,6 +150,10 @@ class SmartWaitRobot : BasicRobot(null, ExistingHierarchy()) { fastReleaseKey(keyCode) } + fun shortcut(keyStoke: KeyStroke) { + fastPressAndReleaseKey(keyStoke.keyCode, keyStoke.modifiers) + } + fun shortcutAndTypeString(keyStoke: KeyStroke, string: String, delayBetweenShortcutAndTypingMs: Int = 0) { fastPressAndReleaseKey(keyStoke.keyCode, keyStoke.modifiers) fastTyping(string, delayBetweenShortcutAndTypingMs)