Java Code Examples for org.eclipse.swtbot.swt.finder.widgets.SWTBotTree#getTreeItem()

The following examples show how to use org.eclipse.swtbot.swt.finder.widgets.SWTBotTree#getTreeItem() . 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: ImportBdmWizardBot.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public ImportBdmWizardBot setImportAction(String packageName, String action) {
    SWTBotTree tree = bot.tree();
    SWTBotShell activeShell = bot.activeShell();
    bot.waitUntil(treeItemAvailable(tree, packageName));
    SWTBotTreeItem treeItem = tree.getTreeItem(packageName);
    treeItem.select();
    treeItem.click(1);

    SWTBot activeBot = activeShell.bot();
    SWTBotCCombo ccomboBoxInGroup = activeBot.ccomboBoxWithId(SmartImportBdmPage.IMPORT_ACTION_COMBO_EDITOR_ID);
    activeBot.waitUntil(new ConditionBuilder()
            .withTest(() -> Stream.of(ccomboBoxInGroup.items()).anyMatch(action::equals))
            .withFailureMessage(() -> String.format("Action '%s' not found in combo", action))
            .create());
    ccomboBoxInGroup.setSelection(action);
    return this;
}
 
Example 2
Source File: SmartImportBdmIT.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void should_import_when_bdm_are_not_confilicting() throws Exception {
    BotApplicationWorkbenchWindow workbenchBot = new BotApplicationWorkbenchWindow(bot);
    ImportBdmWizardBot importBot = workbenchBot.importBDM();
    importBot.setArchive(getFileURL("/smartImport/model_not_conflicting.zip"));

    SWTBotTree importTree = bot.tree();
    bot.waitUntil(importBot.treeItemAvailable(importTree, BUSINESS_PACKAGE));
    bot.waitUntil(importBot.treeItemAvailable(importTree, String.format("%s (%s)", HUMAN_PACKAGE, Messages.skipped)));
    assertThat(bot.button(org.bonitasoft.studio.ui.i18n.Messages.importLabel).isEnabled()).isTrue();

    SWTBotTreeItem treeItem = importTree.getTreeItem(BUSINESS_PACKAGE);
    treeItem.expand();
    bot.waitUntil(importBot.treeNodeAvailable(treeItem, ACCOUNT_BO));
    bot.waitUntil(importBot.treeNodeAvailable(treeItem, String.format("%s (%s)", LOAN_BO, Messages.skipped)));

    importBot.doImport();

    BusinessObjectModelFileStore fileStore = (BusinessObjectModelFileStore) repositoryStore.getChild("bom.xml", true);
    assertThat(fileStore.getContent().getBusinessObjects()).extracting(BusinessObject::getQualifiedName)
            .containsExactlyInAnyOrder(toQualifiedName(BUSINESS_PACKAGE, LOAN_BO),
                    toQualifiedName(BUSINESS_PACKAGE, ACCOUNT_BO),
                    toQualifiedName(HUMAN_PACKAGE, PERSON_BO),
                    toQualifiedName(HUMAN_PACKAGE, ADDRESS_BO));
}
 
Example 3
Source File: NewCounterViewTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Validate the Counters view data model.
 */
@Test
public void testDisplayingDataSeries() {
    // Setup the chart viewer
    IViewPart viewPart = getSWTBotView().getViewReference().getView(true);
    assertTrue(viewPart instanceof CounterView);
    final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart);
    assertNotNull(chartViewer);
    fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
    chartViewer.setNbPoints(NUMBER_OF_POINTS);
    fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));

    final Chart chart = getChart();
    assertNotNull(chart);
    assertEquals(0, chart.getSeriesSet().getSeries().length);

    // Check the counter entry
    SWTBotTree treeBot = getSWTBotView().bot().tree();
    WaitUtils.waitUntil(tree -> tree.rowCount() >= 1, treeBot, "The tree viewer did not finish loading.");
    SWTBotTreeItem root = treeBot.getTreeItem(TRACE_NAME);
    SWTBotTreeItem counter = retrieveTreeItem(root, COUNTER_NAME);
    assertNotNull(counter);
    counter.check();
    fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
    WaitUtils.waitUntil(c -> c.getSeriesSet().getSeries().length >= 1, chart, "The data series did not load.");

    // Ensure the data series has the correct styling
    verifySeriesStyle(MAIN_SERIES_NAME, ISeries.SeriesType.LINE, BLUE, LineStyle.SOLID, false);

    // Ensure the data model is valid
    WaitUtils.waitUntil(json -> isChartDataValid(chart, json, MAIN_SERIES_NAME),
            "resources/minor_faults-res50.json", "The chart data is not valid.");
}
 
