mirror of
https://github.com/nextcloud/talk-android
synced 2025-03-12 10:32:36 +00:00
Refactor ShareUtils and remove ShareUtilsTest file
Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
parent
b6ab867280
commit
1c26c757f0
@ -7,22 +7,11 @@
|
||||
package com.nextcloud.talk.utils
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.data.user.model.User
|
||||
import com.nextcloud.talk.models.domain.ConversationModel
|
||||
|
||||
object ShareUtils {
|
||||
fun getStringForIntent(context: Context, user: User, conversation: ConversationModel?): String {
|
||||
return String.format(
|
||||
context.resources.getString(R.string.nc_share_link_text),
|
||||
conversation?.name,
|
||||
user.baseUrl,
|
||||
conversation?.token
|
||||
)
|
||||
}
|
||||
|
||||
fun shareConversationLink(context: Activity, baseUrl: String?, roomToken: String?, conversationName: String?) {
|
||||
if (baseUrl.isNullOrBlank() || roomToken.isNullOrBlank() || conversationName.isNullOrBlank()) {
|
||||
|
@ -331,7 +331,7 @@ How to translate with transifex:
|
||||
<string name="nc_add_emojis">Add emojis</string>
|
||||
<string name="nc_share_subject">%1$s invitation</string>
|
||||
<string name="nc_share_text_pass">\nPassword: %1$s</string>
|
||||
<string name="nc_share_link_text">Join the conversation %1$s at %2$s/index.php/call/%3$s</string>
|
||||
|
||||
|
||||
<string name="nc_push_to_talk">Push-to-talk</string>
|
||||
<string name="nc_push_to_talk_desc">With microphone disabled, click&hold to use Push-to-talk</string>
|
||||
|
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* Nextcloud Talk - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2017-2019 Mario Danic <mario@lovelyhq.com>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
package com.nextcloud.talk.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import com.nextcloud.talk.R
|
||||
import com.nextcloud.talk.data.user.model.User
|
||||
import com.nextcloud.talk.models.domain.ConversationModel
|
||||
import com.nextcloud.talk.users.UserManager
|
||||
import io.reactivex.Maybe
|
||||
import org.junit.Assert
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.mockito.Mock
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.MockitoAnnotations
|
||||
|
||||
class ShareUtilsTest {
|
||||
@Mock
|
||||
private val context: Context? = null
|
||||
|
||||
@Mock
|
||||
private val resources: Resources? = null
|
||||
|
||||
@Mock
|
||||
private val userManager: UserManager? = null
|
||||
|
||||
@Mock
|
||||
private val user: User? = null
|
||||
|
||||
private val baseUrl = "https://my.nextcloud.com"
|
||||
private val token = "2aotbrjr"
|
||||
|
||||
private lateinit var conversation: ConversationModel
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.openMocks(this)
|
||||
Mockito.`when`(userManager!!.currentUser).thenReturn(Maybe.just(user))
|
||||
Mockito.`when`(user!!.baseUrl).thenReturn(baseUrl)
|
||||
Mockito.`when`(context!!.resources).thenReturn(resources)
|
||||
Mockito.`when`(resources!!.getString(R.string.nc_share_text))
|
||||
.thenReturn("Join the conversation at %1\$s/index.php/call/%2\$s")
|
||||
Mockito.`when`(resources.getString(R.string.nc_share_text_pass)).thenReturn("\nPassword: %1\$s")
|
||||
|
||||
conversation = ConversationModel(token = token)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun stringForIntent_noPasswordGiven_correctStringWithoutPasswordReturned() {
|
||||
val expectedResult = String.format(
|
||||
"Join the conversation at %s/index.php/call/%s",
|
||||
baseUrl,
|
||||
token
|
||||
)
|
||||
Assert.assertEquals(
|
||||
"Intent string was not as expected",
|
||||
expectedResult,
|
||||
ShareUtils.getStringForIntent(context!!, userManager!!.currentUser.blockingGet(), conversation)
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user