ToggleStateAction extends ToggleAction { @Override public boolean isSelected(@NotNull AnActionEvent event) { View image = getImageView(); return image != null && Ints.contains(image.getDrawableState(), myState.getIntValue()); } ToggleStateAction(@NotNull State state, @NotNull DesignSurface surface); @Override boolean isSelected(@NotNull AnActionEvent event); @Override void setSelected(@NotNull AnActionEvent event, boolean selected); @Override boolean displayTextInToolbar();  }
@Test public void isSelectedImageIsNull() { ToggleAction action = new ToggleStateAction(State.PRESSED, mockSurface(null)); assertFalse(action.isSelected(new AnActionEvent(null, dataId -> null, "sdsd", action.getTemplatePresentation(), ActionManager.getInstance(), -1))); }
@Test public void isSelectedImageIsNotPressed() { ImageView image = mockImage(new int[0]); ToggleAction action = new ToggleStateAction(State.PRESSED, mockSurface(image)); assertFalse(action.isSelected(new AnActionEvent(null, dataId -> null, "sdsd", action.getTemplatePresentation(), ActionManager.getInstance(), -1))); }
@Test public void isSelectedImageIsPressed() { ImageView image = mockImage(new int[]{State.PRESSED.getIntValue()}); ToggleAction action = new ToggleStateAction(State.PRESSED, mockSurface(image)); assertTrue(action.isSelected(new AnActionEvent(null, dataId -> null, "sdsd", action.getTemplatePresentation(), ActionManager.getInstance(), -1))); }