Home | History | Annotate | Download | only in shadows
      1 package com.xtremelabs.robolectric.shadows;
      2 
      3 import android.widget.EditText;
      4 import com.xtremelabs.robolectric.Robolectric;
      5 import com.xtremelabs.robolectric.WithTestDefaultsRunner;
      6 import com.xtremelabs.robolectric.tester.android.util.TestAttributeSet;
      7 import org.junit.Test;
      8 import org.junit.runner.RunWith;
      9 
     10 import java.util.HashMap;
     11 
     12 import static org.hamcrest.CoreMatchers.equalTo;
     13 import static org.junit.Assert.assertThat;
     14 
     15 @RunWith(WithTestDefaultsRunner.class)
     16 public class ShadowEditTextTest {
     17     @Test
     18     public void shouldRespectMaxLength() throws Exception {
     19         HashMap<String, String> hash = new HashMap<String, String>();
     20         hash.put("android:maxLength", "5");
     21         TestAttributeSet attributeSet = new TestAttributeSet(hash);
     22         EditText editText = new EditText(Robolectric.application, attributeSet);
     23         editText.setText("0123456678");
     24         assertThat(editText.getText().toString(), equalTo("01234"));
     25     }
     26 }
     27