Back to Exoplayer

SpannedSubject (ExoPlayer library)

docs/doc/reference/com/google/android/exoplayer2/testutil/truth/SpannedSubject.html

latest29.8 KB
Original Source

Package com.google.android.exoplayer2.testutil.truth

Class SpannedSubject

  • java.lang.Object

    • com.google.common.truth.Subject
      • com.google.android.exoplayer2.testutil.truth.SpannedSubject

public final classSpannedSubjectextends com.google.common.truth.Subject

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

Nested Class Summary

Nested Classes | Modifier and Type | Class | Description | | --- | --- | --- | | static interface | SpannedSubject.AbsoluteSized | Allows assertions about the absolute size of a span. | | static interface | SpannedSubject.Aligned | Allows assertions about the alignment of a span. | | static interface | SpannedSubject.AndSpanFlags | Allows additional assertions to be made on the flags of matching spans. | | static interface | SpannedSubject.Colored | Allows assertions about the color of a span. | | static interface | SpannedSubject.EmphasizedText | Allows assertions about a span's text emphasis mark and its position. | | static interface | SpannedSubject.RelativeSized | Allows assertions about the relative size of a span. | | static interface | SpannedSubject.RubyText | Allows assertions about a span's ruby text and its position. | | static interface | SpannedSubject.Typefaced | Allows assertions about the typeface of a span. | | static interface | SpannedSubject.WithSpanFlags | Allows additional assertions to be made on the flags of matching spans. |

- 

Nested classes/interfaces inherited from class com.google.common.truth.Subject

com.google.common.truth.Subject.Factory<SubjectT extends com.google.common.truth.Subject,​ActualT extends Object>

Method Summary

All Methods Static Methods Instance Methods Concrete Methods | Modifier and Type | Method | Description | | --- | --- | --- | | static SpannedSubject | assertThat​(Spanned spanned) | 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 | hasHorizontalTextInVerticalContextSpanBetween​(int start, int end) | 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 | hasNoHorizontalTextInVerticalContextSpanBetween​(int start, int end) | 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 | hasNoSpans() | | | 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. | | 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. | | static com.google.common.truth.Subject.Factory<SpannedSubject,​Spanned> | spanned() | |

- 

Methods inherited from class com.google.common.truth.Subject

actualCustomStringRepresentation, check, equals, failWithActual, failWithActual, failWithoutActual, hashCode, ignoreCheck, isAnyOf, isEqualTo, isIn, isInstanceOf, isNoneOf, isNotEqualTo, isNotIn, isNotInstanceOf, isNotNull, isNotSameInstanceAs, isNull, isSameInstanceAs, toString

- 

Methods inherited from class java.lang.Object

clone, finalize, getClass, notify, notifyAll, wait, wait, wait

Method Detail

- 

spanned

public static com.google.common.truth.Subject.Factory<[SpannedSubject](SpannedSubject.html "class in com.google.android.exoplayer2.testutil.truth"),​[Spanned](https://developer.android.com/reference/android/text/Spanned.html "class or interface in android.text")> spanned()
- 

assertThat

public static[SpannedSubject](SpannedSubject.html "class in com.google.android.exoplayer2.testutil.truth")assertThat​(@Nullable[Spanned](https://developer.android.com/reference/android/text/Spanned.html "class or interface in android.text")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](SpannedSubject.WithSpanFlags.html "interface in com.google.android.exoplayer2.testutil.truth")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](SpannedSubject.WithSpanFlags.html "interface in com.google.android.exoplayer2.testutil.truth")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](SpannedSubject.WithSpanFlags.html "interface in com.google.android.exoplayer2.testutil.truth")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`](https://developer.android.com/reference/android/text/style/StyleSpan.html "class or interface in android.text.style") with `span.getStyle() == Typeface.BOLD_ITALIC`. 
  - Two [`StyleSpan`](https://developer.android.com/reference/android/text/style/StyleSpan.html "class or interface in android.text.style")s, 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](SpannedSubject.WithSpanFlags.html "interface in com.google.android.exoplayer2.testutil.truth")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](SpannedSubject.WithSpanFlags.html "interface in com.google.android.exoplayer2.testutil.truth")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](SpannedSubject.Aligned.html "interface in com.google.android.exoplayer2.testutil.truth")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](SpannedSubject.Colored.html "interface in com.google.android.exoplayer2.testutil.truth")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](SpannedSubject.Colored.html "interface in com.google.android.exoplayer2.testutil.truth")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](SpannedSubject.Typefaced.html "interface in com.google.android.exoplayer2.testutil.truth")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.

- 

hasAbsoluteSizeSpanBetween

@CheckResult
public[SpannedSubject.AbsoluteSized](SpannedSubject.AbsoluteSized.html "interface in com.google.android.exoplayer2.testutil.truth")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 SpannedSubject.AbsoluteSized object.

Parameters:start - The start of the expected span.end - The end of the expected span.Returns:A SpannedSubject.AbsoluteSized object to assert on the size of the matching 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.

- 

hasRelativeSizeSpanBetween

@CheckResult
public[SpannedSubject.RelativeSized](SpannedSubject.RelativeSized.html "interface in com.google.android.exoplayer2.testutil.truth")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 SpannedSubject.RelativeSized object.

Parameters:start - The start of the expected span.end - The end of the expected span.Returns:A SpannedSubject.RelativeSized object to assert on the size of the matching 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](SpannedSubject.RubyText.html "interface in com.google.android.exoplayer2.testutil.truth")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.

- 

hasHorizontalTextInVerticalContextSpanBetween

public[SpannedSubject.WithSpanFlags](SpannedSubject.WithSpanFlags.html "interface in com.google.android.exoplayer2.testutil.truth")hasHorizontalTextInVerticalContextSpanBetween​(int start,
                                                                                  int end)

Checks that the subject has an HorizontalTextInVerticalContextSpan 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.

- 

hasTextEmphasisSpanBetween

public[SpannedSubject.EmphasizedText](SpannedSubject.EmphasizedText.html "interface in com.google.android.exoplayer2.testutil.truth")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.