Class AvatarGroupTester<T extends AvatarGroup>

java.lang.Object
com.vaadin.browserless.ComponentTester<T>
com.vaadin.flow.component.avatar.AvatarGroupTester<T>
Type Parameters:
T - component type
All Implemented Interfaces:
Clickable<T>

public class AvatarGroupTester<T extends AvatarGroup> extends ComponentTester<T>
Tester for AvatarGroup components.

AvatarGroup has no server-side listeners: everything the user can do with it happens in the browser without a round trip. This tester is therefore assertion-only, and reports which items are shown as individual avatars and which ones are grouped behind the overflow avatar.

The split is derived from AvatarGroup.getMaxItemsVisible() only. Without a browser there is no layout, so the additional truncation the component applies when the avatars do not fit the available width cannot be taken into account.

  • Constructor Details

    • AvatarGroupTester

      public AvatarGroupTester(T component)
      Wrap given component for testing.
      Parameters:
      component - target component
  • Method Details

    • getItems

      public List<AvatarGroup.AvatarGroupItem> getItems()
      Gets all items of the group, whether or not they are shown as individual avatars.
      Returns:
      the items of the group
      Throws:
      IllegalStateException - if the group is not visible to the user
    • getVisibleItems

      public List<AvatarGroup.AvatarGroupItem> getVisibleItems()
      Gets the items that are shown as individual avatars.
      Returns:
      the items shown as individual avatars
      Throws:
      IllegalStateException - if the group is not visible to the user
    • getOverflowItems

      public List<AvatarGroup.AvatarGroupItem> getOverflowItems()
      Gets the items that do not fit AvatarGroup.getMaxItemsVisible() and are grouped behind the overflow avatar.
      Returns:
      the overflowing items, empty if nothing overflows
      Throws:
      IllegalStateException - if the group is not visible to the user
    • getOverflowAbbreviation

      @Nullable public @Nullable String getOverflowAbbreviation()
      Gets the abbreviation shown on the overflow avatar, such as "+3".
      Returns:
      the overflow abbreviation, or null if no items overflow and the overflow avatar is not shown
      Throws:
      IllegalStateException - if the group is not visible to the user
    • getActiveUsersLabel

      @Nullable public @Nullable String getActiveUsersLabel()
      Gets the accessible label of the group, that is, the one or many active users phrase with {count} replaced by the total number of items.
      Returns:
      the accessible label, or null if no matching translation has been set on the component
      Throws:
      IllegalStateException - if the group is not visible to the user