From: <sh...@us...> - 2009-09-14 14:48:23
|
Revision: 14828 http://cdk.svn.sourceforge.net/cdk/?rev=14828&view=rev Author: shk3 Date: 2009-09-14 14:48:12 +0000 (Mon, 14 Sep 2009) Log Message: ----------- test(s) for specific bugs Added Paths: ----------- jchempaint/trunk/src/test/org/openscience/jchempaint/JCPEditorAppletBugsTest.java Added: jchempaint/trunk/src/test/org/openscience/jchempaint/JCPEditorAppletBugsTest.java =================================================================== --- jchempaint/trunk/src/test/org/openscience/jchempaint/JCPEditorAppletBugsTest.java (rev 0) +++ jchempaint/trunk/src/test/org/openscience/jchempaint/JCPEditorAppletBugsTest.java 2009-09-14 14:48:12 UTC (rev 14828) @@ -0,0 +1,78 @@ +package org.openscience.jchempaint; + +import java.awt.Point; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; + +import javax.vecmath.Point2d; + +import org.fest.swing.applet.AppletViewer; +import org.fest.swing.core.MouseButton; +import org.fest.swing.fixture.DialogFixture; +import org.fest.swing.fixture.FrameFixture; +import org.fest.swing.fixture.JPanelFixture; +import org.fest.swing.launcher.AppletLauncher; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openscience.cdk.CDKConstants; +import org.openscience.cdk.DefaultChemObjectBuilder; +import org.openscience.cdk.exception.CDKException; +import org.openscience.cdk.interfaces.IBond; +import org.openscience.cdk.interfaces.IChemModel; +import org.openscience.cdk.io.MDLV2000Reader; +import org.openscience.jchempaint.applet.JChemPaintEditorApplet; + +public class JCPEditorAppletBugsTest { + private static AppletViewer viewer; + private static FrameFixture applet; + + + @BeforeClass public static void setUp() { + Map<String, String> parameters = new HashMap<String, String>(); + viewer = AppletLauncher.applet(new JChemPaintEditorApplet()) + .withParameters(parameters) + .start(); + applet = new FrameFixture(viewer); + applet.show(); + } + + @Test public void testSquareSelectSingleAtom() throws CDKException, ClassNotFoundException, IOException, CloneNotSupportedException { + JPanelFixture jcppanel=applet.panel("appletframe"); + JChemPaintPanel panel = (JChemPaintPanel)jcppanel.target; + applet.button("C").click(); + Point movetopint=new Point(100,100); + applet.panel("renderpanel").robot.click(applet.panel("renderpanel").component(), movetopint, MouseButton.LEFT_BUTTON,1); + Assert.assertEquals(1, panel.getChemModel().getMoleculeSet().getAtomContainer(0).getAtomCount()); + applet.button("select").click(); + movetopint=new Point(110,110); + applet.panel("renderpanel").robot.moveMouse(applet.panel("renderpanel").component(),movetopint); + applet.panel("renderpanel").robot.pressMouse(MouseButton.LEFT_BUTTON); + movetopint=new Point(90,90); + applet.panel("renderpanel").robot.moveMouse(applet.panel("renderpanel").component(),movetopint); + applet.panel("renderpanel").robot.releaseMouse(MouseButton.LEFT_BUTTON); + Assert.assertEquals(1, panel.getRenderPanel().getRenderer().getRenderer2DModel().getSelection().getConnectedAtomContainer().getAtomCount()); + restoreModel(); + } + + private void restoreModel(){ + JPanelFixture jcppanel=applet.panel("appletframe"); + JChemPaintPanel panel = (JChemPaintPanel)jcppanel.target; + IChemModel basic = DefaultChemObjectBuilder.getInstance().newChemModel(); + basic.setMoleculeSet(basic.getBuilder().newMoleculeSet()); + basic.getMoleculeSet().addAtomContainer( + basic.getBuilder().newMolecule()); + panel.setChemModel(basic); + panel.getRenderPanel().getRenderer().getRenderer2DModel().setZoomFactor(1); + panel.get2DHub().updateView(); + } + + + @AfterClass public static void tearDown() { + viewer.unloadApplet(); + applet.cleanUp(); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |