Search in sources :

Example 76 with SWTBotShell

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project translationstudio8 by heartsome.

the class ProjectDelete method deletePrj.

/**
	 * 删除项目
	 * @param name
	 *            项目名称
	 * @param deleteContent
	 *            是否同时删除项目文件夹
	 */
public void deletePrj(Entry from, String name, boolean deleteContent) {
    ProjectTreeView ptv = ProjectTreeView.getInstance();
    SWTBotTree treePrj = ProjectTreeView.getTree();
    Waits.prjExistOnTree(name);
    // 取消选中任何项目,避免误操作
    treePrj.unselect();
    // 选择项目并删除
    treePrj.select(name).isActive();
    switch(from) {
        case CONTEXT_MENU:
            {
                ptv.ctxMenuDelete().click();
                break;
            }
        case MENU:
            {
                TS.getInstance().menuEditDelete().click();
                break;
            }
        default:
            {
                assertTrue("无此入口:" + from, false);
            }
    }
    // 确认删除对话框
    ConfirmProjectDeleteDialog cpd = new ConfirmProjectDeleteDialog(name);
    cpd.isActive();
    // 选择是否删除内容
    if (deleteContent) {
        cpd.radBtnAlsoDeleteContentsUnder().click();
        cpd.btnYes().click();
        Waits.shellClosed(cpd);
        SWTBotShell[] shells = HSBot.bot().shells();
        if (shells.length > 1) {
            ProgressDialog dlgProg = new ProgressDialog("dlgTitleProgressDeleteResource");
            Waits.shellClosed(dlgProg);
        }
        Waits.prjNotExistOnTree(name);
        Waits.prjNotExistInWorkspace(name);
    } else {
        cpd.radBtnDoNotDeleteContents().click();
        cpd.btnYes().click();
        Waits.shellClosed(cpd);
        SWTBotShell[] shells = HSBot.bot().shells();
        if (shells.length > 1) {
            ProgressDialog dlgProg = new ProgressDialog("dlgTitleProgressDeleteResource");
            Waits.shellClosed(dlgProg);
        }
        Waits.prjNotExistOnTree(name);
        Waits.prjExistInWorkspace(name);
    }
}
Also used : ConfirmProjectDeleteDialog(net.heartsome.cat.ts.test.ui.msgdialogs.ConfirmProjectDeleteDialog) SWTBotTree(org.eclipse.swtbot.swt.finder.widgets.SWTBotTree) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) ProgressDialog(net.heartsome.cat.ts.test.ui.msgdialogs.ProgressDialog) ProjectTreeView(net.heartsome.cat.ts.test.ui.views.ProjectTreeView)

Example 77 with SWTBotShell

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project linuxtools by eclipse.

the class BuildDockerImageShortcutSWTBotTest method shouldNotBuildDockerImageOnSecondCallWhenDockerfileWasRemoved.

@Test
@RunWithProject("foo")
public void shouldNotBuildDockerImageOnSecondCallWhenDockerfileWasRemoved() throws InterruptedException, com.spotify.docker.client.exceptions.DockerException, IOException, CoreException {
    // given
    final DockerClient client = MockDockerClientFactory.build();
    final DockerConnection dockerConnection = MockDockerConnectionFactory.from("Test", client).withDefaultTCPConnectionSettings();
    DockerConnectionManagerUtils.configureConnectionManager(dockerConnection);
    // when
    SWTUtils.asyncExec(() -> getRunAsdockerImageBuildContextMenu("foo", "Dockerfile").click());
    // then expect a dialog, fill the "repository" text field and click "Ok"
    assertThat(bot.shell(WizardMessages.getString("ImageBuildDialog.title"))).isNotNull();
    bot.textWithLabel(WizardMessages.getString("ImageBuildDialog.repoNameLabel")).setText("foo/bar:latest");
    // when launching the build
    SWTUtils.syncExec(() -> {
        bot.button("OK").click();
    });
    // then the 'DockerConnection#buildImage(...) method should have been
    // called within the specified timeout
    Mockito.verify(client, Mockito.timeout((int) TimeUnit.SECONDS.toMillis(30)).times(1)).build(Matchers.any(Path.class), Matchers.any(String.class), Matchers.any(ProgressHandler.class), Matchers.anyVararg());
    // when trying to call again after file was removed, there should
    // be an error dialog
    projectInit.getProject().findMember("Dockerfile").delete(true, new NullProgressMonitor());
    bot.toolbarDropDownButtonWithTooltip("Run").menuItem("1 foo_bar [latest]").click();
    // $NON-NLS-1$
    final SWTBotShell shell = bot.shell(JobMessages.getString("BuildImageJob.title"));
    assertThat(shell).isNotNull();
    // closing the dialog
    SWTUtils.syncExec(() -> {
        shell.bot().button(IDialogConstants.OK_LABEL).click();
    });
}
Also used : DockerConnection(org.eclipse.linuxtools.internal.docker.core.DockerConnection) Path(java.nio.file.Path) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) DockerClient(com.spotify.docker.client.DockerClient) ProgressHandler(com.spotify.docker.client.ProgressHandler) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Test(org.junit.Test) RunWithProject(org.eclipse.linuxtools.internal.docker.ui.testutils.RunWithProject)

