本文整理汇总了Java中com.intellij.testFramework.PlatformTestUtil类的典型用法代码示例。如果您正苦于以下问题:Java PlatformTestUtil类的具体用法?Java PlatformTestUtil怎么用?Java PlatformTestUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PlatformTestUtil类属于com.intellij.testFramework包,在下文中一共展示了PlatformTestUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: doTest
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
private void doTest(int version) throws IOException, JDOMException, StudySerializationUtils.StudyUnrecognizedFormatException {
final String name = PlatformTestUtil.getTestName(this.name.getMethodName(), true);
final Path before = getTestDataPath().resolve(name + ".xml");
final Path after = getTestDataPath().resolve(name + ".after.xml");
Element element = JdomKt.loadElement(before);
Element converted = element;
switch (version) {
case 1:
converted = StudySerializationUtils.Xml.convertToSecondVersion(element);
break;
case 3:
converted = StudySerializationUtils.Xml.convertToForthVersion(element);
break;
case 4:
converted = StudySerializationUtils.Xml.convertToFifthVersion(element);
break;
}
assertTrue(JDOMUtil.areElementsEqual(converted, JdomKt.loadElement(after)));
}
开发者ID:medvector,项目名称:educational-plugin,代码行数:20,代码来源:StudyMigrationTest.java
示例2: testInheritingSettingsFromParentAndAlignCorrectly
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testInheritingSettingsFromParentAndAlignCorrectly() throws Exception {
createProjectPom("<groupId>test</groupId>" +
"<artifactId>parent</artifactId>" +
"<version>1</version>" +
"<build>" +
" <directory>custom</directory>" +
"</build>");
VirtualFile module = createModulePom("module",
"<parent>" +
" <groupId>test</groupId>" +
" <artifactId>parent</artifactId>" +
" <version>1</version>" +
"</parent>");
MavenModel p = readProject(module);
PlatformTestUtil.assertPathsEqual(pathFromBasedir(module.getParent(), "custom"), p.getBuild().getDirectory());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:MavenProjectReaderTest.java
示例3: testInfoTestAttributes
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testInfoTestAttributes() throws Exception {
LanguageExtensionPoint<Annotator> extension = new LanguageExtensionPoint<Annotator>();
extension.language="TEXT";
extension.implementationClass = TestAnnotator.class.getName();
PlatformTestUtil.registerExtension(ExtensionPointName.create(LanguageAnnotators.EP_NAME), extension, getTestRootDisposable());
myFixture.configureByText(PlainTextFileType.INSTANCE, "foo");
EditorColorsScheme scheme = new EditorColorsSchemeImpl(new DefaultColorsScheme()){{initFonts();}};
scheme.setAttributes(HighlighterColors.TEXT, new TextAttributes(Color.black, Color.white, null, null, Font.PLAIN));
((EditorEx)myFixture.getEditor()).setColorsScheme(scheme);
myFixture.doHighlighting();
MarkupModel model = DocumentMarkupModel.forDocument(myFixture.getEditor().getDocument(), getProject(), false);
RangeHighlighter[] highlighters = model.getAllHighlighters();
assertEquals(1, highlighters.length);
TextAttributes attributes = highlighters[0].getTextAttributes();
assertNotNull(attributes);
assertNull(attributes.getBackgroundColor());
assertNull(attributes.getForegroundColor());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:DocumentMarkupModelTest.java
示例4: testManyPointersUpdatePerformance
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testManyPointersUpdatePerformance() throws IOException {
LoggingListener listener = new LoggingListener();
final List<VFileEvent> events = new ArrayList<VFileEvent>();
final File ioTempDir = createTempDirectory();
final VirtualFile temp = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(ioTempDir);
for (int i=0; i<100000; i++) {
myVirtualFilePointerManager.create(VfsUtilCore.pathToUrl("/a/b/c/d/" + i), disposable, listener);
events.add(new VFileCreateEvent(this, temp, "xxx" + i, false, true));
}
PlatformTestUtil.startPerformanceTest("vfp update", 10000, new ThrowableRunnable() {
@Override
public void run() throws Throwable {
for (int i=0; i<100; i++) {
// simulate VFS refresh events since launching the actual refresh is too slow
myVirtualFilePointerManager.before(events);
myVirtualFilePointerManager.after(events);
}
}
}).assertTiming();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:VirtualFilePointerTest.java
示例5: testModulesSelector
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testModulesSelector() throws ConfigurationException {
if (PlatformTestUtil.COVERAGE_ENABLED_BUILD) return;
Module module1 = getModule1();
Module module2 = getModule2();
JUnitConfigurable editor = new JUnitConfigurable(myProject);
try {
JUnitConfiguration configuration = createConfiguration(findTestA(module2));
editor.getComponent(); // To get all the watchers installed.
Configurable configurable = new RunConfigurationConfigurableAdapter(editor, configuration);
JComboBox comboBox = editor.getModulesComponent();
configurable.reset();
assertFalse(configurable.isModified());
assertEquals(module2.getName(), ((Module)comboBox.getSelectedItem()).getName());
assertEquals(ModuleManager.getInstance(myProject).getModules().length + 1, comboBox.getModel().getSize()); //no module
comboBox.setSelectedItem(module1);
assertTrue(configurable.isModified());
configurable.apply();
assertFalse(configurable.isModified());
assertEquals(Collections.singleton(module1), ContainerUtilRt.newHashSet(configuration.getModules()));
}
finally {
Disposer.dispose(editor);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:ConfigurationsTest.java
示例6: testCreatingApplicationConfiguration
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testCreatingApplicationConfiguration() throws ConfigurationException {
if (PlatformTestUtil.COVERAGE_ENABLED_BUILD) return;
ApplicationConfiguration configuration = new ApplicationConfiguration(null, myProject, ApplicationConfigurationType.getInstance());
ApplicationConfigurable editor = new ApplicationConfigurable(myProject);
try {
editor.getComponent(); // To get all the watchers installed.
Configurable configurable = new RunConfigurationConfigurableAdapter(editor, configuration);
configurable.reset();
CommonJavaParametersPanel javaParameters = editor.getCommonProgramParameters();
javaParameters.setProgramParameters("prg");
javaParameters.setVMParameters("vm");
javaParameters.setWorkingDirectory("dir");
assertTrue(configurable.isModified());
configurable.apply();
assertEquals("prg", configuration.getProgramParameters());
assertEquals("vm", configuration.getVMParameters());
assertEquals("dir", configuration.getWorkingDirectory());
}
finally {
Disposer.dispose(editor);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:ConfigurationsTest.java
示例7: testBigFile
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testBigFile() throws Exception {
configureByFiles(null, getVirtualFile(getTestName(false) + ".xml"), getVirtualFile("buildserver.xml"), getVirtualFile("buildserver.properties"));
try {
myIgnoreInfos = true;
PlatformTestUtil.startPerformanceTest("Should be quite performant !", 25000, new ThrowableRunnable() {
@Override
public void run() {
doDoTest(true, false);
}
}).cpuBound().assertTiming();
}
finally {
myIgnoreInfos = false;
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:AntHighlightingTest.java
示例8: test
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void test() throws IOException {
File dir = Files.createTempDir();
try {
assertNotNull(FileResourceRepository.get(dir));
// We shouldn't clear it out immediately on GC *eligibility*:
System.gc();
assertNotNull(FileResourceRepository.getCached(dir));
// However, in low memory conditions we should:
try {
PlatformTestUtil.tryGcSoftlyReachableObjects();
} catch (Throwable t) {
// The above method can throw java.lang.OutOfMemoryError; that's fine for this test
}
System.gc();
assertNull(FileResourceRepository.getCached(dir));
}
finally {
FileUtil.delete(dir);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:FileResourceRepositoryTest.java
示例9: testASTBecomesInvalidOnExternalChange
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testASTBecomesInvalidOnExternalChange() {
final String text = "class A{}";
final PsiJavaFile file = (PsiJavaFile)myFixture.addFileToProject("a.java", text);
PsiElement leaf = file.findElementAt(5);
PlatformTestUtil.tryGcSoftlyReachableObjects();
assertNull(PsiDocumentManager.getInstance(getProject()).getCachedDocument(file));
new WriteCommandAction.Simple(getProject()) {
@Override
protected void run() throws Throwable {
VfsUtil.saveText(file.getVirtualFile(), text + " ");
}
}.execute();
assertTrue(file.isValid());
assertFalse(leaf.isValid());
assertNotSame(leaf, file.findElementAt(5));
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:MiscPsiTest.java
示例10: testClassShouldNotAppearWithoutEvents_WithoutPsi
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testClassShouldNotAppearWithoutEvents_WithoutPsi() throws IOException {
final GlobalSearchScope allScope = GlobalSearchScope.allScope(getProject());
final JavaPsiFacade facade = JavaPsiFacade.getInstance(getProject());
final PsiManager psiManager = PsiManager.getInstance(getProject());
final PsiModificationTracker tracker = psiManager.getModificationTracker();
final VirtualFile file = myFixture.getTempDirFixture().createFile("Foo.java", "");
final Document document = FileDocumentManager.getInstance().getDocument(file);
assertNotNull(document);
assertNull(facade.findClass("Foo", allScope));
long count1 = tracker.getJavaStructureModificationCount();
PlatformTestUtil.tryGcSoftlyReachableObjects();
assertNull(PsiDocumentManager.getInstance(getProject()).getCachedPsiFile(document));
document.insertString(0, "class Foo {}");
assertFalse(count1 == tracker.getJavaStructureModificationCount());
assertTrue(PsiDocumentManager.getInstance(getProject()).isCommitted(document));
assertNotNull(facade.findClass("Foo", allScope));
PsiJavaFile psiFile = (PsiJavaFile)psiManager.findFile(file);
assertSize(1, psiFile.getClasses());
assertEquals("class Foo {}", psiFile.getText());
assertEquals("class Foo {}", psiFile.getNode().getText());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:PsiModificationTrackerTest.java
示例11: testClassShouldNotDisappearWithoutEvents_NoDocument
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testClassShouldNotDisappearWithoutEvents_NoDocument() throws IOException {
PsiModificationTracker tracker = PsiManager.getInstance(getProject()).getModificationTracker();
final PsiManagerEx psiManager = (PsiManagerEx)PsiManager.getInstance(getProject());
final VirtualFile file = myFixture.addFileToProject("Foo.java", "class Foo {}").getVirtualFile();
assertNotNull(JavaPsiFacade.getInstance(getProject()).findClass("Foo", GlobalSearchScope.allScope(getProject())));
long count1 = tracker.getJavaStructureModificationCount();
// gc softly-referenced file and document
PlatformTestUtil.tryGcSoftlyReachableObjects();
assertNull(FileDocumentManager.getInstance().getCachedDocument(file));
assertNull(psiManager.getFileManager().getCachedPsiFile(file));
VfsUtil.saveText(file, "");
assertNull(FileDocumentManager.getInstance().getCachedDocument(file));
assertNull(JavaPsiFacade.getInstance(getProject()).findClass("Foo", GlobalSearchScope.allScope(getProject())));
assertFalse(count1 == tracker.getJavaStructureModificationCount());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PsiModificationTrackerTest.java
示例12: testClassShouldNotDisappearWithoutEvents_ParentVirtualDirectoryDeleted
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testClassShouldNotDisappearWithoutEvents_ParentVirtualDirectoryDeleted() throws IOException {
PsiModificationTracker tracker = PsiManager.getInstance(getProject()).getModificationTracker();
final PsiManagerEx psiManager = (PsiManagerEx)PsiManager.getInstance(getProject());
final VirtualFile file = myFixture.addFileToProject("foo/Foo.java", "package foo; class Foo {}").getVirtualFile();
assertNotNull(JavaPsiFacade.getInstance(getProject()).findClass("foo.Foo", GlobalSearchScope.allScope(getProject())));
long count1 = tracker.getJavaStructureModificationCount();
// gc softly-referenced file and document
PlatformTestUtil.tryGcSoftlyReachableObjects();
assertNull(FileDocumentManager.getInstance().getCachedDocument(file));
assertNull(psiManager.getFileManager().getCachedPsiFile(file));
file.getParent().delete(this);
assertNull(JavaPsiFacade.getInstance(getProject()).findClass("foo.Foo", GlobalSearchScope.allScope(getProject())));
assertFalse(count1 == tracker.getJavaStructureModificationCount());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PsiModificationTrackerTest.java
示例13: testLanguageLevelChange
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testLanguageLevelChange() {
//noinspection unused
PsiFile psiFile = myFixture.addFileToProject("Foo.java", "class Foo {}");
GlobalSearchScope scope = GlobalSearchScope.allScope(getProject());
PlatformTestUtil.tryGcSoftlyReachableObjects();
PsiClass psiClass = JavaPsiFacade.getInstance(getProject()).findClass("Foo", scope);
assertNotNull(psiClass);
long count = PsiManager.getInstance(getProject()).getModificationTracker().getJavaStructureModificationCount();
IdeaTestUtil.setModuleLanguageLevel(myFixture.getModule(), LanguageLevel.JDK_1_3);
assertTrue(count != PsiManager.getInstance(getProject()).getModificationTracker().getJavaStructureModificationCount());
psiClass = (JavaPsiFacade.getInstance(getProject()).findClass("Foo", scope));
assertNotNull(psiClass);
assertTrue(psiClass.isValid());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:PsiModificationTrackerTest.java
示例14: testMultipleClasses
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testMultipleClasses() throws Exception {
String rootBefore = getRoot();
PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk17());
final VirtualFile root = PsiTestUtil.createTestProjectStructure(myProject, myModule, rootBefore, myFilesToDelete);
final PsiClass aClass = myJavaFacade.findClass("pack1.Klass");
assertNotNull(aClass);
final PsiFile containingFile = aClass.getContainingFile();
assertTrue(CopyHandler.canCopy(new PsiElement[]{containingFile}));
assertFalse(CopyHandler.canClone(new PsiElement[]{containingFile}));
PsiPackage pack2 = myJavaFacade.findPackage("pack2");
final PsiDirectory targetDirectory = pack2.getDirectories()[0];
CopyHandler.doCopy(new PsiElement[]{containingFile}, targetDirectory);
VirtualFile fileAfter = root.findFileByRelativePath("pack2/Klass.java");
VirtualFile fileExpected = root.findFileByRelativePath("pack2/Klass.expected.java");
PlatformTestUtil.assertFilesEqual(fileExpected, fileAfter);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:CopyTest.java
示例15: doTest
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
private void doTest(String className) throws Exception {
String rootBefore = getRoot() + "/before";
PsiTestUtil.removeAllRoots(myModule, IdeaTestUtil.getMockJdk17());
final VirtualFile rootDir = PsiTestUtil.createTestProjectStructure(myProject, myModule, rootBefore, myFilesToDelete);
PsiClass classToInline = myJavaFacade.findClass(className, ProjectScope.getAllScope(myProject));
assertEquals(null, InlineToAnonymousClassHandler.getCannotInlineMessage(classToInline));
InlineToAnonymousClassProcessor processor = new InlineToAnonymousClassProcessor(myProject,
classToInline,
null, false, false, false);
UsageInfo[] usages = processor.findUsages();
MultiMap<PsiElement,String> conflicts = processor.getConflicts(usages);
assertEquals(0, conflicts.size());
processor.run();
String rootAfter = getRoot() + "/after";
VirtualFile rootDir2 = LocalFileSystem.getInstance().findFileByPath(rootAfter.replace(File.separatorChar, '/'));
myProject.getComponent(PostprocessReformattingAspect.class).doPostponedFormatting();
PlatformTestUtil.assertDirectoriesEqual(rootDir2, rootDir);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:InlineToAnonymousClassMultifileTest.java
示例16: testGetPathPerformance
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testGetPathPerformance() throws IOException, InterruptedException {
final File dir = createTempDirectory();
String path = dir.getPath() + StringUtil.repeat("/xxx", 50) + "/fff.txt";
File ioFile = new File(path);
boolean b = ioFile.getParentFile().mkdirs();
assertTrue(b);
boolean c = ioFile.createNewFile();
assertTrue(c);
final VirtualFile file = LocalFileSystem.getInstance().refreshAndFindFileByPath(ioFile.getPath().replace(File.separatorChar, '/'));
assertNotNull(file);
PlatformTestUtil.startPerformanceTest("VF.getPath() performance failed", 4000, new ThrowableRunnable() {
@Override
public void run() {
for (int i = 0; i < 1000000; ++i) {
file.getPath();
}
}
}).cpuBound().assertTiming();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:VfsUtilPerformanceTest.java
示例17: testCustomAttrsPerformance
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testCustomAttrsPerformance() throws Throwable {
myFixture.copyFileToProject("dom/resources/bigfile.xml", "res/values/bigfile.xml");
myFixture.copyFileToProject("dom/resources/bigattrs.xml", "res/values/bigattrs.xml");
myFixture.copyFileToProject("dom/resources/bigattrs.xml", "res/values/bigattrs1.xml");
myFixture.copyFileToProject("dom/resources/bigattrs.xml", "res/values/bigattrs2.xml");
myFixture.copyFileToProject("dom/resources/bigattrs.xml", "res/values/bigattrs3.xml");
VirtualFile f = copyFileToProject("bigfile.xml");
myFixture.configureFromExistingVirtualFile(f);
PlatformTestUtil.startPerformanceTest("android custom attrs highlighting is slow", 800, new ThrowableRunnable() {
@Override
public void run() throws Throwable {
myFixture.doHighlighting();
}
}).attempts(2).cpuBound().usesAllCPUCores().assertTiming();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:AndroidLayoutDomTest.java
示例18: _testReparsePerformance
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void _testReparsePerformance() throws Exception {
final String text = loadFile("performance2.xml");
final PsiFile file = createFile("test.xml", text);
transformAllChildren(file.getNode());
final Document doc = PsiDocumentManager.getInstance(getProject()).getDocument(file);
System.gc();
System.gc();
new WriteCommandAction(getProject(), file) {
@Override
protected void run(@NotNull final Result result) throws Throwable {
PlatformTestUtil.startPerformanceTest("XML reparse using PsiBuilder", 2500, new ThrowableRunnable() {
@Override
public void run() throws Exception {
for (int i = 0; i < 10; i++) {
final long tm = System.currentTimeMillis();
doc.insertString(0, "<additional root=\"tag\"/>");
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
System.out.println("Reparsed for: " + (System.currentTimeMillis() - tm));
}
}
}).cpuBound().assertTiming();
}
}.execute();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:XmlParsingTest.java
示例19: testRemappingToInstalledPluginExtension
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
public void testRemappingToInstalledPluginExtension() throws WriteExternalException, InvalidDataException {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
myFileTypeManager.associatePattern(PlainTextFileType.INSTANCE, "*.fromPlugin");
}
});
Element element = myFileTypeManager.getState();
String s = JDOMUtil.writeElement(element);
final AbstractFileType typeFromPlugin = new AbstractFileType(new SyntaxTable());
PlatformTestUtil.registerExtension(FileTypeFactory.FILE_TYPE_FACTORY_EP, new FileTypeFactory() {
@Override
public void createFileTypes(@NotNull FileTypeConsumer consumer) {
consumer.consume(typeFromPlugin, "fromPlugin");
}
}, getTestRootDisposable());
myFileTypeManager.initStandardFileTypes();
myFileTypeManager.loadState(element);
myFileTypeManager.initComponent();
Map<FileNameMatcher, Pair<FileType, Boolean>> mappings = myFileTypeManager.getRemovedMappings();
assertEquals(1, mappings.size());
assertEquals(typeFromPlugin, mappings.values().iterator().next().first);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:FileTypesTest.java
示例20: performance
import com.intellij.testFramework.PlatformTestUtil; //导入依赖的package包/类
@Test
public void performance() throws Exception {
final IElementType[] elementTypes = IElementType.enumerate(IElementType.TRUE);
final TokenSet set = TokenSet.create();
final int shift = new Random().nextInt(500000);
PlatformTestUtil.startPerformanceTest("TokenSet.contains() performance", 25, new ThrowableRunnable() {
@Override
public void run() throws Throwable {
for (int i = 0; i < 1000000; i++) {
final IElementType next = elementTypes[((i + shift) % elementTypes.length)];
assertFalse(set.contains(next));
}
}
}).cpuBound().assertTiming();
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:TokenSetTest.java
注:本文中的com.intellij.testFramework.PlatformTestUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论