public static void openNewGraphWalkerModel(SWTWorkbenchBot bot) { SWTBotMenu all = bot.menu("File").menu("New"); /* Function<String, String> f = new Function<String, String> () { @Override public String apply(String t) { return t; } }; all.menuItems().stream().map(f); */ bot.menu("File").menu("New").menu("GW4E Model").click(); bot.waitUntil(new ShellActiveCondition("GW4E")); SWTBotShell shell = bot.shell("GW4E"); assertTrue(shell.isOpen()); shell.bot().button("Cancel").click(); bot.waitUntil(Conditions.shellCloses(shell)); }
/** * Pre flight initialization (run once for each test _case_) */ @Before public void setUp() throws Exception { // Force shell activation to counter, no active Shell when running SWTBot tests in Xvfb/Xvnc // see https://wiki.eclipse.org/SWTBot/Troubleshooting#No_active_Shell_when_running_SWTBot_tests_in_Xvfb Display.getDefault().syncExec(new Runnable() { public void run() { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().forceActive(); } }); bot = new SWTWorkbenchBot(); // Wait for the Toolbox shell to be available final Matcher<Shell> withText = withText("TLA+ Toolbox"); bot.waitUntil(Conditions.waitForShell(withText), 30000); // Wait for the Toolbox UI to be fully started. final Matcher<MenuItem> withMnemonic = WidgetMatcherFactory.withMnemonic("File"); final Matcher<MenuItem> matcher = WidgetMatcherFactory.allOf(WidgetMatcherFactory.widgetOfType(MenuItem.class), withMnemonic); bot.waitUntil(Conditions.waitForMenu(bot.shell("TLA+ Toolbox"), matcher), 30000); }
@BeforeClass public static void beforeClass() throws Exception { RCPTestSetupHelper.beforeClass(); // Force shell activation to counter, no active Shell when running SWTBot tests in Xvfb/Xvnc // see https://wiki.eclipse.org/SWTBot/Troubleshooting#No_active_Shell_when_running_SWTBot_tests_in_Xvfb Display.getDefault().syncExec(new Runnable() { public void run() { PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().forceActive(); } }); bot = new SWTWorkbenchBot(); // Wait for the Toolbox shell to be available final Matcher<Shell> withText = withText("TLA+ Toolbox"); bot.waitUntil(Conditions.waitForShell(withText), 30000); // Wait for the Toolbox UI to be fully started. final Matcher<MenuItem> withMnemonic = WidgetMatcherFactory.withMnemonic("File"); final Matcher<MenuItem> matcher = WidgetMatcherFactory.allOf(WidgetMatcherFactory.widgetOfType(MenuItem.class), withMnemonic); bot.waitUntil(Conditions.waitForMenu(bot.shell("TLA+ Toolbox"), matcher), 30000); }
public void ok ( ) { String name="OK"; if (GW4EPlatform.isEclipse47()) { name = "Apply and Close"; } SWTBotButton button = shell.bot().button(name); button.click(); parentBot.waitUntil(Conditions.shellCloses(shell)); }
/** * Test if catalog wizard is enabled if a project folder is selected. */ @Test public void testCheckCatalogWizardIsEnabled() { selectProjectFolder(wizard, VALID_PACKAGE_NAME); // open the check catalog wizard after having selected the project source folder. // that way, the wizard page should be enabled. initializeWizardBot(); assertEquals("new check catalog page was loaded", Messages.CATALOG_WIZARD_WINDOW_TITLE, wizard.activeShell().getText()); wizard.waitUntil(Conditions.widgetIsEnabled(wizard.textWithLabel(Messages.CATALOG_FIELD_NAME_LABEL)), SwtWizardBot.SWTBOT_TIMEOUT); wizard.waitUntil(Conditions.widgetIsEnabled(wizard.textWithLabel(Messages.PACKAGE_NAME_LABEL)), SwtWizardBot.SWTBOT_TIMEOUT); CheckWizardTestUtil.assertButtonsEnabled(false, true, false, wizard); }
/** * @return waits for the TLA+ Toolbox shell to come available */ protected SWTBotShell waitForToolboxShell() { final WaitForObjectCondition<Shell> waitForShell = Conditions.waitForShell(WithText .<Shell> withText("TLA+ Toolbox")); bot.waitUntil(waitForShell); return new SWTBotShell(waitForShell.get(0)); }
/** * Adds a new spec to the toolbox, opens it and tests if parsing is done on * a non-UI thread * * @see Bug #103 in general/bugzilla/index.html */ @Test public void parseSpecInNonUIThread() { // Open specA SWTBotMenu fileMenu = bot.menu("File"); SWTBotMenu openSpecMenu = fileMenu.menu("Open Spec"); SWTBotMenu addNewSpecMenu = openSpecMenu.menu("Add New Spec..."); addNewSpecMenu.click(); bot.textWithLabel("Root-module file:").setText(specB); bot.button("Finish").click(); assertNoBackendCodeInUIThread(); // Open specB addNewSpecMenu.click(); bot.textWithLabel("Root-module file:").setText(specA); bot.button("Finish").click(); assertNoBackendCodeInUIThread(); final String specName = getSpecName(new File(specB)); // increase timeout since farsite spec takes a long time to parse final long timeout = SWTBotPreferences.TIMEOUT * 4; // specs are created in non-UI thread asynchronously which causes a // delay before the menu entry becomes available bot.waitUntil(Conditions.waitForMenu(waitForToolboxShell(), WithText.<MenuItem> withText(specName)), timeout); // Go back to previous spec openSpecMenu.menu(specName); assertNoBackendCodeInUIThread(); }
@Before public void setUp() throws Exception { super.setUp(); // create a dummy spec "ToBeRenamedSpec" SWTBotMenu fileMenu = bot.menu("File"); SWTBotMenu openSpecMenu = fileMenu.menu("Open Spec"); SWTBotMenu addNewSpecMenu = openSpecMenu.menu("Add New Spec..."); addNewSpecMenu.click(); String path = System.getProperty("java.io.tmpdir") + File.separator + "RSHTest" + System.currentTimeMillis(); path += File.separator + TEST_SPEC + TLA_SUFFIX; bot.textWithLabel("Root-module file:").setText(path); bot.button("Finish").click(); final String specName = getSpecName(new File(path)); bot.waitUntil(Conditions.waitForMenu(bot.activeShell(), WithText.<MenuItem> withText(specName))); // create a new dummy model final SWTBotMenu modelMenu = bot.menu("TLC Model Checker"); final SWTBotMenu newModelMenu = modelMenu.menu("New Model..."); newModelMenu.click(); bot.button("OK").click(); bot.waitUntil(new ModelEditorOpenCondition(TEST_MODEL)); // save and close model editor SWTBotEditor activeEditor = bot.activeEditor(); activeEditor.saveAndClose(); checkSpecAndModelExistenceAPI(TEST_SPEC); }
protected void createProjectInWorkspace(String category, String projectType, String projectName) { SWTBotShell shell = createNewProjectWizard(category, projectType, projectName); bot.button("Finish").click(); bot.waitUntil(Conditions.shellCloses(shell)); // assert project exists }
public void cancel ( ) { SWTBotButton button = shell.bot().button("Cancel"); button.click(); parentBot.waitUntil(Conditions.shellCloses(shell)); }
@Test public void testNewModel() { // Open specA SWTBotMenu fileMenu = bot.menu("File"); SWTBotMenu openSpecMenu = fileMenu.menu("Open Spec"); SWTBotMenu addNewSpecMenu = openSpecMenu.menu("Add New Spec..."); addNewSpecMenu.click(); bot.textWithLabel("Root-module file:").setText(specA); bot.button("Finish").click(); final String specName = getSpecName(new File(specA)); // specs are created in non-UI thread asynchronously which causes a // delay before the menu entry becomes available bot.waitUntil(Conditions.waitForMenu(bot.activeShell(), WithText.<MenuItem> withText(specName))); // create a new model final SWTBotMenu modelMenu = bot.menu("TLC Model Checker"); final SWTBotMenu newModelMenu = modelMenu.menu("New Model..."); newModelMenu.click(); bot.button("OK").click(); // wait for model editor to show up and parse bot.waitUntil(new ModelEditorOpenCondition("Model_")); // register job listener who listens for the model checker job final String modelName = UIHelper.getActiveEditor().getTitle(); final Model model = ToolboxHandle.getCurrentSpec().getAdapter(TLCSpec.class).getModel(modelName); final IJobChangeListener listener = new DummyJobChangeListener(model); Job.getJobManager().addJobChangeListener(listener); // start model checking by clicking the menu. This is more robust // compared to the f11 keystroke which can get lost when fired during // initialization of the model editor. bot.menu("TLC Model Checker").menu("Run model").click(); // make unit test wait for model checker job to finish bot.waitUntil((ICondition) listener, SWTBotPreferences.TIMEOUT * 3); // Do some unregistration prior to model deletion: Job.getJobManager().removeJobChangeListener(listener); // close corresponding editor if open final IEditorPart editorWithModelOpened = model.getAdapter(ModelEditor.class); if (editorWithModelOpened != null) { UIHelper.runUISync(new Runnable() { public void run() { UIHelper.getActivePage().closeEditor(editorWithModelOpened, false); } }); } // Delete the newly created model again. It does not use the UI because // SWTBot cannot handle the modal confirmation dialog do delete the // model. // Deleting the model is necessary because repeated test execution would // leave huge numbers of model leftovers contributing to slowed down test // execution (see SizeControlContribution for reason why). try { model.delete(new NullProgressMonitor()); } catch (CoreException e) { e.printStackTrace(); } }
public static void openNewGW4EProject(SWTWorkbenchBot bot) { bot.menu("File").menu("New").menu("GW4E Project").click(); bot.waitUntil(new ShellActiveCondition("GW4E Project Creation Wizard")); SWTBotShell shell = bot.shell("GW4E Project Creation Wizard"); assertTrue(shell.isOpen()); shell.bot().button("Cancel").click(); bot.waitUntil(Conditions.shellCloses(shell)); }