Search in sources :

Example 1 with UpdateListener

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

the class MockHelper method setupParticipantsMocks.

public static void setupParticipantsMocks(final IConversation mockConversation, final TestActivity activity) {
    IParticipantsStore mockParticipantsStore = activity.getStoreFactory().getParticipantsStore();
    doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocation) {
            Object[] args = invocation.getArguments();
            UpdateListener u = (UpdateListener) args[0];
            u.updated();
            return null;
        }
    }).when(mockConversation).addUpdateListener(any(UpdateListener.class));
    doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocation) {
            Object[] args = invocation.getArguments();
            ParticipantsStoreObserver o = (ParticipantsStoreObserver) args[0];
            o.conversationUpdated(mockConversation);
            return null;
        }
    }).when(mockParticipantsStore).addParticipantsStoreObserver(any(ParticipantsStoreObserver.class));
    INetworkStore mockNetworkStore = activity.getStoreFactory().getNetworkStore();
    when(mockNetworkStore.hasInternetConnection()).thenReturn(true);
    doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocation) {
            Object[] args = invocation.getArguments();
            NetworkAction a = (NetworkAction) args[0];
            a.execute(NetworkMode.WIFI);
            return null;
        }
    }).when(mockNetworkStore).doIfHasInternetOrNotifyUser(any(NetworkAction.class));
}
Also used : ParticipantsStoreObserver(com.waz.zclient.core.stores.participants.ParticipantsStoreObserver) InvocationOnMock(org.mockito.invocation.InvocationOnMock) IParticipantsStore(com.waz.zclient.core.stores.participants.IParticipantsStore) INetworkStore(com.waz.zclient.core.stores.network.INetworkStore) UpdateListener(com.waz.api.UpdateListener) NetworkAction(com.waz.zclient.core.stores.network.NetworkAction)

Example 2 with UpdateListener

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

the class InboxLinkConversation method updated.

@Override
public void updated() {
    if (incomingConversations.size() > 0) {
        indicatorConversation = incomingConversations.get(0);
        indicatorConversation.addUpdateListener(this);
        for (UpdateListener updateListener : updateListeners) {
            updateListener.updated();
        }
    }
}
Also used : UpdateListener(com.waz.api.UpdateListener)

Example 3 with UpdateListener

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

the class MockHelper method setupConversationMocks.

public static void setupConversationMocks(final IConversation mockConversation, final TestActivity activity) {
    IConversationStore mockConversationStore = activity.getStoreFactory().getConversationStore();
    when(mockConversationStore.getCurrentConversation()).thenReturn(mockConversation);
    doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocation) {
            Object[] args = invocation.getArguments();
            UpdateListener u = (UpdateListener) args[0];
            u.updated();
            return null;
        }
    }).when(mockConversation).addUpdateListener(any(UpdateListener.class));
    doAnswer(new Answer<Void>() {

        @Override
        public Void answer(InvocationOnMock invocation) {
            Object[] args = invocation.getArguments();
            ConversationStoreObserver o = (ConversationStoreObserver) args[0];
            o.onCurrentConversationHasChanged(null, mockConversation, ConversationChangeRequester.UPDATER);
            return null;
        }
    }).when(mockConversationStore).addConversationStoreObserverAndUpdate(any(ConversationStoreObserver.class));
    doAnswer(new Answer<Void>() {

        public Void answer(InvocationOnMock invocation) {
            Object[] args = invocation.getArguments();
            ConversationStoreObserver o = (ConversationStoreObserver) args[0];
            o.onCurrentConversationHasChanged(null, mockConversation, ConversationChangeRequester.UPDATER);
            return null;
        }
    }).when(mockConversationStore).addConversationStoreObserver(any(ConversationStoreObserver.class));
}
Also used : ConversationStoreObserver(com.waz.zclient.core.stores.conversation.ConversationStoreObserver) InvocationOnMock(org.mockito.invocation.InvocationOnMock) IConversationStore(com.waz.zclient.core.stores.conversation.IConversationStore) UpdateListener(com.waz.api.UpdateListener)

Aggregations

UpdateListener (com.waz.api.UpdateListener)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 ConversationStoreObserver (com.waz.zclient.core.stores.conversation.ConversationStoreObserver)1 IConversationStore (com.waz.zclient.core.stores.conversation.IConversationStore)1 INetworkStore (com.waz.zclient.core.stores.network.INetworkStore)1 NetworkAction (com.waz.zclient.core.stores.network.NetworkAction)1 IParticipantsStore (com.waz.zclient.core.stores.participants.IParticipantsStore)1 ParticipantsStoreObserver (com.waz.zclient.core.stores.participants.ParticipantsStoreObserver)1