Class TextFlowMatchers


  • public class TextFlowMatchers
    extends java.lang.Object
    TestFX matchers for TextFlow 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 (TextFlows whose "text" (the result of combining all of its Text children's text together) equals the given string.
      private static boolean hasText​(javafx.scene.text.TextFlow textFlow, java.lang.String string)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TextFlowMatchers

        private TextFlowMatchers()
    • Method Detail

      • hasText

        public static org.hamcrest.Matcher<javafx.scene.text.TextFlow> hasText​(java.lang.String string)
        Creates a matcher that matches all (TextFlows whose "text" (the result of combining all of its Text children's text together) equals the given string.
        Parameters:
        string - the text that matching TextFlows should have
        Returns:
        a match if the text contained in the TextFlow has the same text as the given string
      • 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)