mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-30 13:35:18 +00:00
parent
e97255a17f
commit
06e137aee9
40
build.gradle
40
build.gradle
@ -80,8 +80,9 @@ dependencies {
|
|||||||
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
|
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
|
||||||
compile 'org.whispersystems:textsecure-android:1.6.2'
|
compile 'org.whispersystems:textsecure-android:1.6.2'
|
||||||
|
|
||||||
androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
|
testCompile 'junit:junit:4.12'
|
||||||
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
|
testCompile 'org.assertj:assertj-core:1.7.1'
|
||||||
|
testCompile "org.mockito:mockito-core:1.9.5"
|
||||||
|
|
||||||
androidTestCompile ('org.assertj:assertj-core:1.7.1') {
|
androidTestCompile ('org.assertj:assertj-core:1.7.1') {
|
||||||
exclude group: 'org.hamcrest', module: 'hamcrest-core'
|
exclude group: 'org.hamcrest', module: 'hamcrest-core'
|
||||||
@ -90,13 +91,6 @@ dependencies {
|
|||||||
exclude group: 'org.hamcrest', module: 'hamcrest-core'
|
exclude group: 'org.hamcrest', module: 'hamcrest-core'
|
||||||
exclude group: 'com.android.support', module: 'support-annotations'
|
exclude group: 'com.android.support', module: 'support-annotations'
|
||||||
}
|
}
|
||||||
androidTestCompile ('com.android.support.test:runner:0.2') {
|
|
||||||
exclude group: 'com.android.support', module: 'support-annotations'
|
|
||||||
}
|
|
||||||
androidTestCompile ('com.android.support.test.espresso:espresso-core:2.1') {
|
|
||||||
exclude group: 'com.android.support', module: 'support-annotations'
|
|
||||||
exclude group: 'javax.inject'
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencyVerification {
|
dependencyVerification {
|
||||||
@ -161,7 +155,6 @@ android {
|
|||||||
minSdkVersion 9
|
minSdkVersion 9
|
||||||
targetSdkVersion 22
|
targetSdkVersion 22
|
||||||
|
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
|
||||||
buildConfigField "long", "BUILD_TIMESTAMP", System.currentTimeMillis() + "L"
|
buildConfigField "long", "BUILD_TIMESTAMP", System.currentTimeMillis() + "L"
|
||||||
buildConfigField "String", "PUSH_URL", "\"https://textsecure-service.whispersystems.org\""
|
buildConfigField "String", "PUSH_URL", "\"https://textsecure-service.whispersystems.org\""
|
||||||
buildConfigField "boolean", "DEV_BUILD", "false"
|
buildConfigField "boolean", "DEV_BUILD", "false"
|
||||||
@ -226,6 +219,9 @@ android {
|
|||||||
androidTest {
|
androidTest {
|
||||||
java.srcDirs = ['test/androidTest/java']
|
java.srcDirs = ['test/androidTest/java']
|
||||||
}
|
}
|
||||||
|
test {
|
||||||
|
java.srcDirs = ['test/unitTest/java']
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
lintOptions {
|
lintOptions {
|
||||||
@ -264,27 +260,3 @@ if (propFile.canRead()){
|
|||||||
android.buildTypes.release.signingConfig = null
|
android.buildTypes.release.signingConfig = null
|
||||||
}
|
}
|
||||||
|
|
||||||
if (project.hasProperty('espresso') && System.console() != null) {
|
|
||||||
println "______________________WARNING_______________________"
|
|
||||||
println "ALL YOUR CONTACTS WILL BE DELETED IN THE PROCESS"
|
|
||||||
println "OF RUNNING THESE TESTS, TYPE 'delete all my contacts'"
|
|
||||||
println "TO CONTINUE"
|
|
||||||
println "----------------------------------------------------"
|
|
||||||
|
|
||||||
def input = System.console().readLine(':')
|
|
||||||
if (input == 'delete all my contacts') {
|
|
||||||
android.productFlavors {
|
|
||||||
base {}
|
|
||||||
espresso {
|
|
||||||
testInstrumentationRunner "org.thoughtcrime.securesms.TextSecureWakingTestRunner"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
android.sourceSets.espresso {
|
|
||||||
manifest.srcFile 'test/espresso/AndroidManifest.xml'
|
|
||||||
}
|
|
||||||
android.sourceSets.androidTestEspresso {
|
|
||||||
java.srcDirs = ['test/androidTestEspresso/java']
|
|
||||||
res.srcDirs = ['test/androidTestEspresso/res']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package org.thoughtcrime.securesms.util;
|
package org.thoughtcrime.securesms.util;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.TextSecureTestCase;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class BitmapUtilTest extends TextSecureTestCase {
|
import static org.junit.Assert.assertEquals;
|
||||||
public void testScaleFactorNormal() {
|
|
||||||
|
public class BitmapUtilTest {
|
||||||
|
@Test public void testScaleFactorNormal() {
|
||||||
assertEquals(1, BitmapUtil.getScaleFactor(1000, 1000, 9000, 9000, false));
|
assertEquals(1, BitmapUtil.getScaleFactor(1000, 1000, 9000, 9000, false));
|
||||||
|
|
||||||
assertEquals(1, BitmapUtil.getScaleFactor(1000, 1000, 750, 750, false));
|
assertEquals(1, BitmapUtil.getScaleFactor(1000, 1000, 750, 750, false));
|
||||||
@ -18,7 +20,7 @@ public class BitmapUtilTest extends TextSecureTestCase {
|
|||||||
assertEquals(2, BitmapUtil.getScaleFactor(1000, 2000, 499, 499, false));
|
assertEquals(2, BitmapUtil.getScaleFactor(1000, 2000, 499, 499, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testScaleFactorConstrained() {
|
@Test public void testScaleFactorConstrained() {
|
||||||
assertEquals(1, BitmapUtil.getScaleFactor(1000, 1000, 9000, 9000, true));
|
assertEquals(1, BitmapUtil.getScaleFactor(1000, 1000, 9000, 9000, true));
|
||||||
|
|
||||||
assertEquals(2, BitmapUtil.getScaleFactor(1000, 1000, 750, 750, true));
|
assertEquals(2, BitmapUtil.getScaleFactor(1000, 1000, 750, 750, true));
|
@ -1,15 +1,15 @@
|
|||||||
package org.thoughtcrime.securesms.util;
|
package org.thoughtcrime.securesms.util;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.TextSecureTestCase;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static junit.framework.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class ListPartitionTest extends TextSecureTestCase {
|
public class ListPartitionTest {
|
||||||
|
|
||||||
public void testPartitionEven() {
|
@Test public void testPartitionEven() {
|
||||||
List<Integer> list = new LinkedList<>();
|
List<Integer> list = new LinkedList<>();
|
||||||
|
|
||||||
for (int i=0;i<100;i++) {
|
for (int i=0;i<100;i++) {
|
||||||
@ -32,7 +32,7 @@ public class ListPartitionTest extends TextSecureTestCase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPartitionOdd() {
|
@Test public void testPartitionOdd() {
|
||||||
List<Integer> list = new LinkedList<>();
|
List<Integer> list = new LinkedList<>();
|
||||||
|
|
||||||
for (int i=0;i<100;i++) {
|
for (int i=0;i<100;i++) {
|
||||||
@ -60,7 +60,7 @@ public class ListPartitionTest extends TextSecureTestCase {
|
|||||||
assertEquals((int)partitions.get(10).get(0), 100);
|
assertEquals((int)partitions.get(10).get(0), 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testPathological() {
|
@Test public void testPathological() {
|
||||||
List<Integer> list = new LinkedList<>();
|
List<Integer> list = new LinkedList<>();
|
||||||
|
|
||||||
for (int i=0;i<100;i++) {
|
for (int i=0;i<100;i++) {
|
@ -1,25 +1,23 @@
|
|||||||
package org.thoughtcrime.securesms.util;
|
package org.thoughtcrime.securesms.util;
|
||||||
|
|
||||||
import android.test.AndroidTestCase;
|
|
||||||
|
|
||||||
import junit.framework.AssertionFailedError;
|
import junit.framework.AssertionFailedError;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.TextSecureTestCase;
|
import org.junit.Test;
|
||||||
import org.whispersystems.textsecure.api.util.InvalidNumberException;
|
import org.whispersystems.textsecure.api.util.InvalidNumberException;
|
||||||
import org.whispersystems.textsecure.api.util.PhoneNumberFormatter;
|
import org.whispersystems.textsecure.api.util.PhoneNumberFormatter;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
public class PhoneNumberFormatterTest extends TextSecureTestCase {
|
public class PhoneNumberFormatterTest {
|
||||||
private static final String LOCAL_NUMBER = "+15555555555";
|
private static final String LOCAL_NUMBER = "+15555555555";
|
||||||
|
|
||||||
public void testFormatNumberE164() throws Exception, InvalidNumberException {
|
@Test public void testFormatNumberE164() throws Exception, InvalidNumberException {
|
||||||
assertThat(PhoneNumberFormatter.formatNumber("(555) 555-5555", LOCAL_NUMBER)).isEqualTo(LOCAL_NUMBER);
|
assertThat(PhoneNumberFormatter.formatNumber("(555) 555-5555", LOCAL_NUMBER)).isEqualTo(LOCAL_NUMBER);
|
||||||
assertThat(PhoneNumberFormatter.formatNumber("555-5555", LOCAL_NUMBER)).isEqualTo(LOCAL_NUMBER);
|
assertThat(PhoneNumberFormatter.formatNumber("555-5555", LOCAL_NUMBER)).isEqualTo(LOCAL_NUMBER);
|
||||||
assertThat(PhoneNumberFormatter.formatNumber("(123) 555-5555", LOCAL_NUMBER)).isNotEqualTo(LOCAL_NUMBER);
|
assertThat(PhoneNumberFormatter.formatNumber("(123) 555-5555", LOCAL_NUMBER)).isNotEqualTo(LOCAL_NUMBER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFormatNumberEmail() throws Exception {
|
@Test public void testFormatNumberEmail() throws Exception {
|
||||||
try {
|
try {
|
||||||
PhoneNumberFormatter.formatNumber("person@domain.com", LOCAL_NUMBER);
|
PhoneNumberFormatter.formatNumber("person@domain.com", LOCAL_NUMBER);
|
||||||
throw new AssertionFailedError("should have thrown on email");
|
throw new AssertionFailedError("should have thrown on email");
|
||||||
@ -27,9 +25,4 @@ public class PhoneNumberFormatterTest extends TextSecureTestCase {
|
|||||||
// success
|
// success
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setUp() throws Exception {
|
|
||||||
super.setUp();
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -19,15 +19,19 @@ package org.thoughtcrime.securesms.util;
|
|||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import org.thoughtcrime.securesms.TextSecureTestCase;
|
import junit.framework.AssertionFailedError;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
|
|
||||||
public class Rfc5724UriTest extends TextSecureTestCase {
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
public class Rfc5724UriTest {
|
||||||
|
|
||||||
private static final String TAG = Rfc5724UriTest.class.getSimpleName();
|
private static final String TAG = Rfc5724UriTest.class.getSimpleName();
|
||||||
|
|
||||||
public void testInvalidPath() throws Exception {
|
@Test public void testInvalidPath() throws Exception {
|
||||||
final String[] invalidSchemaUris = {
|
final String[] invalidSchemaUris = {
|
||||||
"",
|
"",
|
||||||
":",
|
":",
|
||||||
@ -40,13 +44,14 @@ public class Rfc5724UriTest extends TextSecureTestCase {
|
|||||||
for (String uri : invalidSchemaUris) {
|
for (String uri : invalidSchemaUris) {
|
||||||
try {
|
try {
|
||||||
new Rfc5724Uri(uri);
|
new Rfc5724Uri(uri);
|
||||||
Log.e(TAG, "uri " + uri + " should have failed path check");
|
throw new AssertionFailedError("URISyntaxException should be thrown");
|
||||||
assertTrue(false);
|
} catch (URISyntaxException e) {
|
||||||
} catch (URISyntaxException e) { }
|
// success
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetSchema() throws Exception {
|
@Test public void testGetSchema() throws Exception {
|
||||||
final String[][] uriTestPairs = {
|
final String[][] uriTestPairs = {
|
||||||
{"sms:+15555555555", "sms"},
|
{"sms:+15555555555", "sms"},
|
||||||
{"sMs:+15555555555", "sMs"},
|
{"sMs:+15555555555", "sMs"},
|
||||||
@ -57,15 +62,14 @@ public class Rfc5724UriTest extends TextSecureTestCase {
|
|||||||
|
|
||||||
for (String[] uriTestPair : uriTestPairs) {
|
for (String[] uriTestPair : uriTestPairs) {
|
||||||
final Rfc5724Uri testUri = new Rfc5724Uri(uriTestPair[0]);
|
final Rfc5724Uri testUri = new Rfc5724Uri(uriTestPair[0]);
|
||||||
Log.d(TAG, testUri.getSchema() + " ?= " + uriTestPair[1]);
|
|
||||||
assertTrue(testUri.getSchema().equals(uriTestPair[1]));
|
assertTrue(testUri.getSchema().equals(uriTestPair[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetPath() throws Exception {
|
@Test public void testGetPath() throws Exception {
|
||||||
final String[][] uriTestPairs = {
|
final String[][] uriTestPairs = {
|
||||||
{"sms:+15555555555", "+15555555555"},
|
{"sms:+15555555555", "+15555555555"},
|
||||||
{"sms:%2B49555555555", "%2B555555555"},
|
{"sms:%2B555555555", "%2B555555555"},
|
||||||
{"smsto:+15555555555?", "+15555555555"},
|
{"smsto:+15555555555?", "+15555555555"},
|
||||||
{"mms:+15555555555?a=b", "+15555555555"},
|
{"mms:+15555555555?a=b", "+15555555555"},
|
||||||
{"mmsto:+15555555555?a=b&c=d", "+15555555555"},
|
{"mmsto:+15555555555?a=b&c=d", "+15555555555"},
|
||||||
@ -77,12 +81,11 @@ public class Rfc5724UriTest extends TextSecureTestCase {
|
|||||||
|
|
||||||
for (String[] uriTestPair : uriTestPairs) {
|
for (String[] uriTestPair : uriTestPairs) {
|
||||||
final Rfc5724Uri testUri = new Rfc5724Uri(uriTestPair[0]);
|
final Rfc5724Uri testUri = new Rfc5724Uri(uriTestPair[0]);
|
||||||
Log.d(TAG, testUri.getPath() + " ?= " + uriTestPair[1]);
|
|
||||||
assertTrue(testUri.getPath().equals(uriTestPair[1]));
|
assertTrue(testUri.getPath().equals(uriTestPair[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetQueryParams() throws Exception {
|
@Test public void testGetQueryParams() throws Exception {
|
||||||
final String[][] uriTestPairs = {
|
final String[][] uriTestPairs = {
|
||||||
{"sms:+15555555555", "a", null},
|
{"sms:+15555555555", "a", null},
|
||||||
{"mms:+15555555555?b=", "a", null},
|
{"mms:+15555555555?b=", "a", null},
|
||||||
@ -103,5 +106,4 @@ public class Rfc5724UriTest extends TextSecureTestCase {
|
|||||||
else assertTrue(paramResult.equals(uriTestPair[2]));
|
else assertTrue(paramResult.equals(uriTestPair[2]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user