Java Code Examples for org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu#menu()
The following examples show how to use
org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu#menu() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PDFHandlerThreadingTest.java From tlaplus with MIT License | 6 votes |
@Test @Ignore("not ready yet") public void producePDFInNonUIThread() throws InterruptedException { // 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(); // generate PDF SWTBotMenu pdfMenu = fileMenu.menu("Produce PDF Version"); pdfMenu.click(); // wait for the browser to show up with the generated PDF SWTBotEditor swtBotEditor = bot.editorById(OpenSpecHandler.TLA_EDITOR); Assert.assertNotNull(swtBotEditor); assertNoBackendCodeInUIThread(); }
Example 2
Source File: XsemanticsSwtbotTestBase.java From xsemantics with Eclipse Public License 1.0 | 6 votes |
protected void createProjectAndAssertNoErrorMarker(String projectType) throws CoreException { SWTBotMenu fileMenu = bot.menu("File"); SWTBotMenu newMenu = fileMenu.menu("New"); SWTBotMenu projectMenu = newMenu.menu("Project..."); projectMenu.click(); SWTBotShell shell = bot.shell("New Project"); shell.activate(); SWTBotTreeItem xsemanticsNode = bot.tree().expandNode("Xsemantics"); waitForTreeItems(xsemanticsNode); xsemanticsNode.expandNode(projectType).select(); bot.button("Next >").click(); bot.textWithLabel("Project name:").setText(TEST_PROJECT); bot.button("Finish").click(); // creation of a project might require some time bot.waitUntil(shellCloses(shell), SHELL_TIMEOUT); assertTrue("Project doesn't exist", isProjectCreated(TEST_PROJECT)); waitForBuild(); assertNoErrorsInProject(); }
Example 3
Source File: XsemanticsImportExamplesProjectWizardTests.java From xsemantics with Eclipse Public License 1.0 | 6 votes |
protected void createExampleProjects(String projectType, String mainProjectId) { SWTBotMenu fileMenu = bot.menu("File"); SWTBotMenu newMenu = fileMenu.menu("New"); SWTBotMenu otherMenu = newMenu.menu("Other..."); otherMenu.click(); SWTBotShell shell = bot.shell("New"); shell.activate(); SWTBotTreeItem xsemanticsNode = bot.tree().expandNode("Xsemantics"); waitForTreeItems(xsemanticsNode); SWTBotTreeItem examplesNode = xsemanticsNode.expandNode("Examples"); waitForTreeItems(examplesNode); examplesNode.expandNode(projectType).select(); bot.button("Next >").click(); bot.button("Finish").click(); // creation of a project might require some time bot.waitUntil(shellCloses(shell), SHELL_TIMEOUT); assertTrue("Project doesn't exist", isProjectCreated(mainProjectId)); assertTrue("Project doesn't exist", isProjectCreated(mainProjectId + ".tests")); assertTrue("Project doesn't exist", isProjectCreated(mainProjectId + ".ui")); }
Example 4
Source File: HandlerThreadingTest.java From tlaplus with MIT License | 5 votes |
/** * 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 @Ignore 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(); }
Example 5
Source File: CloneModelTest.java From tlaplus with MIT License | 5 votes |
@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, TEST_MODEL); }
Example 6
Source File: CloneModelTest.java From tlaplus with MIT License | 5 votes |
@Test public void cloneModelMainMenu() { final SWTBotMenu modelMenu = bot.menu("TLC Model Checker"); final SWTBotMenu cloneModelMenu = modelMenu.menu("Clone Model"); final SWTBotMenu cloneModelSubMenu = cloneModelMenu.click(); cloneModelSubMenu.menu(TEST_MODEL).click(); bot.button("OK").click(); bot.waitUntil(new ModelEditorOpenCondition(TEST_MODEL_RENAME)); }
Example 7
Source File: RenameSpecHandlerTest.java From tlaplus with MIT License | 5 votes |
@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, TEST_MODEL); }
Example 8
Source File: RenameSpecHandlerTest.java From tlaplus with MIT License | 5 votes |
private void openSpecExplorer() { SWTBotMenu windowMenu = bot.menu("Window"); SWTBotMenu specExplorerMenu = windowMenu.menu(SPEC_EXPLORER); specExplorerMenu.click(); // spec context menu SWTBotView packageExplorerView = bot.viewByTitle(SPEC_EXPLORER); packageExplorerView.setFocus(); }
Example 9
Source File: AddSpecWizardTest.java From tlaplus with MIT License | 5 votes |
/** * Test to make sure the "Add Spec" wizard does not accept invalid spec names */ @Test public void doNotAcceptInvalidSpecNames() { // Open specA SWTBotMenu fileMenu = bot.menu("File"); SWTBotMenu openSpecMenu = fileMenu.menu("Open Spec"); SWTBotMenu addNewSpecMenu = openSpecMenu.menu("Add New Spec..."); addNewSpecMenu.click(); // get a handle for the button before invoking the UI (widget not found exception otherwise) SWTBotButton button = bot.button("Finish"); // create a valid path String path = System.getProperty("java.io.tmpdir"); path += File.separator + "Invalid-Name.tla"; // set an invalid spec name bot.textWithLabel("Root-module file:").setText(path); // check if the wizard can finish Assert.assertTrue( "Finish button must not be enabled with invalid spec name", !button.isEnabled()); //TODO could change the wizard marker/error area for the correct string too }
Example 10
Source File: ModelCheckerTest.java From tlaplus with MIT License | 4 votes |
@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(); } }