Search in sources :

Example 6 with IConversation

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

the class ConversationFragmentTest method assertCursorImagesGalleryButton.

@TargetApi(Build.VERSION_CODES.KITKAT)
public void assertCursorImagesGalleryButton() throws Exception {
    IConversation mockConversation = mock(IConversation.class);
    when(mockConversation.getType()).thenReturn(IConversation.Type.GROUP);
    when(mockConversation.isMemberOfConversation()).thenReturn(true);
    when(mockConversation.isActive()).thenReturn(true);
    IAccentColorController mockAccentColorController = activity.getControllerFactory().getAccentColorController();
    AccentColor mockAccentColor = mock(AccentColor.class);
    when(mockAccentColor.getColor()).thenReturn(Color.RED);
    when(mockAccentColorController.getAccentColor()).thenReturn(mockAccentColor);
    String action = Intent.ACTION_OPEN_DOCUMENT;
    Matcher<Intent> expectedIntent = allOf(hasAction(action), hasType("image/*"));
    Intent intent = new Intent();
    intent.setData(Uri.parse("file:///tmp/whatever.txt"));
    Instrumentation.ActivityResult result = new Instrumentation.ActivityResult(Activity.RESULT_OK, intent);
    intending(expectedIntent).respondWith(result);
    MockHelper.setupConversationMocks(mockConversation, activity);
    attachFragment(ConversationFragment.newInstance(), ConversationFragment.TAG);
    onView(withId(R.id.cursor_menu_item_camera)).check(isVisible());
    onView(withId(R.id.cursor_menu_item_camera)).perform(click());
    Thread.sleep(500);
    onView(withId(R.id.rv__cursor_images)).check(isVisible());
    onView(withId(R.id.gtv__cursor_image__nav_open_gallery)).check(isVisible());
//        onView(withId(R.id.gtv__cursor_image__nav_open_gallery)).perform(click());
}
Also used : AccentColor(com.waz.api.AccentColor) Instrumentation(android.app.Instrumentation) IConversation(com.waz.api.IConversation) Intent(android.content.Intent) IAccentColorController(com.waz.zclient.controllers.accentcolor.IAccentColorController) TargetApi(android.annotation.TargetApi)

Example 7 with IConversation

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

the class FileUploadTest method assertFileUploadIntentInOneToOneConversation.

@Test
@SuppressLint("NewApi")
public void assertFileUploadIntentInOneToOneConversation() throws InterruptedException {
    // Mock conversation
    IConversation mockConversation = mock(IConversation.class);
    when(mockConversation.getType()).thenReturn(IConversation.Type.ONE_TO_ONE);
    when(mockConversation.isMemberOfConversation()).thenReturn(true);
    when(mockConversation.isActive()).thenReturn(true);
    MockHelper.setupConversationMocks(mockConversation, activity);
    IConversationStore mockConversationStore = activity.getStoreFactory().getConversationStore();
    // Mock intent result
    String action;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        action = Intent.ACTION_OPEN_DOCUMENT;
    } else {
        action = Intent.ACTION_GET_CONTENT;
    }
    Matcher<Intent> expectedIntent = allOf(hasAction(action), hasType("*/*"));
    Intent intent = new Intent();
    intent.setData(Uri.parse("file:///tmp/whatever.txt"));
    Instrumentation.ActivityResult result = new Instrumentation.ActivityResult(Activity.RESULT_OK, intent);
    intending(expectedIntent).respondWith(result);
    // attach fragment
    attachFragment(ConversationFragment.newInstance(), ConversationFragment.TAG);
    // verify stuff
    Thread.sleep(500);
    onView(withId(R.id.cursor_menu_item_more)).perform(click());
    Thread.sleep(500);
    onView(withId(R.id.cursor_menu_item_file)).perform(click());
    Thread.sleep(200);
    verify(mockConversationStore).sendMessage(any(AssetForUpload.class), any(MessageContent.Asset.ErrorHandler.class));
}
Also used : MessageContent(com.waz.api.MessageContent) IConversationStore(com.waz.zclient.core.stores.conversation.IConversationStore) Instrumentation(android.app.Instrumentation) AssetForUpload(com.waz.api.AssetForUpload) IConversation(com.waz.api.IConversation) Intent(android.content.Intent) FragmentTest(com.waz.zclient.testutils.FragmentTest) Test(org.junit.Test) SuppressLint(android.annotation.SuppressLint)

