mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
testframework refactoring: compact tests hierarchy
This commit is contained in:
+2
-33
@@ -20,7 +20,6 @@ import com.intellij.execution.testframework.*;
|
||||
import com.intellij.execution.testframework.sm.TestsLocationProviderUtil;
|
||||
import com.intellij.execution.testframework.sm.runner.states.*;
|
||||
import com.intellij.execution.testframework.sm.runner.ui.TestsPresentationUtil;
|
||||
import com.intellij.execution.testframework.ui.PrintableTestProxy;
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
import com.intellij.ide.util.EditSourceUtil;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -39,7 +38,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author: Roman Chernyatchik
|
||||
*/
|
||||
public class SMTestProxy extends CompositePrintable implements PrintableTestProxy {
|
||||
public class SMTestProxy extends AbstractTestProxy {
|
||||
private static final Logger LOG = Logger.getInstance(SMTestProxy.class.getName());
|
||||
|
||||
private List<SMTestProxy> myChildren;
|
||||
@@ -53,8 +52,6 @@ public class SMTestProxy extends CompositePrintable implements PrintableTestProx
|
||||
private boolean myHasErrors = false;
|
||||
private boolean myHasErrorsCached = false;
|
||||
|
||||
private Printer myPrinter = Printer.DEAF;
|
||||
|
||||
private final boolean myIsSuite;
|
||||
|
||||
public SMTestProxy(final String testName, final boolean isSuite,
|
||||
@@ -152,9 +149,7 @@ public class SMTestProxy extends CompositePrintable implements PrintableTestProx
|
||||
child.setParent(this);
|
||||
// if parent is being printed then all childs output
|
||||
// should be also send to the same printer
|
||||
if (myPrinter != Printer.DEAF) {
|
||||
child.setPrintLinstener(myPrinter);
|
||||
}
|
||||
setChildPrinter(child);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@@ -333,17 +328,6 @@ public class SMTestProxy extends CompositePrintable implements PrintableTestProx
|
||||
return getParent() == null;
|
||||
}
|
||||
|
||||
public void setPrintLinstener(final Printer printer) {
|
||||
myPrinter = printer;
|
||||
|
||||
if (myChildren == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (ChangingPrintable child : myChildren) {
|
||||
child.setPrintLinstener(printer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints this proxy and all its children on given printer
|
||||
@@ -356,17 +340,6 @@ public class SMTestProxy extends CompositePrintable implements PrintableTestProx
|
||||
myState.printOn(printer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores printable information in internal buffer and notifies
|
||||
* proxy's printer about new text available
|
||||
* @param printable Printable info
|
||||
*/
|
||||
@Override
|
||||
public void addLast(final Printable printable) {
|
||||
super.addLast(printable);
|
||||
fireOnNewPrintable(printable);
|
||||
}
|
||||
|
||||
public void addStdOutput(final String output, final Key outputType) {
|
||||
addLast(new Printable() {
|
||||
public void printOn(final Printer printer) {
|
||||
@@ -404,10 +377,6 @@ public class SMTestProxy extends CompositePrintable implements PrintableTestProx
|
||||
});
|
||||
}
|
||||
|
||||
private void fireOnNewPrintable(final Printable printable) {
|
||||
myPrinter.onNewAvailable(printable);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getPresentableName() {
|
||||
return TestsPresentationUtil.getPresentableName(this);
|
||||
|
||||
+3
-2
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package com.intellij.execution.testframework.sm.runner.states;
|
||||
|
||||
import com.intellij.execution.testframework.CompositePrintable;
|
||||
import com.intellij.execution.testframework.Printer;
|
||||
import com.intellij.execution.testframework.sm.SMTestsRunnerBundle;
|
||||
import com.intellij.execution.testframework.ui.PrintableTestProxy;
|
||||
import com.intellij.execution.testframework.sm.runner.SMTestProxy;
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
|
||||
@@ -105,7 +106,7 @@ public abstract class SuiteFinishedState extends AbstractState {
|
||||
public void printOn(final Printer printer) {
|
||||
super.printOn(printer);
|
||||
|
||||
final String msg = EMPTY_SUITE_TEXT + PrintableTestProxy.NEW_LINE;
|
||||
final String msg = EMPTY_SUITE_TEXT + CompositePrintable.NEW_LINE;
|
||||
printer.print(msg, ConsoleViewContentType.SYSTEM_OUTPUT);
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -15,8 +15,9 @@
|
||||
*/
|
||||
package com.intellij.execution.testframework.sm.runner.states;
|
||||
|
||||
import com.intellij.execution.testframework.CompositePrintable;
|
||||
import com.intellij.execution.testframework.Printer;
|
||||
import com.intellij.execution.testframework.ui.PrintableTestProxy;
|
||||
import com.intellij.execution.testframework.sm.runner.SMTestProxy;
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -38,16 +39,16 @@ public class TestFailedState extends AbstractState {
|
||||
@Nullable final String stackTrace) {
|
||||
final String text = (StringUtil.isEmptyOrSpaces(localizedMessage)
|
||||
? ""
|
||||
: localizedMessage + PrintableTestProxy.NEW_LINE) +
|
||||
: localizedMessage + CompositePrintable.NEW_LINE) +
|
||||
(StringUtil.isEmptyOrSpaces(stackTrace)
|
||||
? ""
|
||||
: stackTrace + PrintableTestProxy.NEW_LINE);
|
||||
: stackTrace + CompositePrintable.NEW_LINE);
|
||||
return StringUtil.isEmptyOrSpaces(text) ? null : text;
|
||||
}
|
||||
|
||||
public static void printError(@NotNull final Printer printer,
|
||||
@NotNull final String errorPresentationText) {
|
||||
printer.print(PrintableTestProxy.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT);
|
||||
printer.print(CompositePrintable.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT);
|
||||
printer.mark();
|
||||
printer.print(errorPresentationText, ConsoleViewContentType.ERROR_OUTPUT);
|
||||
}
|
||||
|
||||
+6
-5
@@ -15,9 +15,10 @@
|
||||
*/
|
||||
package com.intellij.execution.testframework.sm.runner.states;
|
||||
|
||||
import com.intellij.execution.testframework.CompositePrintable;
|
||||
import com.intellij.execution.testframework.Printer;
|
||||
import com.intellij.execution.testframework.sm.SMTestsRunnerBundle;
|
||||
import com.intellij.execution.testframework.ui.PrintableTestProxy;
|
||||
import com.intellij.execution.testframework.sm.runner.SMTestProxy;
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -33,8 +34,8 @@ public class TestIgnoredState extends AbstractState {
|
||||
|
||||
public TestIgnoredState(final String ignoredComment, @Nullable final String stackTrace) {
|
||||
final String ignored_msg = StringUtil.isEmpty(ignoredComment) ? IGNORED_TEST_TEXT : ignoredComment;
|
||||
myText = PrintableTestProxy.NEW_LINE + ignored_msg;
|
||||
myStacktrace = stackTrace == null ? null : stackTrace + PrintableTestProxy.NEW_LINE;
|
||||
myText = CompositePrintable.NEW_LINE + ignored_msg;
|
||||
myStacktrace = stackTrace == null ? null : stackTrace + CompositePrintable.NEW_LINE;
|
||||
}
|
||||
|
||||
public boolean isInProgress() {
|
||||
@@ -67,10 +68,10 @@ public class TestIgnoredState extends AbstractState {
|
||||
|
||||
printer.print(myText, ConsoleViewContentType.SYSTEM_OUTPUT);
|
||||
if (StringUtil.isEmptyOrSpaces(myStacktrace)) {
|
||||
printer.print(PrintableTestProxy.NEW_LINE, ConsoleViewContentType.SYSTEM_OUTPUT);
|
||||
printer.print(CompositePrintable.NEW_LINE, ConsoleViewContentType.SYSTEM_OUTPUT);
|
||||
}
|
||||
else {
|
||||
printer.print(PrintableTestProxy.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT);
|
||||
printer.print(CompositePrintable.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT);
|
||||
printer.mark();
|
||||
printer.print(myStacktrace, ConsoleViewContentType.ERROR_OUTPUT);
|
||||
}
|
||||
|
||||
+1
-2
@@ -23,7 +23,6 @@ import com.intellij.execution.testframework.TestFrameworkRunningModel;
|
||||
import com.intellij.execution.testframework.sm.SMRunnerUtil;
|
||||
import com.intellij.execution.testframework.sm.runner.SMTestProxy;
|
||||
import com.intellij.execution.testframework.ui.BaseTestsOutputConsoleView;
|
||||
import com.intellij.execution.testframework.ui.PrintableTestProxy;
|
||||
import com.intellij.execution.testframework.ui.TestResultsPanel;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -88,7 +87,7 @@ public class SMTRunnerConsoleView extends BaseTestsOutputConsoleView {
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
public void onSelected(@Nullable final PrintableTestProxy selectedTestProxy,
|
||||
public void onSelected(@Nullable final SMTestProxy selectedTestProxy,
|
||||
@NotNull final TestResultsViewer viewer,
|
||||
@NotNull final TestFrameworkRunningModel model) {
|
||||
if (selectedTestProxy == null) {
|
||||
|
||||
+1
-3
@@ -16,11 +16,9 @@
|
||||
package com.intellij.execution.testframework.sm.runner.ui;
|
||||
|
||||
import com.intellij.execution.testframework.AbstractTestProxy;
|
||||
import com.intellij.execution.testframework.Filter;
|
||||
import com.intellij.execution.testframework.TestConsoleProperties;
|
||||
import com.intellij.execution.testframework.TestFrameworkRunningModel;
|
||||
import com.intellij.execution.testframework.sm.runner.ProxyFilters;
|
||||
import com.intellij.execution.testframework.ui.PrintableTestProxy;
|
||||
import com.intellij.execution.testframework.actions.ScrollToTestSourceAction;
|
||||
import com.intellij.execution.testframework.sm.runner.SMTestProxy;
|
||||
import com.intellij.execution.testframework.sm.SMRunnerUtil;
|
||||
@@ -79,7 +77,7 @@ public class SMTRunnerUIActionsHandler implements TestResultsViewer.EventsListen
|
||||
}
|
||||
}
|
||||
|
||||
public void onSelected(@Nullable final PrintableTestProxy selectedTestProxy,
|
||||
public void onSelected(@Nullable final SMTestProxy selectedTestProxy,
|
||||
@NotNull final TestResultsViewer viewer,
|
||||
@NotNull final TestFrameworkRunningModel model) {
|
||||
//TODO: tests o "onSelected"
|
||||
|
||||
+1
-2
@@ -26,7 +26,6 @@ import com.intellij.execution.testframework.sm.runner.SMTRunnerTreeStructure;
|
||||
import com.intellij.execution.testframework.sm.runner.SMTestProxy;
|
||||
import com.intellij.execution.testframework.sm.runner.ui.statistics.StatisticsPanel;
|
||||
import com.intellij.execution.testframework.ui.AbstractTestTreeBuilder;
|
||||
import com.intellij.execution.testframework.ui.PrintableTestProxy;
|
||||
import com.intellij.execution.testframework.ui.TestResultsPanel;
|
||||
import com.intellij.execution.testframework.ui.TestsProgressAnimator;
|
||||
import com.intellij.openapi.Disposable;
|
||||
@@ -344,7 +343,7 @@ public class SMTestRunnerResultsForm extends TestResultsPanel implements TestFra
|
||||
//e.g. it is focused. Otherwise it is side effect of selecting proxy in
|
||||
//try by other component
|
||||
//if (myTreeView.isFocusOwner()) {
|
||||
@Nullable final PrintableTestProxy selectedProxy = (PrintableTestProxy)getTreeView().getSelectedTest();
|
||||
@Nullable final SMTestProxy selectedProxy = (SMTestProxy)getTreeView().getSelectedTest();
|
||||
listener.onSelected(selectedProxy, SMTestRunnerResultsForm.this, SMTestRunnerResultsForm.this);
|
||||
//}
|
||||
}
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
package com.intellij.execution.testframework.sm.runner.ui;
|
||||
|
||||
import com.intellij.execution.testframework.ui.PrintableTestProxy;
|
||||
import com.intellij.execution.testframework.sm.runner.SMTestProxy;
|
||||
import com.intellij.execution.testframework.TestFrameworkRunningModel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -30,7 +30,7 @@ public interface TestProxyTreeSelectionListener {
|
||||
* @param viewer
|
||||
* @param model
|
||||
*/
|
||||
void onSelected(@Nullable PrintableTestProxy selectedTestProxy,
|
||||
void onSelected(@Nullable SMTestProxy selectedTestProxy,
|
||||
@NotNull TestResultsViewer viewer,
|
||||
@NotNull TestFrameworkRunningModel model);
|
||||
}
|
||||
|
||||
+11
-11
@@ -86,7 +86,7 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
}
|
||||
|
||||
public void testPrintTestProxy() {
|
||||
mySimpleTest.setPrintLinstener(myMockResetablePrinter);
|
||||
mySimpleTest.setPrintListener(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.setPrintLinstener(myMockResetablePrinter);
|
||||
mySimpleTest.setPrintListener(myMockResetablePrinter);
|
||||
|
||||
mySimpleTest.addStdOutput("one", ProcessOutputTypes.STDOUT);
|
||||
assertStdOutput(myMockResetablePrinter, "one");
|
||||
@@ -114,14 +114,14 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
}
|
||||
|
||||
public void testAddStdSys() {
|
||||
mySimpleTest.setPrintLinstener(myMockResetablePrinter);
|
||||
mySimpleTest.setPrintListener(myMockResetablePrinter);
|
||||
|
||||
mySimpleTest.addSystemOutput("sys");
|
||||
assertAllOutputs(myMockResetablePrinter, "", "", "sys");
|
||||
}
|
||||
|
||||
public void testPrintTestProxy_Order() {
|
||||
mySimpleTest.setPrintLinstener(myMockResetablePrinter);
|
||||
mySimpleTest.setPrintListener(myMockResetablePrinter);
|
||||
|
||||
sendToTestProxyStdOut(mySimpleTest, "first ");
|
||||
sendToTestProxyStdOut(mySimpleTest, "second");
|
||||
@@ -132,7 +132,7 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
public void testSetPrintListener_ForExistingChildren() {
|
||||
mySuite.addChild(mySimpleTest);
|
||||
|
||||
mySuite.setPrintLinstener(myMockResetablePrinter);
|
||||
mySuite.setPrintListener(myMockResetablePrinter);
|
||||
|
||||
sendToTestProxyStdOut(mySimpleTest, "child ");
|
||||
sendToTestProxyStdOut(mySuite, "root");
|
||||
@@ -141,7 +141,7 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
}
|
||||
|
||||
public void testSetPrintListener_OnNewChild() {
|
||||
mySuite.setPrintLinstener(myMockResetablePrinter);
|
||||
mySuite.setPrintListener(myMockResetablePrinter);
|
||||
|
||||
sendToTestProxyStdOut(mySuite, "root ");
|
||||
|
||||
@@ -299,7 +299,7 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
|
||||
myEventsProcessor.onSuiteStarted("suite", null);
|
||||
final SMTestProxy suite = myEventsProcessor.getCurrentSuite();
|
||||
suite.setPrintLinstener(myMockResetablePrinter);
|
||||
suite.setPrintListener(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.setPrintLinstener(myMockResetablePrinter);
|
||||
myRootSuite.setPrintListener(myMockResetablePrinter);
|
||||
|
||||
assertOnUncapturedOutput();
|
||||
}
|
||||
|
||||
public void testOnUncapturedOutput_BeforeFirstSuiteStarted() {
|
||||
myRootSuite.setPrintLinstener(myMockResetablePrinter);
|
||||
myRootSuite.setPrintListener(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.setPrintLinstener(myMockResetablePrinter);
|
||||
mySuite.setPrintListener(myMockResetablePrinter);
|
||||
|
||||
assertOnUncapturedOutput();
|
||||
}
|
||||
@@ -476,7 +476,7 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
|
||||
myEventsProcessor.onTestStarted(testName, null);
|
||||
final SMTestProxy proxy =
|
||||
myEventsProcessor.getProxyByFullTestName(myEventsProcessor.getFullTestName(testName));
|
||||
proxy.setPrintLinstener(myMockResetablePrinter);
|
||||
proxy.setPrintListener(myMockResetablePrinter);
|
||||
return proxy;
|
||||
}
|
||||
|
||||
|
||||
+47
-16
@@ -26,36 +26,67 @@ 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 interface AbstractTestProxy {
|
||||
DataKey<AbstractTestProxy> DATA_KEY = DataKey.create("testProxy");
|
||||
@Deprecated @NonNls String DATA_CONSTANT = DATA_KEY.getName();
|
||||
public abstract class AbstractTestProxy extends CompositePrintable {
|
||||
public static final DataKey<AbstractTestProxy> DATA_KEY = DataKey.create("testProxy");
|
||||
protected Printer myPrinter = Printer.DEAF;
|
||||
|
||||
boolean isInProgress();
|
||||
public abstract boolean isInProgress();
|
||||
|
||||
boolean isDefect();
|
||||
public abstract boolean isDefect();
|
||||
|
||||
//todo?
|
||||
boolean shouldRun();
|
||||
public abstract boolean shouldRun();
|
||||
|
||||
int getMagnitude();
|
||||
public abstract int getMagnitude();
|
||||
|
||||
boolean isLeaf();
|
||||
public abstract boolean isLeaf();
|
||||
|
||||
boolean isInterrupted();
|
||||
public abstract boolean isInterrupted();
|
||||
|
||||
boolean isPassed();
|
||||
public abstract boolean isPassed();
|
||||
|
||||
String getName();
|
||||
public abstract String getName();
|
||||
|
||||
Location getLocation(final Project project);
|
||||
public abstract Location getLocation(final Project project);
|
||||
|
||||
Navigatable getDescriptor(final Location location);
|
||||
public abstract Navigatable getDescriptor(final Location location);
|
||||
|
||||
AbstractTestProxy getParent();
|
||||
public abstract AbstractTestProxy getParent();
|
||||
|
||||
List<? extends AbstractTestProxy> getChildren();
|
||||
public abstract List<? extends AbstractTestProxy> getChildren();
|
||||
|
||||
List<? extends AbstractTestProxy> getAllTests();
|
||||
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) {
|
||||
myPrinter.onNewAvailable(printable);
|
||||
}
|
||||
|
||||
public void setPrintListener(final Printer printer) {
|
||||
myPrinter = printer;
|
||||
for (AbstractTestProxy testProxy : getChildren()) {
|
||||
testProxy.setPrintListener(printer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores printable information in internal buffer and notifies
|
||||
* proxy's printer about new text available
|
||||
* @param printable Printable info
|
||||
*/
|
||||
@Override
|
||||
public void addLast(final Printable printable) {
|
||||
super.addLast(printable);
|
||||
fireOnNewPrintable(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;
|
||||
|
||||
|
||||
|
||||
public interface ChangingPrintable extends Printable {
|
||||
|
||||
void setPrintLinstener(Printer printer);
|
||||
|
||||
ChangingPrintable DEAF = new ChangingPrintable() {
|
||||
|
||||
public void setPrintLinstener(final Printer printer) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void printOn(final Printer printer) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
public String toString() {
|
||||
|
||||
//noinspection HardCodedStringLiteral
|
||||
|
||||
return "DEAF printer";
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+1
-26
@@ -13,58 +13,33 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
package com.intellij.execution.testframework;
|
||||
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
public class CompositePrintable implements Printable {
|
||||
public static final String NEW_LINE = "\n";
|
||||
|
||||
private final ArrayList<Printable> myNestedPrintables = new ArrayList<Printable>();
|
||||
|
||||
|
||||
|
||||
public void printOn(final Printer printer) {
|
||||
|
||||
printAllOn(myNestedPrintables, printer);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void addLast(final Printable printable) {
|
||||
|
||||
myNestedPrintables.add(printable);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void clear() {
|
||||
|
||||
myNestedPrintables.clear();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static <T extends Printable> void printAllOn(final List<T> printables, final Printer console) {
|
||||
|
||||
for (final T printable : printables) {
|
||||
|
||||
printable.printOn(console);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
-28
@@ -1,28 +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.ui;
|
||||
|
||||
import com.intellij.execution.testframework.AbstractTestProxy;
|
||||
import com.intellij.execution.testframework.ChangingPrintable;
|
||||
|
||||
/**
|
||||
* @author Roman Chernyatchik
|
||||
*/
|
||||
public interface PrintableTestProxy extends AbstractTestProxy, ChangingPrintable {
|
||||
String NEW_LINE = "\n";
|
||||
|
||||
boolean isRoot();
|
||||
}
|
||||
+5
-10
@@ -25,7 +25,7 @@ import com.intellij.openapi.Disposable;
|
||||
public class TestsOutputConsolePrinter implements Printer, Disposable {
|
||||
private final ConsoleView myConsole;
|
||||
private final TestConsoleProperties myProperties;
|
||||
private ChangingPrintable myCurrentPrintable = ChangingPrintable.DEAF;
|
||||
private AbstractTestProxy myCurrentPrintable;
|
||||
private Printer myOutput;
|
||||
|
||||
// After pause action has been invoked - all output will be redirected to special
|
||||
@@ -91,19 +91,18 @@ public class TestsOutputConsolePrinter implements Printer, Disposable {
|
||||
* This method must be invoked in Event Dispatch Thread
|
||||
* @param test Selected test
|
||||
*/
|
||||
public void updateOnTestSelected(final PrintableTestProxy test) {
|
||||
public void updateOnTestSelected(final AbstractTestProxy test) {
|
||||
if (myCurrentPrintable == test) {
|
||||
return;
|
||||
}
|
||||
myCurrentPrintable.setPrintLinstener(DEAF);
|
||||
myConsole.clear();
|
||||
myMarkOffset = 0;
|
||||
if (test == null) {
|
||||
myCurrentPrintable = ChangingPrintable.DEAF;
|
||||
myCurrentPrintable = null;
|
||||
return;
|
||||
}
|
||||
myCurrentPrintable = test;
|
||||
myCurrentPrintable.setPrintLinstener(this);
|
||||
myCurrentPrintable.setPrintListener(this);
|
||||
if (test.isRoot()) {
|
||||
myOutputStorage.printOn(this);
|
||||
}
|
||||
@@ -132,11 +131,7 @@ public class TestsOutputConsolePrinter implements Printer, Disposable {
|
||||
}
|
||||
|
||||
public boolean canPause() {
|
||||
if (myCurrentPrintable instanceof AbstractTestProxy) {
|
||||
final AbstractTestProxy test = (AbstractTestProxy)myCurrentPrintable;
|
||||
return test.isInProgress();
|
||||
}
|
||||
return false;
|
||||
return myCurrentPrintable != null ? myCurrentPrintable.isInProgress() : false;
|
||||
}
|
||||
|
||||
protected void scrollToBeginning() {
|
||||
|
||||
@@ -22,8 +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.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,12 +34,11 @@ import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class TestProxy extends CompositePrintable implements PrintableTestProxy, ChangingPrintable {
|
||||
public class TestProxy extends AbstractTestProxy {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.execution.junit2.TestProxy");
|
||||
|
||||
private final TestInfo myInfo;
|
||||
private TestState myState = TestState.DEFAULT;
|
||||
private Printer myPrinter = Printer.DEAF;
|
||||
private final TestProxyListenersNotifier myNotifier = new TestProxyListenersNotifier();
|
||||
private Statistics myStatistics = new Statistics();
|
||||
private TestEventsConsumer myEventsConsumer;
|
||||
@@ -74,15 +71,6 @@ public class TestProxy extends CompositePrintable implements PrintableTestProxy,
|
||||
});
|
||||
}
|
||||
|
||||
public void addLast(final Printable printable) {
|
||||
super.addLast(printable);
|
||||
fireOnNewPrintable(printable);
|
||||
}
|
||||
|
||||
private void fireOnNewPrintable(final Printable printable) {
|
||||
myPrinter.onNewAvailable(printable);
|
||||
}
|
||||
|
||||
public void printOn(final Printer printer) {
|
||||
super.printOn(printer);
|
||||
CompositePrintable.printAllOn(myChildren.getList(), printer);
|
||||
@@ -117,10 +105,6 @@ public class TestProxy extends CompositePrintable implements PrintableTestProxy,
|
||||
return myStateTimestamp;
|
||||
}
|
||||
|
||||
public TestProxy getChildAt(final int childIndex) {
|
||||
return myChildren.getList().get(childIndex);
|
||||
}
|
||||
|
||||
public int getChildCount() {
|
||||
return myChildren.getList().size();
|
||||
}
|
||||
@@ -181,22 +165,12 @@ public class TestProxy extends CompositePrintable implements PrintableTestProxy,
|
||||
return;//todo throw new RuntimeException("Test: "+child + " already has parent: " + child.getParent());
|
||||
myChildren.add(child);
|
||||
child.myParent = this;
|
||||
if (myPrinter != Printer.DEAF) {
|
||||
child.setPrintLinstener(myPrinter);
|
||||
child.fireOnNewPrintable(child);
|
||||
}
|
||||
setChildPrinter(child);
|
||||
pullEvent(new NewChildEvent(this, child));
|
||||
getState().changeStateAfterAddingChildTo(this, child);
|
||||
myNotifier.onChildAdded(this, child);
|
||||
}
|
||||
|
||||
public void setPrintLinstener(final Printer printer) {
|
||||
myPrinter = printer;
|
||||
for (Iterator iterator = myChildren.iterator(); iterator.hasNext();) {
|
||||
final TestProxy testProxy = (TestProxy) iterator.next();
|
||||
testProxy.setPrintLinstener(printer);
|
||||
}
|
||||
}
|
||||
|
||||
public TestInfo getInfo() {
|
||||
return myInfo;
|
||||
|
||||
@@ -20,8 +20,9 @@ import com.intellij.execution.Location;
|
||||
import com.intellij.execution.PsiLocation;
|
||||
import com.intellij.execution.junit2.segments.ObjectReader;
|
||||
import com.intellij.execution.stacktrace.StackTraceLine;
|
||||
import com.intellij.execution.testframework.AbstractTestProxy;
|
||||
import com.intellij.execution.testframework.CompositePrintable;
|
||||
import com.intellij.execution.testframework.Printer;
|
||||
import com.intellij.execution.testframework.ui.PrintableTestProxy;
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
import com.intellij.openapi.diff.LineTokenizer;
|
||||
import com.intellij.pom.Navigatable;
|
||||
@@ -44,11 +45,11 @@ public class FaultyState extends ReadableState {
|
||||
}
|
||||
|
||||
public void printOn(final Printer printer) {
|
||||
printer.print(PrintableTestProxy.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT);
|
||||
printer.print(CompositePrintable.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT);
|
||||
printer.mark();
|
||||
for (int i = 0; i < myMessages.size(); i++) {
|
||||
printExceptionHeader(printer, myMessages.get(i));
|
||||
printer.print(myStackTraces.get(i) + PrintableTestProxy.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT);
|
||||
printer.print(myStackTraces.get(i) + CompositePrintable.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,9 @@ package com.intellij.execution.junit2.states;
|
||||
import com.intellij.execution.ExecutionBundle;
|
||||
import com.intellij.execution.junit2.TestProxy;
|
||||
import com.intellij.execution.junit2.segments.ObjectReader;
|
||||
import com.intellij.execution.testframework.AbstractTestProxy;
|
||||
import com.intellij.execution.testframework.CompositePrintable;
|
||||
import com.intellij.execution.testframework.Printer;
|
||||
import com.intellij.execution.testframework.ui.PrintableTestProxy;
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
|
||||
public class IgnoredState extends ReadableState {
|
||||
@@ -39,12 +40,12 @@ public class IgnoredState extends ReadableState {
|
||||
public void printOn(final Printer printer) {
|
||||
String parentName = myPeformedTest.getParent() == null ? myPeformedTest.getInfo().getComment() : myPeformedTest.getParent().toString();
|
||||
String message = ExecutionBundle.message("junit.runing.info.ignored.console.message", parentName, myPeformedTest.getInfo().getName());
|
||||
printer.print(message + (myIgnoredMessage.length() > 0 ? " (" + myIgnoredMessage + ")": "") + PrintableTestProxy.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT);
|
||||
printer.print(message + (myIgnoredMessage.length() > 0 ? " (" + myIgnoredMessage + ")": "") + CompositePrintable.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT);
|
||||
if (myMessage.length() > 0) {
|
||||
printer.print(myMessage + PrintableTestProxy.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT);
|
||||
printer.print(myMessage + CompositePrintable.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT);
|
||||
}
|
||||
if (myStackTrace.length() > 0) {
|
||||
printer.print(myStackTrace + PrintableTestProxy.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT);
|
||||
printer.print(myStackTrace + CompositePrintable.NEW_LINE, ConsoleViewContentType.ERROR_OUTPUT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,9 @@ package com.intellij.execution.junit2.states;
|
||||
import com.intellij.execution.junit2.TestProxy;
|
||||
import com.intellij.execution.junit2.segments.ObjectReader;
|
||||
import com.intellij.execution.junit2.ui.Formatters;
|
||||
import com.intellij.execution.testframework.AbstractTestProxy;
|
||||
import com.intellij.execution.testframework.CompositePrintable;
|
||||
import com.intellij.execution.testframework.Printer;
|
||||
import com.intellij.execution.testframework.ui.PrintableTestProxy;
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
|
||||
public class SkippedState extends ReadableState {
|
||||
@@ -31,7 +32,7 @@ public class SkippedState extends ReadableState {
|
||||
}
|
||||
|
||||
public void printOn(final Printer printer) {
|
||||
printer.print(Formatters.printTest(myPeformedTest) + ":" + PrintableTestProxy.NEW_LINE,
|
||||
printer.print(Formatters.printTest(myPeformedTest) + ":" + CompositePrintable.NEW_LINE,
|
||||
ConsoleViewContentType.SYSTEM_OUTPUT);
|
||||
myPeformedTest.printOn(printer);
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.execution.stacktrace.StackTraceLine;
|
||||
import com.intellij.execution.testframework.AbstractTestProxy;
|
||||
import com.intellij.execution.testframework.Filter;
|
||||
import com.intellij.execution.testframework.Printable;
|
||||
import com.intellij.execution.testframework.Printer;
|
||||
import com.intellij.execution.ui.ConsoleViewContentType;
|
||||
import com.intellij.ide.util.EditSourceUtil;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
@@ -42,7 +43,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author Hani Suleiman Date: Jul 28, 2005 Time: 10:52:51 PM
|
||||
*/
|
||||
public class TestProxy implements AbstractTestProxy {
|
||||
public class TestProxy extends AbstractTestProxy {
|
||||
private final List<TestProxy> results = new ArrayList<TestProxy>();
|
||||
private TestResultMessage resultMessage;
|
||||
private String name;
|
||||
@@ -63,10 +64,6 @@ public class TestProxy implements AbstractTestProxy {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public PsiElement getPsiElement() {
|
||||
return psiElement != null ? psiElement.getElement() : null;
|
||||
@@ -202,17 +199,6 @@ public class TestProxy implements AbstractTestProxy {
|
||||
return EditSourceUtil.getDescriptor(location.getPsiElement());
|
||||
}
|
||||
|
||||
public TestProxy[] getPathFromRoot() {
|
||||
ArrayList<TestProxy> arraylist = new ArrayList<TestProxy>();
|
||||
TestProxy testproxy = this;
|
||||
do {
|
||||
arraylist.add(testproxy);
|
||||
}
|
||||
while ((testproxy = testproxy.getParent()) != null);
|
||||
Collections.reverse(arraylist);
|
||||
return arraylist.toArray(new TestProxy[arraylist.size()]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name + ' ' + results;
|
||||
@@ -258,6 +244,11 @@ public class TestProxy implements AbstractTestProxy {
|
||||
return total;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRoot() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getChildCount() {
|
||||
return results.size();
|
||||
}
|
||||
@@ -275,15 +266,6 @@ public class TestProxy implements AbstractTestProxy {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean childExists(String child) {
|
||||
for (int count = 0; count < getChildCount(); count++) {
|
||||
if (child.equals(getChildAt(count).getName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getExceptionMark() {
|
||||
if (myExceptionMark == 0 && getChildCount() > 0) {
|
||||
return (output != null ? output.size() : 0) + getChildAt(0).getExceptionMark();
|
||||
@@ -309,4 +291,16 @@ public class TestProxy implements 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,7 +33,12 @@ public class TreeRootNode extends TestProxy
|
||||
return inProgress;
|
||||
}
|
||||
|
||||
public void setInProgress(boolean inProgress) {
|
||||
@Override
|
||||
public boolean isRoot() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setInProgress(boolean inProgress) {
|
||||
this.inProgress = inProgress;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user