/* * @(#)Test.java * * Project: JHotdraw - a GUI framework for technical drawings * http://www.jhotdraw.org * http://jhotdraw.sourceforge.net * Copyright: (c) by the original author(s) and all contributors * License: Lesser GNU Public License (LGPL) * http://www.opensource.org/licenses/lgpl-license.html */ package org.jhotdraw.test.contrib; import java.awt.Point; import org.jhotdraw.contrib.TriangleFigure; import junit.framework.TestCase; // JUnitDoclet begin import // JUnitDoclet end import /* * Generated by JUnitDoclet, a tool provided by * ObjectFab GmbH under LGPL. * Please see www.junitdoclet.org, www.gnu.org * and www.objectfab.de for informations about * the tool, the licence and the authors. */ // JUnitDoclet begin javadoc_class /** * TestCase TriangleFigureTest is generated by * JUnitDoclet to hold the tests for TriangleFigure. * @see org.jhotdraw.contrib.TriangleFigure */ // JUnitDoclet end javadoc_class public class TriangleFigureTest // JUnitDoclet begin extends_implements extends TestCase // JUnitDoclet end extends_implements { // JUnitDoclet begin class // instance variables, helper methods, ... put them in this marker private TriangleFigure trianglefigure; // JUnitDoclet end class /** * Constructor TriangleFigureTest is * basically calling the inherited constructor to * initiate the TestCase for use by the Framework. */ public TriangleFigureTest(String name) { // JUnitDoclet begin method TriangleFigureTest super(name); // JUnitDoclet end method TriangleFigureTest } /** * Factory method for instances of the class to be tested. */ public TriangleFigure createInstance() throws Exception { // JUnitDoclet begin method testcase.createInstance return new TriangleFigure(new Point(0, 0), new Point(10, 10)); // JUnitDoclet end method testcase.createInstance } /** * Method setUp is overwriting the framework method to * prepare an instance of this TestCase for a single test. * It's called from the JUnit framework only. */ protected void setUp() throws Exception { // JUnitDoclet begin method testcase.setUp super.setUp(); trianglefigure = createInstance(); // JUnitDoclet end method testcase.setUp } /** * Method tearDown is overwriting the framework method to * clean up after each single test of this TestCase. * It's called from the JUnit framework only. */ protected void tearDown() throws Exception { // JUnitDoclet begin method testcase.tearDown trianglefigure = null; super.tearDown(); // JUnitDoclet end method testcase.tearDown } // JUnitDoclet begin javadoc_method handles() /** * Method testHandles is testing handles * @see org.jhotdraw.contrib.TriangleFigure#handles() */ // JUnitDoclet end javadoc_method handles() public void testHandles() throws Exception { // JUnitDoclet begin method handles // JUnitDoclet end method handles } // JUnitDoclet begin javadoc_method rotate() /** * Method testRotate is testing rotate * @see org.jhotdraw.contrib.TriangleFigure#rotate(double) */ // JUnitDoclet end javadoc_method rotate() public void testRotate() throws Exception { // JUnitDoclet begin method rotate // JUnitDoclet end method rotate } // JUnitDoclet begin javadoc_method getPolygon() /** * Method testGetPolygon is testing getPolygon * @see org.jhotdraw.contrib.TriangleFigure#getPolygon() */ // JUnitDoclet end javadoc_method getPolygon() public void testGetPolygon() throws Exception { // JUnitDoclet begin method getPolygon // JUnitDoclet end method getPolygon } // JUnitDoclet begin javadoc_method draw() /** * Method testDraw is testing draw * @see org.jhotdraw.contrib.TriangleFigure#draw(java.awt.Graphics) */ // JUnitDoclet end javadoc_method draw() public void testDraw() throws Exception { // JUnitDoclet begin method draw // JUnitDoclet end method draw } // JUnitDoclet begin javadoc_method connectionInsets() /** * Method testConnectionInsets is testing connectionInsets * @see org.jhotdraw.contrib.TriangleFigure#connectionInsets() */ // JUnitDoclet end javadoc_method connectionInsets() public void testConnectionInsets() throws Exception { // JUnitDoclet begin method connectionInsets // JUnitDoclet end method connectionInsets } // JUnitDoclet begin javadoc_method containsPoint() /** * Method testContainsPoint is testing containsPoint * @see org.jhotdraw.contrib.TriangleFigure#containsPoint(int, int) */ // JUnitDoclet end javadoc_method containsPoint() public void testContainsPoint() throws Exception { // JUnitDoclet begin method containsPoint for (int yy = 0; yy <= 10; yy++) { for (int xx = 0; xx <= 10; xx++) { assertEquals(CONTAINS_SAMPLES[yy][xx], trianglefigure.containsPoint(xx, yy)); } } // also try some definitely out of bounds points assertFalse(trianglefigure.containsPoint(10, 15)); assertFalse(trianglefigure.containsPoint(15, 15)); assertFalse(trianglefigure.containsPoint(15, 10)); assertFalse(trianglefigure.containsPoint(-15, -15)); assertFalse(trianglefigure.containsPoint(-1, -1)); // JUnitDoclet end method containsPoint } // JUnitDoclet begin javadoc_method center() /** * Method testCenter is testing center * @see org.jhotdraw.contrib.TriangleFigure#center() */ // JUnitDoclet end javadoc_method center() public void testCenter() throws Exception { // JUnitDoclet begin method center // JUnitDoclet end method center } // JUnitDoclet begin javadoc_method chop() /** * Method testChop is testing chop * @see org.jhotdraw.contrib.TriangleFigure#chop(java.awt.Point) */ // JUnitDoclet end javadoc_method chop() public void testChop() throws Exception { // JUnitDoclet begin method chop // JUnitDoclet end method chop } // JUnitDoclet begin javadoc_method clone() /** * Method testClone is testing clone * @see org.jhotdraw.contrib.TriangleFigure#clone() */ // JUnitDoclet end javadoc_method clone() public void testClone() throws Exception { // JUnitDoclet begin method clone // JUnitDoclet end method clone } // JUnitDoclet begin javadoc_method getRotationAngle() /** * Method testGetRotationAngle is testing getRotationAngle * @see org.jhotdraw.contrib.TriangleFigure#getRotationAngle() */ // JUnitDoclet end javadoc_method getRotationAngle() public void testGetRotationAngle() throws Exception { // JUnitDoclet begin method getRotationAngle // JUnitDoclet end method getRotationAngle } // JUnitDoclet begin javadoc_method write() /** * Method testWrite is testing write * @see org.jhotdraw.contrib.TriangleFigure#write(org.jhotdraw.util.StorableOutput) */ // JUnitDoclet end javadoc_method write() public void testWrite() throws Exception { // JUnitDoclet begin method write // JUnitDoclet end method write } // JUnitDoclet begin javadoc_method read() /** * Method testRead is testing read * @see org.jhotdraw.contrib.TriangleFigure#read(org.jhotdraw.util.StorableInput) */ // JUnitDoclet end javadoc_method read() public void testRead() throws Exception { // JUnitDoclet begin method read // JUnitDoclet end method read } // JUnitDoclet begin javadoc_method testVault /** * JUnitDoclet moves marker to this method, if there is not match * for them in the regenerated code and if the marker is not empty. * This way, no test gets lost when regenerating after renaming. * <b>Method testVault is supposed to be empty.</b> */ // JUnitDoclet end javadoc_method testVault public void testVault() throws Exception { // JUnitDoclet begin method testcase.testVault // JUnitDoclet end method testcase.testVault } protected static final boolean[][] CONTAINS_SAMPLES = { { false, false, false, false, false, false, false, false, false, false, false }, { false, false, false, false, false, true , false, false, false, false, false }, { false, false, false, false, true , true , false, false, false, false, false }, { false, false, false, false, true , true , true , false, false, false, false }, { false, false, false, true , true , true , true , false, false, false, false }, { false, false, false, true , true , true , true , true , false, false, false }, { false, false, true , true , true , true , true , true , false, false, false }, { false, false, true , true , true , true , true , true , true , false, false }, { false, true , true , true , true , true , true , true , true , false, false }, { false, true , true , true , true , true , true , true , true , true , false }, { false, false, false, false, false, false, false, false, false, false, false }}; }