mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-28 21:57:17 +00:00
Add support for syncing forced unread status.
This commit is contained in:
@@ -55,6 +55,7 @@ public class ContactConflictMergerTest {
|
||||
.setUsername("username A")
|
||||
.setProfileSharingEnabled(false)
|
||||
.setArchived(false)
|
||||
.setForcedUnread(false)
|
||||
.build();
|
||||
SignalContactRecord local = new SignalContactRecord.Builder(byteArray(2), new SignalServiceAddress(UUID_B, E164_B))
|
||||
.setBlocked(false)
|
||||
@@ -66,6 +67,7 @@ public class ContactConflictMergerTest {
|
||||
.setUsername("username B")
|
||||
.setProfileSharingEnabled(true)
|
||||
.setArchived(true)
|
||||
.setForcedUnread(true)
|
||||
.build();
|
||||
|
||||
SignalContactRecord merged = new ContactConflictMerger(Collections.singletonList(local), SELF).merge(remote, local, mock(KeyGenerator.class));
|
||||
@@ -81,6 +83,7 @@ public class ContactConflictMergerTest {
|
||||
assertEquals("username A", merged.getUsername().get());
|
||||
assertFalse(merged.isProfileSharingEnabled());
|
||||
assertFalse(merged.isArchived());
|
||||
assertFalse(merged.isForcedUnread());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -30,11 +30,13 @@ public final class GroupV1ConflictMergerTest {
|
||||
.setBlocked(false)
|
||||
.setProfileSharingEnabled(false)
|
||||
.setArchived(false)
|
||||
.setForcedUnread(false)
|
||||
.build();
|
||||
SignalGroupV1Record local = new SignalGroupV1Record.Builder(byteArray(2), byteArray(100))
|
||||
.setBlocked(true)
|
||||
.setProfileSharingEnabled(true)
|
||||
.setArchived(true)
|
||||
.setForcedUnread(true)
|
||||
.build();
|
||||
|
||||
SignalGroupV1Record merged = new GroupV1ConflictMerger(Collections.singletonList(local)).merge(remote, local, KEY_GENERATOR);
|
||||
@@ -44,6 +46,7 @@ public final class GroupV1ConflictMergerTest {
|
||||
assertFalse(merged.isProfileSharingEnabled());
|
||||
assertFalse(merged.isBlocked());
|
||||
assertFalse(merged.isArchived());
|
||||
assertFalse(merged.isForcedUnread());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -30,11 +30,13 @@ public final class GroupV2ConflictMergerTest {
|
||||
.setBlocked(false)
|
||||
.setProfileSharingEnabled(false)
|
||||
.setArchived(false)
|
||||
.setForcedUnread(false)
|
||||
.build();
|
||||
SignalGroupV2Record local = new SignalGroupV2Record.Builder(byteArray(2), groupKey(100))
|
||||
.setBlocked(true)
|
||||
.setProfileSharingEnabled(true)
|
||||
.setArchived(true)
|
||||
.setForcedUnread(true)
|
||||
.build();
|
||||
|
||||
SignalGroupV2Record merged = new GroupV2ConflictMerger(Collections.singletonList(local)).merge(remote, local, KEY_GENERATOR);
|
||||
@@ -44,6 +46,7 @@ public final class GroupV2ConflictMergerTest {
|
||||
assertFalse(merged.isProfileSharingEnabled());
|
||||
assertFalse(merged.isBlocked());
|
||||
assertFalse(merged.isArchived());
|
||||
assertFalse(merged.isForcedUnread());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -8,6 +8,10 @@ import org.junit.runner.RunWith;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import edu.emory.mathcs.backport.java.util.Collections;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
@@ -23,7 +27,7 @@ public final class SqlUtilTest {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("a", 2);
|
||||
|
||||
SqlUtil.UpdateQuery updateQuery = SqlUtil.buildTrueUpdateQuery(selection, args, values);
|
||||
SqlUtil.Query updateQuery = SqlUtil.buildTrueUpdateQuery(selection, args, values);
|
||||
|
||||
assertEquals("(_id = ?) AND (a != ? OR a IS NULL)", updateQuery.getWhere());
|
||||
assertArrayEquals(new String[] { "1", "2" }, updateQuery.getWhereArgs());
|
||||
@@ -37,7 +41,7 @@ public final class SqlUtilTest {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("a", 4);
|
||||
|
||||
SqlUtil.UpdateQuery updateQuery = SqlUtil.buildTrueUpdateQuery(selection, args, values);
|
||||
SqlUtil.Query updateQuery = SqlUtil.buildTrueUpdateQuery(selection, args, values);
|
||||
|
||||
assertEquals("(_id = ? AND (foo = ? OR bar != ?)) AND (a != ? OR a IS NULL)", updateQuery.getWhere());
|
||||
assertArrayEquals(new String[] { "1", "2", "3", "4" }, updateQuery.getWhereArgs());
|
||||
@@ -53,7 +57,7 @@ public final class SqlUtilTest {
|
||||
values.put("b", 3);
|
||||
values.put("c", 4);
|
||||
|
||||
SqlUtil.UpdateQuery updateQuery = SqlUtil.buildTrueUpdateQuery(selection, args, values);
|
||||
SqlUtil.Query updateQuery = SqlUtil.buildTrueUpdateQuery(selection, args, values);
|
||||
|
||||
assertEquals("(_id = ?) AND (a != ? OR a IS NULL OR b != ? OR b IS NULL OR c != ? OR c IS NULL)", updateQuery.getWhere());
|
||||
assertArrayEquals(new String[] { "1", "2", "3", "4"}, updateQuery.getWhereArgs());
|
||||
@@ -67,7 +71,7 @@ public final class SqlUtilTest {
|
||||
ContentValues values = new ContentValues();
|
||||
values.put("a", (String) null);
|
||||
|
||||
SqlUtil.UpdateQuery updateQuery = SqlUtil.buildTrueUpdateQuery(selection, args, values);
|
||||
SqlUtil.Query updateQuery = SqlUtil.buildTrueUpdateQuery(selection, args, values);
|
||||
|
||||
assertEquals("(_id = ?) AND (a NOT NULL)", updateQuery.getWhere());
|
||||
assertArrayEquals(new String[] { "1" }, updateQuery.getWhereArgs());
|
||||
@@ -85,9 +89,30 @@ public final class SqlUtilTest {
|
||||
values.put("d", (String) null);
|
||||
values.put("e", (String) null);
|
||||
|
||||
SqlUtil.UpdateQuery updateQuery = SqlUtil.buildTrueUpdateQuery(selection, args, values);
|
||||
SqlUtil.Query updateQuery = SqlUtil.buildTrueUpdateQuery(selection, args, values);
|
||||
|
||||
assertEquals("(_id = ?) AND (a NOT NULL OR b != ? OR b IS NULL OR c != ? OR c IS NULL OR d NOT NULL OR e NOT NULL)", updateQuery.getWhere());
|
||||
assertArrayEquals(new String[] { "1", "2", "3" }, updateQuery.getWhereArgs());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildCollectionQuery_single() {
|
||||
SqlUtil.Query updateQuery = SqlUtil.buildCollectionQuery("a", Arrays.asList(1));
|
||||
|
||||
assertEquals("a IN (?)", updateQuery.getWhere());
|
||||
assertArrayEquals(new String[] { "1" }, updateQuery.getWhereArgs());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void buildCollectionQuery_multiple() {
|
||||
SqlUtil.Query updateQuery = SqlUtil.buildCollectionQuery("a", Arrays.asList(1, 2, 3));
|
||||
|
||||
assertEquals("a IN (?, ?, ?)", updateQuery.getWhere());
|
||||
assertArrayEquals(new String[] { "1", "2", "3" }, updateQuery.getWhereArgs());
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void buildCollectionQuery_none() {
|
||||
SqlUtil.buildCollectionQuery("a", Collections.emptyList());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user