mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
testRunner: make action to navigate from statistics panel to test tree available for all runners
This commit is contained in:
+3
-14
@@ -16,8 +16,7 @@
|
||||
package com.intellij.execution.testframework.sm.runner;
|
||||
|
||||
import com.intellij.execution.testframework.AbstractTestProxy;
|
||||
import com.intellij.execution.testframework.Filter;
|
||||
import com.intellij.ide.util.treeView.AbstractTreeStructure;
|
||||
import com.intellij.execution.testframework.TestTreeViewStructure;
|
||||
import com.intellij.ide.util.treeView.NodeDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -27,16 +26,14 @@ import java.util.List;
|
||||
/**
|
||||
* @author: Roman Chernyatchik
|
||||
*/
|
||||
public class SMTRunnerTreeStructure extends AbstractTreeStructure
|
||||
public class SMTRunnerTreeStructure extends TestTreeViewStructure<SMTestProxy>
|
||||
{
|
||||
private final Object myRootNode;
|
||||
private Filter myTestNodesFilter;
|
||||
private final Project myProject;
|
||||
|
||||
public SMTRunnerTreeStructure(final Project project, final Object rootNode) {
|
||||
myProject = project;
|
||||
myRootNode = rootNode;
|
||||
myTestNodesFilter = Filter.NO_FILTER;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,14 +55,10 @@ public class SMTRunnerTreeStructure extends AbstractTreeStructure
|
||||
(NodeDescriptor<SMTestProxy>)parentDesc);
|
||||
}
|
||||
|
||||
public Filter getFilter() {
|
||||
return myTestNodesFilter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] getChildElements(final Object element) {
|
||||
final List<? extends SMTestProxy> results =
|
||||
((SMTestProxy)element).getChildren(myTestNodesFilter);
|
||||
((SMTestProxy)element).getChildren(getFilter());
|
||||
|
||||
return results.toArray(new AbstractTestProxy[results.size()]);
|
||||
}
|
||||
@@ -80,8 +73,4 @@ public class SMTRunnerTreeStructure extends AbstractTreeStructure
|
||||
public Object getRootElement() {
|
||||
return myRootNode;
|
||||
}
|
||||
|
||||
public void setFilter(final Filter nodesFilter) {
|
||||
myTestNodesFilter = nodesFilter;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -17,6 +17,7 @@ package com.intellij.execution.testframework.sm.runner.ui.statistics;
|
||||
|
||||
import com.intellij.execution.testframework.TestFrameworkRunningModel;
|
||||
import com.intellij.execution.testframework.TestsUIUtil;
|
||||
import com.intellij.execution.testframework.actions.TestContext;
|
||||
import com.intellij.execution.testframework.sm.SMRunnerUtil;
|
||||
import com.intellij.execution.testframework.sm.runner.SMTRunnerEventsAdapter;
|
||||
import com.intellij.execution.testframework.sm.runner.SMTRunnerEventsListener;
|
||||
@@ -163,7 +164,11 @@ public class StatisticsPanel implements DataProvider {
|
||||
if (SM_TEST_RUNNER_STATISTICS.is(dataId)) {
|
||||
return this;
|
||||
}
|
||||
return TestsUIUtil.getData(getSelectedItem(), dataId, myFrameworkRunningModel);
|
||||
final SMTestProxy selectedItem = getSelectedItem();
|
||||
if (TestContext.DATA_KEY.is(dataId)) {
|
||||
return new TestContext(myFrameworkRunningModel, selectedItem);
|
||||
}
|
||||
return TestsUIUtil.getData(selectedItem, dataId, myFrameworkRunningModel);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
package com.intellij.execution.testframework;
|
||||
|
||||
import com.intellij.ide.util.treeView.AbstractTreeStructure;
|
||||
|
||||
public abstract class TestTreeViewStructure<T extends AbstractTestProxy> extends AbstractTreeStructure {
|
||||
private Filter<T> myTestNodesFilter = Filter.NO_FILTER;
|
||||
|
||||
public Filter<T> getFilter() {
|
||||
return myTestNodesFilter;
|
||||
}
|
||||
|
||||
public void setFilter(final Filter<T> nodesFilter) {
|
||||
myTestNodesFilter = nodesFilter;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.execution.junit2.ui.actions;
|
||||
package com.intellij.execution.testframework.actions;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
@@ -24,7 +24,7 @@ public class SelectInTreeAction extends AnAction {
|
||||
final TestContext context = TestContext.from(e);
|
||||
if (!shouldBeEnabled(context))
|
||||
return;
|
||||
context.getModel().selectTest(context.getSelection());
|
||||
context.getModel().getTreeBuilder().select(context.getSelection());
|
||||
}
|
||||
|
||||
public void update(final AnActionEvent e) {
|
||||
+12
-10
@@ -14,30 +14,31 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.intellij.execution.junit2.ui.actions;
|
||||
package com.intellij.execution.testframework.actions;
|
||||
|
||||
import com.intellij.execution.junit2.TestProxy;
|
||||
import com.intellij.execution.junit2.ui.model.JUnitRunningModel;
|
||||
import com.intellij.execution.testframework.AbstractTestProxy;
|
||||
import com.intellij.execution.testframework.TestFrameworkRunningModel;
|
||||
import com.intellij.execution.testframework.TestTreeViewStructure;
|
||||
import com.intellij.ide.util.treeView.AbstractTreeStructure;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DataKey;
|
||||
|
||||
public class TestContext {
|
||||
public static final DataKey<TestContext> DATA_KEY = DataKey.create("JUNIT_CONTEXT");
|
||||
@Deprecated public static final String TEST_CONTEXT = DATA_KEY.getName();
|
||||
|
||||
private final JUnitRunningModel myModel;
|
||||
private final TestProxy mySelection;
|
||||
private final TestFrameworkRunningModel myModel;
|
||||
private final AbstractTestProxy mySelection;
|
||||
|
||||
public TestContext(final JUnitRunningModel model, final TestProxy selection) {
|
||||
public TestContext(final TestFrameworkRunningModel model, final AbstractTestProxy selection) {
|
||||
myModel = model;
|
||||
mySelection = selection;
|
||||
}
|
||||
|
||||
public JUnitRunningModel getModel() {
|
||||
public TestFrameworkRunningModel getModel() {
|
||||
return myModel;
|
||||
}
|
||||
|
||||
public TestProxy getSelection() {
|
||||
public AbstractTestProxy getSelection() {
|
||||
return mySelection;
|
||||
}
|
||||
|
||||
@@ -46,7 +47,8 @@ public class TestContext {
|
||||
}
|
||||
|
||||
public boolean treeContainsSelection() {
|
||||
return getModel().hasInTree(getSelection());
|
||||
final AbstractTreeStructure structure = getModel().getTreeBuilder().getTreeStructure();
|
||||
return structure instanceof TestTreeViewStructure && ((TestTreeViewStructure)structure).getFilter().shouldAccept(getSelection());
|
||||
}
|
||||
|
||||
public static TestContext from(final AnActionEvent event) {
|
||||
@@ -63,11 +63,6 @@
|
||||
</extensionPoints>
|
||||
|
||||
<actions>
|
||||
<group>
|
||||
<separator/>
|
||||
<action id="JUnitTesting.SelectInTree" class="com.intellij.execution.junit2.ui.actions.SelectInTreeAction" text="Select in Tree" description="Navigate from tests statistics to tests tree"/>
|
||||
<add-to-group anchor="last" group-id="TestStatisticsTablePopupMenu"/>
|
||||
</group>
|
||||
<group>
|
||||
<action class="com.intellij.execution.junit.JUnitExcludeFromRunAction" text="Exclude from suite" id="excludeFromSuite"/>
|
||||
<separator/>
|
||||
|
||||
@@ -18,7 +18,7 @@ package com.intellij.execution.junit2.ui;
|
||||
|
||||
import com.intellij.execution.junit2.TestProxy;
|
||||
import com.intellij.execution.junit2.events.TestEvent;
|
||||
import com.intellij.execution.junit2.ui.actions.TestContext;
|
||||
import com.intellij.execution.testframework.actions.TestContext;
|
||||
import com.intellij.execution.junit2.ui.model.JUnitAdapter;
|
||||
import com.intellij.execution.junit2.ui.model.JUnitRunningModel;
|
||||
import com.intellij.execution.testframework.TestsUIUtil;
|
||||
|
||||
@@ -176,10 +176,6 @@ public class JUnitRunningModel implements TestFrameworkRunningModel {
|
||||
return TreeUtil.getPath((TreeNode) myTreeView.getModel().getRoot(), node);
|
||||
}
|
||||
|
||||
public boolean hasInTree(final AbstractTestProxy test) {
|
||||
return getStructure().getFilter().shouldAccept(test);
|
||||
}
|
||||
|
||||
public JUnitConfiguration getConfiguration() {
|
||||
return myProperties.getConfiguration();
|
||||
}
|
||||
|
||||
@@ -16,29 +16,18 @@
|
||||
|
||||
package com.intellij.execution.junit2.ui.model;
|
||||
|
||||
import com.intellij.execution.testframework.Filter;
|
||||
import com.intellij.execution.junit2.TestProxy;
|
||||
import com.intellij.execution.testframework.AbstractTestProxy;
|
||||
import com.intellij.execution.junit2.ui.properties.JUnitConsoleProperties;
|
||||
import com.intellij.ide.util.treeView.AbstractTreeStructure;
|
||||
import com.intellij.execution.testframework.AbstractTestProxy;
|
||||
import com.intellij.execution.testframework.TestTreeViewStructure;
|
||||
import com.intellij.ide.util.treeView.NodeDescriptor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class TestTreeStructure extends AbstractTreeStructure {
|
||||
class TestTreeStructure extends TestTreeViewStructure<TestProxy> {
|
||||
private final TestProxy myRootTest;
|
||||
private final JUnitConsoleProperties myProperties;
|
||||
private SpecialNode mySpecialNode;
|
||||
|
||||
public void setFilter(final Filter filter) {
|
||||
myFilter = filter;
|
||||
}
|
||||
|
||||
public Filter getFilter() {
|
||||
return myFilter;
|
||||
}
|
||||
|
||||
private Filter myFilter = Filter.NO_FILTER;
|
||||
|
||||
public TestTreeStructure(final TestProxy rootTest, final JUnitConsoleProperties properties) {
|
||||
myRootTest = rootTest;
|
||||
myProperties = properties;
|
||||
@@ -51,7 +40,7 @@ class TestTreeStructure extends AbstractTreeStructure {
|
||||
}
|
||||
|
||||
public Object[] getChildElements(final Object element) {
|
||||
final AbstractTestProxy[] children = ((TestProxy)element).selectChildren(myFilter);
|
||||
final AbstractTestProxy[] children = ((TestProxy)element).selectChildren(getFilter());
|
||||
if (element == myRootTest) {
|
||||
if (children.length == 0 && myRootTest.getState().isPassed()) {
|
||||
mySpecialNode.setVisible(true);
|
||||
|
||||
@@ -15,35 +15,22 @@
|
||||
*/
|
||||
package com.theoryinpractice.testng.model;
|
||||
|
||||
import com.intellij.execution.testframework.Filter;
|
||||
import com.intellij.execution.testframework.AbstractTestProxy;
|
||||
import com.intellij.ide.util.treeView.AbstractTreeStructure;
|
||||
import com.intellij.execution.testframework.TestTreeViewStructure;
|
||||
import com.intellij.ide.util.treeView.NodeDescriptor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TestTreeStructure extends AbstractTreeStructure
|
||||
public class TestTreeStructure extends TestTreeViewStructure<TestProxy>
|
||||
{
|
||||
private final Object root;
|
||||
private Filter filter;
|
||||
private final Project project;
|
||||
|
||||
public TestTreeStructure(Project project, Object root) {
|
||||
this.project = project;
|
||||
this.root = root;
|
||||
filter = Filter.NO_FILTER;
|
||||
}
|
||||
|
||||
public void setFilter(Filter filter)
|
||||
{
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
public Filter getFilter()
|
||||
{
|
||||
return filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,7 +42,7 @@ public class TestTreeStructure extends AbstractTreeStructure
|
||||
@Override
|
||||
public Object[] getChildElements(Object obj)
|
||||
{
|
||||
List<AbstractTestProxy> results = ((TestProxy)obj).getResults(filter);
|
||||
List<AbstractTestProxy> results = ((TestProxy)obj).getResults(getFilter());
|
||||
return results.toArray(new AbstractTestProxy[results.size()]);
|
||||
}
|
||||
|
||||
|
||||
@@ -346,6 +346,8 @@
|
||||
<reference ref="EditSource"/>
|
||||
<reference ref="ViewSource"/>
|
||||
<separator/>
|
||||
<action id="Testing.SelectInTree" class="com.intellij.execution.testframework.actions.SelectInTreeAction"
|
||||
text="Select in Tree" description="Navigate from tests statistics to tests tree"/>
|
||||
</group>
|
||||
|
||||
<!-- TODO: fix
|
||||
|
||||
Reference in New Issue
Block a user