Update Robolectric to 3.7.1 and simplify test annotations

This commit is contained in:
cketti 2018-02-25 01:28:42 +01:00
parent 149603618b
commit 5d93d1139e
47 changed files with 116 additions and 169 deletions

View file

@ -4,7 +4,7 @@ androidBuildToolsVersion=27.0.3
androidSupportLibraryVersion=27.0.2
timberVersion=4.5.1
robolectricVersion=3.2.2
robolectricVersion=3.7.1
junitVersion=4.12
mockitoVersion=1.10.19
okioVersion=1.11.0

View file

@ -109,6 +109,12 @@ android {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
testOptions {
unitTests {
includeAndroidResources = true
}
}
}
if (project.hasProperty('keyAlias')) {

View file

@ -1,20 +0,0 @@
package com.fsck.k9;
import org.junit.runners.model.InitializationError;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
public class K9RobolectricTestRunner extends RobolectricTestRunner {
public K9RobolectricTestRunner(Class<?> testClass) throws InitializationError {
super(testClass);
}
@Override
protected Config buildGlobalConfig() {
return new Config.Builder()
.setSdk(22)
.setManifest("src/main/AndroidManifest.xml")
.build();
}
}

View file

@ -5,11 +5,11 @@ import android.content.Context;
import com.fsck.k9.Account;
import com.fsck.k9.K9;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.mail.Message;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import static junit.framework.Assert.assertEquals;
@ -17,7 +17,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(K9RobolectricTestRunner.class)
@RunWith(RobolectricTestRunner.class)
public class ActivityListenerTest {
private static final String FOLDER = "folder";
private static final String ERROR_MESSAGE = "errorMessage";

View file

@ -1,11 +1,10 @@
package com.fsck.k9.activity;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.mail.Flag;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import org.robolectric.RobolectricTestRunner;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
@ -14,8 +13,7 @@ import static junit.framework.Assert.assertTrue;
import static org.junit.Assert.assertNotNull;
@RunWith(K9RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
@RunWith(RobolectricTestRunner.class)
public class MessageReferenceTest {
@Test

View file

@ -10,17 +10,17 @@ import android.net.Uri;
import android.provider.ContactsContract;
import android.provider.ContactsContract.CommonDataKinds.Email;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.mail.Address;
import com.fsck.k9.view.RecipientSelectView.Recipient;
import com.fsck.k9.view.RecipientSelectView.RecipientCryptoStatus;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import static android.provider.ContactsContract.CommonDataKinds.Email.TYPE_HOME;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.mockito.AdditionalMatchers.aryEq;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
@ -29,7 +29,7 @@ import static org.mockito.Mockito.when;
@SuppressWarnings("WeakerAccess")
@RunWith(K9RobolectricTestRunner.class)
@RunWith(RobolectricTestRunner.class)
public class RecipientLoaderTest {
static final String CRYPTO_PROVIDER = "cryptoProvider";
static final String[] PROJECTION = {

View file

@ -11,7 +11,6 @@ import android.os.ParcelFileDescriptor;
import com.fsck.k9.Account;
import com.fsck.k9.K9;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.activity.compose.RecipientMvpView.CryptoSpecialModeDisplayType;
import com.fsck.k9.activity.compose.RecipientMvpView.CryptoStatusDisplayType;
import com.fsck.k9.activity.compose.RecipientPresenter.CryptoMode;
@ -34,6 +33,7 @@ import org.openintents.openpgp.util.OpenPgpApi;
import org.openintents.openpgp.util.OpenPgpServiceConnection;
import org.openintents.openpgp.util.ShadowOpenPgpAsyncTask;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowApplication;
@ -49,8 +49,8 @@ import static org.mockito.Mockito.when;
@SuppressWarnings("ConstantConditions")
@RunWith(K9RobolectricTestRunner.class)
@Config(shadows = {ShadowOpenPgpAsyncTask.class})
@RunWith(RobolectricTestRunner.class)
@Config(shadows = { ShadowOpenPgpAsyncTask.class })
public class RecipientPresenterTest {
private static final ReplyToAddresses TO_ADDRESSES = new ReplyToAddresses(Address.parse("to@example.org"));
private static final List<Address> ALL_TO_ADDRESSES = Arrays.asList(Address.parse("allTo@example.org"));

View file

@ -1,15 +1,15 @@
package com.fsck.k9.activity.misc;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.mail.Address;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import static org.junit.Assert.assertEquals;
@RunWith(K9RobolectricTestRunner.class)
@RunWith(RobolectricTestRunner.class)
public class ContactPictureLoaderTest {
@Test

View file

@ -1,7 +1,6 @@
package com.fsck.k9.autocrypt;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
@ -14,7 +13,6 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@ -22,8 +20,6 @@ import static org.junit.Assert.assertNull;
@RunWith(RobolectricTestRunner.class)
@Config(manifest = Config.NONE, sdk = 21)
@SuppressWarnings("WeakerAccess")
public class AutocryptHeaderParserTest {
AutocryptHeaderParser autocryptHeaderParser = AutocryptHeaderParser.getInstance();
@ -123,8 +119,6 @@ public class AutocryptHeaderParserTest {
}
private InputStream readFromResourceFile(String name) throws FileNotFoundException {
return new FileInputStream(RuntimeEnvironment.application.getPackageResourcePath() + "/src/test/resources/" + name);
return getClass().getResourceAsStream("/" + name);
}
}
}

View file

@ -1,20 +1,19 @@
package com.fsck.k9.cache;
import com.fsck.k9.K9RobolectricTestRunner;
import java.util.Collections;
import java.util.UUID;
import com.fsck.k9.mailstore.LocalFolder;
import com.fsck.k9.mailstore.LocalMessage;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import java.util.Collections;
import java.util.UUID;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
@ -24,7 +23,7 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.when;
@RunWith(K9RobolectricTestRunner.class)
@RunWith(RobolectricTestRunner.class)
public class EmailProviderCacheTest {
private EmailProviderCache cache;

View file

@ -14,7 +14,6 @@ import android.content.Context;
import com.fsck.k9.Account;
import com.fsck.k9.AccountStats;
import com.fsck.k9.K9;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.Preferences;
import com.fsck.k9.helper.Contacts;
import com.fsck.k9.mail.AuthenticationFailedException;
@ -46,6 +45,7 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.shadows.ShadowApplication;
import org.robolectric.shadows.ShadowLog;
@ -70,7 +70,7 @@ import static org.mockito.Mockito.when;
@SuppressWarnings("unchecked")
@RunWith(K9RobolectricTestRunner.class)
@RunWith(RobolectricTestRunner.class)
public class MessagingControllerTest {
private static final String FOLDER_NAME = "Folder";
private static final String SENT_FOLDER_NAME = "Sent";

View file

@ -11,7 +11,6 @@ import android.content.Context;
import com.fsck.k9.Account;
import com.fsck.k9.AccountStats;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.controller.MessagingController;
import com.fsck.k9.controller.MessagingListener;
import com.fsck.k9.controller.SimpleMessagingListener;
@ -34,6 +33,7 @@ import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.shadows.ShadowApplication;
import org.robolectric.shadows.ShadowLog;
@ -51,7 +51,7 @@ import static org.mockito.Mockito.when;
@SuppressWarnings("unchecked")
@RunWith(K9RobolectricTestRunner.class)
@RunWith(RobolectricTestRunner.class)
public class ImapSyncTest {
private static final String FOLDER_NAME = "Folder";
private static final int MAXIMUM_SMALL_MESSAGE_SIZE = 1000;

View file

@ -4,7 +4,6 @@ package com.fsck.k9.crypto;
import java.util.ArrayList;
import java.util.List;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.mail.BodyPart;
import com.fsck.k9.mail.Message;
import com.fsck.k9.mail.Multipart;
@ -15,7 +14,7 @@ import com.fsck.k9.mail.internet.TextBody;
import com.fsck.k9.ui.crypto.MessageCryptoAnnotations;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import org.robolectric.RobolectricTestRunner;
import static com.fsck.k9.message.TestMessageConstructionUtils.bodypart;
import static com.fsck.k9.message.TestMessageConstructionUtils.messageFromBody;
@ -29,8 +28,7 @@ import static org.mockito.Mockito.mock;
@SuppressWarnings("WeakerAccess")
@RunWith(K9RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
@RunWith(RobolectricTestRunner.class)
public class MessageCryptoStructureDetectorTest {
MessageCryptoAnnotations messageCryptoAnnotations = mock(MessageCryptoAnnotations.class);
static final String PGP_INLINE_DATA = "" +

View file

@ -2,16 +2,14 @@ package com.fsck.k9.crypto;
import com.fsck.k9.Identity;
import com.fsck.k9.K9RobolectricTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import org.robolectric.RobolectricTestRunner;
import static org.junit.Assert.assertEquals;
@RunWith(K9RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
@RunWith(RobolectricTestRunner.class)
public class OpenPgpApiHelperTest {
@Test

View file

@ -3,7 +3,6 @@ package com.fsck.k9.helper
import com.fsck.k9.Account
import com.fsck.k9.Identity
import com.fsck.k9.K9RobolectricTestRunner
import com.fsck.k9.mail.Address
import com.fsck.k9.mail.Message
import com.fsck.k9.mail.Message.RecipientType
@ -11,9 +10,10 @@ import com.fsck.k9.mail.internet.MimeMessage
import com.google.common.truth.Truth.assertThat
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
@RunWith(K9RobolectricTestRunner::class)
@RunWith(RobolectricTestRunner::class)
class IdentityHelperTest {
private val account = createDummyAccount()

View file

@ -7,14 +7,13 @@ import java.util.List;
import android.net.Uri;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.helper.MailTo.CaseInsensitiveParamWrapper;
import com.fsck.k9.mail.Address;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import org.robolectric.RobolectricTestRunner;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
@ -23,8 +22,7 @@ import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
@RunWith(K9RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
@RunWith(RobolectricTestRunner.class)
public class MailToTest {
@Rule
public ExpectedException exception = ExpectedException.none();

View file

@ -5,20 +5,18 @@ import android.content.Context;
import android.graphics.Color;
import android.text.SpannableString;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.mail.Address;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertTrue;
@RunWith(K9RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
@RunWith(RobolectricTestRunner.class)
public class MessageHelperTest {
private Contacts contacts;
private Contacts contactsWithFakeContact;

View file

@ -5,7 +5,6 @@ import java.lang.reflect.Array;
import java.util.ArrayList;
import com.fsck.k9.Account;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.helper.ReplyToParser.ReplyToAddresses;
import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.Message;
@ -14,7 +13,7 @@ import com.fsck.k9.mail.internet.ListHeaders;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import org.robolectric.RobolectricTestRunner;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
@ -26,8 +25,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(K9RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
@RunWith(RobolectricTestRunner.class)
public class ReplyToParserTest {
private static final Address[] REPLY_TO_ADDRESSES = Address.parse("replyTo1@example.com, replyTo2@example.com");
private static final Address[] LIST_POST_ADDRESSES = Address.parse("listPost@example.com");

View file

@ -5,7 +5,6 @@ import java.util.Map;
import android.net.Uri;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.mail.BodyPart;
import com.fsck.k9.mail.Multipart;
import com.fsck.k9.mail.Part;
@ -16,9 +15,10 @@ import com.fsck.k9.message.extractors.AttachmentInfoExtractor;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import org.robolectric.RobolectricTestRunner;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
@ -26,8 +26,7 @@ import static org.mockito.Mockito.when;
@SuppressWarnings("unchecked")
@RunWith(K9RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
@RunWith(RobolectricTestRunner.class)
public class AttachmentResolverTest {
public static final Uri ATTACHMENT_TEST_URI_1 = Uri.parse("uri://test/1");
public static final Uri ATTACHMENT_TEST_URI_2 = Uri.parse("uri://test/2");

View file

@ -7,14 +7,13 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.mailstore.util.FileFactory;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import org.robolectric.RobolectricTestRunner;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
@ -23,8 +22,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
@RunWith(K9RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
@RunWith(RobolectricTestRunner.class)
public class DeferredFileBodyTest {
public static final String TEST_ENCODING = "test-encoding";
public static final byte[] TEST_DATA_SHORT = "test data".getBytes();
@ -143,4 +141,4 @@ public class DeferredFileBodyTest {
outputStream.write(TEST_DATA_LONG);
outputStream.close();
}
}
}

View file

@ -12,7 +12,6 @@ import android.app.Application;
import android.support.annotation.NonNull;
import com.fsck.k9.GlobalsHelper;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.activity.K9ActivityCommon;
import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.BodyPart;
@ -39,6 +38,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import static com.fsck.k9.message.TestMessageConstructionUtils.bodypart;
@ -56,7 +56,7 @@ import static org.mockito.Mockito.when;
@SuppressWarnings("WeakerAccess")
@RunWith(K9RobolectricTestRunner.class)
@RunWith(RobolectricTestRunner.class)
public class MessageViewInfoExtractorTest {
public static final String BODY_TEXT = "K-9 Mail rocks :>";
public static final String BODY_TEXT_HTML = "K-9 Mail rocks :&gt;";

View file

@ -14,7 +14,6 @@ import android.database.sqlite.SQLiteDatabase;
import com.fsck.k9.Account;
import com.fsck.k9.K9;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.Preferences;
import com.fsck.k9.mail.BodyPart;
import com.fsck.k9.mail.FetchProfile;
@ -29,11 +28,13 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openintents.openpgp.util.OpenPgpUtils;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.shadows.ShadowLog;
import org.robolectric.shadows.ShadowSQLiteConnection;
@RunWith(K9RobolectricTestRunner.class)
@RunWith(RobolectricTestRunner.class)
public class MigrationTest {
Account account;

View file

@ -17,14 +17,13 @@ import com.fsck.k9.Account;
import com.fsck.k9.BuildConfig;
import com.fsck.k9.GlobalsHelper;
import com.fsck.k9.K9;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.R;
import com.fsck.k9.mail.MessagingException;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import org.robolectric.shadows.ShadowLog;
import static org.junit.Assert.assertEquals;
@ -37,8 +36,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(K9RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
@RunWith(RobolectricTestRunner.class)
public class StoreSchemaDefinitionTest {
private StoreSchemaDefinition storeSchemaDefinition;

View file

@ -3,14 +3,14 @@ package com.fsck.k9.mailstore.migrations;
import android.content.ContentValues;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.mailstore.migrations.MigrationTo51.MimeStructureState;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
@RunWith(K9RobolectricTestRunner.class) // required for ContentValues
@RunWith(RobolectricTestRunner.class) // required for ContentValues
public class MigrationMimeStructureStateTest {
@Test(expected = IllegalStateException.class)

View file

@ -15,7 +15,6 @@ import android.app.Application;
import com.fsck.k9.Account.QuoteStyle;
import com.fsck.k9.Identity;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.activity.misc.Attachment;
import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.BodyPart;
@ -33,6 +32,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.robolectric.Robolectric;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import static org.junit.Assert.assertArrayEquals;
@ -45,7 +45,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
@RunWith(K9RobolectricTestRunner.class)
@RunWith(RobolectricTestRunner.class)
public class MessageBuilderTest {
public static final String TEST_MESSAGE_TEXT = "soviet message\r\ntext ☭";
public static final String TEST_ATTACHMENT_TEXT = "text data in attachment";

View file

@ -17,7 +17,6 @@ import android.os.Bundle;
import com.fsck.k9.Account.QuoteStyle;
import com.fsck.k9.Identity;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.activity.compose.ComposeCryptoStatus;
import com.fsck.k9.activity.compose.ComposeCryptoStatus.ComposeCryptoStatusBuilder;
import com.fsck.k9.activity.compose.RecipientPresenter.CryptoMode;
@ -49,6 +48,7 @@ import org.mockito.ArgumentCaptor;
import org.openintents.openpgp.OpenPgpError;
import org.openintents.openpgp.util.OpenPgpApi;
import org.openintents.openpgp.util.OpenPgpApi.OpenPgpDataSource;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import static com.fsck.k9.autocrypt.AutocryptOperationsHelper.assertMessageHasAutocryptHeader;
@ -65,7 +65,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
@RunWith(K9RobolectricTestRunner.class)
@RunWith(RobolectricTestRunner.class)
public class PgpMessageBuilderTest {
private static final long TEST_KEY_ID = 123L;
private static final String TEST_MESSAGE_TEXT = "message text with a ☭ CCCP symbol";

View file

@ -5,20 +5,19 @@ import android.content.Context;
import android.net.Uri;
import android.support.annotation.Nullable;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.mail.Part;
import com.fsck.k9.mail.internet.MimeBodyPart;
import com.fsck.k9.mail.internet.MimeHeader;
import com.fsck.k9.mail.internet.TextBody;
import com.fsck.k9.mailstore.AttachmentViewInfo;
import com.fsck.k9.mailstore.LocalBodyPart;
import com.fsck.k9.mailstore.DeferredFileBody;
import com.fsck.k9.mailstore.LocalBodyPart;
import com.fsck.k9.provider.AttachmentProvider;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@ -27,8 +26,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(K9RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
@RunWith(RobolectricTestRunner.class)
public class AttachmentInfoExtractorTest {
public static final Uri TEST_URI = Uri.parse("uri://test");
public static final String TEST_MIME_TYPE = "text/plain";

View file

@ -1,11 +1,11 @@
package com.fsck.k9.message.extractors;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.mail.Message;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import static com.fsck.k9.message.MessageCreationHelper.createMessage;
import static com.fsck.k9.message.MessageCreationHelper.createMultipartMessage;
@ -16,7 +16,8 @@ import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(K9RobolectricTestRunner.class)
@RunWith(RobolectricTestRunner.class)
public class EncryptionDetectorTest {
private static final String CRLF = "\r\n";

View file

@ -1,20 +1,18 @@
package com.fsck.k9.message.extractors;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.mail.Part;
import com.fsck.k9.mail.internet.MimeBodyPart;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import org.robolectric.RobolectricTestRunner;
import static com.fsck.k9.message.MessageCreationHelper.createTextPart;
import static org.junit.Assert.assertEquals;
@RunWith(K9RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
@RunWith(RobolectricTestRunner.class)
public class PreviewTextExtractorTest {
private PreviewTextExtractor previewTextExtractor;

View file

@ -8,7 +8,6 @@ import java.io.IOException;
import com.fsck.k9.K9;
import com.fsck.k9.K9.Theme;
import com.fsck.k9.K9RobolectricTestRunner;
import org.apache.commons.io.IOUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
@ -16,13 +15,12 @@ import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import org.robolectric.RobolectricTestRunner;
import static junit.framework.Assert.assertEquals;
@RunWith(K9RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
@RunWith(RobolectricTestRunner.class)
public class HtmlConverterTest {
// Useful if you want to write stuff to a file for debugging in a browser.
private static final boolean WRITE_TO_FILE = Boolean.parseBoolean(System.getProperty("k9.htmlConverterTest.writeToFile", "false"));

View file

@ -1,18 +1,15 @@
package com.fsck.k9.message.signature;
import com.fsck.k9.K9RobolectricTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import org.robolectric.RobolectricTestRunner;
import static com.fsck.k9.message.html.HtmlHelper.extractText;
import static org.junit.Assert.assertEquals;
@RunWith(K9RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
@RunWith(RobolectricTestRunner.class)
public class HtmlSignatureRemoverTest {
@Test
public void shouldStripSignatureFromK9StyleHtml() throws Exception {

View file

@ -9,12 +9,12 @@ import android.support.v4.app.NotificationCompat.Builder;
import android.support.v4.app.NotificationManagerCompat;
import com.fsck.k9.Account;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.MockHelper;
import com.fsck.k9.R;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import static org.mockito.Matchers.any;
@ -24,7 +24,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(K9RobolectricTestRunner.class)
@RunWith(RobolectricTestRunner.class)
public class AuthenticationErrorNotificationsTest {
private static final boolean INCOMING = true;
private static final boolean OUTGOING = false;

View file

@ -7,13 +7,12 @@ import android.support.v4.app.NotificationCompat.Builder;
import com.fsck.k9.Account;
import com.fsck.k9.K9;
import com.fsck.k9.K9.NotificationQuickDelete;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.MockHelper;
import com.fsck.k9.R;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import org.robolectric.RobolectricTestRunner;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
@ -23,8 +22,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(K9RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
@RunWith(RobolectricTestRunner.class)
public class BaseNotificationsTest {
private static final int ACCOUNT_COLOR = 0xAABBCC;
private static final String ACCOUNT_NAME = "AccountName";

View file

@ -9,12 +9,12 @@ import android.support.v4.app.NotificationCompat.Builder;
import android.support.v4.app.NotificationManagerCompat;
import com.fsck.k9.Account;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.MockHelper;
import com.fsck.k9.R;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import static org.mockito.Matchers.any;
@ -24,7 +24,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(K9RobolectricTestRunner.class)
@RunWith(RobolectricTestRunner.class)
public class CertificateErrorNotificationsTest {
private static final boolean INCOMING = true;
private static final boolean OUTGOING = false;

View file

@ -15,7 +15,6 @@ import com.fsck.k9.Account;
import com.fsck.k9.K9;
import com.fsck.k9.K9.NotificationHideSubject;
import com.fsck.k9.K9.NotificationQuickDelete;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.NotificationSetting;
import com.fsck.k9.R;
import org.junit.Before;
@ -23,6 +22,7 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import static com.fsck.k9.MockHelper.mockBuilder;
@ -34,7 +34,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(K9RobolectricTestRunner.class)
@RunWith(RobolectricTestRunner.class)
public class DeviceNotificationsTest {
private static final int UNREAD_MESSAGE_COUNT = 42;
private static final int NEW_MESSAGE_COUNT = 2;

View file

@ -11,12 +11,12 @@ import android.support.v4.app.NotificationCompat.Builder;
import com.fsck.k9.Account;
import com.fsck.k9.K9;
import com.fsck.k9.K9.LockScreenNotificationVisibility;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.MockHelper;
import com.fsck.k9.R;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import static org.junit.Assert.assertEquals;
@ -27,7 +27,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(K9RobolectricTestRunner.class)
@RunWith(RobolectricTestRunner.class)
public class LockScreenNotificationTest {
private static final String ACCOUNT_NAME = "Hugo";
private static final int NEW_MESSAGE_COUNT = 3;

View file

@ -7,12 +7,12 @@ import android.support.v4.app.NotificationManagerCompat;
import com.fsck.k9.Account;
import com.fsck.k9.K9;
import com.fsck.k9.K9.NotificationHideSubject;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.activity.MessageReference;
import com.fsck.k9.mailstore.LocalMessage;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyBoolean;
@ -25,7 +25,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(K9RobolectricTestRunner.class)
@RunWith(RobolectricTestRunner.class)
public class NewMailNotificationsTest {
private static final int ACCOUNT_NUMBER = 23;

View file

@ -4,7 +4,6 @@ package com.fsck.k9.notification;
import android.content.Context;
import com.fsck.k9.Account;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.activity.MessageReference;
import com.fsck.k9.mail.Address;
import com.fsck.k9.mail.Flag;
@ -14,6 +13,7 @@ import com.fsck.k9.message.extractors.PreviewResult.PreviewType;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import static org.junit.Assert.assertEquals;
@ -22,7 +22,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(K9RobolectricTestRunner.class)
@RunWith(RobolectricTestRunner.class)
public class NotificationContentCreatorTest {
private static final String ACCOUNT_UUID = "1-2-3";
private static final String FOLDER_NAME = "INBOX";

View file

@ -4,13 +4,11 @@ package com.fsck.k9.notification;
import java.util.List;
import com.fsck.k9.Account;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.activity.MessageReference;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import org.robolectric.RobolectricTestRunner;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@ -20,8 +18,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(K9RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
@RunWith(RobolectricTestRunner.class)
public class NotificationDataTest {
private static final String ACCOUNT_UUID = "1-2-3";
private static final int ACCOUNT_NUMBER = 23;

View file

@ -2,18 +2,16 @@ package com.fsck.k9.notification;
import com.fsck.k9.Account;
import com.fsck.k9.K9RobolectricTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import org.robolectric.RobolectricTestRunner;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@RunWith(K9RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
@RunWith(RobolectricTestRunner.class)
public class NotificationIdsTest {
private static final boolean INCOMING = true;
private static final boolean OUTGOING = false;

View file

@ -8,12 +8,12 @@ import android.support.v4.app.NotificationCompat.Builder;
import android.support.v4.app.NotificationManagerCompat;
import com.fsck.k9.Account;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.MockHelper;
import com.fsck.k9.R;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import static org.mockito.Matchers.any;
@ -24,7 +24,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(K9RobolectricTestRunner.class)
@RunWith(RobolectricTestRunner.class)
public class SendFailedNotificationsTest {
private static final int ACCOUNT_NUMBER = 1;
private static final String ACCOUNT_NAME = "TestAccount";

View file

@ -8,13 +8,13 @@ import android.support.v4.app.NotificationCompat.Builder;
import android.support.v4.app.NotificationManagerCompat;
import com.fsck.k9.Account;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.MockHelper;
import com.fsck.k9.R;
import com.fsck.k9.mail.Folder;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import static org.mockito.Matchers.any;
@ -26,7 +26,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(K9RobolectricTestRunner.class)
@RunWith(RobolectricTestRunner.class)
public class SyncNotificationsTest {
private static final int ACCOUNT_NUMBER = 1;
private static final String ACCOUNT_NAME = "TestAccount";

View file

@ -14,7 +14,6 @@ import android.support.v4.app.NotificationCompat.WearableExtender;
import com.fsck.k9.Account;
import com.fsck.k9.K9;
import com.fsck.k9.K9.NotificationQuickDelete;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.MockHelper;
import com.fsck.k9.R;
import com.fsck.k9.activity.MessageReference;
@ -23,6 +22,7 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentMatcher;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import static org.junit.Assert.assertEquals;
@ -34,7 +34,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@RunWith(K9RobolectricTestRunner.class)
@RunWith(RobolectricTestRunner.class)
public class WearNotificationsTest {
private static final int ACCOUNT_NUMBER = 42;
private static final String ACCOUNT_NAME = "accountName";

View file

@ -1,12 +1,5 @@
package com.fsck.k9.preferences;
import com.fsck.k9.K9RobolectricTestRunner;
import org.jdom2.Document;
import org.jdom2.input.SAXBuilder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RuntimeEnvironment;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@ -14,11 +7,19 @@ import java.io.InputStream;
import java.util.Collections;
import java.util.Set;
import org.jdom2.Document;
import org.jdom2.input.SAXBuilder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@RunWith(K9RobolectricTestRunner.class)
@RunWith(RobolectricTestRunner.class)
public class SettingsExporterTest {
@Test

View file

@ -7,13 +7,13 @@ import java.util.List;
import java.util.UUID;
import com.fsck.k9.Account;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.Preferences;
import com.fsck.k9.mail.AuthType;
import org.apache.tools.ant.filters.StringInputStream;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import static org.junit.Assert.assertEquals;
@ -21,7 +21,7 @@ import static org.junit.Assert.assertFalse;
@SuppressWarnings("unchecked")
@RunWith(K9RobolectricTestRunner.class)
@RunWith(RobolectricTestRunner.class)
public class SettingsImporterTest {
@Before

View file

@ -1,18 +1,16 @@
package com.fsck.k9.setup;
import com.fsck.k9.K9RobolectricTestRunner;
import com.fsck.k9.mail.ServerSettings.Type;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
import org.robolectric.RobolectricTestRunner;
import static org.junit.Assert.assertEquals;
@RunWith(K9RobolectricTestRunner.class)
@Config(manifest = Config.NONE)
@RunWith(RobolectricTestRunner.class)
public class ServerNameSuggesterTest {
private ServerNameSuggester serverNameSuggester;

View file

@ -1,13 +1,13 @@
package com.fsck.k9.view
import com.fsck.k9.K9RobolectricTestRunner
import com.fsck.k9.mail.Address
import com.fsck.k9.mail.internet.MimeMessage
import com.google.common.truth.Truth.assertThat
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
@RunWith(K9RobolectricTestRunner::class)
@RunWith(RobolectricTestRunner::class)
class MessageHeaderTest {
@Test