From 91bf5532b203cc9ec015a07f8a1a03da2f17eedb Mon Sep 17 00:00:00 2001 From: Jake McGinty Date: Mon, 12 Jan 2015 11:34:36 -1000 Subject: [PATCH] workaround dexmaker bug in test cases // FREEBIE --- .../securesms/TextSecureTestCase.java | 16 ++++++++++++++++ .../database/CanonicalAddressDatabaseTest.java | 4 ++-- .../securesms/database/PartDatabaseTest.java | 5 ++--- .../securesms/jobs/CleanPreKeysJobTest.java | 3 ++- .../securesms/jobs/DeliveryReceiptJobTest.java | 3 ++- .../securesms/util/PhoneNumberFormatterTest.java | 3 ++- 6 files changed, 26 insertions(+), 8 deletions(-) create mode 100644 androidTest/java/org/thoughtcrime/securesms/TextSecureTestCase.java diff --git a/androidTest/java/org/thoughtcrime/securesms/TextSecureTestCase.java b/androidTest/java/org/thoughtcrime/securesms/TextSecureTestCase.java new file mode 100644 index 0000000000..2e00e238c2 --- /dev/null +++ b/androidTest/java/org/thoughtcrime/securesms/TextSecureTestCase.java @@ -0,0 +1,16 @@ +package org.thoughtcrime.securesms; + +import android.content.Context; +import android.test.InstrumentationTestCase; + +public class TextSecureTestCase extends InstrumentationTestCase { + + @Override + public void setUp() throws Exception { + System.setProperty("dexmaker.dexcache", getInstrumentation().getTargetContext().getCacheDir().getPath()); + } + + protected Context getContext() { + return getInstrumentation().getContext(); + } +} diff --git a/androidTest/java/org/thoughtcrime/securesms/database/CanonicalAddressDatabaseTest.java b/androidTest/java/org/thoughtcrime/securesms/database/CanonicalAddressDatabaseTest.java index 344c7fa0ca..eb5b78edc8 100644 --- a/androidTest/java/org/thoughtcrime/securesms/database/CanonicalAddressDatabaseTest.java +++ b/androidTest/java/org/thoughtcrime/securesms/database/CanonicalAddressDatabaseTest.java @@ -1,10 +1,10 @@ package org.thoughtcrime.securesms.database; -import android.test.InstrumentationTestCase; +import org.thoughtcrime.securesms.TextSecureTestCase; import static org.fest.assertions.api.Assertions.assertThat; -public class CanonicalAddressDatabaseTest extends InstrumentationTestCase { +public class CanonicalAddressDatabaseTest extends TextSecureTestCase { private static final String AMBIGUOUS_NUMBER = "222-3333"; private static final String SPECIFIC_NUMBER = "+49 444 222 3333"; private static final String EMAIL = "a@b.fom"; diff --git a/androidTest/java/org/thoughtcrime/securesms/database/PartDatabaseTest.java b/androidTest/java/org/thoughtcrime/securesms/database/PartDatabaseTest.java index dfba5cbccc..a16e426094 100644 --- a/androidTest/java/org/thoughtcrime/securesms/database/PartDatabaseTest.java +++ b/androidTest/java/org/thoughtcrime/securesms/database/PartDatabaseTest.java @@ -1,8 +1,8 @@ package org.thoughtcrime.securesms.database; import android.net.Uri; -import android.test.InstrumentationTestCase; +import org.thoughtcrime.securesms.TextSecureTestCase; import org.thoughtcrime.securesms.crypto.MasterSecret; import java.io.FileNotFoundException; @@ -19,11 +19,10 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.never; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -public class PartDatabaseTest extends InstrumentationTestCase { +public class PartDatabaseTest extends TextSecureTestCase { private static final long PART_ID = 1L; private PartDatabase database; diff --git a/androidTest/java/org/thoughtcrime/securesms/jobs/CleanPreKeysJobTest.java b/androidTest/java/org/thoughtcrime/securesms/jobs/CleanPreKeysJobTest.java index a8a8b1d85f..584d30475d 100644 --- a/androidTest/java/org/thoughtcrime/securesms/jobs/CleanPreKeysJobTest.java +++ b/androidTest/java/org/thoughtcrime/securesms/jobs/CleanPreKeysJobTest.java @@ -2,6 +2,7 @@ package org.thoughtcrime.securesms.jobs; import android.test.AndroidTestCase; +import org.thoughtcrime.securesms.TextSecureTestCase; import org.thoughtcrime.securesms.crypto.MasterSecret; import org.thoughtcrime.securesms.dependencies.AxolotlStorageModule; import org.whispersystems.libaxolotl.ecc.Curve; @@ -28,7 +29,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; -public class CleanPreKeysJobTest extends AndroidTestCase { +public class CleanPreKeysJobTest extends TextSecureTestCase { public void testSignedPreKeyRotationNotRegistered() throws IOException, MasterSecretJob.RequirementNotMetException { TextSecureAccountManager accountManager = mock(TextSecureAccountManager.class); diff --git a/androidTest/java/org/thoughtcrime/securesms/jobs/DeliveryReceiptJobTest.java b/androidTest/java/org/thoughtcrime/securesms/jobs/DeliveryReceiptJobTest.java index 3f0ed91c8b..8ea87763ab 100644 --- a/androidTest/java/org/thoughtcrime/securesms/jobs/DeliveryReceiptJobTest.java +++ b/androidTest/java/org/thoughtcrime/securesms/jobs/DeliveryReceiptJobTest.java @@ -4,6 +4,7 @@ import android.test.AndroidTestCase; import org.mockito.ArgumentCaptor; import org.mockito.Mockito; +import org.thoughtcrime.securesms.TextSecureTestCase; import org.thoughtcrime.securesms.crypto.MasterSecret; import org.whispersystems.textsecure.api.TextSecureMessageSender; import org.whispersystems.textsecure.api.push.PushAddress; @@ -22,7 +23,7 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.thoughtcrime.securesms.dependencies.TextSecureCommunicationModule.TextSecureMessageSenderFactory; -public class DeliveryReceiptJobTest extends AndroidTestCase { +public class DeliveryReceiptJobTest extends TextSecureTestCase { public void testDelivery() throws IOException { TextSecureMessageSender textSecureMessageSender = mock(TextSecureMessageSender.class); diff --git a/androidTest/java/org/thoughtcrime/securesms/util/PhoneNumberFormatterTest.java b/androidTest/java/org/thoughtcrime/securesms/util/PhoneNumberFormatterTest.java index 9740c28905..cacbd1013b 100644 --- a/androidTest/java/org/thoughtcrime/securesms/util/PhoneNumberFormatterTest.java +++ b/androidTest/java/org/thoughtcrime/securesms/util/PhoneNumberFormatterTest.java @@ -4,11 +4,12 @@ import android.test.AndroidTestCase; import junit.framework.AssertionFailedError; +import org.thoughtcrime.securesms.TextSecureTestCase; import org.whispersystems.textsecure.api.util.InvalidNumberException; import org.whispersystems.textsecure.api.util.PhoneNumberFormatter; import static org.fest.assertions.api.Assertions.assertThat; -public class PhoneNumberFormatterTest extends AndroidTestCase { +public class PhoneNumberFormatterTest extends TextSecureTestCase { private static final String LOCAL_NUMBER = "+15555555555"; public void testFormatNumberE164() throws Exception, InvalidNumberException {