public void testSetProperty() throws Exception { Component component = new Component(); SetPropertyAction test = new SetPropertyAction(); assertFalse(test.isEnabled()); assertFalse(test.isVisible()); OurExplorerContext ec = new OurExplorerContext(); ec.component = component; test.setSelectedContext(ec); test.prepare(); assertTrue(test.isEnabled()); Form form = test.form(); DummyDialogue dv = DummyFormViewFactory.create(form).dialogue(); ((TextWidget) dv.get("Name")).setText("fruit"); SelectionWidget selection = (SelectionWidget) dv.get("Value"); DesignInstance value = selection.setSelected(new QTag("value")); DummyDialogue valueDialog = DummyFormViewFactory.create(value.detail()).dialogue(); ((TextWidget) valueDialog.get(null)).setText("apples"); test.action(); assertEquals("apples", component.fruit); }
/** Test action is disabled for an object. */ public void testWithObject() { OurExplorerContext ec = new OurExplorerContext(); ec.component = new Object(); JobAction test = new StopAction(); test.setSelectedContext(ec); test.prepare(); assertFalse(test.isEnabled()); }
/** Test that performing the action works. */ public void testPerform() throws Exception { class MyS implements Stoppable { boolean stopped = false; public void stop() { stopped = true; } } MyS sample = new MyS(); OurExplorerContext ec = new OurExplorerContext(); ec.component = sample; JobAction test = new StopAction(); test.setSelectedContext(ec); assertTrue(test.isEnabled()); test.action(); assertTrue(sample.stopped); }