Java Code Examples for org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu#click()

The following examples show how to use org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu#click() . 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: ControlViewTest.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Test destroy session
 */
protected void testDestroySession() {
    SWTBotTreeItem sessionItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName());

    sessionItem.select();
    SWTBotMenu menuBot = sessionItem.contextMenu(ControlViewSwtBotUtil.DESTROY_MENU_ITEM);
    menuBot.click();

    SWTBotShell shell = fBot.shell(ControlViewSwtBotUtil.DESTROY_CONFIRM_DIALOG_TITLE).activate();
    shell.bot().button(ControlViewSwtBotUtil.CONFIRM_DIALOG_OK_BUTTON).click();
    WaitUtils.waitForJobs();

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

    fBot.waitUntil(ConditionHelpers.isTreeChildNodeRemoved(0, sessionGroupItem));
    assertEquals(0, sessionGroupItem.getNodes().size());
}
 
Example 2
Source File: XsemanticsSwtbotTestBase.java    From xsemantics with Eclipse Public License 1.0 6 votes vote down vote up
protected void createProjectAndAssertNoErrorMarker(String projectType) throws CoreException {
	SWTBotMenu fileMenu = bot.menu("File");
	SWTBotMenu newMenu = fileMenu.menu("New");
	SWTBotMenu projectMenu = newMenu.menu("Project...");
	projectMenu.click();

	SWTBotShell shell = bot.shell("New Project");
	shell.activate();
	SWTBotTreeItem xsemanticsNode = bot.tree().expandNode("Xsemantics");
	waitForTreeItems(xsemanticsNode);
	xsemanticsNode.expandNode(projectType).select();
	bot.button("Next >").click();

	bot.textWithLabel("Project name:").setText(TEST_PROJECT);

	bot.button("Finish").click();

	// creation of a project might require some time
	bot.waitUntil(shellCloses(shell), SHELL_TIMEOUT);
	assertTrue("Project doesn't exist", isProjectCreated(TEST_PROJECT));

	waitForBuild();
	assertNoErrorsInProject();
}
 
Example 3
Source File: ControlViewAllEventsTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected void testEnableKernelEvent() {
    SWTBotTreeItem sessionItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName());

    sessionItem.select();
    SWTBotMenu menuBot = sessionItem.contextMenu(ControlViewSwtBotUtil.ENABLE_EVENT_DEFAULT_CHANNEL_MENU_ITEM);
    menuBot.click();

    SWTBotShell shell = fBot.shell(ControlViewSwtBotUtil.ENABLE_EVENT_DIALOG_TITLE).activate();
    // all tracepoint events and syscalls
    shell.bot().radioInGroup(ControlViewSwtBotUtil.GROUP_SELECT_NAME, ControlViewSwtBotUtil.ALL_EVENT_GROUP_NAME).click();
    shell.bot().button(ControlViewSwtBotUtil.DIALOG_OK_BUTTON).click();
    WaitUtils.waitForJobs();

    fBot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable(ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, sessionItem));

    SWTBotTreeItem channelItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName(),
            ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME,
            ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME);
    assertEquals(ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME, channelItem.getText());

    SWTBotTreeItem eventItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName(),
            ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME,
            ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME,
            ControlViewSwtBotUtil.ALL_EVENTS_NAME);
    assertEquals(ControlViewSwtBotUtil.ALL_EVENTS_NAME, eventItem.getText());
}
 
Example 4
Source File: ControlViewTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test connect to node
 */
protected void testConnectToNode() {
    SWTBotTreeItem nodeItem = SWTBotUtils.getTreeItem(fBot, fTree, getNodeName());
    nodeItem.select();
    SWTBotMenu menuBot = nodeItem.contextMenu(ControlViewSwtBotUtil.CONNECT_MENU_ITEM);
    menuBot.click();

    fBot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable(ControlViewSwtBotUtil.SESSION_GROUP_NAME, nodeItem));

    // Verify that node is connected
    fBot.waitUntil(ControlViewSwtBotUtil.isStateChanged(fNode, TargetNodeState.CONNECTED));
    // Wait for node configuration jobs
    WaitUtils.waitForJobs();
    assertEquals(TargetNodeState.CONNECTED, fNode.getTargetNodeState());
}
 
