@UnstableApi
class SpannedSubject : Subject


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

Summary

Nested types

Allows assertions about the absolute size of a span.

Allows assertions about the alignment of a span.

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

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.

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

Allows assertions about the typeface of a span.

Allows assertions about a span's voice its position.

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

Public functions

java-static SpannedSubject!
assertThat(spanned: Spanned?)

Convenience method to create a SpannedSubject.

SpannedSubject.AbsoluteSized!

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

SpannedSubject.Aligned!

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

SpannedSubject.Colored!

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

SpannedSubject.WithSpanFlags!

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

SpannedSubject.WithSpanFlags!
hasBoldSpanBetween(start: Int, end: Int)

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

SpannedSubject.Colored!

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(start: Int, end: Int)

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

Unit

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

Unit

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

Unit

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

Unit

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

Unit

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

Unit

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

Unit
hasNoRubySpanBetween(start: Int, end: Int)

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

Unit
Unit

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

Unit
hasNoStyleSpanBetween(start: Int, end: Int)

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

Unit

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

Unit

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

Unit

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

Unit
hasNoVoiceSpanBetween(start: Int, end: Int)

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

SpannedSubject.RelativeSized!

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

SpannedSubject.RubyText!
hasRubySpanBetween(start: Int, end: Int)

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

SpannedSubject.WithSpanFlags!

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

SpannedSubject.EmphasizedText!

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

SpannedSubject.Typefaced!
hasTypefaceSpanBetween(start: Int, end: Int)

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

SpannedSubject.WithSpanFlags!

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

SpannedSubject.VoiceText!
hasVoiceSpanBetween(start: Int, end: Int)

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

java-static Subject.Factory<SpannedSubject!, Spanned!>!

Inherited functions

From com.google.common.truth.Subject
String!
Boolean
equals(o: Any?)

This function is deprecated.

Unit
failWithActual(key: String!, value: Any?)
Unit
failWithoutActual(first: Fact!, rest: Array<Fact!>!)
Int

This function is deprecated.

StandardSubjectBuilder!
Unit
isAnyOf(first: Any?, second: Any?, rest: Array<Any?>?)
Unit
isEqualTo(expected: Any?)
Unit
isIn(iterable: (Mutable)Iterable<Any!>?)
Unit
isInstanceOf(clazz: Class<Any!>!)
Unit
isNoneOf(first: Any?, second: Any?, rest: Array<Any?>?)
Unit
isNotEqualTo(unexpected: Any?)
Unit
isNotIn(iterable: (Mutable)Iterable<Any!>?)
Unit
Unit
Unit
isNotSameInstanceAs(unexpected: Any?)
Unit
Unit
isSameInstanceAs(expected: Any?)
String!

This function is deprecated.

Public functions

assertThat

java-static fun assertThat(spanned: Spanned?): SpannedSubject!

Convenience method to create a SpannedSubject.

Can be statically imported alongside other Truth assertThat methods.

Parameters
spanned: Spanned?

The subject under test.

Returns
SpannedSubject!

An object for conducting assertions on the subject.

hasAbsoluteSizeSpanBetween

fun hasAbsoluteSizeSpanBetween(start: Int, end: Int): SpannedSubject.AbsoluteSized!

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
start: Int

The start of the expected span.

end: Int

The end of the expected span.

Returns
SpannedSubject.AbsoluteSized!

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

hasAlignmentSpanBetween

fun hasAlignmentSpanBetween(start: Int, end: Int): SpannedSubject.Aligned!

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
start: Int

The start of the expected span.

end: Int

The end of the expected span.

Returns
SpannedSubject.Aligned!

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

hasBackgroundColorSpanBetween

fun hasBackgroundColorSpanBetween(start: Int, end: Int): SpannedSubject.Colored!

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
start: Int

The start of the expected span.

end: Int

The end of the expected span.

Returns
SpannedSubject.Colored!

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

hasBoldItalicSpanBetween

fun hasBoldItalicSpanBetween(start: Int, end: Int): SpannedSubject.WithSpanFlags!

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: Int

The start of the expected span.

end: Int

The end of the expected span.

Returns
SpannedSubject.WithSpanFlags!

A WithSpanFlags object for optional additional assertions on the flags.

hasBoldSpanBetween

fun hasBoldSpanBetween(start: Int, end: Int): SpannedSubject.WithSpanFlags!

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

Parameters
start: Int

The start of the expected span.

end: Int

The end of the expected span.

Returns
SpannedSubject.WithSpanFlags!

A WithSpanFlags object for optional additional assertions on the flags.

hasForegroundColorSpanBetween

fun hasForegroundColorSpanBetween(start: Int, end: Int): SpannedSubject.Colored!

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
start: Int

The start of the expected span.

end: Int

The end of the expected span.

Returns
SpannedSubject.Colored!

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

hasHorizontalTextInVerticalContextSpanBetween

fun hasHorizontalTextInVerticalContextSpanBetween(start: Int, end: Int): SpannedSubject.WithSpanFlags!

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

Parameters
start: Int

The start of the expected span.

end: Int

The end of the expected span.

Returns
SpannedSubject.WithSpanFlags!

A WithSpanFlags object for optional additional assertions on the flags.

hasItalicSpanBetween

fun hasItalicSpanBetween(start: Int, end: Int): SpannedSubject.WithSpanFlags!

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

