Package org.fest.swing.core
Class EmergencyAbortListener
java.lang.Object
org.fest.swing.core.EmergencyAbortListener
- All Implemented Interfaces:
AWTEventListener
,EventListener
Understands an escape valve for users to abort a running FEST-Swing test by pressing 'Ctrl + Shift + A'. The key
combination to use to abort test is configurable through the method
keyCombination(KeyPressInfo)
.
The following example shows to use this listener in a TestNG test:
private EmergencyAbortListener listener; @BeforeMethod public void setUp() { // set up your test fixture. listener = EmergencyAbortListener.registerInToolkit(); } @AfterMethod public void tearDown() { // clean up resources. listener.unregister(); }
Changing the default key combination for aborting test:
listener = EmergencyAbortListener.registerInToolkit().keyCombination
(key(VK_C).modifiers(SHIFT_MASK));
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final long
private int
private int
private final TestTerminator
private final Toolkit
-
Constructor Summary
ConstructorsConstructorDescriptionEmergencyAbortListener
(Toolkit toolkit) EmergencyAbortListener
(Toolkit toolkit, TestTerminator testTerminator) -
Method Summary
Modifier and TypeMethodDescriptionvoid
eventDispatched
(AWTEvent event) Inspects key events for the key combination that should terminate any running FEST-Swing tests.(package private) int
keyCode()
keyCombination
(KeyPressInfo keyPressInfo) Sets the key combination that will terminate any FEST-Swing test.(package private) int
(package private) void
register()
static EmergencyAbortListener
Attaches a new instance of
in the givenEmergencyAbortListener
.Toolkit
private void
void
Removes this listener from the
this listener is attached to.Toolkit
-
Field Details
-
EVENT_MASK
private static final long EVENT_MASK- See Also:
-
toolkit
-
testTerminator
-
keyCode
private int keyCode -
modifiers
private int modifiers
-
-
Constructor Details
-
EmergencyAbortListener
EmergencyAbortListener(Toolkit toolkit) -
EmergencyAbortListener
EmergencyAbortListener(Toolkit toolkit, TestTerminator testTerminator)
-
-
Method Details
-
registerInToolkit
Attaches a new instance of
in the givenEmergencyAbortListener
. Any other instances ofToolkit
EmergencyAbortListener
will be removed from theToolkit
.- Returns:
- the created listener.
-
register
void register() -
removePrevious
private void removePrevious() -
keyCombination
Sets the key combination that will terminate any FEST-Swing test. The default combination is 'Ctrl + Shift + A'.- Parameters:
keyPressInfo
- contains information about the key code and modifiers.- Returns:
- this listener.
- Throws:
NullPointerException
- if theKeyPressInfo
isnull
.
-
unregister
public void unregister()Removes this listener from the
this listener is attached to.Toolkit
-
eventDispatched
Inspects key events for the key combination that should terminate any running FEST-Swing tests.- Specified by:
eventDispatched
in interfaceAWTEventListener
- Parameters:
event
- the event to inspect.- See Also:
-
keyCode
int keyCode() -
modifiers
int modifiers()
-