Example 4
Source File: NewCounterViewTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Ensure the data displayed in the chart viewer reflects the tree viewer's
 * selected entries.
 */
@Test
public void testManipulatingTreeViewer() {
    final Chart chart = getChart();
    assertNotNull(chart);
    assertEquals(0, chart.getSeriesSet().getSeries().length);

    SWTBotTree treeBot = getSWTBotView().bot().tree();
    WaitUtils.waitUntil(tree -> tree.rowCount() >= 1, treeBot, "The tree viewer did not finish loading.");
    SWTBotTreeItem root = treeBot.getTreeItem(TRACE_NAME);
    assertNotNull(root);
    SWTBotTreeItem counter = retrieveTreeItem(root, COUNTER_NAME);
    assertNotNull(counter);

    // Check all elements of the tree
    root.check();
    WaitUtils.waitUntil(SWTBotTreeItem::isChecked, root, "Root entry was not checked");
    assertTrue(counter.isChecked());
    assertFalse(root.isGrayed());
    assertFalse(counter.isGrayed());
    WaitUtils.waitUntil(c -> c.getSeriesSet().getSeries().length >= 3, chart, "The data series did not load.");

    // Uncheck a leaf of the tree
    counter.uncheck();
    assertTrue(root.isChecked());
    assertTrue(root.isGrayed());
    assertFalse(counter.isChecked());
    assertFalse(counter.isGrayed());
    WaitUtils.waitUntil(c -> c.getSeriesSet().getSeries().length >= 2, chart,
            "A data series has not been removed.");
}
 
Example 5
Source File: FetchRemoteTracesTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static void deleteProfile() {
    openRemoteProfilePreferences();

    // The second tree is the remote profiles tree on the right side
    SWTBotTree tree = fBot.tree(1);
    SWTBotTreeItem treeNode = tree.getTreeItem(PROFILE_NAME);
    treeNode.select();
    fBot.button("Remove").click();
    SWTBotUtils.pressOKishButtonInPreferences(fBot);
}
 
Example 6
Source File: SmartImportBdmIT.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void should_import_according_to_user_choices_when_conflicts_are_solvable() throws Exception {
    BotApplicationWorkbenchWindow workbenchBot = new BotApplicationWorkbenchWindow(bot);
    ImportBdmWizardBot importBot = workbenchBot.importBDM();
    importBot.setArchive(getFileURL("/smartImport/model_conflicting_ok.zip"));

    SWTBotTree importTree = bot.tree();
    bot.waitUntil(importBot.treeItemAvailable(importTree, HUMAN_PACKAGE));
    bot.waitUntil(importBot.treeItemAvailable(importTree, String.format("%s (%s)", BUSINESS_PACKAGE, Messages.skipped)));
    assertThat(bot.button(org.bonitasoft.studio.ui.i18n.Messages.importLabel).isEnabled()).isTrue();

    SWTBotTreeItem treeItem = importTree.getTreeItem(HUMAN_PACKAGE);
    treeItem.expand();
    bot.waitUntil(importBot.treeNodeAvailable(treeItem, String.format(org.bonitasoft.studio.businessobject.i18n.Messages.conflictingWithSameObject, PERSON_BO)));
    bot.waitUntil(importBot.treeNodeNotAvailable(treeItem, String.format("%s (%s)", ADDRESS_BO, Messages.skipped)));

    assertThat(treeItem.cell(1)).isEqualTo(ImportAction.OVERWRITE.toString());

    importBot.setImportAction(HUMAN_PACKAGE, ImportAction.KEEP.toString());
    bot.waitUntil(importBot.treeNodeAvailable(treeItem, String.format(org.bonitasoft.studio.businessobject.i18n.Messages.conflictingWithSameObject, PERSON_BO)));
    bot.waitUntil(importBot.treeNodeAvailable(treeItem, String.format("%s (%s)", ADDRESS_BO, Messages.skipped)));

    importBot.setImportAction(HUMAN_PACKAGE, ImportAction.OVERWRITE.toString());
    bot.waitUntil(importBot.treeNodeAvailable(treeItem, String.format(org.bonitasoft.studio.businessobject.i18n.Messages.conflictingWithSameObject, PERSON_BO)));
    bot.waitUntil(importBot.treeNodeNotAvailable(treeItem, String.format("%s (%s)", ADDRESS_BO, Messages.skipped)));

    importBot.doImport();

    BusinessObjectModelFileStore fileStore = (BusinessObjectModelFileStore) repositoryStore.getChild("bom.xml", true);
    assertThat(fileStore.getContent().getBusinessObjects()).extracting(BusinessObject::getQualifiedName)
            .containsExactlyInAnyOrder(toQualifiedName(BUSINESS_PACKAGE, LOAN_BO),
                    toQualifiedName(HUMAN_PACKAGE, PERSON_BO));
}
 