Example 78 with SWTBotShell

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project linuxtools by eclipse.

the class SVNProject method checkoutProject.

/**
 * Use File => Import => SVN to create a svn-backed project.
 */
public IProject checkoutProject() throws IllegalStateException {
    if (repoURL == null || projectName == null) {
        // need to have url and project set
        throw new IllegalStateException();
    }
    bot.menu("File").menu("Import...").click();
    SWTBotShell shell = bot.shell("Import");
    shell.activate();
    bot.tree().expandNode("SVN").select("Checkout Projects from SVN");
    bot.button("Next >").click();
    // create new repo
    shell = bot.shell("Checkout from SVN");
    shell.activate();
    bot.button("Next >").click();
    shell = bot.shell("Checkout from SVN");
    shell.activate();
    // Enter url
    bot.comboBoxWithLabelInGroup("Url:", "Location").setText(repoURL);
    bot.button("Next >").click();
    // the next few operation can take quite a while, adjust
    // timout accordingly.
    long oldTimeout = SWTBotPreferences.TIMEOUT;
    SWTBotPreferences.TIMEOUT = 3 * 5000;
    shell = bot.shell("Progress Information").activate();
    bot.waitUntil(Conditions.shellCloses(shell));
    shell = bot.shell("Checkout from SVN").activate();
    bot.waitUntil(new TreeItemAppearsCondition(repoURL, projectName));
    SWTBotTreeItem projectTree = bot.tree().expandNode(repoURL);
    projectTree.expandNode(projectName).select();
    bot.button("Finish").click();
    // Wait for import operation to finish
    bot.waitUntil(Conditions.shellCloses(shell));
    SWTBotShell svnCheckoutPopup = bot.shell("SVN Checkout").activate();
    bot.waitUntil(Conditions.shellCloses(svnCheckoutPopup));
    // need a little delay
    bot.waitUntil(new SVNProjectCreatedCondition(projectName));
    // Set timout back what it was.
    SWTBotPreferences.TIMEOUT = oldTimeout;
    // A quick sanity check
    IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
    IProject changelogTestsProject = (IProject) wsRoot.findMember(new Path(projectName));
    assertNotNull(changelogTestsProject);
    try {
        changelogTestsProject.refreshLocal(IResource.DEPTH_INFINITE, null);
    } catch (CoreException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    IResource manifest = changelogTestsProject.findMember(new Path("/META-INF/MANIFEST.MF"));
    assertNotNull(manifest);
    return changelogTestsProject;
}
Also used : Path(org.eclipse.core.runtime.Path) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) CoreException(org.eclipse.core.runtime.CoreException) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) IProject(org.eclipse.core.resources.IProject) IResource(org.eclipse.core.resources.IResource)

Example 79 with SWTBotShell

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project linuxtools by eclipse.

the class TestCreateSystemtapScript method testDeleteBlankRegex.

