Skip to content

Commit 31f625a

Browse files
committed
- Fix UnitTest Failures
1 parent 8233b26 commit 31f625a

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

app/src/main/java/com/telnyx/webrtc/sdk/ui/MainViewModel.kt

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,21 @@ class MainViewModel @Inject constructor(
4848
telnyxClient = TelnyxClient(context)
4949

5050
providedServerConfig?.let {
51-
telnyxClient?.connect(it,credentialConfig!!,txPushMetaData,true)
51+
telnyxClient?.connect(it, credentialConfig!!, txPushMetaData, true)
5252
} ?: run {
53-
telnyxClient?.connect(txPushMetaData = txPushMetaData, credentialConfig = credentialConfig!!, autoLogin = true)
53+
if (tokenConfig != null) {
54+
telnyxClient?.connect(
55+
txPushMetaData = txPushMetaData,
56+
tokenConfig = tokenConfig,
57+
autoLogin = true
58+
)
59+
} else {
60+
telnyxClient?.connect(
61+
txPushMetaData = txPushMetaData,
62+
credentialConfig = credentialConfig!!,
63+
autoLogin = true
64+
)
65+
}
5466
}
5567
}
5668

@@ -98,7 +110,6 @@ class MainViewModel @Inject constructor(
98110
fun getIsOnLoudSpeakerStatus(): LiveData<Boolean>? = currentCall?.getIsOnLoudSpeakerStatus()
99111

100112

101-
102113
fun doLoginWithToken(tokenConfig: TokenConfig) {
103114
telnyxClient?.tokenLogin(tokenConfig)
104115
}
@@ -109,7 +120,7 @@ class MainViewModel @Inject constructor(
109120
destinationNumber: String,
110121
clientState: String
111122
) {
112-
val call = telnyxClient?.newInvite(
123+
val call = telnyxClient?.newInvite(
113124
callerName, callerNumber, destinationNumber,
114125
clientState, mapOf(Pair("X-test", "123456"))
115126
)

telnyx_rtc/src/main/java/com/telnyx/webrtc/sdk/TelnyxClient.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,6 @@ class TelnyxClient(
400400
host_address = Config.TELNYX_PROD_HOST_ADDRESS,
401401
port = Config.TELNYX_PORT
402402
)
403-
//socketResponseLiveData = MutableLiveData<SocketResponse<ReceivedMessageBody>>()
404403
registerNetworkCallback()
405404
}
406405

@@ -483,7 +482,8 @@ class TelnyxClient(
483482
* (Get this from push notification - fcm data payload)
484483
* required fot push calls to work
485484
*
486-
* @param autoLogin, if true, the SDK will automatically log in with the provided credentials on connection established
485+
* @param autoLogin, if true, the SDK will automatically log in with
486+
* the provided credentials on connection established
487487
* We recommend setting this to true
488488
*
489489
*/

telnyx_rtc/src/main/java/com/telnyx/webrtc/sdk/peer/Peer.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ internal class Peer(
4949
companion object {
5050
private const val AUDIO_LOCAL_TRACK_ID = "audio_local_track"
5151
private const val AUDIO_LOCAL_STREAM_ID = "audio_local_stream"
52+
private const val CANDIDATE_LIMIT : Int = 5
53+
private const val STATS_INTERVAL : Long = 2000L
54+
private const val STATS_INITIAL : Long = 0L
5255
}
5356

5457
private val rootEglBase: EglBase = EglBase.create()
55-
private val candidateNumber = 5
5658

57-
private val statsInterval = 2000L
58-
private val statsInitial = 0L
5959
internal var debugStatsId = UUID.randomUUID()
6060

6161

@@ -193,7 +193,7 @@ internal class Peer(
193193
val jsonOutbound = gson.toJsonTree(value)
194194
outBoundStats.add(jsonOutbound)
195195
}
196-
if (value.type == "candidate-pair" && candidateParis.size() < candidateNumber) {
196+
if (value.type == "candidate-pair" && candidateParis.size() < CANDIDATE_LIMIT) {
197197
val jsonCandidatePair = gson.toJsonTree(value)
198198
candidateParis.add(jsonCandidatePair)
199199
}
@@ -219,7 +219,7 @@ internal class Peer(
219219
}
220220

221221
}
222-
}, statsInitial, statsInterval)
222+
}, STATS_INITIAL, STATS_INTERVAL)
223223
}
224224

225225

telnyx_rtc/src/test/java/com/telnyx/webrtc/sdk/TelnyxClientTest.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,13 @@ class TelnyxClientTest : BaseTest() {
183183
@Test
184184
fun `login with valid credentials - login sent to socket and json received`() {
185185
client = Mockito.spy(TelnyxClient(mockContext))
186+
client.connect(txPushMetaData = null)
186187
client.socket = Mockito.spy(
187188
TxSocket(
188189
host_address = "rtc.telnyx.com",
189190
port = 14938,
190191
)
191192
)
192-
client.connect(txPushMetaData = null)
193193

194194
val config = CredentialConfig(
195195
MOCK_USERNAME_TEST,
@@ -210,13 +210,13 @@ class TelnyxClientTest : BaseTest() {
210210
@Test
211211
fun `login with invalid credentials - login sent to socket and json received`() {
212212
client = Mockito.spy(TelnyxClient(mockContext))
213+
client.connect(txPushMetaData = null)
213214
client.socket = Mockito.spy(
214215
TxSocket(
215216
host_address = "rtc.telnyx.com",
216217
port = 14938,
217218
)
218219
)
219-
client.connect(txPushMetaData = null)
220220

221221
val config = CredentialConfig(
222222
"asdfasass",
@@ -240,14 +240,14 @@ class TelnyxClientTest : BaseTest() {
240240
@Test
241241
fun `login with valid token - login sent to socket and json received`() {
242242
client = Mockito.spy(TelnyxClient(mockContext))
243+
client.connect(txPushMetaData = null)
243244
client.socket = Mockito.spy(
244245
TxSocket(
245246
host_address = "rtc.telnyx.com",
246247
port = 14938,
247248
)
248249
)
249250

250-
client.connect(txPushMetaData = null)
251251

252252
val config = TokenConfig(
253253
MOCK_TOKEN,
@@ -268,15 +268,16 @@ class TelnyxClientTest : BaseTest() {
268268
@Test
269269
fun `login with invalid token - login sent to socket and json received`() {
270270
client = Mockito.spy(TelnyxClient(mockContext))
271+
272+
273+
client.connect(txPushMetaData = null)
271274
client.socket = Mockito.spy(
272275
TxSocket(
273276
host_address = "rtc.telnyx.com",
274277
port = 14938,
275278
)
276279
)
277280

278-
client.connect(txPushMetaData = null)
279-
280281
val config = TokenConfig(
281282
anyString(),
282283
"test",

0 commit comments

Comments
 (0)