Example 7
Source File: FetchRemoteTracesTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static void openRemoteProfilePreferences() {
    SWTBotShell preferencesShell = SWTBotUtils.openPreferences(fBot);

    // The first tree is the preference "categories" on the left side
    SWTBot bot = preferencesShell.bot();
    SWTBotTree tree = bot.tree(0);
    SWTBotTreeItem treeNode = tree.getTreeItem("Tracing");
    treeNode.select();
    treeNode.expand();
    bot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable("Remote Profiles", treeNode));
    treeNode = treeNode.getNode("Remote Profiles");
    treeNode.select();
}
 
Example 8
Source File: XMLAnalysesManagerPreferencePageTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static SWTBotShell openXMLAnalysesPreferences() {
    SWTBotShell preferencesShell = SWTBotUtils.openPreferences(fBot, MANAGE_XML_ANALYSES_PREF_TITLE);
    SWTBot bot = preferencesShell.bot();
    SWTBotTree tree = bot.tree(0);
    SWTBotTreeItem treeNode = tree.getTreeItem("Tracing");
    treeNode.select();
    treeNode.expand();
    bot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable("XML Analyses", treeNode));
    treeNode = treeNode.getNode("XML Analyses");
    treeNode.select();
    return preferencesShell;
}
 
Example 9
Source File: CounterViewTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Validate the Counters view data model.
 */
@Test
public void testDisplayingDataSeries() {
    // Setup the chart viewer
    IViewPart viewPart = getSWTBotView().getViewReference().getView(true);
    assertTrue(viewPart instanceof CounterView);
    final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart);
    assertNotNull(chartViewer);
    fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
    chartViewer.setNbPoints(NUMBER_OF_POINTS);
    fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));

    final Chart chart = getChart();
    assertNotNull(chart);
    assertEquals(0, chart.getSeriesSet().getSeries().length);

    // Check the counter entry
    SWTBotTree treeBot = getSWTBotView().bot().tree();
    WaitUtils.waitUntil(tree -> tree.rowCount() >= 1, treeBot, "The tree viewer did not finish loading.");
    SWTBotTreeItem root = treeBot.getTreeItem(TRACE_NAME);
    SWTBotTreeItem counter = retrieveTreeItem(root, COUNTER_NAME);
    assertNotNull(counter);
    counter.check();
    fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
    WaitUtils.waitUntil(c -> c.getSeriesSet().getSeries().length >= 1, chart, "The data series did not load.");

    // Ensure the data series has the correct styling
    verifySeriesStyle(MAIN_SERIES_NAME, ISeries.SeriesType.LINE, BLUE, LineStyle.SOLID, false);

    // Ensure the data model is valid
    WaitUtils.waitUntil(json -> isChartDataValid(chart, json, MAIN_SERIES_NAME),
            "resources/minor_faults-res50.json", "The chart data is not valid.");
}
 
Example 10
Source File: TestWizardUI.java    From aCute with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testSelectedFolderPresetDirectory() {
	SWTBotView view = bot.viewByTitle("Project Explorer");
	SWTBotTree tree = new SWTBot(view.getWidget()).tree(0);
	SWTBotTreeItem item = tree.getTreeItem(project.getName());
	item.select();

	openWizard();
	assertEquals("Selected container was not used for pre-set project name",
			project.getName(), bot.textWithLabel("Project name").getText());
	assertEquals("Selected container was not used for pre-set project location",
			project.getLocation().toString(), bot.textWithLabel("Location").getText());
	bot.button("Cancel").click();

}
 
