Search in sources :

Example 1 with SWTBotRootMenu

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotRootMenu in project tracecompass by tracecompass.

the class AddProjectNatureTest method toggleFilters.

private static void toggleFilters(boolean checked) {
    SWTBotView viewBot = fBot.viewByTitle(PROJECT_EXPLORER_TITLE);
    viewBot.setFocus();
    SWTBotRootMenu viewMenu = viewBot.viewMenu();
    String title = CUSTOMIZE_VIEW_DIALOG_TITLE_4_7;
    try {
        viewMenu.menu(CUSTOMIZE_VIEW_MENU_ITEM_4_7).click();
    } catch (WidgetNotFoundException e) {
        viewMenu.menu(CUSTOMIZE_VIEW_MENU_ITEM_4_6).click();
        title = CUSTOMIZE_VIEW_DIALOG_TITLE_4_6;
    }
    SWTBotShell shell = fBot.shell(title).activate();
    // Select first cTabItem which has name 'Filters' in 4.10 or older, and 'Pre-set filters' starting with 4.11
    shell.bot().cTabItem(0).activate();
    SWTBotTable table = shell.bot().table();
    SWTBotTableItem item = table.getTableItem(CUSTOMIZE_VIEW_RESOURCES_FILTER);
    item.select();
    if (checked != item.isChecked()) {
        item.toggleCheck();
    }
    item = table.getTableItem(CUSTOMIZE_VIEW_SHADOW_FILTER);
    item.select();
    if (checked != item.isChecked()) {
        item.toggleCheck();
    }
    shell.bot().button(OK_BUTTON).click();
}
Also used : WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) SWTBotRootMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotRootMenu) SWTBotTable(org.eclipse.swtbot.swt.finder.widgets.SWTBotTable) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) SWTBotTableItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTableItem)

Example 2 with SWTBotRootMenu

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotRootMenu in project tracecompass by tracecompass.

the class MarkerSetSwtBotTest method testMenuNoMarkerSet.

/**
 * Test the marker set menu items when there is no marker set
 */
@Test
public void testMenuNoMarkerSet() {
    SWTBotRootMenu viewMenu = fViewBot.viewMenu();
    List<String> menuItems = viewMenu.menu("Marker Set").menuItems();
    assertArrayEquals("menu items, no marker set", MENU_ITEMS_NO_MARKERS_SET, menuItems.toArray());
}
Also used : SWTBotRootMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotRootMenu) Test(org.junit.Test)

Example 3 with SWTBotRootMenu

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotRootMenu in project tracecompass by tracecompass.

the class MarkerSetSwtBotTest method testEditMarkerSet.

/**
 * Test the marker set menu Edit... item
 */
@Test
public void testEditMarkerSet() {
    insertContent();
    SWTBotRootMenu viewMenu = fViewBot.viewMenu();
    List<String> menuItems = viewMenu.menu("Marker Set").menuItems();
    assertArrayEquals("menu items, two marker sets", MENU_ITEMS_2_MARKERS_SET, menuItems.toArray());
    assertTrue("None is checked", viewMenu.menu("Marker Set").menu(MENU_ITEMS_2_MARKERS_SET[0]).isChecked());
    // Select Set A
    viewMenu.menu("Marker Set", MENU_ITEMS_2_MARKERS_SET[1]).click();
    assertTrue("Set A is checked", viewMenu.menu("Marker Set").menu(MENU_ITEMS_2_MARKERS_SET[1]).isChecked());
    // Select Set B
    viewMenu.menu("Marker Set", MENU_ITEMS_2_MARKERS_SET[2]).click();
    assertTrue("set B is checked", viewMenu.menu("Marker Set").menu(MENU_ITEMS_2_MARKERS_SET[2]).isChecked());
    // Select None
    viewMenu.menu("Marker Set", MENU_ITEMS_2_MARKERS_SET[0]).click();
    assertTrue("None is checked", viewMenu.menu("Marker Set").menu(MENU_ITEMS_2_MARKERS_SET[0]).isChecked());
    // Remove all markers set
    removeContent();
    menuItems = viewMenu.menu("Marker Set").menuItems();
    assertArrayEquals("menu items, no marker set", MENU_ITEMS_NO_MARKERS_SET, menuItems.toArray());
}
Also used : SWTBotRootMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotRootMenu) Test(org.junit.Test)

Example 4 with SWTBotRootMenu

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotRootMenu in project tracecompass by tracecompass.

the class ChartMakerDialogTest method openDialog.