@Test
public void testDeleteBlankRegex() {
    SWTBotShell shell = prepareScript("blank.stp", null);
    // Confirm that adding a new regex when the current one is blank has no effect.
    SWTBotCombo combo = bot.comboBoxWithLabel(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
    assertEquals(2, combo.itemCount());
    combo.setSelection(1);
    assertEquals(2, combo.itemCount());
    assertEquals(0, combo.selectionIndex());
    // Confirm that adding a regex works when the current regex is not empty.
    combo.setText("(a) b (c)");
    assertEquals("(a) b (c)", combo.getText());
    combo.setSelection(1);
    assertEquals(3, combo.itemCount());
    assertEquals(1, combo.selectionIndex());
    // Confirm that a blank regex is not removed when other data is not empty.
    combo.setText("(a)");
    bot.button(Messages.SystemTapScriptGraphOptionsTab_AddGraphButton).click();
    SWTBotShell graphShell = bot.shell("Create Graph").activate();
    graphShell.setFocus();
    bot.textWithLabel("Title:").setText("Test");
    bot.button("Finish").click();
    bot.waitUntil(Conditions.shellCloses(graphShell));
    shell.setFocus();
    combo.setText("");
    assertEquals("", combo.getText());
    combo.setSelection(0);
    assertEquals(3, combo.itemCount());
    // Confirm that auto-deleting a blank regex in the middle of the regex list works properly.
    combo.setSelection(2);
    assertEquals(4, combo.itemCount());
    combo.setText("sample");
    combo.setSelection(1);
    assertEquals(4, combo.itemCount());
    SWTBotTable table = bot.table();
    SWTBotButton remButton = bot.button(Messages.SystemTapScriptGraphOptionsTab_RemoveGraphButton);
    assertTrue(!remButton.isEnabled());
    table.select(0);
    assertTrue(remButton.isEnabled());
    remButton.click();
    assertTrue(!remButton.isEnabled());
    combo.setSelection(2);
    assertEquals(3, combo.itemCount());
    assertEquals("sample", combo.getText());
    assertEquals("(a) b (c)", combo.items()[0]);
    assertEquals("sample", combo.items()[1]);
    // Confirm that auto-deleting a regex from the beginning of the list works properly.
    combo.setSelection(2);
    combo.setText("another sample");
    combo.setSelection(0);
    combo.setText("");
    combo.setSelection(1);
    assertEquals(3, combo.itemCount());
    assertEquals("sample", combo.getText());
    assertEquals("sample", combo.items()[0]);
    assertEquals("another sample", combo.items()[1]);
}
Also used : SWTBotCombo(org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo) SWTBotButton(org.eclipse.swtbot.swt.finder.widgets.SWTBotButton) SWTBotTable(org.eclipse.swtbot.swt.finder.widgets.SWTBotTable) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) Test(org.junit.Test)

Example 80 with SWTBotShell

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotShell in project linuxtools by eclipse.

the class TestCreateSystemtapScript method testGraphConfig.