Example 5
Source File: SegmentTableTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test creating a tsv
 *
 * @throws NoSuchMethodException
 *             Error creating the tsv
 * @throws IOException
 *             no such file or the file is locked.
 */
@Test
public void testWriteToTsv() throws NoSuchMethodException, IOException {

    ISegmentStore<@NonNull ISegment> fixture = SegmentStoreFactory.createSegmentStore();
    for (int i = 1; i <= 20; i++) {
        int start = i;
        final int delta = i;
        int end = start + delta * delta;
        fixture.add(createSegment(start, end));
    }
    assertNotNull(getTable());
    getTable().updateModel(fixture);
    SWTBotTable tableBot = new SWTBotTable(getTable().getTableViewer().getTable());
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "1", 0, 2));
    SWTWorkbenchBot swtWorkbenchBot = new SWTWorkbenchBot();
    SWTBotView viewBot = swtWorkbenchBot.viewById(getTableView().getSite().getId());
    String[] lines = extractTsv(viewBot);
    testTsv(lines);
    List<String> actionResult = Arrays.asList(lines);
    String absolutePath = TmfTraceManager.getTemporaryDirPath() + File.separator + "syscallLatencyTest.testWriteToTsv.tsv";
    TmfFileDialogFactory.setOverrideFiles(absolutePath);
    SWTBotMenu menuBot = viewBot.viewMenu().menu("Export to TSV...");
    try {
        assertTrue(menuBot.isEnabled());
        assertTrue(menuBot.isVisible());
        menuBot.click();

        try (BufferedReader br = new BufferedReader(new FileReader(absolutePath))) {
            List<String> actual = br.lines().collect(Collectors.toList());
            assertEquals("Both reads", actionResult, actual);
        }
    } finally {
        new File(absolutePath).delete();
    }

}
 
Example 6
Source File: ProjectTreeItem.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 转换当前项目中的一个源文件为 XLIFF
 * @param srcFileName
 *            要转换的源文件名称
 */
public void ctxMenuConvertFile(String srcFileName) {
	selectFile("Source", srcFileName);
	SWTBotMenu convertFiles = ptv.ctxMenuConvertSrcFile2Xliff();
	convertFiles.isEnabled();
	convertFiles.click();
	// TODO:确认转换对话框正确打开
}
 
Example 7
Source File: ProjectTreeItem.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 合并打开当前项目中的所有 XLIFF
 */
public void ctxMenuOpenProjectFiles() {
	ptn.select();
	SWTBotMenu openProjectFiles = ptv.ctxMenuOpenProjectFiles();
	openProjectFiles.isEnabled(); // 确认右键菜单中的打开项目功能可用
	openProjectFiles.click(); // 点击该菜单项
	// 确认文件被成功打开
	SWTBotEditor editor = HSBot.bot().editorByTitle(prjName);
	HSBot.bot().waitUntil(new IsEditorOpened(editor));
}
 
Example 8
Source File: TraceTypePreferencePageTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static String[] getTraceTypeComboItems() {
    SWTBotTreeItem tracesFolder = SWTBotUtils.selectTracesFolder(fBot, TRACE_PROJECT_NAME);
    SWTBotMenu menu = tracesFolder.contextMenu().menu("Import...");
    menu.click();
    SWTBot bot = fBot.shell("Trace Import").activate().bot();
    SWTBotCombo combo = bot.comboBox(2);
    String[] items = combo.items();
    bot.button("Cancel").click();
    return items;
}
 
Example 9
Source File: SWTBotUtils.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Deletes a project
 *
 * @param projectName
 *            the name of the tracing project
 * @param deleteResources
 *            whether or not to deleted resources under the project
 * @param bot
 *            the workbench bot
 */
public static void deleteProject(final String projectName, boolean deleteResources, SWTWorkbenchBot bot) {
    // Wait for any analysis to complete because it might create
    // supplementary files
    WaitUtils.waitForJobs();
    try {
        ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).refreshLocal(IResource.DEPTH_INFINITE, null);
    } catch (CoreException e) {
    }

    WaitUtils.waitForJobs();

    closeSecondaryShells(bot);
    WaitUtils.waitForJobs();

    if (!ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).exists()) {
        return;
    }

    focusMainWindow(bot.shells());

    final SWTBotView projectViewBot = bot.viewById(IPageLayout.ID_PROJECT_EXPLORER);
    projectViewBot.setFocus();

    SWTBotTree treeBot = projectViewBot.bot().tree();
    SWTBotTreeItem treeItem = treeBot.getTreeItem(projectName);
    SWTBotMenu contextMenu = treeItem.contextMenu("Delete");
    contextMenu.click();

    handleDeleteDialog(deleteResources, bot);
    WaitUtils.waitForJobs();
}
 
