Class GUIRunner.HierarchyWrapper
- java.lang.Object
-
- eu.simuline.testhelpers.GUIRunner.HierarchyWrapper
-
- All Implemented Interfaces:
GUIRunner.Selector
,java.util.EventListener
,javax.swing.event.TreeSelectionListener
- Enclosing class:
- GUIRunner
static class GUIRunner.HierarchyWrapper extends java.lang.Object implements GUIRunner.Selector, javax.swing.event.TreeSelectionListener
Represents the hierarchy of testsuites and testcases as a treehierarchyTree
possibly with a single selected node given bysingleSelectedNode
.
-
-
Field Summary
Fields Modifier and Type Field Description private Actions
actions
This is used only byvalueChanged(TreeSelectionEvent)
to set the filter viaActions.setFilter(Description)
.private GUIRunner.TreePathIterator
currPathIter
Represents the path to the testcase currently run.private javax.swing.JTree
hierarchyTree
The hierarchy of testsuites and testcases as a tree.private GUIRunner.Selector
selector
Selector to be influenced: If this is in the selected tab,selector
is the tab with theTestCaseLister
; otherwise it isGUIRunner.TabChangeListener.EMPTY_SELECTOR
.private javax.swing.tree.DefaultMutableTreeNode
singleSelectedNode
Represents the selected node inhierarchyTree
.private GUIRunner.TestCaseLister
testCaseLister
The theGUIRunner.TestCaseLister
listing the failed test cases.private javax.swing.tree.TreeSelectionModel
treeSelection
The selection model forhierarchyTree
.
-
Constructor Summary
Constructors Constructor Description HierarchyWrapper(Actions actions, GUIRunner.TestCaseLister testCaseLister)
Creates a new HierarchyWrapper with the givenactions
andtestCaseLister
which are used to initializeactions
andtestCaseLister
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearSelection()
Clears the selection.(package private) void
collapseAlongPath()
Collapses the path to the leafcurrPathIter
points to as much as possible in order not to hidesingleSelectedNode
and the leafs corresponding with singular tests which failed already (assumption failure, failure and error).(package private) void
expandAlongPath()
Expands the path to the leafcurrPathIter
points to.(package private) Actions
getActions()
Returns the action.(package private) javax.swing.tree.TreePath
getPath()
(package private) TestCase
getRoot()
(package private) javax.swing.JTree
getTree()
(package private) void
initClassStructure(TestCase testCase)
Notifies that the structure of the test class may have been updated.private boolean
isSelected(TestCase testCase)
Returns whether the given testcasetestCase
is selected in this HierarchyTree.(package private) void
noteReportResult(TestCase testCase)
Notifies that the singular testtestCase
is finished.(package private) TestCase
noteTestStartedI(Quality qual)
Notifies that an atomic test is started or ignored.void
registerSelector(GUIRunner.Selector selector)
Acquaints this selector with another one which is notified of the selection events of thisSelector
.private void
setFilter()
Sets the filter (given by a description) invokingActions.setFilter(Description)
: The description is taken fromsingleSelectedNode
.void
setSelection(int index)
Sets selection ofindex
th item and clears other selections.(package private) void
startTestRun(Description desc)
Notifies that a test run with structure given bydesc
is going to be run next.private static javax.swing.tree.DefaultMutableTreeNode
testCase2treeNode(TestCase testCase)
Converts the (tree of) testcases given bytestCase
.void
valueChanged(javax.swing.event.TreeSelectionEvent selEvent)
Called whenever the value of the selection changes.
-
-
-
Field Detail
-
hierarchyTree
private final javax.swing.JTree hierarchyTree
The hierarchy of testsuites and testcases as a tree. After creation this is a default tree, after invocation ofinitClassStructure(TestCase)
the hierarchy reflects the given testcase. The selection model is given bytreeSelection
and this is theTreeSelectionListener
.
-
treeSelection
private final javax.swing.tree.TreeSelectionModel treeSelection
The selection model forhierarchyTree
. At most one entry is selected. If the entry represents a failure, the according element inGUIRunner.TestCaseLister.failureSelection
is selected also.- See Also:
valueChanged(TreeSelectionEvent)
-
actions
private final Actions actions
This is used only byvalueChanged(TreeSelectionEvent)
to set the filter viaActions.setFilter(Description)
.
-
testCaseLister
private final GUIRunner.TestCaseLister testCaseLister
The theGUIRunner.TestCaseLister
listing the failed test cases. This is used innoteReportResult(TestCase)
only and is to notify that a certain tescase failed and is selected.
-
singleSelectedNode
private javax.swing.tree.DefaultMutableTreeNode singleSelectedNode
Represents the selected node inhierarchyTree
. This isnull
if nothing selected which is also the initial value. This is set byvalueChanged(TreeSelectionEvent)
and updated also byinitClassStructure(TestCase)
.
-
currPathIter
private GUIRunner.TreePathIterator currPathIter
Represents the path to the testcase currently run. This isnull
after this is created and is initialized bystartTestRun(Description)
.
-
selector
private GUIRunner.Selector selector
Selector to be influenced: If this is in the selected tab,selector
is the tab with theTestCaseLister
; otherwise it isGUIRunner.TabChangeListener.EMPTY_SELECTOR
. Set byregisterSelector(GUIRunner.Selector)
.
-
-
Constructor Detail
-
HierarchyWrapper
HierarchyWrapper(Actions actions, GUIRunner.TestCaseLister testCaseLister)
Creates a new HierarchyWrapper with the givenactions
andtestCaseLister
which are used to initializeactions
andtestCaseLister
.- Parameters:
actions
- the Actions to be written intoactions
.testCaseLister
- TestCaseLister to be written intotestCaseLister
.
-
-
Method Detail
-
testCase2treeNode
private static javax.swing.tree.DefaultMutableTreeNode testCase2treeNode(TestCase testCase)
Converts the (tree of) testcases given bytestCase
. ****
-
getRoot
TestCase getRoot()
-
getActions
Actions getActions()
Returns the action. Invoked by the enclosing GUIRunner.
-
initClassStructure
void initClassStructure(TestCase testCase)
Notifies that the structure of the test class may have been updated.Converts the overall test case hierarchy
testCase
into a a tree node hierarchy invokingtestCase2treeNode(TestCase)
. This defines the tree model of the hierarchyhierarchyTree
. The selected nodesingleSelectedNode
is set to the root.Since
currPathIter
points to the first testcase run, it is set tonull
. Finally,actions
is notified about the test to be run next which is specified by the testcase given by the selected node. by invokingsetFilter()
.- Parameters:
testCase
- a description of the test structure defined in the test class which is a hierarchy of suites and singular tests.
-
setFilter
private void setFilter()
Sets the filter (given by a description) invokingActions.setFilter(Description)
: The description is taken fromsingleSelectedNode
.
-
startTestRun
void startTestRun(Description desc)
Notifies that a test run with structure given bydesc
is going to be run next.Sets the quality of the testcases given by
singleSelectedNode
recursively toQuality.Scheduled
and setscurrPathIter
.- Parameters:
desc
- describes the (hierarchy of) tests to be run. This is a sub-hierarchy of the one given by the test class. This parameter is purely formally because it is given bysingleSelectedNode
.
-
expandAlongPath
void expandAlongPath()
Expands the path to the leafcurrPathIter
points to. This is invoked bynoteTestStartedI(Quality)
when a testcase is started or ignored.- See Also:
collapseAlongPath()
-
collapseAlongPath
void collapseAlongPath()
Collapses the path to the leafcurrPathIter
points to as much as possible in order not to hidesingleSelectedNode
and the leafs corresponding with singular tests which failed already (assumption failure, failure and error). This is invoked bynoteReportResult(TestCase)
when a testcase is finished or after being ignored.- See Also:
expandAlongPath()
-
getTree
javax.swing.JTree getTree()
-
getPath
javax.swing.tree.TreePath getPath()
-
noteTestStartedI
TestCase noteTestStartedI(Quality qual)
Notifies that an atomic test is started or ignored.To Updates
currPathIter
pointing to the current testcase and expands along the path given by the current testcase. Then sets the quality of the according testcase toqual
and updates the according tree node.- Parameters:
qual
- the quality of the testcase: This isQuality.Started
orQuality.Ignored
.- Returns:
- the current testcase.
-
noteReportResult
void noteReportResult(TestCase testCase)
Notifies that the singular testtestCase
is finished.Collapses the current path invoking
collapseAlongPath()
, updates the tree nodecurrPathIter
points to and notifiestestCaseLister
iftestCase
failed and is selected invokingGUIRunner.TestCaseLister.addSelectedTestCaseByNeed(TestCase)
.- Parameters:
testCase
- The testcase comprising the result of the singular test finished.
-
isSelected
private boolean isSelected(TestCase testCase)
Returns whether the given testcasetestCase
is selected in this HierarchyTree.- Returns:
- whether the given testcase
testCase
is selected in this HierarchyTree.
-
setSelection
public void setSelection(int index)
Description copied from interface:GUIRunner.Selector
Sets selection ofindex
th item and clears other selections.- Specified by:
setSelection
in interfaceGUIRunner.Selector
- Parameters:
index
- a non-negativeint
value representing the index of a testcase. **** CAUTION: This presupposes that in a tree only the leaves can be selected.
-
clearSelection
public void clearSelection()
Description copied from interface:GUIRunner.Selector
Clears the selection.- Specified by:
clearSelection
in interfaceGUIRunner.Selector
-
registerSelector
public void registerSelector(GUIRunner.Selector selector)
Description copied from interface:GUIRunner.Selector
Acquaints this selector with another one which is notified of the selection events of thisSelector
. The one in the foreground is notified directly by a mouse event, whereas the one in the background is selected via registration. The one in the background in turn notifies the empty selectorGUIRunner.TabChangeListener.EMPTY_SELECTOR
which takes no actions.- Specified by:
registerSelector
in interfaceGUIRunner.Selector
- Parameters:
selector
- anotherSelector
.- See Also:
GUIRunner.TabChangeListener.setSelUnSel(int)
-
valueChanged
public void valueChanged(javax.swing.event.TreeSelectionEvent selEvent)
Called whenever the value of the selection changes. Note that deselection is treated as selection of the root, so w.l.o.g, we have to consider selections only.If an entry is selected,
singleSelectedNode
holds the selected node. Nextselector
is notified of the selection:- if a failure is selected (which is a leaf) triggers according selection in the failure list, otherwise triggers a deselection.
GUIRunner.TestCaseLister.valueChanged(ListSelectionEvent)
.Finally, invokes
setFilter()
setting the filter for the next test run.- Specified by:
valueChanged
in interfacejavax.swing.event.TreeSelectionListener
-
-