org.fest.swing.core
Class EmergencyAbortListener

java.lang.Object
  extended by org.fest.swing.core.EmergencyAbortListener
All Implemented Interfaces:
AWTEventListener, EventListener

public class EmergencyAbortListener
extends Object
implements AWTEventListener

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));
 

Author:
Simeon H.K. Fitch, Alex Ruiz

Method Summary
 void eventDispatched(AWTEvent event)
          Inspects key events for the key combination that should terminate any running FEST-Swing tests.
 EmergencyAbortListener keyCombination(KeyPressInfo keyPressInfo)
          Sets the key combination that will terminate any FEST-Swing test.
static EmergencyAbortListener registerInToolkit()
          Attaches a new instance of EmergencyAbortListener in the given Toolkit.
 void unregister()
          Removes this listener from the Toolkit this listener is attached to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

registerInToolkit

public static EmergencyAbortListener registerInToolkit()
Attaches a new instance of EmergencyAbortListener in the given Toolkit. Any other instances of EmergencyAbortListener will be removed from the Toolkit.

Returns:
the created listener.

keyCombination

public EmergencyAbortListener keyCombination(KeyPressInfo keyPressInfo)
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 the KeyPressInfo is null.

unregister

public void unregister()
Removes this listener from the Toolkit this listener is attached to.


eventDispatched

public void eventDispatched(AWTEvent event)
Inspects key events for the key combination that should terminate any running FEST-Swing tests.

Specified by:
eventDispatched in interface AWTEventListener
Parameters:
event - the event to inspect.
See Also:
AWTEventListener.eventDispatched(java.awt.AWTEvent)


Copyright © 2007-2011 FEST (Fixtures for Easy Software Testing). All Rights Reserved.