Reduce test's memory footprint; cleanup

This commit is contained in:
Roman Shevchenko
2012-02-29 20:46:07 +01:00
parent 504e4d1ac9
commit 27509c137d
3 changed files with 41 additions and 14 deletions
@@ -1,3 +1,18 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.intellij.codeInsight.daemon;
import com.intellij.ExtensionPoints;
@@ -266,10 +281,11 @@ public class LightAdvHighlightingTest extends LightDaemonAnalyzerTestCase {
public void testNamesHighlighting() throws Exception {
LanguageLevelProjectExtension.getInstance(getJavaFacade().getProject()).setLanguageLevel(LanguageLevel.JDK_1_5);
testFile(BASE_PATH + "/" + getTestName(false) + ".java").checkSymbolNames().test();
doTestFile(BASE_PATH + "/" + getTestName(false) + ".java").checkSymbolNames().test();
}
public void testMultiFieldDeclNames() throws Exception {
testFile(BASE_PATH + "/" + getTestName(false) + ".java").checkSymbolNames().test();
doTestFile(BASE_PATH + "/" + getTestName(false) + ".java").checkSymbolNames().test();
}
public static class MyAnnotator implements Annotator {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,12 +18,23 @@ package com.intellij.psi;
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
import com.intellij.openapi.application.ApplicationManager;
public class JavaSOEOnReparseTest extends LightDaemonAnalyzerTestCase {
private static final StringBuilder HUGE_EXPR;
static {
HUGE_EXPR = new StringBuilder("\"-\"");
for (int i = 0; i < 100000; i++) HUGE_EXPR.append("+\"b\"");
private StringBuilder myHugeExpr;
@Override
public void setUp() throws Exception {
super.setUp();
myHugeExpr = new StringBuilder("\"-\"");
for (int i = 0; i < 100000; i++) myHugeExpr.append("+\"b\"");
}
@Override
public void tearDown() throws Exception {
if (myHugeExpr != null) {
myHugeExpr.setLength(0);
myHugeExpr = null;
}
super.tearDown();
}
public void testOnHugeBinaryExprInFile() throws Exception {
@@ -42,7 +53,7 @@ public class JavaSOEOnReparseTest extends LightDaemonAnalyzerTestCase {
// replace small expression with huge binary one
ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override
public void run() {
getEditor().getDocument().replaceString(pos, pos + 2, HUGE_EXPR);
getEditor().getDocument().replaceString(pos, pos + 2, myHugeExpr);
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
}});
doTestConfiguredFile(false, false, null);
@@ -66,7 +77,7 @@ public class JavaSOEOnReparseTest extends LightDaemonAnalyzerTestCase {
// replace huge binary expression with small one
ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override
public void run() {
getEditor().getDocument().replaceString(pos, pos + HUGE_EXPR.length(), "\".\"");
getEditor().getDocument().replaceString(pos, pos + myHugeExpr.length(), "\".\"");
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
}});
doTestConfiguredFile(false, false, null);