Skip to content

Commit

Permalink
Special-case wallpaper file pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
sashaweiss-signal authored Sep 4, 2024
1 parent 879a8f7 commit f6eb5ed
Show file tree
Hide file tree
Showing 105 changed files with 450 additions and 474 deletions.
32 changes: 26 additions & 6 deletions src/main/kotlin/Permutations.kt
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ object Generators {
fun cdnNumbers(): Generator<Int> = Generators.list(0, 2, 3)
fun emails(): Generator<String> = Generators.list("${SeededRandom.string()}@${SeededRandom.string()}.com", "${SeededRandom.string()}@${SeededRandom.string()}.org")
fun blurHashes(): Generator<String> = Generators.list("LfLh6Voa9NIW?wNF-ooL-;WAX8oy", "LGG*f,-i.l-o?G\$~?Zt7pHN1=tE3", "LdIOX?NE9Y4T~pRPRjE1X9f5jrt6", "LJR,66e.~Cxu%LoLM|S2%3WWIosm", "LIM:}RB8?-^L.d4]O.nkK_ruI?od")
fun contentTypes(): Generator<String> = Generators.list("image/jpeg", "image/png", "image/gif", "audio/mp3", "video/mp4")
fun picoMobs(): Generator<String> = Generators.list(SeededRandom.string(18, 25, "123456789"), SeededRandom.string(18, 25, "123456789"))
fun colors(): Generator<Int> = Generators.list(seededRandomColor(), seededRandomColor(), seededRandomColor())

Expand All @@ -297,7 +296,28 @@ object Generators {
return ListGenerator(allItems)
}

fun filePointer(contentTypeGenerator: Generator<String> = Generators.contentTypes()): Generator<FilePointer> {
fun wallpaperFilePointer(): Generator<FilePointer> = filePointerInternal(
includeFileName = false,
includeMediaSize = false,
includeCaption = false,
contentTypeGenerator = Generators.list("image/jpeg", "image/png")
)

fun filePointer(
contentTypeGenerator: Generator<String> = Generators.list("image/jpeg", "image/png", "image/gif", "audio/mp3", "video/mp4")
): Generator<FilePointer> = filePointerInternal(
includeFileName = true,
includeMediaSize = true,
includeCaption = true,
contentTypeGenerator = contentTypeGenerator
)

private fun filePointerInternal(
includeFileName: Boolean,
includeMediaSize: Boolean,
includeCaption: Boolean,
contentTypeGenerator: Generator<String>
): Generator<FilePointer> {
val (backupLocatorGenerator, attachmentLocatorGenerator, invalidAttachmentLocatorGenerator) = oneOf(
Generators.permutation {
val transitCdnKey = some(Generators.nonEmptyStrings().nullable())
Expand Down Expand Up @@ -349,10 +369,10 @@ object Generators {
} else {
null
},
fileName = some(Generators.nonEmptyStrings().nullable()),
width = some(Generators.ints(0, 4096).nullable()),
height = some(Generators.ints(0, 4096).nullable()),
caption = someNullableString(),
fileName = if (includeFileName) some(Generators.nonEmptyStrings().nullable()) else null,
width = if (includeMediaSize) some(Generators.ints(0, 4096).nullable()) else null,
height = if (includeMediaSize) some(Generators.ints(0, 4096).nullable()) else null,
caption = if (includeCaption) someNullableString() else null,
blurHash = if (contentType.startsWith("audio")) null else blurHash
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/tests/AccountDataTestCase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object AccountDataTestCase : TestCase("account_data") {
frames += StandardFrames.backupInfo

val (wallpaperPhotoGenerator, wallpaperPresetGenerator) = oneOf(
Generators.filePointer() as Generator<Any?>,
Generators.wallpaperFilePointer() as Generator<Any?>,
Generators.enum(ChatStyle.WallpaperPreset::class.java, excluding = ChatStyle.WallpaperPreset.UNKNOWN_WALLPAPER_PRESET) as Generator<Any?>
)

Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/tests/ChatTestCase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ object ChatTestCase : TestCase("chat") {
frames += StandardFrames.recipientAlice

val (wallpaperPhotoGenerator, wallpaperPresetGenerator) = oneOf(
Generators.filePointer() as Generator<Any?>,
Generators.wallpaperFilePointer() as Generator<Any?>,
Generators.enum(ChatStyle.WallpaperPreset::class.java, ChatStyle.WallpaperPreset.UNKNOWN_WALLPAPER_PRESET) as Generator<Any?>
)

Expand Down
Binary file modified test-cases/account_data_00.binproto
Binary file not shown.
14 changes: 7 additions & 7 deletions test-cases/account_data_00.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ Frame {
customChatColors = [
CustomChatColor {
id = 1
solid = -2805332
solid = -6739874
},
CustomChatColor {
id = 2
solid = -8354883
solid = -6263822
},
CustomChatColor {
gradient = Gradient {
angle = 20
angle = 226
colors = [
-7053932,
-10086694
-9696843,
-6229632
]
positions = [
0.0,
Expand All @@ -47,12 +47,12 @@ Frame {
storiesDisabled = true
storyViewReceiptsEnabled = true
typingIndicators = true
universalExpireTimerSeconds = 616008951
universalExpireTimerSeconds = 998704135
}
avatarUrlPath = ""
familyName = ""
givenName = ""
profileKey = <99a0b038244c4dded369b915dbc6d9d34af5273ec0c1d502acde812c7ee2f29c>
profileKey = <05d886b98779cc84b63b3b0848ae92e6e00d51de27e38374784397640cc51a91>
}
}

Expand Down
Binary file modified test-cases/account_data_01.binproto
Binary file not shown.
28 changes: 14 additions & 14 deletions test-cases/account_data_01.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ Frame {
customChatColors = [
CustomChatColor {
id = 1
solid = -12885093
solid = -10997243
},
CustomChatColor {
id = 2
solid = -4424695
solid = -5843870
},
CustomChatColor {
gradient = Gradient {
angle = 187
angle = 32
colors = [
-16165811,
-15362572
-6614000,
-7562582
]
positions = [
0.0,
Expand All @@ -46,22 +46,22 @@ Frame {
}
}
phoneNumberSharingMode = PhoneNumberSharingMode.NOBODY
universalExpireTimerSeconds = 769549436
universalExpireTimerSeconds = 118828845
}
avatarUrlPath = "https://example.com/MRnBbKuo"
avatarUrlPath = "https://example.com/gxMhyZCTrFaZq"
donationSubscriberData = SubscriberData {
currencyCode = "USD"
manuallyCancelled = true
subscriberId = <df93d2e29614e293c3e76f4e185b9058efc1fa486e362a8bfe82fac40e9e6701>
subscriberId = <fcd58ca580b80888e681e323c607d5959f6b63ece7730df01fcfad80dfdf000f>
}
familyName = "JRYwuBEiK"
givenName = "FBvMKGTMcILm"
profileKey = <99a0b038244c4dded369b915dbc6d9d34af5273ec0c1d502acde812c7ee2f29c>
username = "HqzzN.96"
familyName = "SZlHtAKtPV"
givenName = "HaWuejXWhGQz"
profileKey = <05d886b98779cc84b63b3b0848ae92e6e00d51de27e38374784397640cc51a91>
username = "LPSkAoCfVdHWJP.67"
usernameLink = UsernameLink {
color = Color.BLUE
entropy = <023354c1c58b8bdb65b292d0fbfd03cef547a36774f7b594a5a5b7db5756287f>
serverId = <731ddfba674ec6f3bac14fed8832849e>
entropy = <aebcb5a166a1e4dfbdea011a4c4f4cdd162925690d31a8ba1a7be8b3820ab936>
serverId = <8e40d2431d317e2dee39bbf801480e9e>
}
}
}
Expand Down
Binary file modified test-cases/account_data_02.binproto
Binary file not shown.
32 changes: 14 additions & 18 deletions test-cases/account_data_02.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ Frame {
customChatColors = [
CustomChatColor {
id = 1
solid = -16570247
solid = -792050
},
CustomChatColor {
id = 2
solid = -415866
solid = -4712235
},
CustomChatColor {
gradient = Gradient {
angle = 229
angle = 323
colors = [
-11328369,
-16144417
-8782409,
-7053975
]
positions = [
0.0,
Expand All @@ -44,13 +44,9 @@ Frame {
transitCdnKey = "EtjaXtfWb"
}
blurHash = "LfLh6Voa9NIW?wNF-ooL-;WAX8oy"
caption = ""
contentType = "image/png"
fileName = "fktWAZnl"
height = 3361
incrementalMac = <b0268c5da867e8b454754359d4337a3c>
incrementalMacChunkSize = 2048
width = 823
}
}
displayBadgesOnProfile = true
Expand All @@ -68,21 +64,21 @@ Frame {
storiesDisabled = true
storyViewReceiptsEnabled = true
typingIndicators = true
universalExpireTimerSeconds = 542768234
universalExpireTimerSeconds = 1205434845
}
avatarUrlPath = "https://example.com/BvsKAUVdtL"
avatarUrlPath = "https://example.com/nUUiit"
donationSubscriberData = SubscriberData {
currencyCode = "EUR"
subscriberId = <6eb51ac08d871eb76f2e7e3825d55d76500fad6608e092e4becbfbbe1e28e38b>
subscriberId = <a6eeb98b207d85f0b413e071743cee3d4bece41ec92ea59e67f1c2ef2a465a56>
}
familyName = "QxVufxIRR"
givenName = "vNHEreJDueIn"
profileKey = <99a0b038244c4dded369b915dbc6d9d34af5273ec0c1d502acde812c7ee2f29c>
username = "ZggKo.88"
familyName = "VMjjbudVyD"
givenName = "tfRDjcU"
profileKey = <05d886b98779cc84b63b3b0848ae92e6e00d51de27e38374784397640cc51a91>
username = "ZhdLygutgr.51"
usernameLink = UsernameLink {
color = Color.WHITE
entropy = <00205ee8e14dd5d6df1bf0ae271eed9d640edd3bd1e1a6cfc758125a94372c26>
serverId = <44b7a5ed7fed22b2f329b86acb134608>
entropy = <74f34922363753d413b462631f8eb741383ccf3627c362ea1d4aadc91b546309>
serverId = <eabc0dacb6f894ff2dcd51a027f66df3>
}
}
}
Expand Down
Binary file modified test-cases/account_data_03.binproto
Binary file not shown.
28 changes: 12 additions & 16 deletions test-cases/account_data_03.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ Frame {
customChatColors = [
CustomChatColor {
id = 1
solid = -2805332
solid = -6739874
},
CustomChatColor {
id = 2
solid = -8354883
solid = -6263822
},
CustomChatColor {
gradient = Gradient {
angle = 20
angle = 226
colors = [
-7053932,
-10086694
-9696843,
-6229632
]
positions = [
0.0,
Expand All @@ -46,30 +46,26 @@ Frame {
transitCdnNumber = 2
}
blurHash = "LGG*f,-i.l-o?G$~?Zt7pHN1=tE3"
caption = "OymkbGZomPlLHy"
contentType = "image/gif"
fileName = "xHDjKnB"
height = 781
width = 3896
contentType = "image/jpeg"
}
}
phoneNumberSharingMode = PhoneNumberSharingMode.NOBODY
universalExpireTimerSeconds = 616008951
universalExpireTimerSeconds = 998704135
}
avatarUrlPath = ""
donationSubscriberData = SubscriberData {
currencyCode = "GBP"
manuallyCancelled = true
subscriberId = <7911e7798244f14304a45b550a99ee0df3ff32c42e228cf0ec92e3182c8face4>
subscriberId = <42bf45e91cd2b5d284298c030d7a577d4e461bad394678abe8ddfe7755cf8693>
}
familyName = ""
givenName = ""
profileKey = <99a0b038244c4dded369b915dbc6d9d34af5273ec0c1d502acde812c7ee2f29c>
username = "HqzzN.96"
profileKey = <05d886b98779cc84b63b3b0848ae92e6e00d51de27e38374784397640cc51a91>
username = "LPSkAoCfVdHWJP.67"
usernameLink = UsernameLink {
color = Color.GREY
entropy = <ea2b87608981423f87a1cf293b8aa5dac03b4e37d46a68b84baa49cf5140d38a>
serverId = <8be2cb21a0fa47a0181037dfcfe0de95>
entropy = <f1199c78f4a921363af79e298cfcf2491a96e707c00259c7264eb5417dfb20d9>
serverId = <2e2771dbc69f3f56cf981fd64acc5040>
}
}
}
Expand Down
Binary file modified test-cases/account_data_04.binproto
Binary file not shown.
32 changes: 15 additions & 17 deletions test-cases/account_data_04.txtproto
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ Frame {
customChatColors = [
CustomChatColor {
id = 1
solid = -12885093
solid = -10997243
},
CustomChatColor {
id = 2
solid = -4424695
solid = -5843870
},
CustomChatColor {
gradient = Gradient {
angle = 187
angle = 32
colors = [
-16165811,
-15362572
-6614000,
-7562582
]
positions = [
0.0,
Expand All @@ -41,12 +41,10 @@ Frame {
mediaName = "6dc1e0cd18b0df35d2dda82a4ffea322"
size = 1000441712
}
caption = "LGdFwzenIne"
contentType = "audio/mp3"
height = 3522
blurHash = "LdIOX?NE9Y4T~pRPRjE1X9f5jrt6"
contentType = "image/png"
incrementalMac = <b0268c5da867e8b454754359d4337a3c>
incrementalMacChunkSize = 2048
width = 710
}
}
displayBadgesOnProfile = true
Expand All @@ -64,17 +62,17 @@ Frame {
storiesDisabled = true
storyViewReceiptsEnabled = true
typingIndicators = true
universalExpireTimerSeconds = 769549436
universalExpireTimerSeconds = 118828845
}
avatarUrlPath = "https://example.com/MRnBbKuo"
familyName = "JRYwuBEiK"
givenName = "FBvMKGTMcILm"
profileKey = <99a0b038244c4dded369b915dbc6d9d34af5273ec0c1d502acde812c7ee2f29c>
username = "ZggKo.88"
avatarUrlPath = "https://example.com/gxMhyZCTrFaZq"
familyName = "SZlHtAKtPV"
givenName = "HaWuejXWhGQz"
profileKey = <05d886b98779cc84b63b3b0848ae92e6e00d51de27e38374784397640cc51a91>
username = "ZhdLygutgr.51"
usernameLink = UsernameLink {
color = Color.OLIVE
entropy = <e663e783cd45f8bcee2bba22154356f8228ce13806bcb400f2316eac211b9328>
serverId = <b1a6608635a5eb695456cf27dca7ca58>
entropy = <f23a4ce20c4220ab396c4b8ebdefd49b44b4c8d19c47cb807844279fb4a4e927>
serverId = <745ec558f58cca155df7981e10411f6e>
}
}
}
Expand Down
Binary file modified test-cases/account_data_05.binproto
Binary file not shown.
Loading

0 comments on commit f6eb5ed

Please sign in to comment.