Package com.vaadin.browserless.internal
Class BasicUtils
java.lang.Object
com.vaadin.browserless.internal.BasicUtils
Basic utilities for firing events on components and checking their state.
For internal use only. May be renamed or removed in a future release.
-
Method Summary
Modifier and TypeMethodDescription_blur(T component) FiresBlurNotifier.BlurEventon the component, but only if it's editable.static voidCloses the UI and simulates the end of the request.static void_fireDomEvent(Component component, String eventType) Fires a DOM event with empty event data on given component.static void_fireDomEvent(Component component, String eventType, tools.jackson.databind.node.ObjectNode eventData) Fires a DOM event on given component._focus(T component) FiresFocusNotifier.FocusEventon the component, but only if it's editable.static boolean_isVisible(Component component) Checks whether the component is visible (usuallyComponent.isVisible()but forTextthe text must be non-empty).static voidcheckEditableByUser(Component component) Checks that a component is actually editable by the user: The component must be effectively visible: it itself must be visible, its parent must be visible and all of its ascendants must be visible.static voidexpectNotEditableByUser(Component component) Fails if the component is editable.static intReturns a fetch limit that is safe to pass to data providers.static booleanisEffectivelyEnabled(Component component) Computes whether this component and all of its parents are enabled.static booleanisEffectivelyVisible(Component component) Computes whether this component and all of its parents are visible.static booleanmatches(Component component, Consumer<SearchSpec<Component>> spec) Checks whether this component matches given spec.
-
Method Details
-
_fireDomEvent
public static void _fireDomEvent(Component component, String eventType, tools.jackson.databind.node.ObjectNode eventData) Fires a DOM event on given component.- Parameters:
component- the component, not null.eventType- the event type, e.g. "click"eventData- the event data, not null.
-
_fireDomEvent
Fires a DOM event with empty event data on given component.- Parameters:
component- the component, not null.eventType- the event type, e.g. "click"
-
_isVisible
Checks whether the component is visible (usuallyComponent.isVisible()but forTextthe text must be non-empty).- Parameters:
component- the component, not null.- Returns:
- true if the component is visible.
-
checkEditableByUser
Checks that a component is actually editable by the user:- The component must be effectively visible: it itself must be visible,
its parent must be visible and all of its ascendants must be visible. For
the purpose of testing individual components not attached to the
UI, a component may be considered visible even though it's not currently nested in aUI. - The component must be effectively enabled: it itself must be enabled, its parent must be enabled and all of its ascendants must be enabled.
- If the component is
HasValue, it must not beHasValue.isReadOnly().
- Parameters:
component- the component, not null.- Throws:
IllegalStateException- if any of the above doesn't hold.
- The component must be effectively visible: it itself must be visible,
its parent must be visible and all of its ascendants must be visible. For
the purpose of testing individual components not attached to the
-
expectNotEditableByUser
Fails if the component is editable. SeecheckEditableByUser(Component)for more details.- Parameters:
component- the component, not null.- Throws:
AssertionError- if the component is editable.
-
isEffectivelyVisible
Computes whether this component and all of its parents are visible.- Parameters:
component- the component, not null.- Returns:
- true if the component and all of its ascendants are visible.
-
isEffectivelyEnabled
Computes whether this component and all of its parents are enabled.Recursively checks that all ancestors are also enabled (the "implicitly disabled" effect, see
HasEnabled.isEnabled()javadoc for more details).Also check that the component is not inert due to there being a modal component.
- Parameters:
component- the component, not null.- Returns:
- false if this component or any of its parent is disabled or is inert.
-
matches
Checks whether this component matches given spec. All rules are matched except thecountrule. The rules are matched against given component only (not against its children).- Parameters:
component- the component, not null.spec- configures the search spec, not null.- Returns:
- true if the component matches the spec.
-
_focus
FiresFocusNotifier.FocusEventon the component, but only if it's editable.- Type Parameters:
T- the component type- Parameters:
component- the component, not null.
-
_blur
FiresBlurNotifier.BlurEventon the component, but only if it's editable.- Type Parameters:
T- the component type- Parameters:
component- the component, not null.
-
_close
Closes the UI and simulates the end of the request. TheUI.close()is called unless the UI is already closing, and then the UI is removed from its session, which fires the detach listeners and makes the UI and all of its components detached.- Parameters:
ui- the UI, not null.
-
get_saneFetchLimit
public static int get_saneFetchLimit()Returns a fetch limit that is safe to pass to data providers.- Returns:
- the fetch limit.
-