|
60 | 60 | import org.scijava.Context; |
61 | 61 | import org.scijava.ItemIO; |
62 | 62 | import org.scijava.ItemVisibility; |
| 63 | +import org.scijava.MenuPath; |
| 64 | +import org.scijava.Priority; |
63 | 65 | import org.scijava.log.LogService; |
64 | 66 | import org.scijava.module.ModuleItem; |
65 | 67 | import org.scijava.plugin.Plugin; |
@@ -264,6 +266,40 @@ public void testParameters() { |
264 | 266 | } |
265 | 267 | } |
266 | 268 |
|
| 269 | + /** Tests {@code #@script} directives. */ |
| 270 | + @Test |
| 271 | + public void testScriptDirective() { |
| 272 | + final String script = "" + // |
| 273 | + "#@script(name = \"my_script\"" + // |
| 274 | + ", label = \"My Script\"" + // |
| 275 | + ", description = \"What a great script.\"" + // |
| 276 | + ", menuPath = \"Plugins > Do All The Things\"" + // |
| 277 | + ", menuRoot = \"special\"" + // |
| 278 | + ", iconPath = \"/path/to/myIcon.png\"" + // |
| 279 | + ", priority = \"extremely-high\"" + // |
| 280 | + ", headless = true" + // |
| 281 | + ", foo = \"bar\"" + // |
| 282 | + ")\n" + |
| 283 | + "WOOT\n"; |
| 284 | + |
| 285 | + ScriptInfo info = null; |
| 286 | + info = |
| 287 | + new ScriptInfo(context, "scriptHeader.bsizes", new StringReader(script)); |
| 288 | + info.inputs(); // HACK: Force lazy initialization. |
| 289 | + |
| 290 | + assertEquals("my_script", info.getName()); |
| 291 | + assertEquals("My Script", info.getLabel()); |
| 292 | + assertEquals("What a great script.", info.getDescription()); |
| 293 | + final MenuPath menuPath = info.getMenuPath(); |
| 294 | + assertEquals(2, menuPath.size()); |
| 295 | + assertEquals("Plugins", menuPath.get(0).getName()); |
| 296 | + assertEquals("Do All The Things", menuPath.get(1).getName()); |
| 297 | + assertEquals("/path/to/myIcon.png", info.getIconPath()); |
| 298 | + assertEquals(Priority.EXTREMELY_HIGH, info.getPriority(), 0.0); |
| 299 | + assertTrue(info.canRunHeadless()); |
| 300 | + assertEquals("bar", info.get("foo")); |
| 301 | + } |
| 302 | + |
267 | 303 | /** |
268 | 304 | * Ensures the ScriptInfos Reader can be reused for multiple executions of the |
269 | 305 | * script. |
|
0 commit comments