public void eventDispatched(AWTEvent event) { if (!isAssertTrigger(event)) { return; } MouseEvent mouse = (MouseEvent) event; GuiComponent guiComponent = factory.find(mouse); if (guiComponent == null) { return; } assertContext.setGuiComponent(guiComponent); assertContext.setPoint(mouse.getPoint()); JPopupMenu menu = dialogManager.newPopupMenu(); for (Iterator iterator = actionManager.actions(); iterator.hasNext(); ) { AbstractAssert assertAction = (AbstractAssert) iterator.next(); String actionId = (String) assertAction.getValue(AbstractAssert.ACTION_ID); ActionViewUtil.connectActionTo(assertAction, menu.add(actionId)); assertAction.update(); if (!guiComponent.isFindable() && AbstractAssert.COMPONENT_ASSERT == assertAction.getAssertType()) { assertAction.setEnabled(false); } } menu.setBorder(BorderFactory.createLineBorder(Color.blue, 5)); menu.show(guiComponent.getSwingComponent(), mouse.getX(), mouse.getY()); }
public void test_update_disable() throws Exception { JTextField source = new JTextField(); context.setGuiComponent(GuiComponentFactory.newGuiComponent(source)); assertTree.update(); assertFalse("Assert disable", assertTree.isEnabled()); }
public void test_assert_bad_source() throws Exception { JTextField source = new JTextField(); context.setGuiComponent(GuiComponentFactory.newGuiComponent(source)); assertTree.execute(); Statement resultAssert = context.getPostedAssert(); assertNull("un assertion n'est pas défini", resultAssert); }
public void test_update_enable() throws Exception { JTree source = buildJTree(new TreePath("root"), "treeName"); context.setGuiComponent(GuiComponentFactory.newGuiComponent(source)); context.setPoint(new Point(1, 1)); assertTree.update(); assertTrue("Assert ensable", assertTree.isEnabled()); }
public void test_update_disabled_noNode() throws Exception { JTree source = buildJTree(null, "treeName"); context.setGuiComponent(GuiComponentFactory.newGuiComponent(source)); context.setPoint(new Point(1, 1)); assertTree.update(); assertFalse("Assert disable", assertTree.isEnabled()); }
public void test_assert_noParent() throws Exception { JTextField source = new JTextField(); assertContext.setGuiComponent(GuiComponentFactory.newGuiComponent(source)); assertFrame.execute(); Statement resultAssert = assertContext.getPostedAssert(); assertNull("un assertion est défini", resultAssert); }
public void test_update() throws Exception { JInternalFrame frame = new JInternalFrame("Options"); JTextField source = new JTextField(); frame.getContentPane().add(source); assertContext.setGuiComponent(GuiComponentFactory.newGuiComponent(source)); assertFrame.update(); assertEquals("AssertFrame titre='Options'", assertFrame.getValue(AssertFrame.LABEL)); }
private void assertTitle(String expectedTitle, RootPaneContainer container) { JTextField source = new JTextField(); container.getContentPane().add(source); assertContext.setGuiComponent(GuiComponentFactory.newGuiComponent(source)); assertFrame.execute(); Statement resultAssert = assertContext.getPostedAssert(); assertNotNull("un assertion est défini", resultAssert); assertEquals("<assertFrame title=\"" + expectedTitle + "\"/>", resultAssert.toXml()); }
public void test_assert_exists() throws Exception { JTree source = buildJTree(new TreePath(new Object[] {"root", "child"}), "treeName"); context.setGuiComponent(GuiComponentFactory.newGuiComponent(source)); context.setPoint(new Point(1, 1)); assertTree.execute(); Statement resultAssert = context.getPostedAssert(); assertNotNull("un assertion est défini", resultAssert); assertEquals( "<assertTree name=\"treeName\" path=\"root:child\" exists=\"true\"/>", resultAssert.toXml()); }
private static GuiComponent toGui(JComponent field) { return GuiComponentFactory.newGuiComponent(field); }