Create fake data for unit tests

Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
sowjanyakch 2024-07-17 22:00:16 +02:00 committed by Marcel Hibbe
parent 5d73b65a31
commit acbda6f887
No known key found for this signature in database
GPG key ID: C793F8B59F43CE7B
6 changed files with 114 additions and 34 deletions

View file

@ -13,7 +13,6 @@ import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.util.Log
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
@ -52,7 +51,6 @@ import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
@ -63,24 +61,21 @@ import androidx.lifecycle.ViewModelProvider
import autodagger.AutoInjector
import coil.compose.AsyncImage
import com.nextcloud.talk.R
import com.nextcloud.talk.activities.BaseActivity
import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.chat.ChatActivity
import com.nextcloud.talk.models.json.autocomplete.AutocompleteUser
import com.nextcloud.talk.openconversations.ListOpenConversationsActivity
import com.nextcloud.talk.ui.theme.ViewThemeUtils
import com.nextcloud.talk.utils.bundle.BundleKeys
import javax.inject.Inject
@AutoInjector(NextcloudTalkApplication::class)
class ContactsActivityCompose : ComponentActivity() {
class ContactsActivityCompose : BaseActivity() {
@Inject
lateinit var viewModelFactory: ViewModelProvider.Factory
private lateinit var contactsViewModel: ContactsViewModel
@Inject
lateinit var viewThemeUtils: ViewThemeUtils
@SuppressLint("UnrememberedMutableState")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -88,8 +83,9 @@ class ContactsActivityCompose : ComponentActivity() {
contactsViewModel = ViewModelProvider(this, viewModelFactory)[ContactsViewModel::class.java]
setContent {
val colorScheme = viewThemeUtils.getColorScheme(this)
MaterialTheme(
colorScheme = viewThemeUtils.getColorScheme(this)
colorScheme = colorScheme
) {
val context = LocalContext.current
Scaffold(
@ -288,8 +284,8 @@ fun ConversationCreationOptions(context: Context) {
.height(40.dp)
.padding(8.dp),
painter = painterResource(R.drawable.baseline_chat_bubble_outline_24),
contentDescription = stringResource(R.string.new_conversation_creation_icon),
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onSurface)
contentDescription = stringResource(R.string.new_conversation_creation_icon)
// colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onSurface)
)
Text(
modifier = Modifier
@ -297,8 +293,8 @@ fun ConversationCreationOptions(context: Context) {
.wrapContentHeight(),
text = stringResource(R.string.nc_create_new_conversation),
maxLines = 1,
fontSize = 16.sp,
color = MaterialTheme.colorScheme.onSurface
fontSize = 16.sp
// color = MaterialTheme.colorScheme.onSurface
)
}
Row(
@ -316,8 +312,8 @@ fun ConversationCreationOptions(context: Context) {
.height(40.dp)
.padding(8.dp),
painter = painterResource(R.drawable.baseline_format_list_bulleted_24),
contentDescription = stringResource(R.string.join_open_conversations_icon),
colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onSurface)
contentDescription = stringResource(R.string.join_open_conversations_icon)
// colorFilter = ColorFilter.tint(MaterialTheme.colorScheme.onSurface)
)
Text(
modifier = Modifier

View file

@ -7,7 +7,6 @@
package com.nextcloud.talk.contacts
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.text.KeyboardActions
@ -17,14 +16,11 @@ import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.filled.Close
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.material3.TextField
import androidx.compose.material3.TextFieldDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.TextStyle
@ -44,19 +40,19 @@ fun DisplaySearch(text: String, onTextChange: (String) -> Unit, contactsViewMode
val keyboardController = LocalSoftwareKeyboardController.current
TextField(
modifier = Modifier
.fillMaxWidth()
.background(MaterialTheme.colorScheme.surface),
.fillMaxWidth(),
// .background(MaterialTheme.colorScheme.surface),
value = text,
onValueChange = { onTextChange(it) },
placeholder = {
Text(
text = stringResource(R.string.nc_search),
color = MaterialTheme.colorScheme.onSurfaceVariant
text = stringResource(R.string.nc_search)
// color = MaterialTheme.colorScheme.onSurfaceVariant
)
},
textStyle = TextStyle(
color = MaterialTheme.colorScheme.onSurface,
// color = MaterialTheme.colorScheme.onSurface,
fontSize = 16.sp
),
singleLine = true,
@ -69,8 +65,8 @@ fun DisplaySearch(text: String, onTextChange: (String) -> Unit, contactsViewMode
) {
Icon(
imageVector = Icons.AutoMirrored.Default.ArrowBack,
contentDescription = stringResource(R.string.back_button),
tint = MaterialTheme.colorScheme.onSurface
contentDescription = stringResource(R.string.back_button)
// tint = MaterialTheme.colorScheme.onSurface
)
}
},
@ -85,7 +81,7 @@ fun DisplaySearch(text: String, onTextChange: (String) -> Unit, contactsViewMode
Icon(
imageVector = Icons.Default.Close,
contentDescription = stringResource(R.string.close_icon),
tint = MaterialTheme.colorScheme.onSurface
//tint = MaterialTheme.colorScheme.onSurface
)
}
}
@ -104,14 +100,10 @@ fun DisplaySearch(text: String, onTextChange: (String) -> Unit, contactsViewMode
}
}
),
maxLines = 1,
colors = TextFieldDefaults.colors(
focusedContainerColor = Color.White,
unfocusedContainerColor = Color.White,
disabledContainerColor = Color.White,
focusedTextColor = Color.Black,
cursorColor = Color.Black
)
maxLines = 1
// colors = TextFieldDefaults.colors(
// cursorColor = Color.Blue
// )
)
}
}

View file

@ -0,0 +1,27 @@
/*
* Nextcloud Talk - Android Client
*
* SPDX-FileCopyrightText: 2024 Your Name <your@email.com>
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package com.nextcloud.talk.contacts.apiService
import com.nextcloud.talk.api.NcApiCoroutines
import com.nextcloud.talk.models.json.autocomplete.AutocompleteOverall
import com.nextcloud.talk.models.json.conversations.RoomOverall
class FakeApiService() : NcApiCoroutines {
override suspend fun getContactsWithSearchParam(
authorization: String?,
url: String?,
listOfShareTypes: List<String>?,
options: Map<String, Any>?
): AutocompleteOverall {
TODO("Not yet implemented")
}
override suspend fun createRoom(authorization: String?, url: String?, options: Map<String, String>?): RoomOverall {
TODO("Not yet implemented")
}
}

View file

@ -0,0 +1,11 @@
/*
* Nextcloud Talk - Android Client
*
* SPDX-FileCopyrightText: 2024 Your Name <your@email.com>
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package com.nextcloud.talk.contacts.apiService
object FakeItem {
}

View file

@ -0,0 +1,27 @@
/*
* Nextcloud Talk - Android Client
*
* SPDX-FileCopyrightText: 2024 Your Name <your@email.com>
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package com.nextcloud.talk.contacts.repository
import com.nextcloud.talk.contacts.ContactsRepository
import com.nextcloud.talk.models.json.autocomplete.AutocompleteOverall
import com.nextcloud.talk.models.json.conversations.RoomOverall
class FakeRepositoryError() : ContactsRepository {
override suspend fun getContacts(searchQuery: String?, shareTypes: List<String>): AutocompleteOverall {
TODO("Not yet implemented")
}
override suspend fun createRoom(
roomType: String,
sourceType: String,
userId: String,
conversationName: String?
): RoomOverall {
TODO("Not yet implemented")
}
}

View file

@ -0,0 +1,27 @@
/*
* Nextcloud Talk - Android Client
*
* SPDX-FileCopyrightText: 2024 Your Name <your@email.com>
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package com.nextcloud.talk.contacts.repository
import com.nextcloud.talk.contacts.ContactsRepository
import com.nextcloud.talk.models.json.autocomplete.AutocompleteOverall
import com.nextcloud.talk.models.json.conversations.RoomOverall
class FakeRepositorySuccess() : ContactsRepository {
override suspend fun getContacts(searchQuery: String?, shareTypes: List<String>): AutocompleteOverall {
TODO("Not yet implemented")
}
override suspend fun createRoom(
roomType: String,
sourceType: String,
userId: String,
conversationName: String?
): RoomOverall {
TODO("Not yet implemented")
}
}