Payments.

Co-authored-by: Alan Evans <alan@signal.org>
Co-authored-by: Alex Hart <alex@signal.org>
Co-authored-by: Cody Henthorne <cody@signal.org>
This commit is contained in:
Android Team
2021-04-06 13:03:33 -03:00
committed by Alan Evans
parent c42023855b
commit fddba2906a
311 changed files with 18956 additions and 235 deletions

View File

@@ -0,0 +1,59 @@
package org.thoughtcrime.securesms.util;
import androidx.annotation.Nullable;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.util.Arrays;
import java.util.Collection;
import java.util.Objects;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertSame;
@RunWith(Parameterized.class)
public final class StringUtilTest_abbreviateInMiddle {
@Parameterized.Parameter(0)
public CharSequence input;
@Parameterized.Parameter(1)
public int maxChars;
@Parameterized.Parameter(2)
public CharSequence expected;
@Parameterized.Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{
{null, 0, null},
{null, 1, null},
{"", 0, ""},
{"", 1, ""},
{"0123456789", 10, "0123456789"},
{"0123456789", 11, "0123456789"},
{"0123456789", 9, "0123…6789"},
{"0123456789", 8, "012…6789"},
{"0123456789", 7, "012…789"},
{"0123456789", 6, "01…789"},
{"0123456789", 5, "01…89"},
{"0123456789", 4, "0…89"},
{"0123456789", 3, "0…9"},
});
}
@Test
public void abbreviateInMiddle() {
CharSequence output = StringUtil.abbreviateInMiddle(input, maxChars);
assertEquals(expected, output);
if (Objects.equals(input, output)) {
assertSame(output, input);
} else {
assertNotNull(output);
assertEquals(maxChars, output.length());
}
}
}

View File

@@ -10,6 +10,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.ParameterizedRobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.thoughtcrime.securesms.BuildConfig;
import java.util.Arrays;
import java.util.Collection;
@@ -23,14 +24,16 @@ public class UriUtilTest_isValidExternalUri {
private final String input;
private final boolean output;
private static final String APPLICATION_ID = BuildConfig.APPLICATION_ID;
@ParameterizedRobolectricTestRunner.Parameters
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{
{ "content://other.app.package.name.org/path/public.txt", true },
{ "file:///sdcard/public.txt", true },
{ "file:///data/data/org.thoughtcrime.securesms/private.txt", false },
{ "file:///any/path/with/package/name/org.thoughtcrime.securesms", false },
{ "file:///org.thoughtcrime.securesms/any/path/with/package/name", false },
{"file:///data/data/" + APPLICATION_ID + "/private.txt", false },
{"file:///any/path/with/package/name/" + APPLICATION_ID, false },
{"file:///" + APPLICATION_ID + "/any/path/with/package/name", false },
{ "file:///any/path/../with/back/references/private.txt", false },
{ "file:///any/path/with/back/references/../private.txt", false },
{ "file:///../any/path/with/back/references/private.txt", false },

View File

@@ -1,9 +1,8 @@
package org.thoughtcrime.securesms.util.livedata;
import androidx.annotation.NonNull;
import androidx.lifecycle.Observer;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.Collection;
import java.util.concurrent.ConcurrentLinkedQueue;