Generate placeholder avatars from two characters, re-fetch missed avatars (#856)

* feat: splitting names in the avatar generation

* fix: re-fetch avatars if initial downloads fail

* fix: remove shadowed name, add tests for common labels
This commit is contained in:
Harris
2022-03-15 09:24:15 +11:00
committed by GitHub
parent 11d49426d3
commit 6649a9a745
6 changed files with 66 additions and 18 deletions

View File

@@ -0,0 +1,26 @@
package org.thoughtcrime.securesms.recipients
import org.junit.Assert.assertEquals
import org.junit.Test
import org.thoughtcrime.securesms.util.AvatarPlaceholderGenerator
class AvatarGeneratorTest {
@Test
fun testCommonAvatarFormats() {
val testNamesAndResults = mapOf(
"H " to "H",
"Test Name" to "TN",
"test name" to "TN",
"howdy partner" to "HP",
"testname" to "TE", //
"05aaapubkey" to "A", // pubkey values only return first non-05 character
"Test" to "TE"
)
testNamesAndResults.forEach { (test, expected) ->
val processed = AvatarPlaceholderGenerator.extractLabel(test)
assertEquals(expected, processed)
}
}
}