Skip to content

Commit 22d7f50

Browse files
Add test case for direct replies with edits.
1 parent 3cd8bec commit 22d7f50

File tree

30 files changed

+2824
-1
lines changed

30 files changed

+2824
-1
lines changed

src/main/kotlin/Main.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ val ALL_TEST_CASES = listOf(
5151
ChatItemViewOnceTestCase,
5252
ChatItemGroupChangeChatUpdateTestCase,
5353
ChatItemGroupChangeChatMultipleUpdateTestCase,
54-
ChatItemDirectStoryReplyTestCase
54+
ChatItemDirectStoryReplyTestCase,
55+
ChatItemDirectStoryReplyWithEditsTestCase
5556
)
5657

5758
fun main(args: Array<String>) {
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
@file:Suppress("UNCHECKED_CAST")
2+
3+
package tests
4+
5+
import Generator
6+
import Generators
7+
import PermutationScope
8+
import TestCase
9+
import nullable
10+
import oneOf
11+
import org.thoughtcrime.securesms.backup.v2.proto.*
12+
13+
/**
14+
* Incoming/outgoing remote deleted messages.
15+
*/
16+
object ChatItemDirectStoryReplyWithEditsTestCase : TestCase("chat_item_direct_story_reply_with_edits") {
17+
18+
// We always want to read the latest value inside a generator, so to prevent capturing
19+
// a snapshot, we keep this as member state
20+
private var originalMessageDateSent: Long = 0L
21+
22+
override fun PermutationScope.execute() {
23+
frames += StandardFrames.MANDATORY_FRAMES
24+
25+
frames += StandardFrames.recipientAlice
26+
frames += StandardFrames.chatAlice
27+
28+
val (textReply, emoji) = oneOf(
29+
Generators.permutation {
30+
val text = some(Generators.textBody(minWords = 10, maxWords = 15))
31+
frames += DirectStoryReplyMessage.TextReply(
32+
text = Text(
33+
body = text,
34+
bodyRanges = some(Generators.bodyRanges(text))
35+
),
36+
longText = some(Generators.longTextFilePointer().nullable())
37+
)
38+
},
39+
Generators.emoji()as Generator<Any?>
40+
)
41+
42+
originalMessageDateSent = someNonZeroTimestamp()
43+
44+
val revisionGenerator = Generators.lists(listOf(1, 3)) {
45+
Generators.permutation<ChatItem>(snapshotCount = 4) {
46+
val dateSent = someIncrementingTimestamp(
47+
lower = originalMessageDateSent - 100_000,
48+
upper = originalMessageDateSent - 10_000
49+
)
50+
51+
frames += ChatItem(
52+
chatId = StandardFrames.chatAlice.chat!!.id,
53+
authorId = StandardFrames.recipientAlice.recipient!!.id,
54+
dateSent = dateSent,
55+
incoming = ChatItem.IncomingMessageDetails(
56+
dateReceived = dateSent - 10,
57+
dateServerSent = dateSent - 1,
58+
read = someBoolean(),
59+
sealedSender = someBoolean()
60+
),
61+
directStoryReplyMessage = DirectStoryReplyMessage(
62+
textReply = DirectStoryReplyMessage.TextReply(
63+
text = Text(
64+
body = some(Generators.textBody())
65+
)
66+
)
67+
)
68+
)
69+
}
70+
}
71+
72+
frames += Frame(
73+
chatItem = ChatItem(
74+
chatId = StandardFrames.chatAlice.chat!!.id,
75+
authorId = StandardFrames.recipientAlice.recipient!!.id,
76+
dateSent = originalMessageDateSent,
77+
incoming = ChatItem.IncomingMessageDetails(
78+
dateReceived = originalMessageDateSent - 10,
79+
dateServerSent = originalMessageDateSent - 1,
80+
read = someBoolean(),
81+
sealedSender = someBoolean()
82+
),
83+
revisions = some(revisionGenerator),
84+
directStoryReplyMessage = DirectStoryReplyMessage(
85+
textReply = someOneOf(textReply),
86+
emoji = someOneOf(emoji),
87+
reactions = some(Generators.reactions(2, StandardFrames.recipientSelf.recipient!!, StandardFrames.recipientAlice.recipient))
88+
)
89+
)
90+
)
91+
}
92+
}
689 Bytes
Binary file not shown.
Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
// This file was auto-generated! It's only meant to show you what's in the .binproto. Do not edit!
2+
3+
BackupInfo {
4+
backupTimeMs = 1715636551000
5+
currentAppVersion = "FooClient 2.0.0"
6+
firstAppVersion = "FooClient 1.0.0"
7+
mediaRootBackupKey = <8fba3ce1946b78a4ca0d9229ddb050a12702072309d6574ae12451269e5fdbb2>
8+
version = 1
9+
}
10+
11+
Frame {
12+
account = AccountData {
13+
accountSettings = AccountSettings {
14+
customChatColors = [
15+
CustomChatColor {
16+
id = 1
17+
solid = -16777216
18+
},
19+
CustomChatColor {
20+
id = 2
21+
solid = -65536
22+
},
23+
CustomChatColor {
24+
id = 3
25+
solid = -16711936
26+
}
27+
]
28+
displayBadgesOnProfile = true
29+
hasCompletedUsernameOnboarding = true
30+
hasSeenGroupStoryEducationSheet = true
31+
hasSetMyStoriesPrivacy = true
32+
hasViewedOnboardingStory = true
33+
keepMutedChatsArchived = true
34+
linkPreviews = true
35+
notDiscoverableByPhoneNumber = true
36+
phoneNumberSharingMode = PhoneNumberSharingMode.NOBODY
37+
preferContactAvatars = true
38+
preferredReactionEmoji = [
39+
"a",
40+
"b",
41+
"c"
42+
]
43+
readReceipts = true
44+
sealedSenderIndicators = true
45+
storiesDisabled = true
46+
storyViewReceiptsEnabled = true
47+
typingIndicators = true
48+
universalExpireTimerSeconds = 3600
49+
}
50+
avatarUrlPath = ""
51+
donationSubscriberData = SubscriberData {
52+
currencyCode = "USD"
53+
manuallyCancelled = true
54+
subscriberId = <ecbb68c734331a2ea333cda747c98c4553652261582b4fce5ae0dea84dce6519>
55+
}
56+
familyName = "Fett"
57+
givenName = "Boba"
58+
profileKey = <610291abedc34249489da39a31c9a5cd99cdd26ff58732e268e357ee0075d9d8>
59+
username = "boba_fett.66"
60+
usernameLink = UsernameLink {
61+
color = Color.OLIVE
62+
entropy = <65675c73d00eb01005e3bb7c4a47f296cb6554f78981238815e915d824fd2e93>
63+
serverId = <61c101a200d5421789c20518d8497af0>
64+
}
65+
}
66+
}
67+
68+
Frame {
69+
recipient = Recipient {
70+
id = 1
71+
self = Self {}
72+
}
73+
}
74+
75+
Frame {
76+
recipient = Recipient {
77+
id = 2
78+
releaseNotes = ReleaseNotes {}
79+
}
80+
}
81+
82+
Frame {
83+
recipient = Recipient {
84+
distributionList = DistributionListItem {
85+
distributionId = <00000000000000000000000000000000>
86+
distributionList = DistributionList {
87+
name = ""
88+
privacyMode = PrivacyMode.ALL
89+
}
90+
}
91+
id = 3
92+
}
93+
}
94+
95+
Frame {
96+
recipient = Recipient {
97+
contact = Contact {
98+
aci = <000a11ce000040008000000000000001>
99+
e164 = 16105550101
100+
identityKey = <05ea7585ab4f6de1913af6059f69b50ad26c55af2779e31bde58dec8ba165e164e>
101+
identityState = IdentityState.DEFAULT
102+
note = ""
103+
pni = <000a11ce000040008000000000000002>
104+
profileFamilyName = "Smith"
105+
profileGivenName = "Alice"
106+
profileKey = <d75d75d75d75d75d75d75d75d75d75d75d75d75d75d75d75d75d75d75d75d75d>
107+
registered = Registered {}
108+
visibility = Visibility.VISIBLE
109+
}
110+
id = 4
111+
}
112+
}
113+
114+
Frame {
115+
chat = Chat {
116+
expireTimerVersion = 1
117+
id = 2
118+
recipientId = 4
119+
}
120+
}
121+
122+
Frame {
123+
chatItem = ChatItem {
124+
authorId = 4
125+
chatId = 2
126+
dateSent = 1683705884536
127+
directStoryReplyMessage = DirectStoryReplyMessage {
128+
textReply = TextReply {
129+
text = Text {
130+
body = "ut cubilia justo congue"
131+
}
132+
}
133+
}
134+
incoming = IncomingMessageDetails {
135+
dateReceived = 1683705884526
136+
dateServerSent = 1683705884535
137+
read = true
138+
sealedSender = true
139+
}
140+
revisions = [
141+
ChatItem {
142+
authorId = 4
143+
chatId = 2
144+
dateSent = 1683705825565
145+
directStoryReplyMessage = DirectStoryReplyMessage {
146+
textReply = TextReply {
147+
text = Text {
148+
body = "dicat vituperata saperet inimicus ridens labores consectetur singulis dui"
149+
}
150+
}
151+
}
152+
incoming = IncomingMessageDetails {
153+
dateReceived = 1683705825555
154+
dateServerSent = 1683705825564
155+
read = true
156+
sealedSender = true
157+
}
158+
}
159+
]
160+
}
161+
}
1.01 KB
Binary file not shown.

0 commit comments

Comments
 (0)