/** Test tool bar buttons "Select Next Event" and "Select Previous Event" */
 @Test
 public void testToolBarSelectNextPreviousEvent() {
   testNextPreviousEvent(
       () -> fViewBot.toolbarButton(SELECT_NEXT_EVENT).click(),
       () -> fViewBot.toolbarButton(SELECT_NEXT_EVENT).click(SWT.SHIFT),
       () -> fViewBot.toolbarButton(SELECT_PREVIOUS_EVENT).click(),
       () -> fViewBot.toolbarButton(SELECT_PREVIOUS_EVENT).click(SWT.SHIFT));
 }
  @Test
  public void shouldUpdateTrackingBranchOnPush() throws Exception {
    makeChangesAndCommit(PROJ1);
    Repository repository = lookupRepository(repositoryFile);
    ObjectId headId = repository.resolve(Constants.HEAD);

    String trackingBranch = Constants.R_REMOTES + "origin/master";
    launchSynchronization(Constants.HEAD, trackingBranch, false);

    SWTBotView viewBot = bot.viewByTitle("Synchronize");
    SWTBotToolbarButton pushButton = viewBot.toolbarButton(UIText.GitActionContributor_Push);
    JobJoiner jobJoiner = JobJoiner.startListening(JobFamilies.PUSH, 30, TimeUnit.SECONDS);
    pushButton.click();
    jobJoiner.join();

    String destinationString = repositoryFile.getParentFile().getName() + " - " + "origin";
    SWTBotShell resultDialog =
        bot.shell(NLS.bind(UIText.PushResultDialog_title, destinationString));
    resultDialog.close();

    Repository remoteRepository = lookupRepository(childRepositoryFile);
    ObjectId masterOnRemote = remoteRepository.resolve("master");
    assertThat("Expected push to update branch on remote repository", masterOnRemote, is(headId));

    ObjectId trackingId = repository.resolve(trackingBranch);
    assertThat("Expected tracking branch to be updated", trackingId, is(headId));
  }
 /**
  * Debug Drools Rule and checks result
  *
  * @param droolsRuletName
  */
 private void debugDroolsRule(String droolsRuleName) {
   packageExplorer.show();
   SWTBotTreeItem tiDroolsRule =
       packageExplorer.selectTreeItem(
           DroolsAllBotTests.SAMPLE_DROOLS_RULE_NAME,
           new String[] {
             DroolsAllBotTests.DROOLS_PROJECT_NAME, DroolsAllBotTests.SRC_MAIN_RULES_TREE_NODE
           });
   SWTBot packageExplorerBot = bot.viewByTitle(ViewType.PACKAGE_EXPLORER.getViewLabel()).bot();
   SWTBotTree tree = packageExplorerBot.tree();
   // Select and Open Rule File
   ContextMenuHelper.prepareTreeItemForContextMenu(tree, tiDroolsRule);
   new SWTBotMenu(ContextMenuHelper.getContextMenu(tree, IDELabel.Menu.OPEN, true)).click();
   SWTBotEclipseEditor ruleEditor = bot.editorByTitle(droolsRuleName).toTextEditor();
   ruleEditor.selectRange(8, 0, 0);
   bot.menu(IDELabel.Menu.RUN).menu(IDELabel.Menu.TOGGLE_BREAKPOINT).click();
   SWTBotTreeItem tiDroolsTest =
       packageExplorer.selectTreeItem(
           DroolsAllBotTests.DROOLS_TEST_JAVA_TREE_NODE,
           new String[] {
             DroolsAllBotTests.DROOLS_PROJECT_NAME,
             DroolsAllBotTests.SRC_MAIN_JAVA_TREE_NODE,
             DroolsAllBotTests.COM_SAMPLE_TREE_NODE
           });
   console.clearConsole();
   eclipse.debugTreeItemAsDroolsApplication(tiDroolsTest);
   eclipse.closeConfirmPerspectiveSwitchShellIfOpened(false);
   String consoleText = console.getConsoleText(3 * 1000L, 3 * 1000L, true);
   assertTrue(
       "Drools Rule was not debuged properly.\nConsole content should have been empty but is:\n"
           + consoleText,
       consoleText.length() == 0);
   SWTBotView debugView = bot.viewByTitle(ViewType.DEBUG.getViewLabel());
   debugView.toolbarButton(IDELabel.DebugView.BUTTON_STEP_OVER_TOOLTIP).click();
   consoleText = console.getConsoleText(3 * 1000L, 60 * 1000L, true);
   assertTrue(
       "Drools Rule was not debuged properly.\nConsole content should be:\n'Hello World\n' but is:\n"
           + consoleText,
       consoleText.equals("Hello World\n"));
   debugView.toolbarButton(IDELabel.DebugView.BUTTON_RESUME_TOOLTIP).click();
   consoleText = console.getConsoleText(3 * 1000L, 60 * 1000L, true);
   assertTrue(
       "Drools Rule was not debuged properly.\nConsole content should be:Hello World\nGoodbye cruel world\n"
           + consoleText,
       consoleText.equals("Hello World\nGoodbye cruel world\n"));
 }
