Java Code Examples for org.eclipse.swtbot.swt.finder.widgets.SWTBotShell#setFocus()

The following examples show how to use org.eclipse.swtbot.swt.finder.widgets.SWTBotShell#setFocus() . 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: ActorDefinitionTranslationsTest.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.button(IDialogConstants.OK_LABEL).click();
    activeShell.setFocus();
}
 
Example 2
Source File: ActorFilterDefinitionTest.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testCreateExistingCategory() throws Exception {
    final String id = "test7";
    final String version = "1.0.0";
    final String categoryId = "category3";
    SWTBotActorFilterUtil.createActorFilterDefinition(bot, id, version);
    SWTBotActorFilterUtil.createNewCategory(bot, categoryId);
    SWTBotShell activeShell = bot.activeShell();
    bot.button("New...").click();
    bot.textWithLabel("Id").setText(categoryId);
    assertFalse(
            "Ok button should be disabled when trying to create an existing category",
            bot.button(IDialogConstants.OK_LABEL).isEnabled());
    bot.button(IDialogConstants.CANCEL_LABEL).click();
    activeShell.setFocus();
    bot.button(IDialogConstants.FINISH_LABEL).click();
}
 
Example 3
Source File: TestConnectorExpression.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testConnectorExpression() {
    final String id = "connectorExpressionTest";
    createConnectorDefinition(id);
    SWTBotConnectorTestUtil.activateConnectorTestWizard(bot);
    bot.text().setText(id);
    bot.table().select(id);
    bot.button(IDialogConstants.NEXT_LABEL).click();
    SWTBotShell activeShell = bot.activeShell();
    bot.toolbarButtonWithId(SWTBOT_ID_EDITBUTTON, 0).click();
    bot.table().select("Constant");
    bot.text().setText("Hello World");
    assertFalse("return type combobox should be disabled", bot.comboBoxWithLabel("Return type").isEnabled());
    assertEquals("wrong return type", bot.comboBoxWithLabel("Return type").selection(), String.class.getName());
    bot.button(IDialogConstants.OK_LABEL).click();
    activeShell.setFocus();
    assertEquals("wrong value for input1", bot.textWithLabel("Input1").getText(), "Hello World");
    editGroovyEditor(1, "Input2", Boolean.class.getName(), "booleanScriptTest", "1==1;");
    editGroovyEditor(2, "Input3", Double.class.getName(), "doubleScriptTest", "(double)9.345+1.256;");
    editGroovyEditor(3, "Input4", Float.class.getName(), "floatScriptTest", "(float)9.345+1.256;");
    editGroovyEditor(4, "Input5", Integer.class.getName(), "integerScriptTest", "(int)9+10;");
    editGroovyEditor(5, "Input6", List.class.getName(), "listScriptTest", "def list=[1,2,3];");
    bot.button(IDialogConstants.CANCEL_LABEL).click();
}
 
Example 4
Source File: TestPatternExpressionViewer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void editGroovyEditor(final int buttonIndex, final String inputName, final String inputtype,
        final String scriptName, final String groovyScript) {
    SWTBotShell activeShell = bot.activeShell();
    bot.toolbarButtonWithId(SWTBOT_ID_EDITBUTTON, buttonIndex).click();
    bot.table().select("Script");
    bot.waitUntil(Conditions.widgetIsEnabled(bot.textWithLabel("Name")), 10000);
    bot.textWithLabel("Name").setText(scriptName);
    bot.styledText().setText(groovyScript);
    assertFalse("return type combobox should be disabled", bot.comboBoxWithLabel("Return type").isEnabled());
    assertEquals("return type should be" + inputtype, bot.comboBoxWithLabel("Return type").getText(), inputtype);
    bot.button(IDialogConstants.OK_LABEL).click();
    activeShell.setFocus();
    bot.waitUntil(Conditions.shellIsActive(activeShell.getText()));
    assertEquals("wrong value for " + inputName, bot.textWithId(SWTBOT_ID_EXPRESSIONVIEWER_TEXT, 0).getText(),
            scriptName);
}
 
