Search in sources :

Example 1 with ShadowTextView

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));
}
Also used : ShadowTextView(org.robolectric.shadows.ShadowTextView) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)1 ShadowTextView (org.robolectric.shadows.ShadowTextView)1