Package org.testfx.matcher.control
Class TextFlowMatchers
- java.lang.Object
-
- org.testfx.matcher.control.TextFlowMatchers
-
public class TextFlowMatchers extends java.lang.Object
TestFX matchers forTextFlow
controls.
-
-
Constructor Summary
Constructors Modifier Constructor Description private
TextFlowMatchers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static java.lang.String
getColoredTextMarkup(javafx.scene.text.TextFlow textFlow, boolean exact)
private static java.lang.String
getText(javafx.scene.text.TextFlow textFlow)
static org.hamcrest.Matcher<javafx.scene.text.TextFlow>
hasColoredText(java.lang.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, java.lang.String string, boolean exact)
static org.hamcrest.Matcher<javafx.scene.text.TextFlow>
hasExactlyColoredText(java.lang.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(java.lang.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
.private static boolean
hasText(javafx.scene.text.TextFlow textFlow, java.lang.String string)
-
-
-
Method Detail
-
hasText
public static org.hamcrest.Matcher<javafx.scene.text.TextFlow> hasText(java.lang.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(java.lang.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(java.lang.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
-
getText
private static java.lang.String getText(javafx.scene.text.TextFlow textFlow)
-
hasText
private static boolean hasText(javafx.scene.text.TextFlow textFlow, java.lang.String string)
-
hasColoredText
private static boolean hasColoredText(javafx.scene.text.TextFlow textFlow, java.lang.String string, boolean exact)
-
getColoredTextMarkup
private static java.lang.String getColoredTextMarkup(javafx.scene.text.TextFlow textFlow, boolean exact)
-
-