public class SectionsTestHelper extends Section
Allows testing a GroupsSectionSpec
's direct children without building the whole
hieararchy. Also allows simpler State updates testing by keeping trach of a scoped section
context.
Section.Builder<T extends Section.Builder<T>>
SectionLifecycle.StateContainer, SectionLifecycle.StateUpdate
Constructor and Description |
---|
SectionsTestHelper(Context c) |
Modifier and Type | Method and Description |
---|---|
static Object |
dispatchEvent(HasEventDispatcher section,
EventHandler eventHandler,
Object event)
Dispatches an event to the section
|
List<SubSection> |
getChildren(Section section)
Get child sections for the given section.
|
SectionContext |
getContext()
Return a generic
SectionContext you can use to create sections. |
SectionContext |
getScopedContext(Section s)
Return the specific
SectionContext that's been scoped to the given section. |
String |
getSimpleName()
Mostly used by logging to provide more readable messages.
|
<T extends SectionLifecycle.StateContainer> |
getStateContainer(Section section)
Get the state container of the given section.
|
static List<SubSection> |
getSubSections(Children children)
Get sub sections for the given Children.
|
Section |
prepare(Section s)
Prepare section for testing.
|
getChildren, getEventDispatcher, getGlobalKey, getScopedContext, getStateContainer, isEquivalentTo, makeShallowCopy, makeShallowCopy, recordEventTrigger, setChildren, setCount, setGlobalKey, setKey, setScopedContext
acceptTriggerEvent, acquireDiff, acquireOutput, bindService, createChildren, createInitialState, createService, dataBound, dispatchLoadingEvent, dispatchOnEvent, generateChangeSet, getEventTrigger, getLoadingEventHandler, getService, getTreePropsForChildren, isDiffSectionSpec, newEventHandler, newEventHandler, newEventTrigger, populateTreeProps, refresh, releaseDiff, releaseOutput, requestFocus, requestFocus, requestFocus, requestFocusWithOffset, requestFocusWithOffset, shouldUpdate, transferService, transferState, unbindService, viewportChanged
public SectionContext getContext()
SectionContext
you can use to create sections.@Nullable public SectionContext getScopedContext(Section s)
SectionContext
that's been scoped to the given section.public Section prepare(Section s)
Prepare sets up a proper scoped SectionContext
we can use to test lifecycle methods
and state updates. It also prepares the given section for use by calling lifecycle methods like
onCreateInitialState
.
@Nullable public List<SubSection> getChildren(Section section)
section
- The section under test.@Nullable public static List<SubSection> getSubSections(Children children)
getChildren(Section)
except it gets the Children intead of calling createChildren. This is useful for testing the
output of RenderSectionEvent
handlers.children
- The Children object to extract sections from.public <T extends SectionLifecycle.StateContainer> T getStateContainer(Section section)
T
- The section's StateContainer classsection
- The section for which you want the state values from.public static Object dispatchEvent(HasEventDispatcher section, EventHandler eventHandler, Object event)
section
- the section under testeventHandler
- the event handler to executeevent
- the event objectpublic String getSimpleName()
Section
getSimpleName
in class Section