1212import java .util .List ;
1313import java .util .Map ;
1414
15+ import androidx .annotation .NonNull ;
16+ import kotlinx .coroutines .flow .Flow ;
1517import net .thunderbird .core .android .testing .RobolectricTest ;
1618import net .thunderbird .core .android .account .QuoteStyle ;
1719import com .fsck .k9 .CoreResourceProvider ;
3133import com .fsck .k9 .message .quote .InsertableHtmlContent ;
3234import net .thunderbird .core .logging .legacy .Log ;
3335import net .thunderbird .core .logging .testing .TestLogger ;
36+ import net .thunderbird .core .preference .AppTheme ;
37+ import net .thunderbird .core .preference .BackgroundSync ;
38+ import net .thunderbird .core .preference .GeneralSettings ;
39+ import net .thunderbird .core .preference .GeneralSettingsManager ;
40+ import net .thunderbird .core .preference .SubTheme ;
3441import org .junit .Before ;
3542import org .junit .Test ;
3643import org .mockito .ArgumentCaptor ;
@@ -198,6 +205,154 @@ public class MessageBuilderTest extends RobolectricTest {
198205 private CoreResourceProvider resourceProvider = new TestCoreResourceProvider ();
199206 private Callback callback ;
200207
208+ private final GeneralSettingsManager fakeSettingsManager = new GeneralSettingsManager () {
209+ @ NonNull
210+ @ Override
211+ public GeneralSettings getSettings () {
212+ return new GeneralSettings (
213+ BackgroundSync .NEVER ,
214+ false ,
215+ AppTheme .FOLLOW_SYSTEM ,
216+ SubTheme .USE_GLOBAL ,
217+ SubTheme .USE_GLOBAL ,
218+ false ,
219+ false ,
220+ false ,
221+ false ,
222+ false ,
223+ false ,
224+ false ,
225+ false ,
226+ false ,
227+ false ,
228+ false ,
229+ false ,
230+ false ,
231+ false ,
232+ false ,
233+ false ,
234+ false ,
235+ false
236+ );
237+ }
238+
239+ @ NonNull
240+ @ Override
241+ public Flow <GeneralSettings > getSettingsFlow () {
242+ throw new UnsupportedOperationException ("not implemented" );
243+ }
244+
245+ @ Override
246+ public void setShowRecentChanges (boolean showRecentChanges ) {
247+ throw new UnsupportedOperationException ("not implemented" );
248+ }
249+
250+ @ Override
251+ public void setAppTheme (@ NonNull AppTheme appTheme ) {
252+ throw new UnsupportedOperationException ("not implemented" );
253+ }
254+
255+ @ Override
256+ public void setMessageViewTheme (@ NonNull SubTheme subTheme ) {
257+ throw new UnsupportedOperationException ("not implemented" );
258+ }
259+
260+ @ Override
261+ public void setMessageComposeTheme (@ NonNull SubTheme subTheme ) {
262+ throw new UnsupportedOperationException ("not implemented" );
263+ }
264+
265+ @ Override
266+ public void setFixedMessageViewTheme (boolean fixedMessageViewTheme ) {
267+ throw new UnsupportedOperationException ("not implemented" );
268+ }
269+
270+ @ Override
271+ public void setIsShowUnifiedInbox (boolean isShowUnifiedInbox ) {
272+ throw new UnsupportedOperationException ("not implemented" );
273+ }
274+
275+ @ Override
276+ public void setIsShowStarredCount (boolean isShowStarredCount ) {
277+ throw new UnsupportedOperationException ("not implemented" );
278+ }
279+
280+ @ Override
281+ public void setIsShowMessageListStars (boolean isShowMessageListStars ) {
282+ throw new UnsupportedOperationException ("not implemented" );
283+ }
284+
285+ @ Override
286+ public void setIsShowAnimations (boolean isShowAnimations ) {
287+ throw new UnsupportedOperationException ("not implemented" );
288+ }
289+
290+ @ Override
291+ public void setIsShowCorrespondentNames (boolean isShowCorrespondentNames ) {
292+ throw new UnsupportedOperationException ("not implemented" );
293+ }
294+
295+ @ Override
296+ public void setSetupArchiveShouldNotShowAgain (boolean shouldShowSetupArchiveFolderDialog ) {
297+ throw new UnsupportedOperationException ("not implemented" );
298+ }
299+
300+ @ Override
301+ public void setIsMessageListSenderAboveSubject (boolean isMessageListSenderAboveSubject ) {
302+ throw new UnsupportedOperationException ("not implemented" );
303+ }
304+
305+ @ Override
306+ public void setIsShowContactName (boolean isShowContactName ) {
307+ throw new UnsupportedOperationException ("not implemented" );
308+ }
309+
310+ @ Override
311+ public void setIsShowContactPicture (boolean isShowContactPicture ) {
312+ throw new UnsupportedOperationException ("not implemented" );
313+ }
314+
315+ @ Override
316+ public void setIsChangeContactNameColor (boolean isChangeContactNameColor ) {
317+ throw new UnsupportedOperationException ("not implemented" );
318+ }
319+
320+ @ Override
321+ public void setIsColorizeMissingContactPictures (boolean isColorizeMissingContactPictures ) {
322+ throw new UnsupportedOperationException ("not implemented" );
323+ }
324+
325+ @ Override
326+ public void setIsUseBackgroundAsUnreadIndicator (boolean isUseBackgroundAsUnreadIndicator ) {
327+ throw new UnsupportedOperationException ("not implemented" );
328+ }
329+
330+ @ Override
331+ public void setIsShowComposeButtonOnMessageList (boolean isShowComposeButtonOnMessageList ) {
332+ throw new UnsupportedOperationException ("not implemented" );
333+ }
334+
335+ @ Override
336+ public void setIsThreadedViewEnabled (boolean isThreadedViewEnabled ) {
337+ throw new UnsupportedOperationException ("not implemented" );
338+ }
339+
340+ @ Override
341+ public void setIsUseMessageViewFixedWidthFont (boolean isUseMessageViewFixedWidthFont ) {
342+ throw new UnsupportedOperationException ("not implemented" );
343+ }
344+
345+ @ Override
346+ public void setIsAutoFitWidth (boolean isAutoFitWidth ) {
347+ throw new UnsupportedOperationException ("not implemented" );
348+ }
349+
350+ @ Override
351+ public void setIsHideUserAgent (boolean isHideUserAgent ) {
352+ throw new UnsupportedOperationException ("not implemented" );
353+ }
354+ };
355+
201356
202357 @ Before
203358 public void setUp () throws Exception {
@@ -345,12 +500,13 @@ public void build_detachAndReattach_shouldSucceed() throws MessagingException {
345500
346501 @ Test
347502 public void buildWithException_shouldThrow () throws MessagingException {
348- MessageBuilder messageBuilder = new SimpleMessageBuilder (messageIdGenerator , boundaryGenerator , resourceProvider ) {
349- @ Override
350- protected void buildMessageInternal () {
351- queueMessageBuildException (new MessagingException ("expected error" ));
352- }
353- };
503+ MessageBuilder messageBuilder =
504+ new SimpleMessageBuilder (messageIdGenerator , boundaryGenerator , resourceProvider , fakeSettingsManager ) {
505+ @ Override
506+ protected void buildMessageInternal () {
507+ queueMessageBuildException (new MessagingException ("expected error" ));
508+ }
509+ };
354510
355511 messageBuilder .buildAsync (callback );
356512
@@ -361,7 +517,7 @@ protected void buildMessageInternal() {
361517 @ Test
362518 public void buildWithException_detachAndReattach_shouldThrow () throws MessagingException {
363519 Callback anotherCallback = mock (Callback .class );
364- MessageBuilder messageBuilder = new SimpleMessageBuilder (messageIdGenerator , boundaryGenerator , resourceProvider ) {
520+ MessageBuilder messageBuilder = new SimpleMessageBuilder (messageIdGenerator , boundaryGenerator , resourceProvider , fakeSettingsManager ) {
365521 @ Override
366522 protected void buildMessageInternal () {
367523 queueMessageBuildException (new MessagingException ("expected error" ));
@@ -393,7 +549,8 @@ private String getMessageContents(MimeMessage message) throws IOException, Messa
393549 return outputStream .toString ();
394550 }
395551
396- private Attachment createAttachmentWithContent (final String mimeType , final String filename , String content ) throws Exception {
552+ private Attachment createAttachmentWithContent (final String mimeType , final String filename , String content )
553+ throws Exception {
397554 final byte [] bytes = content .getBytes ();
398555 final File tempFile = File .createTempFile ("pre" , ".tmp" );
399556 tempFile .deleteOnExit ();
@@ -436,33 +593,33 @@ public boolean isInternalAttachment() {
436593
437594 private MessageBuilder createSimpleMessageBuilder () {
438595 Identity identity = createIdentity ();
439- return new SimpleMessageBuilder (messageIdGenerator , boundaryGenerator , resourceProvider )
440- .setSubject (TEST_SUBJECT )
441- .setSentDate (SENT_DATE )
442- .setHideTimeZone (true )
443- .setReplyTo (TEST_REPLY_TO )
444- .setTo (Arrays .asList (TEST_TO ))
445- .setCc (Arrays .asList (TEST_CC ))
446- .setBcc (Arrays .asList (TEST_BCC ))
447- .setInReplyTo ("inreplyto" )
448- .setReferences ("references" )
449- .setRequestReadReceipt (false )
450- .setIdentity (identity )
451- .setMessageFormat (SimpleMessageFormat .TEXT )
452- .setText (TEST_MESSAGE_TEXT )
453- .setAttachments (new ArrayList <>())
454- .setSignature ("signature" )
455- .setQuoteStyle (QuoteStyle .PREFIX )
456- .setQuotedTextMode (QuotedTextMode .NONE )
457- .setQuotedText ("quoted text" )
458- .setQuotedHtmlContent (new InsertableHtmlContent ())
459- .setReplyAfterQuote (false )
460- .setSignatureBeforeQuotedText (false )
461- .setIdentityChanged (false )
462- .setSignatureChanged (false )
463- .setCursorPosition (0 )
464- .setMessageReference (null )
465- .setDraft (false );
596+ return new SimpleMessageBuilder (messageIdGenerator , boundaryGenerator , resourceProvider , fakeSettingsManager )
597+ .setSubject (TEST_SUBJECT )
598+ .setSentDate (SENT_DATE )
599+ .setHideTimeZone (true )
600+ .setReplyTo (TEST_REPLY_TO )
601+ .setTo (Arrays .asList (TEST_TO ))
602+ .setCc (Arrays .asList (TEST_CC ))
603+ .setBcc (Arrays .asList (TEST_BCC ))
604+ .setInReplyTo ("inreplyto" )
605+ .setReferences ("references" )
606+ .setRequestReadReceipt (false )
607+ .setIdentity (identity )
608+ .setMessageFormat (SimpleMessageFormat .TEXT )
609+ .setText (TEST_MESSAGE_TEXT )
610+ .setAttachments (new ArrayList <>())
611+ .setSignature ("signature" )
612+ .setQuoteStyle (QuoteStyle .PREFIX )
613+ .setQuotedTextMode (QuotedTextMode .NONE )
614+ .setQuotedText ("quoted text" )
615+ .setQuotedHtmlContent (new InsertableHtmlContent ())
616+ .setReplyAfterQuote (false )
617+ .setSignatureBeforeQuotedText (false )
618+ .setIdentityChanged (false )
619+ .setSignatureChanged (false )
620+ .setCursorPosition (0 )
621+ .setMessageReference (null )
622+ .setDraft (false );
466623 }
467624
468625 private MessageBuilder createHtmlMessageBuilder () {
@@ -471,12 +628,12 @@ private MessageBuilder createHtmlMessageBuilder() {
471628
472629 private Identity createIdentity () {
473630 return new Identity (
474- "test identity" ,
475- TEST_IDENTITY_ADDRESS .getPersonal (),
476- TEST_IDENTITY_ADDRESS .getAddress (),
477- null ,
478- false ,
479- null
631+ "test identity" ,
632+ TEST_IDENTITY_ADDRESS .getPersonal (),
633+ TEST_IDENTITY_ADDRESS .getAddress (),
634+ null ,
635+ false ,
636+ null
480637 );
481638 }
482639}
0 commit comments