use of org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo in project translationstudio8 by heartsome.
the class XlfEditor method selectLangPair.
/**
* 选择指定的语言对
* @param srcLang
* 源语言代码
* @param tgtLang
* 目标语言代码
*/
public void selectLangPair(String srcLang, String tgtLang) {
String langPair = srcLang + " -> " + tgtLang;
SWTBotCombo langCombo = getLangCombo();
langCombo.setSelection(langPair);
bot.waitUntil(new IsComboEquals(langCombo, langPair));
SWTBotAssert.assertText(langPair, langCombo);
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo in project translationstudio8 by heartsome.
the class XlfEditor method selectSegFilter.
/**
* 选择指定的文本段过滤器
* @param filterName
* 过滤器名称
*/
public void selectSegFilter(final String filterName) {
SWTBotCombo segFilterCombo = getSegFilterCombo();
segFilterCombo.setSelection(filterName);
bot.waitUntil(new IsComboEquals(segFilterCombo, filterName));
SWTBotAssert.assertText(filterName, segFilterCombo);
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo in project linuxtools by eclipse.
the class TestCreateSystemtapScript method testGenerateFromPrintf.
@Test
public void testGenerateFromPrintf() {
SWTBotShell shell = prepareScript("testGenerates.stp", "#!/usr/bin/env stap" + "\nglobal i,j,k,a" + "\nprobe begin{i=0;j=5;k=20;a=65}" + "\n#probe begin{printf(\"%1b%1b%1blo %1b%1brld\\n\", 72,101,108,87,111)}" + "\nprobe timer.ms(100){printf(\"%5i|\\n%10.5d|\\n%-10.5i|\\n%05c\\n\",i,j,k,a);i++;j+=5;k+=20;a++}" + "\n//printf(\"this is a comment\\n\");" + "\n/*printf(\"this is a...\\n\");" + "\nprintf(\"...multiline comment\\n\");*/" + "\nprobe begin{b = sprintf(\"Here\"); printf(\"-->%s<--\\n\", b)}" + "\nprobe timer.ms(100){printf(\"%x - %#x - %#X\\n\",i,i,i);}" + "\nprobe timer.ms(100){printf(\"%o - %#o\\n\",i,i);}" + "\nprobe begin{printf(\"%1b-\\\\n-%p\\n\", 65, 0x8000000002345678)}");
// Generate regexs.
bot.button(Messages.SystemTapScriptGraphOptionsTab_generateFromPrintsButton).click();
SWTBotShell dialogShell = bot.shell(Messages.SystemTapScriptGraphOptionsTab_generateFromPrintsTitle);
dialogShell.setFocus();
bot.button("Yes").click();
bot.waitUntil(Conditions.shellCloses(dialogShell));
shell.setFocus();
SWTBotCombo combo = bot.comboBoxWithLabel(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
// One extra entry for "Add New Regex"
assertEquals(9, combo.itemCount());
String[] expectedRegexs = new String[] { " {0,4}(-?\\d+)\\|", " {0,9}(-?\\d+)\\|", "(-?\\d+) {0,9}\\|", " {0,4}(.)", "-->(.+)<--", "([a-f0-9]+) - (0x[a-f0-9]+) - (0X[A-F0-9]+)", "(\\d+) - (0\\d+)", "(.)-\\\\n-(0x[a-f0-9]+)", Messages.SystemTapScriptGraphOptionsTab_regexAddNew };
for (int i = 0, n = combo.itemCount(); i < n; i++) {
assertEquals(expectedRegexs[i], combo.items()[i]);
}
bot.button("Apply").click();
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo in project linuxtools by eclipse.
the class TestCreateSystemtapScript method testGraphErrors.
@Test
public void testGraphErrors() {
SWTBotShell shell = prepareScript("missingColumns.stp", null);
SWTBotButton runButton = bot.button("Run");
SWTBotButton addButton = bot.button(Messages.SystemTapScriptGraphOptionsTab_AddGraphButton);
SWTBotButton editButton = bot.button(Messages.SystemTapScriptGraphOptionsTab_EditGraphButton);
SWTBotButton dupButton = bot.button(Messages.SystemTapScriptGraphOptionsTab_DuplicateGraphButton);
SWTBotButton remButton = bot.button(Messages.SystemTapScriptGraphOptionsTab_RemoveGraphButton);
String graphID = "org.eclipse.linuxtools.systemtap.graphing.ui.charts.scatterchartbuilder";
// As soon as the Graphing tab is entered, no regular expression exists & nothing can be run.
SWTBotCombo combo = bot.comboBoxWithLabel(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
assertEquals("", combo.getText());
assertFalse(runButton.isEnabled());
assertFalse(addButton.isEnabled());
combo.setText("(1)(2)");
assertEquals("(1)(2)", combo.getText());
assertTrue(runButton.isEnabled());
assertTrue(addButton.isEnabled());
setupGraphWithTests("Graph", false);
assertTrue(runButton.isEnabled());
// Removing groups from the regex disables graphs that rely on those groups.
combo = bot.comboBoxWithLabel(Messages.SystemTapScriptGraphOptionsTab_regexLabel);
combo.setText("(1)");
assertFalse(runButton.isEnabled());
combo.setText("(1)(2)(3)");
assertTrue(runButton.isEnabled());
final SWTBotTable table = bot.table();
table.select(0);
dupButton.click();
assertEquals(2, table.rowCount());
assertTrue(runButton.isEnabled());
combo.setText("(1)");
assertFalse(runButton.isEnabled());
for (int i = 0, n = table.rowCount(); i < n; i++) {
String itemTitle = table.getTableItem(i).getText();
assertTrue("Graph " + i + " should be invalid, but it's not: " + itemTitle, table.getTableItem(i).getText().contains(Messages.SystemTapScriptGraphOptionsTab_invalidGraph));
}
setupGraphGeneral("Safe", 1, graphID, true, false);
assertFalse(table.getTableItem(2).getText().contains(Messages.SystemTapScriptGraphOptionsTab_invalidGraph));
combo.setText("(1)(2)(3)");
assertTrue(runButton.isEnabled());
setupGraphGeneral("Unsafe", 3, graphID, true, false);
assertTrue(runButton.isEnabled());
combo.setText("(1)(2)");
assertFalse(runButton.isEnabled());
for (int i = 0, n = table.rowCount(); i < n; i++) {
String itemTitle = table.getTableItem(i).getText();
assertTrue("Graph " + i + " has incorrect validity: " + itemTitle, !itemTitle.contains(Messages.SystemTapScriptGraphOptionsTab_invalidGraph) || itemTitle.contains("Unsafe"));
}
table.select(3);
dupButton.click();
remButton.click();
assertTrue(!runButton.isEnabled());
table.select(3);
editButton.click();
SWTBotShell graphShell = bot.shell("Edit Graph").activate();
SWTBotButton finishButton = bot.button("Finish");
assertTrue(!finishButton.isEnabled());
bot.comboBox("<Deleted>").setSelection("NA");
finishButton.click();
bot.waitUntil(Conditions.shellCloses(graphShell));
shell.setFocus();
assertTrue(runButton.isEnabled());
// Perform tests when graphs have an invalid graphID.
UIThreadRunnable.syncExec(() -> {
GraphData gd = (GraphData) table.getTableItem(0).widget.getData();
gd.graphID = "invalidID";
table.getTableItem(0).widget.setData(gd);
});
// Just to refresh the dialog
combo.setText(combo.getText().concat(" "));
assertFalse(runButton.isEnabled());
assertTrue(table.getTableItem(0).getText().contains(Messages.SystemTapScriptGraphOptionsTab_invalidGraphID));
table.select(0);
dupButton.click();
remButton.click();
assertFalse(runButton.isEnabled());
assertTrue(table.getTableItem(table.rowCount() - 1).getText().contains(Messages.SystemTapScriptGraphOptionsTab_invalidGraphID));
table.select(table.rowCount() - 1);
editButton.click();
graphShell = bot.shell("Edit Graph").activate();
finishButton = bot.button("Finish");
assertFalse(finishButton.isEnabled());
bot.radio(0).click();
finishButton.click();
bot.waitUntil(Conditions.shellCloses(graphShell));
shell.setFocus();
assertTrue(runButton.isEnabled());
// Removing all invalid graphs should restore validity.
combo.setText("(1)");
assertFalse(runButton.isEnabled());
for (int i = table.rowCount() - 1; i >= 0; i--) {
if (table.getTableItem(i).getText().contains(Messages.SystemTapScriptGraphOptionsTab_invalidGraph)) {
table.select(i);
remButton.click();
}
}
assertTrue(runButton.isEnabled());
while (table.rowCount() > 0) {
table.select(0);
remButton.click();
}
bot.button("Apply").click();
}
use of org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo in project translationstudio8 by heartsome.
the class XlfEditor method getSegFilterCombo.
/**
* 得到文本段过滤器下拉列表
* @return SWTBotCombo 文本段过滤器下拉列表
*/
public SWTBotCombo getSegFilterCombo() {
String defaultFilter = TsUIConstants.getString("cmbSegFilterAllSegments");
int index = 0;
while (true) {
SWTBotCombo segFilterCombo = editorBot.comboBox(index);
if (segFilterCombo.getText().equals(defaultFilter)) {
return segFilterCombo;
}
index++;
}
}
Aggregations