use of com.intellij.testFramework.TestDataProvider in project intellij-community by JetBrains.
the class JUnitRerunFailedTestsTest method testMultipleClassesInOneFile.
public void testMultipleClassesInOneFile() throws Exception {
myFixture.configureByText("a.java", "public class Test1 {<caret>} public class Test2 {}");
final IdeaTestApplication testApplication = IdeaTestApplication.getInstance();
try {
testApplication.setDataProvider(new TestDataProvider(myFixture.getProject()) {
@Override
public Object getData(@NonNls String dataId) {
if (CommonDataKeys.VIRTUAL_FILE_ARRAY.is(dataId)) {
return new VirtualFile[] { myFixture.getFile().getVirtualFile() };
}
return super.getData(dataId);
}
});
final PsiElement psiElement = myFixture.getFile().findElementAt(getEditor().getCaretModel().getOffset());
final PatternConfigurationProducer configurationProducer = RunConfigurationProducer.getInstance(PatternConfigurationProducer.class);
assertFalse(configurationProducer.isMultipleElementsSelected(new ConfigurationContext(psiElement)));
} finally {
testApplication.setDataProvider(null);
}
}
use of com.intellij.testFramework.TestDataProvider in project intellij-community by JetBrains.
the class JavaFileTemplatesTest method testManyTemplates.
public void testManyTemplates() {
FileTemplateManagerImpl templateManager = (FileTemplateManagerImpl) FileTemplateManager.getInstance(getProject());
templateManager.getState().RECENT_TEMPLATES.clear();
FileTemplate[] before = templateManager.getAllTemplates();
try {
for (int i = 0; i < 30; i++) {
templateManager.addTemplate("foo" + i, "java");
}
AnAction[] children = new CreateFromTemplateGroup().getChildren(new TestActionEvent(new TestDataProvider(getProject())));
assertEquals(3, children.length);
assertTrue(IdeBundle.message("action.from.file.template").equals(children[0].getTemplatePresentation().getText()));
} finally {
templateManager.setTemplates(FileTemplateManager.DEFAULT_TEMPLATES_CATEGORY, Arrays.asList(before));
templateManager.getState().RECENT_TEMPLATES.clear();
}
}
use of com.intellij.testFramework.TestDataProvider in project intellij-community by JetBrains.
the class JavaFileTemplatesTest method testCreateFromTemplateGroup.
public void testCreateFromTemplateGroup() {
myFixture.configureByText("foo.java", "");
AnAction[] children = new CreateFromTemplateGroup().getChildren(new TestActionEvent(new TestDataProvider(getProject())));
assertTrue(Stream.of(children).noneMatch(action -> isTemplateAction(action, "Class")));
assertTrue(Stream.of(children).anyMatch(action -> isTemplateAction(action, "Singleton")));
}
Aggregations