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 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. |
<T extends 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.
|
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.
|
generateUniqueGlobalKeyForChild, getChildren, getEventDispatcher, getGlobalKey, getHandle, getKey, getLogTag, getParent, getScopedContext, getSimpleName, getStateContainer, makeShallowCopy, makeShallowCopy, recordEventTrigger, setChildren, setCount, setGlobalKey, setKey, setScopedContext
acceptTriggerEvent, bindService, createChildren, createInitialState, createService, dataBound, dataRendered, dispatchLoadingEvent, dispatchOnEvent, generateChangeSet, getEventTrigger, getEventTrigger, getLoadingEventHandler, getService, getTreePropsForChildren, isDiffSectionSpec, isSectionIndexValid, newEventHandler, newEventHandler, newEventTrigger, populateTreeProps, refresh, requestFocus, requestFocus, requestFocus, requestFocusWithOffset, requestFocusWithOffset, requestFocusWithOffset, requestSmoothFocus, requestSmoothFocus, requestSmoothFocus, shouldUpdate, transferService, transferState, unbindService, 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 List<SubSection> getChildren(Section section)
section
- The section under test.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 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 object