Package 

Interface NodeAssertions

    • Method Detail

      • assertIsEnabled

         Unit assertIsEnabled()

        Asserts that the current semantics node is enabled.

        Throws AssertionError if the node is not enabled or does not define the property at all.

      • assertIsNotEnabled

         Unit assertIsNotEnabled()

        Asserts that the current semantics node is not enabled.

        Throws AssertionError if the node is enabled or does not defined the property at all.

      • assertIsOn

         Unit assertIsOn()

        Asserts that the current semantics node is checked.

        Throws AssertionError if the node is not unchecked, indeterminate, or not toggleable.

      • assertIsOff

         Unit assertIsOff()

        Asserts that the current semantics node is unchecked.

        Throws AssertionError if the node is checked, indeterminate, or not toggleable.

      • assertIsFocused

         Unit assertIsFocused()

        Asserts that the current semantics node has a focus.

        Throws AssertionError if the node is not in the focus or does not defined the property at all.

      • assertIsNotFocused

         Unit assertIsNotFocused()

        Asserts that the current semantics node does not have a focus.

        Throws AssertionError if the node is in the focus or does not defined the property at all.

      • assertContentDescriptionEquals

         Unit assertContentDescriptionEquals(String values)

        Asserts that the node's content description contains exactly the given values and nothing else.

        Note that in merged semantics tree there can be a list of content descriptions that got merged from the child nodes. Typically an accessibility tooling will decide based on its heuristics which ones to announce.

        Throws AssertionError if the node's descriptions don't contain all items from values, or if the descriptions contain extra items that are not in values.

        Parameters:
        values - List of values to match (the order does not matter)
      • assertContentDescriptionContains

         Unit assertContentDescriptionContains(String value, Boolean substring, Boolean ignoreCase)

        Asserts that the node's content description contains the given value.

        Note that in merged semantics tree there can be a list of content descriptions that got merged from the child nodes. Typically an accessibility tooling will decide based on its heuristics which ones to announce.

        Throws AssertionError if the node's value does not contain value, or if the node has no value

        Parameters:
        value - Value to match as one of the items in the list of content descriptions.
        substring - Whether this can be satisfied as a substring match of an item in the list of descriptions.
        ignoreCase - Whether case should be ignored.
      • assertTextEquals

         Unit assertTextEquals(String values, Boolean includeEditableText)

        Asserts that the node's text contains exactly the given values and nothing else.

        This will also search in SemanticsProperties.EditableText by default.

        Note that in merged semantics tree there can be a list of text items that got merged from the child nodes. Typically an accessibility tooling will decide based on its heuristics which ones to use.

        Throws AssertionError if the node's text values don't contain all items from values, or if the text values contain extra items that are not in values.

        Parameters:
        values - List of values to match (the order does not matter)
        includeEditableText - Whether to also assert against the editable text.
      • assertTextContains

         Unit assertTextContains(String value, Boolean substring, Boolean ignoreCase)

        Asserts that the node's text contains the given value.

        This will also search in SemanticsProperties.EditableText.

        Note that in merged semantics tree there can be a list of text items that got merged from the child nodes. Typically an accessibility tooling will decide based on its heuristics which ones to use.

        Throws AssertionError if the node's value does not contain value, or if the node has no value

        Parameters:
        value - Value to match as one of the items in the list of text values.
        substring - Whether this can be satisfied as a substring match of an item in the list of text.
        ignoreCase - Whether case should be ignored.
      • assertValueEquals

         Unit assertValueEquals(String value)

        Asserts the node's value equals the given value.

        For further details please check SemanticsProperties.StateDescription. Throws AssertionError if the node's value is not equal to value, or if the node has no value

      • assertRangeInfoEquals

         Unit assertRangeInfoEquals(ProgressBarRangeInfo value)

        Asserts the node's range info equals the given value.

        For further details please check SemanticsProperties.ProgressBarRangeInfo. Throws AssertionError if the node's value is not equal to value, or if the node has no value

      • assertDoesNotExist

         Unit assertDoesNotExist()

        Asserts that no item was found or that the item is no longer in the hierarchy.

        This will synchronize with the UI and fetch all the nodes again to ensure it has latest data.

      • assertExists

         Unit assertExists(String errorMessageOnFail)

        Asserts that the component was found and is part of the component tree.

        This will synchronize with the UI and fetch all the nodes again to ensure it has latest data. If you are using fetchSemanticsNode you don't need to call this. In fact you would just introduce additional overhead.

        Parameters:
        errorMessageOnFail - Error message prefix to be added to the message in case this asserts fails.
      • assert

         Unit assert(SemanticsMatcher matcher, Function0<String> messagePrefixOnError)

        Asserts that the provided matcher is satisfied for this node.

        Parameters:
        matcher - Matcher to verify.
        messagePrefixOnError - Prefix to be put in front of an error that gets thrown in case this assert fails.