Example 11
Source File: ControlViewProfileTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test load session
 */
private void testLoadSession() {
    SWTBotTreeItem nodeItem = SWTBotUtils.getTreeItem(fBot, fTree, getNodeName());
    SWTBotTreeItem sessionGroupItem = nodeItem.getNode(ControlViewSwtBotUtil.SESSION_GROUP_NAME);

    sessionGroupItem.select();
    SWTBotMenu menuBot = sessionGroupItem.contextMenu(ControlViewSwtBotUtil.LOAD_MENU_ITEM);
    menuBot.click();

    SWTBotShell shell = fBot.shell(ControlViewSwtBotUtil.LOAD_DIALOG_TITLE).activate();

    SWTBotRadio button = shell.bot().radio(ControlViewSwtBotUtil.REMOTE_RADIO_BUTTON_LABEL);
    button.click();

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

    SWTBotTreeItem profileItem = shellTree.getTreeItem(SESSION_NAME + ControlViewSwtBotUtil.PROFILE_SUFFIX);
    profileItem.select();
    profileItem.click();

    shell.bot().button(ControlViewSwtBotUtil.CONFIRM_DIALOG_OK_BUTTON).click();
    WaitUtils.waitForJobs();

    sessionGroupItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(), ControlViewSwtBotUtil.SESSION_GROUP_NAME);

    fBot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable(SESSION_NAME, sessionGroupItem));
    assertEquals(1, sessionGroupItem.getNodes().size());
}
 
Example 12
Source File: TraceTypePreferencePageTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static SWTBotShell openTraceTypePreferences() {
    SWTBotShell preferencesShell = SWTBotUtils.openPreferences(fBot);
    SWTBot bot = preferencesShell.bot();
    SWTBotTree tree = bot.tree(0);
    SWTBotTreeItem treeNode = tree.getTreeItem("Tracing");
    treeNode.select();
    treeNode.expand();
    bot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable("Trace Types", treeNode));
    treeNode = treeNode.getNode("Trace Types");
    treeNode.select();
    return preferencesShell;
}
 
Example 13
Source File: ControlViewExcludeEventsTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test that the Properties view has been update and shows the the right
 * information.
 */
protected void testPropertiesEventExclude() {
    // Open the properties view (by id)
    SWTBotUtils.openView("org.eclipse.ui.views.PropertySheet");

    // Select the event in the Control view
    fBot.viewById(ControlView.ID).show();
    SWTBotTreeItem eventItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName(),
            ControlViewSwtBotUtil.UST_DOMAIN_NAME,
            ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME,
            ControlViewSwtBotUtil.ALL_EVENTS_NAME);
    eventItem.select();

    // Get a bot and open the Properties view
    SWTBotView propertiesViewBot = fBot.viewByTitle(PROPERTIES_VIEW);
    propertiesViewBot.show();

    // Get the Exclude field in the tree
    SWTBotTree propertiesViewTree = propertiesViewBot.bot().tree();
    SWTBotTreeItem excludeTreeItem = propertiesViewTree.getTreeItem(EXCLUDE_TREE_ITEM);
    // We want the VALUE of the 'Exclude' row so the cell index is 1
    String excludeExpression = excludeTreeItem.cell(1);

    // Assert that the expression in the Properties view is the same as
    // the one we entered
    assertEquals(EXCLUDE_EXPRESSION, excludeExpression);

    // Close the Properties view
    SWTBotUtils.closeView(PROPERTIES_VIEW, fBot);
}
 
Example 14
Source File: BotTreeWidget.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
public BotContractInputRow selectActiveRow(final SWTGefBot bot) {
    final SWTBotTree treeWithId = bot.treeWithId(SWTBotConstants.SWTBOT_ID_CONTRACT_INPUT_TREE);
    final TableCollection selection = treeWithId.selection();
    treeWithId.getTreeItem(selection.get(0, 0));
    return new BotContractInputRow(bot, selection.rowCount());
}
 