Example 5
Source File: TestPatternExpressionViewer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void fillGroovyExpression() {
    SWTBotShell activeShell = bot.activeShell();
    bot.link(Messages.switchEditor).click(Messages.switchEditor.replaceAll("<A>", "").replaceAll("</A>", ""));
    bot.button(IDialogConstants.YES_LABEL).click();
    activeShell.setFocus();
    bot.waitUntil(Conditions.shellIsActive(activeShell.getText()));
    editGroovyEditor(0, "Request", String.class.getName(), "sqlQuery", GROOVY_SQL_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 6
Source File: ConnectorDefinitionTranslationsTest.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.button(IDialogConstants.OK_LABEL).click();
    activeShell.setFocus();
}
 
Example 7
Source File: ConnectorDefinitionWizardPageTest.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) {
    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.button(IDialogConstants.OK_LABEL).click();
    activeShell.setFocus();

}
 
Example 8
Source File: BotOpenDiagramDialog.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public BotOpenDiagramDialog delete() {
	SWTBotShell activeShell = bot.activeShell();
    bot.button(org.bonitasoft.studio.diagram.custom.i18n.Messages.removeProcessLabel).click();
    bot.waitUntil(
            Conditions.shellIsActive(org.bonitasoft.studio.diagram.custom.i18n.Messages.confirmProcessDeleteTitle));
    bot.button(IDialogConstants.YES_LABEL).click();
    bot.waitUntil(Conditions.shellIsActive(getDialogTitle()));
    activeShell.setFocus();
    return this;
}
 
Example 9
Source File: SWTBotActorFilterUtil.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * use it when the wizard "New definition" is active. (menu
 * development>Actors filters>New definition...)
 *
 * @param bot
 * @param categoryId
 * @throws Exception
 */
public static void createNewCategory(final SWTBot bot, final String categoryId)
        throws Exception {
    bot.waitUntil(Conditions.widgetIsEnabled(bot.button("New...")), 10000);
    SWTBotShell activeShell = bot.activeShell();
    bot.button("New...").click();
    Assert.assertFalse("ok button should be desabled",
            bot.button(IDialogConstants.OK_LABEL).isEnabled());
    bot.textWithLabel("Id").setText(categoryId);
    bot.textWithLabel("Display name").setText(categoryId);
    bot.button(IDialogConstants.OK_LABEL).click();
    activeShell.setFocus();
}
 
Example 10
Source File: OpenApplicationWizardBot.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public OpenApplicationWizardBot rename(String newName) {
    SWTBotShell activeShell = bot.activeShell();
    bot.button(org.bonitasoft.studio.ui.i18n.Messages.rename).click();
    bot.waitUntil(Conditions.shellIsActive(org.bonitasoft.studio.ui.i18n.Messages.rename));
    bot.text().setText(newName);
    bot.button(IDialogConstants.OK_LABEL).click();
    activeShell.setFocus();
    bot.waitUntil(Conditions.shellIsActive(Messages.openExistingApplication));
    return this;
}
 
Example 11
Source File: SWTBotConnectorTestUtil.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * use it when the wizard "New definition" is active. (menu
 * development>connectors>New definition...)
 * 
 * @param bot
 * @param categoryId
 * @throws Exception
 */
public static void createNewCategory(SWTBot bot, String categoryId) {
    bot.waitUntil(Conditions.widgetIsEnabled((bot.button("New..."))), 10000);
    SWTBotShell activeShell = bot.activeShell();
    bot.button("New...").click();
    bot.waitUntil(Conditions.widgetIsEnabled(bot.activeShell()));
    Assert.assertFalse("ok button should be desabled",
            bot.button(IDialogConstants.OK_LABEL).isEnabled());
    bot.textWithLabel("Id").setText(categoryId);
    bot.textWithLabel("Display name").setText(categoryId);
    bot.button(IDialogConstants.OK_LABEL).click();
    activeShell.setFocus();
}
 
Example 12
Source File: SWTBotTestUtil.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param bot
 */