示例#4
0
 /** Test color by making all events yellow */
 @Test
 public void testYellow() {
   SWTBotView viewBot = fBot.viewById(ColorsView.ID);
   viewBot.setFocus();
   final String insert = "Insert new color setting";
   final String increasePriority = "Increase priority";
   final String decreasePriority = "Decrease priority";
   final String delete = "Delete color setting";
   viewBot.toolbarButton(insert).click();
   viewBot.toolbarButton(insert).click();
   viewBot.toolbarButton(insert).click();
   viewBot.toolbarButton(insert).click();
   viewBot.toolbarButton(increasePriority).click();
   viewBot.toolbarButton(decreasePriority).click();
   viewBot.toolbarButton(delete).click();
   viewBot.bot().label(0).setFocus();
   viewBot.toolbarButton(delete).click();
   viewBot.bot().label(0).setFocus();
   viewBot.toolbarButton(delete).click();
   final RGB foreground = new RGB(0, 0, 0);
   final RGB background = new RGB(255, 255, 0);
   // Simulate the side effects of picking a color because we cannot
   // control native Color picker dialog in SWTBot.
   final ColorSetting[] cs = new ColorSetting[1];
   UIThreadRunnable.syncExec(
       new VoidResult() {
         @Override
         public void run() {
           cs[0] = new ColorSetting(foreground, background, foreground, new PassAll());
           ColorSettingsManager.setColorSettings(cs);
         }
       });
   final SWTBotTable eventsEditor = SWTBotUtils.activeEventsEditor(fBot).bot().table();
   // should fix race condition of loading the trace
   SWTBotUtils.waitForJobs();
   eventsEditor.select(2);
   final SWTBotTableItem tableItem = eventsEditor.getTableItem(2);
   RGB fgc =
       UIThreadRunnable.syncExec(
           new Result<RGB>() {
             @Override
             public RGB run() {
               return tableItem.widget.getForeground().getRGB();
             }
           });
   RGB bgc =
       UIThreadRunnable.syncExec(
           new Result<RGB>() {
             @Override
             public RGB run() {
               return tableItem.widget.getBackground().getRGB();
             }
           });
   assertEquals("Fg", foreground, fgc);
   assertEquals("Bg", background, bgc);
   // reset color settings
   UIThreadRunnable.syncExec(
       new VoidResult() {
         @Override
         public void run() {
           ColorSettingsManager.setColorSettings(new ColorSetting[0]);
         }
       });
 }
  /** Test tool bar buttons "Follow CPU Forward" and "Follow CPU Backward" */
  @Test
  public void testToolBarFollowCPUForwardBackward() {
    /* change window range to 10 ms */
    TmfTimeRange range =
        new TmfTimeRange(
            START_TIME, START_TIME.normalize(10000000L, ITmfTimestamp.NANOSECOND_SCALE));
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, range));
    fBot.waitUntil(ConditionHelpers.windowRange(range));

    /* set selection to trace start time */
    TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, START_TIME));
    fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(START_TIME, START_TIME)));

    /* select first item */
    final SWTBotTree tree = fViewBot.bot().tree();
    tree.pressShortcut(Keystrokes.HOME);

    /* set focus on time graph */
    final TimeGraphControl timegraph =
        fViewBot.bot().widget(WidgetOfType.widgetOfType(TimeGraphControl.class));
    UIThreadRunnable.syncExec(
        new VoidResult() {
          @Override
          public void run() {
            timegraph.setFocus();
          }
        });

    /* click "Follow CPU Forward" 3 times */
    timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME));
    fViewBot.toolbarButton(FOLLOW_CPU_FORWARD).click();
    timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME1, TID1_TIME1));
    fViewBot.toolbarButton(FOLLOW_CPU_FORWARD).click();
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME1, TID2_TIME1));
    fViewBot.toolbarButton(FOLLOW_CPU_FORWARD).click();
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME2));
    fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME2, TID2_TIME2)));
    fBot.waitUntil(ConditionHelpers.treeSelectionContains(tree, 1, "2"));
    assertTrue(
        TmfTraceManager.getInstance()
            .getCurrentTraceContext()
            .getWindowRange()
            .contains(TID2_TIME2));

    /* shift-click "Follow CPU Forward" 3 times */
    fViewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME3));
    fViewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME4));
    fViewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME4));
    fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME2, TID5_TIME1)));
    fBot.waitUntil(ConditionHelpers.treeSelectionContains(tree, 1, "5"));
    assertTrue(
        TmfTraceManager.getInstance()
            .getCurrentTraceContext()
            .getWindowRange()
            .contains(TID5_TIME1));

    /* shift-click "Follow CPU Backward" 4 times */
    fViewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME4));
    fViewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME3));
    fViewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME2));
    fViewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME1));
    fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME2, TID2_TIME1)));
    fBot.waitUntil(ConditionHelpers.treeSelectionContains(tree, 1, "2"));
    assertTrue(
        TmfTraceManager.getInstance()
            .getCurrentTraceContext()
            .getWindowRange()
            .contains(TID2_TIME1));

    /* click "Follow CPU Forward" 2 times */
    fViewBot.toolbarButton(FOLLOW_CPU_FORWARD).click();
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME2));
    fViewBot.toolbarButton(FOLLOW_CPU_FORWARD).click();
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME3));
    fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME3, TID2_TIME3)));
    fBot.waitUntil(ConditionHelpers.treeSelectionContains(tree, 1, "2"));
    assertTrue(
        TmfTraceManager.getInstance()
            .getCurrentTraceContext()
            .getWindowRange()
            .contains(TID2_TIME3));

    /* shift-click "Follow CPU Backward" 3 times */
    fViewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME2));
    fViewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME1));
    fViewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID1_TIME1));
    fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME3, TID1_TIME1)));
    fBot.waitUntil(ConditionHelpers.treeSelectionContains(tree, 1, "1"));
    assertTrue(
        TmfTraceManager.getInstance()
            .getCurrentTraceContext()
            .getWindowRange()
            .contains(TID1_TIME1));

    /* shift-click "Follow CPU Forward" 4 times */
    fViewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME1));
    fViewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME2));
    fViewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME3));
    fViewBot.toolbarButton(FOLLOW_CPU_FORWARD).click(SWT.SHIFT);
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME4));
    fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(TID2_TIME3, TID2_TIME4)));
    fBot.waitUntil(ConditionHelpers.treeSelectionContains(tree, 1, "2"));
    assertTrue(
        TmfTraceManager.getInstance()
            .getCurrentTraceContext()
            .getWindowRange()
            .contains(TID2_TIME4));

    /* click "Follow CPU Backward" 5 times */
    fViewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click();
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME3, TID2_TIME3));
    fViewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click();
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME2, TID2_TIME2));
    fViewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click();
    timeGraphIsReadyCondition(new TmfTimeRange(TID2_TIME1, TID2_TIME1));
    fViewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click();
    timeGraphIsReadyCondition(new TmfTimeRange(TID1_TIME1, TID1_TIME1));
    fViewBot.toolbarButton(FOLLOW_CPU_BACKWARD).click();
    timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME));
    fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(START_TIME, START_TIME)));
    assertTrue(
        TmfTraceManager.getInstance()
            .getCurrentTraceContext()
            .getWindowRange()
            .contains(START_TIME));
  }