Package org.testfx.matcher.control
Class TextFlowMatchers
java.lang.Object
org.testfx.matcher.control.TextFlowMatchers
TestFX matchers for
TextFlow
controls.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static String
getColoredTextMarkup
(javafx.scene.text.TextFlow textFlow, boolean exact) private static String
getText
(javafx.scene.text.TextFlow textFlow) 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.private static boolean
hasColoredText
(javafx.scene.text.TextFlow textFlow, String string, boolean exact) 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> Creates a matcher that matches all (TextFlow
s whose "text" (the result of combining all of itsText
children'stext
together) equals the givenstring
.private static boolean
-
Constructor Details
-
TextFlowMatchers
private TextFlowMatchers()
-
-
Method Details
-
hasText
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:
-
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:
-
getText
-
hasText
-
hasColoredText
private static boolean hasColoredText(javafx.scene.text.TextFlow textFlow, String string, boolean exact) -
getColoredTextMarkup
-