Example 10
Source File: ControlViewTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test disconnect from node
 */
protected void testDisconnectFromNode() {
    SWTBotTreeItem nodeItem = SWTBotUtils.getTreeItem(fBot, fTree, getNodeName());
    nodeItem.select();
    SWTBotMenu menuBot = nodeItem.contextMenu(ControlViewSwtBotUtil.DISCONNECT_MENU_ITEM);
    menuBot.click();
    WaitUtils.waitForJobs();

    // Verify that node is connected
    fBot.waitUntil(ControlViewSwtBotUtil.isStateChanged(fNode, TargetNodeState.DISCONNECTED));
    assertEquals(TargetNodeState.DISCONNECTED, fNode.getTargetNodeState());
    assertEquals(0, nodeItem.getNodes().size());
}
 
Example 11
Source File: RenameSpecHandlerTest.java    From tlaplus with MIT License 5 votes vote down vote up
private void openSpecExplorer() {
	SWTBotMenu windowMenu = bot.menu("Window");
	SWTBotMenu specExplorerMenu = windowMenu.menu(SPEC_EXPLORER);
	specExplorerMenu.click();
	
	// spec context menu
	SWTBotView packageExplorerView = bot.viewByTitle(SPEC_EXPLORER);
	packageExplorerView.setFocus();
}
 
Example 12
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 13
Source File: ProjectTreeItem.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 转换当前项目中的一个源文件为 XLIFF
 * @param srcFileName
 *            要转换的源文件名称
 */
public void ctxMenuConvertFile(String srcFileName) {
	selectFile("Source", srcFileName);
	SWTBotMenu convertFiles = ptv.ctxMenuConvertSrcFile2Xliff();
	convertFiles.isEnabled();
	convertFiles.click();
	// TODO:确认转换对话框正确打开
}
 
Example 14
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 15
Source File: ControlViewTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test create session
 */
protected void testCreateSession() {
    SWTBotTreeItem nodeItem = SWTBotUtils.getTreeItem(fBot, fTree, getNodeName());

    SWTBotTreeItem sessionGroupItem = nodeItem.getNode(ControlViewSwtBotUtil.SESSION_GROUP_NAME);

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

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

    SWTBotText sessionText = shell.bot().textWithLabel(ControlViewSwtBotUtil.SESSION_NAME_LABEL);
    sessionText.setText(SESSION_NAME);

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

    sessionGroupItem.expand();

    fBot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable(getSessionName(), sessionGroupItem));
    assertEquals(1, sessionGroupItem.getNodes().size());

    SWTBotTreeItem sessionItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName());
    assertEquals(getSessionName(), sessionItem.getText());
}
 
Example 16
Source File: ControlViewKernelFilterTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
private void testEnableKernelFromProviderEvent() {
    SWTBotTreeItem kernelProviderEventItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.PROVIDER_GROUP_NAME,
            ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME,
            ControlViewSwtBotUtil.SCHED_SWITCH_EVENT_NAME);

    kernelProviderEventItem.select();
    SWTBotMenu menuBot = kernelProviderEventItem.contextMenu(ControlViewSwtBotUtil.ENABLE_EVENT_MENU_ITEM);
    menuBot.click();

    SWTBotShell shell = fBot.shell(ControlViewSwtBotUtil.ENABLE_EVENT_DIALOG_TITLE).activate();
    SWTBotCCombo sessionCombo = shell.bot().ccomboBoxInGroup(ControlViewSwtBotUtil.SESSION_LIST_GROUP_NAME);
    sessionCombo.setSelection(getSessionName());
    SWTBotText filterText = shell.bot().textInGroup(ControlViewSwtBotUtil.FILTER_EXPRESSION_LABEL);
    filterText.setText(FILTER_EXPRESSION);
    shell.bot().button(ControlViewSwtBotUtil.DIALOG_OK_BUTTON).click();
    WaitUtils.waitForJobs();

    SWTBotTreeItem sessionItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName());

    fBot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable(ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, sessionItem));

    SWTBotTreeItem kernelDomainItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName(),
            ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME);
    assertEquals(ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME, kernelDomainItem.getText());

    SWTBotTreeItem channelItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName(),
            ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME,
            ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME);
    assertEquals(ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME, channelItem.getText());

    SWTBotTreeItem eventItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName(),
            ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME,
            ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME,
            ControlViewSwtBotUtil.SCHED_SWITCH_EVENT_NAME);
    assertEquals(ControlViewSwtBotUtil.SCHED_SWITCH_EVENT_NAME, eventItem.getText());

    ITraceControlComponent comp = ControlViewSwtBotUtil.getComponent(fNode,
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName(),
            ControlViewSwtBotUtil.KERNEL_DOMAIN_NAME,
            ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME,
            ControlViewSwtBotUtil.SCHED_SWITCH_EVENT_NAME);
    assertNotNull(comp);
    assertTrue(comp instanceof TraceEventComponent);
    TraceEventComponent event = (TraceEventComponent) comp;
    assertEquals(FILTER_EXPRESSION_DISPLAY, event.getFilterExpression());
}
 
