Created
July 31, 2014 05:30
-
-
Save IlyaEremin/56ad0344c9551113ee74 to your computer and use it in GitHub Desktop.
robolectric tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Config(emulateSdk = 18) | |
@RunWith(RobolectricTestRunner.class) | |
public class FileIconHelperTest { | |
@Test | |
public void testGetExtension() throws Exception { | |
assertThat(getExtension("image/jpeg")).isEqualTo("jpg"); | |
assertThat(getExtension("video/avi")).isEqualTo("avi"); | |
assertThat(getExtension("superpuper/file")).isEqualTo(""); | |
} | |
@Test | |
public void testGetIconForType() throws Exception { | |
assertThat(getIconForType(Constants.SYSTEM_SHARED_FOLDER)).isEqualTo(R.drawable.shared_folder_icon); | |
assertThat(getIconForType(Constants.SYSTEM_CONTACTS_FOLDER)).isEqualTo(R.drawable.contacts_icon); | |
assertThat(getIconForType("unknown_type")).isEqualTo(R.drawable.documents_icon); | |
} | |
@Test | |
public void testGetTextColor() throws Exception { | |
// verify toLowerCase convertation | |
assertThat(getTextColor("pdf")).isEqualTo(getTextColor("PDF")); | |
assertThat(getTextColor("pdf")).isEqualTo(PDF_COLOR); | |
assertThat(getTextColor("docx")).isEqualTo(DOC_COLOR); | |
assertThat(getTextColor("mp3")).isEqualTo(MP3_COLOR); | |
assertThat(getTextColor("magic_extension")).isEqualTo(Color.BLACK); | |
} | |
} | |
@Config(emulateSdk = 18) | |
@RunWith(RobolectricTestRunner.class) | |
public class MainActivityRobTest { | |
@Test public void checkLogIn() throws Exception { | |
MainActivity activity = Robolectric.buildActivity(MainActivity.class).create().start().resume().visible().get(); | |
EditText username = (EditText) activity.findViewById(R.id.et_login_email); | |
EditText password = (EditText) activity.findViewById(R.id.et_login_password); | |
username.setText("[email protected]"); | |
password.setText("Password"); | |
activity.findViewById(R.id.login_button).performClick(); | |
Assertions.assertThat(password.getText().toString()).isNotEmpty(); | |
Assertions.assertThat(activity).isNotEqualTo(activity); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment