Search in sources :

Example 6 with SWTBotCombo

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo 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 7 with SWTBotCombo

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo 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 8 with SWTBotCombo

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

the class TestCreateSystemtapScript method setupGraphWithTests.

private static void setupGraphWithTests(String title, boolean isTab) {
    SWTBotShell firstShell = bot.activeShell();
    openGraphMenu(isTab);
    SWTBotShell shell = bot.shell("Create Graph");
    shell.setFocus();
    SWTBotText text = bot.textWithLabel("Title:");
    text.setText(title);
    assertEquals(title, text.getText());
    SWTBotCombo comboX = bot.comboBoxWithLabel("X Series:");
    // X Series includes "Row Num" as a selection
    assertEquals(3, comboX.itemCount());
    SWTBotCombo comboY0 = bot.comboBoxWithLabel("Y Series 0:");
    // Y Series 0 only includes series entries
    assertEquals(2, comboY0.itemCount());
    comboY0.setSelection(0);
    SWTBotCombo comboY1 = bot.comboBoxWithLabel("Y Series 1:");
    // Y Series (i>0) has extra "NA" option as first entry
    assertEquals(3, comboY1.itemCount());
    comboY1.setSelection(1);
    // Don't allow duplicate selections
    assertFalse(bot.button("Finish").isEnabled());
    comboY1.setSelection(2);
    bot.button("Finish").click();
    bot.waitUntil(Conditions.shellCloses(shell));
    firstShell.setFocus();
}
Also used : SWTBotCombo(org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo) SWTBotText(org.eclipse.swtbot.swt.finder.widgets.SWTBotText) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)

Aggregations

SWTBotCombo (org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo)8 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)5 Test (org.junit.Test)4 SWTBotTable (org.eclipse.swtbot.swt.finder.widgets.SWTBotTable)3 IsComboEquals (net.heartsome.test.swtbot.waits.IsComboEquals)2 Point (org.eclipse.swt.graphics.Point)2 SWTBotButton (org.eclipse.swtbot.swt.finder.widgets.SWTBotButton)2 SWTBotText (org.eclipse.swtbot.swt.finder.widgets.SWTBotText)2 GraphData (org.eclipse.linuxtools.systemtap.graphing.core.structures.GraphData)1 SWTBotCTabItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotCTabItem)1