use of com.airbnb.epoxy.DataBindingEpoxyModel.DataBindingHolder in project epoxy by airbnb.
the class DataBindingModelIntegrationTest method createDataBindingModel.
@Test
public void createDataBindingModel() {
SimpleEpoxyController controller = new SimpleEpoxyController();
ModelWithDataBindingBindingModel_ firstModel = new ModelWithDataBindingBindingModel_().stringValue("hello").id(1);
controller.setModels(Collections.singletonList(firstModel));
ControllerLifecycleHelper lifecycleHelper = new ControllerLifecycleHelper();
EpoxyViewHolder viewHolder = lifecycleHelper.createViewHolder(controller.getAdapter(), 0);
controller.getAdapter().onBindViewHolder(viewHolder, 0);
DataBindingHolder dataBindingHolder = ((DataBindingHolder) viewHolder.objectToBind());
assertNotNull(dataBindingHolder.getDataBinding());
// Check that the requiredText was set on the view
assertEquals(firstModel.stringValue(), ((Button) viewHolder.itemView).getText());
ModelWithDataBindingBindingModel_ secondModel = new ModelWithDataBindingBindingModel_().stringValue("hello again").id(1);
controller.setModels(Collections.singletonList(secondModel));
List<Object> payloads = DiffPayloadTestUtil.payloadsWithChangedModels(firstModel);
controller.getAdapter().onBindViewHolder(viewHolder, 0, payloads);
// Check that the requiredText was updated after the change payload
assertEquals(secondModel.stringValue(), ((Button) viewHolder.itemView).getText());
}
use of com.airbnb.epoxy.DataBindingEpoxyModel.DataBindingHolder in project epoxy by airbnb.
the class DataBindingModelIntegrationTest method fullyCreateDataBindingModel.
@Test
public void fullyCreateDataBindingModel() {
SimpleEpoxyController controller = new SimpleEpoxyController();
ModelWithDataBindingBindingModel_ firstModel = new ModelWithDataBindingBindingModel_().stringValue("hello").id(1);
controller.setModels(Collections.singletonList(firstModel));
ControllerLifecycleHelper lifecycleHelper = new ControllerLifecycleHelper();
EpoxyViewHolder viewHolder = lifecycleHelper.createViewHolder(controller.getAdapter(), 0);
controller.getAdapter().onBindViewHolder(viewHolder, 0);
DataBindingHolder dataBindingHolder = ((DataBindingHolder) viewHolder.objectToBind());
assertNotNull(dataBindingHolder.getDataBinding());
// Check that the requiredText was set on the view
assertEquals(firstModel.stringValue(), ((Button) viewHolder.itemView).getText());
ModelWithDataBindingBindingModel_ secondModel = new ModelWithDataBindingBindingModel_().stringValue("hello again").id(1);
controller.setModels(Collections.singletonList(secondModel));
List<Object> payloads = DiffPayloadTestUtil.payloadsWithChangedModels(firstModel);
controller.getAdapter().onBindViewHolder(viewHolder, 0, payloads);
// Check that the requiredText was updated after the change payload
assertEquals(secondModel.stringValue(), ((Button) viewHolder.itemView).getText());
}
Aggregations