diff --git a/app/src/main/java/com/nextcloud/talk/call/CallParticipantModelNotifier.java b/app/src/main/java/com/nextcloud/talk/call/CallParticipantModelNotifier.java index e0b6904fc..8452a157c 100644 --- a/app/src/main/java/com/nextcloud/talk/call/CallParticipantModelNotifier.java +++ b/app/src/main/java/com/nextcloud/talk/call/CallParticipantModelNotifier.java @@ -28,12 +28,14 @@ import java.util.List; /** * Helper class to register and notify CallParticipantModel.Observers. - * + *

* This class is only meant for internal use by CallParticipantModel; observers must register themselves against a * CallParticipantModel rather than against a CallParticipantModelNotifier. */ class CallParticipantModelNotifier { + private final List callParticipantModelObserversOn = new ArrayList<>(); + /** * Helper class to associate a CallParticipantModel.Observer with a Handler. */ @@ -47,8 +49,6 @@ class CallParticipantModelNotifier { } } - private final List callParticipantModelObserversOn = new ArrayList<>(); - public synchronized void addObserver(CallParticipantModel.Observer observer, Handler handler) { if (observer == null) { throw new IllegalArgumentException("CallParticipantModel.Observer can not be null"); diff --git a/app/src/main/java/com/nextcloud/talk/signaling/CallParticipantMessageNotifier.java b/app/src/main/java/com/nextcloud/talk/signaling/CallParticipantMessageNotifier.java index 07679304b..3f28dce50 100644 --- a/app/src/main/java/com/nextcloud/talk/signaling/CallParticipantMessageNotifier.java +++ b/app/src/main/java/com/nextcloud/talk/signaling/CallParticipantMessageNotifier.java @@ -25,12 +25,14 @@ import java.util.List; /** * Helper class to register and notify CallParticipantMessageListeners. - * + *

* This class is only meant for internal use by SignalingMessageReceiver; listeners must register themselves against * a SignalingMessageReceiver rather than against a CallParticipantMessageNotifier. */ class CallParticipantMessageNotifier { + private final List callParticipantMessageListenersFrom = new ArrayList<>(); + /** * Helper class to associate a CallParticipantMessageListener with a session ID. */ @@ -45,8 +47,6 @@ class CallParticipantMessageNotifier { } } - private final List callParticipantMessageListenersFrom = new ArrayList<>(); - public synchronized void addListener(SignalingMessageReceiver.CallParticipantMessageListener listener, String sessionId) { if (listener == null) { throw new IllegalArgumentException("CallParticipantMessageListener can not be null"); diff --git a/app/src/main/java/com/nextcloud/talk/signaling/WebRtcMessageNotifier.java b/app/src/main/java/com/nextcloud/talk/signaling/WebRtcMessageNotifier.java index 9dbe6cb38..6e9ce3c22 100644 --- a/app/src/main/java/com/nextcloud/talk/signaling/WebRtcMessageNotifier.java +++ b/app/src/main/java/com/nextcloud/talk/signaling/WebRtcMessageNotifier.java @@ -25,12 +25,14 @@ import java.util.List; /** * Helper class to register and notify WebRtcMessageListeners. - * + *

* This class is only meant for internal use by SignalingMessageReceiver; listeners must register themselves against * a SignalingMessageReceiver rather than against a WebRtcMessageNotifier. */ class WebRtcMessageNotifier { + private final List webRtcMessageListenersFrom = new ArrayList<>(); + /** * Helper class to associate a WebRtcMessageListener with a session ID and room type. */ @@ -48,8 +50,6 @@ class WebRtcMessageNotifier { } } - private final List webRtcMessageListenersFrom = new ArrayList<>(); - public synchronized void addListener(SignalingMessageReceiver.WebRtcMessageListener listener, String sessionId, String roomType) { if (listener == null) { throw new IllegalArgumentException("WebRtcMessageListener can not be null"); diff --git a/app/src/test/java/com/nextcloud/talk/call/CallParticipantListExternalSignalingTest.java b/app/src/test/java/com/nextcloud/talk/call/CallParticipantListExternalSignalingTest.java index 51cfabd44..ba4c95f10 100644 --- a/app/src/test/java/com/nextcloud/talk/call/CallParticipantListExternalSignalingTest.java +++ b/app/src/test/java/com/nextcloud/talk/call/CallParticipantListExternalSignalingTest.java @@ -66,6 +66,15 @@ public class CallParticipantListExternalSignalingTest { private Collection expectedLeft; private Collection expectedUnchanged; + // The order of the left participants in some tests depends on how they are internally sorted by the map, so the + // list of left participants needs to be checked ignoring the sorting (or, rather, sorting by session ID as in + // expectedLeft). + // Other tests can just relay on the not guaranteed, but known internal sorting of the elements. + private final ArgumentMatcher> matchesExpectedLeftIgnoringOrder = left -> { + Collections.sort(left, Comparator.comparing(Participant::getSessionId)); + return expectedLeft.equals(left); + }; + private static class ParticipantsUpdateParticipantBuilder { private Participant newUser(long inCall, long lastPing, String sessionId, Participant.ParticipantType type, String userId) { @@ -90,15 +99,6 @@ public class CallParticipantListExternalSignalingTest { } } - // The order of the left participants in some tests depends on how they are internally sorted by the map, so the - // list of left participants needs to be checked ignoring the sorting (or, rather, sorting by session ID as in - // expectedLeft). - // Other tests can just relay on the not guaranteed, but known internal sorting of the elements. - private final ArgumentMatcher> matchesExpectedLeftIgnoringOrder = left -> { - Collections.sort(left, Comparator.comparing(Participant::getSessionId)); - return expectedLeft.equals(left); - }; - @Before public void setUp() { SignalingMessageReceiver mockedSignalingMessageReceiver = mock(SignalingMessageReceiver.class); diff --git a/app/src/test/java/com/nextcloud/talk/call/CallParticipantListInternalSignalingTest.java b/app/src/test/java/com/nextcloud/talk/call/CallParticipantListInternalSignalingTest.java index c0198fc0a..15403ecf8 100644 --- a/app/src/test/java/com/nextcloud/talk/call/CallParticipantListInternalSignalingTest.java +++ b/app/src/test/java/com/nextcloud/talk/call/CallParticipantListInternalSignalingTest.java @@ -58,6 +58,15 @@ public class CallParticipantListInternalSignalingTest { private Collection expectedLeft; private Collection expectedUnchanged; + // The order of the left participants in some tests depends on how they are internally sorted by the map, so the + // list of left participants needs to be checked ignoring the sorting (or, rather, sorting by session ID as in + // expectedLeft). + // Other tests can just relay on the not guaranteed, but known internal sorting of the elements. + private final ArgumentMatcher> matchesExpectedLeftIgnoringOrder = left -> { + Collections.sort(left, Comparator.comparing(Participant::getSessionId)); + return expectedLeft.equals(left); + }; + private static class UsersInRoomParticipantBuilder { private Participant newUser(long inCall, long lastPing, String sessionId, String userId) { Participant participant = new Participant(); @@ -79,15 +88,6 @@ public class CallParticipantListInternalSignalingTest { } } - // The order of the left participants in some tests depends on how they are internally sorted by the map, so the - // list of left participants needs to be checked ignoring the sorting (or, rather, sorting by session ID as in - // expectedLeft). - // Other tests can just relay on the not guaranteed, but known internal sorting of the elements. - private final ArgumentMatcher> matchesExpectedLeftIgnoringOrder = left -> { - Collections.sort(left, Comparator.comparing(Participant::getSessionId)); - return expectedLeft.equals(left); - }; - @Before public void setUp() { SignalingMessageReceiver mockedSignalingMessageReceiver = mock(SignalingMessageReceiver.class); @@ -529,7 +529,9 @@ public class CallParticipantListInternalSignalingTest { // Last ping is not seen as changed, even if it did. expectedUnchanged.add(builder.newUser(IN_CALL | WITH_AUDIO, 42, "theSessionId9", "theUserId9")); - verify(mockedCallParticipantListObserver).onCallParticipantsChanged(eq(expectedJoined), eq(expectedUpdated), - argThat(matchesExpectedLeftIgnoringOrder), eq(expectedUnchanged)); + verify(mockedCallParticipantListObserver).onCallParticipantsChanged(eq(expectedJoined), + eq(expectedUpdated), + argThat(matchesExpectedLeftIgnoringOrder), + eq(expectedUnchanged)); } }