Search in sources :

Example 26 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 27 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 28 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 29 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)

Example 30 with SWTBotShell

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

the class TestCreateSystemtapScript method testGraphContents.

@Test
public void testGraphContents() {
    final String valA1 = "A1";
    final String valB1 = "B1";
    createAndViewDummyData(new String[] { valA1, valB1 }, new Integer[] { 0, 0, 1, 2, 2, 4, 3, 6, 4, 8, 5, 10, 6, 12, 7, 14, 8, 16, 9, 18 });
    SWTBotEditor graphEditorA = bot.activeEditor();
    final String valA2 = "A2";
    final String valB2 = "B2";
    createAndViewDummyData(new String[] { valA2, valB2 }, new Integer[] { 2, 0, 5, 1, 7, 2, 10, 3 });
    SWTBotEditor graphEditorB = bot.activeEditor();
    // Add graphs.
    setupGraphWithTests("Others", true);
    String graphTitle2 = "Others - Scatter Graph";
    graphEditorA.show();
    setupGraphWithTests("Values", true);
    String graphTitle1 = "Values - Scatter Graph";
    // Test table & graph contents.
    graphEditorA.bot().cTabItem("Data View").activate();
    SWTBotTable dataTable = bot.table();
    List<String> colNames = dataTable.columns();
    assertEquals(3, colNames.size());
    assertEquals(valA1, colNames.get(1));
    assertEquals(valB1, colNames.get(2));
    assertEquals("2", dataTable.cell(2, 1));
    assertEquals("4", dataTable.cell(2, 2));
    graphEditorA.bot().cTabItem(graphTitle1).activate();
    Matcher<AbstractChartBuilder> matcher = widgetOfType(AbstractChartBuilder.class);
    AbstractChartBuilder cb = bot.widget(matcher);
    ISeries[] series = cb.getChart().getSeriesSet().getSeries();
    assertEquals(2, series.length);
    assertEquals(10, series[0].getXSeries().length);
    assertEquals(10, series[1].getXSeries().length);
    assertEquals(2, (int) series[0].getYSeries()[2]);
    assertEquals(4, (int) series[1].getYSeries()[2]);
    graphEditorB.show();
    graphEditorB.bot().cTabItem("Data View").activate();
    dataTable = bot.table();
    colNames = dataTable.columns();
    assertEquals(3, colNames.size());
    assertEquals(valA2, colNames.get(1));
    assertEquals(valB2, colNames.get(2));
    assertEquals("7", dataTable.cell(2, 1));
    assertEquals("2", dataTable.cell(2, 2));
    graphEditorB.bot().cTabItem(graphTitle2).activate();
    cb = bot.widget(matcher);
    series = cb.getChart().getSeriesSet().getSeries();
    assertEquals(2, series.length);
    assertEquals(4, series[0].getXSeries().length);
    assertEquals(4, series[1].getXSeries().length);
    assertEquals(7, (int) series[0].getYSeries()[2]);
    assertEquals(2, (int) series[1].getYSeries()[2]);
    // Test filters on the data table & graphs.
    graphEditorA.show();
    graphEditorA.bot().cTabItem("Data View").activate();
    dataTable = bot.table();
    new SWTBotMenu(ContextMenuHelper.contextMenu(dataTable, "Add filter...")).click();
    SWTBotShell shell = bot.shell("Create Filter");
    shell.setFocus();
    // Match Filter - Remove a matching
    bot.button("Match Filter").click();
    bot.button("Next >").click();
    bot.text().setText("2");
    deselectDefaultSelection(0);
    bot.radio(1).click();
    bot.button("Finish").click();
    bot.waitUntil(Conditions.shellCloses(shell));
    bot.waitUntil(new TableHasUpdated(graphEditorA.bot().table(), 9, true));
    assertEquals("3", dataTable.cell(2, 1));
    assertEquals("6", dataTable.cell(2, 2));
    // Filters should be applied to graphs as well as data tables.
    graphEditorA.bot().cTabItem(graphTitle1).activate();
    cb = bot.widget(matcher);
    series = cb.getChart().getSeriesSet().getSeries();
    bot.waitUntil(new ChartHasUpdated(cb.getChart(), 9));
    assertEquals(3, (int) series[0].getYSeries()[2]);
    assertEquals(6, (int) series[1].getYSeries()[2]);
    // Each graph set should have its own filters.
    graphEditorB.show();
    graphEditorB.bot().cTabItem("Data View").activate();
    dataTable = bot.table();
    assertEquals(4, dataTable.rowCount());
    assertEquals("2", dataTable.cell(0, 1));
    // Test removing a filter.
    graphEditorA.show();
    graphEditorA.bot().cTabItem("Data View").activate();
    dataTable = bot.table();
    new SWTBotMenu(ContextMenuHelper.contextMenu(dataTable, "Remove filter...", "Match Filter: \"" + valA1 + "\" removing \"2\"")).click();
    bot.waitUntil(new TableHasUpdated(graphEditorA.bot().table(), 10, true));
    assertEquals("2", dataTable.cell(2, 1));
    assertEquals("4", dataTable.cell(2, 2));
}
Also used : SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu) SWTBotTable(org.eclipse.swtbot.swt.finder.widgets.SWTBotTable) AbstractChartBuilder(org.eclipse.linuxtools.systemtap.graphing.ui.charts.AbstractChartBuilder) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) ISeries(org.swtchart.ISeries) Test(org.junit.Test)

Aggregations

SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)41 Test (org.junit.Test)14 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)8 SWTBotTable (org.eclipse.swtbot.swt.finder.widgets.SWTBotTable)6 SWTBotTree (org.eclipse.swtbot.swt.finder.widgets.SWTBotTree)6 SWTBotEclipseEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor)5 SWTBotCombo (org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo)5 SWTBotText (org.eclipse.swtbot.swt.finder.widgets.SWTBotText)5 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)5 WidgetNotFoundException (org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException)4 Point (org.eclipse.swt.graphics.Point)3 SWTBotEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor)3 SWTBot (org.eclipse.swtbot.swt.finder.SWTBot)3 SWTBotMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)3 BeforeClass (org.junit.BeforeClass)3 DockerClient (com.spotify.docker.client.DockerClient)2 ProgressHandler (com.spotify.docker.client.ProgressHandler)2 Path (java.nio.file.Path)2 IFile (org.eclipse.core.resources.IFile)2 IWorkspace (org.eclipse.core.resources.IWorkspace)2