Class BaseUIUnitTest
-
- All Implemented Interfaces:
public abstract class BaseUIUnitTestBase class for UI unit tests. Provides methods to set up and clean a mocked Vaadin environment. The class allows scan classpath for routes and error views. Subclasses should typically restrict classpath scanning to a specific packages for faster bootstrap, by using ViewPackages annotation. If the annotation is not present a full classpath scan is performed For internal use only. May be renamed or removed in a future release.
-
-
Constructor Summary
Constructors Constructor Description BaseUIUnitTest()
-
Method Summary
Modifier and Type Method Description <T extends Component> Tnavigate(Class<T> navigationTarget)Navigate to the given view class if it is registered. <C, T extends Component, HasUrlParameter<C>> Tnavigate(Class<T> navigationTarget, C parameter)Navigate to view with url parameter. <T extends Component> Tnavigate(Class<T> navigationTarget, Map<String, String> parameters)Navigate to view corresponding to the given navigation target with the specified parameters. <T extends Component> Tnavigate(String location, Class<T> expectedTarget)Navigate to given location string. voidfireShortcut(Key key, Array<KeyModifier> modifiers)Simulates a keyboard shortcut performed on the browser. HasElementgetCurrentView()Get the current view instance that is shown on the ui. <T extends ComponentTester<Y>, Y extends Component> Ttest(Y component)Wrap component with ComponentTester best matching component type. <T extends ComponentTester<Y>, Y extends Component> Ttest(Class<T> tester, Y component)Wrap component in given ComponentTester. <T extends Component> ComponentQuery<T>$(Class<T> componentType)Gets a query object for finding a component inside the UI <T extends Component> ComponentQuery<T>$(Class<T> componentType, Component fromThis)Gets a query object for finding a component nested inside the given component. <T extends Component> ComponentQuery<T>$view(Class<T> componentType)Gets a query object for finding a component inside the current view -
-
Method Detail
-
navigate
<T extends Component> T navigate(Class<T> navigationTarget)
Navigate to the given view class if it is registered.
- Parameters:
navigationTarget- view class to navigate to- Returns:
instantiated view
-
navigate
<C, T extends Component, HasUrlParameter<C>> T navigate(Class<T> navigationTarget, C parameter)
Navigate to view with url parameter.
- Parameters:
navigationTarget- view class to navigate toparameter- parameter to send to view- Returns:
instantiated view
-
navigate
<T extends Component> T navigate(Class<T> navigationTarget, Map<String, String> parameters)
Navigate to view corresponding to the given navigation target with the specified parameters.
- Parameters:
navigationTarget- view class to navigate toparameters- parameters to pass to view.- Returns:
instantiated view
-
navigate
<T extends Component> T navigate(String location, Class<T> expectedTarget)
Navigate to given location string. Check that location navigated to is the expected view or throw exception.
- Parameters:
location- location string for navigatingexpectedTarget- class that is expected for navigation- Returns:
instantiated view
-
fireShortcut
void fireShortcut(Key key, Array<KeyModifier> modifiers)
Simulates a keyboard shortcut performed on the browser.
- Parameters:
key- Primary key of the shortcut.modifiers- Key modifiers.
-
getCurrentView
HasElement getCurrentView()
Get the current view instance that is shown on the ui.
- Returns:
current view
-
test
<T extends ComponentTester<Y>, Y extends Component> T test(Y component)
Wrap component with ComponentTester best matching component type.
- Parameters:
component- component to get test wrapper for- Returns:
component in wrapper with test helpers
-
test
<T extends ComponentTester<Y>, Y extends Component> T test(Class<T> tester, Y component)
Wrap component in given ComponentTester.
- Parameters:
tester- test wrapper to usecomponent- component to wrap- Returns:
initialized test wrapper for component
-
$
<T extends Component> ComponentQuery<T> $(Class<T> componentType)
Gets a query object for finding a component inside the UI
- Parameters:
componentType- the type of the component(s) to search for- Returns:
a query object for finding components
-
$
<T extends Component> ComponentQuery<T> $(Class<T> componentType, Component fromThis)
Gets a query object for finding a component nested inside the given component.
- Parameters:
componentType- the type of the component(s) to search forfromThis- component used as starting element for search.- Returns:
a query object for finding components
-
$view
<T extends Component> ComponentQuery<T> $view(Class<T> componentType)
Gets a query object for finding a component inside the current view
- Parameters:
componentType- the type of the component(s) to search for- Returns:
a query object for finding components
-
-
-
-