mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-26 15:05:44 +03:00
Merge pull request #3310 from nextcloud/Utils_and_Webrtc
Added Instrumentation Test and Unit Tests
This commit is contained in:
commit
5eef4e7470
9 changed files with 422 additions and 4 deletions
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Samanwith KSN
|
||||
* Copyright (C) 2023 Samanwith KSN <samanwith21@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.talk.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.os.VibrationEffect
|
||||
import android.os.Vibrator
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.junit.MockitoJUnitRunner
|
||||
|
||||
@RunWith(MockitoJUnitRunner::class)
|
||||
class VibrationUtilsTest {
|
||||
|
||||
@Mock
|
||||
private lateinit var mockContext: Context
|
||||
|
||||
@Mock
|
||||
private lateinit var mockVibrator: Vibrator
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
Mockito.`when`(mockContext.getSystemService(Context.VIBRATOR_SERVICE)).thenReturn(mockVibrator)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testVibrateShort() {
|
||||
VibrationUtils.vibrateShort(mockContext)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
Mockito.verify(mockVibrator)
|
||||
.vibrate(
|
||||
VibrationEffect
|
||||
.createOneShot(
|
||||
VibrationUtils.SHORT_VIBRATE,
|
||||
VibrationEffect.DEFAULT_AMPLITUDE
|
||||
)
|
||||
)
|
||||
} else {
|
||||
Mockito.verify(mockVibrator).vibrate(VibrationUtils.SHORT_VIBRATE)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -25,7 +25,7 @@ import android.os.VibrationEffect
|
|||
import android.os.Vibrator
|
||||
|
||||
object VibrationUtils {
|
||||
private const val SHORT_VIBRATE: Long = 100
|
||||
const val SHORT_VIBRATE: Long = 100
|
||||
|
||||
fun vibrateShort(context: Context) {
|
||||
val vibrator = context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
|
||||
|
|
|
@ -31,7 +31,8 @@ import java.util.Set;
|
|||
*/
|
||||
public class DataChannelMessageNotifier {
|
||||
|
||||
private final Set<PeerConnectionWrapper.DataChannelMessageListener> dataChannelMessageListeners = new LinkedHashSet<>();
|
||||
public final Set<PeerConnectionWrapper.DataChannelMessageListener> dataChannelMessageListeners =
|
||||
new LinkedHashSet<>();
|
||||
|
||||
public synchronized void addListener(PeerConnectionWrapper.DataChannelMessageListener listener) {
|
||||
if (listener == null) {
|
||||
|
|
103
app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt
Normal file
103
app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt
Normal file
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Samanwith KSN
|
||||
* Copyright (C) 2023 Samanwith KSN <samanwith21@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.talk.utils
|
||||
|
||||
import com.nextcloud.talk.utils.bundle.BundleKeys
|
||||
import junit.framework.TestCase.assertEquals
|
||||
import org.junit.Test
|
||||
class BundleKeysTest {
|
||||
|
||||
@Test
|
||||
fun testBundleKeysValues() {
|
||||
assertEquals("KEY_SELECTED_USERS", BundleKeys.KEY_SELECTED_USERS)
|
||||
assertEquals("KEY_SELECTED_GROUPS", BundleKeys.KEY_SELECTED_GROUPS)
|
||||
assertEquals("KEY_SELECTED_CIRCLES", BundleKeys.KEY_SELECTED_CIRCLES)
|
||||
assertEquals("KEY_SELECTED_EMAILS", BundleKeys.KEY_SELECTED_EMAILS)
|
||||
assertEquals("KEY_USERNAME", BundleKeys.KEY_USERNAME)
|
||||
assertEquals("KEY_TOKEN", BundleKeys.KEY_TOKEN)
|
||||
assertEquals("KEY_TRANSLATE_MESSAGE", BundleKeys.KEY_TRANSLATE_MESSAGE)
|
||||
assertEquals("KEY_BASE_URL", BundleKeys.KEY_BASE_URL)
|
||||
assertEquals("KEY_IS_ACCOUNT_IMPORT", BundleKeys.KEY_IS_ACCOUNT_IMPORT)
|
||||
assertEquals("KEY_ORIGINAL_PROTOCOL", BundleKeys.KEY_ORIGINAL_PROTOCOL)
|
||||
assertEquals("KEY_OPERATION_CODE", BundleKeys.KEY_OPERATION_CODE)
|
||||
assertEquals("KEY_APP_ITEM_PACKAGE_NAME", BundleKeys.KEY_APP_ITEM_PACKAGE_NAME)
|
||||
assertEquals("KEY_APP_ITEM_NAME", BundleKeys.KEY_APP_ITEM_NAME)
|
||||
assertEquals("KEY_CONVERSATION_PASSWORD", BundleKeys.KEY_CONVERSATION_PASSWORD)
|
||||
assertEquals("KEY_ROOM_TOKEN", BundleKeys.KEY_ROOM_TOKEN)
|
||||
assertEquals("KEY_ROOM_ONE_TO_ONE", BundleKeys.KEY_ROOM_ONE_TO_ONE)
|
||||
assertEquals("KEY_NEW_CONVERSATION", BundleKeys.KEY_NEW_CONVERSATION)
|
||||
assertEquals("KEY_ADD_PARTICIPANTS", BundleKeys.KEY_ADD_PARTICIPANTS)
|
||||
assertEquals("KEY_EXISTING_PARTICIPANTS", BundleKeys.KEY_EXISTING_PARTICIPANTS)
|
||||
assertEquals("KEY_CALL_URL", BundleKeys.KEY_CALL_URL)
|
||||
assertEquals("KEY_NEW_ROOM_NAME", BundleKeys.KEY_NEW_ROOM_NAME)
|
||||
assertEquals("KEY_MODIFIED_BASE_URL", BundleKeys.KEY_MODIFIED_BASE_URL)
|
||||
assertEquals("KEY_NOTIFICATION_SUBJECT", BundleKeys.KEY_NOTIFICATION_SUBJECT)
|
||||
assertEquals("KEY_NOTIFICATION_SIGNATURE", BundleKeys.KEY_NOTIFICATION_SIGNATURE)
|
||||
assertEquals("KEY_INTERNAL_USER_ID", BundleKeys.KEY_INTERNAL_USER_ID)
|
||||
assertEquals("KEY_CONVERSATION_TYPE", BundleKeys.KEY_CONVERSATION_TYPE)
|
||||
assertEquals("KEY_INVITED_PARTICIPANTS", BundleKeys.KEY_INVITED_PARTICIPANTS)
|
||||
assertEquals("KEY_INVITED_CIRCLE", BundleKeys.KEY_INVITED_CIRCLE)
|
||||
assertEquals("KEY_INVITED_GROUP", BundleKeys.KEY_INVITED_GROUP)
|
||||
assertEquals("KEY_INVITED_EMAIL", BundleKeys.KEY_INVITED_EMAIL)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testBundleKeysValues2() {
|
||||
assertEquals("KEY_CONVERSATION_NAME", BundleKeys.KEY_CONVERSATION_NAME)
|
||||
assertEquals("KEY_RECORDING_STATE", BundleKeys.KEY_RECORDING_STATE)
|
||||
assertEquals("KEY_CALL_VOICE_ONLY", BundleKeys.KEY_CALL_VOICE_ONLY)
|
||||
assertEquals("KEY_CALL_WITHOUT_NOTIFICATION", BundleKeys.KEY_CALL_WITHOUT_NOTIFICATION)
|
||||
assertEquals("KEY_FROM_NOTIFICATION_START_CALL", BundleKeys.KEY_FROM_NOTIFICATION_START_CALL)
|
||||
assertEquals("KEY_ROOM_ID", BundleKeys.KEY_ROOM_ID)
|
||||
assertEquals("KEY_ARE_CALL_SOUNDS", BundleKeys.KEY_ARE_CALL_SOUNDS)
|
||||
assertEquals("KEY_FILE_PATHS", BundleKeys.KEY_FILE_PATHS)
|
||||
assertEquals("KEY_ACCOUNT", BundleKeys.KEY_ACCOUNT)
|
||||
assertEquals("KEY_FILE_ID", BundleKeys.KEY_FILE_ID)
|
||||
assertEquals("KEY_NOTIFICATION_ID", BundleKeys.KEY_NOTIFICATION_ID)
|
||||
assertEquals("KEY_NOTIFICATION_TIMESTAMP", BundleKeys.KEY_NOTIFICATION_TIMESTAMP)
|
||||
assertEquals("KEY_SHARED_TEXT", BundleKeys.KEY_SHARED_TEXT)
|
||||
assertEquals("KEY_GEOCODING_QUERY", BundleKeys.KEY_GEOCODING_QUERY)
|
||||
assertEquals("KEY_META_DATA", BundleKeys.KEY_META_DATA)
|
||||
assertEquals("KEY_FORWARD_MSG_FLAG", BundleKeys.KEY_FORWARD_MSG_FLAG)
|
||||
assertEquals("KEY_FORWARD_MSG_TEXT", BundleKeys.KEY_FORWARD_MSG_TEXT)
|
||||
assertEquals("KEY_FORWARD_HIDE_SOURCE_ROOM", BundleKeys.KEY_FORWARD_HIDE_SOURCE_ROOM)
|
||||
assertEquals("KEY_SYSTEM_NOTIFICATION_ID", BundleKeys.KEY_SYSTEM_NOTIFICATION_ID)
|
||||
assertEquals("KEY_MESSAGE_ID", BundleKeys.KEY_MESSAGE_ID)
|
||||
assertEquals("KEY_MIME_TYPE_FILTER", BundleKeys.KEY_MIME_TYPE_FILTER)
|
||||
assertEquals(
|
||||
"KEY_PARTICIPANT_PERMISSION_CAN_PUBLISH_AUDIO",
|
||||
BundleKeys.KEY_PARTICIPANT_PERMISSION_CAN_PUBLISH_AUDIO
|
||||
)
|
||||
assertEquals(
|
||||
"KEY_PARTICIPANT_PERMISSION_CAN_PUBLISH_VIDEO",
|
||||
BundleKeys.KEY_PARTICIPANT_PERMISSION_CAN_PUBLISH_VIDEO
|
||||
)
|
||||
assertEquals("KEY_IS_MODERATOR", BundleKeys.KEY_IS_MODERATOR)
|
||||
assertEquals("KEY_SWITCH_TO_ROOM", BundleKeys.KEY_SWITCH_TO_ROOM)
|
||||
assertEquals("KEY_START_CALL_AFTER_ROOM_SWITCH", BundleKeys.KEY_START_CALL_AFTER_ROOM_SWITCH)
|
||||
assertEquals("KEY_IS_BREAKOUT_ROOM", BundleKeys.KEY_IS_BREAKOUT_ROOM)
|
||||
assertEquals("KEY_NOTIFICATION_RESTRICT_DELETION", BundleKeys.KEY_NOTIFICATION_RESTRICT_DELETION)
|
||||
assertEquals("KEY_DISMISS_RECORDING_URL", BundleKeys.KEY_DISMISS_RECORDING_URL)
|
||||
assertEquals("KEY_SHARE_RECORDING_TO_CHAT_URL", BundleKeys.KEY_SHARE_RECORDING_TO_CHAT_URL)
|
||||
assertEquals("KEY_GEOCODING_RESULT", BundleKeys.KEY_GEOCODING_RESULT)
|
||||
assertEquals("ADD_ACCOUNT", BundleKeys.ADD_ACCOUNT)
|
||||
assertEquals("SAVED_TRANSLATED_MESSAGE", BundleKeys.SAVED_TRANSLATED_MESSAGE)
|
||||
}
|
||||
}
|
41
app/src/test/java/com/nextcloud/talk/utils/UriUtilsTest.kt
Normal file
41
app/src/test/java/com/nextcloud/talk/utils/UriUtilsTest.kt
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Samanwith KSN
|
||||
* Copyright (C) 2023 Samanwith KSN <samanwith21@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.talk.utils
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
class UriUtilsTest {
|
||||
|
||||
@Test
|
||||
fun testHasHttpProtocolPrefixed() {
|
||||
val uriHttp = "http://www.example.com"
|
||||
val resultHttp = UriUtils.hasHttpProtocollPrefixed(uriHttp)
|
||||
Assert.assertTrue(resultHttp)
|
||||
|
||||
val uriHttps = "https://www.example.com"
|
||||
val resultHttps = UriUtils.hasHttpProtocollPrefixed(uriHttps)
|
||||
Assert.assertTrue(resultHttps)
|
||||
|
||||
val uriWithoutPrefix = "www.example.com"
|
||||
val resultWithoutPrefix = UriUtils.hasHttpProtocollPrefixed(uriWithoutPrefix)
|
||||
Assert.assertFalse(resultWithoutPrefix)
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Mario Danic
|
||||
* @author Marcel Hibbe
|
||||
* @author Samanwith KSN
|
||||
* Copyright (C) 2023 Marcel Hibbe <dev@mhibbe.de>
|
||||
* Copyright (C) 2017-2018 Mario Danic <mario@lovelyhq.com>
|
||||
* Copyright (C) 2023 Samanwith KSN <samanwith21@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Samanwith KSN
|
||||
* Copyright (C) 2023 Samanwith KSN <samanwith21@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.talk.webrtc
|
||||
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.mockito.Mockito.mock
|
||||
import org.mockito.Mockito.verify
|
||||
|
||||
class DataChannelMessageNotifierTest {
|
||||
|
||||
private lateinit var notifier: DataChannelMessageNotifier
|
||||
private lateinit var listener: PeerConnectionWrapper.DataChannelMessageListener
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
notifier = DataChannelMessageNotifier()
|
||||
listener = mock(PeerConnectionWrapper.DataChannelMessageListener::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAddListener() {
|
||||
notifier.addListener(listener)
|
||||
assertTrue(notifier.dataChannelMessageListeners.contains(listener))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRemoveListener() {
|
||||
notifier.addListener(listener)
|
||||
notifier.removeListener(listener)
|
||||
assertFalse(notifier.dataChannelMessageListeners.contains(listener))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNotifyAudioOn() {
|
||||
notifier.addListener(listener)
|
||||
notifier.notifyAudioOn()
|
||||
verify(listener).onAudioOn()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNotifyAudioOff() {
|
||||
notifier.addListener(listener)
|
||||
notifier.notifyAudioOff()
|
||||
verify(listener).onAudioOff()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNotifyVideoOn() {
|
||||
notifier.addListener(listener)
|
||||
notifier.notifyVideoOn()
|
||||
verify(listener).onVideoOn()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNotifyVideoOff() {
|
||||
notifier.addListener(listener)
|
||||
notifier.notifyVideoOff()
|
||||
verify(listener).onVideoOff()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNotifyNickChanged() {
|
||||
notifier.addListener(listener)
|
||||
val newNick = "NewNick"
|
||||
notifier.notifyNickChanged(newNick)
|
||||
verify(listener).onNickChanged(newNick)
|
||||
}
|
||||
}
|
40
app/src/test/java/com/nextcloud/talk/webrtc/GlobalsTest.kt
Normal file
40
app/src/test/java/com/nextcloud/talk/webrtc/GlobalsTest.kt
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Samanwith KSN
|
||||
* Copyright (C) 2023 Samanwith KSN <samanwith21@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.talk.webrtc
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
|
||||
class GlobalsTest {
|
||||
@Test
|
||||
fun testRoomToken() {
|
||||
Assert.assertEquals("roomToken", Globals.ROOM_TOKEN)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testTargetParticipants() {
|
||||
Assert.assertEquals("participants", Globals.TARGET_PARTICIPANTS)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testTargetRoom() {
|
||||
Assert.assertEquals("room", Globals.TARGET_ROOM)
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* Nextcloud Talk application
|
||||
*
|
||||
* @author Samanwith KSN
|
||||
* Copyright (C) 2023 Samanwith KSN <samanwith21@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.talk.webrtc
|
||||
|
||||
import com.nextcloud.talk.webrtc.PeerConnectionWrapper.PeerConnectionObserver
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.mockito.Mockito
|
||||
import org.webrtc.MediaStream
|
||||
import org.webrtc.PeerConnection
|
||||
|
||||
class PeerConnectionNotifierTest {
|
||||
private var notifier: PeerConnectionNotifier? = null
|
||||
private var observer1: PeerConnectionObserver? = null
|
||||
private var observer2: PeerConnectionObserver? = null
|
||||
private var mockStream: MediaStream? = null
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
notifier = PeerConnectionNotifier()
|
||||
observer1 = Mockito.mock(PeerConnectionObserver::class.java)
|
||||
observer2 = Mockito.mock(PeerConnectionObserver::class.java)
|
||||
mockStream = Mockito.mock(MediaStream::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAddObserver() {
|
||||
notifier!!.addObserver(observer1)
|
||||
notifier!!.notifyStreamAdded(mockStream)
|
||||
Mockito.verify(observer1)?.onStreamAdded(mockStream)
|
||||
Mockito.verify(observer2, Mockito.never())?.onStreamAdded(mockStream)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRemoveObserver() {
|
||||
notifier!!.addObserver(observer1)
|
||||
notifier!!.addObserver(observer2)
|
||||
notifier!!.removeObserver(observer1)
|
||||
notifier!!.notifyStreamAdded(mockStream)
|
||||
Mockito.verify(observer1, Mockito.never())?.onStreamAdded(mockStream)
|
||||
Mockito.verify(observer2)?.onStreamAdded(mockStream)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNotifyStreamAdded() {
|
||||
notifier!!.addObserver(observer1)
|
||||
notifier!!.notifyStreamAdded(mockStream)
|
||||
Mockito.verify(observer1)?.onStreamAdded(mockStream)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNotifyStreamRemoved() {
|
||||
notifier!!.addObserver(observer1)
|
||||
notifier!!.notifyStreamRemoved(mockStream)
|
||||
Mockito.verify(observer1)?.onStreamRemoved(mockStream)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNotifyIceConnectionStateChanged() {
|
||||
notifier!!.addObserver(observer1)
|
||||
notifier!!.notifyIceConnectionStateChanged(PeerConnection.IceConnectionState.CONNECTED)
|
||||
Mockito.verify(observer1)?.onIceConnectionStateChanged(PeerConnection.IceConnectionState.CONNECTED)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue