org.eclipse.swtbot.swt.finder.waits.Conditions Java Examples

The following examples show how to use org.eclipse.swtbot.swt.finder.waits.Conditions. 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: SuperBot.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void confirmShellAddProjectToSession(String project, String[] files)
    throws RemoteException {
  SWTBot bot = new SWTBot();
  SWTBotShell shell = bot.shell(SHELL_ADD_PROJECTS_TO_SESSION);
  shell.activate();

  // wait for tree update
  bot.sleep(500);

  SWTBotTree tree = shell.bot().tree();

  selectProjectFiles(tree, project, files);

  shell.bot().button(FINISH).click();
  bot.waitUntil(Conditions.shellCloses(shell));
}
 
Example #2
Source File: DeleteSpecHandlerTest.java    From tlaplus with MIT License 6 votes vote down vote up
@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);
}
 
Example #3
Source File: AddSpecWizardTest.java    From tlaplus with MIT License 6 votes vote down vote up
@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);
}
 
Example #4
Source File: DataWizardIT.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Add a Text Data
 *
 * @param dataName
 */
private void addDataOnSelectedElementWithName(final String dataName, final String tabId) {
    bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_PROCESS_DATA).show();
    SWTBotTestUtil.selectTabbedPropertyView(bot, tabId);

    bot.buttonWithId(SWTBotConstants.SWTBOT_ID_ADD_PROCESS_DATA).click();
    // Shell "New variable"
    bot.waitUntil(Conditions.shellIsActive(Messages.newVariable));

    bot.textWithLabel(Messages.name + " *").setText(dataName);
    bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.FINISH_LABEL)));
    bot.button(IDialogConstants.FINISH_LABEL).click();
    SWTBotTestUtil.waitUntilRootShellIsActive(bot);
    final BotApplicationWorkbenchWindow applicationWorkbenchWindow = new BotApplicationWorkbenchWindow(bot);
    applicationWorkbenchWindow.save();
    SWTBotTestUtil.waitUntilRootShellIsActive(bot);
}
 
Example #5
Source File: FetchRemoteTracesTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test 8.11: Run Profile "TestSpecificRecursive"
 */
@Test
public void test_8_11() {
    SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER);
    projectExplorerBot.show();
    SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot);

    tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click();
    SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate();
    fBot.comboBox().setSelection("TestSpecificRecursive");
    fBot.button("Next >").click();
    fBot.button("Finish").click();
    fBot.waitUntil(Conditions.shellCloses(shell), FETCH_TIME_OUT);
    WaitUtils.waitForJobs();

    TmfProjectElement project = TmfProjectRegistry.getProject(ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME), true);
    fBot.waitUntil(new TraceCountCondition(project, 2));
    final TmfTraceFolder tracesFolder = project.getTracesFolder();
    assertNotNull(tracesFolder);
    List<TmfTraceElement> traces = tracesFolder.getTraces();
    assertEquals(2, traces.size());
    testTrace(traces.get(0), CONNECTION_NODE1_NAME + "/resources/generated/synthetic-trace", TRACE_TYPE_KERNEL);
    testTrace(traces.get(1), CONNECTION_NODE1_NAME + "/resources/syslog", TRACE_TYPE_SYSLOG);
}
 
Example #6
Source File: FetchRemoteTracesTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test 8.14: Cancel Import
 */
@Test
public void test_8_14() {
    SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER);
    projectExplorerBot.show();
    SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot);

    tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click();
    SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate();
    fBot.comboBox().setSelection("TestAllRecursive");
    fBot.button("Next >").click();
    fBot.button("Finish").click();
    fBot.button("Cancel").click();
    fBot.waitUntil(Conditions.shellCloses(shell), FETCH_TIME_OUT);
    WaitUtils.waitForJobs();

    /* Can't verify cancelled import, it depends on timing */
}
 
Example #7
Source File: FetchRemoteTracesTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test 8.15: Run Profile "TestMultiNodse"
 */
