Search in sources :

Example 1 with SWTBotEditor

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

the class OpenFileDialog method openFile.

/**
	 * 在打开文件对话框中输入指定文件名称或路径
	 * @param filePath
	 *            要打开的文件名称或路径
	 * @param isValid
	 *            是否为有效文件名称或路径
	 * @param isFile
	 *            true 表示输入的是文件名称,false 表示文件路径
	 */
public static void openFile(String filePath, boolean isValid, boolean isFile) {
    // typePath 方法处理了多种操作系统的情况
    OsUtil.typePath(filePath);
    // 从路径中取出文件名
    String fileName = new Path(filePath).lastSegment();
    if (isValid) {
        // 确认编辑器成功打开
        HsSWTWorkbenchBot bot = HSBot.bot();
        final SWTBotEditor editor = bot.editorByTitle(fileName);
        bot.waitUntil(new IsEditorOpened(editor));
    } else {
        if (isFile) {
            // 弹出信息对话框
            InfoFileNotFound fnf = new InfoFileNotFound(filePath);
            // 文件未找到
            fnf.msgFileNotFound().isVisible();
            fnf.btnOK().click();
        } else {
            try {
                // 在系统对话框的信息提示框上点确认
                OsUtil.typeEnter();
                // 按 Esc 取消打开文件
                OsUtil.typeEsc();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
Also used : Path(org.eclipse.core.runtime.Path) SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) InfoFileNotFound(net.heartsome.cat.ts.test.ui.msgdialogs.InfoFileNotFound) IsEditorOpened(net.heartsome.test.swtbot.waits.IsEditorOpened) HsSWTWorkbenchBot(net.heartsome.test.swtbot.finders.HsSWTWorkbenchBot)

Example 2 with SWTBotEditor

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

the class ProjectTreeView method doubleClickXlfFile.

/* ****** 鼠标双击功能 ****** */
/**
	 * 双击打开 XLIFF 文件
	 * @param prjName
	 *            XLIFF 文件所在的项目名称
	 * @param xlfFileName
	 *            要打开的 XLIFF 文件名称
	 */
public static void doubleClickXlfFile(String prjName, final String xlfFileName) {
    getTree().expandNode(prjName).expandNode("XLIFF").expandNode(xlfFileName).doubleClick();
    // 确认文件被打开
    SWTBotEditor editor = HSBot.bot().editorByTitle(xlfFileName);
    HSBot.bot().waitUntil(new IsEditorOpened(editor));
}
Also used : SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) IsEditorOpened(net.heartsome.test.swtbot.waits.IsEditorOpened)

Example 3 with SWTBotEditor

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

the class ProjectTreeItem method ctxMenuOpenFile.

/**
	 * 打开当前项目中的一个 XLIFF 文件
	 * @param xlfFileName
	 *            要打开的 XLIFF 文件名称
	 */
public void ctxMenuOpenFile(final String xlfFileName) {
    selectFile("XLIFF", xlfFileName);
    SWTBotMenu openFiles = ptv.ctxMenuOpenFile();
    openFiles.isEnabled();
    openFiles.click();
    SWTBotEditor editor = HSBot.bot().editorByTitle(xlfFileName);
    HSBot.bot().waitUntil(new IsEditorOpened(editor));
}
Also used : SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) IsEditorOpened(net.heartsome.test.swtbot.waits.IsEditorOpened) SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)

Example 4 with SWTBotEditor

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

the class TestCreateSystemtapScript method testLabelledGraphScript.

@Test
public void testLabelledGraphScript() {
    final int numItems = 13;
    final int numNumberItems = 4;
    final int numCategories = 3;
    createAndViewDummyData(new String[] { "Fruit", "Number", "Freshness", "Tastiness" }, new Object[] { "Apples", 2, 14, 16, 1, 1, 2, 3, "Bananas (2)", 10, 10, 10, "Cherries", 10, 20, 30, 2, 2, 4, 6, "Apples", 12, 5, 16, "Bananas", 0, 1, 0, 3, 3, 6, 9, "Dates", 12, 5, 16, "Bananas", 2, 1, 2, 4, 4, 8, 12, "Apples", 12, 5, 16, "Bananas (2)", 3, 1, 3 });
    SWTBotEditor graphEditor = bot.activeEditor();
    // Add bar, pie, and line graphs that use the same column data.
    String title = "Fruit Info";
    setupGraphGeneral(title, 4, "org.eclipse.linuxtools.systemtap.graphing.ui.charts.barchartbuilder", false, true);
    setupGraphGeneral(title, 4, "org.eclipse.linuxtools.systemtap.graphing.ui.charts.piechartbuilder", false, true);
    setupGraphGeneral(title, 4, "org.eclipse.linuxtools.systemtap.graphing.ui.charts.linechartbuilder", false, true);
    // Confirm that the bar & pie charts display the String categories, but the line chart ignores them.
    String titleBar = title + " - Bar Graph";
    String titlePie = title + " - Pie Chart";
    String titleLine = title + " - Line Graph";
    graphEditor.bot().cTabItem(titleLine).activate();
    Matcher<AbstractChartBuilder> matcher = widgetOfType(AbstractChartBuilder.class);
    AbstractChartBuilder cb = bot.widget(matcher);
    assertEquals(numNumberItems, cb.getChart().getSeriesSet().getSeries()[0].getXSeries().length);
    graphEditor.bot().cTabItem(titlePie).activate();
    cb = bot.widget(matcher);
    assertEquals(numItems, cb.getChart().getSeriesSet().getSeries().length);
    graphEditor.bot().cTabItem(titleBar).activate();
    cb = bot.widget(matcher);
    assertEquals(numItems, cb.getChart().getSeriesSet().getSeries()[0].getXSeries().length);
    // Test graph scaling & scrolling
    // Bar Chart
    discreteXControlTests(cb, numItems);
    continuousControlTests(cb, false);
    graphEditor.bot().cTabItem(titlePie).activate();
    cb = bot.widget(matcher);
    discreteXControlTests(cb, numCategories);
    graphEditor.bot().cTabItem(titleLine).activate();
    cb = bot.widget(matcher);
    continuousControlTests(cb, true);
    continuousControlTests(cb, false);
}
Also used : SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) AbstractChartBuilder(org.eclipse.linuxtools.systemtap.graphing.ui.charts.AbstractChartBuilder) Point(org.eclipse.swt.graphics.Point) Test(org.junit.Test)

