Search in sources :

Example 1 with ContactDetails

use of com.waz.api.ContactDetails 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 ContactDetails

use of com.waz.api.ContactDetails in project wire-android by wireapp.

the class SearchResultAdapter method updateMergedContacts.

private void updateMergedContacts() {
    mergedContacts.clear();
    if (contacts != null) {
        for (int i = 0; i < contacts.size(); i++) {
            ContactDetails details = contacts.get(i).getDetails();
            if (details != null) {
                mergedContacts.add(new SearchContact(ITEM_TYPE_CONTACT, i, details.getDisplayName()));
            }
        }
    }
    if (connectedUsers != null) {
        for (int i = 0; i < connectedUsers.length; i++) {
            mergedContacts.add(new SearchContact(ITEM_TYPE_CONNECTED_USER, i, connectedUsers[i].getDisplayName()));
        }
    }
    Collections.sort(mergedContacts, new Comparator<SearchContact>() {

        @Override
        public int compare(SearchContact o1, SearchContact o2) {
            return o1.name.compareToIgnoreCase(o2.name);
        }
    });
}
Also used : ContactDetails(com.waz.api.ContactDetails)

Example 3 with ContactDetails

use of com.waz.api.ContactDetails in project wire-android by wireapp.

the class UserDetailsViewTest method assertAddressBookNameThatIsSameThanWireNameIsShown.

@Test
public void assertAddressBookNameThatIsSameThanWireNameIsShown() {
    User mockUser = MockHelper.createMockUser("Anna", "123");
    ContactDetails mockContactDetails = mock(ContactDetails.class);
    String addressBookName = "Anna";
    when(mockContactDetails.getDisplayName()).thenReturn(addressBookName);
    when(mockUser.getFirstContact()).thenReturn(mockContactDetails);
    UserDetailsView userDetailsView = new UserDetailsView(activity);
    userDetailsView.setUser(mockUser);
    setView(userDetailsView);
    final String addressBookInfo = activity.getString(com.waz.zclient.ui.R.string.content__message__connect_request__user_info, "");
    onView(withId(R.id.ttv__user_details__user_info)).check(isVisible());
    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 4 with ContactDetails

use of com.waz.api.ContactDetails in project wire-android by wireapp.

the class UserDetailsViewTest method assertAddressBookNameThatIsDifferentThanWireNameIsShown.

@Test
public void assertAddressBookNameThatIsDifferentThanWireNameIsShown() {
    User mockUser = MockHelper.createMockUser("Anna", "123");
    ContactDetails mockContactDetails = mock(ContactDetails.class);
    String addressBookName = "Mom";
    when(mockContactDetails.getDisplayName()).thenReturn(addressBookName);
    when(mockUser.getFirstContact()).thenReturn(mockContactDetails);
    UserDetailsView userDetailsView = new UserDetailsView(activity);
    userDetailsView.setUser(mockUser);
    setView(userDetailsView);
    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(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)

Aggregations

ContactDetails (com.waz.api.ContactDetails)4 User (com.waz.api.User)3 ViewTest (com.waz.zclient.testutils.ViewTest)3 UserDetailsView (com.waz.zclient.ui.views.UserDetailsView)3 Test (org.junit.Test)3