Example 17
Source File: ControlViewExcludeEventsTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Enable all UST events with one excluded event.
 */
protected void testEnableUstEventExclude() {
    // Getting the 'Sessions' tree
    SWTBotTreeItem sessionItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName());
    sessionItem.select();

    // Clicking on the 'Enable Event (default channel)...'
    SWTBotMenu menuBot = sessionItem.contextMenu(ControlViewSwtBotUtil.ENABLE_EVENT_DEFAULT_CHANNEL_MENU_ITEM);
    menuBot.click();

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

    // Switching to the UST domain
    shell.bot().radioInGroup(ControlViewSwtBotUtil.UST_GROUP_NAME, ControlViewSwtBotUtil.DOMAIN_GROUP_NAME).click();

    // Selecting all UST events
    SWTBotTree tracepointsTree = shell.bot().treeInGroup(ControlViewSwtBotUtil.TRACEPOINTS_GROUP_NAME);
    SWTBotTreeItem treeItem = tracepointsTree.getTreeItem(ControlViewSwtBotUtil.ALL_TREE_NODE);
    treeItem.check();

    // Click the checkbox for the Exclude event
    shell.bot().checkBoxInGroup(ControlViewSwtBotUtil.GROUP_SELECT_NAME, ControlViewSwtBotUtil.EXCLUDE_EVENT_LABEL).click();

    // Enter the event to exclude in the text field
    SWTBotText excludeText = shell.bot().textInGroup(ControlViewSwtBotUtil.EXCLUDE_EVENT_LABEL);
    excludeText.setText(EXCLUDE_EXPRESSION);

    // Click the Ok at the bottom of the dialog window
    shell.bot().button(ControlViewSwtBotUtil.DIALOG_OK_BUTTON).click();
    WaitUtils.waitForJobs();

    fBot.waitUntil(ConditionHelpers.isTreeChildNodeAvailable(ControlViewSwtBotUtil.UST_DOMAIN_NAME, sessionItem));

    // Assert that the domain is UST global
    SWTBotTreeItem ustGlobalDomainItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName(),
            ControlViewSwtBotUtil.UST_DOMAIN_NAME);
    assertEquals(ControlViewSwtBotUtil.UST_DOMAIN_NAME, ustGlobalDomainItem.getText());

    // Assert that the new channel name is channel0 (which is the default name)
    SWTBotTreeItem channelItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName(),
            ControlViewSwtBotUtil.UST_DOMAIN_NAME,
            ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME);
    assertEquals(ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME, channelItem.getText());

    // Assert that the event type in the channel node are correct (all events = *)
    SWTBotTreeItem eventItem = SWTBotUtils.getTreeItem(fBot, fTree,
            getNodeName(),
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName(),
            ControlViewSwtBotUtil.UST_DOMAIN_NAME,
            ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME,
            ControlViewSwtBotUtil.ALL_EVENTS_NAME);
    assertEquals(ControlViewSwtBotUtil.ALL_EVENTS_NAME, eventItem.getText());

    // Assert that the excluded event is the correct one
    ITraceControlComponent comp = ControlViewSwtBotUtil.getComponent(fNode,
            ControlViewSwtBotUtil.SESSION_GROUP_NAME,
            getSessionName(),
            ControlViewSwtBotUtil.UST_DOMAIN_NAME,
            ControlViewSwtBotUtil.DEFAULT_CHANNEL_NAME,
            ControlViewSwtBotUtil.ALL_EVENTS_NAME);
    assertNotNull(comp);
    assertTrue(comp instanceof TraceEventComponent);
    TraceEventComponent event = (TraceEventComponent) comp;
    assertEquals(EXCLUDE_EXPRESSION, event.getExcludedEvents());
}
 
