mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-25 19:29:54 +01:00
GV2 Update message description.
This commit is contained in:
@@ -14,6 +14,7 @@ import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.signal.storageservice.protos.groups.AccessControl;
|
||||
import org.signal.storageservice.protos.groups.Member;
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedGroup;
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedGroupChange;
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedMember;
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedModifyMemberRole;
|
||||
@@ -491,6 +492,84 @@ public final class GroupsV2UpdateMessageProducerTest {
|
||||
"Alice changed who can edit group membership to \"All members\".")));
|
||||
}
|
||||
|
||||
// Group state without a change record
|
||||
|
||||
@Test
|
||||
public void you_created_a_group() {
|
||||
DecryptedGroup group = newGroupBy(you, 0)
|
||||
.build();
|
||||
|
||||
assertThat(producer.describeNewGroup(group), is("You created the group."));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void alice_created_a_group() {
|
||||
DecryptedGroup group = newGroupBy(alice, 0)
|
||||
.member(you)
|
||||
.build();
|
||||
|
||||
assertThat(producer.describeNewGroup(group), is("Alice added you to the group."));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void alice_created_a_group_above_zero() {
|
||||
DecryptedGroup group = newGroupBy(alice, 1)
|
||||
.member(you)
|
||||
.build();
|
||||
|
||||
assertThat(producer.describeNewGroup(group), is("You joined the group."));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void you_were_invited_to_a_group() {
|
||||
DecryptedGroup group = newGroupBy(alice, 0)
|
||||
.invite(bob, you)
|
||||
.build();
|
||||
|
||||
assertThat(producer.describeNewGroup(group), is("Bob invited you to the group."));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void describe_a_group_you_are_not_in() {
|
||||
DecryptedGroup group = newGroupBy(alice, 1)
|
||||
.build();
|
||||
|
||||
assertThat(producer.describeNewGroup(group), is("Group updated."));
|
||||
}
|
||||
|
||||
private GroupStateBuilder newGroupBy(UUID foundingMember, int revision) {
|
||||
return new GroupStateBuilder(foundingMember, revision);
|
||||
}
|
||||
|
||||
private static class GroupStateBuilder {
|
||||
|
||||
private final DecryptedGroup.Builder builder;
|
||||
|
||||
GroupStateBuilder(@NonNull UUID foundingMember, int version) {
|
||||
builder = DecryptedGroup.newBuilder()
|
||||
.setVersion(version)
|
||||
.addMembers(DecryptedMember.newBuilder()
|
||||
.setUuid(UuidUtil.toByteString(foundingMember)));
|
||||
}
|
||||
|
||||
GroupStateBuilder invite(@NonNull UUID inviter, @NonNull UUID invitee) {
|
||||
builder.addPendingMembers(DecryptedPendingMember.newBuilder()
|
||||
.setUuid(UuidUtil.toByteString(invitee))
|
||||
.setAddedByUuid(UuidUtil.toByteString(inviter)));
|
||||
return this;
|
||||
}
|
||||
|
||||
GroupStateBuilder member(@NonNull UUID member) {
|
||||
builder.addMembers(DecryptedMember.newBuilder()
|
||||
.setUuid(UuidUtil.toByteString(member)));
|
||||
return this;
|
||||
}
|
||||
|
||||
public DecryptedGroup build() {
|
||||
return builder.build();
|
||||
}
|
||||
}
|
||||
|
||||
private static class ChangeBuilder {
|
||||
|
||||
private final DecryptedGroupChange.Builder builder;
|
||||
|
||||
Reference in New Issue
Block a user