org.eclipse.swtbot.swt.finder.widgets.SWTBotStyledText Java Examples

The following examples show how to use org.eclipse.swtbot.swt.finder.widgets.SWTBotStyledText. 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: SwtBotTestingUtilities.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Wait until the given text widget contains the provided string
 */
public static void waitUntilStyledTextContains(SWTBot bot, String text, SWTBotStyledText widget) {
  bot.waitUntil(new DefaultCondition() {
    @Override
    public boolean test() throws Exception {
      return widget.getText().contains(text);
    }

    @Override
    public String getFailureMessage() {
      return "Text not found!";
    }
  });
}
 
Example #2
Source File: FontEventEditorTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static FontData getFont(final SWTBotStyledText rawText) {
    return UIThreadRunnable.syncExec(new Result<FontData>() {
        @Override
        public FontData run() {
            return rawText.widget.getFont().getFontData()[0];
        }
    });
}
 
Example #3
Source File: ConsoleViewContains.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean test() throws Exception {
  msg = "Could not open Console view";
  SWTBotView consoleView = bot.viewById("org.eclipse.ui.console.ConsoleView");
  msg = "Could not find textWidget in Console view";
  SWTBotStyledText textWidget = consoleView.bot().styledText();
  msg = "Could not get the text from the Console view";
  String text = textWidget.getText();
  msg = "Looking for: '" + searchString + "' but found \n\t------\n\t" + text + "\n\t-----";

  return text.contains(searchString);
}
 
Example #4
Source File: ConsoleView.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private SWTBotStyledText getCurrentConsoleTextWidget() {
  // testing showed that there is only 1 styledText but play it safe

  final List<? extends StyledText> styledTexts =
      view.bot().widgets(allOf(widgetOfType(StyledText.class)), view.getWidget());

  final StyledText widget =
      UIThreadRunnable.syncExec(
          new WidgetResult<StyledText>() {

            @Override
            public StyledText run() {
              for (StyledText text : styledTexts) {
                if (text.isDisposed()) continue;

                if (text.isVisible()) return text;
              }
              return null;
            }
          });

  if (widget == null)
    throw new WidgetNotFoundException("the console window does not contain an active console");

  return new SWTBotStyledText(widget);
}
 
Example #5
Source File: RawTextEditorTest.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * Test going to raw and back
 */
@Test
public void testRead() {
    ITmfTrace activeTrace = TmfTraceManager.getInstance().getActiveTrace();

    fBot.waitUntil(new NumberOfEventsCondition(activeTrace, INITIAL_NB_EVENTS));

    SWTBotEditor eventsEditor = SWTBotUtils.activeEventsEditor(fBot);
    eventsEditor.setFocus();
    assertFalse(eventsEditor.bot().table().rowCount() == 0);
    eventsEditor.bot().table().select(4);
    eventsEditor.bot().table().getTableItem(4).contextMenu("Show Raw").click();
    eventsEditor.bot().table().getTableItem(4).click();
    final SWTBotStyledText rawViewer = eventsEditor.bot().styledText();

    String selection = rawViewer.getText();
    assertEquals(":03 HostF LoggerF: SourceFileF:9 Message F", selection.substring(12, 54));
    rawViewer.pressShortcut(Keystrokes.DOWN);
    final ICondition colorIsNotHighlight = new DefaultCondition() {
        @Override
        public boolean test() throws Exception {
            return !HIGHLIGHT_COLOR.equals(rawViewer.getLineBackground(0));
        }

        @Override
        public String getFailureMessage() {
            return "Timed out";
        }
    };
    final ICondition colorIsHighlight = new DefaultCondition() {
        @Override
        public boolean test() {
            return HIGHLIGHT_COLOR.equals(rawViewer.getLineBackground(0));
        }

        @Override
        public String getFailureMessage() {
            return "Timed out";
        }
    };
    fBot.waitUntil(colorIsNotHighlight);
    assertEquals("Non-highlighted color", WHITE, rawViewer.getLineBackground(0));
    assertEquals("Highlighted color", HIGHLIGHT_COLOR, rawViewer.getLineBackground(1));
    rawViewer.pressShortcut(Keystrokes.UP);
    fBot.waitUntil(colorIsHighlight);
    assertEquals("Highlighted color", HIGHLIGHT_COLOR, rawViewer.getLineBackground(0));
    rawViewer.pressShortcut(Keystrokes.DOWN);
    fBot.waitUntil(colorIsNotHighlight);
    assertEquals("Non-highlighted color", WHITE, rawViewer.getLineBackground(0));
    assertEquals("Highlighted color", HIGHLIGHT_COLOR, rawViewer.getLineBackground(1));
    rawViewer.pressShortcut(Keystrokes.PAGE_UP);
    fBot.waitUntil(colorIsHighlight);
    assertEquals("Highlighted color", HIGHLIGHT_COLOR, rawViewer.getLineBackground(0));
    rawViewer.pressShortcut(SWT.CTRL, SWT.END, ' ');
    assertEquals("Highlighted color", HIGHLIGHT_COLOR, rawViewer.getLineBackground(0));
    rawViewer.pressShortcut(Keystrokes.UP);
    rawViewer.pressShortcut(Keystrokes.PAGE_DOWN);
    fBot.waitUntil(colorIsNotHighlight);
    assertEquals("Non-highlighted color", WHITE, rawViewer.getLineBackground(0));
    assertEquals("Highlighted color", HIGHLIGHT_COLOR, rawViewer.getLineBackground(1));
    rawViewer.pressShortcut(SWT.CTRL, SWT.HOME, ' ');
    fBot.waitUntil(colorIsHighlight);
    assertEquals("Highlighted color", HIGHLIGHT_COLOR, rawViewer.getLineBackground(0));
    eventsEditor.bot().table().getTableItem(5).click();
    eventsEditor.bot().table().getTableItem(4).contextMenu("Hide Raw").click();
    assertFalse(rawViewer.isActive());
}
 
Example #6
Source File: RemoteBotStyledText.java    From saros with GNU General Public License v2.0 4 votes vote down vote up
public IRemoteBotStyledText setWidget(SWTBotStyledText styledText) {
  this.widget = styledText;
  return this;
}
 
Example #7
Source File: SarosSWTBotChatInput.java    From saros with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Constructs a new instance of this object.
 *
 * @param w the widget.
 * @param description the description of the widget, this will be reported by {@link #toString()}
 * @throws WidgetNotFoundException if the widget is <code>null</code> or widget has been disposed.
 */
public SarosSWTBotChatInput(ChatInput w, SelfDescribing description)
    throws WidgetNotFoundException {
  super(w, description);
  this.styledText = new SWTBotStyledText(getStyledText(w));
}