tests: simplified animation

This commit is contained in:
Anna Kozlova
2015-04-07 11:26:14 +02:00
parent 9f700af6be
commit 6a700ff040
8 changed files with 40 additions and 104 deletions
@@ -163,7 +163,7 @@ public class SMTestRunnerResultsForm extends TestResultsPanel
myTreeBuilder.setTestsComparator(TestConsoleProperties.SORT_ALPHABETICALLY.value(myProperties));
Disposer.register(this, myTreeBuilder);
myAnimator = new MyAnimator(this, myTreeBuilder);
myAnimator = new TestsProgressAnimator(myTreeBuilder);
//TODO always hide root node
//myTreeView.setRootVisible(false);
@@ -570,13 +570,6 @@ public class SMTestRunnerResultsForm extends TestResultsPanel
}
private static class MyAnimator extends TestsProgressAnimator {
public MyAnimator(final Disposable parentDisposable, final AbstractTestTreeBuilder builder) {
super(parentDisposable);
init(builder);
}
}
private void updateCountersAndProgressOnTestCount(final int count, final boolean isCustomMessage) {
if (!isModeConsistent(isCustomMessage)) return;
@@ -24,7 +24,7 @@ import org.jetbrains.annotations.Nullable;
import javax.swing.*;
public abstract class TestsProgressAnimator implements Runnable, Disposable {
public class TestsProgressAnimator implements Runnable, Disposable {
private static final int FRAMES_COUNT = 8;
private static final int MOVIE_TIME = 800;
private static final int FRAME_TIME = MOVIE_TIME / FRAMES_COUNT;
@@ -37,8 +37,9 @@ public abstract class TestsProgressAnimator implements Runnable, Disposable {
private AbstractTestProxy myCurrentTestCase;
private AbstractTestTreeBuilder myTreeBuilder;
protected TestsProgressAnimator(Disposable parentDisposable) {
Disposer.register(parentDisposable, this);
public TestsProgressAnimator(AbstractTestTreeBuilder builder) {
Disposer.register(builder, this);
init(builder);
}
static {
@@ -1,56 +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.ui;
import com.intellij.execution.junit2.events.StateChangedEvent;
import com.intellij.execution.junit2.events.TestEvent;
import com.intellij.execution.junit2.TestProxy;
import com.intellij.execution.junit2.ui.model.JUnitAdapter;
import com.intellij.execution.junit2.ui.model.JUnitRunningModel;
import com.intellij.execution.junit2.ui.model.StateEvent;
import com.intellij.execution.testframework.ui.TestsProgressAnimator;
import com.intellij.openapi.Disposable;
import com.intellij.rt.execution.junit.states.PoolOfTestStates;
public class Animator extends TestsProgressAnimator {
public Animator(Disposable parentDisposable) {
super(parentDisposable);
}
public void setModel(final JUnitRunningModel model) {
init(model.getTreeBuilder());
model.addListener(new JUnitAdapter() {
public void onTestChanged(final TestEvent event) {
if (event instanceof StateChangedEvent) {
final TestProxy test = event.getSource();
if (test.isLeaf() && test.getState().getMagnitude() == PoolOfTestStates.RUNNING_INDEX)
setCurrentTestCase(test);
}
}
public void onRunnerStateChanged(final StateEvent event) {
if (!event.isRunning())
stopMovie();
}
public void doDispose() {
dispose();
}
});
}
}
@@ -21,6 +21,7 @@ import com.intellij.execution.junit2.info.TestInfo;
import com.intellij.execution.junit2.ui.model.SpecialNode;
import com.intellij.execution.testframework.PoolOfTestIcons;
import com.intellij.execution.testframework.TestsUIUtil;
import com.intellij.execution.testframework.ui.TestsProgressAnimator;
import com.intellij.icons.AllIcons;
import com.intellij.rt.execution.junit.states.PoolOfTestStates;
import com.intellij.ui.SimpleColoredComponent;
@@ -36,7 +37,7 @@ class TestRenderer {
public static Icon getIconFor(final TestProxy testProxy, final boolean isPaused) {
final int magnitude = testProxy.getState().getMagnitude();
if (magnitude == PoolOfTestStates.RUNNING_INDEX)
return isPaused ? AllIcons.RunConfigurations.TestPaused : Animator.getCurrentFrame();
return isPaused ? AllIcons.RunConfigurations.TestPaused : TestsProgressAnimator.getCurrentFrame();
else
return ourIcons.get(new Integer(magnitude));
}
@@ -18,7 +18,8 @@ package com.intellij.execution.junit2.ui.model;
import com.intellij.execution.junit.JUnitConfiguration;
import com.intellij.execution.junit2.TestProxy;
import com.intellij.execution.junit2.ui.Animator;
import com.intellij.execution.junit2.events.StateChangedEvent;
import com.intellij.execution.junit2.events.TestEvent;
import com.intellij.execution.junit2.ui.TestProgress;
import com.intellij.execution.junit2.ui.TestProxyClient;
import com.intellij.execution.junit2.ui.properties.JUnitConsoleProperties;
@@ -26,10 +27,12 @@ import com.intellij.execution.testframework.AbstractTestProxy;
import com.intellij.execution.testframework.Filter;
import com.intellij.execution.testframework.TestFrameworkRunningModel;
import com.intellij.execution.testframework.TestTreeView;
import com.intellij.execution.testframework.ui.TestsProgressAnimator;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Disposer;
import com.intellij.rt.execution.junit.states.PoolOfTestStates;
import com.intellij.util.ui.tree.TreeUtil;
import javax.swing.*;
@@ -50,7 +53,7 @@ public class JUnitRunningModel implements TestFrameworkRunningModel {
private TestTreeBuilder myTreeBuilder;
private final JUnitListenersNotifier myNotifier = new JUnitListenersNotifier();
private final Animator myAnimator;
private TestsProgressAnimator myAnimator;
public JUnitRunningModel(final TestProxy root, final JUnitConsoleProperties properties) {
myRoot = root;
@@ -64,7 +67,6 @@ public class JUnitRunningModel implements TestFrameworkRunningModel {
myNotifier.fireDisposed(JUnitRunningModel.this);
}
});
myAnimator = new Animator(this);
}
public TestTreeBuilder getTreeBuilder() {
@@ -74,7 +76,27 @@ public class JUnitRunningModel implements TestFrameworkRunningModel {
public void attachToTree(final TestTreeView treeView) {
myTreeBuilder = new TestTreeBuilder(treeView, this, myProperties);
Disposer.register(this, myTreeBuilder);
myAnimator.setModel(this);
myAnimator = new TestsProgressAnimator(myTreeBuilder);
addListener(new JUnitAdapter() {
public void onTestChanged(final TestEvent event) {
if (event instanceof StateChangedEvent) {
final TestProxy test = event.getSource();
if (test.isLeaf() && test.getState().getMagnitude() == PoolOfTestStates.RUNNING_INDEX) {
myAnimator.setCurrentTestCase(test);
}
}
}
public void onRunnerStateChanged(final StateEvent event) {
if (!event.isRunning()) {
myAnimator.stopMovie();
}
}
public void doDispose() {
dispose();
}
});
myTreeView = treeView;
selectTest(getRoot());
myTreeListener.install();
@@ -1,27 +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.theoryinpractice.testng.ui;
import com.intellij.execution.testframework.ui.TestsProgressAnimator;
import com.intellij.openapi.Disposable;
import com.theoryinpractice.testng.model.TestTreeBuilder;
public class Animator extends TestsProgressAnimator {
public Animator(final Disposable parentDisposable, final TestTreeBuilder builder) {
super(parentDisposable);
init(builder);
}
}
@@ -17,6 +17,7 @@ package com.theoryinpractice.testng.ui;
import com.intellij.execution.testframework.PoolOfTestIcons;
import com.intellij.execution.testframework.TestFrameworkRunningModel;
import com.intellij.execution.testframework.ui.TestsProgressAnimator;
import com.intellij.icons.AllIcons;
import com.intellij.ui.ColoredTreeCellRenderer;
import com.intellij.ui.SimpleTextAttributes;
@@ -62,7 +63,7 @@ public class ResultTreeRenderer extends ColoredTreeCellRenderer
}
} else {
setIcon(root.isInProgress() ? Animator.getCurrentFrame() : getIcon(proxy));
setIcon(root.isInProgress() ? TestsProgressAnimator.getCurrentFrame() : getIcon(proxy));
append(root.isInProgress() ? "Running tests..." : "Test Results", SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
@@ -77,10 +78,10 @@ public class ResultTreeRenderer extends ColoredTreeCellRenderer
} else {
append(proxy.getName(), SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
setIcon(proxy.isInProgress() ? Animator.getCurrentFrame() : proxy.isInterrupted() ? PoolOfTestIcons.NOT_RAN : getIcon(proxy));
setIcon(proxy.isInProgress() ? TestsProgressAnimator.getCurrentFrame() : proxy.isInterrupted() ? PoolOfTestIcons.NOT_RAN : getIcon(proxy));
}
} else {
setIcon(Animator.getCurrentFrame());
setIcon(TestsProgressAnimator.getCurrentFrame());
append(node.getUserObject() != null ? node.getUserObject().toString() : "null", SimpleTextAttributes.REGULAR_ATTRIBUTES);
}
}
@@ -28,6 +28,7 @@ import com.intellij.execution.runners.ExecutionEnvironment;
import com.intellij.execution.testframework.*;
import com.intellij.execution.testframework.actions.ScrollToTestSourceAction;
import com.intellij.execution.testframework.ui.TestResultsPanel;
import com.intellij.execution.testframework.ui.TestsProgressAnimator;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.DefaultActionGroup;
import com.intellij.openapi.application.ApplicationManager;
@@ -80,7 +81,6 @@ public class TestNGResults extends TestResultsPanel implements TestFrameworkRunn
private long start;
private long end;
private TestTreeBuilder treeBuilder;
private Animator animator;
private final TreeRootNode rootNode;
private static final String NO_PACKAGE = "No Package";
@@ -88,6 +88,7 @@ public class TestNGResults extends TestResultsPanel implements TestFrameworkRunn
private int myStatus = MessageHelper.PASSED_TEST;
private Set<String> startedMethods = new HashSet<String>();
private TestProxy myLastSelected;
private TestsProgressAnimator animator;
public TestNGResults(final JComponent component,
final TestNGConfiguration configuration,
@@ -135,7 +136,7 @@ public class TestNGResults extends TestResultsPanel implements TestFrameworkRunn
treeBuilder = new TestTreeBuilder(tree, structure);
Disposer.register(this, treeBuilder);
animator = new Animator(this, treeBuilder);
animator = new TestsProgressAnimator(treeBuilder);
openSourceListener = new OpenSourceSelectionListener();
tree.getSelectionModel().addTreeSelectionListener(openSourceListener);