Example 15
Source File: ControlFlowViewTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test the filter
 */
@Test
public void testFilter() {
    /* change window range to 1 ms */
    TmfTimeRange range = new TmfTimeRange(START_TIME, START_TIME.normalize(1000000L, ITmfTimestamp.NANOSECOND_SCALE));
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, range));
    timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME));

    SWTBotView viewBot = getViewBot();
    SWTBotToolbarButton filterButton = viewBot.toolbarButton("Show View Filters");
    filterButton.click();
    SWTBot bot = fBot.shell("Filter").activate().bot();
    SWTBotTree treeBot = bot.tree();
    // get how many items there are
    int checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals("default", 226, checked);
    // test "uncheck all button"
    bot.button(UNCHECK_ALL).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(0, checked);
    // test check active
    bot.button(CHECK_ACTIVE).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(CHECK_ACTIVE, 69, checked);
    // test check all
    bot.button(CHECK_ALL).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(CHECK_ALL, 226, checked);
    // test uncheck inactive
    bot.button(UNCHECK_INACTIVE).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(UNCHECK_INACTIVE, 69, checked);
    // test check selected
    treeBot.getTreeItem(LttngTraceGenerator.getName()).select("gnuplot");
    bot.button(UNCHECK_ALL).click();
    bot.button(CHECK_SELECTED).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(CHECK_SELECTED, 2, checked);
    // test check subtree
    bot.button(UNCHECK_ALL).click();
    bot.button(CHECK_SUBTREE).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(CHECK_SUBTREE, 2, checked);
    // test uncheck selected
    bot.button(CHECK_ALL).click();
    bot.button(UNCHECK_SELECTED).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(UNCHECK_SELECTED, 225, checked);
    // test uncheck subtree
    bot.button(CHECK_ALL).click();
    bot.button(UNCHECK_SUBTREE).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(UNCHECK_SELECTED, 225, checked);
    // test filter
    bot.button(UNCHECK_ALL).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals(0, checked);
    bot.text().setText("half-life 3");
    SWTBotTreeItem treeItem = treeBot.getTreeItem(LttngTraceGenerator.getName());
    treeItem.rowCount();
    fBot.waitUntil(ConditionHelpers.treeItemCount(treeItem, 25));
    bot.button(CHECK_ALL).click();
    checked = SWTBotUtils.getTreeCheckedItemCount(treeBot);
    assertEquals("Filtered", 26, checked);
    bot.button(DIALOG_OK).click();
    SWTBotTimeGraph timeGraph = new SWTBotTimeGraph(getViewBot().bot());
    SWTBotTimeGraphEntry traceEntry = timeGraph.getEntry(LttngTraceGenerator.getName());
    for (SWTBotTimeGraphEntry entry : traceEntry.getEntries()) {
        assertEquals("Filtered Control flow view", "Half-life 3", entry.getText());
    }
}
 
Example 16
Source File: FilterViewerTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
     * test compare field >= 2
     */
    @Test
    public void testField01() {
        SWTBotView viewBot = fBot.viewById(FilterView.ID);
        viewBot.setFocus();
        SWTBot filterBot = viewBot.bot();
        SWTBotTree treeBot = filterBot.tree();

        viewBot.toolbarButton("Add new filter").click();
        treeBot.getTreeItem("FILTER <name>").select();
        SWTBotText textBot = filterBot.text();
        textBot.setFocus();
        String filterName = "field";
        textBot.setText(filterName);
        SWTBotTreeItem filterNodeBot = treeBot.getTreeItem(FILTER_TEST + filterName);
        filterNodeBot.click();
        filterNodeBot.contextMenu("TRACETYPE").click();
        filterNodeBot.expand();
        SWTBotCCombo comboBot = filterBot.ccomboBox();
        comboBot.setSelection(TRACETYPE);
        filterNodeBot.getNode(WITH_TRACETYPE).expand();

        // --------------------------------------------------------------------
        // add Compare > 1.5
        // --------------------------------------------------------------------

        filterNodeBot.getNode(WITH_TRACETYPE).contextMenu(COMPARE).click();
        SWTBotTreeItem contentNode = filterNodeBot.getNode(WITH_TRACETYPE).getNode("<select aspect> " + "=" + " <value>");
        contentNode.expand();
        comboBot = filterBot.ccomboBox(1); // aspect
        comboBot.setSelection(CONTENTS);
        textBot = filterBot.text(0); // field
        textBot.setFocus();
        textBot.setText(filterName);

        textBot = filterBot.text(1); // value
        textBot.setFocus();
        textBot.setText("1.5");
        filterBot.radio(">").click();

        // --------------------------------------------------------------------
        // apply
        // --------------------------------------------------------------------
        viewBot.toolbarButton("Save filters").click();

        String ret = applyFilter(fBot, filterName);
//        filterNodeBot.contextMenu().menu("Delete").click();
        assertEquals("50/100", ret);
    }
 
