Package io.jmix.flowui.testassist.vaadin
Class TestUI
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.UI
io.jmix.flowui.testassist.vaadin.TestUI
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.HasComponents,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.PollNotifier,com.vaadin.flow.router.RouterLayout,Serializable
public class TestUI
extends com.vaadin.flow.component.UI
UI for integration tests that emulates the client response cycle.
In a running application, tasks registered via UI.beforeClientResponse(com.vaadin.flow.component.Component, com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.internal.ExecutionContext>) are collected by
the StateTree during request handling and executed as a single batch before the response
is sent to the client. There is no client-server communication in tests, so these tasks would
never run, leaving components that defer initialization partially initialized — e.g.
JmixTabSheet attaches the selected tab content to the component tree in such a callback.
This UI emulates the cycle in two phases:
- while a navigation is being handled, callbacks are only collected, then executed as one batch once the navigation finishes — exactly as a real request behaves;
- at any other time there is no response to wait for, so each callback registered via
beforeClientResponse(Component, SerializableConsumer)runs immediately, and programmatic changes or dialogs opened without navigation are handled without any explicit flush.
- only registrations made through
UI.beforeClientResponse(com.vaadin.flow.component.Component, com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.internal.ExecutionContext>)trigger the immediate run; code that registers directly on theStateTree(e.g.Element#executeJsor data communicator flushes) is collected and executed at the next flush — the next navigation orbeforeClientResponsecall — or explicitly viarunExecutionsBeforeClientResponse(); - the immediate run happens synchronously inside the registering call, whereas in a
running application the callback runs at the end of the request — caller code following the
registration that the callback depends on (e.g.
field = ui.beforeClientResponse(owner, ctx -> field = null)) observes the inverted order.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.vaadin.flow.component.UI
com.vaadin.flow.component.UI.BrowserLeaveNavigationEvent, com.vaadin.flow.component.UI.BrowserNavigateEvent, com.vaadin.flow.component.UI.BrowserRefreshEvent, com.vaadin.flow.component.UI.ClientViewPlaceholder -
Field Summary
FieldsFields inherited from class com.vaadin.flow.component.UI
CLIENT_NAVIGATE_TO, wrapperElement -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.internal.StateTree.ExecutionRegistrationbeforeClientResponse(com.vaadin.flow.component.Component component, com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.internal.ExecutionContext> execution) voidvoidRuns the tasks collected viaUI.beforeClientResponse(com.vaadin.flow.component.Component, com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.internal.ExecutionContext>), emulating the batch the framework executes before a client response.Methods inherited from class com.vaadin.flow.component.UI
access, accessLater, accessLater, accessSynchronously, add, addAfterNavigationListener, addBeforeEnterListener, addBeforeLeaveListener, addHeartbeatListener, addModal, addShortcutListener, addShortcutListener, addToModalComponent, browserNavigate, close, getActiveDragSourceComponent, getActiveRouterTargetsChain, getActiveViewLocation, getChildren, getCsrfToken, getCurrent, getCurrentOrThrow, getCurrentView, getElement, getForwardToClientUrl, getInternals, getLoadingIndicatorConfiguration, getLocale, getNavigationListeners, getPage, getPollInterval, getPushConfiguration, getReconnectDialogConfiguration, getSession, getUI, getUIId, hasModalComponent, init, isClosing, isNavigationSupported, leaveNavigation, localeSignal, navigate, navigate, navigate, navigate, navigate, navigate, navigate, navigate, navigate, navigateToClient, onAttach, onDetach, push, refreshCurrentRoute, setChildComponentModal, setChildComponentModal, setCurrent, setDirection, setLocale, setPollIntervalMethods inherited from class com.vaadin.flow.component.Component
addListener, bindVisible, findAncestor, fireEvent, from, get, getEventBus, getId, getListeners, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, hasListener, isAttached, isTemplateMapped, isVisible, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.HasComponents
add, add, addComponentAsFirst, addComponentAtIndex, bindChildren, getComponentAt, getComponentCount, indexOf, remove, remove, removeAll, replaceMethods inherited from interface com.vaadin.flow.component.HasEnabled
bindEnabled, isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.PollNotifier
addPollListenerMethods inherited from interface com.vaadin.flow.router.RouterLayout
removeRouterLayoutContent, showRouterLayoutContent
-
Field Details
-
runningExecutions
protected boolean runningExecutions
-
-
Constructor Details
-
TestUI
public TestUI()
-
-
Method Details
-
doInit
- Overrides:
doInitin classcom.vaadin.flow.component.UI
-
beforeClientResponse
public com.vaadin.flow.internal.StateTree.ExecutionRegistration beforeClientResponse(com.vaadin.flow.component.Component component, com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.internal.ExecutionContext> execution) - Overrides:
beforeClientResponsein classcom.vaadin.flow.component.UI
-
runExecutionsBeforeClientResponse
public void runExecutionsBeforeClientResponse()Runs the tasks collected viaUI.beforeClientResponse(com.vaadin.flow.component.Component, com.vaadin.flow.function.SerializableConsumer<com.vaadin.flow.internal.ExecutionContext>), emulating the batch the framework executes before a client response.
-