Example 8 with IConversation

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

the class ParticipantHeaderFragmentTest method assertUserDetailsIsVisibleInOneToOneConversation.

@Test
public void assertUserDetailsIsVisibleInOneToOneConversation() throws InterruptedException {
    IConversation mockConversation = mock(IConversation.class);
    when(mockConversation.getType()).thenReturn(IConversation.Type.ONE_TO_ONE);
    when(mockConversation.isMemberOfConversation()).thenReturn(true);
    User otherUser = MockHelper.createMockUser("James", "988");
    when(otherUser.getVerified()).thenReturn(Verification.UNVERIFIED);
    when(mockConversation.getOtherParticipant()).thenReturn(otherUser);
    MockHelper.setupParticipantsMocks(mockConversation, activity);
    attachFragment(ParticipantHeaderFragment.newInstance(IConnectStore.UserRequester.CONVERSATION), ParticipantHeaderFragment.TAG);
    Thread.sleep(400);
    onView(withId(R.id.udv__participants__user_details)).check(isVisible());
}
Also used : User(com.waz.api.User) IConversation(com.waz.api.IConversation) Test(org.junit.Test) FragmentTest(com.waz.zclient.testutils.FragmentTest)

Example 9 with IConversation

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

the class AudioRecordingTest method verifyLongPressingAudioMessageButtonShowsRecordingView.

@Test
public void verifyLongPressingAudioMessageButtonShowsRecordingView() throws InterruptedException {
    IConversation mockConversation = mock(IConversation.class);
    when(mockConversation.getType()).thenReturn(IConversation.Type.ONE_TO_ONE);
    when(mockConversation.isMemberOfConversation()).thenReturn(true);
    when(mockConversation.isActive()).thenReturn(true);
    MockHelper.setupConversationMocks(mockConversation, activity);
    attachFragment(ConversationFragment.newInstance(), ConversationFragment.TAG);
    onView(withId(R.id.cursor_menu_item_audio_message)).check(isVisible());
    onView(withId(R.id.cursor_menu_item_audio_message)).perform(ViewActions.longClick());
    onView(withId(R.id.amrv_audio_message_recording)).check(isVisible());
}
Also used : IConversation(com.waz.api.IConversation) Test(org.junit.Test) FragmentTest(com.waz.zclient.testutils.FragmentTest)

Example 10 with IConversation

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

the class ConversationFragmentTest method assertNoVideoCallButtonInGroupConversation.

@Test
public void assertNoVideoCallButtonInGroupConversation() throws InterruptedException {
    IConversation mockConversation = mock(IConversation.class);
    when(mockConversation.getType()).thenReturn(IConversation.Type.GROUP);
    when(mockConversation.isMemberOfConversation()).thenReturn(true);
    MockHelper.setupConversationMocks(mockConversation, activity);
    attachFragment(ConversationFragment.newInstance(), ConversationFragment.TAG);
    onView(withId(R.id.action_video_call)).check(CustomViewAssertions.isNull());
}
Also used : IConversation(com.waz.api.IConversation) FragmentTest(com.waz.zclient.testutils.FragmentTest) Test(org.junit.Test)

Aggregations

IConversation (com.waz.api.IConversation)69 FragmentTest (com.waz.zclient.testutils.FragmentTest)25 Test (org.junit.Test)25 GlobalTrackingController (com.waz.zclient.tracking.GlobalTrackingController)14 View (android.view.View)10 User (com.waz.api.User)9 ArrayList (java.util.ArrayList)6 SuppressLint (android.annotation.SuppressLint)5 Intent (android.content.Intent)4 Handler (android.os.Handler)4 AbsListView (android.widget.AbsListView)4 CreatedGroupConversationEvent (com.waz.zclient.controllers.tracking.events.group.CreatedGroupConversationEvent)4 FooterMenuCallback (com.waz.zclient.views.menus.FooterMenuCallback)4 Instrumentation (android.app.Instrumentation)3 TextView (android.widget.TextView)3 BaseScalaActivity (com.waz.zclient.BaseScalaActivity)3 AddedMemberToGroupEvent (com.waz.zclient.controllers.tracking.events.group.AddedMemberToGroupEvent)3 ExceptionHandler (net.hockeyapp.android.ExceptionHandler)3 Animator (android.animation.Animator)2 AnimatorSet (android.animation.AnimatorSet)2