Example 17
Source File: FilterViewerTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Return all timestamps ending with 100... for reasons
 */
@Test
public void testTimestampFilter() {
    SWTBotView viewBot = fBot.viewById(FilterView.ID);
    viewBot.setFocus();
    SWTBot filterBot = viewBot.bot();
    SWTBotTree treeBot = filterBot.tree();

    viewBot.toolbarButton("Add new filter").click();
    treeBot.getTreeItem("FILTER <name>").select();
    SWTBotText textBot = filterBot.text();
    textBot.setFocus();
    String filterName = "timestamp";
    textBot.setText(filterName);
    SWTBotTreeItem filterNodeBot = treeBot.getTreeItem(FILTER_TEST + filterName);
    filterNodeBot.click();
    filterNodeBot.contextMenu("TRACETYPE").click();
    filterNodeBot.expand();
    SWTBotCCombo comboBot = filterBot.ccomboBox();
    comboBot.setSelection(TRACETYPE);
    filterNodeBot.getNode(WITH_TRACETYPE).expand();

    // --------------------------------------------------------------------
    // add AND
    // --------------------------------------------------------------------

    filterNodeBot.getNode(WITH_TRACETYPE).contextMenu(AND).click();

    // --------------------------------------------------------------------
    // add CONTAINS "100"
    // --------------------------------------------------------------------

    filterNodeBot.getNode(WITH_TRACETYPE).getNode(AND).contextMenu(CONTAINS).click();
    filterNodeBot.getNode(WITH_TRACETYPE).getNode(AND).expand();
    comboBot = filterBot.ccomboBox(1); // aspect
    comboBot.setSelection(TIMESTAMP);
    textBot = filterBot.text();
    textBot.setFocus();
    textBot.setText("100");
    filterNodeBot.getNode(WITH_TRACETYPE).getNode(AND).getNode("Timestamp CONTAINS \"100\"").select();
    filterNodeBot.getNode(WITH_TRACETYPE).getNode(AND).select();

    viewBot.toolbarButton("Save filters").click();

    String ret = applyFilter(fBot, filterName);
    assertEquals("10/100", ret);
}
 
Example 18
Source File: ControlViewLoggerTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test that the Properties view has been update and shows the the right
 * information.
 *
 * @param domain
 *            the logger domain to test
 */
