-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Launch custom commands directly from Menu Item or Dropdown #59 - Draft
Register action programmatically via template in layer.xml (else it does not work using instanceCreate)
- Loading branch information
Showing
6 changed files
with
215 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...pener/src/test/java/me/dsnet/quickopener/actions/layer/ActionRegistrationServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
package me.dsnet.quickopener.actions.layer; | ||
|
||
import org.junit.Test; | ||
import org.openide.filesystems.FileObject; | ||
import org.openide.filesystems.FileUtil; | ||
|
||
/** | ||
* | ||
* @author markiewb | ||
*/ | ||
public class ActionRegistrationServiceTest extends org.netbeans.junit.NbTestCase { | ||
|
||
public ActionRegistrationServiceTest(String name) { | ||
super(name); | ||
} | ||
|
||
@Test | ||
public void testRegisterAction() throws Exception { | ||
ActionRegistrationService.registerAction("id", "category", "displayName", "command"); | ||
{ | ||
FileObject configFile = FileUtil.getConfigFile("Actions/category/displayName.instance"); | ||
assertNotNull(configFile); | ||
//check for attribute | ||
assertEquals("displayName", configFile.getAttribute("displayName")); | ||
assertEquals("command", configFile.getAttribute("custom-command")); | ||
assertNotNull(configFile.getAttribute("imagePath")); | ||
} | ||
|
||
} | ||
|
||
@Test | ||
public void testRegisterMenu() throws Exception { | ||
ActionRegistrationService.registerActionAsMenuAndToolbar("action1", "category"); | ||
{ | ||
FileObject configFile = FileUtil.getConfigFile("Menu/category/action1.shadow"); | ||
assertNotNull(configFile); | ||
} | ||
} | ||
|
||
@Test | ||
public void testRegisterToolbar() throws Exception { | ||
ActionRegistrationService.registerActionAsMenuAndToolbar("action1", "category"); | ||
{ | ||
FileObject configFile = FileUtil.getConfigFile("Toolbars/category/action1.shadow"); | ||
assertNotNull(configFile); | ||
} | ||
} | ||
|
||
@Test | ||
public void testUnregisterAction() throws Exception { | ||
ActionRegistrationService.registerAction("id", "category", "displayName", "command"); | ||
ActionRegistrationService.registerActionAsMenuAndToolbar("displayName", "category"); | ||
|
||
ActionRegistrationService.unregisterAction("displayName", "category"); | ||
assertNull(FileUtil.getConfigFile("Actions/category/displayName.instance")); | ||
assertNull(FileUtil.getConfigFile("Menu/category/displayName.shadow")); | ||
assertNull(FileUtil.getConfigFile("Toolbars/category/displayName.shadow")); | ||
} | ||
|
||
} |