use of org.eclipse.linuxtools.internal.valgrind.massif.MassifPidMenuAction in project linuxtools by eclipse.
the class MultiProcessTest method testExecPidMenu.
@Test
public void testExecPidMenu() throws CoreException, URISyntaxException, IOException {
ILaunchConfigurationWorkingCopy config = createConfiguration(proj.getProject()).getWorkingCopy();
config.setAttribute(LaunchConfigurationConstants.ATTR_GENERAL_TRACECHILD, true);
config.doSave();
// $NON-NLS-1$
doLaunch(config, "testExec");
ValgrindViewPart view = ValgrindUIPlugin.getDefault().getView();
MassifViewPart dynamicView = (MassifViewPart) view.getDynamicView();
MassifOutput output = dynamicView.getOutput();
MassifPidMenuAction menuAction = null;
IToolBarManager manager = view.getViewSite().getActionBars().getToolBarManager();
for (IContributionItem item : manager.getItems()) {
if (item instanceof ActionContributionItem && ((ActionContributionItem) item).getAction() instanceof MassifPidMenuAction) {
menuAction = (MassifPidMenuAction) ((ActionContributionItem) item).getAction();
}
}
assertNotNull(menuAction);
Integer[] pids = dynamicView.getOutput().getPids();
Shell shell = new Shell(Display.getCurrent());
Menu pidMenu = menuAction.getMenu(shell);
assertEquals(2, pidMenu.getItemCount());
ActionContributionItem firstPid = (ActionContributionItem) pidMenu.getItem(0).getData();
ActionContributionItem secondPid = (ActionContributionItem) pidMenu.getItem(1).getData();
// check initial state
assertTrue(firstPid.getAction().isChecked());
assertFalse(secondPid.getAction().isChecked());
assertArrayEquals(output.getSnapshots(pids[0]), dynamicView.getSnapshots());
// select second pid
selectItem(pidMenu, 1);
assertFalse(firstPid.getAction().isChecked());
assertTrue(secondPid.getAction().isChecked());
assertArrayEquals(output.getSnapshots(pids[1]), dynamicView.getSnapshots());
// select second pid again
selectItem(pidMenu, 1);
assertFalse(firstPid.getAction().isChecked());
assertTrue(secondPid.getAction().isChecked());
assertArrayEquals(output.getSnapshots(pids[1]), dynamicView.getSnapshots());
// select first pid
selectItem(pidMenu, 0);
assertTrue(firstPid.getAction().isChecked());
assertFalse(secondPid.getAction().isChecked());
assertArrayEquals(output.getSnapshots(pids[0]), dynamicView.getSnapshots());
}
Aggregations