Java Doc for ComponentTestFixture.java in  » Testing » abbot-1.0.1 » junit » extensions » abbot » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » abbot 1.0.1 » junit.extensions.abbot 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


junit.extensions.abbot.ComponentTestFixture

All known Subclasses:   abbot.tester.RobotAppletTest,  abbot.tester.JSpinnerTesterTest,  junit.extensions.abbot.ComponentTestFixtureTest,  abbot.tester.JTableTesterTest,  abbot.tester.JTreeTesterTest,  abbot.tester.ListTesterTest,  abbot.tester.WindowTrackerTest,  abbot.tester.JSliderTesterTest,  abbot.util.EventNormalizerTest,  abbot.editor.widgets.AbstractComponentDecoratorTest,  abbot.tester.JListTesterTest,  example.ArrowButtonTest,  abbot.editor.HierarchyWriterTest,  abbot.editor.ScriptEditorTest,  abbot.tester.InputStateTest,  abbot.editor.LookAndFeelPreserverTest,  abbot.tester.JTextComponentTesterTest,  abbot.tester.TextComponentTesterTest,  example.LabeledListTest,  abbot.tester.RobotDragDropTest,  abbot.finder.BasicFinderTest,  abbot.editor.ScriptEditorFrameTest,  abbot.util.AWTTest,  abbot.tester.ButtonTesterTest,  abbot.editor.ComponentTreeTest,  example.CelsiusConverterTest,  abbot.util.WeakAWTEventListenerTest,  abbot.finder.AWTHierarchyTest,  abbot.tester.RobotAWTModeTest,  abbot.tester.AbstractButtonTesterTest,  abbot.tester.JComponentTesterTest,  abbot.PlatformTest,  abbot.editor.widgets.ArrayEditorTest,  abbot.tester.JComboBoxTesterTest,  abbot.tester.FrameTesterTest,  abbot.editor.CompactHierarchyTest,  abbot.editor.ComponentPropertyModelTest,  abbot.tester.JTextFieldTesterTest,  junit.extensions.abbot.ResolverFixture,  abbot.tester.KeyStrokeMapTest,  abbot.tester.JFileChooserTesterTest,  abbot.tester.CheckboxTesterTest,  abbot.editor.ScriptTableTest,  abbot.finder.TestHierarchyTest,  abbot.util.BugsTest,  abbot.tester.ComponentTesterTest,  abbot.tester.JToolBarTesterTest,  abbot.tester.FileDialogTesterTest,  abbot.editor.ComponentNodeTest,  abbot.tester.JInternalFrameTesterTest,  abbot.tester.RobotTest,  abbot.tester.ChoiceTesterTest,  abbot.tester.JScrollBarTesterTest,  abbot.tester.extensions.JGraphTesterTest,  abbot.tester.JSplitPaneTesterTest,  abbot.tester.JTabbedPaneTesterTest,  abbot.editor.widgets.TextFieldTest,
ComponentTestFixture
abstract public class ComponentTestFixture extends TestCase (Code)
Fixture for testing AWT and/or JFC/Swing components under JUnit. Ensures proper setup and cleanup for a GUI environment. Provides methods for automatically placing a GUI component within a frame and properly handling Window showing/hiding (including modal dialogs). Catches exceptions thrown on the event dispatch thread and rethrows them as test failures.

Use ComponentTestFixture.showFrame(Component) when testing individual components, or ComponentTestFixture.showWindow(Window) when testing a Frame , Dialog , or Window .

Any member fields you define which are classes derived from any of the classes in ComponentTestFixture.DISPOSE_CLASSES will be automatically set to null after the test is run.

WARNING: Any tests which use significant or scarce resources and reference them in member fields should explicitly null those fields in the tearDown method if those classes are not included or derived from those in ComponentTestFixture.DISPOSE_CLASSES . Otherwise the resources will not be subject to GC until the TestCase itself and any containing junit.framework.TestSuite is disposed (which, in the case of the standard JUnit test runners, is never).


Inner Class :public class EventDispatchException extends InvocationTargetException
Inner Class :protected class ComponentMatcher implements Matcher

Field Summary
final protected static  Class[]DISPOSE_CLASSES
     Any member data derived from these classes will be automatically set to null after the test has run.
final public static  intEVENT_GENERATION_DELAY
     Typical delay to wait for a robot event to be translated into a Java event.
final public static  intPOPUP_DELAY
    
final public static  intWINDOW_DELAY
    

Constructor Summary
public  ComponentTestFixture(String name)
     Construct a test case with the given name.
public  ComponentTestFixture()
     Default Constructor.

Method Summary
protected  HierarchycreateHierarchy()
     Provide for derived classes to provide their own Hierarchy.
protected  voiddisposeAll()
     Dispose of all extant windows.
protected  voiddisposeWindow(Window w)
     Synchronous, safe dispose of a window.
protected  voidfixtureSetUp()
     Ensure proper test harness setup and teardown that won't be inadvertently overridden by a derived class.
