Search in sources :

Example 1 with WidgetNotFoundException

use of org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException in project translationstudio8 by heartsome.

the class ProjectSetting method setTMDB.

/**
	 * 设置记忆库
	 * @param from
	 *            功能入口,请使用 TSUIConstants 类提供的常量;
	 * @param nextAction
	 *            下一步操作,请使用本类提供的常量;
	 */
public void setTMDB(Entry from, NextAction nextAction) {
    if (dlgPrjSetting == null) {
        openPrjSettingDlg(from);
    }
    dlgPrjSetting.treiTmSetting().select();
    if (!dlgPrjSetting.table().containsTextInColumn(tMDBName, dlgPrjSetting.tblColName())) {
        if (isTMDBExist) {
            dlgPrjSetting.btnAdd().click();
            DBManagement dbMgmt = new DBManagement(row);
            dbMgmt.selectDB(tMDBName);
        } else {
            dlgPrjSetting.btnCreate().click();
        // TODO 目前弹出的是数据库创建向导,而该向导有较大的改进余地,暂不实现
        }
        try {
            InformationDialog dlgInfo = new InformationDialog(InformationDialog.dlgTitleTips, InformationDialog.msgNoMatchInDB);
            dlgInfo.btnOK().click();
            Waits.shellClosed(dlgInfo);
        } catch (WidgetNotFoundException e) {
        // e.printStackTrace();
        }
        assertTrue("未正确选择记忆库:" + tMDBName, dlgPrjSetting.table().containsTextInColumn(tMDBName, dlgPrjSetting.tblColName()));
    }
    nextAction(nextAction);
}
Also used : WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) InformationDialog(net.heartsome.cat.ts.test.ui.msgdialogs.InformationDialog) DBManagement(net.heartsome.cat.ts.test.basecase.menu.db.DBManagement)

Example 2 with WidgetNotFoundException

use of org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException in project translationstudio8 by heartsome.

the class PreTranslate method preTranslate.

/**
	 * 预翻译
	 * @param from
	 *            入口,请使用 TSUIConstants 类提供的常量;
	 */
public void preTranslate(Entry from) {
    getDataPreTrans();
    select();
    openPreTransDlg(from);
    assertTrue("未正确添加选中的文件:" + fileFullPath, dlgPreTrans.table().containsTextInColumn(fileFullPath, dlgPreTrans.tblColFile()));
    dlgPreTrans.btnOK().click();
    HSBot.bot().waitUntil(new DefaultCondition() {

        public boolean test() throws Exception {
            try {
                dlgPreTransResult = new PreTranslateResultDialog();
                return dlgPreTransResult.isOpen();
            } catch (WidgetNotFoundException e) {
                return false;
            }
        }

        public String getFailureMessage() {
            return "未正确显示预翻译结果对话框。";
        }
    }, 3600000);
    assertTrue("未正确该文件的预翻译结果:" + fileFullPath, dlgPreTransResult.table().containsTextInColumn(fileFullPath, dlgPreTransResult.tblColFile()));
    dlgPreTransResult.btnOK().click();
}
Also used : WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) DefaultCondition(org.eclipse.swtbot.swt.finder.waits.DefaultCondition) PreTranslateResultDialog(net.heartsome.cat.ts.test.ui.dialogs.PreTranslateResultDialog) WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException)

Example 3 with WidgetNotFoundException

use of org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException in project xtext-xtend by eclipse.

the class SwtBotProjectHelper method fileNew.

protected static void fileNew(final SWTWorkbenchBot it, final String newWhat) {
    int retries = 3;
    ExclusiveRange _doubleDotLessThan = new ExclusiveRange(0, retries, true);
    for (final Integer i : _doubleDotLessThan) {
        try {
            it.menu("File").menu("New").menu(newWhat).click();
            return;
        } catch (final Throwable _t) {
            if (_t instanceof WidgetNotFoundException) {
                final WidgetNotFoundException e = (WidgetNotFoundException) _t;
                if (((i).intValue() == (retries - 1))) {
                    throw e;
                }
                String _message = e.getMessage();
                String _plus = ("failed: " + _message);
                InputOutput.<String>println(_plus);
                InputOutput.<String>println("retrying...");
                it.sleep(1000);
            } else {
                throw Exceptions.sneakyThrow(_t);
            }
        }
    }
}
Also used : WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) ExclusiveRange(org.eclipse.xtext.xbase.lib.ExclusiveRange)

Example 4 with WidgetNotFoundException

use of org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException in project linuxtools by eclipse.

the class AbstractSWTBotTest method exitProjectFolder.

/**
 * Exit from the project tree.
 */
private static void exitProjectFolder(SWTWorkbenchBot bot) {
    try {
        SWTBotToolbarButton forwardButton = projectExplorer.toolbarPushButton("Forward");
        projectExplorer.toolbarPushButton("Back to Workspace").click();
        bot.waitUntil(widgetIsEnabled(forwardButton));
    } catch (WidgetNotFoundException e) {
    // Already exited from project folder
    }
}
Also used : WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) SWTBotToolbarButton(org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton)

Example 5 with WidgetNotFoundException

use of org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException in project linuxtools by eclipse.

the class MetadataPageTest method setUpBeforeClass.

/**
 * Initialize the test project.
 *
 * @throws CoreException
 */
@BeforeClass
public static void setUpBeforeClass() throws CoreException {
    testProject = new TestCreaterepoProject();
    assertTrue(testProject.getProject().exists());
    bot = new SWTWorkbenchBot();
    try {
        bot.shell(ICreaterepoTestConstants.MAIN_SHELL).activate();
    } catch (WidgetNotFoundException e) {
    // cannot activate main shell, continue anyways
    }
    TestUtils.openResourcePerspective(bot);
    navigator = TestUtils.enterProjectFolder(bot);
}
Also used : SWTWorkbenchBot(org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot) WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) BeforeClass(org.junit.BeforeClass)

Aggregations

WidgetNotFoundException (org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException)24 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)12 BeforeClass (org.junit.BeforeClass)12 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 TestCreaterepoProject (org.eclipse.linuxtools.internal.rpm.createrepo.form.tests.TestCreaterepoProject)3 DBManagement (net.heartsome.cat.ts.test.basecase.menu.db.DBManagement)2 InformationDialog (net.heartsome.cat.ts.test.ui.msgdialogs.InformationDialog)2 IWorkspace (org.eclipse.core.resources.IWorkspace)2 IWorkspaceDescription (org.eclipse.core.resources.IWorkspaceDescription)2 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)2 SWTBotText (org.eclipse.swtbot.swt.finder.widgets.SWTBotText)2 After (org.junit.After)2 File (java.io.File)1 List (java.util.List)1 Consumer (java.util.function.Consumer)1 InputDialog (net.heartsome.cat.ts.test.ui.dialogs.InputDialog)1 PreTranslateResultDialog (net.heartsome.cat.ts.test.ui.dialogs.PreTranslateResultDialog)1 PreferencesDialog (net.heartsome.cat.ts.test.ui.dialogs.PreferencesDialog)1 IsWidgetInvisible (net.heartsome.test.swtbot.waits.IsWidgetInvisible)1