@@ -0,0 +1,2867 @@
+// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.%0Apackage com.intellij.ide.actions;%0A%0Aimport com.intellij.openapi.actionSystem.ActionManager;%0Aimport com.intellij.openapi.actionSystem.AnAction;%0Aimport com.intellij.openapi.actionSystem.AnActionEvent;%0Aimport com.intellij.openapi.actionSystem.CustomShortcutSet;%0Aimport com.intellij.testFramework.LightPlatformTestCase;%0Aimport com.intellij.testFramework.LoggedErrorProcessor;%0Aimport com.intellij.testFramework.RunAll;%0Aimport com.intellij.util.containers.ContainerUtil;%0Aimport org.apache.log4j.Logger;%0Aimport org.jetbrains.annotations.NotNull;%0A%0Aimport javax.swing.*;%0Aimport java.util.List;%0A%0Apublic class BadActionShortcutCheckTest extends LightPlatformTestCase %7B%0A  private static final String MARKER = %22ShortcutSet of global AnActions should not be changed outside of KeymapManager%22;%0A%0A  private final List%3CString%3E myLoggedWarnings = ContainerUtil.createConcurrentList();%0A%0A  @Override%0A  public void setUp() throws Exception %7B%0A    super.setUp();%0A    LoggedErrorProcessor.setNewInstance(new LoggedErrorProcessor() %7B%0A      @Override%0A      public void processWarn(String message, Throwable t, @NotNull Logger logger) %7B%0A        super.processWarn(message, t, logger);%0A        myLoggedWarnings.add(message);%0A      %7D%0A    %7D);%0A  %7D%0A%0A  @Override%0A  public void tearDown() throws Exception %7B%0A    new RunAll()%0A      .append(() -%3E myLoggedWarnings.clear())%0A      .append(() -%3E LoggedErrorProcessor.restoreDefaultProcessor())%0A      .append(() -%3E super.tearDown())%0A      .run();%0A  %7D%0A%0A  public void testActionCanChangeShortcut() %7B%0A    AnAction action1 = new AnAction() %7B%0A      @Override%0A      public void actionPerformed(@NotNull AnActionEvent e) %7B%0A      %7D%0A    %7D;%0A    AnAction action2 = ActionManager.getInstance().getAction(%22$Delete%22);%0A    JPanel component = new JPanel();%0A%0A    action1.registerCustomShortcutSet(action2.getShortcutSet(), component);%0A    assertWarningShown(false);%0A  %7D%0A%0A  public void testGlobalActionCantChangeShortcut1() %7B%0A    AnAction action1 = ActionManager.getInstance().getAction(%22$Copy%22);%0A    AnAction action2 = ActionManager.getInstance().getAction(%22$Delete%22);%0A    JPanel component = new JPanel();%0A%0A    action1.registerCustomShortcutSet(action2.getShortcutSet(), component);%0A    assertWarningShown(true);%0A  %7D%0A%0A  public void testGlobalActionCantChangeShortcut2() %7B%0A    AnAction action = ActionManager.getInstance().getAction(%22$Copy%22);%0A    JPanel component = new JPanel();%0A%0A    action.registerCustomShortcutSet(CustomShortcutSet.EMPTY, component);%0A    assertWarningShown(true);%0A  %7D%0A%0A  private void assertWarningShown(boolean isExpected) %7B%0A    boolean hasWarning = ContainerUtil.exists(myLoggedWarnings, message -%3E message.contains(MARKER));%0A    if (hasWarning != isExpected) %7B%0A      fail(myLoggedWarnings.toString());%0A    %7D%0A  %7D%0A%7D%0A

add test for AnAction.setShortcutSet warning