mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
testframework refactoring: paused printer & unbound output refactored
This commit is contained in:
+1
-5
@@ -149,7 +149,7 @@ public class SMTestProxy extends AbstractTestProxy {
|
||||
child.setParent(this);
|
||||
// if parent is being printed then all childs output
|
||||
// should be also send to the same printer
|
||||
setChildPrinter(child);
|
||||
child.setPrinter(myPrinter);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@@ -324,10 +324,6 @@ public class SMTestProxy extends AbstractTestProxy {
|
||||
return myState.wasLaunched();
|
||||
}
|
||||
|
||||
public boolean isRoot() {
|
||||
return getParent() == null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prints this proxy and all its children on given printer
|
||||
|
||||
+1
-2
@@ -52,7 +52,7 @@ public class SMTRunnerConsoleView extends BaseTestsOutputConsoleView {
|
||||
public SMTRunnerConsoleView(final TestConsoleProperties consoleProperties, final RunnerSettings runnerSettings,
|
||||
final ConfigurationPerRunnerSettings configurationPerRunnerSettings,
|
||||
@Nullable final String splitterProperty) {
|
||||
super(consoleProperties);
|
||||
super(consoleProperties, null);
|
||||
myRunnerSettings = runnerSettings;
|
||||
myConfigurationPerRunnerSettings = configurationPerRunnerSettings;
|
||||
mySplitterProperty = splitterProperty;
|
||||
@@ -109,6 +109,5 @@ public class SMTRunnerConsoleView extends BaseTestsOutputConsoleView {
|
||||
}
|
||||
|
||||
public void attachToProcess(final ProcessHandler processHandler) {
|
||||
getPrinter().setCollectOutput(false);
|
||||
}
|
||||
}
|
||||
|
||||
+12
-12
@@ -46,7 +46,7 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
final ConfigurationPerRunnerSettings configurationPerRunnerSettings) {
|
||||
super(consoleProperties, runnerSettings, configurationPerRunnerSettings);
|
||||
|
||||
myTestsOutputConsolePrinter = new TestsOutputConsolePrinter(MyConsoleView.this, consoleProperties) {
|
||||
myTestsOutputConsolePrinter = new TestsOutputConsolePrinter(MyConsoleView.this, consoleProperties, null) {
|
||||
@Override
|
||||
public void print(final String text, final ConsoleViewContentType contentType) {
|
||||
myMockResetablePrinter.print(text, contentType);
|
||||
@@ -86,7 +86,7 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
}
|
||||
|
||||
public void testPrintTestProxy() {
|
||||
mySimpleTest.setPrintListener(myMockResetablePrinter);
|
||||
mySimpleTest.setPrinter(myMockResetablePrinter);
|
||||
mySimpleTest.addLast(new Printable() {
|
||||
public void printOn(final Printer printer) {
|
||||
printer.print("std out", ConsoleViewContentType.NORMAL_OUTPUT);
|
||||
@@ -98,7 +98,7 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
}
|
||||
|
||||
public void testAddStdOut() {
|
||||
mySimpleTest.setPrintListener(myMockResetablePrinter);
|
||||
mySimpleTest.setPrinter(myMockResetablePrinter);
|
||||
|
||||
mySimpleTest.addStdOutput("one", ProcessOutputTypes.STDOUT);
|
||||
assertStdOutput(myMockResetablePrinter, "one");
|
||||
@@ -114,14 +114,14 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
}
|
||||
|
||||
public void testAddStdSys() {
|
||||
mySimpleTest.setPrintListener(myMockResetablePrinter);
|
||||
mySimpleTest.setPrinter(myMockResetablePrinter);
|
||||
|
||||
mySimpleTest.addSystemOutput("sys");
|
||||
assertAllOutputs(myMockResetablePrinter, "", "", "sys");
|
||||
}
|
||||
|
||||
public void testPrintTestProxy_Order() {
|
||||
mySimpleTest.setPrintListener(myMockResetablePrinter);
|
||||
mySimpleTest.setPrinter(myMockResetablePrinter);
|
||||
|
||||
sendToTestProxyStdOut(mySimpleTest, "first ");
|
||||
sendToTestProxyStdOut(mySimpleTest, "second");
|
||||
@@ -132,7 +132,7 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
public void testSetPrintListener_ForExistingChildren() {
|
||||
mySuite.addChild(mySimpleTest);
|
||||
|
||||
mySuite.setPrintListener(myMockResetablePrinter);
|
||||
mySuite.setPrinter(myMockResetablePrinter);
|
||||
|
||||
sendToTestProxyStdOut(mySimpleTest, "child ");
|
||||
sendToTestProxyStdOut(mySuite, "root");
|
||||
@@ -141,7 +141,7 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
}
|
||||
|
||||
public void testSetPrintListener_OnNewChild() {
|
||||
mySuite.setPrintListener(myMockResetablePrinter);
|
||||
mySuite.setPrinter(myMockResetablePrinter);
|
||||
|
||||
sendToTestProxyStdOut(mySuite, "root ");
|
||||
|
||||
@@ -299,7 +299,7 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
|
||||
myEventsProcessor.onSuiteStarted("suite", null);
|
||||
final SMTestProxy suite = myEventsProcessor.getCurrentSuite();
|
||||
suite.setPrintListener(myMockResetablePrinter);
|
||||
suite.setPrinter(myMockResetablePrinter);
|
||||
myEventsProcessor.onError("error msg:suite", "method1:1\nmethod2:2");
|
||||
|
||||
assertAllOutputs(myMockResetablePrinter, "", "\n" +
|
||||
@@ -387,13 +387,13 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
}
|
||||
|
||||
public void testOnUncapturedOutput_BeforeProcessStarted() {
|
||||
myRootSuite.setPrintListener(myMockResetablePrinter);
|
||||
myRootSuite.setPrinter(myMockResetablePrinter);
|
||||
|
||||
assertOnUncapturedOutput();
|
||||
}
|
||||
|
||||
public void testOnUncapturedOutput_BeforeFirstSuiteStarted() {
|
||||
myRootSuite.setPrintListener(myMockResetablePrinter);
|
||||
myRootSuite.setPrinter(myMockResetablePrinter);
|
||||
|
||||
myEventsProcessor.onStartTesting();
|
||||
assertOnUncapturedOutput();
|
||||
@@ -405,7 +405,7 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
myEventsProcessor.onSuiteStarted("my suite", null);
|
||||
final SMTestProxy mySuite = myEventsProcessor.getCurrentSuite();
|
||||
assertTrue(mySuite != myRootSuite);
|
||||
mySuite.setPrintListener(myMockResetablePrinter);
|
||||
mySuite.setPrinter(myMockResetablePrinter);
|
||||
|
||||
assertOnUncapturedOutput();
|
||||
}
|
||||
@@ -476,7 +476,7 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
myEventsProcessor.onTestStarted(testName, null);
|
||||
final SMTestProxy proxy =
|
||||
myEventsProcessor.getProxyByFullTestName(myEventsProcessor.getFullTestName(testName));
|
||||
proxy.setPrintListener(myMockResetablePrinter);
|
||||
proxy.setPrinter(myMockResetablePrinter);
|
||||
return proxy;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -78,11 +78,11 @@ public class SMTestProxyTest extends BaseSMTRunnerTestCase {
|
||||
|
||||
public void testIsRoot() {
|
||||
final SMTestProxy rootTest = createTestProxy("root");
|
||||
assertTrue(rootTest.isRoot());
|
||||
assertTrue(rootTest.getParent() == null);
|
||||
|
||||
rootTest.addChild(mySimpleTest);
|
||||
|
||||
assertFalse(mySimpleTest.isRoot());
|
||||
assertFalse(mySimpleTest.getParent() == null);
|
||||
}
|
||||
|
||||
public void testTestStarted() {
|
||||
|
||||
+7
-14
@@ -21,17 +21,16 @@
|
||||
package com.intellij.execution.testframework;
|
||||
|
||||
import com.intellij.execution.Location;
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractTestProxy extends CompositePrintable {
|
||||
public static final DataKey<AbstractTestProxy> DATA_KEY = DataKey.create("testProxy");
|
||||
protected Printer myPrinter = Printer.DEAF;
|
||||
protected Printer myPrinter = null;
|
||||
|
||||
public abstract boolean isInProgress();
|
||||
|
||||
@@ -60,22 +59,16 @@ public abstract class AbstractTestProxy extends CompositePrintable {
|
||||
|
||||
public abstract List<? extends AbstractTestProxy> getAllTests();
|
||||
|
||||
public abstract boolean isRoot();
|
||||
|
||||
public void setChildPrinter(AbstractTestProxy child) {
|
||||
if (myPrinter != Printer.DEAF) {
|
||||
child.setPrintListener(myPrinter);
|
||||
public void fireOnNewPrintable(final Printable printable) {
|
||||
if (myPrinter != null) {
|
||||
myPrinter.onNewAvailable(printable);
|
||||
}
|
||||
}
|
||||
|
||||
public void fireOnNewPrintable(final Printable printable) {
|
||||
myPrinter.onNewAvailable(printable);
|
||||
}
|
||||
|
||||
public void setPrintListener(final Printer printer) {
|
||||
public void setPrinter(final Printer printer) {
|
||||
myPrinter = printer;
|
||||
for (AbstractTestProxy testProxy : getChildren()) {
|
||||
testProxy.setPrintListener(printer);
|
||||
testProxy.setPrinter(printer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,11 +20,9 @@ import com.intellij.execution.filters.HyperlinkInfo;
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
|
||||
public class DeferingPrinter implements Printer {
|
||||
private final boolean myCollectOutput;
|
||||
private CompositePrintable myCompositePrintable;
|
||||
|
||||
public DeferingPrinter(final boolean collectOutput) {
|
||||
myCollectOutput = collectOutput;
|
||||
public DeferingPrinter() {
|
||||
myCompositePrintable = new CompositePrintable();
|
||||
}
|
||||
|
||||
@@ -48,9 +46,8 @@ public class DeferingPrinter implements Printer {
|
||||
myCompositePrintable.addLast(new PrinterMark());
|
||||
}
|
||||
|
||||
public void printOn(final Printer printer) {
|
||||
public void printAndForget(final Printer printer) {
|
||||
myCompositePrintable.printOn(printer);
|
||||
if (!myCollectOutput)
|
||||
myCompositePrintable.clear();
|
||||
myCompositePrintable.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,12 +23,4 @@ public interface Printer {
|
||||
void onNewAvailable(Printable printable);
|
||||
void printHyperlink(String text, HyperlinkInfo info);
|
||||
void mark();
|
||||
|
||||
|
||||
Printer DEAF = new Printer() {
|
||||
public void print(final String text, final ConsoleViewContentType contentType) {}
|
||||
public void onNewAvailable(final Printable printable) {}
|
||||
public void printHyperlink(final String text, final HyperlinkInfo info) {}
|
||||
public void mark() {}
|
||||
};
|
||||
}
|
||||
|
||||
+2
-2
@@ -35,10 +35,10 @@ public abstract class BaseTestsOutputConsoleView implements ConsoleView, Observa
|
||||
protected TestConsoleProperties myProperties;
|
||||
protected TestResultsPanel myTestResultsPanel;
|
||||
|
||||
public BaseTestsOutputConsoleView(final TestConsoleProperties properties) {
|
||||
public BaseTestsOutputConsoleView(final TestConsoleProperties properties, final AbstractTestProxy unboundOutputRoot) {
|
||||
myProperties = properties;
|
||||
myConsole = TextConsoleBuilderFactory.getInstance().createBuilder(properties.getProject(), myProperties.getScope()).getConsole();
|
||||
myPrinter = new TestsOutputConsolePrinter(myConsole, properties);
|
||||
myPrinter = new TestsOutputConsolePrinter(myConsole, properties, unboundOutputRoot);
|
||||
myProperties.setConsole(this);
|
||||
|
||||
Disposer.register(this, myProperties);
|
||||
|
||||
+32
-42
@@ -25,24 +25,13 @@ import com.intellij.openapi.Disposable;
|
||||
public class TestsOutputConsolePrinter implements Printer, Disposable {
|
||||
private final ConsoleView myConsole;
|
||||
private final TestConsoleProperties myProperties;
|
||||
private AbstractTestProxy myCurrentPrintable;
|
||||
private Printer myOutput;
|
||||
private final AbstractTestProxy myUnboundOutputRoot;
|
||||
private AbstractTestProxy myCurrentTest;
|
||||
|
||||
// After pause action has been invoked - all output will be redirected to special
|
||||
// myDeferingPrinter which will dump all buffered data after user will continue process.
|
||||
private final DeferingPrinter myDeferingPrinter = new DeferingPrinter(false);
|
||||
|
||||
// It seems it is storage for uncaptured output by other printers (e.g. test proxies).
|
||||
// To prevent duplicated output collectioning output on this printer must be paused
|
||||
// (i.e. setCollectOutput(false)) after additional printer have been attached. You can
|
||||
// continue to collect output after additional printers will be deattached(e.g. test runner stops
|
||||
// sending events to test proxies).
|
||||
|
||||
// If output collection was enabled for this console printer - all output will be collected in
|
||||
// myOutputStorage component. Otherwise no output will be stored.
|
||||
// 'myCurrentOutputStorage' printer is used for displaying whole output for test's root
|
||||
private final DeferingPrinter myOutputStorage = new DeferingPrinter(true);
|
||||
private Printer myCurrentOutputStorage = myOutputStorage;
|
||||
// myPausedPrinter which will dump all buffered data after user will continue process.
|
||||
private final DeferingPrinter myPausedPrinter = new DeferingPrinter();
|
||||
private boolean myPaused = false;
|
||||
|
||||
private int myMarkOffset = 0;
|
||||
|
||||
@@ -52,11 +41,11 @@ public class TestsOutputConsolePrinter implements Printer, Disposable {
|
||||
}
|
||||
};
|
||||
|
||||
public TestsOutputConsolePrinter(final ConsoleView console, final TestConsoleProperties properties) {
|
||||
public TestsOutputConsolePrinter(final ConsoleView console, final TestConsoleProperties properties, final AbstractTestProxy unboundOutputRoot) {
|
||||
myConsole = console;
|
||||
myProperties = properties;
|
||||
myUnboundOutputRoot = unboundOutputRoot;
|
||||
myProperties.addListener(TestConsoleProperties.SCROLL_TO_STACK_TRACE, myPropertyListener);
|
||||
myOutput = this;
|
||||
}
|
||||
|
||||
public ConsoleView getConsole() {
|
||||
@@ -64,15 +53,13 @@ public class TestsOutputConsolePrinter implements Printer, Disposable {
|
||||
}
|
||||
|
||||
public boolean isPaused() {
|
||||
return myOutput != this;
|
||||
return myPaused;
|
||||
}
|
||||
|
||||
public void pause(final boolean doPause) {
|
||||
if (doPause)
|
||||
myOutput = myDeferingPrinter;
|
||||
else {
|
||||
myOutput = this;
|
||||
myDeferingPrinter.printOn(myOutput);
|
||||
myPaused = doPause;
|
||||
if (!doPause) {
|
||||
myPausedPrinter.printAndForget(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,8 +68,11 @@ public class TestsOutputConsolePrinter implements Printer, Disposable {
|
||||
}
|
||||
|
||||
public void onNewAvailable(final Printable printable) {
|
||||
printable.printOn(myCurrentOutputStorage);
|
||||
printable.printOn(myOutput);
|
||||
if (myPaused) {
|
||||
printable.printOn(myPausedPrinter);
|
||||
} else {
|
||||
printable.printOn(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -92,27 +82,35 @@ public class TestsOutputConsolePrinter implements Printer, Disposable {
|
||||
* @param test Selected test
|
||||
*/
|
||||
public void updateOnTestSelected(final AbstractTestProxy test) {
|
||||
if (myCurrentPrintable == test) {
|
||||
if (myCurrentTest == test) {
|
||||
return;
|
||||
}
|
||||
if (myCurrentTest != null) {
|
||||
myCurrentTest.setPrinter(null);
|
||||
}
|
||||
myConsole.clear();
|
||||
myMarkOffset = 0;
|
||||
if (test == null) {
|
||||
myCurrentPrintable = null;
|
||||
myCurrentTest = null;
|
||||
return;
|
||||
}
|
||||
myCurrentPrintable = test;
|
||||
myCurrentPrintable.setPrintListener(this);
|
||||
if (test.isRoot()) {
|
||||
myOutputStorage.printOn(this);
|
||||
myCurrentTest = test;
|
||||
myCurrentTest.setPrinter(this);
|
||||
if (isRoot() && myUnboundOutputRoot != null) {
|
||||
myUnboundOutputRoot.printOn(this);
|
||||
} else {
|
||||
myCurrentTest.printOn(this);
|
||||
}
|
||||
myCurrentPrintable.printOn(this);
|
||||
scrollToBeginning();
|
||||
if (myConsole instanceof ConsoleViewImpl) {
|
||||
((ConsoleViewImpl)myConsole).foldImmediately();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isRoot() {
|
||||
return myCurrentTest.getParent() == myUnboundOutputRoot;
|
||||
}
|
||||
|
||||
public void printHyperlink(final String text, final HyperlinkInfo info) {
|
||||
myConsole.printHyperlink(text, info);
|
||||
}
|
||||
@@ -125,13 +123,9 @@ public class TestsOutputConsolePrinter implements Printer, Disposable {
|
||||
public void dispose() {
|
||||
myProperties.removeListener(TestConsoleProperties.SCROLL_TO_STACK_TRACE, myPropertyListener);
|
||||
}
|
||||
|
||||
public void setCollectOutput(final boolean doCollect) {
|
||||
myCurrentOutputStorage = doCollect ? myOutputStorage : DEAF;
|
||||
}
|
||||
|
||||
public boolean canPause() {
|
||||
return myCurrentPrintable != null ? myCurrentPrintable.isInProgress() : false;
|
||||
return myCurrentTest != null ? myCurrentTest.isInProgress() : false;
|
||||
}
|
||||
|
||||
protected void scrollToBeginning() {
|
||||
@@ -141,8 +135,4 @@ public class TestsOutputConsolePrinter implements Printer, Disposable {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isMarked() {
|
||||
return myMarkOffset > 0;
|
||||
}
|
||||
}
|
||||
@@ -27,13 +27,13 @@ import com.intellij.execution.junit2.ui.JUnitTreeConsoleView;
|
||||
import com.intellij.execution.junit2.ui.TestsPacketsReceiver;
|
||||
import com.intellij.execution.junit2.ui.actions.RerunFailedTestsAction;
|
||||
import com.intellij.execution.junit2.ui.model.JUnitRunningModel;
|
||||
import com.intellij.execution.junit2.ui.model.RootTestInfo;
|
||||
import com.intellij.execution.junit2.ui.properties.JUnitConsoleProperties;
|
||||
import com.intellij.execution.process.ProcessAdapter;
|
||||
import com.intellij.execution.process.ProcessEvent;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.runners.ProgramRunner;
|
||||
import com.intellij.execution.testframework.*;
|
||||
import com.intellij.execution.testframework.ui.TestsOutputConsolePrinter;
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
import com.intellij.execution.util.JavaParametersUtil;
|
||||
import com.intellij.openapi.Disposable;
|
||||
@@ -259,8 +259,9 @@ public abstract class TestObject implements JavaCommandLine {
|
||||
for(final RunConfigurationExtension ext: Extensions.getExtensions(RunConfigurationExtension.EP_NAME)) {
|
||||
ext.handleStartProcess(myConfiguration, handler);
|
||||
}
|
||||
final TestProxy unboundOutputRoot = new TestProxy(new RootTestInfo());
|
||||
final JUnitConsoleProperties consoleProperties = new JUnitConsoleProperties(myConfiguration);
|
||||
final JUnitTreeConsoleView consoleView = new JUnitTreeConsoleView(consoleProperties, getRunnerSettings(), getConfigurationSettings());
|
||||
final JUnitTreeConsoleView consoleView = new JUnitTreeConsoleView(consoleProperties, getRunnerSettings(), getConfigurationSettings(), unboundOutputRoot);
|
||||
consoleView.initUI();
|
||||
consoleView.attachToProcess(handler);
|
||||
|
||||
@@ -268,6 +269,7 @@ public abstract class TestObject implements JavaCommandLine {
|
||||
@Override
|
||||
public void notifyStart(TestProxy root) {
|
||||
super.notifyStart(root);
|
||||
unboundOutputRoot.addChild(root);
|
||||
final JUnitRunningModel model = getModel();
|
||||
if (model != null) {
|
||||
handler.getOut().setDispatchListener(model.getNotifier());
|
||||
@@ -309,7 +311,6 @@ public abstract class TestObject implements JavaCommandLine {
|
||||
final String text = event.getText();
|
||||
final ConsoleViewContentType consoleViewType = ConsoleViewContentType.getConsoleViewType(outputType);
|
||||
final TestProxy currentTest = packetsReceiver.getCurrentTest();
|
||||
final TestsOutputConsolePrinter consolePrinter = consoleView.getPrinter();
|
||||
final Printable printable = new Printable() {
|
||||
public void printOn(final Printer printer) {
|
||||
printer.print(text, consoleViewType);
|
||||
@@ -317,13 +318,10 @@ public abstract class TestObject implements JavaCommandLine {
|
||||
};
|
||||
|
||||
if (currentTest != null) {
|
||||
if (consoleViewType == ConsoleViewContentType.ERROR_OUTPUT && !consolePrinter.isMarked()) {
|
||||
consolePrinter.mark();
|
||||
}
|
||||
currentTest.addLast(printable);
|
||||
}
|
||||
else {
|
||||
consolePrinter.onNewAvailable(printable);
|
||||
unboundOutputRoot.addLast(printable);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.intellij.execution.junit2.info.TestInfo;
|
||||
import com.intellij.execution.junit2.states.Statistics;
|
||||
import com.intellij.execution.junit2.states.TestState;
|
||||
import com.intellij.execution.testframework.*;
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.pom.Navigatable;
|
||||
@@ -60,7 +59,6 @@ public class TestProxy extends AbstractTestProxy {
|
||||
|
||||
public void printOn(final Printer printer) {
|
||||
super.printOn(printer);
|
||||
CompositePrintable.printAllOn(myChildren.getList(), printer);
|
||||
myState.printOn(printer);
|
||||
}
|
||||
|
||||
@@ -152,7 +150,8 @@ public class TestProxy extends AbstractTestProxy {
|
||||
return;//todo throw new RuntimeException("Test: "+child + " already has parent: " + child.getParent());
|
||||
myChildren.add(child);
|
||||
child.myParent = this;
|
||||
setChildPrinter(child);
|
||||
addLast(child);
|
||||
child.setPrinter(myPrinter);
|
||||
pullEvent(new NewChildEvent(this, child));
|
||||
getState().changeStateAfterAddingChildTo(this, child);
|
||||
myNotifier.onChildAdded(this, child);
|
||||
@@ -260,8 +259,4 @@ public class TestProxy extends AbstractTestProxy {
|
||||
return parents.toArray(new TestProxy[parents.size()]);
|
||||
}
|
||||
|
||||
public boolean isRoot() {
|
||||
return getParent() == null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,10 +18,12 @@ package com.intellij.execution.junit2.ui;
|
||||
|
||||
import com.intellij.execution.configurations.ConfigurationPerRunnerSettings;
|
||||
import com.intellij.execution.configurations.RunnerSettings;
|
||||
import com.intellij.execution.junit2.TestProxy;
|
||||
import com.intellij.execution.junit2.ui.model.JUnitRunningModel;
|
||||
import com.intellij.execution.junit2.ui.model.TreeCollapser;
|
||||
import com.intellij.execution.junit2.ui.properties.JUnitConsoleProperties;
|
||||
import com.intellij.execution.process.ProcessHandler;
|
||||
import com.intellij.execution.testframework.AbstractTestProxy;
|
||||
import com.intellij.execution.testframework.ui.BaseTestsOutputConsoleView;
|
||||
import com.intellij.execution.testframework.ui.TestResultsPanel;
|
||||
|
||||
@@ -35,12 +37,12 @@ public class JUnitTreeConsoleView extends BaseTestsOutputConsoleView {
|
||||
|
||||
public JUnitTreeConsoleView(final JUnitConsoleProperties properties,
|
||||
final RunnerSettings runnerSettings,
|
||||
final ConfigurationPerRunnerSettings configurationSettings) {
|
||||
super(properties);
|
||||
final ConfigurationPerRunnerSettings configurationSettings,
|
||||
final AbstractTestProxy unboundOutputRoot) {
|
||||
super(properties, unboundOutputRoot);
|
||||
myProperties = properties;
|
||||
myRunnerSettings = runnerSettings;
|
||||
myConfigurationSettings = configurationSettings;
|
||||
getPrinter().setCollectOutput(true);
|
||||
}
|
||||
|
||||
protected TestResultsPanel createTestResultsPanel() {
|
||||
@@ -64,7 +66,6 @@ public class JUnitTreeConsoleView extends BaseTestsOutputConsoleView {
|
||||
}
|
||||
|
||||
public void attachToModel(JUnitRunningModel model) {
|
||||
getPrinter().setCollectOutput(false);
|
||||
myConsolePanel.getTreeView().attachToModel(model);
|
||||
model.attachToTree(myConsolePanel.getTreeView());
|
||||
myConsolePanel.setModel(model);
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2000-2010 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.ui.model;
|
||||
|
||||
import com.intellij.execution.Location;
|
||||
import com.intellij.execution.junit2.info.TestInfo;
|
||||
import com.intellij.execution.junit2.segments.ObjectReader;
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
* Date: Jul 21, 2010
|
||||
*/
|
||||
public class RootTestInfo extends TestInfo {
|
||||
private String myName = SpecialNode.TESTS_IN_PROGRESS;
|
||||
|
||||
public String getComment() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getName() { return myName; }
|
||||
|
||||
public void setName(final String name) { myName = name; }
|
||||
|
||||
public boolean shouldRun() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getTestsCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFrom(ObjectReader reader) {
|
||||
}
|
||||
|
||||
public Location getLocation(final Project project) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,22 +16,18 @@
|
||||
|
||||
package com.intellij.execution.junit2.ui.model;
|
||||
|
||||
import com.intellij.execution.Location;
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.junit2.segments.ObjectReader;
|
||||
import com.intellij.execution.junit2.ui.TestProgress;
|
||||
import com.intellij.execution.junit2.TestProxy;
|
||||
import com.intellij.execution.junit2.info.TestInfo;
|
||||
import com.intellij.execution.junit2.states.NotFailedState;
|
||||
import com.intellij.ide.util.treeView.AbstractTreeBuilder;
|
||||
import com.intellij.openapi.project.Project;
|
||||
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
public class SpecialNode extends TestProxy {
|
||||
private static final String ALL_PASSED = ExecutionBundle.message("junit.all.tests.passed.label");
|
||||
private static final String TESTS_IN_PROGRESS = ExecutionBundle.message("junit.tests.in.progress.label");
|
||||
public static final String ALL_PASSED = ExecutionBundle.message("junit.all.tests.passed.label");
|
||||
public static final String TESTS_IN_PROGRESS = ExecutionBundle.message("junit.tests.in.progress.label");
|
||||
|
||||
private final JUnitRunningModel myModel;
|
||||
private final AbstractTreeBuilder myBuilder;
|
||||
@@ -40,7 +36,7 @@ public class SpecialNode extends TestProxy {
|
||||
private CompletionEvent myCompletionEvent;
|
||||
|
||||
public SpecialNode(final TestTreeBuilder treeBuilder, final JUnitRunningModel model) {
|
||||
super(new MyTestInfo());
|
||||
super(new RootTestInfo());
|
||||
myModel = model;
|
||||
myBuilder = treeBuilder;
|
||||
final MyJUnitAdapter listener = new MyJUnitAdapter();
|
||||
@@ -59,35 +55,6 @@ public class SpecialNode extends TestProxy {
|
||||
updateName();
|
||||
}
|
||||
|
||||
private static class MyTestInfo extends TestInfo {
|
||||
private String myName = TESTS_IN_PROGRESS;
|
||||
|
||||
public String getComment() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getName() { return myName; }
|
||||
|
||||
public void setName(final String name) { myName = name; }
|
||||
|
||||
public boolean shouldRun() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getTestsCount() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFrom(ObjectReader reader) {
|
||||
}
|
||||
|
||||
public Location getLocation(final Project project) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class MyJUnitAdapter extends JUnitAdapter implements ChangeListener {
|
||||
public void stateChanged(final ChangeEvent e) {
|
||||
if (myCompletionEvent != null) updateName();
|
||||
@@ -107,7 +74,7 @@ public class SpecialNode extends TestProxy {
|
||||
|
||||
private void updateName() {
|
||||
if (!myIsVisible) return;
|
||||
final MyTestInfo myTestInfo = (MyTestInfo)getInfo();
|
||||
final RootTestInfo myTestInfo = (RootTestInfo)getInfo();
|
||||
final String newName;
|
||||
final TestProgress progress = myModel.getProgress();
|
||||
if (myCompletionEvent == null) {
|
||||
|
||||
@@ -36,7 +36,6 @@ import org.testng.remote.strprotocol.MessageHelper;
|
||||
import org.testng.remote.strprotocol.TestResultMessage;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
@@ -244,11 +243,6 @@ public class TestProxy extends AbstractTestProxy {
|
||||
return total;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRoot() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getChildCount() {
|
||||
return results.size();
|
||||
}
|
||||
@@ -291,16 +285,4 @@ public class TestProxy extends AbstractTestProxy {
|
||||
public void setTearDownFailure(boolean tearDownFailure) {
|
||||
myTearDownFailure = tearDownFailure;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printOn(Printer printer) {//todo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPrintListener(Printer printer) {// todo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fireOnNewPrintable(Printable printable) {// todo
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,10 +33,6 @@ public class TreeRootNode extends TestProxy
|
||||
return inProgress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRoot() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setInProgress(boolean inProgress) {
|
||||
this.inProgress = inProgress;
|
||||
|
||||
@@ -65,7 +65,7 @@ public class TestNGConsoleView extends BaseTestsOutputConsoleView {
|
||||
public TestNGConsoleView(TestNGConfiguration config,
|
||||
final RunnerSettings runnerSettings,
|
||||
final ConfigurationPerRunnerSettings configurationPerRunnerSettings) {
|
||||
super(new TestNGConsoleProperties(config));
|
||||
super(new TestNGConsoleProperties(config), null);
|
||||
myConfiguration = config;
|
||||
myRunnerSettings = runnerSettings;
|
||||
myConfigurationPerRunnerSettings = configurationPerRunnerSettings;
|
||||
|
||||
Reference in New Issue
Block a user