@Test
public void test_8_15() {
    SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER);
    projectExplorerBot.show();
    SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot);

    tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click();
    SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate();
    fBot.comboBox().setSelection("TestMultiNode");
    fBot.button("Next >").click();
    fBot.button("Finish").click();
    fBot.waitUntil(Conditions.shellCloses(shell), FETCH_TIME_OUT);
    WaitUtils.waitForJobs();

    TmfProjectElement project = TmfProjectRegistry.getProject(ResourcesPlugin.getWorkspace().getRoot().getProject(PROJECT_NAME), true);
    fBot.waitUntil(new TraceCountCondition(project, 2));
    final TmfTraceFolder tracesFolder = project.getTracesFolder();
    assertNotNull(tracesFolder);
    List<TmfTraceElement> traces = tracesFolder.getTraces();
    assertEquals(2, traces.size());
    testTrace(traces.get(0), CONNECTION_NODE1_NAME + "/resources/generated/synthetic-trace", TRACE_TYPE_KERNEL);
    testTrace(traces.get(1), CONNECTION_NODE2_NAME + "/resources/syslog", TRACE_TYPE_SYSLOG);
}
 
Example #8
Source File: FetchRemoteTracesTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test 9.2: Cannot connect to remote host (wrong password)
 *
 * This test is ignored to avoid repeated authentication failures in the CI
 * infrastructure. The @Ignore tag can be removed to run the test locally.
 */
@Test
@Ignore
public void test_9_02() {
    SWTBotView projectExplorerBot = fBot.viewByTitle(PROJECT_EXPLORER);
    projectExplorerBot.show();
    SWTBotTreeItem tracesFolderItem = getTracesFolderTreeItem(projectExplorerBot);

    tracesFolderItem.contextMenu(FETCH_COMMAND_NAME).click();
    SWTBotShell shell = fBot.shell(FETCH_SHELL_NAME).activate();
    fBot.comboBox().setSelection("TestLocal");
    fBot.button("Finish").click();
    SWTBotShell anyShell = SWTBotUtils.anyShellOf(fBot, AUTHENTICATION_SHELL_NAME, PASSWORD_SHELL_NAME).activate();
    if (anyShell.getText().equals(AUTHENTICATION_SHELL_NAME)) {
        fBot.button("Yes").click();
    }
    fBot.shell(PASSWORD_SHELL_NAME).activate();
    fBot.textWithLabel("Password:").setText("anonymous");
    fBot.button("OK").click();
    fBot.shell(PASSWORD_SHELL_NAME).activate();
    fBot.button("Cancel").click();
    /* ErrorDialog is inhibited by the platform when running tests */
    fBot.button("Cancel").click();
    fBot.waitUntil(Conditions.shellCloses(shell), FETCH_TIME_OUT);
    WaitUtils.waitForJobs();
}
 
Example #9
Source File: SWTBotUtils.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Clear the trace folder (using the UI)
 *
 * @param bot
 *            a given workbench bot
 * @param projectName
 *            the name of the project (needs to exist)
 */
public static void clearTracesFolderUI(SWTWorkbenchBot bot, String projectName) {
    SWTBotTreeItem tracesFolder = selectTracesFolder(bot, projectName);
    tracesFolder.contextMenu().menu("Clear").click();
    String CONFIRM_CLEAR_DIALOG_TITLE = "Confirm Clear";
    SWTBotShell shell = bot.shell(CONFIRM_CLEAR_DIALOG_TITLE).activate();
    shell.bot().button("Yes").click();
    bot.waitUntil(Conditions.shellCloses(shell));
    bot.waitWhile(ConditionHelpers.treeItemHasChildren(tracesFolder));
    try {
        /* This ensures that the Clear workspace operation has completed */
        ResourcesPlugin.getWorkspace().run(monitor -> {}, null);
    } catch (CoreException e) {
        // Ignore
    }
}
 
Example #10
Source File: SWTBotTimeGraphEntry.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected SWTBotRootMenu contextMenu(final Control control) throws WidgetNotFoundException {
    Rectangle bounds = absoluteLocation();
    if (bounds == null) {
        return null;
    }
    UIThreadRunnable.syncExec(new VoidResult() {
        @Override
        public void run() {
            final Event event = new Event();
            event.time = (int) System.currentTimeMillis();
            event.display = control.getDisplay();
            event.widget = control;
            event.x = bounds.x + widget.getTimeDataProvider().getNameSpace() / 2;
            event.y = bounds.y + bounds.height / 2;
            control.notifyListeners(SWT.MenuDetect, event);
        }
    });
    select();

    WaitForObjectCondition<Menu> waitForMenu = Conditions.waitForPopupMenu(control);
    new SWTBot().waitUntilWidgetAppears(waitForMenu);
    return new SWTBotRootMenu(waitForMenu.get(0));
}
 
