diff --git a/build.gradle b/build.gradle index 48c74ccfed..7340820c09 100644 --- a/build.gradle +++ b/build.gradle @@ -94,7 +94,7 @@ dependencies { androidTestCompile ('org.assertj:assertj-core:1.7.1') { exclude group: 'org.hamcrest', module: 'hamcrest-core' } - androidTestCompile ('com.squareup.assertj:assertj-android:1.0.0') { + androidTestCompile ('com.squareup.assertj:assertj-android:1.1.1') { exclude group: 'org.hamcrest', module: 'hamcrest-core' exclude group: 'com.android.support', module: 'support-annotations' } @@ -217,6 +217,7 @@ android { 'proguard-shortcutbadger.pro', 'proguard-retrofit.pro', 'proguard.cfg' + testProguardFiles 'proguard-automation.pro' } release { minifyEnabled true diff --git a/src/org/thoughtcrime/securesms/ConversationAdapter.java b/src/org/thoughtcrime/securesms/ConversationAdapter.java index 23bc22115b..523e03b883 100644 --- a/src/org/thoughtcrime/securesms/ConversationAdapter.java +++ b/src/org/thoughtcrime/securesms/ConversationAdapter.java @@ -21,6 +21,7 @@ import android.database.Cursor; import android.support.annotation.LayoutRes; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.annotation.VisibleForTesting; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; @@ -39,7 +40,6 @@ import org.thoughtcrime.securesms.database.model.MessageRecord; import org.thoughtcrime.securesms.recipients.Recipients; import org.thoughtcrime.securesms.util.LRUCache; import org.thoughtcrime.securesms.util.ViewUtil; -import org.thoughtcrime.securesms.util.VisibleForTesting; import java.lang.ref.SoftReference; import java.security.MessageDigest; diff --git a/src/org/thoughtcrime/securesms/database/AttachmentDatabase.java b/src/org/thoughtcrime/securesms/database/AttachmentDatabase.java index ddb10170ed..f591765d1e 100644 --- a/src/org/thoughtcrime/securesms/database/AttachmentDatabase.java +++ b/src/org/thoughtcrime/securesms/database/AttachmentDatabase.java @@ -24,6 +24,7 @@ import android.database.sqlite.SQLiteOpenHelper; import android.net.Uri; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.annotation.VisibleForTesting; import android.text.TextUtils; import android.util.Log; import android.util.Pair; @@ -41,7 +42,6 @@ import org.thoughtcrime.securesms.mms.PartAuthority; import org.thoughtcrime.securesms.util.MediaUtil; import org.thoughtcrime.securesms.util.MediaUtil.ThumbnailData; import org.thoughtcrime.securesms.util.Util; -import org.thoughtcrime.securesms.util.VisibleForTesting; import java.io.File; import java.io.FileNotFoundException; @@ -151,6 +151,7 @@ public class AttachmentDatabase extends Database { notifyConversationListeners(DatabaseFactory.getMmsDatabase(context).getThreadIdForMessage(mmsId)); } + @VisibleForTesting public @Nullable DatabaseAttachment getAttachment(AttachmentId attachmentId) { SQLiteDatabase database = databaseHelper.getReadableDatabase(); Cursor cursor = null; diff --git a/src/org/thoughtcrime/securesms/database/CanonicalAddressDatabase.java b/src/org/thoughtcrime/securesms/database/CanonicalAddressDatabase.java index 9c0b76d460..c1c85c3ec1 100644 --- a/src/org/thoughtcrime/securesms/database/CanonicalAddressDatabase.java +++ b/src/org/thoughtcrime/securesms/database/CanonicalAddressDatabase.java @@ -23,6 +23,7 @@ import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase.CursorFactory; import android.database.sqlite.SQLiteOpenHelper; import android.support.annotation.NonNull; +import android.support.annotation.VisibleForTesting; import android.telephony.PhoneNumberUtils; import android.text.TextUtils; import android.util.Log; @@ -35,7 +36,6 @@ import com.google.i18n.phonenumbers.ShortNumberInfo; import org.thoughtcrime.securesms.util.GroupUtil; import org.thoughtcrime.securesms.util.ShortCodeUtil; import org.thoughtcrime.securesms.util.TextSecurePreferences; -import org.thoughtcrime.securesms.util.VisibleForTesting; import org.whispersystems.signalservice.api.util.InvalidNumberException; import org.whispersystems.signalservice.api.util.PhoneNumberFormatter; diff --git a/src/org/thoughtcrime/securesms/database/CursorRecyclerViewAdapter.java b/src/org/thoughtcrime/securesms/database/CursorRecyclerViewAdapter.java index b68da35a91..174ba25a0f 100644 --- a/src/org/thoughtcrime/securesms/database/CursorRecyclerViewAdapter.java +++ b/src/org/thoughtcrime/securesms/database/CursorRecyclerViewAdapter.java @@ -21,13 +21,12 @@ import android.database.Cursor; import android.database.DataSetObserver; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.annotation.VisibleForTesting; import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView.ViewHolder; import android.view.View; import android.view.ViewGroup; -import org.thoughtcrime.securesms.util.VisibleForTesting; - /** * RecyclerView.Adapter that manages a Cursor, comparable to the CursorAdapter usable in ListView/GridView. */ diff --git a/src/org/thoughtcrime/securesms/jobs/AttachmentDownloadJob.java b/src/org/thoughtcrime/securesms/jobs/AttachmentDownloadJob.java index af91ddc74b..087910a608 100644 --- a/src/org/thoughtcrime/securesms/jobs/AttachmentDownloadJob.java +++ b/src/org/thoughtcrime/securesms/jobs/AttachmentDownloadJob.java @@ -1,6 +1,7 @@ package org.thoughtcrime.securesms.jobs; import android.content.Context; +import android.support.annotation.VisibleForTesting; import android.text.TextUtils; import android.util.Log; @@ -17,7 +18,6 @@ import org.thoughtcrime.securesms.events.PartProgressEvent; import org.thoughtcrime.securesms.jobs.requirements.MasterSecretRequirement; import org.thoughtcrime.securesms.jobs.requirements.MediaNetworkRequirement; import org.thoughtcrime.securesms.notifications.MessageNotifier; -import org.thoughtcrime.securesms.util.VisibleForTesting; import org.whispersystems.jobqueue.JobParameters; import org.whispersystems.jobqueue.requirements.NetworkRequirement; import org.whispersystems.libsignal.InvalidMessageException; diff --git a/src/org/thoughtcrime/securesms/service/SmsListener.java b/src/org/thoughtcrime/securesms/service/SmsListener.java index 990629128d..0be3f11ae0 100644 --- a/src/org/thoughtcrime/securesms/service/SmsListener.java +++ b/src/org/thoughtcrime/securesms/service/SmsListener.java @@ -24,6 +24,7 @@ import android.os.Bundle; import android.provider.Telephony; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.support.annotation.VisibleForTesting; import android.telephony.SmsMessage; import android.util.Log; @@ -31,7 +32,6 @@ import org.thoughtcrime.securesms.ApplicationContext; import org.thoughtcrime.securesms.jobs.SmsReceiveJob; import org.thoughtcrime.securesms.util.TextSecurePreferences; import org.thoughtcrime.securesms.util.Util; -import org.thoughtcrime.securesms.util.VisibleForTesting; import java.util.regex.Matcher; import java.util.regex.Pattern; diff --git a/src/org/thoughtcrime/securesms/util/VisibleForTesting.java b/src/org/thoughtcrime/securesms/util/VisibleForTesting.java deleted file mode 100644 index 3a8a9d7b5f..0000000000 --- a/src/org/thoughtcrime/securesms/util/VisibleForTesting.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.thoughtcrime.securesms.util; - -public @interface VisibleForTesting { -} diff --git a/test/androidTest/java/org/thoughtcrime/securesms/TextSecureTestCase.java b/test/androidTest/java/org/thoughtcrime/securesms/TextSecureTestCase.java index 2e00e238c2..0de79c8d4b 100644 --- a/test/androidTest/java/org/thoughtcrime/securesms/TextSecureTestCase.java +++ b/test/androidTest/java/org/thoughtcrime/securesms/TextSecureTestCase.java @@ -6,7 +6,7 @@ import android.test.InstrumentationTestCase; public class TextSecureTestCase extends InstrumentationTestCase { @Override - public void setUp() throws Exception { + public void setUp() { System.setProperty("dexmaker.dexcache", getInstrumentation().getTargetContext().getCacheDir().getPath()); } diff --git a/test/androidTest/java/org/thoughtcrime/securesms/database/AttachmentDatabaseTest.java b/test/androidTest/java/org/thoughtcrime/securesms/database/AttachmentDatabaseTest.java index 94e8763c51..f4af133343 100644 --- a/test/androidTest/java/org/thoughtcrime/securesms/database/AttachmentDatabaseTest.java +++ b/test/androidTest/java/org/thoughtcrime/securesms/database/AttachmentDatabaseTest.java @@ -29,6 +29,7 @@ public class AttachmentDatabaseTest extends TextSecureTestCase { @Override public void setUp() { + super.setUp(); database = spy(DatabaseFactory.getAttachmentDatabase(getInstrumentation().getTargetContext())); } diff --git a/test/androidTest/java/org/thoughtcrime/securesms/database/CanonicalAddressDatabaseTest.java b/test/androidTest/java/org/thoughtcrime/securesms/database/CanonicalAddressDatabaseTest.java index 0d05570ff6..a8fd6c3699 100644 --- a/test/androidTest/java/org/thoughtcrime/securesms/database/CanonicalAddressDatabaseTest.java +++ b/test/androidTest/java/org/thoughtcrime/securesms/database/CanonicalAddressDatabaseTest.java @@ -16,7 +16,8 @@ public class CanonicalAddressDatabaseTest extends TextSecureTestCase { private CanonicalAddressDatabase db; - public void setUp() throws Exception { + @Override + public void setUp() { super.setUp(); this.db = CanonicalAddressDatabase.getInstance(getInstrumentation().getTargetContext()); } diff --git a/test/unitTest/java/org/thoughtcrime/securesms/jobs/DeliveryReceiptJobTest.java b/test/unitTest/java/org/thoughtcrime/securesms/jobs/DeliveryReceiptJobTest.java index 00e3117317..9439f09011 100644 --- a/test/unitTest/java/org/thoughtcrime/securesms/jobs/DeliveryReceiptJobTest.java +++ b/test/unitTest/java/org/thoughtcrime/securesms/jobs/DeliveryReceiptJobTest.java @@ -45,6 +45,7 @@ public class DeliveryReceiptJobTest extends BaseUnitTest { assertTrue(captor.getValue().getNumber().equals("+14152222222")); } + @Test public void testNetworkError() throws IOException { SignalServiceMessageSender textSecureMessageSender = mock(SignalServiceMessageSender.class); long timestamp = System.currentTimeMillis();