Class DialogTester
- Since:
- 1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidSimulates clicking outside the dialog to close it.voidclose()Close the dialog from the server side, like the application callingDialog.close().<R extends Component>
ComponentQuery<R> findInFooter(Class<R> componentType) Searches the dialog's footer for components of the given type.<R extends Component>
ComponentQuery<R> findInHeader(Class<R> componentType) Searches the dialog's header for components of the given type.booleanisOpen()Check if the dialog is open.booleanisUsable()Validate that component can be interacted with and should be visible in the UI.protected voidnotUsableReasons(Consumer<String> collector) Provides messages explaining why the component is actually not usable.voidopen()Open the dialog.voidSimulates pressing Escape to close the dialog.Methods inherited from class com.vaadin.browserless.ComponentTester
canSetValueAsUser, clearAsUser, clickClearButtonAsUser, ensureComponentIsUsable, ensureComponentIsUsable, ensureComponentIsUsableOrDetach, ensureVisible, ensureVisible, find, findAllByQuery, findByQuery, fireDomEvent, fireDomEvent, fireDomEvent, getComponent, getField, getField, getMethod, getMethod, isComponentReadOnly, isUsable, notUsableReasons, roundTrip, setModal, setPropertyAsUser, setValueAsUser, setValueAsUserMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.browserless.Clickable
click, click, click, middleClick, middleClick, rightClick, rightClick
-
Constructor Details
-
DialogTester
Wrap given component for testing.- Parameters:
component- target component
-
-
Method Details
-
open
public void open()Open the dialog. -
close
public void close()Close the dialog from the server side, like the application callingDialog.close().This is not something the user can do: the dialog is closed regardless of
Dialog.isCloseOnEsc()andDialog.isCloseOnOutsideClick(), and noDialog.DialogCloseActionEventis fired, so a close action listener cannot veto it. To simulate the user dismissing the dialog, usepressEscape()orclickOutside()instead. -
pressEscape
public void pressEscape()Simulates pressing Escape to close the dialog.If the application has registered a close action listener, a
Dialog.DialogCloseActionEventis fired instead of closing the dialog, leaving it up to the listener whether to close it.- Throws:
IllegalStateException- if the dialog is not usable, e.g. not open, or close-on-Esc is disabled
-
clickOutside
public void clickOutside()Simulates clicking outside the dialog to close it.If the application has registered a close action listener, a
Dialog.DialogCloseActionEventis fired instead of closing the dialog, leaving it up to the listener whether to close it.- Throws:
IllegalStateException- if the dialog is not usable, e.g. not open, or close-on-outside-click is disabled
-
isOpen
public boolean isOpen()Check if the dialog is open.- Returns:
- true if the dialog is open
-
isUsable
public boolean isUsable()Description copied from class:ComponentTesterValidate that component can be interacted with and should be visible in the UI. Subclasses overriding this method should also overrideComponentTester.notUsableReasons(Consumer)to provide additional details to the potential exception thrown byComponentTester.ensureComponentIsUsable().- Overrides:
isUsablein classComponentTester<Dialog>- Returns:
trueif component can be interacted with by the user- See Also:
-
notUsableReasons
Description copied from class:ComponentTesterProvides messages explaining why the component is actually not usable. Subclasses overridingComponentTester.isUsable()should also override this method to provide additional details to the potential exception throw byComponentTester.ensureComponentIsUsable().- Overrides:
notUsableReasonsin classComponentTester<Dialog>- See Also:
-
findInHeader
Searches the dialog's header for components of the given type.The header is the area above the dialog content, filled with
dialog.getHeader().add(...). Components nested inside the header content are found too, so a button inside a header layout is reached as well as a button added to the header directly.- Type Parameters:
R- the type of the components to search for- Parameters:
componentType- the type of the components to search for- Returns:
- a query for components of the given type in the dialog's header
- Throws:
IllegalStateException- if the dialog is not usable, e.g. not open
-