Пример #1
0
  public void testChartCallback() throws Exception {
    ILaunchConfiguration config = createConfiguration(proj.getProject());
    doLaunch(config, "testChartCallback"); // $NON-NLS-1$

    ValgrindViewPart view = ValgrindUIPlugin.getDefault().getView();
    IAction chartAction = getChartAction(view);
    assertNotNull(chartAction);
    chartAction.run();

    IEditorPart part =
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    if (part instanceof ChartEditor) {
      ChartControl control = ((ChartEditor) part).getControl();
      Event event = new Event();
      event.button = 1;
      event.count = 1;
      event.widget = control;
      MouseEvent mEvent = new MouseEvent(event);
      DataPointHints source =
          new DataPointHints(
              null, null, null, null, null, null, null, null, null, 4, null, 0, null);
      control.callback(mEvent, new WrappedStructureSource(source), null);

      TableViewer viewer = ((MassifViewPart) view.getDynamicView()).getTableViewer();
      MassifSnapshot[] snapshots = (MassifSnapshot[]) viewer.getInput();
      MassifSnapshot snapshot =
          (MassifSnapshot) ((StructuredSelection) viewer.getSelection()).getFirstElement();
      assertEquals(4, Arrays.asList(snapshots).indexOf(snapshot));
    } else {
      fail();
    }
  }
Пример #2
0
  public void testExecPidMenu() throws Exception {
    ILaunchConfigurationWorkingCopy config =
        createConfiguration(proj.getProject()).getWorkingCopy();
    config.setAttribute(LaunchConfigurationConstants.ATTR_GENERAL_TRACECHILD, true);
    config.doSave();
    doLaunch(config, "testExec"); // $NON-NLS-1$

    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());
    assertEquals(output.getSnapshots(pids[0]), dynamicView.getSnapshots());

    // select second pid
    selectItem(pidMenu, 1);

    assertFalse(firstPid.getAction().isChecked());
    assertTrue(secondPid.getAction().isChecked());
    assertEquals(output.getSnapshots(pids[1]), dynamicView.getSnapshots());

    // select second pid again
    selectItem(pidMenu, 1);

    assertFalse(firstPid.getAction().isChecked());
    assertTrue(secondPid.getAction().isChecked());
    assertEquals(output.getSnapshots(pids[1]), dynamicView.getSnapshots());

    // select first pid
    selectItem(pidMenu, 0);

    assertTrue(firstPid.getAction().isChecked());
    assertFalse(secondPid.getAction().isChecked());
    assertEquals(output.getSnapshots(pids[0]), dynamicView.getSnapshots());
  }