public static void editScriptConnector(final SWTGefBot bot, final String scriptName, final String scriptText,
        final String scriptDescription) {
    // 1st page
    editConnector(bot, "Script", "Groovy");

    // 2nde page
    bot.textWithLabel("Name *").setText(scriptName);
    if (scriptDescription != null) {
        bot.textWithLabel("Description").setText(scriptDescription);
    }
    Assert.assertTrue("Error : Next button is not enable in Connectors Wizard.",
            bot.button(IDialogConstants.NEXT_LABEL).isEnabled());
    bot.button(IDialogConstants.NEXT_LABEL).click();

    // 3th page
    SWTBotShell activeShell = bot.activeShell();
    bot.toolbarButtonWithId(SWTBOT_ID_EDITBUTTON).click();
    bot.waitUntil(Conditions.widgetIsEnabled(bot.textWithLabel("Name")));
    bot.textWithLabel("Name").setText(scriptName);
    bot.styledText().setText(scriptText);
    bot.button(IDialogConstants.OK_LABEL).click();
    activeShell.setFocus();
    bot.button(IDialogConstants.NEXT_LABEL).click();

    // 4th page
    Assert.assertTrue("Error : finish button is not enable in Connectors Wizard.",
            bot.button(IDialogConstants.FINISH_LABEL).isEnabled());
    bot.button(IDialogConstants.FINISH_LABEL).click();
}
 
Example 13
Source File: DataWizardIT.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void testProcessDataCanBeInitializedWithProcessContractInput() throws ExecutionException {
    final BotApplicationWorkbenchWindow botApplicationWorkbenchWindow = new BotApplicationWorkbenchWindow(bot);
    final BotProcessDiagramPerspective diagramPerspective = botApplicationWorkbenchWindow.createNewDiagram();
    final BotGefProcessDiagramEditor activeProcessDiagramEditor = diagramPerspective.activeProcessDiagramEditor();
    final Pool pool = (Pool) activeProcessDiagramEditor.getSelectedSemanticElement();
    Display.getDefault().syncExec(new Runnable() {

        @Override
        public void run() {
            try {
                new AbstractEMFOperation(TransactionUtil.getEditingDomain(pool), "Prepare Pool with Contract Input") {

                    @Override
                    protected IStatus doExecute(final IProgressMonitor monitor, final IAdaptable info)
                            throws ExecutionException {
                        final Contract contract = ProcessFactory.eINSTANCE.createContract();
                        final ContractInput contractInput = ProcessFactory.eINSTANCE.createContractInput();
                        contractInput.setName("input1");
                        contractInput.setType(ContractInputType.TEXT);
                        contract.getInputs().add(contractInput);
                        pool.setContract(contract);
                        return Status.OK_STATUS;
                    }
                }.execute(null, null);
            } catch (final ExecutionException e) {
                e.printStackTrace();
            }
        }
    });

    final BotDataPropertySection botDataPropertySection = diagramPerspective.getDiagramPropertiesPart().selectDataTab()
            .selectPoolDataTab();
    final BotAddDataWizardPage addData = botDataPropertySection.addData();
    SWTBotShell activeShell = bot.activeShell();
    addData.editDefaultValueExpression().selectContractInputType().selectContractInput("input1 -- TEXT").ok();
    activeShell.setFocus();
    bot.button(IDialogConstants.CANCEL_LABEL).click();
}
 
Example 14
Source File: TestConnectorExpression.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void editGroovyEditor(int buttonIndex, String inputName, String inputtype, String scriptName,
        String groovyScript) {
    SWTBotShell activeShell = bot.activeShell();
    bot.toolbarButtonWithId(SWTBOT_ID_EDITBUTTON, buttonIndex).click();
    bot.table().select("Script");
    bot.waitUntil(Conditions.widgetIsEnabled(bot.textWithLabel("Name")), 10000);
    bot.textWithLabel("Name").setText(scriptName);
    bot.styledText().setText(groovyScript);
    assertFalse("return type combobox should be disabled", bot.comboBoxWithLabel("Return type").isEnabled());
    assertEquals("return type should be" + inputtype, bot.comboBoxWithLabel("Return type").getText(), inputtype);
    bot.button(IDialogConstants.OK_LABEL).click();
    activeShell.setFocus();
    assertEquals("wrong value for " + inputName, bot.textWithLabel(inputName).getText(), scriptName);
}
 
