Package com.vaadin.browserless.internal
Interface TestingLifecycleHook
public interface TestingLifecycleHook
If you need to hook into the testing lifecycle (e.g. you need to wait for any
async operations to finish), provide your own custom implementation of this
interface, then set it via
TestingLifecycleHooks.setTestingLifecycleHook(TestingLifecycleHook).
Mocking server request end
Since Browserless Testing runs in the same JVM as the server and there is no browser, the boundaries between the client and the server become unclear. When looking into sources of any test method, it's really hard to tell where exactly the server request ends, and where another request starts.
You can establish an explicit client boundary in your test, by explicitly
calling MockVaadin.clientRoundtrip(). However, since that would be
both laborous and error-prone, the default operation is that Browserless
Testing pretends as if there was a client-server roundtrip before every
component lookup via the _get/_find/_expectNone/
_expectOne call. Therefore, MockVaadin.clientRoundtrip() is
called from awaitBeforeLookup() by default.
For internal use only. May be renamed or removed in a future release.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final TestingLifecycleHookA hook that does nothing beyond the default implementations below. -
Method Summary
Modifier and TypeMethodDescriptiondefault voidInvoked after every component lookup.default voidInvoked before every component lookup.getAllChildren(Component component) Provides all children of given component.
-
Field Details
-
DEFAULT
A hook that does nothing beyond the default implementations below.
-
-
Method Details
-
awaitBeforeLookup
default void awaitBeforeLookup()Invoked before every component lookup. You can e.g. wait for any async operations to finish and for the server to settle down.The default implementation calls the
MockVaadin.clientRoundtrip()method. When implementing this method, you should also callMockVaadin.clientRoundtrip()(or simply call super). -
awaitAfterLookup
default void awaitAfterLookup()Invoked after every component lookup. You can e.g. wait for any async operations to finish and for the server to settle down. Invoked even if the_get()/_find()/_expectNone()function fails. -
getAllChildren
Provides all children of given component. The default implementation returns the children provided by the first registeredComponentSupportthat knows the component (for example the header, footer and editor components of aGrid, or the items of a sub-menu). Otherwise it returns the component's own children together with its element-tree children, including virtual ones; for templates andCompositeonly the component's own children are returned.- Parameters:
component- the component whose children to return.- Returns:
- the children of the component.
-