mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-28 05:35:44 +00:00
Renamed database classes to table classes.
Because they're not databases. They're tables.
This commit is contained in:
committed by
Cody Henthorne
parent
b190f9495a
commit
7949996c5c
@@ -23,7 +23,7 @@ import org.robolectric.annotation.Config
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.crypto.IdentityKeyUtil
|
||||
import org.thoughtcrime.securesms.crypto.storage.SignalIdentityKeyStore
|
||||
import org.thoughtcrime.securesms.database.IdentityDatabase
|
||||
import org.thoughtcrime.securesms.database.IdentityTable
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabaseTestUtils
|
||||
import org.thoughtcrime.securesms.database.model.IdentityRecord
|
||||
import org.thoughtcrime.securesms.recipients.Recipient
|
||||
@@ -90,7 +90,7 @@ class SafetyNumberRepositoryTest {
|
||||
val record = IdentityRecord(
|
||||
recipientId = recipient.id,
|
||||
identityKey = IdentityKeyUtil.generateIdentityKeyPair().publicKey,
|
||||
verifiedStatus = IdentityDatabase.VerifiedStatus.DEFAULT,
|
||||
verifiedStatus = IdentityTable.VerifiedStatus.DEFAULT,
|
||||
firstUse = false,
|
||||
timestamp = 0,
|
||||
nonblockingApproval = false
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.thoughtcrime.securesms.conversationlist.model.ConversationFilter;
|
||||
import org.thoughtcrime.securesms.conversationlist.model.ConversationReader;
|
||||
import org.thoughtcrime.securesms.database.DatabaseObserver;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||
import org.thoughtcrime.securesms.database.ThreadTable;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -45,13 +45,13 @@ public class UnarchivedConversationListDataSourceTest {
|
||||
|
||||
private ConversationListDataSource.UnarchivedConversationListDataSource testSubject;
|
||||
|
||||
private ThreadDatabase threadDatabase;
|
||||
private ThreadTable threadTable;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
threadDatabase = mock(ThreadDatabase.class);
|
||||
threadTable = mock(ThreadTable.class);
|
||||
|
||||
when(SignalDatabase.threads()).thenReturn(threadDatabase);
|
||||
when(SignalDatabase.threads()).thenReturn(threadTable);
|
||||
when(ApplicationDependencies.getDatabaseObserver()).thenReturn(mock(DatabaseObserver.class));
|
||||
|
||||
testSubject = new ConversationListDataSource.UnarchivedConversationListDataSource(ConversationFilter.OFF);
|
||||
@@ -74,7 +74,7 @@ public class UnarchivedConversationListDataSourceTest {
|
||||
@Test
|
||||
public void givenArchivedConversations_whenIGetTotalCount_thenIExpectOne() {
|
||||
// GIVEN
|
||||
when(threadDatabase.getArchivedConversationListCount(ConversationFilter.OFF)).thenReturn(12);
|
||||
when(threadTable.getArchivedConversationListCount(ConversationFilter.OFF)).thenReturn(12);
|
||||
|
||||
// WHEN
|
||||
int result = testSubject.getTotalCount();
|
||||
@@ -91,9 +91,9 @@ public class UnarchivedConversationListDataSourceTest {
|
||||
@Test
|
||||
public void givenSinglePinnedAndArchivedConversations_whenIGetTotalCount_thenIExpectThree() {
|
||||
// GIVEN
|
||||
when(threadDatabase.getPinnedConversationListCount(ConversationFilter.OFF)).thenReturn(1);
|
||||
when(threadDatabase.getUnarchivedConversationListCount(ConversationFilter.OFF)).thenReturn(1);
|
||||
when(threadDatabase.getArchivedConversationListCount(ConversationFilter.OFF)).thenReturn(12);
|
||||
when(threadTable.getPinnedConversationListCount(ConversationFilter.OFF)).thenReturn(1);
|
||||
when(threadTable.getUnarchivedConversationListCount(ConversationFilter.OFF)).thenReturn(1);
|
||||
when(threadTable.getArchivedConversationListCount(ConversationFilter.OFF)).thenReturn(12);
|
||||
|
||||
// WHEN
|
||||
int result = testSubject.getTotalCount();
|
||||
@@ -110,8 +110,8 @@ public class UnarchivedConversationListDataSourceTest {
|
||||
@Test
|
||||
public void givenSingleUnpinnedAndArchivedConversations_whenIGetTotalCount_thenIExpectTwo() {
|
||||
// GIVEN
|
||||
when(threadDatabase.getUnarchivedConversationListCount(ConversationFilter.OFF)).thenReturn(1);
|
||||
when(threadDatabase.getArchivedConversationListCount(ConversationFilter.OFF)).thenReturn(12);
|
||||
when(threadTable.getUnarchivedConversationListCount(ConversationFilter.OFF)).thenReturn(1);
|
||||
when(threadTable.getArchivedConversationListCount(ConversationFilter.OFF)).thenReturn(12);
|
||||
|
||||
// WHEN
|
||||
int result = testSubject.getTotalCount();
|
||||
@@ -128,8 +128,8 @@ public class UnarchivedConversationListDataSourceTest {
|
||||
@Test
|
||||
public void givenSinglePinnedAndSingleUnpinned_whenIGetTotalCount_thenIExpectFour() {
|
||||
// GIVEN
|
||||
when(threadDatabase.getPinnedConversationListCount(ConversationFilter.OFF)).thenReturn(1);
|
||||
when(threadDatabase.getUnarchivedConversationListCount(ConversationFilter.OFF)).thenReturn(2);
|
||||
when(threadTable.getPinnedConversationListCount(ConversationFilter.OFF)).thenReturn(1);
|
||||
when(threadTable.getUnarchivedConversationListCount(ConversationFilter.OFF)).thenReturn(2);
|
||||
|
||||
// WHEN
|
||||
int result = testSubject.getTotalCount();
|
||||
@@ -152,8 +152,8 @@ public class UnarchivedConversationListDataSourceTest {
|
||||
Cursor cursor = testSubject.getCursor(0, 100);
|
||||
|
||||
// THEN
|
||||
verify(threadDatabase).getUnarchivedConversationList(ConversationFilter.OFF, true, 0, 100);
|
||||
verify(threadDatabase).getUnarchivedConversationList(ConversationFilter.OFF, false, 0, 100);
|
||||
verify(threadTable).getUnarchivedConversationList(ConversationFilter.OFF, true, 0, 100);
|
||||
verify(threadTable).getUnarchivedConversationList(ConversationFilter.OFF, false, 0, 100);
|
||||
assertEquals(0, cursor.getCount());
|
||||
}
|
||||
|
||||
@@ -161,15 +161,15 @@ public class UnarchivedConversationListDataSourceTest {
|
||||
public void givenArchivedConversations_whenIGetCursor_thenIExpectOne() {
|
||||
// GIVEN
|
||||
setupThreadDatabaseCursors(0, 0);
|
||||
when(threadDatabase.getArchivedConversationListCount(ConversationFilter.OFF)).thenReturn(12);
|
||||
when(threadTable.getArchivedConversationListCount(ConversationFilter.OFF)).thenReturn(12);
|
||||
testSubject.getTotalCount();
|
||||
|
||||
// WHEN
|
||||
Cursor cursor = testSubject.getCursor(0, 100);
|
||||
|
||||
// THEN
|
||||
verify(threadDatabase).getUnarchivedConversationList(ConversationFilter.OFF, true, 0, 100);
|
||||
verify(threadDatabase).getUnarchivedConversationList(ConversationFilter.OFF, false, 0, 100);
|
||||
verify(threadTable).getUnarchivedConversationList(ConversationFilter.OFF, true, 0, 100);
|
||||
verify(threadTable).getUnarchivedConversationList(ConversationFilter.OFF, false, 0, 100);
|
||||
assertEquals(1, cursor.getCount());
|
||||
}
|
||||
|
||||
@@ -177,17 +177,17 @@ public class UnarchivedConversationListDataSourceTest {
|
||||
public void givenSinglePinnedAndArchivedConversations_whenIGetCursor_thenIExpectThree() {
|
||||
// GIVEN
|
||||
setupThreadDatabaseCursors(1, 0);
|
||||
when(threadDatabase.getPinnedConversationListCount(ConversationFilter.OFF)).thenReturn(1);
|
||||
when(threadDatabase.getUnarchivedConversationListCount(ConversationFilter.OFF)).thenReturn(1);
|
||||
when(threadDatabase.getArchivedConversationListCount(ConversationFilter.OFF)).thenReturn(12);
|
||||
when(threadTable.getPinnedConversationListCount(ConversationFilter.OFF)).thenReturn(1);
|
||||
when(threadTable.getUnarchivedConversationListCount(ConversationFilter.OFF)).thenReturn(1);
|
||||
when(threadTable.getArchivedConversationListCount(ConversationFilter.OFF)).thenReturn(12);
|
||||
testSubject.getTotalCount();
|
||||
|
||||
// WHEN
|
||||
Cursor cursor = testSubject.getCursor(0, 100);
|
||||
|
||||
// THEN
|
||||
verify(threadDatabase).getUnarchivedConversationList(ConversationFilter.OFF, true, 0, 99);
|
||||
verify(threadDatabase).getUnarchivedConversationList(ConversationFilter.OFF, false, 0, 98);
|
||||
verify(threadTable).getUnarchivedConversationList(ConversationFilter.OFF, true, 0, 99);
|
||||
verify(threadTable).getUnarchivedConversationList(ConversationFilter.OFF, false, 0, 98);
|
||||
assertEquals(3, cursor.getCount());
|
||||
}
|
||||
|
||||
@@ -195,16 +195,16 @@ public class UnarchivedConversationListDataSourceTest {
|
||||
public void givenSingleUnpinnedAndArchivedConversations_whenIGetCursor_thenIExpectTwo() {
|
||||
// GIVEN
|
||||
setupThreadDatabaseCursors(0, 1);
|
||||
when(threadDatabase.getUnarchivedConversationListCount(ConversationFilter.OFF)).thenReturn(1);
|
||||
when(threadDatabase.getArchivedConversationListCount(ConversationFilter.OFF)).thenReturn(12);
|
||||
when(threadTable.getUnarchivedConversationListCount(ConversationFilter.OFF)).thenReturn(1);
|
||||
when(threadTable.getArchivedConversationListCount(ConversationFilter.OFF)).thenReturn(12);
|
||||
testSubject.getTotalCount();
|
||||
|
||||
// WHEN
|
||||
Cursor cursor = testSubject.getCursor(0, 100);
|
||||
|
||||
// THEN
|
||||
verify(threadDatabase).getUnarchivedConversationList(ConversationFilter.OFF, true, 0, 100);
|
||||
verify(threadDatabase).getUnarchivedConversationList(ConversationFilter.OFF, false, 0, 100);
|
||||
verify(threadTable).getUnarchivedConversationList(ConversationFilter.OFF, true, 0, 100);
|
||||
verify(threadTable).getUnarchivedConversationList(ConversationFilter.OFF, false, 0, 100);
|
||||
assertEquals(2, cursor.getCount());
|
||||
}
|
||||
|
||||
@@ -212,16 +212,16 @@ public class UnarchivedConversationListDataSourceTest {
|
||||
public void givenSinglePinnedAndSingleUnpinned_whenIGetCursor_thenIExpectFour() {
|
||||
// GIVEN
|
||||
setupThreadDatabaseCursors(1, 1);
|
||||
when(threadDatabase.getPinnedConversationListCount(ConversationFilter.OFF)).thenReturn(1);
|
||||
when(threadDatabase.getUnarchivedConversationListCount(ConversationFilter.OFF)).thenReturn(2);
|
||||
when(threadTable.getPinnedConversationListCount(ConversationFilter.OFF)).thenReturn(1);
|
||||
when(threadTable.getUnarchivedConversationListCount(ConversationFilter.OFF)).thenReturn(2);
|
||||
testSubject.getTotalCount();
|
||||
|
||||
// WHEN
|
||||
Cursor cursor = testSubject.getCursor(0, 100);
|
||||
|
||||
// THEN
|
||||
verify(threadDatabase).getUnarchivedConversationList(ConversationFilter.OFF, true, 0, 99);
|
||||
verify(threadDatabase).getUnarchivedConversationList(ConversationFilter.OFF, false, 0, 97);
|
||||
verify(threadTable).getUnarchivedConversationList(ConversationFilter.OFF, true, 0, 99);
|
||||
verify(threadTable).getUnarchivedConversationList(ConversationFilter.OFF, false, 0, 97);
|
||||
assertEquals(4, cursor.getCount());
|
||||
}
|
||||
|
||||
@@ -229,16 +229,16 @@ public class UnarchivedConversationListDataSourceTest {
|
||||
public void givenLoadingSecondPage_whenIGetCursor_thenIExpectProperOffsetAndCursorCount() {
|
||||
// GIVEN
|
||||
setupThreadDatabaseCursors(0, 100);
|
||||
when(threadDatabase.getPinnedConversationListCount(ConversationFilter.OFF)).thenReturn(4);
|
||||
when(threadDatabase.getUnarchivedConversationListCount(ConversationFilter.OFF)).thenReturn(104);
|
||||
when(threadTable.getPinnedConversationListCount(ConversationFilter.OFF)).thenReturn(4);
|
||||
when(threadTable.getUnarchivedConversationListCount(ConversationFilter.OFF)).thenReturn(104);
|
||||
testSubject.getTotalCount();
|
||||
|
||||
// WHEN
|
||||
Cursor cursor = testSubject.getCursor(50, 100);
|
||||
|
||||
// THEN
|
||||
verify(threadDatabase).getUnarchivedConversationList(ConversationFilter.OFF, true, 50, 100);
|
||||
verify(threadDatabase).getUnarchivedConversationList(ConversationFilter.OFF, false, 44, 100);
|
||||
verify(threadTable).getUnarchivedConversationList(ConversationFilter.OFF, true, 50, 100);
|
||||
verify(threadTable).getUnarchivedConversationList(ConversationFilter.OFF, false, 44, 100);
|
||||
assertEquals(100, cursor.getCount());
|
||||
}
|
||||
|
||||
@@ -246,17 +246,17 @@ public class UnarchivedConversationListDataSourceTest {
|
||||
public void givenHasArchivedAndLoadingLastPage_whenIGetCursor_thenIExpectProperOffsetAndCursorCount() {
|
||||
// GIVEN
|
||||
setupThreadDatabaseCursors(0, 99);
|
||||
when(threadDatabase.getPinnedConversationListCount(ConversationFilter.OFF)).thenReturn(4);
|
||||
when(threadDatabase.getUnarchivedConversationListCount(ConversationFilter.OFF)).thenReturn(103);
|
||||
when(threadDatabase.getArchivedConversationListCount(ConversationFilter.OFF)).thenReturn(12);
|
||||
when(threadTable.getPinnedConversationListCount(ConversationFilter.OFF)).thenReturn(4);
|
||||
when(threadTable.getUnarchivedConversationListCount(ConversationFilter.OFF)).thenReturn(103);
|
||||
when(threadTable.getArchivedConversationListCount(ConversationFilter.OFF)).thenReturn(12);
|
||||
testSubject.getTotalCount();
|
||||
|
||||
// WHEN
|
||||
Cursor cursor = testSubject.getCursor(50, 100);
|
||||
|
||||
// THEN
|
||||
verify(threadDatabase).getUnarchivedConversationList(ConversationFilter.OFF, true, 50, 100);
|
||||
verify(threadDatabase).getUnarchivedConversationList(ConversationFilter.OFF, false, 44, 100);
|
||||
verify(threadTable).getUnarchivedConversationList(ConversationFilter.OFF, true, 50, 100);
|
||||
verify(threadTable).getUnarchivedConversationList(ConversationFilter.OFF, false, 44, 100);
|
||||
assertEquals(100, cursor.getCount());
|
||||
|
||||
cursor.moveToLast();
|
||||
@@ -268,9 +268,9 @@ public class UnarchivedConversationListDataSourceTest {
|
||||
// GIVEN
|
||||
ConversationListDataSource.UnarchivedConversationListDataSource testSubject = new ConversationListDataSource.UnarchivedConversationListDataSource(ConversationFilter.UNREAD);
|
||||
setupThreadDatabaseCursors(0, 3);
|
||||
when(threadDatabase.getPinnedConversationListCount(ConversationFilter.UNREAD)).thenReturn(0);
|
||||
when(threadDatabase.getUnarchivedConversationListCount(ConversationFilter.UNREAD)).thenReturn(3);
|
||||
when(threadDatabase.getArchivedConversationListCount(ConversationFilter.UNREAD)).thenReturn(0);
|
||||
when(threadTable.getPinnedConversationListCount(ConversationFilter.UNREAD)).thenReturn(0);
|
||||
when(threadTable.getUnarchivedConversationListCount(ConversationFilter.UNREAD)).thenReturn(3);
|
||||
when(threadTable.getArchivedConversationListCount(ConversationFilter.UNREAD)).thenReturn(0);
|
||||
testSubject.getTotalCount();
|
||||
|
||||
// WHEN
|
||||
@@ -292,7 +292,7 @@ public class UnarchivedConversationListDataSourceTest {
|
||||
Cursor unpinnedCursor = mock(Cursor.class);
|
||||
when(unpinnedCursor.getCount()).thenReturn(unpinned);
|
||||
|
||||
when(threadDatabase.getUnarchivedConversationList(any(), eq(true), anyLong(), anyLong())).thenReturn(pinnedCursor);
|
||||
when(threadDatabase.getUnarchivedConversationList(any(), eq(false), anyLong(), anyLong())).thenReturn(unpinnedCursor);
|
||||
when(threadTable.getUnarchivedConversationList(any(), eq(true), anyLong(), anyLong())).thenReturn(pinnedCursor);
|
||||
when(threadTable.getUnarchivedConversationList(any(), eq(false), anyLong(), anyLong())).thenReturn(unpinnedCursor);
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import org.mockito.Mockito.`when`
|
||||
import org.signal.libsignal.protocol.IdentityKey
|
||||
import org.signal.libsignal.protocol.SignalProtocolAddress
|
||||
import org.signal.libsignal.protocol.ecc.ECPublicKey
|
||||
import org.thoughtcrime.securesms.database.IdentityDatabase
|
||||
import org.thoughtcrime.securesms.database.IdentityTable
|
||||
import org.thoughtcrime.securesms.database.model.IdentityStoreRecord
|
||||
import org.whispersystems.signalservice.test.LibSignalLibraryUtil.assumeLibSignalSupportedOnOS
|
||||
|
||||
@@ -28,7 +28,7 @@ class SignalBaseIdentityKeyStoreTest {
|
||||
|
||||
@Test
|
||||
fun `getIdentity() hits disk on first retrieve but not the second`() {
|
||||
val mockDb = mock(IdentityDatabase::class.java)
|
||||
val mockDb = mock(IdentityTable::class.java)
|
||||
val subject = SignalBaseIdentityKeyStore(mock(Context::class.java), mockDb)
|
||||
val identityKey = IdentityKey(ECPublicKey.fromPublicKeyBytes(ByteArray(32)))
|
||||
val record = mockRecord(ADDRESS, identityKey)
|
||||
@@ -44,7 +44,7 @@ class SignalBaseIdentityKeyStoreTest {
|
||||
|
||||
@Test
|
||||
fun `invalidate() evicts cache entry`() {
|
||||
val mockDb = mock(IdentityDatabase::class.java)
|
||||
val mockDb = mock(IdentityTable::class.java)
|
||||
val subject = SignalBaseIdentityKeyStore(mock(Context::class.java), mockDb)
|
||||
val identityKey = IdentityKey(ECPublicKey.fromPublicKeyBytes(ByteArray(32)))
|
||||
val record = mockRecord(ADDRESS, identityKey)
|
||||
@@ -64,7 +64,7 @@ class SignalBaseIdentityKeyStoreTest {
|
||||
return IdentityStoreRecord(
|
||||
addressName = addressName,
|
||||
identityKey = identityKey,
|
||||
verifiedStatus = IdentityDatabase.VerifiedStatus.DEFAULT,
|
||||
verifiedStatus = IdentityTable.VerifiedStatus.DEFAULT,
|
||||
firstUse = false,
|
||||
timestamp = 1,
|
||||
nonblockingApproval = true
|
||||
|
||||
@@ -9,7 +9,7 @@ public class AttachmentDatabaseTransformPropertiesTest {
|
||||
|
||||
@Test
|
||||
public void transformProperties_verifyStructure() {
|
||||
AttachmentDatabase.TransformProperties properties = AttachmentDatabase.TransformProperties.empty();
|
||||
AttachmentTable.TransformProperties properties = AttachmentTable.TransformProperties.empty();
|
||||
assertEquals("Added transform property, need to confirm default behavior for pre-existing payloads in database",
|
||||
"{\"skipTransform\":false,\"videoTrim\":false,\"videoTrimStartTimeUs\":0,\"videoTrimEndTimeUs\":0,\"sentMediaQuality\":0,\"videoEdited\":false}",
|
||||
properties.serialize());
|
||||
@@ -19,7 +19,7 @@ public class AttachmentDatabaseTransformPropertiesTest {
|
||||
public void transformProperties_verifyMissingSentMediaQualityDefaultBehavior() {
|
||||
String json = "{\"skipTransform\":false,\"videoTrim\":false,\"videoTrimStartTimeUs\":0,\"videoTrimEndTimeUs\":0,\"videoEdited\":false}";
|
||||
|
||||
AttachmentDatabase.TransformProperties properties = AttachmentDatabase.TransformProperties.parse(json);
|
||||
AttachmentTable.TransformProperties properties = AttachmentTable.TransformProperties.parse(json);
|
||||
|
||||
assertEquals(0, properties.getSentMediaQuality());
|
||||
assertEquals(SentMediaQuality.STANDARD, SentMediaQuality.fromCode(properties.getSentMediaQuality()));
|
||||
|
||||
@@ -8,7 +8,7 @@ import org.thoughtcrime.securesms.recipients.RecipientId
|
||||
class ContactSearchSelectionBuilderTest {
|
||||
@Test(expected = IllegalStateException::class)
|
||||
fun `Given non registered and registered are false, when I build, then I expect an IllegalStateException`() {
|
||||
RecipientDatabase.ContactSearchSelection.Builder()
|
||||
RecipientTable.ContactSearchSelection.Builder()
|
||||
.withNonRegistered(false)
|
||||
.withRegistered(false)
|
||||
.build()
|
||||
@@ -16,44 +16,44 @@ class ContactSearchSelectionBuilderTest {
|
||||
|
||||
@Test
|
||||
fun `Given registered, when I build, then I expect SIGNAL_CONTACT`() {
|
||||
val result = RecipientDatabase.ContactSearchSelection.Builder()
|
||||
val result = RecipientTable.ContactSearchSelection.Builder()
|
||||
.withRegistered(true)
|
||||
.build()
|
||||
|
||||
Assert.assertTrue(result.where.contains(RecipientDatabase.ContactSearchSelection.SIGNAL_CONTACT))
|
||||
Assert.assertTrue(result.where.contains(RecipientDatabase.ContactSearchSelection.FILTER_BLOCKED))
|
||||
Assert.assertTrue(result.where.contains(RecipientDatabase.ContactSearchSelection.FILTER_HIDDEN))
|
||||
Assert.assertArrayEquals(SqlUtil.buildArgs(RecipientDatabase.RegisteredState.REGISTERED.id, 1, 0, 0), result.args)
|
||||
Assert.assertTrue(result.where.contains(RecipientTable.ContactSearchSelection.SIGNAL_CONTACT))
|
||||
Assert.assertTrue(result.where.contains(RecipientTable.ContactSearchSelection.FILTER_BLOCKED))
|
||||
Assert.assertTrue(result.where.contains(RecipientTable.ContactSearchSelection.FILTER_HIDDEN))
|
||||
Assert.assertArrayEquals(SqlUtil.buildArgs(RecipientTable.RegisteredState.REGISTERED.id, 1, 0, 0), result.args)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Given exclude id, when I build, then I expect FILTER_ID`() {
|
||||
val result = RecipientDatabase.ContactSearchSelection.Builder()
|
||||
val result = RecipientTable.ContactSearchSelection.Builder()
|
||||
.withRegistered(true)
|
||||
.excludeId(RecipientId.from(12))
|
||||
.build()
|
||||
|
||||
Assert.assertTrue(result.where.contains(RecipientDatabase.ContactSearchSelection.FILTER_ID))
|
||||
Assert.assertTrue(result.where.contains(RecipientTable.ContactSearchSelection.FILTER_ID))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Given all non group contacts, when I build, then I expect both CONTACT and FILTER_GROUP`() {
|
||||
val result = RecipientDatabase.ContactSearchSelection.Builder()
|
||||
val result = RecipientTable.ContactSearchSelection.Builder()
|
||||
.withRegistered(true)
|
||||
.withNonRegistered(true)
|
||||
.withGroups(false)
|
||||
.build()
|
||||
|
||||
Assert.assertTrue(result.where.contains(RecipientDatabase.ContactSearchSelection.SIGNAL_CONTACT))
|
||||
Assert.assertTrue(result.where.contains(RecipientTable.ContactSearchSelection.SIGNAL_CONTACT))
|
||||
Assert.assertTrue(result.where.contains(") OR ("))
|
||||
Assert.assertTrue(result.where.contains(RecipientDatabase.ContactSearchSelection.NON_SIGNAL_CONTACT))
|
||||
Assert.assertTrue(result.where.contains(RecipientDatabase.ContactSearchSelection.FILTER_GROUPS))
|
||||
Assert.assertTrue(result.where.contains(RecipientDatabase.ContactSearchSelection.FILTER_BLOCKED))
|
||||
Assert.assertTrue(result.where.contains(RecipientDatabase.ContactSearchSelection.FILTER_HIDDEN))
|
||||
Assert.assertTrue(result.where.contains(RecipientTable.ContactSearchSelection.NON_SIGNAL_CONTACT))
|
||||
Assert.assertTrue(result.where.contains(RecipientTable.ContactSearchSelection.FILTER_GROUPS))
|
||||
Assert.assertTrue(result.where.contains(RecipientTable.ContactSearchSelection.FILTER_BLOCKED))
|
||||
Assert.assertTrue(result.where.contains(RecipientTable.ContactSearchSelection.FILTER_HIDDEN))
|
||||
Assert.assertArrayEquals(
|
||||
SqlUtil.buildArgs(
|
||||
RecipientDatabase.RegisteredState.REGISTERED.id, 1,
|
||||
RecipientDatabase.RegisteredState.REGISTERED.id,
|
||||
RecipientTable.RegisteredState.REGISTERED.id, 1,
|
||||
RecipientTable.RegisteredState.REGISTERED.id,
|
||||
0,
|
||||
0
|
||||
),
|
||||
@@ -63,13 +63,13 @@ class ContactSearchSelectionBuilderTest {
|
||||
|
||||
@Test
|
||||
fun `Given a query, when I build, then I expect QUERY_SIGNAL_CONTACT`() {
|
||||
val result = RecipientDatabase.ContactSearchSelection.Builder()
|
||||
val result = RecipientTable.ContactSearchSelection.Builder()
|
||||
.withRegistered(true)
|
||||
.withGroups(false)
|
||||
.withSearchQuery("query")
|
||||
.build()
|
||||
|
||||
Assert.assertTrue(result.where.contains(RecipientDatabase.ContactSearchSelection.QUERY_SIGNAL_CONTACT))
|
||||
Assert.assertTrue(result.where.contains(RecipientTable.ContactSearchSelection.QUERY_SIGNAL_CONTACT))
|
||||
Assert.assertTrue(result.args.contains("query"))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ object FakeMessageRecords {
|
||||
hasData: Boolean = true,
|
||||
hasThumbnail: Boolean = true,
|
||||
contentType: String = MediaUtil.IMAGE_JPEG,
|
||||
transferProgress: Int = AttachmentDatabase.TRANSFER_PROGRESS_DONE,
|
||||
transferProgress: Int = AttachmentTable.TRANSFER_PROGRESS_DONE,
|
||||
size: Long = 0L,
|
||||
fileName: String = "",
|
||||
cdnNumber: Int = 1,
|
||||
@@ -51,7 +51,7 @@ object FakeMessageRecords {
|
||||
stickerLocator: StickerLocator? = null,
|
||||
blurHash: BlurHash? = null,
|
||||
audioHash: AudioHash? = null,
|
||||
transformProperties: AttachmentDatabase.TransformProperties? = null,
|
||||
transformProperties: AttachmentTable.TransformProperties? = null,
|
||||
displayOrder: Int = 0,
|
||||
uploadTimestamp: Long = 200
|
||||
): DatabaseAttachment {
|
||||
|
||||
@@ -99,7 +99,7 @@ class GroupChangeData(private val revision: Int, private val groupOperations: Gr
|
||||
class GroupStateTestData(private val masterKey: GroupMasterKey, private val groupOperations: GroupsV2Operations.GroupOperations? = null) {
|
||||
|
||||
var localState: DecryptedGroup? = null
|
||||
var groupRecord: Optional<GroupDatabase.GroupRecord> = Optional.empty()
|
||||
var groupRecord: Optional<GroupTable.GroupRecord> = Optional.empty()
|
||||
var serverState: DecryptedGroup? = null
|
||||
var changeSet: ChangeSet? = null
|
||||
var groupChange: GroupChange? = null
|
||||
@@ -172,9 +172,9 @@ fun groupRecord(
|
||||
avatarDigest: ByteArray = ByteArray(0),
|
||||
mms: Boolean = false,
|
||||
distributionId: DistributionId? = null
|
||||
): Optional<GroupDatabase.GroupRecord> {
|
||||
): Optional<GroupTable.GroupRecord> {
|
||||
return Optional.of(
|
||||
GroupDatabase.GroupRecord(
|
||||
GroupTable.GroupRecord(
|
||||
id,
|
||||
recipientId,
|
||||
decryptedGroup.title,
|
||||
|
||||
@@ -21,16 +21,16 @@ import org.thoughtcrime.securesms.testing.TestDatabaseUtil
|
||||
@Config(manifest = Config.NONE, application = Application::class)
|
||||
class MmsDatabaseTest {
|
||||
private lateinit var db: SQLiteDatabase
|
||||
private lateinit var mmsDatabase: MmsDatabase
|
||||
private lateinit var mmsTable: MmsTable
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
val sqlCipher = TestDatabaseUtil.inMemoryDatabase {
|
||||
execSQL(MmsDatabase.CREATE_TABLE)
|
||||
execSQL(MmsTable.CREATE_TABLE)
|
||||
}
|
||||
|
||||
db = sqlCipher.writableDatabase
|
||||
mmsDatabase = MmsDatabase(ApplicationProvider.getApplicationContext(), sqlCipher)
|
||||
mmsTable = MmsTable(ApplicationProvider.getApplicationContext(), sqlCipher)
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -41,75 +41,75 @@ class MmsDatabaseTest {
|
||||
@Test
|
||||
fun `isGroupQuitMessage when normal message, return false`() {
|
||||
val id = TestMms.insert(db, type = Types.BASE_SENDING_TYPE or Types.SECURE_MESSAGE_BIT or Types.PUSH_MESSAGE_BIT)
|
||||
assertFalse(mmsDatabase.isGroupQuitMessage(id))
|
||||
assertFalse(mmsTable.isGroupQuitMessage(id))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `isGroupQuitMessage when legacy quit message, return true`() {
|
||||
val id = TestMms.insert(db, type = Types.BASE_SENDING_TYPE or Types.SECURE_MESSAGE_BIT or Types.PUSH_MESSAGE_BIT or Types.GROUP_LEAVE_BIT)
|
||||
assertTrue(mmsDatabase.isGroupQuitMessage(id))
|
||||
assertTrue(mmsTable.isGroupQuitMessage(id))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `isGroupQuitMessage when GV2 leave update, return false`() {
|
||||
val id = TestMms.insert(db, type = Types.BASE_SENDING_TYPE or Types.SECURE_MESSAGE_BIT or Types.PUSH_MESSAGE_BIT or Types.GROUP_LEAVE_BIT or Types.GROUP_V2_BIT or Types.GROUP_UPDATE_BIT)
|
||||
assertFalse(mmsDatabase.isGroupQuitMessage(id))
|
||||
assertFalse(mmsTable.isGroupQuitMessage(id))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getLatestGroupQuitTimestamp when only normal message, return -1`() {
|
||||
TestMms.insert(db, threadId = 1, sentTimeMillis = 1, type = Types.BASE_SENDING_TYPE or Types.SECURE_MESSAGE_BIT or Types.PUSH_MESSAGE_BIT)
|
||||
assertEquals(-1, mmsDatabase.getLatestGroupQuitTimestamp(1, 4))
|
||||
assertEquals(-1, mmsTable.getLatestGroupQuitTimestamp(1, 4))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getLatestGroupQuitTimestamp when legacy quit, return message timestamp`() {
|
||||
TestMms.insert(db, threadId = 1, sentTimeMillis = 2, type = Types.BASE_SENDING_TYPE or Types.SECURE_MESSAGE_BIT or Types.PUSH_MESSAGE_BIT or Types.GROUP_LEAVE_BIT)
|
||||
assertEquals(2, mmsDatabase.getLatestGroupQuitTimestamp(1, 4))
|
||||
assertEquals(2, mmsTable.getLatestGroupQuitTimestamp(1, 4))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getLatestGroupQuitTimestamp when GV2 leave update message, return -1`() {
|
||||
TestMms.insert(db, threadId = 1, sentTimeMillis = 3, type = Types.BASE_SENDING_TYPE or Types.SECURE_MESSAGE_BIT or Types.PUSH_MESSAGE_BIT or Types.GROUP_LEAVE_BIT or Types.GROUP_V2_BIT or Types.GROUP_UPDATE_BIT)
|
||||
assertEquals(-1, mmsDatabase.getLatestGroupQuitTimestamp(1, 4))
|
||||
assertEquals(-1, mmsTable.getLatestGroupQuitTimestamp(1, 4))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Given no stories in database, when I getStoryViewState, then I expect NONE`() {
|
||||
assertEquals(StoryViewState.NONE, mmsDatabase.getStoryViewState(1))
|
||||
assertEquals(StoryViewState.NONE, mmsTable.getStoryViewState(1))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Given stories in database not in thread 1, when I getStoryViewState for thread 1, then I expect NONE`() {
|
||||
TestMms.insert(db, threadId = 2, storyType = StoryType.STORY_WITH_REPLIES)
|
||||
TestMms.insert(db, threadId = 2, storyType = StoryType.STORY_WITH_REPLIES)
|
||||
assertEquals(StoryViewState.NONE, mmsDatabase.getStoryViewState(1))
|
||||
assertEquals(StoryViewState.NONE, mmsTable.getStoryViewState(1))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Given viewed incoming stories in database, when I getStoryViewState, then I expect VIEWED`() {
|
||||
TestMms.insert(db, threadId = 1, storyType = StoryType.STORY_WITH_REPLIES, viewed = true)
|
||||
TestMms.insert(db, threadId = 1, storyType = StoryType.STORY_WITH_REPLIES, viewed = true)
|
||||
assertEquals(StoryViewState.VIEWED, mmsDatabase.getStoryViewState(1))
|
||||
assertEquals(StoryViewState.VIEWED, mmsTable.getStoryViewState(1))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Given unviewed incoming stories in database, when I getStoryViewState, then I expect UNVIEWED`() {
|
||||
TestMms.insert(db, threadId = 1, storyType = StoryType.STORY_WITH_REPLIES, viewed = false)
|
||||
TestMms.insert(db, threadId = 1, storyType = StoryType.STORY_WITH_REPLIES, viewed = false)
|
||||
assertEquals(StoryViewState.UNVIEWED, mmsDatabase.getStoryViewState(1))
|
||||
assertEquals(StoryViewState.UNVIEWED, mmsTable.getStoryViewState(1))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Given mix of viewed and unviewed incoming stories in database, when I getStoryViewState, then I expect UNVIEWED`() {
|
||||
TestMms.insert(db, threadId = 1, storyType = StoryType.STORY_WITH_REPLIES, viewed = true)
|
||||
TestMms.insert(db, threadId = 1, storyType = StoryType.STORY_WITH_REPLIES, viewed = false)
|
||||
assertEquals(StoryViewState.UNVIEWED, mmsDatabase.getStoryViewState(1))
|
||||
assertEquals(StoryViewState.UNVIEWED, mmsTable.getStoryViewState(1))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Given only outgoing story in database, when I getStoryViewState, then I expect VIEWED`() {
|
||||
TestMms.insert(db, threadId = 1, storyType = StoryType.STORY_WITH_REPLIES, type = Types.BASE_OUTBOX_TYPE)
|
||||
assertEquals(StoryViewState.VIEWED, mmsDatabase.getStoryViewState(1))
|
||||
assertEquals(StoryViewState.VIEWED, mmsTable.getStoryViewState(1))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,18 +19,18 @@ import org.thoughtcrime.securesms.testing.TestDatabaseUtil
|
||||
@Config(manifest = Config.NONE, application = Application::class)
|
||||
class MmsSmsDatabaseTest {
|
||||
|
||||
private lateinit var mmsSmsDatabase: MmsSmsDatabase
|
||||
private lateinit var mmsSmsTable: MmsSmsTable
|
||||
private lateinit var db: SQLiteDatabase
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
val sqlCipher = TestDatabaseUtil.inMemoryDatabase {
|
||||
execSQL(MmsDatabase.CREATE_TABLE)
|
||||
execSQL(SmsDatabase.CREATE_TABLE)
|
||||
execSQL(MmsTable.CREATE_TABLE)
|
||||
execSQL(SmsTable.CREATE_TABLE)
|
||||
}
|
||||
|
||||
db = sqlCipher.writableDatabase
|
||||
mmsSmsDatabase = MmsSmsDatabase(ApplicationProvider.getApplicationContext(), sqlCipher)
|
||||
mmsSmsTable = MmsSmsTable(ApplicationProvider.getApplicationContext(), sqlCipher)
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -41,20 +41,20 @@ class MmsSmsDatabaseTest {
|
||||
@Test
|
||||
fun `getConversationSnippet when single normal SMS, return SMS message id and transport as false`() {
|
||||
TestSms.insert(db)
|
||||
mmsSmsDatabase.getConversationSnippetCursor(1).use { cursor ->
|
||||
mmsSmsTable.getConversationSnippetCursor(1).use { cursor ->
|
||||
cursor.moveToFirst()
|
||||
assertEquals(1, CursorUtil.requireLong(cursor, MmsSmsColumns.ID))
|
||||
assertFalse(CursorUtil.requireBoolean(cursor, MmsSmsDatabase.TRANSPORT))
|
||||
assertFalse(CursorUtil.requireBoolean(cursor, MmsSmsTable.TRANSPORT))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getConversationSnippet when single normal MMS, return MMS message id and transport as true`() {
|
||||
TestMms.insert(db)
|
||||
mmsSmsDatabase.getConversationSnippetCursor(1).use { cursor ->
|
||||
mmsSmsTable.getConversationSnippetCursor(1).use { cursor ->
|
||||
cursor.moveToFirst()
|
||||
assertEquals(1, CursorUtil.requireLong(cursor, MmsSmsColumns.ID))
|
||||
assertTrue(CursorUtil.requireBoolean(cursor, MmsSmsDatabase.TRANSPORT))
|
||||
assertTrue(CursorUtil.requireBoolean(cursor, MmsSmsTable.TRANSPORT))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,17 +63,17 @@ class MmsSmsDatabaseTest {
|
||||
val timestamp = System.currentTimeMillis()
|
||||
|
||||
TestMms.insert(db, receivedTimestampMillis = timestamp + 2)
|
||||
mmsSmsDatabase.getConversationSnippetCursor(1).use { cursor ->
|
||||
mmsSmsTable.getConversationSnippetCursor(1).use { cursor ->
|
||||
cursor.moveToFirst()
|
||||
assertEquals(1, CursorUtil.requireLong(cursor, MmsSmsColumns.ID))
|
||||
assertTrue(CursorUtil.requireBoolean(cursor, MmsSmsDatabase.TRANSPORT))
|
||||
assertTrue(CursorUtil.requireBoolean(cursor, MmsSmsTable.TRANSPORT))
|
||||
}
|
||||
|
||||
TestSms.insert(db, receivedTimestampMillis = timestamp + 3, type = MmsSmsColumns.Types.BASE_SENDING_TYPE or MmsSmsColumns.Types.SECURE_MESSAGE_BIT or MmsSmsColumns.Types.PUSH_MESSAGE_BIT or MmsSmsColumns.Types.GROUP_V2_LEAVE_BITS)
|
||||
mmsSmsDatabase.getConversationSnippetCursor(1).use { cursor ->
|
||||
mmsSmsTable.getConversationSnippetCursor(1).use { cursor ->
|
||||
cursor.moveToFirst()
|
||||
assertEquals(1, CursorUtil.requireLong(cursor, MmsSmsColumns.ID))
|
||||
assertTrue(CursorUtil.requireBoolean(cursor, MmsSmsDatabase.TRANSPORT))
|
||||
assertTrue(CursorUtil.requireBoolean(cursor, MmsSmsTable.TRANSPORT))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,16 +37,16 @@ object RecipientDatabaseTestUtils {
|
||||
e164: String? = null,
|
||||
email: String? = null,
|
||||
groupId: GroupId? = null,
|
||||
groupType: RecipientDatabase.GroupType = RecipientDatabase.GroupType.NONE,
|
||||
groupType: RecipientTable.GroupType = RecipientTable.GroupType.NONE,
|
||||
blocked: Boolean = false,
|
||||
muteUntil: Long = -1,
|
||||
messageVibrateState: RecipientDatabase.VibrateState = RecipientDatabase.VibrateState.DEFAULT,
|
||||
callVibrateState: RecipientDatabase.VibrateState = RecipientDatabase.VibrateState.DEFAULT,
|
||||
messageVibrateState: RecipientTable.VibrateState = RecipientTable.VibrateState.DEFAULT,
|
||||
callVibrateState: RecipientTable.VibrateState = RecipientTable.VibrateState.DEFAULT,
|
||||
messageRingtone: Uri = Uri.EMPTY,
|
||||
callRingtone: Uri = Uri.EMPTY,
|
||||
defaultSubscriptionId: Int = 0,
|
||||
expireMessages: Int = 0,
|
||||
registered: RecipientDatabase.RegisteredState = RecipientDatabase.RegisteredState.REGISTERED,
|
||||
registered: RecipientTable.RegisteredState = RecipientTable.RegisteredState.REGISTERED,
|
||||
profileKey: ByteArray = Random.nextBytes(32),
|
||||
expiringProfileKeyCredential: ExpiringProfileKeyCredential? = null,
|
||||
systemProfileName: ProfileName = ProfileName.EMPTY,
|
||||
@@ -60,12 +60,12 @@ object RecipientDatabaseTestUtils {
|
||||
profileSharing: Boolean = false,
|
||||
lastProfileFetch: Long = 0L,
|
||||
notificationChannel: String? = null,
|
||||
unidentifiedAccessMode: RecipientDatabase.UnidentifiedAccessMode = RecipientDatabase.UnidentifiedAccessMode.UNKNOWN,
|
||||
unidentifiedAccessMode: RecipientTable.UnidentifiedAccessMode = RecipientTable.UnidentifiedAccessMode.UNKNOWN,
|
||||
forceSmsSelection: Boolean = false,
|
||||
capabilities: Long = 0L,
|
||||
insightBannerTier: RecipientDatabase.InsightsBannerTier = RecipientDatabase.InsightsBannerTier.NO_TIER,
|
||||
insightBannerTier: RecipientTable.InsightsBannerTier = RecipientTable.InsightsBannerTier.NO_TIER,
|
||||
storageId: ByteArray? = null,
|
||||
mentionSetting: RecipientDatabase.MentionSetting = RecipientDatabase.MentionSetting.ALWAYS_NOTIFY,
|
||||
mentionSetting: RecipientTable.MentionSetting = RecipientTable.MentionSetting.ALWAYS_NOTIFY,
|
||||
wallpaper: ChatWallpaper? = null,
|
||||
chatColors: ChatColors? = null,
|
||||
avatarColor: AvatarColor = AvatarColor.A100,
|
||||
@@ -75,7 +75,7 @@ object RecipientDatabaseTestUtils {
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
IdentityDatabase.VerifiedStatus.DEFAULT,
|
||||
IdentityTable.VerifiedStatus.DEFAULT,
|
||||
false,
|
||||
false,
|
||||
0
|
||||
@@ -129,13 +129,13 @@ object RecipientDatabaseTestUtils {
|
||||
forceSmsSelection,
|
||||
RecipientRecord.Capabilities(
|
||||
capabilities,
|
||||
Recipient.Capability.deserialize(Bitmask.read(capabilities, RecipientDatabase.Capabilities.GROUPS_V1_MIGRATION, RecipientDatabase.Capabilities.BIT_LENGTH).toInt()),
|
||||
Recipient.Capability.deserialize(Bitmask.read(capabilities, RecipientDatabase.Capabilities.SENDER_KEY, RecipientDatabase.Capabilities.BIT_LENGTH).toInt()),
|
||||
Recipient.Capability.deserialize(Bitmask.read(capabilities, RecipientDatabase.Capabilities.ANNOUNCEMENT_GROUPS, RecipientDatabase.Capabilities.BIT_LENGTH).toInt()),
|
||||
Recipient.Capability.deserialize(Bitmask.read(capabilities, RecipientDatabase.Capabilities.CHANGE_NUMBER, RecipientDatabase.Capabilities.BIT_LENGTH).toInt()),
|
||||
Recipient.Capability.deserialize(Bitmask.read(capabilities, RecipientDatabase.Capabilities.STORIES, RecipientDatabase.Capabilities.BIT_LENGTH).toInt()),
|
||||
Recipient.Capability.deserialize(Bitmask.read(capabilities, RecipientDatabase.Capabilities.GIFT_BADGES, RecipientDatabase.Capabilities.BIT_LENGTH).toInt()),
|
||||
Recipient.Capability.deserialize(Bitmask.read(capabilities, RecipientDatabase.Capabilities.PNP, RecipientDatabase.Capabilities.BIT_LENGTH).toInt()),
|
||||
Recipient.Capability.deserialize(Bitmask.read(capabilities, RecipientTable.Capabilities.GROUPS_V1_MIGRATION, RecipientTable.Capabilities.BIT_LENGTH).toInt()),
|
||||
Recipient.Capability.deserialize(Bitmask.read(capabilities, RecipientTable.Capabilities.SENDER_KEY, RecipientTable.Capabilities.BIT_LENGTH).toInt()),
|
||||
Recipient.Capability.deserialize(Bitmask.read(capabilities, RecipientTable.Capabilities.ANNOUNCEMENT_GROUPS, RecipientTable.Capabilities.BIT_LENGTH).toInt()),
|
||||
Recipient.Capability.deserialize(Bitmask.read(capabilities, RecipientTable.Capabilities.CHANGE_NUMBER, RecipientTable.Capabilities.BIT_LENGTH).toInt()),
|
||||
Recipient.Capability.deserialize(Bitmask.read(capabilities, RecipientTable.Capabilities.STORIES, RecipientTable.Capabilities.BIT_LENGTH).toInt()),
|
||||
Recipient.Capability.deserialize(Bitmask.read(capabilities, RecipientTable.Capabilities.GIFT_BADGES, RecipientTable.Capabilities.BIT_LENGTH).toInt()),
|
||||
Recipient.Capability.deserialize(Bitmask.read(capabilities, RecipientTable.Capabilities.PNP, RecipientTable.Capabilities.BIT_LENGTH).toInt()),
|
||||
),
|
||||
insightBannerTier,
|
||||
storageId,
|
||||
|
||||
@@ -20,16 +20,16 @@ import org.hamcrest.CoreMatchers.`is` as isEqual
|
||||
class SmsDatabaseTest {
|
||||
|
||||
private lateinit var db: AndroidSQLiteDatabase
|
||||
private lateinit var smsDatabase: SmsDatabase
|
||||
private lateinit var smsTable: SmsTable
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
val sqlCipher = TestDatabaseUtil.inMemoryDatabase {
|
||||
execSQL(SmsDatabase.CREATE_TABLE)
|
||||
execSQL(SmsTable.CREATE_TABLE)
|
||||
}
|
||||
|
||||
db = sqlCipher.writableDatabase
|
||||
smsDatabase = SmsDatabase(ApplicationProvider.getApplicationContext(), sqlCipher)
|
||||
smsTable = SmsTable(ApplicationProvider.getApplicationContext(), sqlCipher)
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -39,52 +39,52 @@ class SmsDatabaseTest {
|
||||
|
||||
@Test
|
||||
fun `getThreadIdForMessage when no message absent for id, return -1`() {
|
||||
assertThat(smsDatabase.getThreadIdForMessage(1), isEqual(-1))
|
||||
assertThat(smsTable.getThreadIdForMessage(1), isEqual(-1))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `getThreadIdForMessage when message present for id, return thread id`() {
|
||||
TestSms.insert(db)
|
||||
assertThat(smsDatabase.getThreadIdForMessage(1), isEqual(1))
|
||||
assertThat(smsTable.getThreadIdForMessage(1), isEqual(1))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `hasMeaningfulMessage when no messages, return false`() {
|
||||
assertFalse(smsDatabase.hasMeaningfulMessage(1))
|
||||
assertFalse(smsTable.hasMeaningfulMessage(1))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `hasMeaningfulMessage when normal message, return true`() {
|
||||
TestSms.insert(db)
|
||||
assertTrue(smsDatabase.hasMeaningfulMessage(1))
|
||||
assertTrue(smsTable.hasMeaningfulMessage(1))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `hasMeaningfulMessage when GV2 create message only, return true`() {
|
||||
TestSms.insert(db, type = MmsSmsColumns.Types.BASE_INBOX_TYPE or MmsSmsColumns.Types.SECURE_MESSAGE_BIT or MmsSmsColumns.Types.GROUP_V2_BIT or MmsSmsColumns.Types.GROUP_UPDATE_BIT)
|
||||
assertTrue(smsDatabase.hasMeaningfulMessage(1))
|
||||
assertTrue(smsTable.hasMeaningfulMessage(1))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `hasMeaningfulMessage when empty and then with ignored types, always return false`() {
|
||||
assertFalse(smsDatabase.hasMeaningfulMessage(1))
|
||||
assertFalse(smsTable.hasMeaningfulMessage(1))
|
||||
|
||||
TestSms.insert(db, type = SmsDatabase.IGNORABLE_TYPESMASK_WHEN_COUNTING)
|
||||
assertFalse(smsDatabase.hasMeaningfulMessage(1))
|
||||
TestSms.insert(db, type = SmsTable.IGNORABLE_TYPESMASK_WHEN_COUNTING)
|
||||
assertFalse(smsTable.hasMeaningfulMessage(1))
|
||||
|
||||
TestSms.insert(db, type = MmsSmsColumns.Types.PROFILE_CHANGE_TYPE)
|
||||
assertFalse(smsDatabase.hasMeaningfulMessage(1))
|
||||
assertFalse(smsTable.hasMeaningfulMessage(1))
|
||||
|
||||
TestSms.insert(db, type = MmsSmsColumns.Types.CHANGE_NUMBER_TYPE)
|
||||
assertFalse(smsDatabase.hasMeaningfulMessage(1))
|
||||
assertFalse(smsTable.hasMeaningfulMessage(1))
|
||||
|
||||
TestSms.insert(db, type = MmsSmsColumns.Types.BOOST_REQUEST_TYPE)
|
||||
assertFalse(smsDatabase.hasMeaningfulMessage(1))
|
||||
assertFalse(smsTable.hasMeaningfulMessage(1))
|
||||
|
||||
TestSms.insert(db, type = MmsSmsColumns.Types.SMS_EXPORT_TYPE)
|
||||
assertFalse(smsDatabase.hasMeaningfulMessage(1))
|
||||
assertFalse(smsTable.hasMeaningfulMessage(1))
|
||||
|
||||
TestSms.insert(db, type = MmsSmsColumns.Types.BASE_INBOX_TYPE or MmsSmsColumns.Types.GROUP_V2_LEAVE_BITS)
|
||||
assertFalse(smsDatabase.hasMeaningfulMessage(1))
|
||||
assertFalse(smsTable.hasMeaningfulMessage(1))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ object TestMms {
|
||||
subscriptionId: Int = -1,
|
||||
expiresIn: Long = 0,
|
||||
viewOnce: Boolean = false,
|
||||
distributionType: Int = ThreadDatabase.DistributionTypes.DEFAULT,
|
||||
distributionType: Int = ThreadTable.DistributionTypes.DEFAULT,
|
||||
type: Long = MmsSmsColumns.Types.BASE_INBOX_TYPE,
|
||||
unread: Boolean = false,
|
||||
viewed: Boolean = false,
|
||||
@@ -76,41 +76,41 @@ object TestMms {
|
||||
receivedTimestampMillis: Long = System.currentTimeMillis(),
|
||||
): Long {
|
||||
val contentValues = ContentValues().apply {
|
||||
put(MmsDatabase.DATE_SENT, message.sentTimeMillis)
|
||||
put(MmsDatabase.MESSAGE_TYPE, PduHeaders.MESSAGE_TYPE_SEND_REQ)
|
||||
put(MmsTable.DATE_SENT, message.sentTimeMillis)
|
||||
put(MmsTable.MESSAGE_TYPE, PduHeaders.MESSAGE_TYPE_SEND_REQ)
|
||||
|
||||
put(MmsDatabase.MESSAGE_BOX, type)
|
||||
put(MmsTable.MESSAGE_BOX, type)
|
||||
put(MmsSmsColumns.THREAD_ID, threadId)
|
||||
put(MmsSmsColumns.READ, if (unread) 0 else 1)
|
||||
put(MmsDatabase.DATE_RECEIVED, receivedTimestampMillis)
|
||||
put(MmsTable.DATE_RECEIVED, receivedTimestampMillis)
|
||||
put(MmsSmsColumns.SUBSCRIPTION_ID, message.subscriptionId)
|
||||
put(MmsSmsColumns.EXPIRES_IN, message.expiresIn)
|
||||
put(MmsDatabase.VIEW_ONCE, message.isViewOnce)
|
||||
put(MmsTable.VIEW_ONCE, message.isViewOnce)
|
||||
put(MmsSmsColumns.RECIPIENT_ID, recipientId.serialize())
|
||||
put(MmsSmsColumns.DELIVERY_RECEIPT_COUNT, 0)
|
||||
put(MmsSmsColumns.RECEIPT_TIMESTAMP, 0)
|
||||
put(MmsSmsColumns.VIEWED_RECEIPT_COUNT, if (viewed) 1 else 0)
|
||||
put(MmsDatabase.STORY_TYPE, message.storyType.code)
|
||||
put(MmsTable.STORY_TYPE, message.storyType.code)
|
||||
|
||||
put(MmsSmsColumns.BODY, body)
|
||||
put(MmsDatabase.PART_COUNT, 0)
|
||||
put(MmsDatabase.MENTIONS_SELF, 0)
|
||||
put(MmsTable.PART_COUNT, 0)
|
||||
put(MmsTable.MENTIONS_SELF, 0)
|
||||
}
|
||||
|
||||
return db.insert(MmsDatabase.TABLE_NAME, null, contentValues)
|
||||
return db.insert(MmsTable.TABLE_NAME, null, contentValues)
|
||||
}
|
||||
|
||||
fun markAsRemoteDelete(db: SQLiteDatabase, messageId: Long) {
|
||||
val values = ContentValues()
|
||||
values.put(MmsSmsColumns.REMOTE_DELETED, 1)
|
||||
values.putNull(MmsSmsColumns.BODY)
|
||||
values.putNull(MmsDatabase.QUOTE_BODY)
|
||||
values.putNull(MmsDatabase.QUOTE_AUTHOR)
|
||||
values.putNull(MmsDatabase.QUOTE_ATTACHMENT)
|
||||
values.put(MmsDatabase.QUOTE_TYPE, -1)
|
||||
values.putNull(MmsDatabase.QUOTE_ID)
|
||||
values.putNull(MmsDatabase.LINK_PREVIEWS)
|
||||
values.putNull(MmsDatabase.SHARED_CONTACTS)
|
||||
db.update(MmsDatabase.TABLE_NAME, values, Database.ID_WHERE, arrayOf(messageId.toString()))
|
||||
values.putNull(MmsTable.QUOTE_BODY)
|
||||
values.putNull(MmsTable.QUOTE_AUTHOR)
|
||||
values.putNull(MmsTable.QUOTE_ATTACHMENT)
|
||||
values.put(MmsTable.QUOTE_TYPE, -1)
|
||||
values.putNull(MmsTable.QUOTE_ID)
|
||||
values.putNull(MmsTable.LINK_PREVIEWS)
|
||||
values.putNull(MmsTable.SHARED_CONTACTS)
|
||||
db.update(MmsTable.TABLE_NAME, values, DatabaseTable.ID_WHERE, arrayOf(messageId.toString()))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,27 +62,27 @@ object TestSms {
|
||||
val values = ContentValues().apply {
|
||||
put(MmsSmsColumns.RECIPIENT_ID, message.sender.serialize())
|
||||
put(MmsSmsColumns.ADDRESS_DEVICE_ID, message.senderDeviceId)
|
||||
put(SmsDatabase.DATE_RECEIVED, message.receivedTimestampMillis)
|
||||
put(SmsDatabase.DATE_SENT, message.sentTimestampMillis)
|
||||
put(SmsTable.DATE_RECEIVED, message.receivedTimestampMillis)
|
||||
put(SmsTable.DATE_SENT, message.sentTimestampMillis)
|
||||
put(MmsSmsColumns.DATE_SERVER, message.serverTimestampMillis)
|
||||
put(SmsDatabase.PROTOCOL, message.protocol)
|
||||
put(SmsTable.PROTOCOL, message.protocol)
|
||||
put(MmsSmsColumns.READ, if (unread) 0 else 1)
|
||||
put(MmsSmsColumns.SUBSCRIPTION_ID, message.subscriptionId)
|
||||
put(MmsSmsColumns.EXPIRES_IN, message.expiresIn)
|
||||
put(MmsSmsColumns.UNIDENTIFIED, message.isUnidentified)
|
||||
|
||||
if (!TextUtils.isEmpty(message.pseudoSubject)) {
|
||||
put(SmsDatabase.SUBJECT, message.pseudoSubject)
|
||||
put(SmsTable.SUBJECT, message.pseudoSubject)
|
||||
}
|
||||
|
||||
put(SmsDatabase.REPLY_PATH_PRESENT, message.isReplyPathPresent)
|
||||
put(SmsDatabase.SERVICE_CENTER, message.serviceCenterAddress)
|
||||
put(SmsTable.REPLY_PATH_PRESENT, message.isReplyPathPresent)
|
||||
put(SmsTable.SERVICE_CENTER, message.serviceCenterAddress)
|
||||
put(MmsSmsColumns.BODY, message.messageBody)
|
||||
put(SmsDatabase.TYPE, type)
|
||||
put(SmsTable.TYPE, type)
|
||||
put(MmsSmsColumns.THREAD_ID, threadId)
|
||||
put(MmsSmsColumns.SERVER_GUID, message.serverGuid)
|
||||
}
|
||||
|
||||
return db.insert(SmsDatabase.TABLE_NAME, null, values)
|
||||
return db.insert(SmsTable.TABLE_NAME, null, values)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ import org.signal.storageservice.protos.groups.local.DecryptedGroup
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedMember
|
||||
import org.thoughtcrime.securesms.SignalStoreRule
|
||||
import org.thoughtcrime.securesms.TestZkGroupServer
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase
|
||||
import org.thoughtcrime.securesms.database.GroupStateTestData
|
||||
import org.thoughtcrime.securesms.database.GroupTable
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.member
|
||||
import org.thoughtcrime.securesms.groups.v2.GroupCandidateHelper
|
||||
import org.thoughtcrime.securesms.groups.v2.processing.GroupsV2StateProcessor
|
||||
@@ -62,7 +62,7 @@ class GroupManagerV2Test_edit {
|
||||
val others: List<DecryptedMember> = listOf(member(otherSid))
|
||||
}
|
||||
|
||||
private lateinit var groupDatabase: GroupDatabase
|
||||
private lateinit var groupTable: GroupTable
|
||||
private lateinit var groupsV2API: GroupsV2Api
|
||||
private lateinit var groupsV2Operations: GroupsV2Operations
|
||||
private lateinit var groupsV2Authorization: GroupsV2Authorization
|
||||
@@ -87,7 +87,7 @@ class GroupManagerV2Test_edit {
|
||||
|
||||
val clientZkOperations = ClientZkOperations(server.getServerPublicParams())
|
||||
|
||||
groupDatabase = mock(GroupDatabase::class.java)
|
||||
groupTable = mock(GroupTable::class.java)
|
||||
groupsV2API = mock(GroupsV2Api::class.java)
|
||||
groupsV2Operations = GroupsV2Operations(clientZkOperations, 1000)
|
||||
groupsV2Authorization = mock(GroupsV2Authorization::class.java)
|
||||
@@ -100,7 +100,7 @@ class GroupManagerV2Test_edit {
|
||||
|
||||
manager = GroupManagerV2(
|
||||
ApplicationProvider.getApplicationContext(),
|
||||
groupDatabase,
|
||||
groupTable,
|
||||
groupsV2API,
|
||||
groupsV2Operations,
|
||||
groupsV2Authorization,
|
||||
@@ -115,8 +115,8 @@ class GroupManagerV2Test_edit {
|
||||
val data = GroupStateTestData(masterKey, groupOperations)
|
||||
data.init()
|
||||
|
||||
Mockito.doReturn(data.groupRecord).`when`(groupDatabase).getGroup(groupId)
|
||||
Mockito.doReturn(data.groupRecord.get()).`when`(groupDatabase).requireGroup(groupId)
|
||||
Mockito.doReturn(data.groupRecord).`when`(groupTable).getGroup(groupId)
|
||||
Mockito.doReturn(data.groupRecord.get()).`when`(groupTable).requireGroup(groupId)
|
||||
|
||||
Mockito.doReturn(GroupManagerV2.RecipientAndThread(Recipient.UNKNOWN, 1)).`when`(sendGroupUpdateHelper).sendGroupUpdate(Mockito.eq(masterKey), Mockito.any(), Mockito.any(), Mockito.anyBoolean())
|
||||
|
||||
@@ -128,7 +128,7 @@ class GroupManagerV2Test_edit {
|
||||
}
|
||||
|
||||
private fun then(then: (DecryptedGroup) -> Unit) {
|
||||
Mockito.verify(groupDatabase).update(Mockito.eq(groupId), patchedDecryptedGroup.capture())
|
||||
Mockito.verify(groupTable).update(Mockito.eq(groupId), patchedDecryptedGroup.capture())
|
||||
then(patchedDecryptedGroup.value)
|
||||
}
|
||||
|
||||
|
||||
@@ -37,9 +37,9 @@ import org.signal.storageservice.protos.groups.local.DecryptedMember
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedString
|
||||
import org.signal.storageservice.protos.groups.local.DecryptedTimer
|
||||
import org.thoughtcrime.securesms.SignalStoreRule
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase
|
||||
import org.thoughtcrime.securesms.database.GroupStateTestData
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase
|
||||
import org.thoughtcrime.securesms.database.GroupTable
|
||||
import org.thoughtcrime.securesms.database.RecipientTable
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.DecryptedGroupV2Context
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.member
|
||||
import org.thoughtcrime.securesms.database.model.databaseprotos.requestingMember
|
||||
@@ -72,8 +72,8 @@ class GroupsV2StateProcessorTest {
|
||||
private val others: List<DecryptedMember> = listOf(member(otherSid))
|
||||
}
|
||||
|
||||
private lateinit var groupDatabase: GroupDatabase
|
||||
private lateinit var recipientDatabase: RecipientDatabase
|
||||
private lateinit var groupTable: GroupTable
|
||||
private lateinit var recipientTable: RecipientTable
|
||||
private lateinit var groupsV2API: GroupsV2Api
|
||||
private lateinit var groupsV2Authorization: GroupsV2Authorization
|
||||
private lateinit var profileAndMessageHelper: GroupsV2StateProcessor.ProfileAndMessageHelper
|
||||
@@ -88,13 +88,13 @@ class GroupsV2StateProcessorTest {
|
||||
Log.initialize(SystemOutLogger())
|
||||
SignalProtocolLoggerProvider.setProvider(CustomSignalProtocolLogger())
|
||||
|
||||
groupDatabase = mock(GroupDatabase::class.java)
|
||||
recipientDatabase = mock(RecipientDatabase::class.java)
|
||||
groupTable = mock(GroupTable::class.java)
|
||||
recipientTable = mock(RecipientTable::class.java)
|
||||
groupsV2API = mock(GroupsV2Api::class.java)
|
||||
groupsV2Authorization = mock(GroupsV2Authorization::class.java)
|
||||
profileAndMessageHelper = mock(GroupsV2StateProcessor.ProfileAndMessageHelper::class.java)
|
||||
|
||||
processor = GroupsV2StateProcessor.StateProcessorForGroup(serviceIds, ApplicationProvider.getApplicationContext(), groupDatabase, groupsV2API, groupsV2Authorization, masterKey, profileAndMessageHelper)
|
||||
processor = GroupsV2StateProcessor.StateProcessorForGroup(serviceIds, ApplicationProvider.getApplicationContext(), groupTable, groupsV2API, groupsV2Authorization, masterKey, profileAndMessageHelper)
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -105,8 +105,8 @@ class GroupsV2StateProcessorTest {
|
||||
private fun given(init: GroupStateTestData.() -> Unit) {
|
||||
val data = givenData(init)
|
||||
|
||||
doReturn(data.groupRecord).`when`(groupDatabase).getGroup(any(GroupId.V2::class.java))
|
||||
doReturn(!data.groupRecord.isPresent).`when`(groupDatabase).isUnknownGroup(any())
|
||||
doReturn(data.groupRecord).`when`(groupTable).getGroup(any(GroupId.V2::class.java))
|
||||
doReturn(!data.groupRecord.isPresent).`when`(groupTable).isUnknownGroup(any())
|
||||
|
||||
data.serverState?.let { serverState ->
|
||||
val testPartial = object : PartialDecryptedGroup(null, serverState, null, null) {
|
||||
@@ -306,7 +306,7 @@ class GroupsV2StateProcessorTest {
|
||||
apiCallParameters(2, true)
|
||||
}
|
||||
|
||||
doReturn(true).`when`(groupDatabase).isUnknownGroup(any())
|
||||
doReturn(true).`when`(groupTable).isUnknownGroup(any())
|
||||
|
||||
val result = processor.updateLocalGroupToRevision(2, 0, DecryptedGroupChange.getDefaultInstance())
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.thoughtcrime.securesms.jobmanager.migrations;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.thoughtcrime.securesms.database.MmsSmsDatabase;
|
||||
import org.thoughtcrime.securesms.database.MmsSmsTable;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.JobMigration;
|
||||
import org.thoughtcrime.securesms.jobs.SendReadReceiptJob;
|
||||
@@ -17,7 +17,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
public class SendReadReceiptsJobMigrationTest {
|
||||
|
||||
private final MmsSmsDatabase mockDatabase = mock(MmsSmsDatabase.class);
|
||||
private final MmsSmsTable mockDatabase = mock(MmsSmsTable.class);
|
||||
private final SendReadReceiptsJobMigration testSubject = new SendReadReceiptsJobMigration(mockDatabase);
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,29 +1,25 @@
|
||||
package org.thoughtcrime.securesms.jobmanager.migrations;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.thoughtcrime.securesms.database.GroupDatabase;
|
||||
import org.thoughtcrime.securesms.database.MmsSmsDatabase;
|
||||
import org.thoughtcrime.securesms.database.GroupTable;
|
||||
import org.thoughtcrime.securesms.groups.GroupId;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
import org.thoughtcrime.securesms.jobmanager.JobMigration;
|
||||
import org.thoughtcrime.securesms.jobs.FailingJob;
|
||||
import org.thoughtcrime.securesms.jobs.SendReadReceiptJob;
|
||||
import org.thoughtcrime.securesms.jobs.SenderKeyDistributionSendJob;
|
||||
import org.thoughtcrime.securesms.recipients.RecipientId;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class SenderKeyDistributionSendJobRecipientMigrationTest {
|
||||
|
||||
private final GroupDatabase mockDatabase = mock(GroupDatabase.class);
|
||||
private final GroupTable mockDatabase = mock(GroupTable.class);
|
||||
private final SenderKeyDistributionSendJobRecipientMigration testSubject = new SenderKeyDistributionSendJobRecipientMigration(mockDatabase);
|
||||
|
||||
private static final GroupId GROUP_ID = GroupId.pushOrThrow(Util.getSecretBytes(32));
|
||||
@@ -38,7 +34,7 @@ public class SenderKeyDistributionSendJobRecipientMigrationTest {
|
||||
.putBlobAsString("group_id", GROUP_ID.getDecodedId())
|
||||
.build());
|
||||
|
||||
GroupDatabase.GroupRecord mockGroup = mock(GroupDatabase.GroupRecord.class);
|
||||
GroupTable.GroupRecord mockGroup = mock(GroupTable.GroupRecord.class);
|
||||
when(mockGroup.getRecipientId()).thenReturn(RecipientId.from(2));
|
||||
when(mockDatabase.getGroup(GROUP_ID)).thenReturn(Optional.of(mockGroup));
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.mockito.junit.MockitoRule
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.database.AttachmentDatabase.TransformProperties
|
||||
import org.thoughtcrime.securesms.database.AttachmentTable.TransformProperties
|
||||
import org.thoughtcrime.securesms.testutil.EmptyLogger
|
||||
import org.thoughtcrime.securesms.util.MediaUtil
|
||||
import java.util.Optional
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
import org.thoughtcrime.securesms.SignalStoreRule
|
||||
import org.thoughtcrime.securesms.database.RemoteMegaphoneDatabase
|
||||
import org.thoughtcrime.securesms.database.RemoteMegaphoneTable
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.database.model.RemoteMegaphoneRecord
|
||||
import org.thoughtcrime.securesms.util.toMillis
|
||||
@@ -45,14 +45,14 @@ class RemoteMegaphoneRepositoryTest {
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
clearMocks(remoteMegaphoneDatabase)
|
||||
clearMocks(remoteMegaphoneTable)
|
||||
}
|
||||
|
||||
/** Should return null if no megaphones in database. */
|
||||
@Test
|
||||
fun getRemoteMegaphoneToShow_noMegaphones() {
|
||||
// GIVEN
|
||||
every { remoteMegaphoneDatabase.getPotentialMegaphonesAndClearOld(any()) } returns emptyList()
|
||||
every { remoteMegaphoneTable.getPotentialMegaphonesAndClearOld(any()) } returns emptyList()
|
||||
|
||||
// WHEN
|
||||
val record = RemoteMegaphoneRepository.getRemoteMegaphoneToShow(0)
|
||||
@@ -64,7 +64,7 @@ class RemoteMegaphoneRepositoryTest {
|
||||
@Test
|
||||
fun getRemoteMegaphoneToShow_oneMegaphone() {
|
||||
// GIVEN
|
||||
every { remoteMegaphoneDatabase.getPotentialMegaphonesAndClearOld(any()) } returns listOf(megaphone(1))
|
||||
every { remoteMegaphoneTable.getPotentialMegaphonesAndClearOld(any()) } returns listOf(megaphone(1))
|
||||
|
||||
// WHEN
|
||||
val record = RemoteMegaphoneRepository.getRemoteMegaphoneToShow(0)
|
||||
@@ -84,7 +84,7 @@ class RemoteMegaphoneRepositoryTest {
|
||||
secondaryActionData = JSONObject("{\"snoozeDurationDays\":[3]}")
|
||||
)
|
||||
|
||||
every { remoteMegaphoneDatabase.getPotentialMegaphonesAndClearOld(now.toMillis()) } returns listOf(snoozed)
|
||||
every { remoteMegaphoneTable.getPotentialMegaphonesAndClearOld(now.toMillis()) } returns listOf(snoozed)
|
||||
|
||||
// WHEN
|
||||
val record = RemoteMegaphoneRepository.getRemoteMegaphoneToShow(now.toMillis())
|
||||
@@ -104,7 +104,7 @@ class RemoteMegaphoneRepositoryTest {
|
||||
secondaryActionData = JSONObject("{\"snoozeDurationDays\":[3]}")
|
||||
)
|
||||
|
||||
every { remoteMegaphoneDatabase.getPotentialMegaphonesAndClearOld(now.toMillis()) } returns listOf(snoozed)
|
||||
every { remoteMegaphoneTable.getPotentialMegaphonesAndClearOld(now.toMillis()) } returns listOf(snoozed)
|
||||
|
||||
// WHEN
|
||||
val record = RemoteMegaphoneRepository.getRemoteMegaphoneToShow(now.toMillis())
|
||||
@@ -124,7 +124,7 @@ class RemoteMegaphoneRepositoryTest {
|
||||
secondaryActionData = JSONObject("{\"snoozeDurationDays\":[3, 5, 7]}")
|
||||
)
|
||||
|
||||
every { remoteMegaphoneDatabase.getPotentialMegaphonesAndClearOld(now.toMillis()) } returns listOf(snoozed)
|
||||
every { remoteMegaphoneTable.getPotentialMegaphonesAndClearOld(now.toMillis()) } returns listOf(snoozed)
|
||||
|
||||
// WHEN
|
||||
val record = RemoteMegaphoneRepository.getRemoteMegaphoneToShow(now.toMillis())
|
||||
@@ -136,13 +136,13 @@ class RemoteMegaphoneRepositoryTest {
|
||||
companion object {
|
||||
private val now = LocalDateTime.of(2021, 11, 5, 12, 0)
|
||||
|
||||
private val remoteMegaphoneDatabase: RemoteMegaphoneDatabase = mockk()
|
||||
private val remoteMegaphoneTable: RemoteMegaphoneTable = mockk()
|
||||
|
||||
@BeforeClass
|
||||
@JvmStatic
|
||||
fun classSetup() {
|
||||
mockkObject(SignalDatabase.Companion)
|
||||
every { SignalDatabase.remoteMegaphones } returns remoteMegaphoneDatabase
|
||||
every { SignalDatabase.remoteMegaphones } returns remoteMegaphoneTable
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.signal.libsignal.protocol.util.Pair;
|
||||
import org.thoughtcrime.securesms.database.MessageDatabase;
|
||||
import org.thoughtcrime.securesms.database.MessageTable;
|
||||
import org.thoughtcrime.securesms.database.model.MessageId;
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies;
|
||||
import org.thoughtcrime.securesms.jobmanager.Data;
|
||||
@@ -72,12 +72,12 @@ public class MarkReadReceiverTest {
|
||||
List<Long> threads = Stream.range(4L, 7L).toList();
|
||||
int expected = recipients.size() * threads.size() + 1;
|
||||
|
||||
List<MessageDatabase.MarkedMessageInfo> infoList = Stream.of(threads)
|
||||
.flatMap(threadId -> Stream.of(recipients)
|
||||
List<MessageTable.MarkedMessageInfo> infoList = Stream.of(threads)
|
||||
.flatMap(threadId -> Stream.of(recipients)
|
||||
.map(recipientId -> createMarkedMessageInfo(threadId, recipientId)))
|
||||
.toList();
|
||||
.toList();
|
||||
|
||||
List<MessageDatabase.MarkedMessageInfo> duplicatedList = Util.concatenatedList(infoList, infoList);
|
||||
List<MessageTable.MarkedMessageInfo> duplicatedList = Util.concatenatedList(infoList, infoList);
|
||||
|
||||
// WHEN
|
||||
MarkReadReceiver.process(mockContext, duplicatedList);
|
||||
@@ -104,10 +104,10 @@ public class MarkReadReceiverTest {
|
||||
assertEquals("Should have 9 total combinations.", 9, threadRecipientPairs.size());
|
||||
}
|
||||
|
||||
private MessageDatabase.MarkedMessageInfo createMarkedMessageInfo(long threadId, @NonNull RecipientId recipientId) {
|
||||
return new MessageDatabase.MarkedMessageInfo(threadId,
|
||||
new MessageDatabase.SyncMessageId(recipientId, 0),
|
||||
new MessageId(1, true),
|
||||
new MessageDatabase.ExpirationInfo(0, 0, 0, false));
|
||||
private MessageTable.MarkedMessageInfo createMarkedMessageInfo(long threadId, @NonNull RecipientId recipientId) {
|
||||
return new MessageTable.MarkedMessageInfo(threadId,
|
||||
new MessageTable.SyncMessageId(recipientId, 0),
|
||||
new MessageId(1, true),
|
||||
new MessageTable.ExpirationInfo(0, 0, 0, false));
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,10 @@ import org.mockito.Mock;
|
||||
import org.mockito.MockedStatic;
|
||||
import org.mockito.junit.MockitoJUnit;
|
||||
import org.mockito.junit.MockitoRule;
|
||||
import org.thoughtcrime.securesms.database.MmsSmsDatabase;
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase;
|
||||
import org.thoughtcrime.securesms.database.MmsSmsTable;
|
||||
import org.thoughtcrime.securesms.database.RecipientTable;
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase;
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase;
|
||||
import org.thoughtcrime.securesms.database.ThreadTable;
|
||||
import org.thoughtcrime.securesms.util.FeatureFlags;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@@ -30,10 +30,10 @@ public class RecipientUtilTest {
|
||||
public MockitoRule rule = MockitoJUnit.rule();
|
||||
|
||||
private Context context = mock(Context.class);
|
||||
private Recipient recipient = mock(Recipient.class);
|
||||
private ThreadDatabase mockThreadDatabase = mock(ThreadDatabase.class);
|
||||
private MmsSmsDatabase mockMmsSmsDatabase = mock(MmsSmsDatabase.class);
|
||||
private RecipientDatabase mockRecipientDatabase = mock(RecipientDatabase.class);
|
||||
private Recipient recipient = mock(Recipient.class);
|
||||
private ThreadTable mockThreadTable = mock(ThreadTable.class);
|
||||
private MmsSmsTable mockMmsSmsDatabase = mock(MmsSmsTable.class);
|
||||
private RecipientTable mockRecipientTable = mock(RecipientTable.class);
|
||||
|
||||
@Mock
|
||||
private MockedStatic<SignalDatabase> signalDatabaseMockedStatic;
|
||||
@@ -43,9 +43,9 @@ public class RecipientUtilTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
signalDatabaseMockedStatic.when(SignalDatabase::threads).thenReturn(mockThreadDatabase);
|
||||
signalDatabaseMockedStatic.when(SignalDatabase::threads).thenReturn(mockThreadTable);
|
||||
signalDatabaseMockedStatic.when(SignalDatabase::mmsSms).thenReturn(mockMmsSmsDatabase);
|
||||
signalDatabaseMockedStatic.when(SignalDatabase::recipients).thenReturn(mockRecipientDatabase);
|
||||
signalDatabaseMockedStatic.when(SignalDatabase::recipients).thenReturn(mockRecipientTable);
|
||||
|
||||
when(recipient.getId()).thenReturn(RecipientId.from(5));
|
||||
when(recipient.resolve()).thenReturn(recipient);
|
||||
@@ -72,7 +72,7 @@ public class RecipientUtilTest {
|
||||
@Test
|
||||
public void givenIHaveSentASecureMessageInThisThread_whenIsThreadMessageRequestAccepted_thenIExpectTrue() {
|
||||
// GIVEN
|
||||
when(mockThreadDatabase.getRecipientForThreadId(anyLong())).thenReturn(recipient);
|
||||
when(mockThreadTable.getRecipientForThreadId(anyLong())).thenReturn(recipient);
|
||||
when(mockMmsSmsDatabase.getOutgoingSecureConversationCount(1L)).thenReturn(5);
|
||||
|
||||
// WHEN
|
||||
@@ -86,7 +86,7 @@ public class RecipientUtilTest {
|
||||
public void givenIHaveNotSentASecureMessageInThisThreadAndIAmProfileSharing_whenIsThreadMessageRequestAccepted_thenIExpectTrue() {
|
||||
// GIVEN
|
||||
when(recipient.isProfileSharing()).thenReturn(true);
|
||||
when(mockThreadDatabase.getRecipientForThreadId(anyLong())).thenReturn(recipient);
|
||||
when(mockThreadTable.getRecipientForThreadId(anyLong())).thenReturn(recipient);
|
||||
when(mockMmsSmsDatabase.getOutgoingSecureConversationCount(1L)).thenReturn(0);
|
||||
|
||||
// WHEN
|
||||
@@ -100,7 +100,7 @@ public class RecipientUtilTest {
|
||||
public void givenIHaveNotSentASecureMessageInThisThreadAndRecipientIsSystemContact_whenIsThreadMessageRequestAccepted_thenIExpectTrue() {
|
||||
// GIVEN
|
||||
when(recipient.isSystemContact()).thenReturn(true);
|
||||
when(mockThreadDatabase.getRecipientForThreadId(anyLong())).thenReturn(recipient);
|
||||
when(mockThreadTable.getRecipientForThreadId(anyLong())).thenReturn(recipient);
|
||||
when(mockMmsSmsDatabase.getOutgoingSecureConversationCount(1L)).thenReturn(0);
|
||||
|
||||
// WHEN
|
||||
@@ -114,7 +114,7 @@ public class RecipientUtilTest {
|
||||
@Test
|
||||
public void givenIHaveReceivedASecureMessageIHaveNotSentASecureMessageAndRecipientIsNotSystemContactAndNotProfileSharing_whenIsThreadMessageRequestAccepted_thenIExpectFalse() {
|
||||
// GIVEN
|
||||
when(mockThreadDatabase.getRecipientForThreadId(anyLong())).thenReturn(recipient);
|
||||
when(mockThreadTable.getRecipientForThreadId(anyLong())).thenReturn(recipient);
|
||||
when(mockMmsSmsDatabase.getOutgoingSecureConversationCount(1L)).thenReturn(0);
|
||||
when(mockMmsSmsDatabase.getSecureConversationCount(1L)).thenReturn(5);
|
||||
|
||||
@@ -128,7 +128,7 @@ public class RecipientUtilTest {
|
||||
@Test
|
||||
public void givenIHaveNotReceivedASecureMessageIHaveNotSentASecureMessageAndRecipientIsNotSystemContactAndNotProfileSharing_whenIsThreadMessageRequestAccepted_thenIExpectTrue() {
|
||||
// GIVEN
|
||||
when(mockThreadDatabase.getRecipientForThreadId(anyLong())).thenReturn(recipient);
|
||||
when(mockThreadTable.getRecipientForThreadId(anyLong())).thenReturn(recipient);
|
||||
when(mockMmsSmsDatabase.getOutgoingSecureConversationCount(1L)).thenReturn(0);
|
||||
when(mockMmsSmsDatabase.getSecureConversationCount(1L)).thenReturn(0);
|
||||
|
||||
@@ -220,7 +220,7 @@ public class RecipientUtilTest {
|
||||
RecipientUtil.shareProfileIfFirstSecureMessage(recipient);
|
||||
|
||||
// THEN
|
||||
verify(mockRecipientDatabase).setProfileSharing(recipient.getId(), true);
|
||||
verify(mockRecipientTable).setProfileSharing(recipient.getId(), true);
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@@ -233,6 +233,6 @@ public class RecipientUtilTest {
|
||||
RecipientUtil.shareProfileIfFirstSecureMessage(recipient);
|
||||
|
||||
// THEN
|
||||
verify(mockRecipientDatabase, never()).setProfileSharing(recipient.getId(), true);
|
||||
verify(mockRecipientTable, never()).setProfileSharing(recipient.getId(), true);
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@ import org.robolectric.annotation.Config
|
||||
import org.thoughtcrime.securesms.attachments.Attachment
|
||||
import org.thoughtcrime.securesms.attachments.AttachmentId
|
||||
import org.thoughtcrime.securesms.attachments.DatabaseAttachment
|
||||
import org.thoughtcrime.securesms.database.AttachmentDatabase
|
||||
import org.thoughtcrime.securesms.database.AttachmentTable
|
||||
import org.thoughtcrime.securesms.jobmanager.Job
|
||||
import org.thoughtcrime.securesms.jobmanager.JobManager
|
||||
import org.thoughtcrime.securesms.jobs.AttachmentCompressionJob
|
||||
@@ -84,7 +84,7 @@ class UploadDependencyGraphTest {
|
||||
UriAttachmentBuilder.build(
|
||||
id = 10,
|
||||
contentType = MediaUtil.IMAGE_JPEG,
|
||||
transformProperties = AttachmentDatabase.TransformProperties(false, true, increment, increment + 1, SentMediaQuality.STANDARD.code)
|
||||
transformProperties = AttachmentTable.TransformProperties(false, true, increment, increment + 1, SentMediaQuality.STANDARD.code)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ class UploadDependencyGraphTest {
|
||||
UriAttachmentBuilder.build(
|
||||
id = 10,
|
||||
contentType = MediaUtil.IMAGE_JPEG,
|
||||
transformProperties = if (it != 1) AttachmentDatabase.TransformProperties(false, true, 1, 2, SentMediaQuality.STANDARD.code) else null
|
||||
transformProperties = if (it != 1) AttachmentTable.TransformProperties(false, true, 1, 2, SentMediaQuality.STANDARD.code) else null
|
||||
)
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ class UploadDependencyGraphTest {
|
||||
UriAttachmentBuilder.build(
|
||||
1L,
|
||||
contentType = MediaUtil.IMAGE_JPEG,
|
||||
transformProperties = AttachmentDatabase.TransformProperties.forVideoTrim(it.toLong(), it.toLong() + 1)
|
||||
transformProperties = AttachmentTable.TransformProperties.forVideoTrim(it.toLong(), it.toLong() + 1)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -229,11 +229,11 @@ class UploadDependencyGraphTest {
|
||||
private fun getAttachmentForPreUpload(id: Long, attachment: Attachment): DatabaseAttachment {
|
||||
return DatabaseAttachment(
|
||||
AttachmentId(id, id),
|
||||
AttachmentDatabase.PREUPLOAD_MESSAGE_ID,
|
||||
AttachmentTable.PREUPLOAD_MESSAGE_ID,
|
||||
false,
|
||||
false,
|
||||
attachment.contentType,
|
||||
AttachmentDatabase.TRANSFER_PROGRESS_PENDING,
|
||||
AttachmentTable.TRANSFER_PROGRESS_PENDING,
|
||||
attachment.size,
|
||||
attachment.fileName,
|
||||
attachment.cdnNumber,
|
||||
|
||||
@@ -11,13 +11,12 @@ import org.mockito.Mock
|
||||
import org.mockito.MockedStatic
|
||||
import org.mockito.Mockito
|
||||
import org.mockito.Mockito.mock
|
||||
import org.mockito.Mockito.`when`
|
||||
import org.mockito.internal.configuration.plugins.Plugins
|
||||
import org.mockito.internal.junit.JUnitRule
|
||||
import org.mockito.junit.MockitoRule
|
||||
import org.mockito.quality.Strictness
|
||||
import org.signal.core.util.logging.Log
|
||||
import org.thoughtcrime.securesms.database.RecipientDatabase
|
||||
import org.thoughtcrime.securesms.database.RecipientTable
|
||||
import org.thoughtcrime.securesms.keyvalue.AccountValues
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.testutil.EmptyLogger
|
||||
@@ -36,7 +35,7 @@ class ContactRecordProcessorTest {
|
||||
val mockitoRule: MockitoRule = JUnitRule(Plugins.getMockitoLogger(), Strictness.STRICT_STUBS)
|
||||
|
||||
@Mock
|
||||
lateinit var recipientDatabase: RecipientDatabase
|
||||
lateinit var recipientTable: RecipientTable
|
||||
|
||||
@Mock
|
||||
lateinit var featureFlags: MockedStatic<FeatureFlags>
|
||||
@@ -54,7 +53,7 @@ class ContactRecordProcessorTest {
|
||||
@Test
|
||||
fun `isInvalid, normal, false`() {
|
||||
// GIVEN
|
||||
val subject = ContactRecordProcessor(ACI_A, PNI_A, E164_A, recipientDatabase)
|
||||
val subject = ContactRecordProcessor(ACI_A, PNI_A, E164_A, recipientTable)
|
||||
|
||||
val record = buildRecord {
|
||||
setServiceId(ACI_B.toString())
|
||||
@@ -72,7 +71,7 @@ class ContactRecordProcessorTest {
|
||||
@Test
|
||||
fun `isInvalid, missing serviceId, true`() {
|
||||
// GIVEN
|
||||
val subject = ContactRecordProcessor(ACI_A, PNI_A, E164_A, recipientDatabase)
|
||||
val subject = ContactRecordProcessor(ACI_A, PNI_A, E164_A, recipientTable)
|
||||
|
||||
val record = buildRecord {
|
||||
setServiceE164(E164_B)
|
||||
@@ -88,7 +87,7 @@ class ContactRecordProcessorTest {
|
||||
@Test
|
||||
fun `isInvalid, e164 matches self, true`() {
|
||||
// GIVEN
|
||||
val subject = ContactRecordProcessor(ACI_A, PNI_A, E164_A, recipientDatabase)
|
||||
val subject = ContactRecordProcessor(ACI_A, PNI_A, E164_A, recipientTable)
|
||||
|
||||
val record = buildRecord {
|
||||
setServiceId(ACI_B.toString())
|
||||
@@ -105,7 +104,7 @@ class ContactRecordProcessorTest {
|
||||
@Test
|
||||
fun `isInvalid, aci matches self, true`() {
|
||||
// GIVEN
|
||||
val subject = ContactRecordProcessor(ACI_A, PNI_A, E164_A, recipientDatabase)
|
||||
val subject = ContactRecordProcessor(ACI_A, PNI_A, E164_A, recipientTable)
|
||||
|
||||
val record = buildRecord {
|
||||
setServiceId(ACI_A.toString())
|
||||
@@ -121,7 +120,7 @@ class ContactRecordProcessorTest {
|
||||
@Test
|
||||
fun `isInvalid, pni matches self as serviceId, true`() {
|
||||
// GIVEN
|
||||
val subject = ContactRecordProcessor(ACI_A, PNI_A, E164_A, recipientDatabase)
|
||||
val subject = ContactRecordProcessor(ACI_A, PNI_A, E164_A, recipientTable)
|
||||
|
||||
val record = buildRecord {
|
||||
setServiceId(PNI_A.toString())
|
||||
@@ -137,7 +136,7 @@ class ContactRecordProcessorTest {
|
||||
@Test
|
||||
fun `isInvalid, pni matches self as pni, true`() {
|
||||
// GIVEN
|
||||
val subject = ContactRecordProcessor(ACI_A, PNI_A, E164_A, recipientDatabase)
|
||||
val subject = ContactRecordProcessor(ACI_A, PNI_A, E164_A, recipientTable)
|
||||
|
||||
val record = buildRecord {
|
||||
setServiceId(ACI_B.toString())
|
||||
@@ -154,7 +153,7 @@ class ContactRecordProcessorTest {
|
||||
@Test
|
||||
fun `isInvalid, pniOnly pnpDisabled, true`() {
|
||||
// GIVEN
|
||||
val subject = ContactRecordProcessor(ACI_A, PNI_A, E164_A, recipientDatabase)
|
||||
val subject = ContactRecordProcessor(ACI_A, PNI_A, E164_A, recipientTable)
|
||||
|
||||
featureFlags.`when`<Boolean> { FeatureFlags.phoneNumberPrivacy() }.thenReturn(false)
|
||||
|
||||
@@ -173,7 +172,7 @@ class ContactRecordProcessorTest {
|
||||
@Test
|
||||
fun `isInvalid, pniOnly pnpEnabled, false`() {
|
||||
// GIVEN
|
||||
val subject = ContactRecordProcessor(ACI_A, PNI_A, E164_A, recipientDatabase)
|
||||
val subject = ContactRecordProcessor(ACI_A, PNI_A, E164_A, recipientTable)
|
||||
|
||||
featureFlags.`when`<Boolean> { FeatureFlags.phoneNumberPrivacy() }.thenReturn(true)
|
||||
|
||||
@@ -192,7 +191,7 @@ class ContactRecordProcessorTest {
|
||||
@Test
|
||||
fun `merge, e164MatchesButPnisDont pnpEnabled, keepLocal`() {
|
||||
// GIVEN
|
||||
val subject = ContactRecordProcessor(ACI_A, PNI_A, E164_A, recipientDatabase)
|
||||
val subject = ContactRecordProcessor(ACI_A, PNI_A, E164_A, recipientTable)
|
||||
|
||||
featureFlags.`when`<Boolean> { FeatureFlags.phoneNumberPrivacy() }.thenReturn(true)
|
||||
|
||||
@@ -220,7 +219,7 @@ class ContactRecordProcessorTest {
|
||||
@Test
|
||||
fun `merge, pnisMatchButE164sDont pnpEnabled, keepLocal`() {
|
||||
// GIVEN
|
||||
val subject = ContactRecordProcessor(ACI_A, PNI_A, E164_A, recipientDatabase)
|
||||
val subject = ContactRecordProcessor(ACI_A, PNI_A, E164_A, recipientTable)
|
||||
|
||||
featureFlags.`when`<Boolean> { FeatureFlags.phoneNumberPrivacy() }.thenReturn(true)
|
||||
|
||||
@@ -248,7 +247,7 @@ class ContactRecordProcessorTest {
|
||||
@Test
|
||||
fun `merge, e164AndPniChange pnpEnabled, useRemote`() {
|
||||
// GIVEN
|
||||
val subject = ContactRecordProcessor(ACI_A, PNI_A, E164_A, recipientDatabase)
|
||||
val subject = ContactRecordProcessor(ACI_A, PNI_A, E164_A, recipientTable)
|
||||
|
||||
featureFlags.`when`<Boolean> { FeatureFlags.phoneNumberPrivacy() }.thenReturn(true)
|
||||
|
||||
@@ -276,7 +275,7 @@ class ContactRecordProcessorTest {
|
||||
@Test
|
||||
fun `merge, pnpDisabled, pniDropped`() {
|
||||
// GIVEN
|
||||
val subject = ContactRecordProcessor(ACI_A, PNI_A, E164_A, recipientDatabase)
|
||||
val subject = ContactRecordProcessor(ACI_A, PNI_A, E164_A, recipientTable)
|
||||
|
||||
featureFlags.`when`<Boolean> { FeatureFlags.phoneNumberPrivacy() }.thenReturn(false)
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import org.mockito.kotlin.never
|
||||
import org.mockito.kotlin.verify
|
||||
import org.mockito.kotlin.whenever
|
||||
import org.thoughtcrime.securesms.attachments.AttachmentId
|
||||
import org.thoughtcrime.securesms.database.AttachmentDatabase
|
||||
import org.thoughtcrime.securesms.database.AttachmentTable
|
||||
import org.thoughtcrime.securesms.database.FakeMessageRecords
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.dependencies.ApplicationDependencies
|
||||
@@ -30,7 +30,7 @@ class StoriesTest {
|
||||
val mockitoRule: MockitoRule = MockitoJUnit.rule()
|
||||
|
||||
@Mock
|
||||
private lateinit var mockAttachmentDatabase: AttachmentDatabase
|
||||
private lateinit var mockAttachmentTable: AttachmentTable
|
||||
|
||||
@Mock
|
||||
private lateinit var mockJobManager: JobManager
|
||||
@@ -52,9 +52,9 @@ class StoriesTest {
|
||||
RxJavaPlugins.setIoSchedulerHandler { testScheduler }
|
||||
|
||||
SignalDatabase.setSignalDatabaseInstanceForTesting(mockSignalDatabase)
|
||||
whenever(SignalDatabase.attachments).thenReturn(mockAttachmentDatabase)
|
||||
whenever(SignalDatabase.attachments).thenReturn(mockAttachmentTable)
|
||||
whenever(ApplicationDependencies.getJobManager()).thenReturn(mockJobManager)
|
||||
whenever(mockAttachmentDatabase.getAttachmentsForMessage(any())).thenReturn(emptyList())
|
||||
whenever(mockAttachmentTable.getAttachmentsForMessage(any())).thenReturn(emptyList())
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -103,7 +103,7 @@ class StoriesTest {
|
||||
// GIVEN
|
||||
val attachment = FakeMessageRecords.buildDatabaseAttachment()
|
||||
val messageRecord = FakeMessageRecords.buildMediaMmsMessageRecord()
|
||||
whenever(mockAttachmentDatabase.getAttachmentsForMessage(any())).thenReturn(listOf(attachment))
|
||||
whenever(mockAttachmentTable.getAttachmentsForMessage(any())).thenReturn(listOf(attachment))
|
||||
|
||||
// WHEN
|
||||
val testObserver = Stories.enqueueAttachmentsFromStoryForDownload(messageRecord, true).test()
|
||||
|
||||
@@ -2,7 +2,7 @@ package org.thoughtcrime.securesms.testutil
|
||||
|
||||
import org.thoughtcrime.securesms.attachments.Attachment
|
||||
import org.thoughtcrime.securesms.contactshare.Contact
|
||||
import org.thoughtcrime.securesms.database.ThreadDatabase
|
||||
import org.thoughtcrime.securesms.database.ThreadTable
|
||||
import org.thoughtcrime.securesms.database.documents.IdentityKeyMismatch
|
||||
import org.thoughtcrime.securesms.database.documents.NetworkFailure
|
||||
import org.thoughtcrime.securesms.database.model.Mention
|
||||
@@ -24,7 +24,7 @@ object OutgoingMediaMessageBuilder {
|
||||
subscriptionId: Int = -1,
|
||||
expiresIn: Long = -1,
|
||||
viewOnce: Boolean = false,
|
||||
distributionType: Int = ThreadDatabase.DistributionTypes.DEFAULT,
|
||||
distributionType: Int = ThreadTable.DistributionTypes.DEFAULT,
|
||||
storyType: StoryType = StoryType.NONE,
|
||||
parentStoryId: ParentStoryId? = null,
|
||||
isStoryReaction: Boolean = false,
|
||||
|
||||
@@ -4,7 +4,7 @@ import android.net.Uri
|
||||
import org.thoughtcrime.securesms.attachments.UriAttachment
|
||||
import org.thoughtcrime.securesms.audio.AudioHash
|
||||
import org.thoughtcrime.securesms.blurhash.BlurHash
|
||||
import org.thoughtcrime.securesms.database.AttachmentDatabase
|
||||
import org.thoughtcrime.securesms.database.AttachmentTable
|
||||
import org.thoughtcrime.securesms.stickers.StickerLocator
|
||||
|
||||
object UriAttachmentBuilder {
|
||||
@@ -12,7 +12,7 @@ object UriAttachmentBuilder {
|
||||
id: Long,
|
||||
uri: Uri = Uri.parse("content://$id"),
|
||||
contentType: String,
|
||||
transferState: Int = AttachmentDatabase.TRANSFER_PROGRESS_PENDING,
|
||||
transferState: Int = AttachmentTable.TRANSFER_PROGRESS_PENDING,
|
||||
size: Long = 0L,
|
||||
fileName: String = "file$id",
|
||||
voiceNote: Boolean = false,
|
||||
@@ -23,7 +23,7 @@ object UriAttachmentBuilder {
|
||||
stickerLocator: StickerLocator? = null,
|
||||
blurHash: BlurHash? = null,
|
||||
audioHash: AudioHash? = null,
|
||||
transformProperties: AttachmentDatabase.TransformProperties? = null
|
||||
transformProperties: AttachmentTable.TransformProperties? = null
|
||||
): UriAttachment {
|
||||
return UriAttachment(
|
||||
uri,
|
||||
|
||||
Reference in New Issue
Block a user