Parameters
start: Int

The start of the expected span.

end: Int

The end of the expected span.

Returns
SpannedSubject.WithSpanFlags!

A WithSpanFlags object for optional additional assertions on the flags.

hasNoAbsoluteSizeSpanBetween

fun hasNoAbsoluteSizeSpanBetween(start: Int, end: Int): Unit

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: Int

The start index to start searching for spans.

end: Int

The end index to stop searching for spans.

hasNoAlignmentSpanBetween

fun hasNoAlignmentSpanBetween(start: Int, end: Int): Unit

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: Int

The start index to start searching for spans.

end: Int

The end index to stop searching for spans.

hasNoBackgroundColorSpanBetween

fun hasNoBackgroundColorSpanBetween(start: Int, end: Int): Unit

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: Int

The start index to start searching for spans.

end: Int

The end index to stop searching for spans.

hasNoForegroundColorSpanBetween

fun hasNoForegroundColorSpanBetween(start: Int, end: Int): Unit

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: Int

The start index to start searching for spans.

end: Int

The end index to stop searching for spans.

hasNoHorizontalTextInVerticalContextSpanBetween

fun hasNoHorizontalTextInVerticalContextSpanBetween(start: Int, end: Int): Unit

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: Int

The start index to start searching for spans.

end: Int

The end index to stop searching for spans.

hasNoRelativeSizeSpanBetween

fun hasNoRelativeSizeSpanBetween(start: Int, end: Int): Unit

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: Int

The start index to start searching for spans.

end: Int

The end index to stop searching for spans.

hasNoRubySpanBetween

fun hasNoRubySpanBetween(start: Int, end: Int): Unit

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: Int

The start index to start searching for spans.

end: Int

The end index to stop searching for spans.

hasNoSpans

fun hasNoSpans(): Unit

hasNoStrikethroughSpanBetween

fun hasNoStrikethroughSpanBetween(start: Int, end: Int): Unit

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: Int

The start index to start searching for spans.

end: Int

The end index to stop searching for spans.

hasNoStyleSpanBetween

fun hasNoStyleSpanBetween(start: Int, end: Int): Unit

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: Int

The start index to start searching for spans.

end: Int

The end index to stop searching for spans.

hasNoTextEmphasisSpanBetween

fun hasNoTextEmphasisSpanBetween(start: Int, end: Int): Unit

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: Int

The start index to start searching for spans.

end: Int

The end index to stop searching for spans.

hasNoTypefaceSpanBetween

fun hasNoTypefaceSpanBetween(start: Int, end: Int): Unit

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: Int

The start index to start searching for spans.

end: Int

The end index to stop searching for spans.

hasNoUnderlineSpanBetween

fun hasNoUnderlineSpanBetween(start: Int, end: Int): Unit

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: Int

The start index to start searching for spans.

end: Int

The end index to stop searching for spans.

hasNoVoiceSpanBetween

fun hasNoVoiceSpanBetween(start: Int, end: Int): Unit

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
start: Int

The start index to start searching for spans.

end: Int

The end index to stop searching for spans.

hasRelativeSizeSpanBetween

fun hasRelativeSizeSpanBetween(start: Int, end: Int): SpannedSubject.RelativeSized!

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
start: Int

The start of the expected span.

end: Int

The end of the expected span.

Returns
SpannedSubject.RelativeSized!

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

hasRubySpanBetween

fun hasRubySpanBetween(start: Int, end: Int): SpannedSubject.RubyText!

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
start: Int

The start of the expected span.

end: Int

The end of the expected span.

Returns
SpannedSubject.RubyText!

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

hasStrikethroughSpanBetween

fun hasStrikethroughSpanBetween(start: Int, end: Int): SpannedSubject.WithSpanFlags!

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

Parameters
start: Int

The start of the expected span.

end: Int

The end of the expected span.

Returns
SpannedSubject.WithSpanFlags!

A WithSpanFlags object for optional additional assertions on the flags.

hasTextEmphasisSpanBetween

fun hasTextEmphasisSpanBetween(start: Int, end: Int): SpannedSubject.EmphasizedText!

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

Parameters
start: Int

The start of the expected span.

end: Int

The end of the expected span.

Returns
SpannedSubject.EmphasizedText!

A EmphasizedText object for optional additional assertions on the flags.

hasTypefaceSpanBetween

fun hasTypefaceSpanBetween(start: Int, end: Int): SpannedSubject.Typefaced!

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
start: Int

The start of the expected span.

end: Int

The end of the expected span.

Returns
SpannedSubject.Typefaced!

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

hasUnderlineSpanBetween

fun hasUnderlineSpanBetween(start: Int, end: Int): SpannedSubject.WithSpanFlags!

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

Parameters
start: Int

The start of the expected span.

end: Int

The end of the expected span.

Returns
SpannedSubject.WithSpanFlags!

A WithSpanFlags object for optional additional assertions on the flags.

hasVoiceSpanBetween

fun hasVoiceSpanBetween(start: Int, end: Int): SpannedSubject.VoiceText!

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

Parameters
start: Int

The start of the expected span.

end: Int

The end of the expected span.

Returns
SpannedSubject.VoiceText!

A VoiceSpan object for optional additional assertions on the flags.

spanned

java-static fun spanned(): Subject.Factory<SpannedSubject!, Spanned!>!