From e5debca7c13447667c2118861f02d2736ba6d235 Mon Sep 17 00:00:00 2001 From: Smarshal21 Date: Sun, 10 Sep 2023 04:32:02 +0530 Subject: [PATCH 1/5] Added Instrumentation Test and Unit Tests --- .../talk/utils/VibrationUtilsTest.kt | 56 +++++++++++ .../nextcloud/talk/utils/VibrationUtils.kt | 2 +- .../webrtc/DataChannelMessageNotifier.java | 3 +- .../nextcloud/talk/utils/BundleKeysTest.kt | 95 +++++++++++++++++++ .../com/nextcloud/talk/utils/UriUtilsTest.kt | 42 ++++++++ .../webrtc/DataChannelMessageNotifierTest.kt | 87 +++++++++++++++++ .../com/nextcloud/talk/webrtc/GlobalsTest.kt | 40 ++++++++ .../talk/webrtc/PeerConnectionNotifierTest.kt | 80 ++++++++++++++++ 8 files changed, 403 insertions(+), 2 deletions(-) create mode 100644 app/src/androidTest/java/com/nextcloud/talk/utils/VibrationUtilsTest.kt create mode 100644 app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt create mode 100644 app/src/test/java/com/nextcloud/talk/utils/UriUtilsTest.kt create mode 100644 app/src/test/java/com/nextcloud/talk/webrtc/DataChannelMessageNotifierTest.kt create mode 100644 app/src/test/java/com/nextcloud/talk/webrtc/GlobalsTest.kt create mode 100644 app/src/test/java/com/nextcloud/talk/webrtc/PeerConnectionNotifierTest.kt diff --git a/app/src/androidTest/java/com/nextcloud/talk/utils/VibrationUtilsTest.kt b/app/src/androidTest/java/com/nextcloud/talk/utils/VibrationUtilsTest.kt new file mode 100644 index 0000000000..a583428220 --- /dev/null +++ b/app/src/androidTest/java/com/nextcloud/talk/utils/VibrationUtilsTest.kt @@ -0,0 +1,56 @@ +/* + * Nextcloud Talk application + * + * @author Mario Danic + * Copyright (C) 2017-2019 Mario Danic + * + * 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 . + */ +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) + } + } +} diff --git a/app/src/main/java/com/nextcloud/talk/utils/VibrationUtils.kt b/app/src/main/java/com/nextcloud/talk/utils/VibrationUtils.kt index 4f2c2254c1..58f2b68fe9 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/VibrationUtils.kt +++ b/app/src/main/java/com/nextcloud/talk/utils/VibrationUtils.kt @@ -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 diff --git a/app/src/main/java/com/nextcloud/talk/webrtc/DataChannelMessageNotifier.java b/app/src/main/java/com/nextcloud/talk/webrtc/DataChannelMessageNotifier.java index c949cc39f9..9731bfc842 100644 --- a/app/src/main/java/com/nextcloud/talk/webrtc/DataChannelMessageNotifier.java +++ b/app/src/main/java/com/nextcloud/talk/webrtc/DataChannelMessageNotifier.java @@ -31,7 +31,8 @@ */ public class DataChannelMessageNotifier { - private final Set dataChannelMessageListeners = new LinkedHashSet<>(); + public final Set dataChannelMessageListeners = + new LinkedHashSet<>(); public synchronized void addListener(PeerConnectionWrapper.DataChannelMessageListener listener) { if (listener == null) { diff --git a/app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt b/app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt new file mode 100644 index 0000000000..c75842c22f --- /dev/null +++ b/app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt @@ -0,0 +1,95 @@ +/* + * Nextcloud Talk application + * + * @author Mario Danic + * Copyright (C) 2017-2019 Mario Danic + * + * 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 . + */ +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) + 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) + } +} diff --git a/app/src/test/java/com/nextcloud/talk/utils/UriUtilsTest.kt b/app/src/test/java/com/nextcloud/talk/utils/UriUtilsTest.kt new file mode 100644 index 0000000000..4a9551d91e --- /dev/null +++ b/app/src/test/java/com/nextcloud/talk/utils/UriUtilsTest.kt @@ -0,0 +1,42 @@ +/* + * Nextcloud Talk application + * + * @author Mario Danic + * Copyright (C) 2017-2019 Mario Danic + * + * 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 . + */ +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) + } +} diff --git a/app/src/test/java/com/nextcloud/talk/webrtc/DataChannelMessageNotifierTest.kt b/app/src/test/java/com/nextcloud/talk/webrtc/DataChannelMessageNotifierTest.kt new file mode 100644 index 0000000000..555ccbd690 --- /dev/null +++ b/app/src/test/java/com/nextcloud/talk/webrtc/DataChannelMessageNotifierTest.kt @@ -0,0 +1,87 @@ +/* + * Nextcloud Talk application + * + * @author Mario Danic + * Copyright (C) 2017-2019 Mario Danic + * + * 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 . + */ +package com.nextcloud.talk.webrtc + +import org.junit.Before +import org.junit.Test +import org.mockito.Mockito.* + +import org.junit.Assert.* + +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) + } +} diff --git a/app/src/test/java/com/nextcloud/talk/webrtc/GlobalsTest.kt b/app/src/test/java/com/nextcloud/talk/webrtc/GlobalsTest.kt new file mode 100644 index 0000000000..c0c737f512 --- /dev/null +++ b/app/src/test/java/com/nextcloud/talk/webrtc/GlobalsTest.kt @@ -0,0 +1,40 @@ +/* + * Nextcloud Talk application + * + * @author Mario Danic + * Copyright (C) 2017-2019 Mario Danic + * + * 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 . + */ +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) + } +} diff --git a/app/src/test/java/com/nextcloud/talk/webrtc/PeerConnectionNotifierTest.kt b/app/src/test/java/com/nextcloud/talk/webrtc/PeerConnectionNotifierTest.kt new file mode 100644 index 0000000000..a1373709bb --- /dev/null +++ b/app/src/test/java/com/nextcloud/talk/webrtc/PeerConnectionNotifierTest.kt @@ -0,0 +1,80 @@ +/* + * Nextcloud Talk application + * + * @author Mario Danic + * Copyright (C) 2017-2019 Mario Danic + * + * 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 . + */ +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) + } +} From 38081a523db8c8b6f264c8d44b0077ac4ef56d90 Mon Sep 17 00:00:00 2001 From: Smarshal21 Date: Sun, 10 Sep 2023 14:10:30 +0530 Subject: [PATCH 2/5] Fixed Codacy Lint Warnings --- .../com/nextcloud/talk/utils/VibrationUtilsTest.kt | 10 +++++++++- .../java/com/nextcloud/talk/utils/BundleKeysTest.kt | 11 +++++++---- .../talk/webrtc/DataChannelMessageNotifierTest.kt | 7 ++++--- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/app/src/androidTest/java/com/nextcloud/talk/utils/VibrationUtilsTest.kt b/app/src/androidTest/java/com/nextcloud/talk/utils/VibrationUtilsTest.kt index a583428220..5b4bebd3d5 100644 --- a/app/src/androidTest/java/com/nextcloud/talk/utils/VibrationUtilsTest.kt +++ b/app/src/androidTest/java/com/nextcloud/talk/utils/VibrationUtilsTest.kt @@ -18,6 +18,7 @@ * along with this program. If not, see . */ package com.nextcloud.talk.utils + import android.content.Context import android.os.Build import android.os.VibrationEffect @@ -48,7 +49,14 @@ class VibrationUtilsTest { VibrationUtils.vibrateShort(mockContext) if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - Mockito.verify(mockVibrator).vibrate(VibrationEffect.createOneShot(VibrationUtils.SHORT_VIBRATE, VibrationEffect.DEFAULT_AMPLITUDE)) + Mockito.verify(mockVibrator) + .vibrate( + VibrationEffect + .createOneShot( + VibrationUtils.SHORT_VIBRATE, + VibrationEffect.DEFAULT_AMPLITUDE + ) + ) } else { Mockito.verify(mockVibrator).vibrate(VibrationUtils.SHORT_VIBRATE) } diff --git a/app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt b/app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt index c75842c22f..fd6cec2ec7 100644 --- a/app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt +++ b/app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt @@ -22,8 +22,6 @@ package com.nextcloud.talk.utils import com.nextcloud.talk.utils.bundle.BundleKeys import junit.framework.TestCase.assertEquals import org.junit.Test - - class BundleKeysTest { @Test @@ -58,6 +56,9 @@ class BundleKeysTest { 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) @@ -79,8 +80,10 @@ class BundleKeysTest { 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_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) diff --git a/app/src/test/java/com/nextcloud/talk/webrtc/DataChannelMessageNotifierTest.kt b/app/src/test/java/com/nextcloud/talk/webrtc/DataChannelMessageNotifierTest.kt index 555ccbd690..baceb341da 100644 --- a/app/src/test/java/com/nextcloud/talk/webrtc/DataChannelMessageNotifierTest.kt +++ b/app/src/test/java/com/nextcloud/talk/webrtc/DataChannelMessageNotifierTest.kt @@ -19,11 +19,12 @@ */ 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.* - -import org.junit.Assert.* +import org.mockito.Mockito.mock +import org.mockito.Mockito.verify class DataChannelMessageNotifierTest { From b307add657057dda62c5c71cd89405f066cdd75c Mon Sep 17 00:00:00 2001 From: Smarshal21 Date: Mon, 11 Sep 2023 15:35:50 +0530 Subject: [PATCH 3/5] Fixed Codacy Static Code Warnings --- app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt b/app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt index fd6cec2ec7..0f8eb6352a 100644 --- a/app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt +++ b/app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt @@ -58,7 +58,7 @@ class BundleKeysTest { assertEquals("KEY_INVITED_EMAIL", BundleKeys.KEY_INVITED_EMAIL) } @Test - fun testBundleKeysValues2(){ + 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) From 8913b0fc62ee26f3a43f85511995268ccf268d66 Mon Sep 17 00:00:00 2001 From: Smarshal21 Date: Tue, 12 Sep 2023 14:22:28 +0530 Subject: [PATCH 4/5] updated the author in the copyright headers --- .../java/com/nextcloud/talk/utils/VibrationUtilsTest.kt | 4 ++-- app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt | 4 ++-- app/src/test/java/com/nextcloud/talk/utils/UriUtilsTest.kt | 4 ++-- app/src/test/java/com/nextcloud/talk/utils/UserIdUtilsTest.kt | 4 ++-- .../nextcloud/talk/webrtc/DataChannelMessageNotifierTest.kt | 4 ++-- app/src/test/java/com/nextcloud/talk/webrtc/GlobalsTest.kt | 4 ++-- .../com/nextcloud/talk/webrtc/PeerConnectionNotifierTest.kt | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/app/src/androidTest/java/com/nextcloud/talk/utils/VibrationUtilsTest.kt b/app/src/androidTest/java/com/nextcloud/talk/utils/VibrationUtilsTest.kt index 5b4bebd3d5..02f5e2ed5b 100644 --- a/app/src/androidTest/java/com/nextcloud/talk/utils/VibrationUtilsTest.kt +++ b/app/src/androidTest/java/com/nextcloud/talk/utils/VibrationUtilsTest.kt @@ -1,8 +1,8 @@ /* * Nextcloud Talk application * - * @author Mario Danic - * Copyright (C) 2017-2019 Mario Danic + * @author Samanwith KSN + * Copyright (C) 2023 Samanwith KSN * * 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 diff --git a/app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt b/app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt index 0f8eb6352a..1ee7028924 100644 --- a/app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt +++ b/app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt @@ -1,8 +1,8 @@ /* * Nextcloud Talk application * - * @author Mario Danic - * Copyright (C) 2017-2019 Mario Danic + * @author Samanwith KSN + * Copyright (C) 2023 Samanwith KSN * * 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 diff --git a/app/src/test/java/com/nextcloud/talk/utils/UriUtilsTest.kt b/app/src/test/java/com/nextcloud/talk/utils/UriUtilsTest.kt index 4a9551d91e..6c27e062f6 100644 --- a/app/src/test/java/com/nextcloud/talk/utils/UriUtilsTest.kt +++ b/app/src/test/java/com/nextcloud/talk/utils/UriUtilsTest.kt @@ -1,8 +1,8 @@ /* * Nextcloud Talk application * - * @author Mario Danic - * Copyright (C) 2017-2019 Mario Danic + * @author Samanwith KSN + * Copyright (C) 2023 Samanwith KSN * * 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 diff --git a/app/src/test/java/com/nextcloud/talk/utils/UserIdUtilsTest.kt b/app/src/test/java/com/nextcloud/talk/utils/UserIdUtilsTest.kt index 02a498cff3..8eee75f2b8 100644 --- a/app/src/test/java/com/nextcloud/talk/utils/UserIdUtilsTest.kt +++ b/app/src/test/java/com/nextcloud/talk/utils/UserIdUtilsTest.kt @@ -1,10 +1,10 @@ /* * Nextcloud Talk application * - * @author Mario Danic * @author Marcel Hibbe + * @author Samanwith KSN * Copyright (C) 2023 Marcel Hibbe - * Copyright (C) 2017-2018 Mario Danic + * Copyright (C) 2023 Samanwith KSN * * 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 diff --git a/app/src/test/java/com/nextcloud/talk/webrtc/DataChannelMessageNotifierTest.kt b/app/src/test/java/com/nextcloud/talk/webrtc/DataChannelMessageNotifierTest.kt index baceb341da..30dd53d864 100644 --- a/app/src/test/java/com/nextcloud/talk/webrtc/DataChannelMessageNotifierTest.kt +++ b/app/src/test/java/com/nextcloud/talk/webrtc/DataChannelMessageNotifierTest.kt @@ -1,8 +1,8 @@ /* * Nextcloud Talk application * - * @author Mario Danic - * Copyright (C) 2017-2019 Mario Danic + * @author Samanwith KSN + * Copyright (C) 2023 Samanwith KSN * * 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 diff --git a/app/src/test/java/com/nextcloud/talk/webrtc/GlobalsTest.kt b/app/src/test/java/com/nextcloud/talk/webrtc/GlobalsTest.kt index c0c737f512..f1ff9a020f 100644 --- a/app/src/test/java/com/nextcloud/talk/webrtc/GlobalsTest.kt +++ b/app/src/test/java/com/nextcloud/talk/webrtc/GlobalsTest.kt @@ -1,8 +1,8 @@ /* * Nextcloud Talk application * - * @author Mario Danic - * Copyright (C) 2017-2019 Mario Danic + * @author Samanwith KSN + * Copyright (C) 2023 Samanwith KSN * * 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 diff --git a/app/src/test/java/com/nextcloud/talk/webrtc/PeerConnectionNotifierTest.kt b/app/src/test/java/com/nextcloud/talk/webrtc/PeerConnectionNotifierTest.kt index a1373709bb..36f421bfe4 100644 --- a/app/src/test/java/com/nextcloud/talk/webrtc/PeerConnectionNotifierTest.kt +++ b/app/src/test/java/com/nextcloud/talk/webrtc/PeerConnectionNotifierTest.kt @@ -1,8 +1,8 @@ /* * Nextcloud Talk application * - * @author Mario Danic - * Copyright (C) 2017-2019 Mario Danic + * @author Samanwith KSN + * Copyright (C) 2023 Samanwith KSN * * 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 From 58931564ff82b7bf71e5f8cd6e1d95933cc1600a Mon Sep 17 00:00:00 2001 From: Smarshal21 Date: Mon, 18 Sep 2023 19:45:25 +0530 Subject: [PATCH 5/5] FIxed ktlintCheck Errors --- .../java/com/nextcloud/talk/utils/BundleKeysTest.kt | 13 +++++++++---- .../java/com/nextcloud/talk/utils/UriUtilsTest.kt | 1 - .../talk/webrtc/PeerConnectionNotifierTest.kt | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt b/app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt index 1ee7028924..72b42a9f16 100644 --- a/app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt +++ b/app/src/test/java/com/nextcloud/talk/utils/BundleKeysTest.kt @@ -57,6 +57,7 @@ class BundleKeysTest { 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) @@ -80,10 +81,14 @@ class BundleKeysTest { 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_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) diff --git a/app/src/test/java/com/nextcloud/talk/utils/UriUtilsTest.kt b/app/src/test/java/com/nextcloud/talk/utils/UriUtilsTest.kt index 6c27e062f6..6737246deb 100644 --- a/app/src/test/java/com/nextcloud/talk/utils/UriUtilsTest.kt +++ b/app/src/test/java/com/nextcloud/talk/utils/UriUtilsTest.kt @@ -26,7 +26,6 @@ class UriUtilsTest { @Test fun testHasHttpProtocolPrefixed() { - val uriHttp = "http://www.example.com" val resultHttp = UriUtils.hasHttpProtocollPrefixed(uriHttp) Assert.assertTrue(resultHttp) diff --git a/app/src/test/java/com/nextcloud/talk/webrtc/PeerConnectionNotifierTest.kt b/app/src/test/java/com/nextcloud/talk/webrtc/PeerConnectionNotifierTest.kt index 36f421bfe4..59c0286ccc 100644 --- a/app/src/test/java/com/nextcloud/talk/webrtc/PeerConnectionNotifierTest.kt +++ b/app/src/test/java/com/nextcloud/talk/webrtc/PeerConnectionNotifierTest.kt @@ -31,6 +31,7 @@ class PeerConnectionNotifierTest { private var observer1: PeerConnectionObserver? = null private var observer2: PeerConnectionObserver? = null private var mockStream: MediaStream? = null + @Before fun setUp() { notifier = PeerConnectionNotifier()