CallParticipantModelTest.java 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Nextcloud Talk application
  3. *
  4. * @author Daniel Calviño Sánchez
  5. * Copyright (C) 2022 Daniel Calviño Sánchez <danxuliu@gmail.com>
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. package com.nextcloud.talk.call;
  21. import org.junit.Before;
  22. import org.junit.Test;
  23. import static org.mockito.Mockito.mock;
  24. import static org.mockito.Mockito.only;
  25. import static org.mockito.Mockito.times;
  26. import static org.mockito.Mockito.verify;
  27. public class CallParticipantModelTest {
  28. private MutableCallParticipantModel callParticipantModel;
  29. private CallParticipantModel.Observer mockedCallParticipantModelObserver;
  30. @Before
  31. public void setUp() {
  32. callParticipantModel = new MutableCallParticipantModel("theSessionId");
  33. mockedCallParticipantModelObserver = mock(CallParticipantModel.Observer.class);
  34. }
  35. @Test
  36. public void testSetRaisedHand() {
  37. callParticipantModel.addObserver(mockedCallParticipantModelObserver);
  38. callParticipantModel.setRaisedHand(true, 4815162342L);
  39. verify(mockedCallParticipantModelObserver, only()).onChange();
  40. }
  41. @Test
  42. public void testSetRaisedHandTwice() {
  43. callParticipantModel.addObserver(mockedCallParticipantModelObserver);
  44. callParticipantModel.setRaisedHand(true, 4815162342L);
  45. callParticipantModel.setRaisedHand(false, 4815162342108L);
  46. verify(mockedCallParticipantModelObserver, times(2)).onChange();
  47. }
  48. @Test
  49. public void testSetRaisedHandTwiceWithSameValue() {
  50. callParticipantModel.addObserver(mockedCallParticipantModelObserver);
  51. callParticipantModel.setRaisedHand(true, 4815162342L);
  52. callParticipantModel.setRaisedHand(true, 4815162342L);
  53. verify(mockedCallParticipantModelObserver, only()).onChange();
  54. }
  55. }