Example 15
Source File: StandardImportWizardTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static void selectSyslog() throws Exception {
    SWTWorkbenchBot workbenchBot = getSWTBot();
    SWTBotShell shell = workbenchBot.shell("Trace Import");
    shell.setFocus();
    SWTBot bot = shell.bot();
    URL resource = TmfCoreTestPlugin.getDefault().getBundle().getResource(TEST_FOLDER_NAME);
    String path = FileLocator.toFileURL(resource).toURI().getPath();
    SWTBotImportWizardUtils.selectImportFromDirectory(bot, path);
    for (int i = 1; i <= 6; i++) {
        SWTBotImportWizardUtils.selectFile(bot, "syslog" + i, TEST_FOLDER_NAME);
    }
}
 
Example 16
Source File: DataWizardIT.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void testDataDefaultValueReturnType() throws Exception {
    SWTBotTestUtil.createNewDiagram(bot);
    final SWTBotEditor botEditor = bot.activeEditor();
    final SWTBotGefEditor gmfEditor = bot.gefEditor(botEditor.getTitle());

    final IGraphicalEditPart part = (IGraphicalEditPart) gmfEditor.mainEditPart().part();
    final MainProcess model = (MainProcess) part.resolveSemanticElement();
    final Pool pool = (Pool) model.getElements().get(0);

    gmfEditor.getEditPart(pool.getName()).parent().select();
    bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_PROCESS_DATA).show();

    SWTBotTestUtil.selectTabbedPropertyView(bot, SWTBotTestUtil.VIEWS_PROPERTIES_POOL_DATA_VARIABLES);

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

    final String dataName = "myDataName";
    bot.textWithLabel(Messages.name + " *").setText(dataName);

    String defaultValue = "test return type";
    bot.textWithLabel(Messages.defaultValueLabel).setText(defaultValue);
    bot.sleep(500);

    SWTBotShell activeShell = bot.activeShell();
    bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON).click();
    assertEquals("Expression return type should be " + String.class.getName(), String.class.getName(),
            bot.comboBoxWithLabel(Messages.returnType).getText());
    bot.button(IDialogConstants.OK_LABEL).click();
    activeShell.setFocus();
    bot.comboBoxWithLabel(Messages.datatypeLabel).setSelection(DataTypeLabels.integerDataType);

    defaultValue = "50";
    bot.textWithLabel(Messages.defaultValueLabel).setText(defaultValue);
    bot.sleep(500);
    bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON).click();
    assertEquals("Expression return type should be " + Integer.class.getName(), Integer.class.getName(),
            bot.comboBoxWithLabel(Messages.returnType)
                    .getText());

    bot.button(IDialogConstants.OK_LABEL).click();
    activeShell.setFocus();
    bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.FINISH_LABEL)));
    bot.button(IDialogConstants.FINISH_LABEL).click();
}
 
Example 17
Source File: TestCustomXmlWizard.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test to create a custom XML trace and compare the XML generated
 *
 * @throws IOException
 *             the xml file is not accessible, this is bad
 * @throws FileNotFoundException
 *             the xml file wasn't written, this is bad
 */
