@UnstableApi
public final class SpannedSubject extends Subject


A Truth Subject for assertions on Spanned instances containing text styling.

Summary

Nested types

Allows assertions about the absolute size of a span.

public interface SpannedSubject.Aligned

Allows assertions about the alignment of a span.

Allows additional assertions to be made on the flags of matching spans.

public interface SpannedSubject.Colored

Allows assertions about the color of a span.

Allows assertions about a span's text emphasis mark and its position.

Allows assertions about the relative size of a span.

public interface SpannedSubject.RubyText

Allows assertions about a span's ruby text and its position.

public interface SpannedSubject.Typefaced

Allows assertions about the typeface of a span.

public interface SpannedSubject.VoiceText

Allows assertions about a span's voice its position.

Allows additional assertions to be made on the flags of matching spans.

Public methods

static SpannedSubject

Convenience method to create a SpannedSubject.

SpannedSubject.AbsoluteSized
hasAbsoluteSizeSpanBetween(int start, int end)

Checks that the subject has a AbsoluteSizeSpan from start to end.

SpannedSubject.Aligned
hasAlignmentSpanBetween(int start, int end)

Checks that the subject has a AlignmentSpan from start to end.

SpannedSubject.Colored
hasBackgroundColorSpanBetween(int start, int end)

Checks that the subject has a BackgroundColorSpan from start to end.

SpannedSubject.WithSpanFlags
hasBoldItalicSpanBetween(int start, int end)

Checks that the subject has bold and italic styling from start to end.

SpannedSubject.WithSpanFlags
hasBoldSpanBetween(int start, int end)

Checks that the subject has a bold span from start to end.

SpannedSubject.Colored
hasForegroundColorSpanBetween(int start, int end)

Checks that the subject has a ForegroundColorSpan from start to end.

SpannedSubject.WithSpanFlags

Checks that the subject has an HorizontalTextInVerticalContextSpan from start to end.

SpannedSubject.WithSpanFlags
hasItalicSpanBetween(int start, int end)

Checks that the subject has an italic span from start to end.

void
hasNoAbsoluteSizeSpanBetween(int start, int end)

Checks that the subject has no AbsoluteSizeSpans on any of the text between start and end.

void
hasNoAlignmentSpanBetween(int start, int end)

Checks that the subject has no AlignmentSpans on any of the text between start and end.

void
hasNoBackgroundColorSpanBetween(int start, int end)

Checks that the subject has no BackgroundColorSpans on any of the text between start and end.

void
hasNoForegroundColorSpanBetween(int start, int end)

Checks that the subject has no ForegroundColorSpans on any of the text between start and end.

void

Checks that the subject has no HorizontalTextInVerticalContextSpans on any of the text between start and end.

void
hasNoRelativeSizeSpanBetween(int start, int end)

Checks that the subject has no RelativeSizeSpans on any of the text between start and end.

void
hasNoRubySpanBetween(int start, int end)

Checks that the subject has no RubySpans on any of the text between start and end.

void
void
hasNoStrikethroughSpanBetween(int start, int end)

Checks that the subject has no StrikethroughSpans on any of the text between start and end.

void
hasNoStyleSpanBetween(int start, int end)

Checks that the subject has no StyleSpans on any of the text between start and end.

void
hasNoTextEmphasisSpanBetween(int start, int end)

Checks that the subject has no TextEmphasisSpans on any of the text between start and end.

void
hasNoTypefaceSpanBetween(int start, int end)

Checks that the subject has no TypefaceSpans on any of the text between start and end.

void
hasNoUnderlineSpanBetween(int start, int end)

Checks that the subject has no UnderlineSpans on any of the text between start and end.

void
hasNoVoiceSpanBetween(int start, int end)

Checks that the subject has no VoiceSpans on any of the text between start and end.

SpannedSubject.RelativeSized
hasRelativeSizeSpanBetween(int start, int end)

