use of org.robolectric.shadows.ShadowTextView in project RoboBinding by RoboBinding.
the class TwoWayStringTextAttributeTest method givenALateValueCommitAttribute_whenViewLosesFocus_thenCommitToValueModel.
@Test
public void givenALateValueCommitAttribute_whenViewLosesFocus_thenCommitToValueModel() {
attribute.setValueCommitMode(ValueCommitMode.ON_FOCUS_LOST);
String newText = RandomStringUtils.randomAlphanumeric(5);
ValueModel<String> valueModel = ValueModelUtils.create();
attribute.observeChangesOnTheView(null, valueModel, view);
view.setText(newText);
ShadowTextView shadowTextView = Shadows.shadowOf(view);
shadowTextView.setViewFocus(false);
assertThat(valueModel.getValue(), sameAs(newText));
}
Aggregations