mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-26 03:40:56 +01:00
Add unit testing for Recipient#getChatColors
This commit is contained in:
@@ -0,0 +1,137 @@
|
||||
package org.thoughtcrime.securesms.database
|
||||
|
||||
import android.net.Uri
|
||||
import org.signal.zkgroup.profiles.ProfileKeyCredential
|
||||
import org.thoughtcrime.securesms.conversation.colors.AvatarColor
|
||||
import org.thoughtcrime.securesms.conversation.colors.ChatColors
|
||||
import org.thoughtcrime.securesms.groups.GroupId
|
||||
import org.thoughtcrime.securesms.profiles.ProfileName
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
import org.thoughtcrime.securesms.recipients.RecipientDetails
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
import org.thoughtcrime.securesms.wallpaper.ChatWallpaper
|
||||
import org.whispersystems.libsignal.util.guava.Optional
|
||||
import java.util.UUID
|
||||
import kotlin.random.Random
|
||||
|
||||
/**
|
||||
* Test utilities to create recipients in different states.
|
||||
*/
|
||||
object RecipientDatabaseTestUtils {
|
||||
|
||||
fun createRecipient(
|
||||
resolved: Boolean = false,
|
||||
groupName: String? = null,
|
||||
groupAvatarId: Optional<Long> = Optional.absent(),
|
||||
systemContact: Boolean = false,
|
||||
isSelf: Boolean = false,
|
||||
participants: List<Recipient> = listOf(),
|
||||
recipientId: RecipientId = RecipientId.from(Random.nextLong()),
|
||||
uuid: UUID? = UUID.randomUUID(),
|
||||
username: String? = null,
|
||||
e164: String? = null,
|
||||
email: String? = null,
|
||||
groupId: GroupId? = null,
|
||||
groupType: RecipientDatabase.GroupType = RecipientDatabase.GroupType.NONE,
|
||||
blocked: Boolean = false,
|
||||
muteUntil: Long = -1,
|
||||
messageVibrateState: RecipientDatabase.VibrateState = RecipientDatabase.VibrateState.DEFAULT,
|
||||
callVibrateState: RecipientDatabase.VibrateState = RecipientDatabase.VibrateState.DEFAULT,
|
||||
messageRingtone: Uri = Uri.EMPTY,
|
||||
callRingtone: Uri = Uri.EMPTY,
|
||||
defaultSubscriptionId: Int = 0,
|
||||
expireMessages: Int = 0,
|
||||
registered: RecipientDatabase.RegisteredState = RecipientDatabase.RegisteredState.REGISTERED,
|
||||
profileKey: ByteArray = Random.nextBytes(32),
|
||||
profileKeyCredential: ProfileKeyCredential? = null,
|
||||
systemProfileName: ProfileName = ProfileName.EMPTY,
|
||||
systemDisplayName: String? = null,
|
||||
systemContactPhoto: String? = null,
|
||||
systemPhoneLabel: String? = null,
|
||||
systemContactUri: String? = null,
|
||||
signalProfileName: ProfileName = ProfileName.EMPTY,
|
||||
signalProfileAvatar: String? = null,
|
||||
hasProfileImage: Boolean = false,
|
||||
profileSharing: Boolean = false,
|
||||
lastProfileFetch: Long = 0L,
|
||||
notificationChannel: String? = null,
|
||||
unidentifiedAccessMode: RecipientDatabase.UnidentifiedAccessMode = RecipientDatabase.UnidentifiedAccessMode.UNKNOWN,
|
||||
forceSmsSelection: Boolean = false,
|
||||
capabilities: Long = 0L,
|
||||
insightBannerTier: RecipientDatabase.InsightsBannerTier = RecipientDatabase.InsightsBannerTier.NO_TIER,
|
||||
storageId: ByteArray? = null,
|
||||
mentionSetting: RecipientDatabase.MentionSetting = RecipientDatabase.MentionSetting.ALWAYS_NOTIFY,
|
||||
wallpaper: ChatWallpaper? = null,
|
||||
chatColors: ChatColors? = null,
|
||||
avatarColor: AvatarColor = AvatarColor.BLUE,
|
||||
about: String? = null,
|
||||
aboutEmoji: String? = null,
|
||||
syncExtras: RecipientDatabase.RecipientSettings.SyncExtras = RecipientDatabase.RecipientSettings.SyncExtras(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
IdentityDatabase.VerifiedStatus.DEFAULT,
|
||||
false,
|
||||
false
|
||||
),
|
||||
extras: Recipient.Extras? = null,
|
||||
hasGroupsInCommon: Boolean = false
|
||||
): Recipient = Recipient(
|
||||
recipientId,
|
||||
RecipientDetails(
|
||||
groupName,
|
||||
systemDisplayName,
|
||||
groupAvatarId,
|
||||
systemContact,
|
||||
isSelf,
|
||||
registered,
|
||||
RecipientDatabase.RecipientSettings(
|
||||
recipientId,
|
||||
uuid,
|
||||
username,
|
||||
e164,
|
||||
email,
|
||||
groupId,
|
||||
groupType,
|
||||
blocked,
|
||||
muteUntil,
|
||||
messageVibrateState,
|
||||
callVibrateState,
|
||||
messageRingtone,
|
||||
callRingtone,
|
||||
defaultSubscriptionId,
|
||||
expireMessages,
|
||||
registered,
|
||||
profileKey,
|
||||
profileKeyCredential,
|
||||
systemProfileName,
|
||||
systemDisplayName,
|
||||
systemContactPhoto,
|
||||
systemPhoneLabel,
|
||||
systemContactUri,
|
||||
signalProfileName,
|
||||
signalProfileAvatar,
|
||||
hasProfileImage,
|
||||
profileSharing,
|
||||
lastProfileFetch,
|
||||
notificationChannel,
|
||||
unidentifiedAccessMode,
|
||||
forceSmsSelection,
|
||||
capabilities,
|
||||
insightBannerTier,
|
||||
storageId,
|
||||
mentionSetting,
|
||||
wallpaper,
|
||||
chatColors,
|
||||
avatarColor,
|
||||
about,
|
||||
aboutEmoji,
|
||||
syncExtras,
|
||||
extras,
|
||||
hasGroupsInCommon
|
||||
),
|
||||
participants
|
||||
),
|
||||
resolved
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user