Example #11
Source File: TimeGraphViewTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Clean up after a test, reset the views and reset the states of the
 * timegraph by pressing reset on all the resets of the legend
 */
@After
public void after() {

    // reset all
    fViewBot.toolbarButton(SHOW_LEGEND).click();
    SWTBotShell legendShell = fBot.shell(LEGEND_NAME);
    SWTBot legendBot = legendShell.bot();

    for (int i = 0; i < StubPresentationProvider.STATES.length; i++) {
        SWTBotButton resetButton = legendBot.button(i);
        if (resetButton.isEnabled()) {
            resetButton.click();
        }
    }
    legendBot.button(OK_BUTTON).click();
    TmfTraceStub trace = fTrace;
    assertNotNull(trace);
    UIThreadRunnable.syncExec(() -> TmfSignalManager.dispatchSignal(new TmfTraceClosedSignal(this, trace)));
    fBot.waitUntil(Conditions.shellCloses(legendShell));
    fViewBot.close();
    fBot.waitUntil(ConditionHelpers.viewIsClosed(fViewBot));
    fTrace.dispose();
}
 
Example #12
Source File: ProjectExplorerTracesFolderTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private static void importCustomParsers() {
    // FIXME: We can't use Manage Custom Parsers > Import because it uses a native dialog. We'll still check that they show up in the dialog
    CustomTxtTraceDefinition[] txtDefinitions = CustomTxtTraceDefinition.loadAll(getPath("customParsers/ExampleCustomTxtParser.xml"));
    txtDefinitions[0].save();
    CustomXmlTraceDefinition[] xmlDefinitions = CustomXmlTraceDefinition.loadAll(getPath("customParsers/ExampleCustomXmlParser.xml"));
    xmlDefinitions[0].save();

    SWTBotTreeItem traceFolder = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
    traceFolder.contextMenu("Manage Custom Parsers...").click();
    SWTBotShell shell = fBot.shell(MANAGE_CUSTOM_PARSERS_SHELL_TITLE).activate();
    SWTBot shellBot = shell.bot();

    // Make sure the custom text trace type is imported
    shellBot.list().select(CUSTOM_TEXT_LOG.getTraceType());

    // Make sure the custom xml trace type is imported
    shellBot.radio("XML").click();
    shellBot.list().select(CUSTOM_XML_LOG.getTraceType());
    shellBot.button("Close").click();
    shellBot.waitUntil(Conditions.shellCloses(shell), DISK_ACCESS_TIMEOUT);
}
 
Example #13
Source File: SuperBot.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void confirmShellSessionInvitationAndShellAddProject(
    String projectName, TypeOfCreateProject usingWhichProject) throws RemoteException {

  SWTBot bot = new SWTBot();
  bot.waitUntil(
      Conditions.shellIsActive(SHELL_SESSION_INVITATION),
      SarosSWTBotPreferences.SAROS_LONG_TIMEOUT);

  SWTBotShell invitationShell = bot.shell(SHELL_SESSION_INVITATION);
  invitationShell.bot().button(ACCEPT).click();

  bot.waitUntil(
      Conditions.shellCloses(invitationShell), SarosSWTBotPreferences.SAROS_LONG_TIMEOUT);

  confirmShellAddProjectUsingWhichProject(projectName, usingWhichProject);
  views().sarosView().waitUntilIsInSession();
}
 
Example #14
Source File: ActorFilterDefinitionWizardPageTest.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createWidget(String widgetId, String widgetType, int inputIndex)
        throws Exception {
    SWTBotShell activeShell = bot.activeShell();
    bot.button("Add...").click();
    assertFalse("button ok should be disabled",
            bot.button(IDialogConstants.OK_LABEL).isEnabled());
    bot.textWithLabel("Widget id*").setText(widgetId);
    bot.comboBoxWithLabel("Widget type").setSelection(widgetType);
    if (!widgetType.equals("Group")) {
        bot.comboBoxWithLabel("Input *").setSelection(inputIndex);
    } else {
        assertFalse("inputs combo box should be disabled for Group widget",
                bot.comboBoxWithLabel("Input *").isEnabled());
    }
    assertTrue("button ok should be enabled",
            bot.button(IDialogConstants.OK_LABEL).isEnabled());
    bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.OK_LABEL)), 5000);
    bot.button(IDialogConstants.OK_LABEL).click();
    activeShell.setFocus();

}
 
