Search in sources :

Example 1 with UserDetailsView

use of com.waz.zclient.ui.views.UserDetailsView in project wire-android by wireapp.

the class UserDetailsViewTest method assertCommonUsersIsNotShownForUnconnectedUserThatIsInAddressBook.

@Test
public void assertCommonUsersIsNotShownForUnconnectedUserThatIsInAddressBook() {
    User mockUser = MockHelper.createMockUser("Anna", "123");
    when(mockUser.getConnectionStatus()).thenReturn(User.ConnectionStatus.UNCONNECTED);
    int commonUsersCount = 3;
    when(mockUser.getCommonConnectionsCount()).thenReturn(commonUsersCount);
    String addressBookName = "Mom";
    ContactDetails mockContactDetails = mock(ContactDetails.class);
    when(mockContactDetails.getDisplayName()).thenReturn(addressBookName);
    when(mockUser.getFirstContact()).thenReturn(mockContactDetails);
    UserDetailsView userDetailsView = new UserDetailsView(activity);
    userDetailsView.setUser(mockUser);
    setView(userDetailsView);
    final String commonUsersSummary = activity.getResources().getQuantityString(com.waz.zclient.ui.R.plurals.connect_request__common_users__summary, commonUsersCount, commonUsersCount);
    final String addressBookInfo = activity.getString(com.waz.zclient.ui.R.string.content__message__connect_request__user_info, addressBookName);
    onView(withId(R.id.ttv__user_details__user_info)).check(isVisible());
    onView(withId(R.id.ttv__user_details__user_info)).check(doesNotContainText(commonUsersSummary));
    onView(withId(R.id.ttv__user_details__user_info)).check(hasText(addressBookInfo));
}
Also used : UserDetailsView(com.waz.zclient.ui.views.UserDetailsView) User(com.waz.api.User) ContactDetails(com.waz.api.ContactDetails) Test(org.junit.Test) ViewTest(com.waz.zclient.testutils.ViewTest)

Example 2 with UserDetailsView

use of com.waz.zclient.ui.views.UserDetailsView in project wire-android by wireapp.

the class UserDetailsViewTest method assertCommonUsersIsShownForPendingOutgoingUserThatIsNotInAddressBook.

@Test
public void assertCommonUsersIsShownForPendingOutgoingUserThatIsNotInAddressBook() {
    User mockUser = MockHelper.createMockUser("Anna", "123");
    when(mockUser.getConnectionStatus()).thenReturn(User.ConnectionStatus.PENDING_FROM_USER);
    int commonUsersCount = 3;
    when(mockUser.getCommonConnectionsCount()).thenReturn(commonUsersCount);
    when(mockUser.getFirstContact()).thenReturn(null);
    UserDetailsView userDetailsView = new UserDetailsView(activity);
    userDetailsView.setUser(mockUser);
    setView(userDetailsView);
    final String commonUsersSummary = activity.getResources().getQuantityString(com.waz.zclient.ui.R.plurals.connect_request__common_users__summary, commonUsersCount, commonUsersCount);
    onView(withId(R.id.ttv__user_details__user_info)).check(isVisible());
    onView(withId(R.id.ttv__user_details__user_info)).check(hasText(commonUsersSummary));
}
Also used : UserDetailsView(com.waz.zclient.ui.views.UserDetailsView) User(com.waz.api.User) Test(org.junit.Test) ViewTest(com.waz.zclient.testutils.ViewTest)

Example 3 with UserDetailsView

use of com.waz.zclient.ui.views.UserDetailsView in project wire-android by wireapp.

the class UserDetailsViewTest method assertCommonUsersIsShownForUnconnectedUserThatIsNotInAddressBook.

@Test
public void assertCommonUsersIsShownForUnconnectedUserThatIsNotInAddressBook() {
    User mockUser = MockHelper.createMockUser("Anna", "123");
    when(mockUser.getConnectionStatus()).thenReturn(User.ConnectionStatus.UNCONNECTED);
    int commonUsersCount = 3;
    when(mockUser.getCommonConnectionsCount()).thenReturn(commonUsersCount);
    when(mockUser.getFirstContact()).thenReturn(null);
    UserDetailsView userDetailsView = new UserDetailsView(activity);
    userDetailsView.setUser(mockUser);
    setView(userDetailsView);
    final String commonUsersSummary = activity.getResources().getQuantityString(com.waz.zclient.ui.R.plurals.connect_request__common_users__summary, commonUsersCount, commonUsersCount);
    onView(withId(R.id.ttv__user_details__user_info)).check(isVisible());
    onView(withId(R.id.ttv__user_details__user_info)).check(hasText(commonUsersSummary));
}
Also used : UserDetailsView(com.waz.zclient.ui.views.UserDetailsView) User(com.waz.api.User) Test(org.junit.Test) ViewTest(com.waz.zclient.testutils.ViewTest)

Example 4 with UserDetailsView

use of com.waz.zclient.ui.views.UserDetailsView in project wire-android by wireapp.

the class UserDetailsViewTest method assertExistingUserHandleIsVisible.

@Test
public void assertExistingUserHandleIsVisible() {
    String handle = "red_panda";
    User mockUser = MockHelper.createMockUser("Anna", "123");
    when(mockUser.getUsername()).thenReturn(handle);
    UserDetailsView userDetailsView = new UserDetailsView(activity);
    userDetailsView.setUser(mockUser);
    setView(userDetailsView);
    onView(withId(R.id.ttv__user_details__user_name)).check(isVisible());
    onView(withId(R.id.ttv__user_details__user_name)).check(hasText(StringUtils.formatHandle(handle)));
}
Also used : UserDetailsView(com.waz.zclient.ui.views.UserDetailsView) User(com.waz.api.User) Test(org.junit.Test) ViewTest(com.waz.zclient.testutils.ViewTest)

Example 5 with UserDetailsView

use of com.waz.zclient.ui.views.UserDetailsView in project wire-android by wireapp.

the class UserDetailsViewTest method assertEmptyUserHandleIsNotShown.

@Test
public void assertEmptyUserHandleIsNotShown() {
    String handle = "";
    User mockUser = MockHelper.createMockUser("Anna", "123");
    when(mockUser.getUsername()).thenReturn(handle);
    UserDetailsView userDetailsView = new UserDetailsView(activity);
    userDetailsView.setUser(mockUser);
    setView(userDetailsView);
    onView(withId(R.id.ttv__user_details__user_name)).check(isGone());
}
Also used : UserDetailsView(com.waz.zclient.ui.views.UserDetailsView) User(com.waz.api.User) Test(org.junit.Test) ViewTest(com.waz.zclient.testutils.ViewTest)

Aggregations

UserDetailsView (com.waz.zclient.ui.views.UserDetailsView)14 User (com.waz.api.User)8 ViewTest (com.waz.zclient.testutils.ViewTest)8 Test (org.junit.Test)8 View (android.view.View)6 TextView (android.widget.TextView)6 ImageAssetImageView (com.waz.zclient.views.images.ImageAssetImageView)5 Toolbar (android.support.v7.widget.Toolbar)3 ContactDetails (com.waz.api.ContactDetails)3 ShieldView (com.waz.zclient.ui.views.e2ee.ShieldView)2 Bundle (android.os.Bundle)1 IConnectStore (com.waz.zclient.core.stores.connect.IConnectStore)1