use of org.edx.mobile.event.AccountDataLoadedEvent in project edx-app-android by edx.
the class UserProfileInteractorTest method onAccountUpdatedEvent_withMatchingUsername_emitsUpdatedProfileContent.
@Test
public void onAccountUpdatedEvent_withMatchingUsername_emitsUpdatedProfileContent() throws Exception {
final Account account = configureBareMockAccount();
createAndObserveInteractor();
verify(profileObserver).onData(refEq(new UserProfileViewModel(UserProfileViewModel.LimitedProfileMessage.NONE, null, null, new UserProfileBioModel(UserProfileBioModel.ContentType.NO_ABOUT_ME, null))));
when(account.getBio()).thenReturn(ProfileValues.ABOUT_ME);
eventBus.post(new AccountDataLoadedEvent(account));
verify(profileObserver).onData(refEq(new UserProfileViewModel(UserProfileViewModel.LimitedProfileMessage.NONE, null, null, new UserProfileBioModel(UserProfileBioModel.ContentType.ABOUT_ME, ProfileValues.ABOUT_ME))));
}
use of org.edx.mobile.event.AccountDataLoadedEvent in project edx-app-android by edx.
the class UserProfileInteractorTest method onAccountUpdatedEvent_withUnrelatedUsername_emitsUpdatedProfileContent.
@Test
public void onAccountUpdatedEvent_withUnrelatedUsername_emitsUpdatedProfileContent() throws Exception {
final Account account = configureBareMockAccount();
createAndObserveInteractor();
verify(profileObserver).onData(refEq(new UserProfileViewModel(UserProfileViewModel.LimitedProfileMessage.NONE, null, null, new UserProfileBioModel(UserProfileBioModel.ContentType.NO_ABOUT_ME, null))));
when(account.getUsername()).thenReturn(ProfileValues.ALTERNATE_USERNAME);
when(account.getBio()).thenReturn(ProfileValues.ABOUT_ME);
eventBus.post(new AccountDataLoadedEvent(account));
verifyNoMoreInteractions(profileObserver);
}
use of org.edx.mobile.event.AccountDataLoadedEvent in project edx-app-android by edx.
the class NavigationFragmentTest method testProfileImageUpdation_onGlobalAccountEvent.
@Test
public void testProfileImageUpdation_onGlobalAccountEvent() {
final NavigationFragment fragment = new NavigationFragment();
SupportFragmentTestUtil.startVisibleFragment(fragment);
final View view = fragment.getView();
assertNotNull(view);
final ImageView profileImage = (ImageView) view.findViewById(R.id.profile_image);
assertNotNull(profileImage);
// Assert: Profile pic not updated when a non-logged in user's account object is broadcasted
Drawable previousDrawable = profileImage.getDrawable();
Account account = configureMockAccount("not_logged_in_user");
EventBus.getDefault().post(new AccountDataLoadedEvent(account));
assertEquals(previousDrawable, profileImage.getDrawable());
// Assert: Profile pic is updated when a logged-in user's account object is broadcasted
UserPrefs userPrefs = RoboGuice.getInjector(context).getInstance(UserPrefs.class);
final String loggedInUser = userPrefs.getProfile().username;
account = configureMockAccount(loggedInUser);
EventBus.getDefault().post(new AccountDataLoadedEvent(account));
assertNotEquals(previousDrawable, profileImage.getDrawable());
}
Aggregations