Example #15
Source File: SuperBot.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void confirmShellAddProjectUsingExistProjectWithCopy(String projectName)
    throws RemoteException {

  SWTBot bot = new SWTBot();
  bot.waitUntil(
      Conditions.shellIsActive(SHELL_ADD_PROJECTS), SarosSWTBotPreferences.SAROS_LONG_TIMEOUT);

  SWTBotShell shell = bot.shell(SHELL_ADD_PROJECTS);
  shell.activate();

  shell.bot().radio("Use existing project").click();
  shell.bot().checkBox("Create copy for working distributed. New project name:").click();
  shell.bot().button(FINISH).click();
  shell.bot().waitUntil(Conditions.shellCloses(shell));
}
 
Example #16
Source File: SuperBot.java    From saros with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void confirmShellAddProjectUsingWhichProject(
    String projectName, TypeOfCreateProject usingWhichProject) throws RemoteException {
  SWTBot bot = new SWTBot();
  bot.waitUntil(
      Conditions.shellIsActive(SHELL_ADD_PROJECTS), SarosSWTBotPreferences.SAROS_LONG_TIMEOUT);

  SWTBotShell shell = bot.shell(SHELL_ADD_PROJECTS);
  shell.activate();

  switch (usingWhichProject) {
    case NEW_PROJECT:
      confirmShellAddProjectWithNewProject(projectName);
      break;
    case EXIST_PROJECT:
      confirmShellAddProjectUsingExistProject(projectName);
      break;
    case EXIST_PROJECT_WITH_COPY:
      confirmShellAddProjectUsingExistProjectWithCopy(projectName);
      break;
  }
}
 
Example #17
Source File: ConnectorEditionTest.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public void removeConnectorDefinition(final String name, final String version) {
    SWTBotConnectorTestUtil.activateConnectorDefEditionShell(bot);
    bot.tree().setFocus();
    bot.waitUntil(new SelectNodeUnder(bot, name + " (" + version + ")", "Uncategorized"), 10000, 1000);

    assertNotNull("could not find" + name + " (" + version + ")", bot
            .tree().select("Uncategorized").expandNode("Uncategorized")
            .getNode(name + " (" + version + ")"));
    bot.tree().select("Uncategorized").expandNode("Uncategorized").select(name + " (" + version + ")");
    bot.button("Delete").click();
    if (!FileActionDialog.getDisablePopup()) {
        bot.waitUntil(Conditions.shellIsActive("Delete?"));
        bot.button(IDialogConstants.YES_LABEL).click();
    }
    bot.button(IDialogConstants.CANCEL_LABEL).click();
}
 
Example #18
Source File: SWTBotConnectorDefinitionTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testExistingConnectorDefinition() throws Exception {
    final String id = "test1";
    final String textLabel = "Definition id *";
    final String textLabelVersion = "Version *";
    final String version = "1.1.0";
    SWTBotConnectorTestUtil.activateConnectorDefinitionShell(bot);
    bot.textWithLabel(textLabel).setText(id);
    bot.button(IDialogConstants.FINISH_LABEL).click();
    SWTBotConnectorTestUtil.activateConnectorDefinitionShell(bot);
    testButtonDisabled(id, textLabel);
    bot.textWithLabel(textLabelVersion).setText(version);
    bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.FINISH_LABEL)), 5000);
    bot.button(IDialogConstants.CANCEL_LABEL).click();
}
 
Example #19
Source File: SuperBot.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void confirmShellClosingTheSession() throws RemoteException {
  SWTBotShell shell = new SWTBot().shell(SHELL_CLOSING_THE_SESSION);
  shell.activate();
  shell.bot().button(OK).click();
  shell.bot().waitUntil(Conditions.shellCloses(shell));
  // wait for tree update in the saros session view
  new SWTBot().sleep(500);
}
 
Example #20
Source File: DiagramProjectExplorerBot.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Duplicate a diagram. The behavior is to add '-copy' at the end of the original name.
 * WARNING: It doesn't work if the diagram to duplicate has several pools (pool Text have all the same id..)
 */
public void duplicateDiagram(String diagramName, String version) {
    clickOnContextualMenu(getDiagramTreeItem(diagramName, version), "Duplicate...");
    bot.waitUntil(Conditions.shellIsActive(org.bonitasoft.studio.common.Messages.openNameAndVersionDialogTitle));
    SWTBotShell activeShell = bot.activeShell();
    activeShell.setFocus();
    bot.textWithId("org.bonitasoft.studio.common.diagram.dialog.name.text").setText(diagramName + "-copy");
    SWTBotText poolText = bot.textWithId("org.bonitasoft.studio.common.diagram.dialog.poolName.text");
    poolText.setText(poolText.getText() + "-copy");
    bot.button(IDialogConstants.OK_LABEL).click();
    bot.waitUntil(Conditions.shellCloses(activeShell));
}
 
Example #21
Source File: CloneModelTest.java    From tlaplus with MIT License 5 votes vote down vote up
@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 #22
Source File: LivingApplicationProjectExplorerBot.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public void renameApplication(String oldName, String newName) {
    clickOnContextualMenu(getApplicationTreeItem(oldName), "Rename...");
    bot.waitUntil(Conditions.shellIsActive(Messages.rename));
    SWTBotShell activeShell = bot.activeShell();
    bot.text().setText(newName);
    bot.button(IDialogConstants.OK_LABEL).click();
    bot.waitUntil(Conditions.shellCloses(activeShell));
}
 
Example #23
Source File: RenameSpecHandlerTest.java    From tlaplus with MIT License 5 votes vote down vote up
@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 #24
Source File: ProjectExplorerAnalysisTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static boolean supplementaryFileExists(SWTBotTreeItem traceNode, String filename) {
    // make sure that analysis are finished
    WaitUtils.waitForJobs();
    try {
        ResourcesPlugin.getWorkspace().getRoot().getProject(TRACE_PROJECT_NAME).refreshLocal(IResource.DEPTH_INFINITE, null);
    } catch (CoreException e) {
    }
    // Make sure that all jobs are finished after refresh
    WaitUtils.waitForJobs();

    traceNode.contextMenu().menu("Delete Supplementary Files...").click();

    SWTBotShell shell = fBot.shell("Delete Resources");
    SWTBot bot = shell.bot();
    SWTBotTree tree = bot.tree();
    SWTBotTreeItem traceSupplNode = SWTBotUtils.getTreeItem(bot, tree, traceNode.getText());

    SWTBotTreeItem[] supplFileNodes = traceSupplNode.getItems();

    boolean supplFound = false;
    for (SWTBotTreeItem swtBotTreeItem : supplFileNodes) {
        if (swtBotTreeItem.getText().equals(filename)) {
            supplFound = true;
            break;
        }
    }

    bot.button("Cancel").click();
    fBot.waitUntil(Conditions.shellCloses(shell));
    return supplFound;
}
 
Example #25
Source File: ContextMenusInContactListArea.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void delete() throws RemoteException {
  getTreeItem().select();
  ContextMenuHelper.clickContextMenu(tree, CM_DELETE);
  SWTBotShell shell = new SWTBot().shell(CONFIRM_DELETE);
  shell.activate();
  shell.bot().button(YES).click();
  shell.bot().waitUntil(Conditions.shellCloses(shell));
  // wait for tree update in saros session view
  new SWTBot().sleep(500);
}
 
Example #26
Source File: ProjectExplorerTraceActionsTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test renaming of traces that are created with file system symbolic links.
 *
 * @throws CoreException
 *          If error happens
 * @throws TmfTraceImportException
 *          If error happens
 */
@Test
public void testRenameSymbolicLinks() throws CoreException, TmfTraceImportException {
    // Close editor from @Before since not needed
    fBot.closeAllEditors();

    // Create File system symbolic link to traces
    importTraceAsSymlink();
    SWTBotTreeItem traceItem = SWTBotUtils.getTraceProjectItem(fBot, SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME), SYMBOLIC_FOLDER_NAME, TRACE_NAME);
    fBot.viewByTitle(PROJECT_EXPLORER_VIEW_NAME).setFocus();
    traceItem.doubleClick();
    fBot.waitUntil(new ConditionHelpers.ActiveEventsEditor(fBot, SYMBOLIC_FOLDER_NAME + '/' + TRACE_NAME));

    traceItem = SWTBotUtils.getTraceProjectItem(fBot, SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME), SYMBOLIC_FOLDER_NAME, TRACE_NAME);
    traceItem.contextMenu().menu("Rename...").click();
    final String RENAME_TRACE_DIALOG_TITLE = "Rename Trace";
    SWTBotShell shell = fBot.shell(RENAME_TRACE_DIALOG_TITLE).activate();
    SWTBotText text = shell.bot().textWithLabel("New Trace name:");
    text.setText(RENAMED_TRACE_NAME);
    shell.bot().button("OK").click();
    fBot.waitUntil(Conditions.shellCloses(shell), DISK_ACCESS_TIMEOUT);
    fBot.waitWhile(new ConditionHelpers.ActiveEventsEditor(fBot, null));

    SWTBotTreeItem copiedItem = SWTBotUtils.getTraceProjectItem(fBot, SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME), SYMBOLIC_FOLDER_NAME, RENAMED_TRACE_NAME);
    copiedItem.contextMenu().menu("Open").click();
    SWTBotImportWizardUtils.testEventsTable(fBot, SYMBOLIC_FOLDER_NAME + '/' + RENAMED_TRACE_NAME, CUSTOM_TEXT_LOG.getNbEvents(), CUSTOM_TEXT_LOG.getFirstEventTimestamp());

    // Make sure that the traces have the correct link status
    testLinkStatus(copiedItem, true);
}
 
Example #27
Source File: TestPatternExpressionViewer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void fillPatternExpression() {
    bot.styledText().setText(QUERY);
    bot.sleep(1000);
    bot.button(IDialogConstants.NEXT_LABEL).click();
    if (bot.button(IDialogConstants.NEXT_LABEL).isEnabled()) {
        bot.button(IDialogConstants.NEXT_LABEL).click();
    }
    bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.FINISH_LABEL)), 5000);
    bot.button(IDialogConstants.FINISH_LABEL).click();
    bot.sleep(1000);
    bot.activeEditor().save();
}
 
Example #28
Source File: ProjectExplorerTraceActionsTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test that deleting a trace from an experiment: deletes the experiment if the
 * experiment is empty and deletes the trace from the Traces folder.
 */
@Test
public void test4_11DeleteTraceFromExperiment() {
    /*
     * close the editor for the trace to avoid name conflicts with the one for the
     * experiment
     */
    fBot.closeAllEditors();

    // create experiment
    SWTBotTreeItem traceItem = SWTBotUtils.getTraceProjectItem(fBot, SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME), TRACE_NAME);
    traceItem.contextMenu().menu("Open As Experiment...", "Generic Experiment").click();
    fBot.waitUntil(new ConditionHelpers.ActiveEventsEditor(fBot, TRACE_NAME));

    // find the trace under the experiment
    fBot.viewByTitle(PROJECT_EXPLORER_VIEW_NAME).setFocus();
    SWTBotTreeItem experimentsItem = SWTBotUtils.getTraceProjectItem(fBot, SWTBotUtils.selectProject(fBot, TRACE_PROJECT_NAME), "Experiments");
    experimentsItem.expand();
    fBot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable("ExampleCustomTxt.log [1]", experimentsItem));
    SWTBotTreeItem expItem = SWTBotUtils.getTraceProjectItem(fBot, experimentsItem, "ExampleCustomTxt.log [1]");
    expItem.expand();
    SWTBotTreeItem expTrace = expItem.getNode(TRACE_NAME);

    // delete it
    expTrace.contextMenu("Delete").click();
    SWTBotShell shell = fBot.shell("Confirm Delete").activate();
    shell.bot().button("Yes").click();
    fBot.waitUntil(Conditions.shellCloses(shell), DISK_ACCESS_TIMEOUT);
    fBot.waitWhile(new ConditionHelpers.ActiveEventsEditor(fBot, null));

    // ensure that it is properly deleted from places.
    SWTBotUtils.waitUntil(exp -> exp.getItems().length == 0, experimentsItem,
            "Failed to delete the trace from the experiment");
    fBot.waitUntil(new TraceDeletedCondition());
}
 
Example #29
Source File: BotImportOtherDialog.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void finish() {
    bot.waitUntil(Conditions.widgetIsEnabled(bot.button(Messages.importButtonLabel)), 10000);
    bot.button(Messages.importButtonLabel).click();
    bot.waitUntil(Conditions.shellIsActive(org.bonitasoft.studio.importer.i18n.Messages.importResultTitle), 60000);
    final SWTBotShell activeShell = bot.activeShell();
    bot.button(IDialogConstants.OK_LABEL).click();
    bot.waitUntil(Conditions.shellCloses(activeShell));
}
 
Example #30
Source File: FindDialogTestBase.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test open/close the find dialog
 */
@Test
public void testOpenCloseDialog() {
    SWTBotShell shell = getDialogShell();
    closeDialog(getDialogBot());
    fBot.waitUntil(Conditions.shellCloses(shell));
    openDialog(fViewBot);
}