@Test
public void testNew() throws FileNotFoundException, IOException {
    File xmlFile = ResourcesPlugin.getWorkspace().getRoot().getLocation().append(".metadata/.plugins/org.eclipse.tracecompass.tmf.core/custom_xml_parsers.xml").toFile();
    SWTBotUtils.createProject(PROJECT_NAME);
    SWTBotTreeItem treeNode = SWTBotUtils.selectTracesFolder(fBot, PROJECT_NAME);
    treeNode.contextMenu("Manage Custom Parsers...").click();
    SWTBotShell shell = fBot.shell(MANAGE_CUSTOM_PARSERS_SHELL_TITLE).activate();
    shell.setFocus();
    SWTBot bot = shell.bot();
    bot.radio("XML").click();
    bot.button("New...").click();
    shell = bot.shell(CUSTOM_XML_PARSER_SHELL_TITLE).activate();
    shell.setFocus();
    bot = shell.bot();
    bot.textWithLabel("Category:").setText(CATEGORY_NAME);
    bot.textWithLabel("Trace type:").setText(TRACETYPE_NAME);
    bot.textWithLabel("Time Stamp format:").setText("ss");

    bot.styledText().setText(XML_TRACE1);
    bot.buttonWithTooltip("Feeling lucky").click();

    bot.tree().getTreeItem(TRACE).getNode(EVENT).select();
    bot.checkBox("Log Entry").click();
    bot.button("Next >").click();
    bot.button("Finish").click();

    shell = fBot.shell(MANAGE_CUSTOM_PARSERS_SHELL_TITLE).activate();
    shell.setFocus();
    bot = shell.bot();
    bot.waitUntil(new CustomDefinitionHasContent(xmlFile, CATEGORY_NAME, TRACETYPE_NAME, EXPECTED_TEST_DEFINITION));
    String xmlPart = extractTestXml(xmlFile, CATEGORY_NAME, TRACETYPE_NAME);
    assertEquals(EXPECTED_TEST_DEFINITION, xmlPart);
    bot.list().select(CATEGORY_NAME + " : " + TRACETYPE_NAME);
    bot.button("Delete").click();

    shell = fBot.shell("Delete Custom Parser").activate();
    shell.setFocus();
    bot = shell.bot();
    bot.button("Yes").click();


    shell = fBot.shell(MANAGE_CUSTOM_PARSERS_SHELL_TITLE).activate();
    shell.setFocus();
    bot = shell.bot();
    bot.button("Close").click();
    fBot.waitUntil(new CustomDefinitionHasContent(xmlFile, CATEGORY_NAME, TRACETYPE_NAME, ""));
    xmlPart = extractTestXml(xmlFile, CATEGORY_NAME, TRACETYPE_NAME);
    assertEquals("", xmlPart);

    SWTBotUtils.deleteProject(PROJECT_NAME, fBot);
}
 
Example 18
Source File: TestTraceOffsetting.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test offsetting by 99 ns
 */
@Test
public void testOffsetting() {
    // Skip this test on Mac OS X 10.11.1 because of bug 481611
    // FIXME: Remove this work around once bug 481611 is fixed
    MacOsVersion macOsVersion = MacOsVersion.getMacOsVersion();
    boolean macBugPresent = macOsVersion != null && macOsVersion.compareTo(new MacOsVersion(10, 11, 1)) >= 0;
    assumeTrue(!macBugPresent);

    SWTBotUtils.createProject(PROJET_NAME);
    SWTBotTreeItem traceFolderItem = SWTBotUtils.selectTracesFolder(fBot, PROJET_NAME);
    SWTBotUtils.openTrace(PROJET_NAME, fLocation.getAbsolutePath(), "org.eclipse.linuxtools.tmf.core.tests.xmlstub");
    SWTBotEditor editor = fBot.editorByTitle(fLocation.getName());
    SWTBotTable eventsTableBot = editor.bot().table();
    String timestamp = eventsTableBot.cell(1, 1);
    assertEquals("19:00:00.000 000 000", timestamp);
    SWTBotTreeItem traceItem = SWTBotUtils.getTraceProjectItem(fBot, traceFolderItem, fLocation.getName());
    traceItem.select();
    traceItem.contextMenu("Apply Time Offset...").click();
    WaitUtils.waitForJobs();
    // set offset to 99 ns
    SWTBotShell shell = fBot.shell("Apply time offset");
    shell.setFocus();
    SWTBotTreeItem[] allItems = fBot.tree().getAllItems();
    final SWTBotTreeItem swtBotTreeItem = allItems[0];
    swtBotTreeItem.select();
    swtBotTreeItem.click(1);
    // Press shortcuts on the cell editor
    SWTBotText text = shell.bot().text(1);
    text.pressShortcut(KeyStroke.getInstance('9'));
    text.pressShortcut(KeyStroke.getInstance('9'));
    text.pressShortcut(KeyStroke.getInstance('\n'));
    WaitUtils.waitForJobs();
    fBot.button("OK").click();

    // wait for trace to close
    fBot.waitWhile(ConditionHelpers.isEditorOpened(fBot, fLocation.getName()));

    // re-open trace
    SWTBotUtils.openTrace(PROJET_NAME, fLocation.getAbsolutePath(), "org.eclipse.linuxtools.tmf.core.tests.xmlstub");
    editor = fBot.editorByTitle(fLocation.getName());
    eventsTableBot = editor.bot().table();
    timestamp = eventsTableBot.cell(1, 1);
    assertEquals("19:01:39.000 000 000", timestamp);
    SWTBotUtils.deleteProject(PROJET_NAME, fBot);
}
 
