### Question:
TtmlRenderUtil { public static TtmlStyle resolveStyle(TtmlStyle style, String[] styleIds, Map<String, TtmlStyle> globalStyles) { if (style == null && styleIds == null) { return null; } else if (style == null && styleIds.length == 1) { return globalStyles.get(styleIds[0]); } else if (style == null && styleIds.length > 1) { TtmlStyle chainedStyle = new TtmlStyle(); for (String id : styleIds) { chainedStyle.chain(globalStyles.get(id)); } return chainedStyle; } else if (style != null && styleIds != null && styleIds.length == 1) { return style.chain(globalStyles.get(styleIds[0])); } else if (style != null && styleIds != null && styleIds.length > 1) { for (String id : styleIds) { style.chain(globalStyles.get(id)); } return style; } return style; } private  TtmlRenderUtil(); static TtmlStyle resolveStyle(TtmlStyle style, String[] styleIds,
      Map<String, TtmlStyle> globalStyles); static void applyStylesToSpan(SpannableStringBuilder builder,
      int start, int end, TtmlStyle style);  }### Answer:
@Test public void testResolveStyleSingleReferentialStyle() { Map<String, TtmlStyle> globalStyles = getGlobalStyles(); String[] styleIds = {"s0"}; assertThat(TtmlRenderUtil.resolveStyle(null, styleIds, globalStyles)) .isSameAs(globalStyles.get("s0")); }
@Test public void testResolveStyleMultipleReferentialStyles() { Map<String, TtmlStyle> globalStyles = getGlobalStyles(); String[] styleIds = {"s0", "s1"}; TtmlStyle resolved = TtmlRenderUtil.resolveStyle(null, styleIds, globalStyles); assertThat(resolved).isNotSameAs(globalStyles.get("s0")); assertThat(resolved).isNotSameAs(globalStyles.get("s1")); assertThat(resolved.getId()).isNull(); assertThat(resolved.getBackgroundColor()).isEqualTo(BLACK); assertThat(resolved.getFontColor()).isEqualTo(RED); assertThat(resolved.getStyle()).isEqualTo(STYLE_BOLD_ITALIC); }
@Test public void testResolveMergeSingleReferentialStyleIntoInlineStyle() { Map<String, TtmlStyle> globalStyles = getGlobalStyles(); String[] styleIds = {"s0"}; TtmlStyle style = new TtmlStyle(); style.setBackgroundColor(Color.YELLOW); TtmlStyle resolved = TtmlRenderUtil.resolveStyle(style, styleIds, globalStyles); assertThat(resolved).isSameAs(style); assertThat(resolved.getBackgroundColor()).isEqualTo(YELLOW); assertThat(resolved.getStyle()).isEqualTo(STYLE_BOLD); }
@Test public void testResolveMergeMultipleReferentialStylesIntoInlineStyle() { Map<String, TtmlStyle> globalStyles = getGlobalStyles(); String[] styleIds = {"s0", "s1"}; TtmlStyle style = new TtmlStyle(); style.setBackgroundColor(Color.YELLOW); TtmlStyle resolved = TtmlRenderUtil.resolveStyle(style, styleIds, globalStyles); assertThat(resolved).isSameAs(style); assertThat(resolved.getBackgroundColor()).isEqualTo(YELLOW); assertThat(resolved.getStyle()).isEqualTo(STYLE_BOLD_ITALIC); }
@Test public void testResolveStyleOnlyInlineStyle() { TtmlStyle inlineStyle = new TtmlStyle(); assertThat(TtmlRenderUtil.resolveStyle(inlineStyle, null, null)).isSameAs(inlineStyle); }