Example 18
Source File: RenameSpecHandlerTest.java    From tlaplus with MIT License 4 votes vote down vote up
/**
 * @see Bug #58 in general/bugzilla/index.html
 */
@Test
public void renameSpec() throws InterruptedException {
	openSpecExplorer();

	SWTBotTreeItem treeItem = bot.tree().getTreeItem(TEST_SPEC);
	checkForModelExistenceUI(treeItem);

	SWTBotMenu contextMenu = treeItem.contextMenu("Rename");
	contextMenu.click();
	
	// rename to ..._Copy
	bot.button("OK").click();
	
	// wait for rename to be done
	bot.waitUntil(new SpecEditorOpenCondition(TEST_SPEC));

	// verify (via API)
	checkSpecAndModelExistenceAPI((TEST_SPEC + "_Copy"), TEST_MODEL);
	
	// try to find the renamed file (via UI)
	openSpecExplorer();
	treeItem = bot.tree().getTreeItem(TEST_SPEC + "_Copy [ " + TEST_SPEC + TLA_SUFFIX + " ]");
	
	/*
	 * try to launch the model
	 */
	SWTBotTreeItem modelTreeItem = checkForModelExistenceUI(treeItem);
	modelTreeItem.contextMenu("Open").click();
	Assert.assertNotNull("UI tree item (model) could not be found", modelTreeItem);
	
	// register job listener who listens for the model checker job
	final String modelName = UIHelper.getActiveEditor().getTitle();
	final Model model = ToolboxHandle.getCurrentSpec().getAdapter(TLCSpec.class).getModel(modelName);
	final IJobChangeListener listener = new DummyJobChangeListener(model);
	Job.getJobManager().addJobChangeListener(listener);
	
	// start model checking by clicking the menu. This is more robust
	// compared to the f11 keystroke which can get lost when fired during
	// initialization of the model editor.
	bot.menu("TLC Model Checker").menu("Run model").click();

	// make unit test wait for model checker job to finish
	bot.waitUntil((ICondition) listener, SWTBotPreferences.TIMEOUT * 3);

	// Do some unregistration prior to model deletion:
	Job.getJobManager().removeJobChangeListener(listener);
	
	// close corresponding editor if open
	final IEditorPart editorWithModelOpened = model.getAdapter(ModelEditor.class);
	if (editorWithModelOpened != null) {
		UIHelper.runUISync(new Runnable() {
			public void run() {
				UIHelper.getActivePage().closeEditor(editorWithModelOpened,
						false);
			}
		});
	}
}
 
Example 19
Source File: CollapseEventsInTableTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Main test case
 */