Example 19
Source File: DataWizardIT.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void testDatacantBeInitializeByItself() {
    final BotApplicationWorkbenchWindow botApplicationWorkbenchWindow = new BotApplicationWorkbenchWindow(bot);
    final BotProcessDiagramPerspective diagramPerspective = botApplicationWorkbenchWindow.createNewDiagram();
    final BotGefProcessDiagramEditor activeProcessDiagramEditor = diagramPerspective.activeProcessDiagramEditor();
    activeProcessDiagramEditor.selectDiagram();
    diagramPerspective.getDiagramPropertiesPart().selectGeneralTab().selectDiagramTab().setName("DataInit");

    final EObject selectedSemanticElement = activeProcessDiagramEditor.selectElement("Step1")
            .getSelectedSemanticElement();
    final AbstractProcess proc = ModelHelper.getParentProcess(selectedSemanticElement);

    // add data to Process
    activeProcessDiagramEditor.selectElement(proc.getName());
    BotDataPropertySection botDataPropertySection = diagramPerspective.getDiagramPropertiesPart().selectDataTab()
            .selectPoolDataTab();
    BotAddDataWizardPage addData = botDataPropertySection.addData();
    addData.setName("procVar_1").setType("Text").finishAndAdd().setName("procVar_2").setType("Integer").finish();

    diagramPerspective.activeProcessDiagramEditor().addElementAfter("Step1", SWTBotTestUtil.CONTEXTUALPALETTE_STEP,
            PositionConstants.EAST);

    // set data on step1 Task
    diagramPerspective.activeProcessDiagramEditor().selectElement("Step1");
    botDataPropertySection = diagramPerspective.getDiagramPropertiesPart().selectDataTab().selectLocalDataTab();
    addData = botDataPropertySection.addData();
    addData.setName("varS1_1").setType("Text").finishAndAdd().setName("varS1_2").setType("Integer").finish();

    // set data on step2 Task
    diagramPerspective.activeProcessDiagramEditor().selectElement("Step2");
    botDataPropertySection = diagramPerspective.getDiagramPropertiesPart().selectDataTab().selectLocalDataTab();
    addData = botDataPropertySection.addData();
    addData.setName("varS2_1").setType("Text").finishAndAdd().setName("varS2_2").setType("Integer").finish();
    botApplicationWorkbenchWindow.save();

    // check only process variables are available in tasks data edit expression
    diagramPerspective.activeProcessDiagramEditor().selectElement("Step1");
    botDataPropertySection = diagramPerspective.getDiagramPropertiesPart().selectDataTab().selectLocalDataTab();

    // Test on var varS1_1
    botDataPropertySection.processDataList().select("varS1_1" + " -- " + "Text");
    BotEditDataDialog editDataWizardPage = botDataPropertySection.edit();
    BotExpressionEditorDialog editDefaultValueExpression = editDataWizardPage.editDefaultValueExpression();
    BotTableWidget variableList = editDefaultValueExpression.selectVariableTab().variableList();

    assertThat(variableList.containsItem("varS1_1" + " -- " + "Text"))
            .overridingErrorMessage("Error: Task data can't be initialized by itself").isFalse();
    assertThat(variableList.containsItem("varS1_2" + " -- " + "Integer")).overridingErrorMessage(
            "Error: Task data can't be initialized by a sibling task data").isFalse();

    assertThat(variableList.containsItem("varS2_1" + " -- " + "Text")).overridingErrorMessage(
            "Error: Task data can't be initialized by task data").isFalse();
    assertThat(variableList.containsItem("varS2_2" + " -- " + "Integer")).overridingErrorMessage(
            "Error: Task data can't be initialized by task data").isFalse();

    assertThat(variableList.containsItem("procVar_1" + " -- " + "Text")).overridingErrorMessage(
            "Error:  Task data sould be initialized by Process data", variableList.getSWTBotWidget().rowCount())
            .isTrue();
    assertThat(variableList.containsItem("procVar_2" + " -- " + "Integer")).overridingErrorMessage(
            "Error:  Task data sould be initialized by Process data", variableList.getSWTBotWidget().rowCount())
            .isTrue();

    editDefaultValueExpression.cancel();
    editDataWizardPage.cancel();

    // Test on var varS1_2
    botDataPropertySection.processDataList().select("varS1_2" + " -- " + "Integer");
    editDataWizardPage = botDataPropertySection.edit();
    SWTBotShell activeShell = bot.activeShell();

    editDefaultValueExpression = editDataWizardPage.editDefaultValueExpression();
    variableList = editDefaultValueExpression.selectVariableTab().variableList();

    assertThat(variableList.containsItem("varS1_2" + " -- " + "Integer")).overridingErrorMessage(
            "Error: Task data can't be initialized by itself").isFalse();
    assertThat(variableList.containsItem("varS1_1" + " -- " + "Text")).overridingErrorMessage(
            "Error: Task data can't be initialized by a sibling task data").isFalse();

    assertThat(variableList.containsItem("varS2_1" + " -- " + "Text")).overridingErrorMessage(
            "Error: Task data can't be initialized by task data").isFalse();
    assertThat(variableList.containsItem("procVar_1" + " -- " + "Text")).overridingErrorMessage(
            "Error:  Task data sould be initialized by Process data").isTrue();

    assertThat(variableList.containsItem("varS2_2" + " -- " + "Integer")).overridingErrorMessage(
            "Error: Task data can't be initialized by task data").isFalse();
    assertThat(variableList.containsItem("procVar_2" + " -- " + "Integer")).overridingErrorMessage(
            "Error:  Task data sould be initialized by Process data").isTrue();

    bot.button(IDialogConstants.CANCEL_LABEL).click();
    activeShell.setFocus();
    bot.button(IDialogConstants.CANCEL_LABEL).click();
}
 