protected void testLoggerProperties(TraceDomainType domain) {
    String domainName = new String();
    String logLevel = new String();
    switch (domain) {
    case JUL:
        domainName = ControlViewSwtBotUtil.JUL_DOMAIN_NAME;
        logLevel = "<= Warning";
        break;
    case LOG4J:
        domainName = ControlViewSwtBotUtil.LOG4J_DOMAIN_NAME;
        logLevel = "<= Fatal";
        break;
    case PYTHON:
        domainName = ControlViewSwtBotUtil.PYTHON_DOMAIN_NAME;
        logLevel = "<= Critical";
        break;
        //$CASES-OMITTED$
    default:
        break;
    }

    // Open the properties view (by id)
    SWTBotUtils.openView("org.eclipse.ui.views.PropertySheet");

    // Case 1: Select the "logger" logger in the Control view
    fBot.viewById(ControlView.ID).show();
    SWTBotTreeItem loggerItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName(),
            domainName,
            ControlViewSwtBotUtil.LOGGER_NAME);
    loggerItem.select();

    // Get a bot and open the Properties view
    SWTBotView propertiesViewBot = fBot.viewByTitle(PROPERTIES_VIEW);
    propertiesViewBot.show();

    // Get the Log Level field in the tree
    SWTBotTree propertiesViewTree = propertiesViewBot.bot().tree();
    SWTBotTreeItem loglevelTreeItem = propertiesViewTree.getTreeItem(LOGLEVEL_PROPERTY_NAME);
    // We want the VALUE of the 'Log Level' row so the cell index is 1
    String loglevelExpression = loglevelTreeItem.cell(1);

    // Assert that the expression in the Properties view is the same as
    // the one we entered
    assertEquals("All", loglevelExpression);

    // Case 2: Select the "anotherLogger" logger in the Control view
    fBot.viewById(ControlView.ID).show();
    loggerItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName(),
            domainName,
            ControlViewSwtBotUtil.ANOTHER_LOGGER_NAME);
    loggerItem.select();

    // Get a bot and open the Properties view
    propertiesViewBot = fBot.viewByTitle(PROPERTIES_VIEW);
    propertiesViewBot.show();

    // Get the Log Level field in the tree
    propertiesViewTree = propertiesViewBot.bot().tree();
    loglevelTreeItem = propertiesViewTree.getTreeItem(LOGLEVEL_PROPERTY_NAME);
    // We want the VALUE of the 'Log Level' row so the cell index is 1
    loglevelExpression = loglevelTreeItem.cell(1);

    // Assert that the expression in the Properties view is the same as
    // the one we entered
    assertEquals(logLevel, loglevelExpression);

    // Close the Properties view
    SWTBotUtils.closeView(PROPERTIES_VIEW, fBot);
}
 
Example 19
Source File: KernelMemoryUsageViewTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Simple test to check the Kernel Memory Usage view data model
 */
@Test
public void testKernelMemoryView() {
    IViewPart viewPart = getSWTBotView().getViewReference().getView(true);
    assertTrue(viewPart instanceof KernelMemoryUsageView);
    final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart);
    assertNotNull(chartViewer);
    fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));

    final Chart chart = getChart();
    assertNotNull(chart);
    chartViewer.setNbPoints(NUMBER_OF_POINT);

    SWTBotTree treeBot = getSWTBotView().bot().tree();
    SWTBotTreeItem totalNode = treeBot.getTreeItem(fTraceName);
    SWTBotUtils.waitUntil(root -> root.getItems().length >= 5, totalNode, "Did not finish loading");

    /*
     * Select the total entry, which should be the first entry with an empty pid
     * column.
     */
    SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length >= 1, chart, "No data available");

    /* Test type, style and color of series */
    verifySeriesStyle(TOTAL_PID, ISeries.SeriesType.LINE, BLUE, LineStyle.SOLID, false);

    /* Test data model*/
    SWTBotUtils.waitUntil(json -> isChartDataValid(chart, json), "resources/kernelmemory/kernel-memory-res50.json", "Chart data is not valid");

    /*
     * Select a thread
     */
    SWTBotTreeItem sessiondEntry = totalNode.getNode("lttng-sessiond");
    sessiondEntry.check();
    SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length >= 2, chart, "Only total available");

    /* Test type, style and color of series */
    verifySeriesStyle(SESSIOND_PID, ISeries.SeriesType.LINE, RED, LineStyle.SOLID, false);

    SWTBotUtils.waitUntil(json -> isChartDataValid(chart, json, SESSIOND_PID), "resources/kernelmemory/kernel-memory-res50Selected.json", "Chart data is not valid");

    /*
     * Select an another thread and change zoom
     */
    SWTBotTreeItem consumerdEntry = totalNode.getNode("lttng-consumerd");
    consumerdEntry.check();
    chartViewer.setNbPoints(MORE_POINTS);
    SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length >= 3, chart, "Only total and sessiond available");

    /* Test type, style and color of series */
    verifySeriesStyle(CONSUMERD_PID, ISeries.SeriesType.LINE, GREEN, LineStyle.SOLID, false);

    SWTBotUtils.waitUntil(json -> isChartDataValid(chart, json, CONSUMERD_PID), "resources/kernelmemory/kernel-memory-res100Selected.json", "Chart data is not valid");
}
 