protected  voidfixtureTearDown()
     Handles restoration of system state.
protected  ComponentFindergetFinder()
     Obtain a component finder to look up components.
protected  HierarchygetHierarchy()
     Obtain a consistent hierarchy.
protected  RobotgetRobot()
     Return an Abbot abbot.tester.Robot for basic event generation.
protected  WindowTrackergetWindowTracker()
     Return a WindowTracker instance.
protected  voidhideWindow(Window w)
     Synchronous, safe hide of a window.
protected  voidinstallPopup(Component invoker, JPopupMenu popup)
     Install the given popup on the given component.
protected  voidinvokeAndWait(Runnable runnable)
     Convenience for getRobot().invokeAndWait(Runnable).
protected  voidinvokeLater(Runnable runnable)
     Convenience for getRobot().invokeLater(Runnable).
protected  booleanisShowing(String id)
     Returns whether a Component is showing.
public  voidrunBare()
     Override the default junit.framework.TestCase#RunBare() to ensure proper test harness setup and teardown that won't likely be accidentally overridden by a derived class.

If any exceptions are thrown on the event dispatch thread, they count as errors.

protected  voidsetModifiers(int modifiers, boolean pressed)
     Convenience method to set key modifiers.
protected  FrameshowFrame(Component comp)
     This method should be invoked to display the component under test. The frame's size will be its preferred size.
protected  FrameshowFrame(Component comp, Dimension size)
     This method should be invoked to display the component under test, when a specific size of frame is desired.
protected  DialogshowModalDialog(Runnable showAction)
     Display a modal dialog and wait for it to show.
protected  DialogshowModalDialog(Runnable showAction, Component contents)
    
protected  voidshowPopup(JPopupMenu popup, Component invoker)
     Safely install and display a popup in the center of the given component, returning when it is visible.
protected  voidshowPopup(JPopupMenu popup, Component invoker, int x, int y)
     Safely install and display a popup, returning when it is visible.
protected  voidshowWindow(Window w)
     Safely display a window with proper EDT synchronization.
protected  voidshowWindow(Window w, Dimension size)
     Safely display a window with proper EDT synchronization.
protected  voidshowWindow(Window w, Dimension size, boolean pack)
     Safely display a window with proper EDT synchronization.
protected  voidsleep()
     Convenience method to sleep for a UI interval (same as getRobot().sleep()).
protected  voidwaitForWindow(Window w, boolean visible)
     Return when the window is ready for input or times out waiting.

Field Detail
DISPOSE_CLASSES
final protected static Class[] DISPOSE_CLASSES(Code)
Any member data derived from these classes will be automatically set to null after the test has run. This enables GC of said classes without GC of the test itself (the default JUnit runners never release their references to the tests) or requiring explicit null-setting in the TestCase.tearDown method.



EVENT_GENERATION_DELAY
final public static int EVENT_GENERATION_DELAY(Code)
Typical delay to wait for a robot event to be translated into a Java event.



POPUP_DELAY
final public static int POPUP_DELAY(Code)



WINDOW_DELAY
final public static int WINDOW_DELAY(Code)




Constructor Detail
ComponentTestFixture
public ComponentTestFixture(String name)(Code)
Construct a test case with the given name.



ComponentTestFixture
public ComponentTestFixture()(Code)
Default Constructor. The name will be automatically set from the selected test method.




Method Detail
createHierarchy
protected Hierarchy createHierarchy()(Code)
Provide for derived classes to provide their own Hierarchy.



disposeAll
protected void disposeAll()(Code)
Dispose of all extant windows.



disposeWindow
protected void disposeWindow(Window w)(Code)
Synchronous, safe dispose of a window. The window is ensured to be disposed ( java.awt.event.WindowEvent.WINDOW_CLOSED has been posted) when this method returns.



fixtureSetUp
protected void fixtureSetUp() throws Throwable(Code)
Ensure proper test harness setup and teardown that won't be inadvertently overridden by a derived class.



fixtureTearDown
protected void fixtureTearDown() throws Throwable(Code)
Handles restoration of system state. Automatically disposes of any Components used in the test.



getFinder
protected ComponentFinder getFinder()(Code)
Obtain a component finder to look up components.



getHierarchy
protected Hierarchy getHierarchy()(Code)
Obtain a consistent hierarchy.



getRobot
protected Robot getRobot()(Code)
Return an Abbot abbot.tester.Robot for basic event generation.



getWindowTracker
protected WindowTracker getWindowTracker()(Code)
Return a WindowTracker instance.



hideWindow
protected void hideWindow(Window w)(Code)
Synchronous, safe hide of a window. The window is ensured to be hidden ( java.awt.event.ComponentEvent.COMPONENT_HIDDEN or equivalent has been posted) when this method returns. Note that this will not trigger a java.awt.event.WindowEvent.WINDOW_CLOSING event; use abbot.tester.WindowTester.actionClose(Component) if a window manager window close operation is required.



