diff --git a/k9mail/src/main/java/com/fsck/k9/Globals.java b/k9mail/src/main/java/com/fsck/k9/Globals.java index 1eab061fd..7d7ec227d 100644 --- a/k9mail/src/main/java/com/fsck/k9/Globals.java +++ b/k9mail/src/main/java/com/fsck/k9/Globals.java @@ -8,8 +8,7 @@ import android.support.annotation.VisibleForTesting; public class Globals { private static Context context; - @VisibleForTesting - public static void setContext(Context context) { + static void setContext(Context context) { Globals.context = context; } diff --git a/k9mail/src/test/java/com/fsck/k9/GlobalsHelper.java b/k9mail/src/test/java/com/fsck/k9/GlobalsHelper.java new file mode 100644 index 000000000..47758a953 --- /dev/null +++ b/k9mail/src/test/java/com/fsck/k9/GlobalsHelper.java @@ -0,0 +1,11 @@ +package com.fsck.k9; + + +import android.content.Context; + + +public class GlobalsHelper { + public static void setContext(Context context) { + Globals.setContext(context); + } +} diff --git a/k9mail/src/test/java/com/fsck/k9/mailstore/MessageViewInfoExtractorTest.java b/k9mail/src/test/java/com/fsck/k9/mailstore/MessageViewInfoExtractorTest.java index 73bc1d111..2a8d03fe4 100644 --- a/k9mail/src/test/java/com/fsck/k9/mailstore/MessageViewInfoExtractorTest.java +++ b/k9mail/src/test/java/com/fsck/k9/mailstore/MessageViewInfoExtractorTest.java @@ -7,7 +7,9 @@ import java.util.List; import java.util.Locale; import java.util.TimeZone; -import com.fsck.k9.Globals; +import android.app.Application; + +import com.fsck.k9.GlobalsHelper; import com.fsck.k9.activity.K9ActivityCommon; import com.fsck.k9.helper.HtmlSanitizer; import com.fsck.k9.helper.HtmlSanitizerHelper; @@ -45,15 +47,18 @@ public class MessageViewInfoExtractorTest { private MessageViewInfoExtractor messageViewInfoExtractor; + private Application context; @Before public void setUp() throws Exception { - Globals.setContext(RuntimeEnvironment.application); + context = RuntimeEnvironment.application; + + GlobalsHelper.setContext(context); HtmlSanitizer dummyHtmlSanitizer = HtmlSanitizerHelper.getDummyHtmlSanitizer(); - messageViewInfoExtractor = new MessageViewInfoExtractor(RuntimeEnvironment.application, + messageViewInfoExtractor = new MessageViewInfoExtractor(context, null, dummyHtmlSanitizer); } @@ -69,7 +74,7 @@ public class MessageViewInfoExtractorTest { // Prepare fixture HtmlSanitizer htmlSanitizer = mock(HtmlSanitizer.class); MessageViewInfoExtractor messageViewInfoExtractor = - new MessageViewInfoExtractor(RuntimeEnvironment.application, null, htmlSanitizer); + new MessageViewInfoExtractor(context, null, htmlSanitizer); String value = "--sanitized html--"; when(htmlSanitizer.sanitize(any(String.class))).thenReturn(value); @@ -181,7 +186,7 @@ public class MessageViewInfoExtractorTest { @Test public void testTextPlusRfc822Message() throws MessagingException { - K9ActivityCommon.setLanguage(RuntimeEnvironment.application, "en"); + K9ActivityCommon.setLanguage(context, "en"); Locale.setDefault(Locale.US); TimeZone.setDefault(TimeZone.getTimeZone("GMT+01:00"));