testframework refactoring: inline ExternalOutput; cleanup

This commit is contained in:
anna
2010-07-23 12:37:54 +04:00
parent 5db6c87168
commit 5c0fb7bc03
6 changed files with 23 additions and 133 deletions
@@ -29,7 +29,11 @@ public class DeferingPrinter implements Printer {
}
public void print(final String text, final ConsoleViewContentType contentType) {
myCompositePrintable.addLast(new ExternalOutput(text, contentType));
myCompositePrintable.addLast(new Printable() {
public void printOn(final Printer printer) {
printer.print(text, contentType);
}
});
}
public void onNewAvailable(final Printable printable) {
@@ -1,54 +0,0 @@
/*
* Copyright 2000-2009 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.execution.testframework;
import com.intellij.execution.ui.ConsoleViewContentType;
public class ExternalOutput implements Printable {
private final ConsoleViewContentType myType;
private final String myContents;
public ExternalOutput(final String contents, final ConsoleViewContentType type) {
myType = type;
myContents = contents;
}
public void printOn(final Printer printer) {
printer.print(myContents, myType);
}
}
@@ -18,10 +18,7 @@ package com.intellij.execution.testframework.ui;
import com.intellij.execution.filters.Filter;
import com.intellij.execution.filters.HyperlinkInfo;
import com.intellij.execution.filters.TextConsoleBuilderFactory;
import com.intellij.execution.testframework.ExternalOutput;
import com.intellij.execution.testframework.HyperLink;
import com.intellij.execution.testframework.Printable;
import com.intellij.execution.testframework.TestConsoleProperties;
import com.intellij.execution.testframework.*;
import com.intellij.execution.ui.ConsoleView;
import com.intellij.execution.ui.ConsoleViewContentType;
import com.intellij.execution.ui.ObservableConsoleView;
@@ -57,7 +54,11 @@ public abstract class BaseTestsOutputConsoleView implements ConsoleView, Observa
protected abstract TestResultsPanel createTestResultsPanel();
public void print(final String s, final ConsoleViewContentType contentType) {
printNew(new ExternalOutput(s, contentType));
printNew(new Printable() {
public void printOn(final Printer printer) {
printer.print(s, contentType);
}
});
}
public void clear() {
@@ -312,7 +312,11 @@ public abstract class TestObject implements JavaCommandLine {
currentTest.onOutput(text, consoleViewType);
}
else {
consoleView.getPrinter().onNewAvailable(new ExternalOutput(text, consoleViewType));
consoleView.getPrinter().onNewAvailable(new Printable() {
public void printOn(final Printer printer) {
printer.print(text, consoleViewType);
}
});
}
}
});
@@ -19,11 +19,11 @@ package com.intellij.execution.junit2;
import com.intellij.execution.Location;
import com.intellij.execution.junit2.events.*;
import com.intellij.execution.junit2.info.TestInfo;
import com.intellij.execution.junit2.segments.InputConsumer;
import com.intellij.execution.junit2.states.Statistics;
import com.intellij.execution.junit2.states.TestState;
import com.intellij.execution.testframework.*;
import com.intellij.execution.testframework.ui.PrintableTestProxy;
import com.intellij.execution.testframework.ui.TestsOutputConsolePrinter;
import com.intellij.execution.ui.ConsoleViewContentType;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.project.Project;
@@ -36,7 +36,7 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
public class TestProxy extends CompositePrintable implements PrintableTestProxy, InputConsumer, ChangingPrintable {
public class TestProxy extends CompositePrintable implements PrintableTestProxy, ChangingPrintable {
private static final Logger LOG = Logger.getInstance("#com.intellij.execution.junit2.TestProxy");
private final TestInfo myInfo;
@@ -67,8 +67,11 @@ public class TestProxy extends CompositePrintable implements PrintableTestProxy,
myPrinter.mark();
myMarked = true;
}
final ExternalOutput printable = new ExternalOutput(text, contentType);
addLast(printable);
addLast(new Printable() {
public void printOn(final Printer printer) {
printer.print(text, contentType);
}
});
}
public void addLast(final Printable printable) {
@@ -1,68 +0,0 @@
/*
* Copyright 2000-2009 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.execution.junit2;
import com.intellij.execution.junit2.info.ClassBasedInfo;
import com.intellij.execution.junit2.info.DisplayTestInfoExtractor;
import com.intellij.execution.junit2.segments.ObjectReader;
import com.intellij.util.containers.HashMap;
import java.util.List;
public class TestRootImpl implements TestRoot {
private final TestProxy myRootTest;
private final HashMap<String,TestProxy> myKnownDynamicParents = new HashMap<String, TestProxy>();
public TestRootImpl(final TestProxy rootTest) {
myRootTest = rootTest;
}
public void addChild(final TestProxy child) {
if (child == myRootTest)
return;
getDynamicParentFor(child).addChild(child);
}
private TestProxy getDynamicParentFor(final TestProxy child) {
final String parentClass = child.getInfo().getComment();
TestProxy dynamicParent = myKnownDynamicParents.get(parentClass);
if (dynamicParent == null) {
dynamicParent = new TestProxy(new DynamicParentInfo(parentClass));
myKnownDynamicParents.put(parentClass, dynamicParent);
myRootTest.addChild(dynamicParent);
}
return dynamicParent;
}
public TestProxy getRootTest() {
return myRootTest;
}
public List<TestProxy> getAllTests() {
return getRootTest().getAllTests();
}
private static class DynamicParentInfo extends ClassBasedInfo {
public DynamicParentInfo(final String className) {
super(DisplayTestInfoExtractor.FOR_CLASS);
setClassName(className);
}
public void readFrom(final ObjectReader reader) {
}
}
}