本文整理汇总了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");
}
示例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());
}
示例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());
}
示例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);
}
示例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());
}
示例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>");
}
示例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??????????????????????????????????????????????????????????????????????????????????????????????????-->");
}
示例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());
}
示例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);
}
示例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");
}
示例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");
}
示例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);
}
示例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);
}
}
示例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
}