private void openDialog() {
    // Open the new custom chart dialog
    SWTBotView viewBot = fBot.viewById(CustomChartStubView.ID);
    SWTBotRootMenu viewMenu = viewBot.viewMenu();
    SWTBotMenu menu = viewMenu.menu(CustomChartStubView.MENU_TITLE);
    menu.click();
}
Also used : SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu) SWTBotRootMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotRootMenu) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)

Example 5 with SWTBotRootMenu

use of org.eclipse.swtbot.swt.finder.widgets.SWTBotRootMenu in project aero.minova.rcp by minova-afis.

the class MenuTest method openPreferencesAndTestMenu.

@Test
public void openPreferencesAndTestMenu() {
    if (System.getProperty("os.name").startsWith("Linux")) {
        return;
    }
    // Einstellungen über Command öffnen
    Display.getDefault().asyncExec(() -> {
        ECommandService commandService = getEclipseContext().get(ECommandService.class);
        EHandlerService handlerService = getEclipseContext().get(EHandlerService.class);
        ParameterizedCommand cmd = commandService.createCommand("org.eclipse.ui.window.preferences", null);
        handlerService.executeHandler(cmd);
    });
    // Workspace-Ordner auslesen
    SWTBotShell shell = bot.shell("Preferences");
    assertNotNull(shell);
    SWTBot childBot = new SWTBot(shell.widget);
    SWTBotText currentWorkspaceText = childBot.text(1);
    assertNotNull(currentWorkspaceText);
    assertNotNull(currentWorkspaceText.getText());
    String pathWorkspace = currentWorkspaceText.getText();
    shell.close();
    // application.mdi einlesen und Menü überprüfen
    try {
        Path path = Path.of(pathWorkspace, "application.mdi");
        String applicationString = Files.readString(path);
        assertNotNull(applicationString);
        Main mainMDI = XmlProcessor.get(applicationString, Main.class);
        assertNotNull(mainMDI);
        // Liste mit Menueinträgen (depth-first)
        List<String> menuEntries = new ArrayList<>();
        Map<String, Integer> callsToMenu = new HashMap<>();
        SWTBotRootMenu menu = bot.menu();
        for (String menuEntry : menu.menuItems()) {
            int i = callsToMenu.get(menuEntry) == null ? 0 : callsToMenu.get(menuEntry);
            callsToMenu.put(menuEntry, i + 1);
            SWTBotMenu menu2 = bot.menu().menu(menuEntry, false, i);
            // File Menü überspringen (nicht von uns)
            if (menu2.getText().equals("File")) {
                continue;
            }
            getMenuEntries(menuEntries, menu2);
        }
        // TODO Reihenfolge in der mdi beachten (siehe MenuProcessor)
        int counter = 0;
        for (Object menuOrEntry : mainMDI.getMenu().getMenuOrEntry()) {
            counter = checkEntries(menuEntries, counter, menuOrEntry);
        }
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
Also used : Path(java.nio.file.Path) EHandlerService(org.eclipse.e4.core.commands.EHandlerService) SWTBot(org.eclipse.swtbot.swt.finder.SWTBot) HashMap(java.util.HashMap) SWTBotText(org.eclipse.swtbot.swt.finder.widgets.SWTBotText) ArrayList(java.util.ArrayList) SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu) SWTBotRootMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotRootMenu) SWTBotShell(org.eclipse.swtbot.swt.finder.widgets.SWTBotShell) ParameterizedCommand(org.eclipse.core.commands.ParameterizedCommand) Main(aero.minova.rcp.form.menu.mdi.Main) ECommandService(org.eclipse.e4.core.commands.ECommandService) Test(org.junit.jupiter.api.Test)

Aggregations

SWTBotRootMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotRootMenu)12 Test (org.junit.Test)6 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)5 SWTBotMenu (org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu)5 Event (org.eclipse.swt.widgets.Event)3 Nullable (org.eclipse.jdt.annotation.Nullable)2 SWTBotEclipseEditor (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor)2 SWTBot (org.eclipse.swtbot.swt.finder.SWTBot)2 SWTBotShell (org.eclipse.swtbot.swt.finder.widgets.SWTBotShell)2 Chart (org.eclipse.swtchart.Chart)2 Main (aero.minova.rcp.form.menu.mdi.Main)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 ParameterizedCommand (org.eclipse.core.commands.ParameterizedCommand)1 ECommandService (org.eclipse.e4.core.commands.ECommandService)1 EHandlerService (org.eclipse.e4.core.commands.EHandlerService)1 Rectangle (org.eclipse.swt.graphics.Rectangle)1 Menu (org.eclipse.swt.widgets.Menu)1 SWTWorkbenchBot (org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot)1