コード例 #1
0
  /**
   * Checks Content Assist content on specified position within editor with editorTitle and checks
   * if expectedProposalList is equal to current Proposal List
   *
   * @param editorTitle
   * @param textToSelect
   * @param selectionOffset
   * @param selectionLength
   * @param textToSelectIndex
   * @param expectedProposalList
   * @param mustEquals
   */
  public static SWTBotEditor checkContentAssistContent(
      SWTBotExt bot,
      String editorTitle,
      String textToSelect,
      int selectionOffset,
      int selectionLength,
      int textToSelectIndex,
      List<String> expectedProposalList,
      boolean mustEquals) {

    SWTJBTExt.selectTextInSourcePane(
        bot, editorTitle, textToSelect, selectionOffset, selectionLength, textToSelectIndex);

    bot.sleep(Timing.time1S());

    SWTBotEditorExt editor = SWTTestExt.bot.swtBotEditorExtByTitle(editorTitle);
    ContentAssistBot contentAssist = editor.contentAssist();
    List<String> currentProposalList = contentAssist.getProposalList();
    assertTrue(
        "Code Assist menu has incorrect menu items.\n"
            + "Expected Proposal Menu Labels vs. Current Proposal Menu Labels :\n"
            + FormatUtils.getListsDiffFormatted(expectedProposalList, currentProposalList),
        mustEquals
            ? expectedProposalList.equals(currentProposalList)
            : currentProposalList.containsAll(expectedProposalList));

    return editor;
  }
コード例 #2
0
  /**
   * Checks Content Assist auto proposal. It's case when there is only one content assist item and
   * that item is automatically inserted into editor and checks if expectedProposalList is equal to
   * current Proposal List
   *
   * @param editorTitle
   * @param textToSelect
   * @param selectionOffset
   * @param selectionLength
   * @param textToSelectIndex
   * @param expectedInsertedText
   */
  public static SWTBotEditor checkContentAssistAutoProposal(
      SWTBotExt bot,
      String editorTitle,
      String textToSelect,
      int selectionOffset,
      int selectionLength,
      int textToSelectIndex,
      String expectedInsertedText) {

    SWTJBTExt.selectTextInSourcePane(
        bot, editorTitle, textToSelect, selectionOffset, selectionLength, textToSelectIndex);

    bot.sleep(Timing.time1S());

    SWTBotEditorExt editor = SWTTestExt.bot.swtBotEditorExtByTitle(editorTitle);
    String editorLineBeforeInsert = editor.getTextOnCurrentLine();
    int xPos = editor.cursorPosition().column;
    String expectedEditorLineAfterInsert =
        editorLineBeforeInsert.substring(0, xPos)
            + expectedInsertedText
            + editorLineBeforeInsert.substring(xPos);
    ContentAssistBot contentAssist = editor.contentAssist();
    contentAssist.invokeContentAssist();
    String editorLineAfterInsert = editor.getTextOnCurrentLine();
    assertTrue(
        "Text on current line should be:\n"
            + expectedEditorLineAfterInsert
            + "\nbut is:\n"
            + editorLineAfterInsert,
        editorLineAfterInsert.equals(expectedEditorLineAfterInsert));

    return editor;
  }
コード例 #3
0
  /**
   * Applies Content Assist auto proposal. It's case when there is only one content assist item and
   * that item is automatically inserted into editor
   *
   * @param editorTitle
   * @param textToSelect
   * @param selectionOffset
   * @param selectionLength
   * @param textToSelectIndex
   */
  public static SWTBotEditor applyContentAssistAutoProposal(
      SWTBotExt bot,
      String editorTitle,
      String textToSelect,
      int selectionOffset,
      int selectionLength,
      int textToSelectIndex) {

    SWTJBTExt.selectTextInSourcePane(
        bot, editorTitle, textToSelect, selectionOffset, selectionLength, textToSelectIndex);

    bot.sleep(Timing.time1S());

    SWTBotEditorExt editor = SWTTestExt.bot.swtBotEditorExtByTitle(editorTitle);
    ContentAssistBot contentAssist = editor.contentAssist();
    contentAssist.invokeContentAssist();

    return editor;
  }