Example 5 with SWTBotEditor

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

the class AddChangelogEntrySWTBotTest method canAddChangeLogEntryUsingEditMenuIfSourceIsActive.

/**
 * ChangeLog editor should pop-up if inside an active editor
 * and a ChangeLog file exists in the project. Tests the "Edit" => "ChangeLog Entry"
 * menu item.
 *
 * @throws Exception
 */
@Test
public void canAddChangeLogEntryUsingEditMenuIfSourceIsActive() throws Exception {
    // Add a Java source file
    String sourceCode = "package src;\n" + "public class JavaTest {\n" + "public static void main(String args[]) {\n" + "//" + OFFSET_MARKER + "\n" + "System.out.println(\"Hello World!\");\n" + "}\n" + "}\n";
    assertNull(project.getTestProject().findMember(new Path("/src/JavaTest.java")));
    InputStream newFileInputStream = new ByteArrayInputStream(sourceCode.getBytes());
    project.addFileToProject("/src", "JavaTest.java", newFileInputStream);
    // Add a changelog file
    newFileInputStream = new ByteArrayInputStream("".getBytes());
    project.addFileToProject("/", "ChangeLog", newFileInputStream);
    assertNotNull(project.getTestProject().findMember(new Path("/src/JavaTest.java")));
    assertNotNull(project.getTestProject().findMember(new Path("/ChangeLog")));
    // Open JavaTest.java in an editor
    SWTBotTreeItem projectItem = projectExplorerViewTree.expandNode(PROJECT_NAME);
    projectItem.expandNode("src").expandNode("JavaTest.java").doubleClick();
    Matcher<IEditorReference> editorMatcher = allOf(IsInstanceOf.instanceOf(IEditorReference.class), withPartName("JavaTest.java"));
    // Wait for editor to open
    bot.waitUntil(Conditions.waitForEditor(editorMatcher));
    SWTBotEditor swtBoteditor = bot.editorByTitle("JavaTest.java");
    SWTBotEclipseEditor eclipseEditor = swtBoteditor.toTextEditor();
    eclipseEditor.selectLine(getLineOfOffsetMarker(sourceCode));
    // Click menu item.
    bot.menu("Edit").menu("Insert ChangeLog entry").click();
    // Wait for ChangeLog editor to open
    editorMatcher = allOf(IsInstanceOf.instanceOf(IEditorReference.class), withPartName("ChangeLog"));
    bot.waitUntil(Conditions.waitForEditor(editorMatcher));
    swtBoteditor = bot.activeEditor();
    // save to avoid "save changes"-pop-up
    swtBoteditor.save();
    assertEquals("ChangeLog", swtBoteditor.getTitle());
    eclipseEditor = swtBoteditor.toTextEditor();
    // make sure expected entry has been added.
    assertTrue(eclipseEditor.getText().contains("* src/JavaTest.java"));
}
Also used : Path(org.eclipse.core.runtime.Path) SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) IEditorReference(org.eclipse.ui.IEditorReference) ByteArrayInputStream(java.io.ByteArrayInputStream) SWTBotEclipseEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) Test(org.junit.Test)

Aggregations

SWTBotEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor)24 Test (org.junit.Test)11 Path (org.eclipse.core.runtime.Path)7 SWTBotEclipseEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor)7 SWTBotTreeItem (org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem)7 IEditorReference (org.eclipse.ui.IEditorReference)7 ByteArrayInputStream (java.io.ByteArrayInputStream)5 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)5 Ignore (org.junit.Ignore)5 IsEditorOpened (net.heartsome.test.swtbot.waits.IsEditorOpened)4 IFile (org.eclipse.core.resources.IFile)3 ProjectExplorerTreeItemAppearsCondition (org.eclipse.linuxtools.changelog.ui.tests.utils.ProjectExplorerTreeItemAppearsCondition)3 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)3 SWTBotMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)3 SWTBotTable (org.eclipse.swtbot.swt.finder.widgets.SWTBotTable)3 IEditorPart (org.eclipse.ui.IEditorPart)3 InputStream (java.io.InputStream)2 IResource (org.eclipse.core.resources.IResource)2 AbstractChartBuilder (org.eclipse.linuxtools.systemtap.graphing.ui.charts.AbstractChartBuilder)2 SWTBot (org.eclipse.swtbot.swt.finder.SWTBot)2