Checks that the subject has a RelativeSizeSpan from start to end.

SpannedSubject.RubyText
hasRubySpanBetween(int start, int end)

Checks that the subject has a RubySpan from start to end.

SpannedSubject.WithSpanFlags
hasStrikethroughSpanBetween(int start, int end)

Checks that the subject has an StrikethroughSpan from start to end.

SpannedSubject.EmphasizedText
hasTextEmphasisSpanBetween(int start, int end)

Checks that the subject has an TextEmphasisSpan from start to end.

SpannedSubject.Typefaced
hasTypefaceSpanBetween(int start, int end)

Checks that the subject has a TypefaceSpan from start to end.

SpannedSubject.WithSpanFlags
hasUnderlineSpanBetween(int start, int end)

Checks that the subject has an UnderlineSpan from start to end.

SpannedSubject.VoiceText
hasVoiceSpanBetween(int start, int end)

Checks that the subject has an VoiceSpan from start to end.

static Subject.Factory<SpannedSubjectSpanned>

Inherited methods

From com.google.common.truth.Subject
String
final boolean

This method is deprecated.

final void
final void
failWithoutActual(Fact first, Fact[] rest)
final int

This method is deprecated.

final StandardSubjectBuilder
void
isAnyOf(Object first, Object second, @Nullable Object[] rest)
void
isEqualTo(Object expected)
void
void
void
isNoneOf(Object first, Object second, @Nullable Object[] rest)
void
isNotEqualTo(Object unexpected)
void
void
void
final void
void
final void
String

This method is deprecated.

Public methods

assertThat

public static SpannedSubject assertThat(@Nullable Spanned spanned)

Convenience method to create a SpannedSubject.

Can be statically imported alongside other Truth assertThat methods.

Parameters
@Nullable Spanned spanned

The subject under test.

Returns
SpannedSubject

An object for conducting assertions on the subject.

hasAbsoluteSizeSpanBetween

public SpannedSubject.AbsoluteSized hasAbsoluteSizeSpanBetween(int start, int end)

Checks that the subject has a AbsoluteSizeSpan from start to end.

The size is asserted in a follow-up method call on the return AbsoluteSized object.

Parameters
int start

The start of the expected span.

int end

The end of the expected span.

Returns
SpannedSubject.AbsoluteSized

A AbsoluteSized object to assert on the size of the matching spans.

hasAlignmentSpanBetween

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 Aligned object.

Parameters
int start

The start of the expected span.

int end

The end of the expected span.

Returns
SpannedSubject.Aligned

A Aligned object to assert on the alignment of the matching spans.

hasBackgroundColorSpanBetween

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 Colored object.

Parameters
int start

The start of the expected span.

int end

The end of the expected span.

Returns
SpannedSubject.Colored

A Colored object to assert on the color of the matching spans.

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
int start

The start of the expected span.

int end

The end of the expected span.

Returns
SpannedSubject.WithSpanFlags

A 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
int start

The start of the expected span.

int end

The end of the expected span.

Returns
SpannedSubject.WithSpanFlags

A WithSpanFlags object for optional additional assertions on the flags.

hasForegroundColorSpanBetween

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 Colored object.

Parameters
int start

The start of the expected span.

int end

The end of the expected span.

Returns
SpannedSubject.Colored

A Colored object to assert on the color of the matching spans.

hasHorizontalTextInVerticalContextSpanBetween

public SpannedSubject.WithSpanFlags hasHorizontalTextInVerticalContextSpanBetween(int start, int end)

Checks that the subject has an HorizontalTextInVerticalContextSpan from start to end.

Parameters
int start

The start of the expected span.

int end

The end of the expected span.

Returns
SpannedSubject.WithSpanFlags

A WithSpanFlags object for optional additional assertions on the flags.

hasItalicSpanBetween

public SpannedSubject.WithSpanFlags hasItalicSpanBetween(int start, int end)

