cleanup testframework/sm

This commit is contained in:
Sergey Ignatov
2018-05-10 00:14:43 +02:00
parent 755e5b17f0
commit 61fb8b438e
15 changed files with 33 additions and 263 deletions
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2015 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.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.testframework.sm;
import com.intellij.openapi.application.Application;
@@ -21,9 +7,6 @@ import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.util.ui.UIUtil;
import javax.swing.*;
import java.awt.event.ActionEvent;
/**
* @author Roman Chernyatchik
*/
@@ -1,4 +1,4 @@
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.testframework.sm;
import com.intellij.execution.ExecutionException;
@@ -72,8 +72,6 @@ public class SMTestRunnerConnectionUtil {
* @param processHandler Process handler
* @param consoleProperties Console properties for test console actions
* @return Console view
* @throws ExecutionException If IDEA cannot execute process this exception will
* be caught and shown in error message box
*/
@NotNull
public static BaseTestsOutputConsoleView createAndAttachConsole(@NotNull String testFrameworkName,
@@ -1,26 +1,10 @@
/*
* 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.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.testframework.sm.runner;
import com.intellij.util.messages.Topic;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.List;
/**
* @author Roman Chernyatchik
*
@@ -36,7 +20,7 @@ public interface SMTRunnerEventsListener {
void onTestingStarted(@NotNull SMTestProxy.SMRootTestProxy testsRoot);
/**
* After test framework finish testing
* @param testsRootNode
* @param testsRoot
*/
void onTestingFinished(@NotNull SMTestProxy.SMRootTestProxy testsRoot);
/*
@@ -1,23 +1,8 @@
/*
* 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.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.testframework.sm.runner;
import com.intellij.execution.testframework.ui.AbstractTestTreeBuilder;
import com.intellij.ide.util.treeView.AbstractTreeStructure;
import com.intellij.ide.util.treeView.AbstractTreeUpdater;
import com.intellij.ide.util.treeView.IndexComparator;
import com.intellij.ide.util.treeView.NodeDescriptor;
@@ -1,24 +1,9 @@
/*
* 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.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.testframework.sm.runner;
import com.intellij.execution.testframework.sm.SMTestRunnerConnectionUtil;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Function;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2015 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.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.testframework.sm.runner.history;
import com.intellij.execution.process.ProcessOutputTypes;
@@ -74,12 +60,12 @@ public class ImportedTestContentHandler extends DefaultHandler {
}
@Override
public void characters(char[] ch, int start, int length) throws SAXException {
public void characters(char[] ch, int start, int length) {
currentValue.append(ch, start, length);
}
@Override
public void endElement(String uri, String localName, String qName) throws SAXException {
public void endElement(String uri, String localName, String qName) {
final String currentText = StringUtil.unescapeXml(currentValue.toString());
final boolean isTestOutput = myCurrentTest == null || TestResultsXmlFormatter.STATUS_PASSED.equals(myStatus) || myErrorOutput;
if (isTestOutput) {
@@ -1,22 +1,7 @@
/*
* Copyright 2000-2015 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.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.testframework.sm.runner.history;
import com.intellij.execution.DefaultExecutionResult;
import com.intellij.execution.ExecutionException;
import com.intellij.execution.ExecutionResult;
import com.intellij.execution.Executor;
import com.intellij.execution.configurations.RunProfile;
@@ -47,7 +32,7 @@ public class ImportedTestRunnableState implements RunProfileState {
@Nullable
@Override
public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
public ExecutionResult execute(Executor executor, @NotNull ProgramRunner runner) {
final MyEmptyProcessHandler handler = new MyEmptyProcessHandler();
final SMTRunnerConsoleProperties properties = myRunProfile.getProperties();
RunProfile configuration;
@@ -1,22 +1,7 @@
/*
* Copyright 2000-2015 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.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.testframework.sm.runner.history.actions;
import com.intellij.execution.testframework.sm.runner.SMTRunnerConsoleProperties;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.fileChooser.FileChooser;
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
@@ -1,18 +1,4 @@
/*
* 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.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.testframework.sm.runner.states;
import com.intellij.execution.process.ProcessOutputTypes;
@@ -25,7 +11,6 @@ import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@@ -47,7 +32,7 @@ public class TestFailedState extends AbstractState implements Disposable{
if (msg != null) {
myPresentationText.add(msg);
if (printer != null) {
printError(printer, Arrays.asList(msg), false);
printError(printer, Collections.singletonList(msg), false);
}
}
}
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2015 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.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.testframework.sm.runner.ui;
import com.intellij.execution.testframework.TestConsoleProperties;
@@ -44,7 +30,7 @@ public class TestTreeRenderer extends ColoredTreeCellRenderer {
myConsoleProperties = consoleProperties;
}
public void customizeCellRenderer(final JTree tree,
public void customizeCellRenderer(@NotNull final JTree tree,
final Object value,
final boolean selected,
final boolean expanded,
@@ -1,18 +1,4 @@
/*
* 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.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.testframework.sm;
import com.intellij.openapi.util.Pair;
@@ -55,9 +41,5 @@ public class UITestUtil {
public SimpleTextAttributes getAttribsAt(final int index) {
return myFragments.get(index).second;
}
public void clear() {
myFragments.clear();
}
}
}
@@ -1,18 +1,4 @@
/*
* 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.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.testframework.sm.runner;
import com.intellij.execution.configurations.ModuleRunConfiguration;
@@ -95,21 +81,4 @@ public abstract class BaseSMTRunnerTestCase extends LightPlatformTestCase {
return consoleProperties;
}
protected void doPassTest(final SMTestProxy test) {
test.setStarted();
test.setFinished();
}
protected void doFailTest(final SMTestProxy test) {
test.setStarted();
test.setTestFailed("", "", false);
test.setFinished();
}
protected void doErrorTest(final SMTestProxy test) {
test.setStarted();
test.setTestFailed("", "", true);
test.setFinished();
}
}
@@ -1,22 +1,7 @@
/*
* Copyright 2000-2015 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.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.testframework.sm.runner;
import com.intellij.execution.executors.DefaultRunExecutor;
import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.testframework.Filter;
import com.intellij.execution.testframework.TestConsoleProperties;
import com.intellij.execution.testframework.actions.AbstractRerunFailedTestsAction;
@@ -63,10 +48,10 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
private class MyConsoleView extends SMTRunnerConsoleView {
private final TestsOutputConsolePrinter myTestsOutputConsolePrinter;
private MyConsoleView(final TestConsoleProperties consoleProperties, final ExecutionEnvironment environment) {
private MyConsoleView(final TestConsoleProperties consoleProperties) {
super(consoleProperties);
myTestsOutputConsolePrinter = new TestsOutputConsolePrinter(MyConsoleView.this, consoleProperties, null) {
myTestsOutputConsolePrinter = new TestsOutputConsolePrinter(this, consoleProperties, null) {
@Override
public void print(final String text, final ConsoleViewContentType contentType) {
myMockResettablePrinter.print(text, contentType);
@@ -91,9 +76,8 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
TestConsoleProperties.SELECT_FIRST_DEFECT.set(consoleProperties, false);
TestConsoleProperties.TRACK_RUNNING_TEST.set(consoleProperties, false);
final ExecutionEnvironment environment = new ExecutionEnvironment();
myMockResettablePrinter = new MockPrinter(true);
myConsole = new MyConsoleView(consoleProperties, environment);
myConsole = new MyConsoleView(consoleProperties);
myConsole.initUI();
myResultsViewer = myConsole.getResultsViewer();
myEventsProcessor = new GeneralToSMTRunnerEventsConvertor(consoleProperties.getProject(), myResultsViewer.getTestsRootNode(), "SMTestFramework");
@@ -262,7 +246,7 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
onTestStarted("some_test");
final String fullName = myEventsProcessor.getFullTestName("some_test");
final SMTestProxy proxy = myEventsProcessor.getProxyByFullTestName(fullName);
myEventsProcessor.onTestFinished(new TestFinishedEvent("some_test", 10l));
myEventsProcessor.onTestFinished(new TestFinishedEvent("some_test", 10L));
assertEquals(0, myEventsProcessor.getRunningTestsQuantity());
@@ -306,7 +290,7 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
public void testOnFinishedTesting_WithFailure() {
onTestStarted("test");
myEventsProcessor.onTestFailure(new TestFailedEvent("test", "", "", false, null, null));
myEventsProcessor.onTestFinished(new TestFinishedEvent("test", 10l));
myEventsProcessor.onTestFinished(new TestFinishedEvent("test", 10L));
myEventsProcessor.onFinishTesting();
//Tree
@@ -322,7 +306,7 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
public void testOnFinishedTesting_WithError() {
onTestStarted("test");
myEventsProcessor.onTestFailure(new TestFailedEvent("test", "", "", true, null, null));
myEventsProcessor.onTestFinished(new TestFinishedEvent("test", 10l));
myEventsProcessor.onTestFinished(new TestFinishedEvent("test", 10L));
myEventsProcessor.onFinishTesting();
//Tree
@@ -338,7 +322,7 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
public void testOnFinishedTesting_WithIgnored() {
onTestStarted("test");
myEventsProcessor.onTestIgnored(new TestIgnoredEvent("test", "", null));
myEventsProcessor.onTestFinished(new TestFinishedEvent("test", 10l));
myEventsProcessor.onTestFinished(new TestFinishedEvent("test", 10L));
myEventsProcessor.onFinishTesting();
//Tree
@@ -385,7 +369,7 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
assertEquals("suite3", test2.getParent().getName());
assertEquals("suite2", test2.getParent().getParent().getName());
myEventsProcessor.onTestFinished(new TestFinishedEvent("test2", 10l));
myEventsProcessor.onTestFinished(new TestFinishedEvent("test2", 10L));
//check that after finishing suite (suite3), current will be parent of finished suite (i.e. suite2)
myEventsProcessor.onSuiteFinished(new TestSuiteFinishedEvent("suite3"));
@@ -430,7 +414,7 @@ public class GeneralToSMTRunnerEventsConvertorTest extends BaseSMTRunnerTestCase
myEventsProcessor.onSuiteFinished(new TestSuiteFinishedEvent("suite1"));
myEventsProcessor.onSuiteStarted(new TestSuiteStartedEvent("suite2", null));
myEventsProcessor.onTestFinished(new TestFinishedEvent("suite2.test1", 10l));
myEventsProcessor.onTestFinished(new TestFinishedEvent("suite2.test1", 10L));
myEventsProcessor.onSuiteFinished(new TestSuiteFinishedEvent("suite2"));
assertNotNull(test1);
@@ -32,7 +32,7 @@ public class SMTRunnerConsoleTest extends BaseSMTRunnerTestCase {
private MyConsoleView(final TestConsoleProperties consoleProperties) {
super(consoleProperties);
myTestsOutputConsolePrinter = new TestsOutputConsolePrinter(MyConsoleView.this, consoleProperties, null) {
myTestsOutputConsolePrinter = new TestsOutputConsolePrinter(this, consoleProperties, null) {
@Override
public void print(final String text, final ConsoleViewContentType contentType) {
myMockResettablePrinter.print(text, contentType);
@@ -1,28 +1,12 @@
/*
* 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.
*/
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.intellij.execution.testframework.sm.runner.ui;
import com.intellij.execution.testframework.AbstractTestProxy;
import com.intellij.execution.testframework.TestConsoleProperties;
import com.intellij.execution.testframework.sm.runner.SMTestProxy;
import com.intellij.ui.tabs.JBTabs;
import com.intellij.openapi.util.Disposer;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
/**
* @author Roman Chernyatchik
*/
@@ -30,19 +14,11 @@ public class MockTestResultsViewer implements TestResultsViewer {
private final TestConsoleProperties myProperties;
private final SMTestProxy myRootSuite;
public MockTestResultsViewer(final TestConsoleProperties properties,
final SMTestProxy suite) {
public MockTestResultsViewer(TestConsoleProperties properties, SMTestProxy suite) {
myProperties = properties;
myRootSuite = suite;
}
public void addTab(final String name, @Nullable final String tooltip, final Icon icon, final JComponent contentPane) {}
@Nullable
public JComponent getContentPane() {
return null;
}
@Override
public SMTestProxy getTestsRootNode() {
return myRootSuite;
@@ -54,12 +30,9 @@ public class MockTestResultsViewer implements TestResultsViewer {
@Override
public void addEventsListener(final EventsListener listener) {}
public JBTabs getTabs() { return null; }
@Override
public void dispose() {
myProperties.dispose();
Disposer.dispose(myProperties);
}
@Override