Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2013 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2014 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 16-21
Link Here
|
16 |
* Andrew Eisenberg <andrew@eisenberg.as> - [JUnit] Rerun failed first does not work with JUnit4 - https://bugs.eclipse.org/bugs/show_bug.cgi?id=140392 |
16 |
* Andrew Eisenberg <andrew@eisenberg.as> - [JUnit] Rerun failed first does not work with JUnit4 - https://bugs.eclipse.org/bugs/show_bug.cgi?id=140392 |
17 |
* Thirumala Reddy Mutchukota <thirumala@google.com> - [JUnit] Avoid rerun test launch on UI thread - https://bugs.eclipse.org/bugs/show_bug.cgi?id=411841 |
17 |
* Thirumala Reddy Mutchukota <thirumala@google.com> - [JUnit] Avoid rerun test launch on UI thread - https://bugs.eclipse.org/bugs/show_bug.cgi?id=411841 |
18 |
* Andrew Eisenberg <andrew@eisenberg.as> - [JUnit] Add a monospace font option for the junit results view - https://bugs.eclipse.org/bugs/show_bug.cgi?id=411794 |
18 |
* Andrew Eisenberg <andrew@eisenberg.as> - [JUnit] Add a monospace font option for the junit results view - https://bugs.eclipse.org/bugs/show_bug.cgi?id=411794 |
|
|
19 |
* Sandra Lions <sandra.lions-piron@oracle.com> - [JUnit] allow to sort by name and by execution time - https://bugs.eclipse.org/bugs/show_bug.cgi?id=219466 |
19 |
*******************************************************************************/ |
20 |
*******************************************************************************/ |
20 |
package org.eclipse.jdt.internal.junit.ui; |
21 |
package org.eclipse.jdt.internal.junit.ui; |
21 |
|
22 |
|
Lines 163-170
public class TestRunnerViewPart extends ViewPart {
Link Here
|
163 |
|
164 |
|
164 |
static final int REFRESH_INTERVAL= 200; |
165 |
static final int REFRESH_INTERVAL= 200; |
165 |
|
166 |
|
166 |
static final int LAYOUT_FLAT= 0; |
167 |
public static final int LAYOUT_FLAT= 0; |
167 |
static final int LAYOUT_HIERARCHICAL= 1; |
168 |
public static final int LAYOUT_HIERARCHICAL= 1; |
168 |
|
169 |
|
169 |
/** |
170 |
/** |
170 |
* Whether the output scrolls and reveals tests as they are executed. |
171 |
* Whether the output scrolls and reveals tests as they are executed. |
Lines 203-208
public class TestRunnerViewPart extends ViewPart {
Link Here
|
203 |
*/ |
204 |
*/ |
204 |
private boolean fIsDisposed= false; |
205 |
private boolean fIsDisposed= false; |
205 |
|
206 |
|
|
|
207 |
public enum SortingCriterion { |
208 |
SORT_BY_NAME, SORT_BY_EXECUTION_ORDER, SORT_BY_EXECUTION_TIME |
209 |
} |
210 |
/** |
211 |
* The current sorting criterion. |
212 |
*/ |
213 |
private SortingCriterion fSortingCriterion= SortingCriterion.SORT_BY_EXECUTION_ORDER; |
214 |
|
206 |
/** |
215 |
/** |
207 |
* Actions |
216 |
* Actions |
208 |
*/ |
217 |
*/ |
Lines 225-230
public class TestRunnerViewPart extends ViewPart {
Link Here
|
225 |
private ShowTimeAction fShowTimeAction; |
234 |
private ShowTimeAction fShowTimeAction; |
226 |
private ActivateOnErrorAction fActivateOnErrorAction; |
235 |
private ActivateOnErrorAction fActivateOnErrorAction; |
227 |
private IMenuListener fViewMenuListener; |
236 |
private IMenuListener fViewMenuListener; |
|
|
237 |
|
238 |
private MenuManager fSortByMenu; |
239 |
private ToggleSortingAction[] fToggleSortingActions; |
228 |
|
240 |
|
229 |
private TestRunSession fTestRunSession; |
241 |
private TestRunSession fTestRunSession; |
230 |
private TestSessionListener fTestSessionListener; |
242 |
private TestSessionListener fTestSessionListener; |
Lines 279-284
public class TestRunnerViewPart extends ViewPart {
Link Here
|
279 |
*/ |
291 |
*/ |
280 |
static final String TAG_SHOW_TIME= "time"; //$NON-NLS-1$ |
292 |
static final String TAG_SHOW_TIME= "time"; //$NON-NLS-1$ |
281 |
|
293 |
|
|
|
294 |
static final String TAG_SORTING_CRITERION= "SortingCriterion"; //$NON-NLS-1$ |
295 |
|
282 |
/** |
296 |
/** |
283 |
* @since 3.5 |
297 |
* @since 3.5 |
284 |
*/ |
298 |
*/ |
Lines 706-711
public class TestRunnerViewPart extends ViewPart {
Link Here
|
706 |
|
720 |
|
707 |
fStopAction.setEnabled(true); |
721 |
fStopAction.setEnabled(true); |
708 |
fRerunLastTestAction.setEnabled(true); |
722 |
fRerunLastTestAction.setEnabled(true); |
|
|
723 |
|
724 |
getDisplay().asyncExec(new Runnable() { |
725 |
public void run() { |
726 |
setSortingCriterion(SortingCriterion.SORT_BY_EXECUTION_ORDER); |
727 |
} |
728 |
}); |
709 |
} |
729 |
} |
710 |
|
730 |
|
711 |
public void sessionEnded(long elapsedTime){ |
731 |
public void sessionEnded(long elapsedTime){ |
Lines 961-966
public class TestRunnerViewPart extends ViewPart {
Link Here
|
961 |
} |
981 |
} |
962 |
} |
982 |
} |
963 |
|
983 |
|
|
|
984 |
private class ToggleSortingAction extends Action { |
985 |
private final SortingCriterion fActionSortingCriterion; |
986 |
|
987 |
public ToggleSortingAction(SortingCriterion sortingCriterion) { |
988 |
super("", AS_RADIO_BUTTON); //$NON-NLS-1$ |
989 |
switch (sortingCriterion) { |
990 |
case SORT_BY_NAME: |
991 |
setText(JUnitMessages.TestRunnerViewPart_toggle_name_label); |
992 |
break; |
993 |
case SORT_BY_EXECUTION_ORDER: |
994 |
setText(JUnitMessages.TestRunnerViewPart_toggle_execution_order_label); |
995 |
break; |
996 |
case SORT_BY_EXECUTION_TIME: |
997 |
setText(JUnitMessages.TestRunnerViewPart_toggle_execution_time_label); |
998 |
break; |
999 |
default: |
1000 |
break; |
1001 |
} |
1002 |
fActionSortingCriterion= sortingCriterion; |
1003 |
} |
1004 |
|
1005 |
@Override |
1006 |
public void run() { |
1007 |
if (isChecked()) { |
1008 |
setSortingCriterion(fActionSortingCriterion); |
1009 |
} |
1010 |
} |
1011 |
|
1012 |
public SortingCriterion getActionSortingCriterion() { |
1013 |
return fActionSortingCriterion; |
1014 |
} |
1015 |
} |
1016 |
|
1017 |
public SortingCriterion getSortingCriterion() { |
1018 |
return fSortingCriterion; |
1019 |
} |
1020 |
|
1021 |
public void setSortingCriterion(SortingCriterion sortingCriterion) { |
1022 |
fSortingCriterion= sortingCriterion; |
1023 |
fTestViewer.setSortingCriterion(sortingCriterion); |
1024 |
for (int i= 0; i < fToggleSortingActions.length; ++i) { |
1025 |
fToggleSortingActions[i].setChecked(sortingCriterion == fToggleSortingActions[i].getActionSortingCriterion()); |
1026 |
} |
1027 |
} |
1028 |
|
1029 |
private void updateSortByMenu() { |
1030 |
if (fTestRunSession != null) { |
1031 |
if (fTestRunSession.isStarting() || fTestRunSession.isRunning() || fTestRunSession.isKeptAlive()) { |
1032 |
setSortingCriterion(SortingCriterion.SORT_BY_EXECUTION_ORDER); |
1033 |
fSortByMenu.getMenu().setEnabled(false); |
1034 |
} else { |
1035 |
fSortByMenu.getMenu().setEnabled(true); |
1036 |
} |
1037 |
} else { |
1038 |
setSortingCriterion(SortingCriterion.SORT_BY_EXECUTION_ORDER); |
1039 |
fSortByMenu.getMenu().setEnabled(false); |
1040 |
} |
1041 |
} |
1042 |
|
964 |
/** |
1043 |
/** |
965 |
* Listen for for modifications to Java elements |
1044 |
* Listen for for modifications to Java elements |
966 |
*/ |
1045 |
*/ |
Lines 1145-1150
public class TestRunnerViewPart extends ViewPart {
Link Here
|
1145 |
memento.putString(TAG_FAILURES_ONLY, fFailuresOnlyFilterAction.isChecked() ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$ |
1224 |
memento.putString(TAG_FAILURES_ONLY, fFailuresOnlyFilterAction.isChecked() ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$ |
1146 |
memento.putInteger(TAG_LAYOUT, fLayout); |
1225 |
memento.putInteger(TAG_LAYOUT, fLayout); |
1147 |
memento.putString(TAG_SHOW_TIME, fShowTimeAction.isChecked() ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$ |
1226 |
memento.putString(TAG_SHOW_TIME, fShowTimeAction.isChecked() ? "true" : "false"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
|
1227 |
memento.putString(TAG_SORTING_CRITERION, fSortingCriterion.name()); |
1148 |
} |
1228 |
} |
1149 |
|
1229 |
|
1150 |
private void restoreLayoutState(IMemento memento) { |
1230 |
private void restoreLayoutState(IMemento memento) { |
Lines 1183-1188
public class TestRunnerViewPart extends ViewPart {
Link Here
|
1183 |
boolean showTime= true; |
1263 |
boolean showTime= true; |
1184 |
if (time != null) |
1264 |
if (time != null) |
1185 |
showTime= time.equals("true"); //$NON-NLS-1$ |
1265 |
showTime= time.equals("true"); //$NON-NLS-1$ |
|
|
1266 |
|
1267 |
SortingCriterion sortingCriterion= SortingCriterion.SORT_BY_EXECUTION_ORDER; |
1268 |
String tagSortingCriterion= memento.getString(TAG_SORTING_CRITERION); |
1269 |
if (tagSortingCriterion != null) { |
1270 |
sortingCriterion= Enum.valueOf(SortingCriterion.class, tagSortingCriterion); |
1271 |
} |
1272 |
setSortingCriterion(sortingCriterion); |
1186 |
|
1273 |
|
1187 |
setFilterAndLayout(showFailuresOnly, layoutValue); |
1274 |
setFilterAndLayout(showFailuresOnly, layoutValue); |
1188 |
setShowExecutionTime(showTime); |
1275 |
setShowExecutionTime(showTime); |
Lines 1514-1519
action enablement
Link Here
|
1514 |
fStopAction.setEnabled(fTestRunSession.isKeptAlive()); |
1601 |
fStopAction.setEnabled(fTestRunSession.isKeptAlive()); |
1515 |
fTestViewer.expandFirstLevel(); |
1602 |
fTestViewer.expandFirstLevel(); |
1516 |
} |
1603 |
} |
|
|
1604 |
|
1605 |
updateSortByMenu(); |
1517 |
} |
1606 |
} |
1518 |
return deactivatedSession; |
1607 |
return deactivatedSession; |
1519 |
} |
1608 |
} |
Lines 1942-1947
action enablement
Link Here
|
1942 |
viewMenu.add(fShowTestHierarchyAction); |
2031 |
viewMenu.add(fShowTestHierarchyAction); |
1943 |
viewMenu.add(fShowTimeAction); |
2032 |
viewMenu.add(fShowTimeAction); |
1944 |
viewMenu.add(new Separator()); |
2033 |
viewMenu.add(new Separator()); |
|
|
2034 |
fToggleSortingActions= |
2035 |
new ToggleSortingAction[] { |
2036 |
new ToggleSortingAction(SortingCriterion.SORT_BY_EXECUTION_ORDER), |
2037 |
new ToggleSortingAction(SortingCriterion.SORT_BY_EXECUTION_TIME), |
2038 |
new ToggleSortingAction(SortingCriterion.SORT_BY_NAME)}; |
2039 |
fSortByMenu= new MenuManager(JUnitMessages.TestRunnerViewPart_sort_by_menu); |
2040 |
for (int i= 0; i < fToggleSortingActions.length; ++i) { |
2041 |
fSortByMenu.add(fToggleSortingActions[i]); |
2042 |
} |
2043 |
viewMenu.add(fSortByMenu); |
2044 |
viewMenu.add(new Separator()); |
1945 |
|
2045 |
|
1946 |
MenuManager layoutSubMenu= new MenuManager(JUnitMessages.TestRunnerViewPart_layout_menu); |
2046 |
MenuManager layoutSubMenu= new MenuManager(JUnitMessages.TestRunnerViewPart_layout_menu); |
1947 |
for (int i = 0; i < fToggleOrientationActions.length; ++i) { |
2047 |
for (int i = 0; i < fToggleOrientationActions.length; ++i) { |
Lines 1958-1963
action enablement
Link Here
|
1958 |
fViewMenuListener= new IMenuListener() { |
2058 |
fViewMenuListener= new IMenuListener() { |
1959 |
public void menuAboutToShow(IMenuManager manager) { |
2059 |
public void menuAboutToShow(IMenuManager manager) { |
1960 |
fActivateOnErrorAction.update(); |
2060 |
fActivateOnErrorAction.update(); |
|
|
2061 |
updateSortByMenu(); |
1961 |
} |
2062 |
} |
1962 |
}; |
2063 |
}; |
1963 |
|
2064 |
|
Lines 2174-2185
action enablement
Link Here
|
2174 |
return fFailureTrace; |
2275 |
return fFailureTrace; |
2175 |
} |
2276 |
} |
2176 |
|
2277 |
|
|
|
2278 |
public TestViewer getTestViewer() { |
2279 |
return fTestViewer; |
2280 |
} |
2177 |
|
2281 |
|
2178 |
void setShowFailuresOnly(boolean failuresOnly) { |
2282 |
void setShowFailuresOnly(boolean failuresOnly) { |
2179 |
setFilterAndLayout(failuresOnly, fLayout); |
2283 |
setFilterAndLayout(failuresOnly, fLayout); |
2180 |
} |
2284 |
} |
2181 |
|
2285 |
|
2182 |
private void setLayoutMode(int mode) { |
2286 |
public void setLayoutMode(int mode) { |
2183 |
setFilterAndLayout(fFailuresOnlyFilterAction.isChecked(), mode); |
2287 |
setFilterAndLayout(fFailuresOnlyFilterAction.isChecked(), mode); |
2184 |
} |
2288 |
} |
2185 |
|
2289 |
|