Checks that the subject has an italic span from start to end.

Parameters
int start

The start of the expected span.

int end

The end of the expected span.

Returns
SpannedSubject.WithSpanFlags

A WithSpanFlags object for optional additional assertions on the flags.

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
int start

The start index to start searching for spans.

int end

The end index to stop searching for 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
int start

The start index to start searching for spans.

int end

The end index to stop searching for 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
int start

The start index to start searching for spans.

int end

The end index to stop searching for 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
int start

The start index to start searching for spans.

int 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
int start

The start index to start searching for spans.

int 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
int start

The start index to start searching for spans.

int end

The end index to stop searching for 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
int start

The start index to start searching for spans.

int end

The end index to stop searching for spans.

hasNoSpans

public void hasNoSpans()

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
int start

The start index to start searching for spans.

int end

The end index to stop searching for spans.

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
int start

The start index to start searching for spans.

int end

The end index to stop searching for spans.

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
int start

The start index to start searching for spans.

int end

The end index to stop searching for 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
int start

The start index to start searching for spans.

int end

The end index to stop searching for spans.

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
int start

The start index to start searching for spans.

int end

The end index to stop searching for spans.

hasNoVoiceSpanBetween

public void hasNoVoiceSpanBetween(int start, int end)

Checks that the subject has no VoiceSpans on any of the text between start and end.

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

Parameters
int start

The start index to start searching for spans.

int end

The end index to stop searching for spans.

hasRelativeSizeSpanBetween

public SpannedSubject.RelativeSized hasRelativeSizeSpanBetween(int start, int end)

Checks that the subject has a RelativeSizeSpan from start to end.

The size is asserted in a follow-up method call on the return RelativeSized object.

Parameters
int start

The start of the expected span.

int end

The end of the expected span.

Returns
SpannedSubject.RelativeSized

A RelativeSized object to assert on the size of the matching spans.

hasRubySpanBetween

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 RubyText object.

Parameters
int start

The start of the expected span.

int end

The end of the expected span.

Returns
SpannedSubject.RubyText

A Colored object to assert on the color of the matching spans.

hasStrikethroughSpanBetween

public SpannedSubject.WithSpanFlags hasStrikethroughSpanBetween(int start, int end)

Checks that the subject has an StrikethroughSpan from start to end.

Parameters
int start

The start of the expected span.

int end

The end of the expected span.

Returns
SpannedSubject.WithSpanFlags

A WithSpanFlags object for optional additional assertions on the flags.

hasTextEmphasisSpanBetween

public SpannedSubject.EmphasizedText hasTextEmphasisSpanBetween(int start, int end)

Checks that the subject has an TextEmphasisSpan from start to end.

Parameters
int start

The start of the expected span.

int end

The end of the expected span.

Returns
SpannedSubject.EmphasizedText

A EmphasizedText object for optional additional assertions on the flags.

hasTypefaceSpanBetween

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 Typefaced object.

Parameters
int start

The start of the expected span.

int end

The end of the expected span.

Returns
SpannedSubject.Typefaced

A Typefaced object to assert on the font of the matching spans.

hasUnderlineSpanBetween

public SpannedSubject.WithSpanFlags hasUnderlineSpanBetween(int start, int end)

Checks that the subject has an UnderlineSpan from start to end.

Parameters
int start

The start of the expected span.

int end

The end of the expected span.

Returns
SpannedSubject.WithSpanFlags

A WithSpanFlags object for optional additional assertions on the flags.

hasVoiceSpanBetween

public SpannedSubject.VoiceText hasVoiceSpanBetween(int start, int end)

Checks that the subject has an VoiceSpan from start to end.

Parameters
int start

The start of the expected span.

int end

The end of the expected span.

Returns
SpannedSubject.VoiceText

A VoiceSpan object for optional additional assertions on the flags.

spanned

public static Subject.Factory<SpannedSubjectSpannedspanned()