Search in sources :

Example 1 with HsSWTWorkbenchBot

use of net.heartsome.test.swtbot.finders.HsSWTWorkbenchBot 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 HsSWTWorkbenchBot

use of net.heartsome.test.swtbot.finders.HsSWTWorkbenchBot in project translationstudio8 by heartsome.

the class CursorPosition method setUp.

@Before
public void setUp() {
    //		SWTBotPreferences.PLAYBACK_DELAY = 500;
    SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
    bot = new HsSWTWorkbenchBot();
}
Also used : HsSWTWorkbenchBot(net.heartsome.test.swtbot.finders.HsSWTWorkbenchBot) Before(org.junit.Before)

Aggregations

HsSWTWorkbenchBot (net.heartsome.test.swtbot.finders.HsSWTWorkbenchBot)2 InfoFileNotFound (net.heartsome.cat.ts.test.ui.msgdialogs.InfoFileNotFound)1 IsEditorOpened (net.heartsome.test.swtbot.waits.IsEditorOpened)1 Path (org.eclipse.core.runtime.Path)1 SWTBotEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor)1 Before (org.junit.Before)1