mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-19 08:09:12 +01:00
Update and refactor storage service syncing.
Switched to proto3, updated protos, and generally refactored things to make it easier to add new storage record types.
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package org.thoughtcrime.securesms.testutil;
|
||||
|
||||
import com.annimon.stream.Stream;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
import org.thoughtcrime.securesms.util.Conversions;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public final class TestHelpers {
|
||||
|
||||
private TestHelpers() {}
|
||||
|
||||
|
||||
public static byte[] byteArray(int a) {
|
||||
return Conversions.intToByteArray(a);
|
||||
}
|
||||
|
||||
public static List<byte[]> byteListOf(int... vals) {
|
||||
List<byte[]> list = new ArrayList<>(vals.length);
|
||||
|
||||
for (int i = 0; i < vals.length; i++) {
|
||||
list.add(Conversions.intToByteArray(vals[i]));
|
||||
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public static <E> Set<E> setOf(E... values) {
|
||||
return Sets.newHashSet(values);
|
||||
}
|
||||
|
||||
public static void assertByteListEquals(List<byte[]> a, List<byte[]> b) {
|
||||
assertEquals(a.size(), b.size());
|
||||
|
||||
List<ByteBuffer> aBuffer = Stream.of(a).map(ByteBuffer::wrap).toList();
|
||||
List<ByteBuffer> bBuffer = Stream.of(b).map(ByteBuffer::wrap).toList();
|
||||
|
||||
assertTrue(aBuffer.containsAll(bBuffer));
|
||||
}
|
||||
|
||||
public static <E> void assertContentsEqual(Collection<E> a, Collection<E> b) {
|
||||
assertEquals(a.size(), b.size());
|
||||
assertTrue(a.containsAll(b));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user