ParticipantPermissionsTest.kt 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * Nextcloud Talk application
  3. *
  4. * @author Marcel Hibbe
  5. * @author Tim Krüger
  6. * Copyright (C) 2022 Tim Krüger <t@timkrueger.me>
  7. * Copyright (C) 2022 Marcel Hibbe <dev@mhibbe.de>
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. */
  22. package com.nextcloud.talk.utils
  23. import com.nextcloud.talk.data.user.model.User
  24. import com.nextcloud.talk.models.json.conversations.Conversation
  25. import junit.framework.TestCase
  26. import org.junit.Test
  27. class ParticipantPermissionsTest : TestCase() {
  28. @Test
  29. fun test_areFlagsSet() {
  30. val user = User()
  31. val conversation = Conversation()
  32. conversation.permissions = ParticipantPermissions.PUBLISH_SCREEN or
  33. ParticipantPermissions.JOIN_CALL or
  34. ParticipantPermissions.DEFAULT
  35. val attendeePermissions =
  36. ParticipantPermissions(
  37. user,
  38. conversation
  39. )
  40. assert(attendeePermissions.canPublishScreen)
  41. assert(attendeePermissions.canJoinCall)
  42. assert(attendeePermissions.isDefault)
  43. assertFalse(attendeePermissions.isCustom)
  44. assertFalse(attendeePermissions.canStartCall())
  45. assertFalse(attendeePermissions.canIgnoreLobby())
  46. assertTrue(attendeePermissions.canPublishAudio())
  47. assertTrue(attendeePermissions.canPublishVideo())
  48. }
  49. }