update copyright
[fedora-idea.git] / plugins / xpath / xpath-lang / test / org / intellij / lang / xpath / xslt / XsltHighlightingTest.java
blob23a96b54bccc43baa212327869cdbabe55731f25
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.intellij.lang.xpath.xslt;
18 import com.intellij.codeHighlighting.TextEditorHighlightingPass;
19 import com.intellij.codeInsight.daemon.impl.DaemonProgressIndicator;
20 import com.intellij.codeInsight.daemon.impl.TextEditorHighlightingPassRegistrarEx;
21 import com.intellij.openapi.application.ApplicationManager;
22 import com.intellij.openapi.progress.ProgressIndicator;
23 import com.intellij.openapi.project.Project;
24 import com.intellij.openapi.util.Computable;
25 import com.intellij.psi.PsiDocumentManager;
26 import com.intellij.util.ArrayUtil;
27 import org.intellij.lang.xpath.TestBase;
28 import org.intellij.lang.xpath.xslt.impl.XsltStuffProvider;
30 import java.util.List;
33 * Created by IntelliJ IDEA.
34 * User: sweinreuter
35 * Date: 12.06.2008
37 public class XsltHighlightingTest extends TestBase {
38 @Override
39 protected void setUp() throws Exception {
40 super.setUp();
41 myFixture.enableInspections(new XsltStuffProvider(null).getInspectionClasses());
44 public void xtestBackwardIncludedVariable() throws Throwable {
45 doXsltHighlighting();
48 public void testUnknownTemplate() throws Throwable {
49 doXsltHighlighting();
52 public void testUnknownMode() throws Throwable {
53 doXsltHighlighting();
56 public void testCurrentModeXslt2() throws Throwable {
57 doXsltHighlighting();
60 public void testUndeclaredParam() throws Throwable {
61 doXsltHighlighting();
64 public void testMissingParam() throws Throwable {
65 doXsltHighlighting();
68 public void testUnusedVariable() throws Throwable {
69 doXsltHighlighting();
72 public void testShadowedVariable() throws Throwable {
73 doXsltHighlighting();
76 public void testValidPatterns() throws Throwable {
77 doXsltHighlighting();
80 public void testInvalidPattern1() throws Throwable {
81 doXsltHighlighting();
84 public void testInvalidPattern2() throws Throwable {
85 doXsltHighlighting();
88 public void testInvalidPattern3() throws Throwable {
89 doXsltHighlighting();
92 public void testInvalidPattern4() throws Throwable {
93 doXsltHighlighting();
96 public void testInvalidPattern5() throws Throwable {
97 doXsltHighlighting();
100 public void xtestPerformance() throws Throwable {
101 myFixture.configureByFile(getTestFileName() + ".xsl");
102 final long l = runHighlighting();
103 assertTrue("Highlighting took " + l + "ms", l < 6000);
106 private long runHighlighting() {
107 final Project project = myFixture.getProject();
108 PsiDocumentManager.getInstance(project).commitAllDocuments();
110 return ApplicationManager.getApplication().runReadAction(new Computable<Long>() {
111 public Long compute() {
112 final long l = System.currentTimeMillis();
113 List<TextEditorHighlightingPass> passes =
114 TextEditorHighlightingPassRegistrarEx.getInstanceEx(myFixture.getProject()).instantiatePasses(myFixture.getFile(), myFixture.getEditor(), ArrayUtil.EMPTY_INT_ARRAY);
115 ProgressIndicator progress = new DaemonProgressIndicator();
116 for (TextEditorHighlightingPass pass : passes) {
117 pass.collectInformation(progress);
119 return System.currentTimeMillis() - l;
124 private void doXsltHighlighting(String... moreFiles) throws Throwable {
125 final String name = getTestFileName();
126 myFixture.testHighlighting(true, false, false, ArrayUtil.append(moreFiles, name + ".xsl"));
129 protected String getSubPath() {
130 return "xslt/highlighting";