public class Gooey
extends java.lang.Object
Title: Gooey
Description: Gooey is a jUnit Swing test library of static methods
for capturing windows and retrieving their components.
Methods in this class are designed to be called in JUnit tests. There
are methods to capture displayed windows/dialogs and query their
components. Once a window is captured, methods can retrieve any component by type, by name,
and (in the case of buttons, menus, tabs and labels) by displayed text.
interface to access a captured window.| Modifier and Type | Class and Description |
|---|---|
static class |
Gooey.Match
Enumerated type indicating whether a component is sought by name or displayed text.
|
| Modifier and Type | Method and Description |
|---|---|
static <T extends GooeyDisplayable<U>,U extends java.awt.Window> |
capture(T displayable)
This method uses a capture mechanism, which invokes
the method displaying a window, waits for the window to display (within a timeout period) and calls
the method to test this window.
|
static javax.swing.JButton |
getButton(java.awt.Container container,
java.lang.String text)
Given a container it returns the button displaying the given text.
|
static javax.swing.JButton |
getButton(java.awt.Container container,
java.lang.String string,
Gooey.Match flag)
Given a container it returns the button associated with the given string.
|
static <T extends java.awt.Component> |
getComponent(java.awt.Container container,
java.lang.Class<T> type)
Returns the first component of a class found in a container.
|
static <T extends java.awt.Component> |
getComponent(java.awt.Container container,
java.lang.Class<T> type,
java.lang.String name)
Returns a component found in the container that matches the given class type and associated name.
|
static <T extends java.awt.Component> |
getComponents(java.awt.Container container,
java.lang.Class<T> type)
Returns a list with all components of a given class found in a container.
|
static <T extends java.awt.Component> |
getComponents(java.awt.Container container,
java.lang.Class<T> type,
java.util.function.Predicate<T> criteria)
Returns a list with all components of a given class found in a container that match the given criteria.
|
static javax.swing.JLabel |
getLabel(java.awt.Container container,
java.lang.String text)
Given a container it returns the label displaying the given text.
|
static javax.swing.JLabel |
getLabel(java.awt.Container container,
java.lang.String string,
Gooey.Match flag)
Given a container it returns the label associated with the given string.
|
static javax.swing.JMenu |
getMenu(javax.swing.JMenuBar menubar,
java.lang.String text)
Given a menu bar it returns the menu displaying the given text.
|
static javax.swing.JMenu |
getMenu(javax.swing.JMenuBar menubar,
java.lang.String string,
Gooey.Match flag)
Given a menu bar it returns the menu associated with the given string.
|
static <T extends javax.swing.JMenuItem> |
getMenu(javax.swing.JMenu menu,
java.lang.String text)
Given a menu it returns the sub-menu (i.e., another menu or a menu item) displaying the given text.
|
static <T extends javax.swing.JMenuItem> |
getMenu(javax.swing.JMenu menu,
java.lang.String string,
Gooey.Match flag)
Given a menu it returns the sub-menu (i.e., another menu or a menu item) associated with the given string.
|
static javax.swing.JMenuBar |
getMenuBar(javax.swing.JFrame frame)
Returns the menu bar associated with a frame.
|
static java.util.List<javax.swing.JMenuItem> |
getMenus(javax.swing.JMenu menu)
Returns a list with all sub-menus (i.e., another menu or a menu item) in the menu provided.
|
static java.util.List<javax.swing.JMenu> |
getMenus(javax.swing.JMenuBar menubar)
Returns a list with top-level menus in the menu bar.
|
static java.awt.Component |
getTab(javax.swing.JTabbedPane tabPane,
java.lang.String title)
Given a tab pane it returns the tab component with the given title.
|
static java.awt.Component |
getTab(javax.swing.JTabbedPane tabPane,
java.lang.String string,
Gooey.Match flag)
Given a tab pane it returns the component associated with the given string.
|
static java.lang.String |
getVersion()
Returns Gooey's current version number.
|
static void |
main(java.lang.String[] args) |
public static void main(java.lang.String[] args)
public static final java.lang.String getVersion()
public static java.awt.Component getTab(javax.swing.JTabbedPane tabPane,
java.lang.String title)
tabPane - pane holding the tab.title - title of the tab sought.java.lang.AssertionError - if no tab with the given title is found.public static java.awt.Component getTab(javax.swing.JTabbedPane tabPane,
java.lang.String string,
Gooey.Match flag)
tabPane - pane holding the tab.string - identifier of the tab sought.flag - to search by title (By_Text) or by name.java.lang.AssertionError - if no tab with the given string is found.public static javax.swing.JLabel getLabel(java.awt.Container container,
java.lang.String text)
container - container holding the label.text - text of the label sought.java.lang.AssertionError - if no label with the given text is found.public static javax.swing.JLabel getLabel(java.awt.Container container,
java.lang.String string,
Gooey.Match flag)
container - container holding the label.string - identifier of the label sought.flag - to search by text or by name.java.lang.AssertionError - if no label with the given string is found.public static javax.swing.JButton getButton(java.awt.Container container,
java.lang.String text)
container - container holding the button.text - text of the button sought.java.lang.AssertionError - if no button with the given text is found.public static javax.swing.JButton getButton(java.awt.Container container,
java.lang.String string,
Gooey.Match flag)
container - container holding the button.string - identifier of the button sought.flag - to search by text or by name.java.lang.AssertionError - if no button with the given string is found.public static javax.swing.JMenuBar getMenuBar(javax.swing.JFrame frame)
frame - the frame whose menu is requested.java.lang.AssertionError - if no menu bar is found.public static javax.swing.JMenu getMenu(javax.swing.JMenuBar menubar,
java.lang.String text)
menubar - menu bar holding the menu.text - text of the menu sought.java.lang.AssertionError - if no menu with the given text is found.public static javax.swing.JMenu getMenu(javax.swing.JMenuBar menubar,
java.lang.String string,
Gooey.Match flag)
menubar - menu bar holding the menu.string - identifier of the menu sought.flag - to search by text or by name.java.lang.AssertionError - if no menu with the given string is found.public static <T extends javax.swing.JMenuItem> T getMenu(javax.swing.JMenu menu,
java.lang.String text)
T - class type sub-classing from JMenuItem.menu - menu holding the sub-menu.text - text of the menu sought.java.lang.AssertionError - if no sub-menu with the given text is found.public static <T extends javax.swing.JMenuItem> T getMenu(javax.swing.JMenu menu,
java.lang.String string,
Gooey.Match flag)
T - class type sub-classing from JMenuItem.menu - menu holding the sub-menu.string - identifier of the sub-menu sought.flag - to search by text or by name.java.lang.AssertionError - if no sub-menu with the given string is found.public static java.util.List<javax.swing.JMenu> getMenus(javax.swing.JMenuBar menubar)
menubar - menu bar to evaluate.public static java.util.List<javax.swing.JMenuItem> getMenus(javax.swing.JMenu menu)
menu - menu to evaluate.public static <T extends java.awt.Component> T getComponent(java.awt.Container container,
java.lang.Class<T> type)
T - class type sub-classing from Component.container - container to evaluate.type - class of component sought.java.lang.AssertionError - if no component of the given class is found.public static <T extends java.awt.Component> T getComponent(java.awt.Container container,
java.lang.Class<T> type,
java.lang.String name)
T - class type sub-classing from Component.container - container to evaluate.type - class of component sought.name - name of the component sought.java.lang.AssertionError - if no component with the given class and name is found.public static <T extends java.awt.Component> java.util.List<T> getComponents(java.awt.Container container,
java.lang.Class<T> type)
T - class type sub-classing from Component.container - container to evaluate.type - class of components sought.public static <T extends java.awt.Component> java.util.List<T> getComponents(java.awt.Container container,
java.lang.Class<T> type,
java.util.function.Predicate<T> criteria)
T - class type sub-classing from Component.container - container to evaluate.type - class of components sought.criteria - criteria indicating an accepting component.public static <T extends GooeyDisplayable<U>,U extends java.awt.Window> void capture(T displayable)
invoke
(calls the code to display a window) and test (calls the code to test the window).
If no window is detected within a waiting period the method throws an AssertionError.T - class type sub-classing from Component.U - class type sub-classing from GooeyDisplayable.displayable - interface to display and handle the test of a window.java.lang.AssertionError - if no window is displayed.GooeyDisplayable