@Test
public void test() {
    SWTBotUtils.createProject(TRACE_PROJECT_NAME);
    SWTBotUtils.openTrace(TRACE_PROJECT_NAME, fTestFile.getAbsolutePath(), COLLAPSE_TRACE_TYPE);
    SWTBotEditor editorBot = SWTBotUtils.activateEditor(fBot, fTestFile.getName());

    SWTBotTable tableBot = editorBot.bot().table();

    /* Maximize editor area */
    SWTBotUtils.maximize(editorBot.getReference(), tableBot);
    tableBot.click(1, 0);

    /* Collapse Events */
    SWTBotMenu menuBot = tableBot.contextMenu("Collapse Events");
    menuBot.click();
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "7/22", 1, 1));

    String cell = tableBot.cell(1, 1);
    assertEquals("filterString", "7/22", cell);

    /* Verify first collapsed event */
    cell = tableBot.cell(7, 0);
    assertEquals("1st repeatCount", "+14", cell);
    cell = tableBot.cell(7, 1);
    assertEquals("1st Timestamp", "Jan 1 06:06:06", cell);
    cell = tableBot.cell(7, 2);
    assertEquals("1st Host", "HostF", cell);
    cell = tableBot.cell(7, 3);
    assertEquals("1st Logger", "LoggerF", cell);
    cell = tableBot.cell(7, 4);
    assertEquals("1st File", "SourceFile", cell);
    cell = tableBot.cell(7, 5);
    assertEquals("1st Line", "9", cell);
    cell = tableBot.cell(7, 6);
    assertEquals("1st Message", "Message F", cell);

    /* Verify second collapsed event */
    cell = tableBot.cell(8, 0);
    assertEquals("2nd repeatCount", "+1", cell);
    cell = tableBot.cell(8, 1);
    assertEquals("2nd Timestamp", "Jan 1 06:06:21", cell);
    cell = tableBot.cell(8, 2);
    assertEquals("2nd Host", "HostF", cell);
    cell = tableBot.cell(8, 3);
    assertEquals("2nd Logger", "LoggerF", cell);
    cell = tableBot.cell(8, 4);
    assertEquals("2nd File", "SourceFile", cell);
    cell = tableBot.cell(8, 5);
    assertEquals("2nd Line", "10", cell);
    cell = tableBot.cell(8, 6);
    assertEquals("2nd Message", "Message D", cell);

    /* Clear Filter */
    menuBot = tableBot.contextMenu("Clear Filters");
    menuBot.click();
    fBot.waitUntil(ConditionHelpers.isTableCellFilled(tableBot, "Jan 1 01:01:01", 1, 1));
    assertEquals("Timestamp", "Jan 1 01:01:01", tableBot.cell(1, 1));

    SWTBotUtils.maximize(editorBot.getReference(), tableBot);

    fBot.closeAllEditors();
    SWTBotUtils.deleteProject(TRACE_PROJECT_NAME, fBot);
}
 
Example 20
Source File: ModelCheckerTest.java    From tlaplus with MIT License 4 votes vote down vote up
@Test
public void testNewModel() {
	// Open specA
	SWTBotMenu fileMenu = bot.menu("File");
	SWTBotMenu openSpecMenu = fileMenu.menu("Open Spec");
	SWTBotMenu addNewSpecMenu = openSpecMenu.menu("Add New Spec...");
	addNewSpecMenu.click();

	bot.textWithLabel("Root-module file:").setText(specA);
	bot.button("Finish").click();

	final String specName = getSpecName(new File(specA));

	// specs are created in non-UI thread asynchronously which causes a
	// delay before the menu entry becomes available
	bot.waitUntil(Conditions.waitForMenu(bot.activeShell(), WithText.<MenuItem> withText(specName)));
	
	// create a new model
	final SWTBotMenu modelMenu = bot.menu("TLC Model Checker");
	final SWTBotMenu newModelMenu = modelMenu.menu("New Model...");
	newModelMenu.click();
	bot.button("OK").click();

	// wait for model editor to show up and parse
	bot.waitUntil(new ModelEditorOpenCondition("Model_"));
	
	// register job listener who listens for the model checker job
	final String modelName = UIHelper.getActiveEditor().getTitle();
	final Model model = ToolboxHandle.getCurrentSpec().getAdapter(TLCSpec.class).getModel(modelName);
	final IJobChangeListener listener = new DummyJobChangeListener(model);
	Job.getJobManager().addJobChangeListener(listener);
	
	// start model checking by clicking the menu. This is more robust
	// compared to the f11 keystroke which can get lost when fired during
	// initialization of the model editor.
	bot.menu("TLC Model Checker").menu("Run model").click();

	// make unit test wait for model checker job to finish
	bot.waitUntil((ICondition) listener, SWTBotPreferences.TIMEOUT * 3);

	// Do some unregistration prior to model deletion:
	Job.getJobManager().removeJobChangeListener(listener);
	
	// close corresponding editor if open
	final IEditorPart editorWithModelOpened = model.getAdapter(ModelEditor.class);
	if (editorWithModelOpened != null) {
		UIHelper.runUISync(new Runnable() {
			public void run() {
				UIHelper.getActivePage().closeEditor(editorWithModelOpened,
						false);
			}
		});
	}

	// Delete the newly created model again. It does not use the UI because
	// SWTBot cannot handle the modal confirmation dialog do delete the
	// model.
	// Deleting the model is necessary because repeated test execution would
	// leave huge numbers of model leftovers contributing to slowed down test
	// execution (see SizeControlContribution for reason why).
	try {
		model.delete(new NullProgressMonitor());
	} catch (CoreException e) {
		e.printStackTrace();
	}
}