### Question:
FontRequestEmojiCompatConfig extends EmojiCompat.Config { public FontRequestEmojiCompatConfig setRetryPolicy(RetryPolicy policy) { ((FontRequestMetadataLoader) getMetadataRepoLoader()).setRetryPolicy(policy); return this; } FontRequestEmojiCompatConfig(@NonNull Context context, @NonNull FontRequest request); @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)  FontRequestEmojiCompatConfig(@NonNull Context context, @NonNull FontRequest request,
            @NonNull FontProviderHelper fontProviderHelper); FontRequestEmojiCompatConfig setHandler(Handler handler); FontRequestEmojiCompatConfig setRetryPolicy(RetryPolicy policy);  }### Answer:
@Test @SdkSuppress(minSdkVersion = 19) public void testLoad_retryPolicy() throws IOException, NameNotFoundException { final File file = loadFont(mContext, "NotoColorEmojiCompat.ttf"); final FontInfo[] fonts = new FontInfo[] { new FontInfo(Uri.fromFile(file), 0 , 400 , false , RESULT_CODE_FONT_UNAVAILABLE) }; doReturn(new FontFamilyResult(STATUS_OK, fonts)).when(mFontProviderHelper).fetchFonts( any(Context.class), any(FontRequest.class)); final WaitingLoaderCallback callback = spy(new WaitingLoaderCallback()); final WaitingRetryPolicy retryPolicy = spy(new WaitingRetryPolicy(-1, 1)); final EmojiCompat.Config config = new FontRequestEmojiCompatConfig(mContext, mFontRequest, mFontProviderHelper).setRetryPolicy(retryPolicy); config.getMetadataRepoLoader().load(callback); callback.await(DEFAULT_TIMEOUT_MILLIS); verify(callback, never()).onLoaded(any(MetadataRepo.class)); verify(callback, times(1)).onFailed(any(Throwable.class)); verify(retryPolicy, times(1)).getRetryDelay(); }
@Test @SdkSuppress(minSdkVersion = 19) public void testLoad_keepRetryingAndGiveUp() throws IOException, NameNotFoundException { final File file = loadFont(mContext, "NotoColorEmojiCompat.ttf"); final FontInfo[] fonts = new FontInfo[] { new FontInfo(Uri.fromFile(file), 0 , 400 , false , RESULT_CODE_FONT_UNAVAILABLE) }; doReturn(new FontFamilyResult(STATUS_OK, fonts)).when(mFontProviderHelper).fetchFonts( any(Context.class), any(FontRequest.class)); final WaitingLoaderCallback callback = spy(new WaitingLoaderCallback()); final WaitingRetryPolicy retryPolicy = spy(new WaitingRetryPolicy(500, 1)); final EmojiCompat.Config config = new FontRequestEmojiCompatConfig(mContext, mFontRequest, mFontProviderHelper).setRetryPolicy(retryPolicy); config.getMetadataRepoLoader().load(callback); retryPolicy.await(DEFAULT_TIMEOUT_MILLIS); verify(callback, never()).onLoaded(any(MetadataRepo.class)); verify(callback, never()).onFailed(any(Throwable.class)); verify(retryPolicy, atLeastOnce()).getRetryDelay(); retryPolicy.changeReturnValue(-1); callback.await(DEFAULT_TIMEOUT_MILLIS); verify(callback, never()).onLoaded(any(MetadataRepo.class)); verify(callback, times(1)).onFailed(any(Throwable.class)); }