1) renamed test build type to 'debugTest' because updated gradle

plugin doesn't allow build types to start with 'test'.

2) exclude support-annotations to avoid warning

Closes #3273
// FREEBIE
This commit is contained in:
Rhodey Orbits 2015-06-01 21:44:10 -07:00 committed by Moxie Marlinspike
parent 200fc0c599
commit 5fe7c687f3
3 changed files with 16 additions and 19 deletions

View File

@ -76,7 +76,11 @@ dependencies {
exclude group: 'org.hamcrest', module: 'hamcrest-core' exclude group: 'org.hamcrest', module: 'hamcrest-core'
} }
androidTestCompile ('com.squareup.assertj:assertj-android:1.0.0') { androidTestCompile ('com.squareup.assertj:assertj-android:1.0.0') {
exclude group: 'org.hamcrest', module: 'hamcrest-core' exclude group: 'org.hamcrest', module: 'hamcrest-core'
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') { androidTestCompile ('com.android.support.test.espresso:espresso-core:2.1') {
exclude group: 'javax.inject' exclude group: 'javax.inject'
@ -131,7 +135,7 @@ dependencyVerification {
android { android {
compileSdkVersion 22 compileSdkVersion 22
buildToolsVersion '22.0.1' buildToolsVersion '22.0.1'
testBuildType "testing" testBuildType "debugTest"
dexOptions { dexOptions {
javaMaxHeapSize "4g" javaMaxHeapSize "4g"
@ -186,8 +190,8 @@ android {
proguardFiles = buildTypes.debug.proguardFiles proguardFiles = buildTypes.debug.proguardFiles
signingConfig signingConfigs.release signingConfig signingConfigs.release
} }
testing.initWith(buildTypes.debug) debugTest.initWith(buildTypes.debug)
testing { debugTest {
proguardFile 'proguard-testing.pro' proguardFile 'proguard-testing.pro'
buildConfigField "String", "PUSH_URL", "\"https://textsecure-service-staging.whispersystems.org\"" buildConfigField "String", "PUSH_URL", "\"https://textsecure-service-staging.whispersystems.org\""
} }

View File

@ -640,15 +640,5 @@ public class PartDatabase extends Database {
public boolean isValid() { public boolean isValid() {
return rowId >= 0 && uniqueId >= 0; return rowId >= 0 && uniqueId >= 0;
} }
@Override
public boolean equals(Object object) {
if (!(object instanceof PartId)){
return false;
}
PartId other = (PartId) object;
return rowId == other.rowId && uniqueId == other.uniqueId;
}
} }
} }

View File

@ -34,21 +34,24 @@ public class PartDatabaseTest extends TextSecureTestCase {
} }
public void testTaskNotRunWhenThumbnailExists() throws Exception { public void testTaskNotRunWhenThumbnailExists() throws Exception {
when(database.getPart(new PartId(ROW_ID, UNIQUE_ID))).thenReturn(getPduPartSkeleton("x/x")); final PartId partId = new PartId(ROW_ID, UNIQUE_ID);
doReturn(mock(InputStream.class)).when(database).getDataStream(any(MasterSecret.class), any(PartId.class), eq("thumbnail"));
database.getThumbnailStream(null, new PartId(ROW_ID, UNIQUE_ID)); when(database.getPart(partId)).thenReturn(getPduPartSkeleton("x/x"));
doReturn(mock(InputStream.class)).when(database).getDataStream(any(MasterSecret.class), any(PartId.class), eq("thumbnail"));
database.getThumbnailStream(null, partId);
verify(database, never()).updatePartThumbnail(any(MasterSecret.class), any(PartId.class), any(PduPart.class), any(InputStream.class), anyFloat()); verify(database, never()).updatePartThumbnail(any(MasterSecret.class), any(PartId.class), any(PduPart.class), any(InputStream.class), anyFloat());
} }
public void testTaskRunWhenThumbnailMissing() throws Exception { public void testTaskRunWhenThumbnailMissing() throws Exception {
when(database.getPart(new PartId(ROW_ID, UNIQUE_ID))).thenReturn(getPduPartSkeleton("image/png")); final PartId partId = new PartId(ROW_ID, UNIQUE_ID);
when(database.getPart(partId)).thenReturn(getPduPartSkeleton("image/png"));
doReturn(null).when(database).getDataStream(any(MasterSecret.class), any(PartId.class), eq("thumbnail")); doReturn(null).when(database).getDataStream(any(MasterSecret.class), any(PartId.class), eq("thumbnail"));
doNothing().when(database).updatePartThumbnail(any(MasterSecret.class), any(PartId.class), any(PduPart.class), any(InputStream.class), anyFloat()); doNothing().when(database).updatePartThumbnail(any(MasterSecret.class), any(PartId.class), any(PduPart.class), any(InputStream.class), anyFloat());
try { try {
database.new ThumbnailFetchCallable(mock(MasterSecret.class), new PartId(ROW_ID, UNIQUE_ID)).call(); database.new ThumbnailFetchCallable(mock(MasterSecret.class), partId).call();
throw new AssertionError("didn't try to generate thumbnail"); throw new AssertionError("didn't try to generate thumbnail");
} catch (FileNotFoundException fnfe) { } catch (FileNotFoundException fnfe) {
// success // success