Class SpannedSubject


  • public final class SpannedSubject
    extends com.google.common.truth.Subject
    A Truth Subject for assertions on Spanned instances containing text styling.
    • Method Detail

      • assertThat

        public static SpannedSubject assertThat​(@Nullable
                                                Spanned spanned)
        Convenience method to create a SpannedSubject.

        Can be statically imported alongside other Truth assertThat methods.

        Parameters:
        spanned - The subject under test.
        Returns:
        An object for conducting assertions on the subject.
      • hasNoSpans

        public void hasNoSpans()
      • hasItalicSpanBetween

        public SpannedSubject.WithSpanFlags hasItalicSpanBetween​(int start,
                                                                 int end)
        Checks that the subject has an italic span from start to end.
        Parameters:
        start - The start of the expected span.
        end - The end of the expected span.
        Returns:
        A SpannedSubject.WithSpanFlags object for optional additional assertions on the flags.
      • hasBoldSpanBetween

        public SpannedSubject.WithSpanFlags hasBoldSpanBetween​(int start,
                                                               int end)
        Checks that the subject has a bold span from start to end.
        Parameters:
        start - The start of the expected span.
        end - The end of the expected span.
        Returns:
        A SpannedSubject.WithSpanFlags object for optional additional assertions on the flags.
      • hasBoldItalicSpanBetween

        public SpannedSubject.WithSpanFlags hasBoldItalicSpanBetween​(int start,
                                                                     int end)
        Checks that the subject has bold and italic styling from start to end.

        This can either be:

        • A single StyleSpan with span.getStyle() == Typeface.BOLD_ITALIC.
        • Two StyleSpans, one with span.getStyle() == Typeface.BOLD and the other with span.getStyle() == Typeface.ITALIC.
        Parameters:
        start - The start of the expected span.
        end - The end of the expected span.
        Returns:
        A SpannedSubject.WithSpanFlags object for optional additional assertions on the flags.
      • hasNoStyleSpanBetween

        public void hasNoStyleSpanBetween​(int start,
                                          int end)
        Checks that the subject has no StyleSpans on any of the text between start and end.

        This fails even if the start and end indexes don't exactly match.

        Parameters:
        start - The start index to start searching for spans.
        end - The end index to stop searching for spans.
      • hasUnderlineSpanBetween

        public SpannedSubject.WithSpanFlags hasUnderlineSpanBetween​(int start,
                                                                    int end)
        Checks that the subject has an UnderlineSpan from start to end.
        Parameters:
        start - The start of the expected span.
        end - The end of the expected span.
        Returns:
        A SpannedSubject.WithSpanFlags object for optional additional assertions on the flags.
      • hasNoUnderlineSpanBetween

        public void hasNoUnderlineSpanBetween​(int start,
                                              int end)
        Checks that the subject has no UnderlineSpans on any of the text between start and end.

        This fails even if the start and end indexes don't exactly match.

        Parameters:
        start - The start index to start searching for spans.
        end - The end index to stop searching for spans.
      • hasStrikethroughSpanBetween

        public SpannedSubject.WithSpanFlags hasStrikethroughSpanBetween​(int start,
                                                                        int end)
        Checks that the subject has an StrikethroughSpan from start to end.
        Parameters:
        start - The start of the expected span.
        end - The end of the expected span.
        Returns:
        A SpannedSubject.WithSpanFlags object for optional additional assertions on the flags.
      • hasNoStrikethroughSpanBetween

        public void hasNoStrikethroughSpanBetween​(int start,
                                                  int end)
        Checks that the subject has no StrikethroughSpans on any of the text between start and end.

        This fails even if the start and end indexes don't exactly match.

        Parameters:
        start - The start index to start searching for spans.
        end - The end index to stop searching for spans.
      • hasAlignmentSpanBetween

        @CheckResult
        public SpannedSubject.Aligned hasAlignmentSpanBetween​(int start,
                                                              int end)
        Checks that the subject has a AlignmentSpan from start to end.

        The alignment is asserted in a follow-up method call on the return SpannedSubject.Aligned object.

        Parameters:
        start - The start of the expected span.
        end - The end of the expected span.
        Returns:
        A SpannedSubject.Aligned object to assert on the alignment of the matching spans.
      • hasNoAlignmentSpanBetween

        public void hasNoAlignmentSpanBetween​(int start,
                                              int end)
        Checks that the subject has no AlignmentSpans on any of the text between start and end.

        This fails even if the start and end indexes don't exactly match.

        Parameters:
        start - The start index to start searching for spans.
        end - The end index to stop searching for spans.
      • hasForegroundColorSpanBetween

        @CheckResult
        public SpannedSubject.Colored hasForegroundColorSpanBetween​(int start,
                                                                    int end)
        Checks that the subject has a ForegroundColorSpan from start to end.

        The color is asserted in a follow-up method call on the return SpannedSubject.Colored object.

        Parameters:
        start - The start of the expected span.
        end - The end of the expected span.
        Returns:
        A SpannedSubject.Colored object to assert on the color of the matching spans.
      • hasNoForegroundColorSpanBetween

        public void hasNoForegroundColorSpanBetween​(int start,
                                                    int end)
        Checks that the subject has no ForegroundColorSpans on any of the text between start and end.

        This fails even if the start and end indexes don't exactly match.

        Parameters:
        start - The start index to start searching for spans.
        end - The end index to stop searching for spans.
      • hasBackgroundColorSpanBetween

        @CheckResult
        public SpannedSubject.Colored hasBackgroundColorSpanBetween​(int start,
                                                                    int end)
        Checks that the subject has a BackgroundColorSpan from start to end.

        The color is asserted in a follow-up method call on the return SpannedSubject.Colored object.

        Parameters:
        start - The start of the expected span.
        end - The end of the expected span.
        Returns:
        A SpannedSubject.Colored object to assert on the color of the matching spans.
      • hasNoBackgroundColorSpanBetween

        public void hasNoBackgroundColorSpanBetween​(int start,
                                                    int end)
        Checks that the subject has no BackgroundColorSpans on any of the text between start and end.

        This fails even if the start and end indexes don't exactly match.

        Parameters:
        start - The start index to start searching for spans.
        end - The end index to stop searching for spans.
      • hasTypefaceSpanBetween

        @CheckResult
        public SpannedSubject.Typefaced hasTypefaceSpanBetween​(int start,
                                                               int end)
        Checks that the subject has a TypefaceSpan from start to end.

        The font is asserted in a follow-up method call on the return SpannedSubject.Typefaced object.

        Parameters:
        start - The start of the expected span.
        end - The end of the expected span.
        Returns:
        A SpannedSubject.Typefaced object to assert on the font of the matching spans.
      • hasNoTypefaceSpanBetween

        public void hasNoTypefaceSpanBetween​(int start,
                                             int end)
        Checks that the subject has no TypefaceSpans on any of the text between start and end.

        This fails even if the start and end indexes don't exactly match.

        Parameters:
        start - The start index to start searching for spans.
        end - The end index to stop searching for spans.
      • hasNoAbsoluteSizeSpanBetween

        public void hasNoAbsoluteSizeSpanBetween​(int start,
                                                 int end)
        Checks that the subject has no AbsoluteSizeSpans on any of the text between start and end.

        This fails even if the start and end indexes don't exactly match.

        Parameters:
        start - The start index to start searching for spans.
        end - The end index to stop searching for spans.
      • hasNoRelativeSizeSpanBetween

        public void hasNoRelativeSizeSpanBetween​(int start,
                                                 int end)
        Checks that the subject has no RelativeSizeSpans on any of the text between start and end.

        This fails even if the start and end indexes don't exactly match.

        Parameters:
        start - The start index to start searching for spans.
        end - The end index to stop searching for spans.
      • hasRubySpanBetween

        @CheckResult
        public SpannedSubject.RubyText hasRubySpanBetween​(int start,
                                                          int end)
        Checks that the subject has a RubySpan from start to end.

        The ruby-text is asserted in a follow-up method call on the return SpannedSubject.RubyText object.

        Parameters:
        start - The start of the expected span.
        end - The end of the expected span.
        Returns:
        A SpannedSubject.Colored object to assert on the color of the matching spans.
      • hasNoRubySpanBetween

        public void hasNoRubySpanBetween​(int start,
                                         int end)
        Checks that the subject has no RubySpans on any of the text between start and end.

        This fails even if the start and end indexes don't exactly match.

        Parameters:
        start - The start index to start searching for spans.
        end - The end index to stop searching for spans.
      • hasTextEmphasisSpanBetween

        public SpannedSubject.EmphasizedText hasTextEmphasisSpanBetween​(int start,
                                                                        int end)
        Checks that the subject has an TextEmphasisSpan from start to end.
        Parameters:
        start - The start of the expected span.
        end - The end of the expected span.
        Returns:
        A SpannedSubject.EmphasizedText object for optional additional assertions on the flags.
      • hasNoTextEmphasisSpanBetween

        public void hasNoTextEmphasisSpanBetween​(int start,
                                                 int end)
        Checks that the subject has no TextEmphasisSpans on any of the text between start and end.

        This fails even if the start and end indexes don't exactly match.

        Parameters:
        start - The start index to start searching for spans.
        end - The end index to stop searching for spans.
      • hasNoHorizontalTextInVerticalContextSpanBetween

        public void hasNoHorizontalTextInVerticalContextSpanBetween​(int start,
                                                                    int end)
        Checks that the subject has no HorizontalTextInVerticalContextSpans on any of the text between start and end.

        This fails even if the start and end indexes don't exactly match.

        Parameters:
        start - The start index to start searching for spans.
        end - The end index to stop searching for spans.