diff --git a/k9mail-library/src/test/java/com/fsck/k9/mail/store/imap/ImapFolderTest.java b/k9mail-library/src/test/java/com/fsck/k9/mail/store/imap/ImapFolderTest.java index 9b78a2b2a..0add60dbb 100644 --- a/k9mail-library/src/test/java/com/fsck/k9/mail/store/imap/ImapFolderTest.java +++ b/k9mail-library/src/test/java/com/fsck/k9/mail/store/imap/ImapFolderTest.java @@ -834,6 +834,23 @@ public class ImapFolderTest { verify(imapConnection).sendCommand("UID FETCH 1 (UID BODYSTRUCTURE)", false); } + @Test + public void fetch_withStructureFetchProfile_shouldSetContentType() throws Exception { + ImapFolder folder = createFolder("Folder"); + prepareImapFolderForOpen(OPEN_MODE_RO); + folder.open(OPEN_MODE_RO); + String bodyStructure = "(\"TEXT\" \"PLAIN\" (\"CHARSET\" \"US-ASCII\") NIL NIL \"7BIT\" 2279 48)"; + when(imapConnection.readResponse(any(ImapResponseCallback.class))) + .thenReturn(createImapResponse("* 1 FETCH (BODYSTRUCTURE "+bodyStructure+" UID 1)")) + .thenReturn(createImapResponse("x OK")); + List messages = createImapMessages("1"); + FetchProfile fetchProfile = createFetchProfile(Item.STRUCTURE); + + folder.fetch(messages, fetchProfile, null); + + verify(messages.get(0)).setHeader(MimeHeader.HEADER_CONTENT_TYPE, "text/plain;\r\n CHARSET=\"US-ASCII\""); + } + @Test public void fetch_withBodySaneFetchProfile_shouldIssueRespectiveCommand() throws Exception { ImapFolder folder = createFolder("Folder");