@Test public void testPropertiesContextMenu() throws Exception { openDialog(); // use index 1 since first tree is property page navigation tree SWTBotTree tree = mBot.tree(1); ContextMenuHelper.clickContextMenu(tree, "Add"); new NewPropertyInputDialogTestFixture("keyx", "valuex").inputData(); ContextMenuHelper.clickContextMenu(tree, "Add"); new NewPropertyInputDialogTestFixture("keyz", "valuez").inputData(); tree.getTreeItem("keyz").select(); ContextMenuHelper.clickContextMenu(tree, "Delete"); tree.unselect(); // delete should not show up when the selection is empty assertThat(SWTTestUtil.getMenuItems(tree).get("Delete"), nullValue()); mBot.button("OK").click(); Thread.sleep(WAIT_TIME); AbstractUIRunner.syncRun( new ThrowableRunnable() { @Override public void run() throws Throwable { assertDeployedStrategy( mStrategy, mEngine, StrategyState.STOPPED, "Strategy1", "Claz", "Lang", "c:\\path", true, ImmutableMap.of("keyx", "valuex")); } }); }
private void openDialog() throws Exception { AbstractUIRunner.syncRun( new ThrowableRunnable() { @Override public void run() throws Throwable { mStrategy = createDeployedStrategy("Strategy1"); mStrategy.setUrn(new ModuleURN("metc:strategy:system:Strategy1")); mStrategy.setClassName("Claz"); mStrategy.setLanguage("Lang"); mStrategy.setScriptPath("c:\\path"); mStrategy.setRouteOrdersToServer(true); mEngine = createEngine("Engine"); mEngine.setConnection(new MockUIConnection()); mEngine.getDeployedStrategies().add(mStrategy); mDialog = PropertyDialog.createDialogOn( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), StrategyEngineWorkbenchUI.DEPLOYED_STRATEGY_CONFIGURATION_PROPERTY_PAGE_ID, mStrategy); mDialog.setBlockOnOpen(false); mDialog.open(); } }); mBot.shell("Properties for Strategy1 on Engine"); SWTTestUtil.assertButtonDoesNotExist("Apply"); SWTTestUtil.assertButtonDoesNotExist("Restore Defaults"); SWTTestUtil.testReadOnlyText(mBot.textWithLabel("Instance Name:"), "Strategy1"); SWTTestUtil.testReadOnlyText(mBot.textWithLabel("Class:"), "Claz"); SWTTestUtil.testReadOnlyText(mBot.textWithLabel("Language:"), "Lang"); SWTTestUtil.testReadOnlyText(mBot.textWithLabel("Script:"), "c:\\path"); }