use of com.intellij.testFramework.ExpectedHighlightingData in project intellij-community by JetBrains.
the class HighlightingTestBase method doCustomHighlighting.
protected void doCustomHighlighting(boolean checkWeakWarnings, Boolean includeExternalToolPass) {
final PsiFile file = myTestFixture.getFile();
final Document doc = myTestFixture.getEditor().getDocument();
ExpectedHighlightingData data = new ExpectedHighlightingData(doc, true, checkWeakWarnings, false, file);
data.init();
PsiDocumentManager.getInstance(myTestFixture.getProject()).commitAllDocuments();
Collection<HighlightInfo> highlights1 = doHighlighting(includeExternalToolPass);
data.checkResult(highlights1, doc.getText());
}
use of com.intellij.testFramework.ExpectedHighlightingData in project intellij-plugins by JetBrains.
the class SwfHighlightingTest method testLineMarkersInSwf.
@JSTestOptions({ JSTestOption.WithFlexFacet, JSTestOption.WithLineMarkers })
public void testLineMarkersInSwf() throws Exception {
final String testName = getTestName(false);
myAfterCommitRunnable = () -> FlexTestUtils.addLibrary(myModule, "lib", getTestDataPath() + getBasePath() + "/", testName + ".swc", null, null);
// actual test data is in library.swf; this file is here just because we need any file
configureByFile("/" + testName + ".as");
VirtualFile vFile = LocalFileSystem.getInstance().findFileByPath(getTestDataPath() + getBasePath() + "/" + testName + ".swc");
vFile = JarFileSystem.getInstance().getJarRootForLocalFile(vFile).findChild("library.swf");
myEditor = FileEditorManager.getInstance(myProject).openTextEditor(new OpenFileDescriptor(myProject, vFile, 0), false);
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
myFile = myPsiManager.findFile(vFile);
((EditorImpl) myEditor).setCaretActive();
vFile = LocalFileSystem.getInstance().findFileByPath(getTestDataPath() + getBasePath() + "/" + testName + ".as");
final String verificationText = StreamUtil.convertSeparators(VfsUtilCore.loadText(vFile));
checkHighlighting(new ExpectedHighlightingData(new DocumentImpl(verificationText), false, false, true, myFile));
}
use of com.intellij.testFramework.ExpectedHighlightingData in project kotlin by JetBrains.
the class AbstractLineMarkersTest method doTest.
public void doTest(String path) {
try {
String fileText = FileUtil.loadFile(new File(path));
ConfigLibraryUtil.configureLibrariesByDirective(myFixture.getModule(), PlatformTestUtil.getCommunityPath(), fileText);
myFixture.configureByFile(path);
Project project = myFixture.getProject();
Document document = myFixture.getEditor().getDocument();
ExpectedHighlightingData data = new ExpectedHighlightingData(document, false, false, false, myFixture.getFile());
data.init();
PsiDocumentManager.getInstance(project).commitAllDocuments();
myFixture.doHighlighting();
List<LineMarkerInfo> markers = DaemonCodeAnalyzerImpl.getLineMarkers(document, project);
try {
data.checkLineMarkers(markers, document.getText());
// the latter doesn't throw assertion error when some line markers are expected, but none are present.
if (FileUtil.loadFile(new File(path)).contains("<lineMarker") && markers.isEmpty()) {
throw new AssertionError("Some line markers are expected, but nothing is present at all");
}
} catch (AssertionError error) {
try {
String actualTextWithTestData = TagsTestDataUtil.insertInfoTags(markers, true, myFixture.getFile().getText());
KotlinTestUtils.assertEqualsToFile(new File(path), actualTextWithTestData);
} catch (FileComparisonFailure failure) {
throw new FileComparisonFailure(error.getMessage() + "\n" + failure.getMessage(), failure.getExpected(), failure.getActual(), failure.getFilePath());
}
}
assertNavigationElements(markers);
} catch (Exception exc) {
throw new RuntimeException(exc);
}
}
use of com.intellij.testFramework.ExpectedHighlightingData in project intellij-plugins by JetBrains.
the class ActionScriptHighlightingTest method testBadResolveOfSuperclass.
public void testBadResolveOfSuperclass() throws Exception {
final Module module2 = doCreateRealModuleIn("module2", myProject, FlexModuleType.getInstance());
final Ref<VirtualFile> fileFromModule2 = new Ref<>();
final Ref<Sdk> sdk1 = new Ref<>();
final Ref<Sdk> sdk2 = new Ref<>();
myAfterCommitRunnable = () -> {
sdk1.set(FlexTestUtils.createSdk(getTestDataPath() + BASE_PATH + "fake_sdk", "4.0.0"));
{
SdkModificator m = sdk1.get().getSdkModificator();
m.removeAllRoots();
m.addRoot(sdk1.get().getHomeDirectory().findChild("common_root"), OrderRootType.CLASSES);
m.addRoot(sdk1.get().getHomeDirectory().findChild("flex_root"), OrderRootType.CLASSES);
m.commitChanges();
}
sdk2.set(FlexTestUtils.createSdk(getTestDataPath() + BASE_PATH + "fake_sdk", "4.0.0"));
{
SdkModificator m = sdk2.get().getSdkModificator();
m.removeAllRoots();
m.addRoot(sdk2.get().getHomeDirectory().findChild("common_root"), OrderRootType.CLASSES);
m.addRoot(sdk2.get().getHomeDirectory().findChild("air_root"), OrderRootType.CLASSES);
m.commitChanges();
}
fileFromModule2.set(copyFileToModule(module2, getTestDataPath() + BASE_PATH + getTestName(false) + "2.as"));
};
configureByFile(BASE_PATH + getTestName(false) + "1.as");
FlexTestUtils.modifyConfigs(myProject, e -> {
FlexTestUtils.setSdk(e.getConfigurations(myModule)[0], sdk1.get());
FlexTestUtils.setSdk(e.getConfigurations(module2)[0], sdk2.get());
});
checkHighlighting(new ExpectedHighlightingData(myEditor.getDocument(), true, true, false, myFile));
myFile = PsiManager.getInstance(myProject).findFile(fileFromModule2.get());
myEditor = createEditor(fileFromModule2.get());
checkHighlighting(new ExpectedHighlightingData(myEditor.getDocument(), true, true, false, myFile));
}
use of com.intellij.testFramework.ExpectedHighlightingData in project intellij-plugins by JetBrains.
the class ActionScriptHighlightingInTextFieldTest method doTestForEditorTextField.
private void doTestForEditorTextField(JSExpressionCodeFragment fragment) throws Exception {
myFile = fragment;
Document document = PsiDocumentManager.getInstance(myProject).getDocument(fragment);
final JSEditorTextField editorTextField = new JSEditorTextField(myProject, document);
// initialize editor
editorTextField.addNotify();
myEditor = editorTextField.getEditor();
try {
checkHighlighting(new ExpectedHighlightingData(editorTextField.getDocument(), true, true, true, myFile));
} finally {
editorTextField.removeNotify();
UIUtil.dispatchAllInvocationEvents();
}
}
Aggregations