@Test
public void testGraphConfig() {
    String scriptName = "testGraph.stp";
    createScript(bot, scriptName);
    final String val0 = "i";
    final String val1 = "j";
    final String val2 = "k";
    openRunConfigurations(scriptName);
    SWTBotShell shell = bot.shell("Run Configurations");
    shell.setFocus();
    bot.tree().select("SystemTap").contextMenu("New").click();
    bot.textWithLabel("Name:").setText(scriptName);
    // Select the "Graphing" tab.
    SWTBotCTabItem tab = bot.cTabItem(Messages.SystemTapScriptGraphOptionsTab_graphingTitle);
    tab.activate();
    bot.checkBox(Messages.SystemTapScriptGraphOptionsTab_graphOutputRun).click();
    // Create first regex.
    SWTBotCombo combo = bot.comboBoxWithLabel(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
    combo.setText("Value:(\\d+) (\\d+)");
    assertEquals("Value:(\\d+) (\\d+)", combo.getText());
    SWTBotText text = bot.textWithLabel(Messages.SystemTapScriptGraphOptionsTab_sampleOutputLabel);
    text.setText("Value:1 2");
    assertEquals("Value:1 2", text.getText());
    text = bot.text(MessageFormat.format(Messages.SystemTapScriptGraphOptionsTab_defaultColumnTitleBase, 1));
    text.setText(val0);
    assertEquals(val0, text.getText());
    text = bot.text(MessageFormat.format(Messages.SystemTapScriptGraphOptionsTab_defaultColumnTitleBase, 2));
    text.setText(val1);
    assertEquals(val1, text.getText());
    setupGraphWithTests("Values", false);
    // Make a second regex, and a graph for it.
    shell.setFocus();
    combo = bot.comboBoxWithLabel(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
    assertEquals(2, combo.itemCount());
    combo.setSelection(combo.selectionIndex() + 1);
    assertEquals(3, combo.itemCount());
    assertEquals("", combo.getText());
    combo.setText("Other:(\\d+) (\\d+)");
    assertEquals("Other:(\\d+) (\\d+)", combo.getText());
    text = bot.text(MessageFormat.format(Messages.SystemTapScriptGraphOptionsTab_defaultColumnTitleBase, 1));
    text.setText(val0);
    assertEquals(val0, text.getText());
    text = bot.text(MessageFormat.format(Messages.SystemTapScriptGraphOptionsTab_defaultColumnTitleBase, 2));
    text.setText(val2);
    assertEquals(val2, text.getText());
    text = bot.textWithLabel(Messages.SystemTapScriptGraphOptionsTab_sampleOutputLabel);
    assertEquals("", text.getText());
    setupGraphWithTests("Others", false);
    // Apply the changes, then close the menu & reopen it to make sure settings were saved.
    shell.setFocus();
    bot.button("Apply").click();
    bot.button("Close").click();
    bot.waitUntil(Conditions.shellCloses(shell));
    openRunConfigurations(scriptName);
    shell = bot.shell("Run Configurations");
    shell.setFocus();
    // Set the filter text to show configs of the current script
    shell.bot().text().setText(scriptName);
    bot.waitUntil(new NodeAvailableAndSelect(bot.tree(), "SystemTap", scriptName));
    tab = bot.cTabItem(Messages.SystemTapScriptGraphOptionsTab_graphingTitle);
    tab.activate();
    combo = bot.comboBoxWithLabel(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
    text = bot.textWithLabel(Messages.SystemTapScriptGraphOptionsTab_sampleOutputLabel);
    SWTBotTable table = bot.table();
    assertEquals(3, combo.itemCount());
    assertEquals("Value:(\\d+) (\\d+)", combo.getText());
    assertEquals("Value:1 2", text.getText());
    assertEquals(1, table.rowCount());
    String graphName = GraphFactory.getGraphName("org.eclipse.linuxtools.systemtap.graphing.ui.charts.scatterchartbuilder");
    assertTrue(table.containsItem(graphName.concat(":Values")));
    combo.setSelection(1);
    assertEquals("Other:(\\d+) (\\d+)", combo.getText());
    assertEquals("", text.getText());
    assertEquals(1, table.rowCount());
    assertTrue(table.containsItem(graphName.concat(":Others")));
}
Also used : SWTBotCombo(org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo) SWTBotText(org.eclipse.swtbot.swt.finder.widgets.SWTBotText) SWTBotTable(org.eclipse.swtbot.swt.finder.widgets.SWTBotTable) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) SWTBotCTabItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotCTabItem) Test(org.junit.Test)

Aggregations

SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)158 Test (org.junit.Test)82 SWTBotTree (org.eclipse.swtbot.swt.finder.widgets.SWTBotTree)46 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)40 Repository (org.eclipse.jgit.lib.Repository)18 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)11 SWTBotTable (org.eclipse.swtbot.swt.finder.widgets.SWTBotTable)11 File (java.io.File)10 SWTBot (org.eclipse.swtbot.swt.finder.SWTBot)9 SWTBotText (org.eclipse.swtbot.swt.finder.widgets.SWTBotText)9 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)7 WidgetNotFoundException (org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException)7 SWTBotCombo (org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo)7 Path (org.eclipse.core.runtime.Path)6 JobJoiner (org.eclipse.egit.ui.test.JobJoiner)6 Shell (org.eclipse.swt.widgets.Shell)6 SWTBotButton (org.eclipse.swtbot.swt.finder.widgets.SWTBotButton)6 IProject (org.eclipse.core.resources.IProject)5 SWTBotEclipseEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor)5 ICondition (org.eclipse.swtbot.swt.finder.waits.ICondition)5