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 ;
41+ import net .thunderbird .core .preference .privacy .PrivacySettings ;
3442import org .junit .Before ;
3543import org .junit .Test ;
3644import org .mockito .ArgumentCaptor ;
@@ -198,6 +206,184 @@ public class MessageBuilderTest extends RobolectricTest {
198206 private CoreResourceProvider resourceProvider = new TestCoreResourceProvider ();
199207 private Callback callback ;
200208
209+ private final GeneralSettingsManager fakeSettingsManager = new GeneralSettingsManager () {
210+ @ Override
211+ public void setIsHideTimeZone (boolean isHideTimeZone ) {
212+
213+ }
214+
215+ @ NonNull
216+ @ Override
217+ public PrivacySettings getPrivacySettings () {
218+ throw new UnsupportedOperationException ("not implemented" );
219+ }
220+
221+ @ Override
222+ public void setIsQuietTimeEnabled (boolean isQuietTimeEnabled ) {
223+ throw new UnsupportedOperationException ("not implemented" );
224+ }
225+
226+ @ Override
227+ public void setQuietTimeStarts (@ NonNull String quietTimeStarts ) {
228+ throw new UnsupportedOperationException ("not implemented" );
229+ }
230+
231+ @ Override
232+ public void setQuietTimeEnds (@ NonNull String quietTimeEnds ) {
233+ throw new UnsupportedOperationException ("not implemented" );
234+ }
235+
236+ @ NonNull
237+ @ Override
238+ public GeneralSettings getSettings () {
239+ return new GeneralSettings (
240+ BackgroundSync .NEVER ,
241+ false ,
242+ AppTheme .FOLLOW_SYSTEM ,
243+ SubTheme .USE_GLOBAL ,
244+ SubTheme .USE_GLOBAL ,
245+ false ,
246+ false ,
247+ false ,
248+ false ,
249+ false ,
250+ false ,
251+ false ,
252+ false ,
253+ false ,
254+ false ,
255+ false ,
256+ false ,
257+ false ,
258+ false ,
259+ false ,
260+ false ,
261+ false ,
262+ "07:00" ,
263+ "07:00" ,
264+ false ,
265+ false ,
266+ new PrivacySettings (false , false )
267+ );
268+ }
269+
270+ @ NonNull
271+ @ Override
272+ public Flow <GeneralSettings > getSettingsFlow () {
273+ throw new UnsupportedOperationException ("not implemented" );
274+ }
275+
276+ @ Override
277+ public void setShowRecentChanges (boolean showRecentChanges ) {
278+ throw new UnsupportedOperationException ("not implemented" );
279+ }
280+
281+ @ Override
282+ public void setAppTheme (@ NonNull AppTheme appTheme ) {
283+ throw new UnsupportedOperationException ("not implemented" );
284+ }
285+
286+ @ Override
287+ public void setMessageViewTheme (@ NonNull SubTheme subTheme ) {
288+ throw new UnsupportedOperationException ("not implemented" );
289+ }
290+
291+ @ Override
292+ public void setMessageComposeTheme (@ NonNull SubTheme subTheme ) {
293+ throw new UnsupportedOperationException ("not implemented" );
294+ }
295+
296+ @ Override
297+ public void setFixedMessageViewTheme (boolean fixedMessageViewTheme ) {
298+ throw new UnsupportedOperationException ("not implemented" );
299+ }
300+
301+ @ Override
302+ public void setIsShowUnifiedInbox (boolean isShowUnifiedInbox ) {
303+ throw new UnsupportedOperationException ("not implemented" );
304+ }
305+
306+ @ Override
307+ public void setIsShowStarredCount (boolean isShowStarredCount ) {
308+ throw new UnsupportedOperationException ("not implemented" );
309+ }
310+
311+ @ Override
312+ public void setIsShowMessageListStars (boolean isShowMessageListStars ) {
313+ throw new UnsupportedOperationException ("not implemented" );
314+ }
315+
316+ @ Override
317+ public void setIsShowAnimations (boolean isShowAnimations ) {
318+ throw new UnsupportedOperationException ("not implemented" );
319+ }
320+
321+ @ Override
322+ public void setIsShowCorrespondentNames (boolean isShowCorrespondentNames ) {
323+ throw new UnsupportedOperationException ("not implemented" );
324+ }
325+
326+ @ Override
327+ public void setSetupArchiveShouldNotShowAgain (boolean shouldShowSetupArchiveFolderDialog ) {
328+ throw new UnsupportedOperationException ("not implemented" );
329+ }
330+
331+ @ Override
332+ public void setIsMessageListSenderAboveSubject (boolean isMessageListSenderAboveSubject ) {
333+ throw new UnsupportedOperationException ("not implemented" );
334+ }
335+
336+ @ Override
337+ public void setIsShowContactName (boolean isShowContactName ) {
338+ throw new UnsupportedOperationException ("not implemented" );
339+ }
340+
341+ @ Override
342+ public void setIsShowContactPicture (boolean isShowContactPicture ) {
343+ throw new UnsupportedOperationException ("not implemented" );
344+ }
345+
346+ @ Override
347+ public void setIsChangeContactNameColor (boolean isChangeContactNameColor ) {
348+ throw new UnsupportedOperationException ("not implemented" );
349+ }
350+
351+ @ Override
352+ public void setIsColorizeMissingContactPictures (boolean isColorizeMissingContactPictures ) {
353+ throw new UnsupportedOperationException ("not implemented" );
354+ }
355+
356+ @ Override
357+ public void setIsUseBackgroundAsUnreadIndicator (boolean isUseBackgroundAsUnreadIndicator ) {
358+ throw new UnsupportedOperationException ("not implemented" );
359+ }
360+
361+ @ Override
362+ public void setIsShowComposeButtonOnMessageList (boolean isShowComposeButtonOnMessageList ) {
363+ throw new UnsupportedOperationException ("not implemented" );
364+ }
365+
366+ @ Override
367+ public void setIsThreadedViewEnabled (boolean isThreadedViewEnabled ) {
368+ throw new UnsupportedOperationException ("not implemented" );
369+ }
370+
371+ @ Override
372+ public void setIsUseMessageViewFixedWidthFont (boolean isUseMessageViewFixedWidthFont ) {
373+ throw new UnsupportedOperationException ("not implemented" );
374+ }
375+
376+ @ Override
377+ public void setIsAutoFitWidth (boolean isAutoFitWidth ) {
378+ throw new UnsupportedOperationException ("not implemented" );
379+ }
380+
381+ @ Override
382+ public void setIsHideUserAgent (boolean isHideUserAgent ) {
383+ throw new UnsupportedOperationException ("not implemented" );
384+ }
385+ };
386+
201387
202388 @ Before
203389 public void setUp () throws Exception {
@@ -345,12 +531,13 @@ public void build_detachAndReattach_shouldSucceed() throws MessagingException {
345531
346532 @ Test
347533 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- };
534+ MessageBuilder messageBuilder =
535+ new SimpleMessageBuilder (messageIdGenerator , boundaryGenerator , resourceProvider , fakeSettingsManager ) {
536+ @ Override
537+ protected void buildMessageInternal () {
538+ queueMessageBuildException (new MessagingException ("expected error" ));
539+ }
540+ };
354541
355542 messageBuilder .buildAsync (callback );
356543
@@ -361,7 +548,7 @@ protected void buildMessageInternal() {
361548 @ Test
362549 public void buildWithException_detachAndReattach_shouldThrow () throws MessagingException {
363550 Callback anotherCallback = mock (Callback .class );
364- MessageBuilder messageBuilder = new SimpleMessageBuilder (messageIdGenerator , boundaryGenerator , resourceProvider ) {
551+ MessageBuilder messageBuilder = new SimpleMessageBuilder (messageIdGenerator , boundaryGenerator , resourceProvider , fakeSettingsManager ) {
365552 @ Override
366553 protected void buildMessageInternal () {
367554 queueMessageBuildException (new MessagingException ("expected error" ));
@@ -393,7 +580,8 @@ private String getMessageContents(MimeMessage message) throws IOException, Messa
393580 return outputStream .toString ();
394581 }
395582
396- private Attachment createAttachmentWithContent (final String mimeType , final String filename , String content ) throws Exception {
583+ private Attachment createAttachmentWithContent (final String mimeType , final String filename , String content )
584+ throws Exception {
397585 final byte [] bytes = content .getBytes ();
398586 final File tempFile = File .createTempFile ("pre" , ".tmp" );
399587 tempFile .deleteOnExit ();
@@ -436,33 +624,33 @@ public boolean isInternalAttachment() {
436624
437625 private MessageBuilder createSimpleMessageBuilder () {
438626 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 );
627+ return new SimpleMessageBuilder (messageIdGenerator , boundaryGenerator , resourceProvider , fakeSettingsManager )
628+ .setSubject (TEST_SUBJECT )
629+ .setSentDate (SENT_DATE )
630+ .setHideTimeZone (true )
631+ .setReplyTo (TEST_REPLY_TO )
632+ .setTo (Arrays .asList (TEST_TO ))
633+ .setCc (Arrays .asList (TEST_CC ))
634+ .setBcc (Arrays .asList (TEST_BCC ))
635+ .setInReplyTo ("inreplyto" )
636+ .setReferences ("references" )
637+ .setRequestReadReceipt (false )
638+ .setIdentity (identity )
639+ .setMessageFormat (SimpleMessageFormat .TEXT )
640+ .setText (TEST_MESSAGE_TEXT )
641+ .setAttachments (new ArrayList <>())
642+ .setSignature ("signature" )
643+ .setQuoteStyle (QuoteStyle .PREFIX )
644+ .setQuotedTextMode (QuotedTextMode .NONE )
645+ .setQuotedText ("quoted text" )
646+ .setQuotedHtmlContent (new InsertableHtmlContent ())
647+ .setReplyAfterQuote (false )
648+ .setSignatureBeforeQuotedText (false )
649+ .setIdentityChanged (false )
650+ .setSignatureChanged (false )
651+ .setCursorPosition (0 )
652+ .setMessageReference (null )
653+ .setDraft (false );
466654 }
467655
468656 private MessageBuilder createHtmlMessageBuilder () {
@@ -471,12 +659,12 @@ private MessageBuilder createHtmlMessageBuilder() {
471659
472660 private Identity createIdentity () {
473661 return new Identity (
474- "test identity" ,
475- TEST_IDENTITY_ADDRESS .getPersonal (),
476- TEST_IDENTITY_ADDRESS .getAddress (),
477- null ,
478- false ,
479- null
662+ "test identity" ,
663+ TEST_IDENTITY_ADDRESS .getPersonal (),
664+ TEST_IDENTITY_ADDRESS .getAddress (),
665+ null ,
666+ false ,
667+ null
480668 );
481669 }
482670}
0 commit comments