use of org.robobinding.BindingContext in project RoboBinding by RoboBinding.
the class SubViewWithoutPresentationModelAttributeTest method whenBindTo_thenStaticSubViewIsSetOnHolder.
@Test
public void whenBindTo_thenStaticSubViewIsSetOnHolder() {
BindingContext bindingContext = mock(BindingContext.class);
when(bindingContext.inflateWithoutAttachingToRoot(anyInt(), any(ViewGroup.class))).thenReturn(staticSubView);
SubViewWithoutPresentationModelAttribute attribute = new SubViewWithoutPresentationModelAttribute(null, 0, subViewHolder);
attribute.bindTo(bindingContext);
verify(subViewHolder).setSubView(staticSubView);
}
use of org.robobinding.BindingContext in project RoboBinding by RoboBinding.
the class ViewBinderImpl method inflateAndBind.
@Override
public View inflateAndBind(int layoutId, Object presentationModel) {
checkLayoutId(layoutId);
checkPresentationModel(presentationModel);
BindingContext bindingContext = bindingContextFactory.create(presentationModel);
InflatedViewWithRoot inflatedView = bindingViewInflater.inflateView(layoutId);
viewBindingLifecycle.run(inflatedView, bindingContext);
return inflatedView.getRootView();
}
use of org.robobinding.BindingContext in project RoboBinding by RoboBinding.
the class SubViewPresentationModelAttributeTest method whenBind_thenBoundSubViewIsSetOnHolder.
@Test
public void whenBind_thenBoundSubViewIsSetOnHolder() {
int layoutId = 1;
String presentationModelPropertyName = "propertyName";
ViewGroup parent = mock(ViewGroup.class);
View boundSubView = mock(View.class);
BindingContext context = mock(BindingContext.class);
SubViewHolder subViewHolder = mock(SubViewHolder.class);
SubBindingContext subBindingContext = mock(SubBindingContext.class);
when(context.navigateToSubContext(presentationModelPropertyName)).thenReturn(subBindingContext);
when(subBindingContext.inflateAndBindWithoutAttachingToRoot(layoutId, parent)).thenReturn(boundSubView);
SubViewPresentationModelAttribute subViewAttribute = new SubViewPresentationModelAttribute(parent, layoutId, subViewHolder);
subViewAttribute.setAttribute(aValueModelAttribute(presentationModelPropertyName));
subViewAttribute.bindTo(context);
verify(subViewHolder).setSubView(boundSubView);
}
Aggregations