installPopup
protected void installPopup(Component invoker, JPopupMenu popup)(Code)
Install the given popup on the given component. Takes care of installing the appropriate mouse handler to activate the popup.



invokeAndWait
protected void invokeAndWait(Runnable runnable)(Code)
Convenience for getRobot().invokeAndWait(Runnable).



invokeLater
protected void invokeLater(Runnable runnable)(Code)
Convenience for getRobot().invokeLater(Runnable).



isShowing
protected boolean isShowing(String id)(Code)
Returns whether a Component is showing. The ID may be the component name or, in the case of a Frame or Dialog, the title. Regular expressions may be used, but must be delimited by slashes, e.g. /expr/. Returns if one or more matches is found.



runBare
public void runBare() throws Throwable(Code)
Override the default junit.framework.TestCase#RunBare() to ensure proper test harness setup and teardown that won't likely be accidentally overridden by a derived class.

If any exceptions are thrown on the event dispatch thread, they count as errors. They will not, however supersede any failures/errors thrown by the test itself unless thrown prior to the main test failure.




setModifiers
protected void setModifiers(int modifiers, boolean pressed)(Code)
Convenience method to set key modifiers. Using this method is preferred to invoking Robot.setModifiers(intboolean) or Robot.keyPress(int) , since this method's effects will be automatically undone at the end of the test. If you use the Robot methods, you must remember to release any keys pressed during the test.
Parameters:
  modifiers - mask indicating which modifier keys to use
Parameters:
  pressed - whether the modifiers should be in the pressed state.



showFrame
protected Frame showFrame(Component comp)(Code)
This method should be invoked to display the component under test. The frame's size will be its preferred size. This method will return with the enclosing Frame is showing and ready for input.



showFrame
protected Frame showFrame(Component comp, Dimension size)(Code)
This method should be invoked to display the component under test, when a specific size of frame is desired. The method will return when the enclosing Frame is showing and ready for input.
Parameters:
  comp -
Parameters:
  size - Desired size of the enclosing frame, or nullto make no explicit adjustments to its size.



showModalDialog
protected Dialog showModalDialog(Runnable showAction) throws ComponentSearchException(Code)
Display a modal dialog and wait for it to show. Useful for things like JFileChooser.showOpenDialog(Component) or JOptionPane.showInputDialog(ComponentObject) , or any other instance where the dialog contents are not predefined and displaying the dialog involves anything more than Window.setVisible(boolean) show()/setVisible(true (if Window.setVisible(boolean) show()/setVisible(true) is all that is required, use the ComponentTestFixture.showWindow(Window) method instead).

The given Runnable should contain the code which will show the modal Dialog (and thus block); it will be run on the event dispatch thread.

This method will return when a Dialog becomes visible which contains the given component (which may be any component which will appear on the Dialog ), or the standard timeout (10s) is reached, at which point a RuntimeException will be thrown.

For example,


 final Frame parent = ...;
 Dialog d = showModalDialog(new Runnable) {
 public void run() {
 JOptionPane.showInputDialog(parent, "Hit me");
 }
 });
 

See Also:   ComponentTestFixture.showWindow(java.awt.Window)
See Also:   ComponentTestFixture.showWindow(java.awt.Window,java.awt.Dimension)
See Also:   ComponentTestFixture.showWindow(java.awt.Window,java.awt.Dimension,boolean)



showModalDialog
protected Dialog showModalDialog(Runnable showAction, Component contents) throws Exception(Code)
Similar to ComponentTestFixture.showModalDialog(Runnable) , but provides for the case where some of the Dialog 's contents are known beforehand.

ComponentTestFixture.showModalDialog(Runnable)




showPopup
protected void showPopup(JPopupMenu popup, Component invoker)(Code)
Safely install and display a popup in the center of the given component, returning when it is visible. Does not install any mouse handlers not generate any mouse events.



showPopup
protected void showPopup(JPopupMenu popup, Component invoker, int x, int y)(Code)
Safely install and display a popup, returning when it is visible. Does not install any mouse handlers not generate any mouse events.



showWindow
protected void showWindow(Window w)(Code)
Safely display a window with proper EDT synchronization. This method blocks until the Window is showing and ready for input.



showWindow
protected void showWindow(Window w, Dimension size)(Code)
Safely display a window with proper EDT synchronization. This method blocks until the Window is showing and ready for input.



showWindow
protected void showWindow(Window w, Dimension size, boolean pack)(Code)
Safely display a window with proper EDT synchronization. This method blocks until the window is showing. This method will return even when the window is a modal dialog, since the show method is called on the event dispatch thread. The window will be packed if the pack flag is set, and set to the given size if it is non-null.

Modal dialogs may be shown with this method without blocking.




sleep
protected void sleep()(Code)
Convenience method to sleep for a UI interval (same as getRobot().sleep()).



waitForWindow
protected void waitForWindow(Window w, boolean visible)(Code)
Return when the window is ready for input or times out waiting.
Parameters:
  w -



www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.