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>>
Constructor and Description |
---|
SectionsTestHelper(Context c) |
Modifier and Type | Method and Description |
---|---|
static java.lang.Object |
dispatchEvent(HasEventDispatcher section,
EventHandler eventHandler,
java.lang.Object event)
Dispatches an event to the section
|
java.util.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. |
<T extends StateContainer> |
getStateContainer(Section section)
Get the state container of the given section.
|
static java.util.List<SubSection> |
getSubSections(Children children)
Get sub sections for the given Children.
|
boolean |
isEquivalentTo(Section other)
Compares this section to a different one to check if they are the same
|
Section |
prepare(Section s)
Prepare section for testing.
|
createStateContainer, generateUniqueGlobalKeyForChild, getChildren, getEventDispatcher, getGlobalKey, getLogTag, getParent, getScopedContext, getSimpleName, getStateContainer, getStateContainer, isEquivalentProps, makeShallowCopy, makeShallowCopy, recordEventTrigger, setChildren, setCount, setGlobalKey, setKey, setScopedContext, setStateContainer
acceptTriggerEvent, acceptTriggerEventImpl, bindService, createChildren, createInitialState, createService, dataBound, dataRendered, dispatchLoadingEvent, dispatchOnEvent, dispatchOnEventImpl, generateChangeSet, getEventTrigger, getEventTrigger, getLoadingEventHandler, getService, getTreePropsForChildren, isDiffSectionSpec, isSectionIndexValid, newEventHandler, newEventTrigger, newEventTrigger, populateTreeProps, refresh, requestFocus, requestFocus, requestFocus, requestFocusWithOffset, requestFocusWithOffset, requestFocusWithOffset, requestSmoothFocus, requestSmoothFocus, requestSmoothFocus, shouldUpdate, transferService, transferState, unbindService, verifyChangeSet, viewportChanged
public boolean isEquivalentTo(Section other)
Section
This is used to be able to skip rendering a section again. We avoid using the Object.equals(Object)
so we can optimize the code better over time since we don't have to
adhere to the contract required for a equals method.
isEquivalentTo
in interface Equivalence<Section>
isEquivalentTo
in class Section
other
- the component to compare topublic SectionContext getContext()
SectionContext
you can use to create sections.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
.
public java.util.List<SubSection> getChildren(Section section)
section
- The section under test.public static java.util.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 StateContainer> T getStateContainer(Section section)
T
- The section's StateContainer classsection
- The section for which you want the state values from.public static java.lang.Object dispatchEvent(HasEventDispatcher section, EventHandler eventHandler, java.lang.Object event)
section
- the section under testeventHandler
- the event handler to executeevent
- the event object