Skip to content

Instantly share code, notes, and snippets.

@miquelbeltran
Last active September 5, 2016 17:28
Show Gist options
  • Save miquelbeltran/de0156c2f87c850af4ef4052b9709dac to your computer and use it in GitHub Desktop.
Save miquelbeltran/de0156c2f87c850af4ef4052b9709dac to your computer and use it in GitHub Desktop.
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class)
public class ProfileFrameLayoutTest {
private ProfileFrameLayout profileView;
@Mock
ProfilePresenter presenter;
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
profileView = new ProfileFrameLayout(RuntimeEnvironment.application);
profileView.setPresenter(presenter);
}
@Test
public void testEmpty() throws Exception {
verify(presenter).attachView(profileView);
asserThat(profileView.textUsername.getText().toString()).isEmpty();
}
@Test
public void testLeaveView() throws Exception {
profileView.onDetachedFromWindow();
verify(presenter).detachView();
}
@Test
public void testReturnToView() throws Exception {
reset(presenter);
profileView.onAttachedToWindow();
verify(presenter).attachView(profileView);
}
@Test
public void testDisplay() throws Exception {
UserProfile user = new UserProfile(USER);
profileView.display(user);
asserThat(profileView.textUsername.getText().toString()).isEqualTo(USER);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment