- java.lang.Object
-
- org.testfx.matcher.control.TextFlowMatchers
-
public class TextFlowMatchers extends Object
TestFX matchers forTextFlow
controls.
-
-
Method Summary
Modifier and Type Method Description static org.hamcrest.Matcher<javafx.scene.text.TextFlow>
hasColoredText(String coloredTextMarkup)
Allows one to verify both the content and color of the text that makes up a TextFlow.static org.hamcrest.Matcher<javafx.scene.text.TextFlow>
hasExactlyColoredText(String coloredTextMarkup)
Allows one to verify both the content and color of the text that makes up a TextFlow.static org.hamcrest.Matcher<javafx.scene.text.TextFlow>
hasText(String string)
Creates a matcher that matches all (TextFlow
s whose "text" (the result of combining all of itsText
children'stext
together) equals the givenstring
.
-
-
-
Method Detail
-
hasText
public static org.hamcrest.Matcher<javafx.scene.text.TextFlow> hasText(String string)
Creates a matcher that matches all (TextFlow
s whose "text" (the result of combining all of itsText
children'stext
together) equals the givenstring
.- Parameters:
string
- the text that matchingTextFlow
s should have- Returns:
- a match if the text contained in the
TextFlow
has the same text as the givenstring
-
hasColoredText
public static org.hamcrest.Matcher<javafx.scene.text.TextFlow> hasColoredText(String coloredTextMarkup)
Allows one to verify both the content and color of the text that makes up a TextFlow. The color is matched by using the closest named color, as described below.Colors are specified using the following markup:
<COLOR>text</COLOR>
Where COLOR is one of JavaFX's named colors.
Here is an example for verifying that a TextFlow contains the text "hello" and that the named color that has the closest value to the color of the text is Colors.RED:
Text text = new Text("hello"); text.setFill(Colors.RED); TextFlow textFlow = new TextFlow(text); assertThat(textFlow, TextFlowMatchers.hasColoredText("<RED>hello</RED>"));
- Parameters:
coloredTextMarkup
- the text contained in the TextFlow with color markup that specifies the expected color of the text- Returns:
- a match if the text contained in the TextFlow has the same content and colors that match by the "closest named color" criteria
- See Also:
- Named Colors
-
hasExactlyColoredText
public static org.hamcrest.Matcher<javafx.scene.text.TextFlow> hasExactlyColoredText(String coloredTextMarkup)
Allows one to verify both the content and color of the text that makes up a TextFlow. The color is matched in an exact way, as described below.Colors are specified using the following markup:
<COLOR>text</COLOR>
Where COLOR is one of JavaFX's named colors.
Here is an example for verifying that a TextFlow contains the text "hello" and that the color of the text is exactly Colors.BLUE (that is, it has an RGB value of (0, 0, 255)).
Text text = new Text("hello"); text.setFill(Colors.BLUE); // or: text.setFill(Colors.rgb(0, 0, 255)); TextFlow textFlow = new TextFlow(text); assertThat(textFlow, TextFlowMatchers.hasExactlyColoredText("
hello "));- Parameters:
coloredTextMarkup
- the text contained in the TextFlow with color markup that specifies the expected color of the text- Returns:
- a match if the text contained in the TextFlow has the same content and the exactly matching colors
- See Also:
- Named Colors
-
-