Example 20
Source File: BarExporterTest.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void testServerBuild() {

    SWTBotTestUtil.createNewDiagram(bot);
    final SWTBotEditor activeEditor = bot.activeEditor();
    final String editorTitle = activeEditor.getTitle();
    assertFalse("Error: first diagram name is empty.", editorTitle.isEmpty());

    final BotExecutionDiagramPropertiesView executionTab = new BotProcessDiagramPropertiesViewFolder(bot)
            .selectExecutionTab();
    executionTab.selectInstantiationFormTab().selectNone();
    new BotGefProcessDiagramEditor(bot).selectElement("Step1");
    executionTab.selectFormTab().selectNone();

    // get the GEF editor to activate tools
    final SWTBotGefEditor gmfEditor = bot.gefEditor(editorTitle);

    // Create 2 Pools
    gmfEditor.activateTool("Pool");
    gmfEditor.click(200, 500);

    new BotProcessDiagramPropertiesViewFolder(bot).selectExecutionTab().selectInstantiationFormTab().selectNone();

    gmfEditor.activateTool("Pool");
    gmfEditor.click(200, 800);

    new BotProcessDiagramPropertiesViewFolder(bot).selectExecutionTab().selectInstantiationFormTab().selectNone();

    // Save Diagram
    bot.menu("File").menu("Save").click();
    bot.waitUntil(BonitaBPMConditions.noPopupActive());

    // Menu Server > Build...
    bot.menu("Server").menu("Build...").click();

    // shell 'Build'
    final SWTBotShell shell = bot.shell(Messages.buildTitle);
    bot.waitUntil(Conditions.shellIsActive(Messages.buildTitle));

    // select and check created Diagram in the Tree
    final SWTBotTree tree = bot.treeWithLabel("Select processes to export");
    final SWTBotTreeItem diagramTreeItem = tree.getTreeItem(editorTitle);

    // check the diagram to export
    diagramTreeItem.select().check();
    diagramTreeItem.expand();

    // Number of pool in the diagram
    final int poolListSize = diagramTreeItem.getItems().length;
    assertEquals("Error: Diagram must contain 3 Pools.", 3, poolListSize);

    // unselect the first pool of the list

    diagramTreeItem.getNode(0).select();
    diagramTreeItem.getNode(0).uncheck();

    final List<String> poolTitleList = new ArrayList<>(3);
    final int poolTitleListSize = poolTitleList.size();

    // check the selected pools
    for (int i = 1; i < poolTitleListSize; i++) {
        final SWTBotTreeItem poolTreeItem = diagramTreeItem.getNode(i);
        poolTitleList.set(i, poolTreeItem.getText());
        final String poolName = getItemName(poolTitleList.get(i));

        // test the good pool is checked
        assertFalse("Error: Pool " + i + " should be checked.", !poolTreeItem.isChecked());
        assertFalse("Error: Pool selected is not the good one.", !poolName.equals("Pool" + i));
    }
    // create tmp directory to write diagrams
    final File tmpBarFolder = new File(ProjectUtil.getBonitaStudioWorkFolder(), "testExportBar");
    tmpBarFolder.deleteOnExit();
    tmpBarFolder.mkdirs();
    //set the path where files are saved
    final String tmpBarFolderPath = tmpBarFolder.getAbsolutePath();
    bot.comboBoxWithLabel(Messages.destinationPath + " *").setText(tmpBarFolderPath);

    // click 'Finish' button to close 'Build' shell
    bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.FINISH_LABEL)));
    bot.button(IDialogConstants.FINISH_LABEL).click();

    //  click 'OK' button to close 'Export' shell
    bot.waitUntil(new ShellIsActiveWithThreadSTacksOnFailure(Messages.exportSuccessTitle), 10000);
    bot.button(IDialogConstants.OK_LABEL).click();

    // wait the shell to close before checking creation of files
    bot.waitUntil(Conditions.shellCloses(shell));

    // check pools files exist
    for (int i = 1; i < poolTitleListSize; i++) {
        final String tmpPoolTitle = poolTitleList.get(i);
        final String poolFileName = getItemName(tmpPoolTitle) + "--" + getItemVersion(tmpPoolTitle) + ".bar";
        final File poolFile = new File(tmpBarFolderPath, poolFileName);
        poolFile.deleteOnExit();
        assertTrue("Error: The Pool export must exist", poolFile.exists());
        assertTrue("Error: The Pool export must be a file", poolFile.isFile());
    }
}