use of com.fsck.k9.TestCoreResourceProvider in project k-9 by k9mail.
the class MessageViewInfoExtractorTest method setUp.
@Before
public void setUp() throws Exception {
context = RuntimeEnvironment.application;
HtmlProcessor htmlProcessor = createFakeHtmlProcessor();
attachmentInfoExtractor = spy(DI.get(AttachmentInfoExtractor.class));
messageViewInfoExtractor = new MessageViewInfoExtractor(attachmentInfoExtractor, htmlProcessor, new TestCoreResourceProvider());
}
use of com.fsck.k9.TestCoreResourceProvider in project k-9 by k9mail.
the class MessageViewInfoExtractorTest method testShouldSanitizeOutputHtml.
@Test
public void testShouldSanitizeOutputHtml() throws MessagingException {
// Create text/plain body
TextBody body = new TextBody(BODY_TEXT);
// Create message
MimeMessage message = new MimeMessage();
MimeMessageHelper.setBody(message, body);
message.setHeader(MimeHeader.HEADER_CONTENT_TYPE, "text/plain; format=flowed");
// Prepare fixture
HtmlProcessor htmlProcessor = mock(HtmlProcessor.class);
MessageViewInfoExtractor messageViewInfoExtractor = new MessageViewInfoExtractor(null, htmlProcessor, new TestCoreResourceProvider());
String value = "--sanitized html--";
when(htmlProcessor.processForDisplay(anyString())).thenReturn(value);
// Extract text
List<Part> outputNonViewableParts = new ArrayList<>();
ArrayList<Viewable> outputViewableParts = new ArrayList<>();
MessageExtractor.findViewablesAndAttachments(message, outputViewableParts, outputNonViewableParts);
ViewableExtractedText viewableExtractedText = messageViewInfoExtractor.extractTextFromViewables(outputViewableParts);
assertSame(value, viewableExtractedText.html);
}
Aggregations