Example 20
Source File: TestTimer.java    From bonita-studio with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Set properties on a Fixed Date Timer .
 *
 * @throws InterruptedException
 * @throws ParseException
 */
@Test
public void testEditVariableScriptTimerCondition() throws Exception {

    final SWTBotGefEditor gmfEditor = addTimerAndTaskToDiagram();

    // Set Timer1
    editTimerCondition(gmfEditor, DEFAULT_TIMER_NAME);
    SWTBotShell activeShell = bot.activeShell();
    bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON, 0).click();

    // wait for "Edit Expression" shell
    bot.waitUntil(Conditions.shellIsActive(editExpressionShellLabel));

    bot.table().select("Script");

    bot.waitUntil(Conditions.widgetIsEnabled(bot.textWithLabel("Name")));
    bot.textWithLabel("Name").setText("myScript");

    bot.styledText().setText("120000");

    Assert.assertEquals("Error: Wrong Timer Condition setted", "120000", bot.styledText().getText());

    // "Return type" , "java.lang.Long"
    bot.comboBoxWithLabel(org.bonitasoft.studio.groovy.ui.Messages.returnType).setSelection(TestTimer.JAVA_LANG_LONG);

    Assert.assertEquals("Error: Wrong Timer Condition return type setted", TestTimer.JAVA_LANG_LONG,
            bot.comboBoxWithLabel(org.bonitasoft.studio.groovy.ui.Messages.returnType).getText());

    // in the shell editor for 'Every hour'
    bot.button(IDialogConstants.OK_LABEL).click();

    activeShell.setFocus();
    
    assertEquals("xpression not created correctly", "myScript", bot.text().getText());

    bot.button(IDialogConstants.FINISH_LABEL).click();

    Assert.assertEquals("Error: Wrong Timer Condition", "00:02:00",
            bot.textWithLabel(Messages.timerCondition).getText());

    bot.menu("File").menu("Save").click();
    final IStatus status = SWTBotTestUtil.selectAndRunFirstPoolFound(bot);
    assertTrue(status.getMessage(), status.isOK());
}