当前位置: 首页>>代码示例>>Java>>正文


Java EditorTestUtil类代码示例

本文整理汇总了Java中com.intellij.testFramework.EditorTestUtil的典型用法代码示例。如果您正苦于以下问题:Java EditorTestUtil类的具体用法?Java EditorTestUtil怎么用?Java EditorTestUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


EditorTestUtil类属于com.intellij.testFramework包,在下文中一共展示了EditorTestUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testInsertDeleteParenth

import com.intellij.testFramework.EditorTestUtil; //导入依赖的package包/类
public void testInsertDeleteParenth() throws Exception {
  configureByFile(BASE_PATH + "InsertDeleteParenth.cs");
  EditorTestUtil.performTypingAction(getEditor(), '(');
  checkResultByFile(BASE_PATH + "InsertDeleteParenth_after.cs");

  configureByFile(BASE_PATH+"InsertDeleteParenth_after.cs");
  EditorTestUtil.performTypingAction(getEditor(), BACKSPACE_FAKE_CHAR);
  checkResultByFile(BASE_PATH+"InsertDeleteParenth.cs");

  configureByFile(BASE_PATH+"InsertDeleteParenth_after.cs");
  EditorTestUtil.performTypingAction(getEditor(), ')');
  checkResultByFile(BASE_PATH+"InsertDeleteParenth_after2.cs");

  configureByFile(BASE_PATH + "InsertDeleteParenth2_2.cs");
  EditorTestUtil.performTypingAction(getEditor(), '(');
  checkResultByFile(BASE_PATH + "InsertDeleteParenth2_2_after.cs");

  configureByFile(BASE_PATH + "InsertDeleteParenth2.cs");
  EditorTestUtil.performTypingAction(getEditor(), '(');
  checkResultByFile(BASE_PATH + "InsertDeleteParenth2_after.cs");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:CustomFileTypeEditorTest.java

示例2: testPrevNextWordWithFolding

import com.intellij.testFramework.EditorTestUtil; //导入依赖的package包/类
public void testPrevNextWordWithFolding() {
  myFixture.configureByText("a.txt", "<caret>brown fox");
  EditorTestUtil.addFoldRegion(myFixture.getEditor(), 4, 7, "...", true);
  myFixture.performEditorAction(IdeActions.ACTION_EDITOR_NEXT_WORD);
  myFixture.checkResult("brow<caret>n fox");
  myFixture.performEditorAction(IdeActions.ACTION_EDITOR_NEXT_WORD);
  myFixture.checkResult("brown f<caret>ox");
  myFixture.performEditorAction(IdeActions.ACTION_EDITOR_NEXT_WORD);
  myFixture.checkResult("brown fox<caret>");
  myFixture.performEditorAction(IdeActions.ACTION_EDITOR_PREVIOUS_WORD);
  myFixture.checkResult("brown f<caret>ox");
  myFixture.performEditorAction(IdeActions.ACTION_EDITOR_PREVIOUS_WORD);
  myFixture.checkResult("brow<caret>n fox");
  myFixture.performEditorAction(IdeActions.ACTION_EDITOR_PREVIOUS_WORD);
  myFixture.checkResult("<caret>brown fox");
  FoldRegion[] foldRegions = myFixture.getEditor().getFoldingModel().getAllFoldRegions();
  assertEquals(1, foldRegions.length);
  assertFalse(foldRegions[0].isExpanded());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:NextPrevWordTest.java

示例3: testPrevNextWordWithSelectionAndFolding

import com.intellij.testFramework.EditorTestUtil; //导入依赖的package包/类
public void testPrevNextWordWithSelectionAndFolding() {
  myFixture.configureByText("a.txt", "<caret>brown fox");
  EditorTestUtil.addFoldRegion(myFixture.getEditor(), 4, 7, "...", true);
  myFixture.performEditorAction(IdeActions.ACTION_EDITOR_NEXT_WORD_WITH_SELECTION);
  myFixture.checkResult("<selection>brow<caret></selection>n fox");
  myFixture.performEditorAction(IdeActions.ACTION_EDITOR_NEXT_WORD_WITH_SELECTION);
  myFixture.checkResult("<selection>brown f<caret></selection>ox");
  myFixture.performEditorAction(IdeActions.ACTION_EDITOR_NEXT_WORD_WITH_SELECTION);
  myFixture.checkResult("<selection>brown fox<caret></selection>");
  myFixture.performEditorAction(IdeActions.ACTION_EDITOR_PREVIOUS_WORD_WITH_SELECTION);
  myFixture.checkResult("<selection>brown f<caret></selection>ox");
  myFixture.performEditorAction(IdeActions.ACTION_EDITOR_PREVIOUS_WORD_WITH_SELECTION);
  myFixture.checkResult("<selection>brow<caret></selection>n fox");
  myFixture.performEditorAction(IdeActions.ACTION_EDITOR_PREVIOUS_WORD_WITH_SELECTION);
  myFixture.checkResult("<caret>brown fox");
  FoldRegion[] foldRegions = myFixture.getEditor().getFoldingModel().getAllFoldRegions();
  assertEquals(1, foldRegions.length);
  assertFalse(foldRegions[0].isExpanded());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:NextPrevWordTest.java

示例4: testSoftWrapsRecalculationInASpecificCase

import com.intellij.testFramework.EditorTestUtil; //导入依赖的package包/类
public void testSoftWrapsRecalculationInASpecificCase() throws Exception {
  configureFromFileText(getTestName(false) + ".java",
                        "<selection>class Foo {\n" +
                        "\[email protected]\n" +
                        "\tpublic boolean equals(Object other) {\n" +
                        "\t\treturn this == other;\n" +
                        "\t}\n" +
                        "}</selection>");
  CodeFoldingManager.getInstance(ourProject).buildInitialFoldings(myEditor);
  EditorTestUtil.configureSoftWraps(myEditor, 232, 7); // wrap after 32 characters

  // verify initial state
  assertEquals(4, EditorUtil.getTabSize(myEditor));
  assertEquals("[FoldRegion +(59:64), placeholder=' { ', FoldRegion +(85:88), placeholder=' }']", myEditor.getFoldingModel().toString());
  verifySoftWrapPositions(52, 85);
  
  Document document = myEditor.getDocument();
  for (int i = document.getLineCount() - 1; i >= 0; i--) {
    document.insertString(document.getLineStartOffset(i), "//");
  }

  verifySoftWrapPositions(58, 93);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:EditorImplTest.java

示例5: testOnlyMinimalRangeIsRecalculatedOnDocumentChange

import com.intellij.testFramework.EditorTestUtil; //导入依赖的package包/类
public void testOnlyMinimalRangeIsRecalculatedOnDocumentChange() throws IOException {
  init("aa bb cc dd ee<caret> ff gg hh ii jj", TestFileType.TEXT);
  EditorTestUtil.configureSoftWraps(myEditor, 8);
  verifySoftWrapPositions(6, 12, 18, 24);
  
  final IncrementalCacheUpdateEvent[] event = new IncrementalCacheUpdateEvent[1];
  ((SoftWrapModelImpl)myEditor.getSoftWrapModel()).getApplianceManager().addListener(new SoftWrapAwareDocumentParsingListenerAdapter() {
    @Override
    public void onRecalculationEnd(@NotNull IncrementalCacheUpdateEvent e) {
      assertNull(event[0]);
      event[0] = e;
    }
  });
  
  type(' ');
  
  verifySoftWrapPositions(6, 12, 19, 25);
  assertNotNull(event[0]);
  assertEquals(6, event[0].getStartOffset());
  assertEquals(19, event[0].getActualEndOffset());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:SoftWrapApplianceOnDocumentModificationTest.java

示例6: testFoldTreeIterator

import com.intellij.testFramework.EditorTestUtil; //导入依赖的package包/类
public void testFoldTreeIterator() {
  configureFromFileText(getTestName(false) + ".txt",
                        "abcdefghijklmnopqrstuvwxyz");
  EditorTestUtil.addFoldRegion(myEditor, 0, 10, ".", true);
  EditorTestUtil.addFoldRegion(myEditor, 0, 5, ".", false);
  EditorTestUtil.addFoldRegion(myEditor, 1, 2, ".", true);
  EditorTestUtil.addFoldRegion(myEditor, 7, 10, ".", false);
  EditorTestUtil.addFoldRegion(myEditor, 10, 11, ".", true);

  StringBuilder b = new StringBuilder();
  Iterator<FoldRegion> it = FoldingUtil.createFoldTreeIterator(myEditor);
  while (it.hasNext()) {
    FoldRegion region = it.next();
    if (b.length() > 0) {
      b.append('|');
    }
    b.append(region.getStartOffset()).append(',').append(region.getEndOffset());
  }

  assertEquals("0,10|0,5|1,2|7,10|10,11", b.toString());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:FoldingUtilTest.java

示例7: testHardWrap

import com.intellij.testFramework.EditorTestUtil; //导入依赖的package包/类
public void testHardWrap() throws Exception {
  configureFromFileText("a.xml",
                        "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n" +
                        "<svg version=\"1.1\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\">\n" +
                        "<g>\n" +
                        "        <path clip-path=\"url(#SVGID_2_)\" fill=\"#ffffff\" stroke=\"<selection>#000000</selection>\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-miterlimit=\"10\" d=\"M19.333,8.333V12c0,1.519-7.333,4-7.333,4s-7.333-2.481-7.333-4V8.333\"/>\n" +
                        "</g>\n" +
                        "</svg>");

  CodeStyleSettings clone = CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings().clone();
  clone.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = true;
  try {
    CodeStyleSettingsManager.getInstance(getProject()).setTemporarySettings(clone);
    EditorTestUtil.performTypingAction(getEditor(), 'x');
  }
  finally {
    CodeStyleSettingsManager.getInstance(getProject()).dropTemporarySettings();
  }
  checkResultByText("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n" +
                    "<svg version=\"1.1\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\">\n" +
                    "<g>\n" +
                    "        <path clip-path=\"url(#SVGID_2_)\" fill=\"#ffffff\" stroke=\"x\" stroke-width=\"2\" stroke-linecap=\"round\" \n" +
                    "              stroke-linejoin=\"round\" stroke-miterlimit=\"10\" d=\"M19.333,8.333V12c0,1.519-7.333,4-7.333,4s-7.333-2.481-7.333-4V8.333\"/>\n" +
                    "</g>\n" +
                    "</svg>");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:XmlEditorTest.java

示例8: testHardWrapInComment

import com.intellij.testFramework.EditorTestUtil; //导入依赖的package包/类
public void testHardWrapInComment() throws Exception {
  configureFromFileText("a.xml",
                        "<!-- Some very long and informative xml comment to trigger hard wrapping indeed. Too short? Dave, let me ask you something. Are hard wraps working? What do we live for? What ice-cream do you like? Who am I?????????????????????????????????????????????????????????????????????????????????????????????????<caret>-->");

  CodeStyleSettings clone = CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings().clone();
  clone.WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN = true;
  try {
    CodeStyleSettingsManager.getInstance(getProject()).setTemporarySettings(clone);
    EditorTestUtil.performTypingAction(getEditor(), '?');
  }
  finally {
    CodeStyleSettingsManager.getInstance(getProject()).dropTemporarySettings();
  }
  checkResultByText("<!-- Some very long and informative xml comment to trigger hard wrapping indeed. Too short? Dave, let me ask you \n" +
                    "something. Are hard wraps working? What do we live for? What ice-cream do you like? Who am I??????????????????????????????????????????????????????????????????????????????????????????????????-->");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:XmlEditorTest.java

示例9: testOnlyMinimalRangeIsRecalculatedOnDocumentChange

import com.intellij.testFramework.EditorTestUtil; //导入依赖的package包/类
public void testOnlyMinimalRangeIsRecalculatedOnDocumentChange() throws IOException {
  init("aa bb cc dd ee<caret> ff gg hh ii jj", TestFileType.TEXT);
  EditorTestUtil.configureSoftWraps(myEditor, 8);
  verifySoftWrapPositions(6, 12, 18, 24);

  final IncrementalCacheUpdateEvent[] event = new IncrementalCacheUpdateEvent[1];
  ((SoftWrapModelImpl)myEditor.getSoftWrapModel()).getApplianceManager().addListener(new SoftWrapAwareDocumentParsingListenerAdapter() {
    @Override
    public void onRecalculationEnd(@Nonnull IncrementalCacheUpdateEvent e) {
      assertNull(event[0]);
      event[0] = e;
    }
  });

  type(' ');

  verifySoftWrapPositions(6, 12, 19, 25);
  assertNotNull(event[0]);
  assertEquals(6, event[0].getStartOffset());
  assertEquals(19, event[0].getActualEndOffset());
}
 
开发者ID:consulo,项目名称:consulo,代码行数:22,代码来源:SoftWrapApplianceOnDocumentModificationTest.java

示例10: getPlaceholders

import com.intellij.testFramework.EditorTestUtil; //导入依赖的package包/类
public Pair<Document, List<AnswerPlaceholder>> getPlaceholders(String name, boolean useLength, boolean removeMarkers) {
  try {
    String text = StringUtil.convertLineSeparators(FileUtil.loadFile(new File(getBasePath(), name)));
    Document tempDocument = EditorFactory.getInstance().createDocument(text);
    if (removeMarkers) {
      EditorTestUtil.extractCaretAndSelectionMarkers(tempDocument);
    }
    List<AnswerPlaceholder> placeholders = getPlaceholders(tempDocument, useLength);
    return Pair.create(tempDocument, placeholders);
  }
  catch (IOException e) {
    LOG.error(e);
  }
  return Pair.create(null, null);
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:16,代码来源:CCTestCase.java

示例11: testInsertDeleteQuotes

import com.intellij.testFramework.EditorTestUtil; //导入依赖的package包/类
public void testInsertDeleteQuotes() throws Exception {
  configureByFile(BASE_PATH + "InsertDeleteQuote.cs");
  EditorTestUtil.performTypingAction(getEditor(), '"');
  checkResultByFile(BASE_PATH + "InsertDeleteQuote_after.cs");

  configureByFile(BASE_PATH+"InsertDeleteQuote_after.cs");
  EditorTestUtil.performTypingAction(getEditor(), BACKSPACE_FAKE_CHAR);
  checkResultByFile(BASE_PATH+"InsertDeleteQuote.cs");

  FileType extension = FileTypeManager.getInstance().getFileTypeByExtension("pl");
  assertTrue("Test is not set up correctly:"+extension, extension instanceof AbstractFileType);
  configureByFile(BASE_PATH + "InsertDeleteQuote.pl");
  EditorTestUtil.performTypingAction(getEditor(), '"');
  checkResultByFile(BASE_PATH + "InsertDeleteQuote_after.pl");

  configureByFile(BASE_PATH+"InsertDeleteQuote_after.pl");
  EditorTestUtil.performTypingAction(getEditor(), BACKSPACE_FAKE_CHAR);
  checkResultByFile(BASE_PATH+"InsertDeleteQuote.pl");

  configureByFile(BASE_PATH + "InsertDeleteQuote.aj");
  EditorTestUtil.performTypingAction(getEditor(), '"');
  checkResultByFile(BASE_PATH + "InsertDeleteQuote_after.aj");

  configureByFile(BASE_PATH+"InsertDeleteQuote_after.aj");
  EditorTestUtil.performTypingAction(getEditor(), BACKSPACE_FAKE_CHAR);
  checkResultByFile(BASE_PATH+"InsertDeleteQuote.aj");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:CustomFileTypeEditorTest.java

示例12: testInsertDeleteBracket

import com.intellij.testFramework.EditorTestUtil; //导入依赖的package包/类
public void testInsertDeleteBracket() throws Exception {
  configureByFile(BASE_PATH + "InsertDeleteBracket.cs");
  EditorTestUtil.performTypingAction(getEditor(), '[');
  checkResultByFile(BASE_PATH + "InsertDeleteBracket_after.cs");

  configureByFile(BASE_PATH+"InsertDeleteBracket_after.cs");
  EditorTestUtil.performTypingAction(getEditor(), BACKSPACE_FAKE_CHAR);
  checkResultByFile(BASE_PATH+"InsertDeleteBracket.cs");

  configureByFile(BASE_PATH+"InsertDeleteBracket_after.cs");
  EditorTestUtil.performTypingAction(getEditor(), ']');
  checkResultByFile(BASE_PATH + "InsertDeleteBracket_after2.cs");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:CustomFileTypeEditorTest.java

示例13: getDocumentationText

import com.intellij.testFramework.EditorTestUtil; //导入依赖的package包/类
private String getDocumentationText(String sourceEditorText) throws Exception {
  int caretPosition = sourceEditorText.indexOf(EditorTestUtil.CARET_TAG);
  if (caretPosition >= 0) {
    sourceEditorText = sourceEditorText.substring(0, caretPosition) + 
                       sourceEditorText.substring(caretPosition + EditorTestUtil.CARET_TAG.length());
  }
  PsiFile psiFile = PsiFileFactory.getInstance(myProject).createFileFromText(JavaLanguage.INSTANCE, sourceEditorText);
  return getDocumentationText(psiFile, caretPosition);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:JavaExternalDocumentationTest.java

示例14: doTest

import com.intellij.testFramework.EditorTestUtil; //导入依赖的package包/类
private void doTest() {
  DetectableIndentOptionsProvider provider = DetectableIndentOptionsProvider.getInstance();
  assertNotNull("DetectableIndentOptionsProvider not found", provider);
  String testName = getTestName(true);
  provider.setEnabledInTest(true);
  try {
    configureByFile(BASE_PATH + testName + ".java");
    EditorTestUtil.performTypingAction(getEditor(), '\n');
    checkResultByFile(BASE_PATH + testName + "_after.java");
  }
  finally {
    provider.setEnabledInTest(false);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:JavaDetectableIndentsTest.java

示例15: doTest

import com.intellij.testFramework.EditorTestUtil; //导入依赖的package包/类
private void doTest(String fileName) {
  configureByFile("/codeInsight/folding/" + fileName);
  EditorTestUtil.configureSoftWraps(myEditor, 120);
  runFoldingPass();
  deleteLine();
  runFoldingPass();
  // we just verify here that the operation completes normally - it was known to fail previously
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:FoldingExceptionTest.java


注:本文中的com.intellij.testFramework.EditorTestUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。