[gui-test] remove testGuiFramework from git4idea plugin

This commit is contained in:
Sergey Karashevich
2017-10-17 15:26:53 +03:00
parent 9754048878
commit 2c57725a02
5 changed files with 0 additions and 318 deletions
-1
View File
@@ -41,7 +41,6 @@
<orderEntry type="module" module-name="vcs-tests" scope="TEST" />
<orderEntry type="module" module-name="util" />
<orderEntry type="library" exported="" scope="TEST" name="cucumber-testing" level="project" />
<orderEntry type="module" module-name="testGuiFramework" scope="TEST" />
<orderEntry type="library" name="ini4j" level="project" />
<orderEntry type="module" module-name="tasks-platform-impl" />
<orderEntry type="module" module-name="tasks-platform-api" scope="TEST" />
@@ -1,83 +0,0 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.testGuiFramework.tests
import com.intellij.openapi.project.DumbService
import com.intellij.openapi.vcs.VcsBundle
import com.intellij.testGuiFramework.fixtures.JBListPopupFixture
import com.intellij.testGuiFramework.fixtures.ToolWindowFixture
import com.intellij.testGuiFramework.framework.GuiTestUtil
import com.intellij.ui.EditorComboBox
import org.fest.swing.edt.GuiActionRunner
import org.fest.swing.edt.GuiTask
import org.junit.Ignore
import org.junit.Test
/**
* @author Sergey Karashevich
*/
class GitGuiTest : GitGuiTestCase() {
@Test @Ignore
fun testGitImport(){
val vcsName = "Git"
val gitApp = "path_to_git_repo"
val projectPath = guiTestRule.getMasterProjectDirPath(gitApp)
welcomeFrame {
checkoutFrom()
JBListPopupFixture.findListPopup(robot()).invokeAction(vcsName)
dialog("Clone Repository") {
val labelText = "Git Repository URL:"
val editorComboBox = robot().finder().findByLabel(this.target(), labelText, EditorComboBox::class.java)
GuiActionRunner.execute(object : GuiTask() {
@Throws(Throwable::class)
override fun executeInEDT() {
editorComboBox.text = projectPath.absolutePath
}
})
button("Clone").click()
}
message(VcsBundle.message("checkout.title")).clickYes()
dialog("Import Project") {
button("Next").click()
val textField = GuiTestUtil.findTextField(robot(), "Project name:").click()
button("Next").click()
button("Next").click()
button("Next").click() //libraries
button("Next").click() //module dependencies
button("Next").click() //select sdk
button("Finish").click()
}
}
val ideFrame = guiTestRule.findIdeFrame()
ideFrame.waitForBackgroundTasksToFinish()
val projectView = ideFrame.projectView
val testJavaPath = "src/First.java"
val editor = ideFrame.editor
editor.open(testJavaPath)
ToolWindowFixture.showToolwindowStripes(robot())
//prevent from ProjectLeak (if the project is closed during the indexing
DumbService.getInstance(ideFrame.project).waitForSmartMode()
}
}
@@ -1,36 +0,0 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.testGuiFramework.tests
import com.intellij.testGuiFramework.impl.GuiTestCase
/**
* @author Sergey Karashevich
*/
open class GitGuiTestCase: GuiTestCase(){
// @Before
// override fun setUp() {
// super.setUp()
// if (IS_UNDER_TEAMCITY) GitSettings.setup()
// }
//
// @After
// override fun tearDown() {
// GitSettings.restore()
// super.tearDown()
// }
}
@@ -1,105 +0,0 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.testGuiFramework.tests
import com.intellij.execution.configurations.GeneralCommandLine
import com.intellij.execution.process.CapturingProcessHandler
import com.intellij.openapi.util.text.StringUtil
import com.intellij.openapi.vfs.CharsetToolkit
import com.intellij.testFramework.vcs.ExecutableHelper
import git4idea.config.GitVcsApplicationSettings
import java.util.*
import java.util.regex.Pattern
object GitSettings{
fun setup() {
setPathToGit()
cache()
setTestSettings()
}
fun restore() {
if (gitGlobalUserNameCached != null) setGitGlobalUserName(gitGlobalUserNameCached!!)
if (gitGlobalUserEmailCached != null) setGitGlobalUserEmail(gitGlobalUserEmailCached!!)
}
private val TEST_GIT_USER_NAME = "jetbrains_tester";
private val TEST_GIT_USER_EMAIL = "test@jetbrains.com";
private var gitGlobalUserNameCached: String? = null
private var gitGlobalUserEmailCached: String? = null
private fun setTestSettings() {
setGitGlobalUserName(TEST_GIT_USER_NAME)
setGitGlobalUserEmail(TEST_GIT_USER_EMAIL)
}
private fun cache() {
cacheGitGlobalUserName()
cacheGitGlobalUserEmail()
}
private fun cacheGitGlobalUserName() { gitGlobalUserNameCached = executeGitCommand("config user.name") }
private fun cacheGitGlobalUserEmail() { gitGlobalUserEmailCached = executeGitCommand("config user.email")
}
private fun setGitGlobalUserName(userName: String) { executeGitCommand("config --global user.name \"$userName\"") }
private fun setGitGlobalUserEmail(userEmail: String) { executeGitCommand("config --global user.email $userEmail") }
private fun setPathToGit() { GitVcsApplicationSettings.getInstance().setPathToGit(ExecutableHelper.findGitExecutable()) }
private fun getPathToGit() = GitVcsApplicationSettings.getInstance().pathToGit
private fun executeGitCommand(commandLine: String) = executeGitCommand(commandLine.splitSpaceIgnoreQuotes())
private fun executeGitCommand(params: List<String>): String? {
val myCommandLine = GeneralCommandLine()
myCommandLine.exePath = getPathToGit()
myCommandLine.addParameters(params)
val clientProcess = myCommandLine.createProcess()
val commandLineParams = StringUtil.join(params, " ")
val handler = CapturingProcessHandler(clientProcess, CharsetToolkit.getDefaultSystemCharset(), commandLineParams)
val result = handler.runProcess(30 * 1000)
if (result.isTimeout) {
throw RuntimeException("Timeout waiting for the command execution. Command: " + commandLineParams)
}
return result.stdout.removeSuffix("\n")
}
private fun String.splitSpaceIgnoreQuotes(): List<String> {
val matchList = ArrayList<String>()
val regex = Pattern.compile("[^\\s\"']+|\"([^\"]*)\"|'([^']*)'")
val regexMatcher = regex.matcher(this)
while (regexMatcher.find()) {
if (regexMatcher.group(1) != null) {
// Add double-quoted string without the quotes
matchList.add(regexMatcher.group(1))
}
else if (regexMatcher.group(2) != null) {
// Add single-quoted string without the quotes
matchList.add(regexMatcher.group(2))
} else {
// Add unquoted word
matchList.add(regexMatcher.group())
}
}
return matchList
}
}
@@ -1,93 +0,0 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.testGuiFramework.tests;
import com.intellij.ide.IdeBundle;
import com.intellij.idea.ActionsBundle;
import com.intellij.openapi.vcs.FileStatus;
import com.intellij.openapi.vcs.VcsBundle;
import com.intellij.testGuiFramework.fixtures.*;
import com.intellij.testGuiFramework.framework.ParentPlugin;
import git4idea.i18n.GitBundle;
import org.fest.swing.core.FastRobot;
import org.fest.swing.core.Robot;
import org.junit.Test;
import java.awt.event.KeyEvent;
import java.io.IOException;
import static com.intellij.testGuiFramework.framework.GuiTestUtil.findAndClickButton;
import static com.intellij.testGuiFramework.matcher.TitleMatcher.withTitleMatcher;
/**
* @author Sergey Karashevich
*/
@ParentPlugin(pluginId = "Git4Idea")
public class SimpleGitTest extends GitGuiTestCase {
@Test
public void testSimpleGit() throws IOException {
IdeFrameFixture ideFrameFixture = guiTestRule.importSimpleProject();
ideFrameFixture.waitForBackgroundTasksToFinish();
ProjectViewFixture.PaneFixture projectPane = ideFrameFixture.getProjectView().selectProjectPane();
final String projectName = ideFrameFixture.getProject().getName();
projectPane.expandByPath(projectName, "src");
Robot myRobot = robot();
//invoke "New..." action
invokeAction("NewElement");
//select first element (Java class)
myRobot.pressAndReleaseKey(KeyEvent.VK_ENTER);
JDialogFixture.find(myRobot, IdeBundle.message("action.create.new.class"));
myRobot.enterText("MyClass");
myRobot.pressAndReleaseKey(KeyEvent.VK_ENTER);
EditorFixture editorFixture = new EditorFixture(myRobot, ideFrameFixture);
FileFixture currentFileFixture = editorFixture.waitUntilFileIsLoaded();
ideFrameFixture.invokeMenuPath("VCS", ActionsBundle.message("group.Vcs.Import.text"), "Create Git Repository...");
FileChooserDialogFixture fileChooserDialogFixture = FileChooserDialogFixture.Companion
.findDialog(myRobot, withTitleMatcher(GitBundle.message("init.destination.directory.title")));
fileChooserDialogFixture.waitFilledTextField().clickOk();
pause("Wait when files will be added to Git Repository and marked as untracked",
30, () -> currentFileFixture.getVcsStatus().equals(FileStatus.UNKNOWN));
invokeAction("ChangesView.AddUnversioned");
pause("Wait when file will be marked as added",
30, () -> currentFileFixture.getVcsStatus().equals(FileStatus.ADDED));
invokeAction("CheckinProject");
JDialogFixture commitJDialogFixture = JDialogFixture.find(myRobot, VcsBundle.message("commit.dialog.title"));
myRobot.enterText("initial commit");
findAndClickButton(commitJDialogFixture, "Commit");
MessagesFixture messagesFixture = MessagesFixture.findAny(myRobot, commitJDialogFixture.target());
messagesFixture.click("Commit");
if (MessagesFixture.exists(myRobot, commitJDialogFixture.target(), "Check TODO is not possible right now")) {
MessagesFixture.findByTitle(myRobot, commitJDialogFixture.target(), "Check TODO is not possible right now").click("Commit");
}
pause("Wait when file will be marked as not changed (committed)", 300, () -> currentFileFixture.getVcsStatus().equals(FileStatus.NOT_CHANGED));
}
private void waitForIdle() {
if (robot() instanceof FastRobot) ((FastRobot)robot()).superWaitForIdle();
}
}