void () { myParent.clearOwnActionsIds(); myChild.clearOwnActionsIds(); String BASE = "BASE_ACTION"; String DEPENDENT = "DEPENDENT_ACTION"; KeymapManagerEx.getInstanceEx().bindShortcuts(BASE, DEPENDENT); try { assertSameElements(myParent.getShortcuts(BASE)); assertSameElements(myParent.getShortcuts(DEPENDENT)); assertSameElements(myParent.getActionIds(shortcut1)); assertSameElements(myChild.getShortcuts(BASE)); assertSameElements(myChild.getShortcuts(DEPENDENT)); assertSameElements(myChild.getActionIds(shortcut1)); myParent.addShortcut(BASE, shortcut1); // parent: // BASE -> shortcut1 // DEPENDENT -> BASE // child: // - assertSameElements(myParent.getShortcuts(BASE), shortcut1); assertSameElements(myParent.getShortcuts(DEPENDENT), shortcut1); assertSameElements(myParent.getActionIds(shortcut1), BASE, DEPENDENT); assertTrue(myParent.hasOwnActionId(BASE)); assertFalse(myParent.hasOwnActionId(DEPENDENT)); assertSameElements(myChild.getShortcuts(BASE), shortcut1); assertSameElements(myChild.getShortcuts(DEPENDENT), shortcut1); assertSameElements(myChild.getActionIds(shortcut1), BASE, DEPENDENT); assertFalse(myChild.hasOwnActionId(BASE)); assertFalse(myChild.hasOwnActionId(DEPENDENT)); // override BASE action in child // parent: // BASE -> shortcut1 // DEPENDENT -> BASE // child: // BASE -> shortcut1, shortcut2 // DEPENDENT -> child:BASE myChild.addShortcut(BASE, shortcut2); assertSameElements(myChild.getShortcuts(BASE), shortcut1, shortcut2); assertSameElements(myChild.getShortcuts(DEPENDENT), shortcut1, shortcut2); assertSameElements(myChild.getActionIds(shortcut1), BASE, DEPENDENT); assertSameElements(myChild.getActionIds(shortcut2), BASE, DEPENDENT); assertTrue(myChild.hasOwnActionId(BASE)); assertFalse(myChild.hasOwnActionId(DEPENDENT)); // extend BASE action, overridden in child // parent: // BASE -> shortcut1, shortcutA // DEPENDENT -> BASE // child: // BASE -> shortcut1, shortcut2 // DEPENDENT -> child:BASE myParent.addShortcut(BASE, shortcutA); // parent assertSameElements(myParent.getShortcuts(BASE), shortcut1, shortcutA); assertSameElements(myParent.getShortcuts(DEPENDENT), shortcut1, shortcutA); assertSameElements(myParent.getActionIds(shortcut1), BASE, DEPENDENT); assertSameElements(myParent.getActionIds(shortcutA), BASE, DEPENDENT); assertTrue(myParent.hasOwnActionId(BASE)); assertFalse(myParent.hasOwnActionId(DEPENDENT)); // child is not affected since the action is overridden assertSameElements(myChild.getShortcuts(BASE), shortcut1, shortcut2); assertSameElements(myChild.getShortcuts(DEPENDENT), shortcut1, shortcut2); assertSameElements(myChild.getActionIds(shortcut1), BASE, DEPENDENT); assertSameElements(myChild.getActionIds(shortcut2), BASE, DEPENDENT); assertSameElements(myChild.getActionIds(shortcutA)); assertTrue(myChild.hasOwnActionId(BASE)); assertFalse(myChild.hasOwnActionId(DEPENDENT)); // extend DEPENDENT action, not-overridden in child // parent: // BASE -> shortcut1 // DEPENDENT -> shortcut1, shortcutB // child: // BASE -> shortcut1, shortcut2 // DEPENDENT -> child:BASE myParent.removeShortcut(BASE, shortcutA); myParent.addShortcut(DEPENDENT, shortcutB); // parent assertSameElements(myParent.getShortcuts(BASE), shortcut1); assertSameElements(myParent.getShortcuts(DEPENDENT), shortcut1, shortcutB); assertSameElements(myParent.getActionIds(shortcut1), BASE, DEPENDENT); assertSameElements(myParent.getActionIds(shortcut2)); assertSameElements(myParent.getActionIds(shortcutA)); assertSameElements(myParent.getActionIds(shortcutB), DEPENDENT); assertTrue(myParent.hasOwnActionId(BASE)); assertTrue(myParent.hasOwnActionId(DEPENDENT)); // child assertSameElements(myChild.getShortcuts(BASE), shortcut1, shortcut2); assertSameElements(myChild.getShortcuts(DEPENDENT), shortcut1, shortcut2); assertSameElements(myChild.getActionIds(shortcut1), BASE, DEPENDENT); assertSameElements(myChild.getActionIds(shortcut2), BASE, DEPENDENT); assertSameElements(myChild.getActionIds(shortcutA)); assertSameElements(myChild.getActionIds(shortcutB)); assertTrue(myChild.hasOwnActionId(BASE)); assertFalse(myChild.hasOwnActionId(DEPENDENT)); // override DEPENDENT action in child // parent: // BASE -> shortcut1 // DEPENDENT -> shortcut1, shortcutB // child: // BASE -> shortcut1, shortcut2 // DEPENDENT -> shortcut1, shortcut2, shortcutA myChild.addShortcut(DEPENDENT, shortcutA); assertSameElements(myChild.getShortcuts(BASE), shortcut1, shortcut2); assertSameElements(myChild.getShortcuts(DEPENDENT), shortcut1, shortcut2, shortcutA); assertSameElements(myChild.getActionIds(shortcut1), BASE, DEPENDENT); assertSameElements(myChild.getActionIds(shortcut2), BASE, DEPENDENT); assertSameElements(myChild.getActionIds(shortcutA), DEPENDENT); assertSameElements(myChild.getActionIds(shortcutB)); assertTrue(myChild.hasOwnActionId(BASE)); assertTrue(myChild.hasOwnActionId(DEPENDENT)); } finally { KeymapManagerEx.getInstanceEx().unbindShortcuts(DEPENDENT); } }