use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor in project linuxtools by eclipse.
the class FormatChangeLogSWTBotTest method canFormatChangeLogFile.
/**
* Simple test for ChangeLog formatting.
*
* @throws Exception
*/
@Test
public void canFormatChangeLogFile() throws Exception {
// add a ChangeLog file
assertNull(project.getTestProject().findMember(new Path("/ChangeLog")));
final String changelogContent = "2010-12-14 Severin Gehwolf <sgehwolf@redhat.com>\n\n" + "\tAdded org.eclipse.linuxtools.changelog.tests.ui plug-in.\n" + "\t* .classpath: New file.\n" + "\t* .project: New file.\n" + "\t* .settings/org.eclipse.jdt.core.prefs: New file.\n" + "\t* build.properties: New file.\n" + "\t* src/log4j.xml: New file.\n" + "\t* src/org/eclipse/linuxtools/changelog/tests/ui/utils/ContextMenuHelper.java: New file.\n" + "\t* src/org/eclipse/linuxtools/changelog/tests/ui/utils/ProjectExplorer.java: New file.\n" + "\t* src/org/eclipse/linuxtools/changelog/tests/ui/utils/ProjectExplorerTreeItemAppearsCondition.java: New file.\n";
project.addFileToProject("/", "ChangeLog", new ByteArrayInputStream(changelogContent.getBytes()));
assertNotNull(project.getTestProject().findMember(new Path("/ChangeLog")));
// select ChangeLog file
String teamProviderString = "n/a";
SWTBotTreeItem projectItem = ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME, teamProviderString);
long oldTimeout = SWTBotPreferences.TIMEOUT;
SWTBotPreferences.TIMEOUT = 5000;
bot.waitUntil(new ProjectExplorerTreeItemAppearsCondition(projectExplorerViewTree, PROJECT_NAME, teamProviderString, "ChangeLog"));
SWTBotPreferences.TIMEOUT = oldTimeout;
SWTBotTreeItem changeLogItem = ProjectExplorer.getProjectItem(projectItem, "ChangeLog");
// should open ChangeLog file
changeLogItem.doubleClick();
oldTimeout = SWTBotPreferences.TIMEOUT;
SWTBotPreferences.TIMEOUT = 3 * 5000;
// Wait for ChangeLog editor to open
Matcher<IEditorReference> editorMatcher = allOf(IsInstanceOf.instanceOf(IEditorReference.class), withPartName("ChangeLog"));
bot.waitUntil(Conditions.waitForEditor(editorMatcher));
SWTBotEditor swtBoteditor = bot.activeEditor();
assertEquals("ChangeLog", swtBoteditor.getTitle());
SWTBotEclipseEditor swtBotEclipseEditor = swtBoteditor.toTextEditor();
// Add two extra lines after the first date line
swtBotEclipseEditor.insertText(1, 0, "\n\n");
// Should have 3 empty lines between date-line and first file entry
swtBotEclipseEditor.selectRange(1, 0, 3);
// format: ESC CTRL+F
swtBotEclipseEditor.pressShortcut(Keystrokes.ESC);
swtBotEclipseEditor.pressShortcut(Keystrokes.CTRL, KeyStroke.getInstance("F"));
swtBoteditor.save();
}
use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor in project linuxtools by eclipse.
the class PrepareChangelogSWTBotTest method canPrepareChangeLog.
/**
* Basic prepare changelog test.
*
* @throws Exception
*/
@Test
@Ignore
public void canPrepareChangeLog() throws Exception {
// Find manifest file
IResource manifest = project.findMember(new Path("/META-INF/MANIFEST.MF"));
assertNotNull(manifest);
// delete it
manifest.delete(true, null);
project.refreshLocal(IResource.DEPTH_INFINITE, null);
// select ChangeLog file
String teamProviderString = "[changelog/trunk/" + PROJECT_NAME + "]";
SWTBotTreeItem projectItem = ProjectExplorer.expandProject(projectExplorerViewTree, PROJECT_NAME, teamProviderString);
SWTBotTreeItem changeLogItem = ProjectExplorer.getProjectItem(projectItem, "ChangeLog");
changeLogItem.select();
// Should be unique
bot.menu("Prepare ChangeLog").click();
long oldTimeout = SWTBotPreferences.TIMEOUT;
SWTBotPreferences.TIMEOUT = 3 * 5000;
// Wait for ChangeLog editor to open
Matcher<IEditorReference> editorMatcher = allOf(IsInstanceOf.instanceOf(IEditorReference.class), withPartName("ChangeLog"));
bot.waitUntil(Conditions.waitForEditor(editorMatcher));
SWTBotPreferences.TIMEOUT = oldTimeout;
SWTBotEditor swtBoteditor = bot.activeEditor();
// save to avoid "save changes"-pop-up
swtBoteditor.save();
assertEquals("ChangeLog", swtBoteditor.getTitle());
SWTBotEclipseEditor eclipseEditor = swtBoteditor.toTextEditor();
// make sure expected entry has been added.
assertTrue(matchHead(eclipseEditor.getText(), "\t* META-INF/MANIFEST.MF:", 3));
}
use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor in project translationstudio8 by heartsome.
the class ProjectTreeItem method ctxMenuOpenProjectFiles.
/**
* 合并打开当前项目中的所有 XLIFF
*/
public void ctxMenuOpenProjectFiles() {
ptn.select();
SWTBotMenu openProjectFiles = ptv.ctxMenuOpenProjectFiles();
// 确认右键菜单中的打开项目功能可用
openProjectFiles.isEnabled();
// 点击该菜单项
openProjectFiles.click();
// 确认文件被成功打开
SWTBotEditor editor = HSBot.bot().editorByTitle(prjName);
HSBot.bot().waitUntil(new IsEditorOpened(editor));
}
use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor in project translationstudio8 by heartsome.
the class TS method getXlfEditor.
/**
* 得到指定文件名所在的编辑器
*
* @param fileName
* 指定的文件名
* @return XlfEditor 得到的编辑器
*/
public XlfEditor getXlfEditor(String fileName) {
SWTBotEditor editor = bot.editorByTitle(fileName);
editor.show();
return new XlfEditor(editor);
}
use of org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor 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));
}
Aggregations