use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.
the class FindManagerTest method runAsyncTest.
private void runAsyncTest(String text, FindModel findModel) throws InterruptedException {
final Ref<FindResult> result = new Ref<>();
final CountDownLatch progressStarted = new CountDownLatch(1);
final ProgressIndicatorBase progressIndicatorBase = new ProgressIndicatorBase();
final Thread thread = new Thread(() -> ProgressManager.getInstance().runProcess(() -> {
try {
progressStarted.countDown();
result.set(myFindManager.findString(text, 0, findModel, new LightVirtualFile("foo.java")));
} catch (ProcessCanceledException ex) {
result.set(new FindResultImpl());
}
}, progressIndicatorBase), "runAsyncTest");
thread.start();
progressStarted.await();
thread.join(100);
progressIndicatorBase.cancel();
thread.join(500);
assertNotNull(result.get());
assertTrue(!result.get().isStringFound());
thread.join();
}
use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.
the class FindManagerTest method testFindExceptComments2.
public void testFindExceptComments2() {
FindModel findModel = FindManagerTestUtils.configureFindModel("oo");
String text = "//oooo";
findModel.setSearchContext(FindModel.SearchContext.EXCEPT_COMMENTS);
LightVirtualFile file = new LightVirtualFile("A.java", text);
FindResult findResult = myFindManager.findString(text, 0, findModel, file);
assertFalse(findResult.isStringFound());
}
use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.
the class FindManagerTest method testFindExceptComments.
public void testFindExceptComments() {
FindModel findModel = FindManagerTestUtils.configureFindModel("done");
String prefix = "/*";
String text = prefix + "done*/done";
findModel.setSearchContext(FindModel.SearchContext.EXCEPT_COMMENTS);
LightVirtualFile file = new LightVirtualFile("A.java", text);
FindResult findResult = myFindManager.findString(text, prefix.length(), findModel, file);
assertTrue(findResult.isStringFound());
assertTrue(findResult.getStartOffset() > prefix.length());
findModel.setRegularExpressions(true);
findResult = myFindManager.findString(text, prefix.length(), findModel, file);
assertTrue(findResult.isStringFound());
assertTrue(findResult.getStartOffset() > prefix.length());
}
use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.
the class FindManagerTest method testRegExpInString.
public void testRegExpInString() {
FindModel findModel = FindManagerTestUtils.configureFindModel("^*$");
String prefix = "<foo bar=\"";
String text = prefix + "\" />";
findModel.setSearchContext(FindModel.SearchContext.IN_STRING_LITERALS);
findModel.setRegularExpressions(true);
LightVirtualFile file = new LightVirtualFile("A.xml", text);
FindResult findResult = myFindManager.findString(text, prefix.length(), findModel, file);
assertTrue(findResult.isStringFound());
}
use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.
the class FindManagerTest method testFindExceptLiterals.
public void testFindExceptLiterals() {
FindModel findModel = FindManagerTestUtils.configureFindModel("done");
String prefix = "\"";
String text = prefix + "done\"done";
findModel.setSearchContext(FindModel.SearchContext.EXCEPT_STRING_LITERALS);
LightVirtualFile file = new LightVirtualFile("A.java", text);
FindResult findResult = myFindManager.findString(text, prefix.length(), findModel, file);
assertTrue(findResult.isStringFound());
assertTrue(findResult.getStartOffset() > prefix.length());
findModel.setRegularExpressions(true);
findResult = myFindManager.findString(text, prefix.length(), findModel, file);
assertTrue(findResult.isStringFound());
assertTrue(findResult.getStartOffset() > prefix.length());
}
Aggregations