Thread: [Picross-commit] SF.net SVN: picross: [64] trunk (Page 2)
Status: Pre-Alpha
Brought to you by:
yvan_norsa
From: <yva...@us...> - 2008-04-24 13:36:01
|
Revision: 64 http://picross.svn.sourceforge.net/picross/?rev=64&view=rev Author: yvan_norsa Date: 2008-04-24 06:36:06 -0700 (Thu, 24 Apr 2008) Log Message: ----------- support for more XBM files Modified Paths: -------------- trunk/data/contents.txt trunk/src/picross/game/simple/XBMModel.java trunk/src/picross/menus/LevelMenuUI.java Added Paths: ----------- trunk/data/star.xbm Modified: trunk/data/contents.txt =================================================================== --- trunk/data/contents.txt 2008-04-23 19:13:48 UTC (rev 63) +++ trunk/data/contents.txt 2008-04-24 13:36:06 UTC (rev 64) @@ -3,3 +3,4 @@ bunny.xbm : 16x16 halloween.xbm : 16x16 squares.xbm : 16x16 +star.xbm : 16x16 Added: trunk/data/star.xbm =================================================================== --- trunk/data/star.xbm (rev 0) +++ trunk/data/star.xbm 2008-04-24 13:36:06 UTC (rev 64) @@ -0,0 +1,7 @@ +#define group_width 16 +#define group_height 16 +static char group_bits[] = { + 0x0, 0x0, 0x80, 0x1, 0x80, 0x1, 0xc0, 0x3, + 0xc0, 0x3, 0xff, 0xff, 0xfe, 0x7f, 0xfc, 0x3f, + 0xf8, 0x1f, 0xf0, 0xf, 0xf0, 0xf, 0xf8, 0x1f, + 0x78, 0x1e, 0x3c, 0x3c, 0xc, 0x30, 0x0, 0x0}; Modified: trunk/src/picross/game/simple/XBMModel.java =================================================================== --- trunk/src/picross/game/simple/XBMModel.java 2008-04-23 19:13:48 UTC (rev 63) +++ trunk/src/picross/game/simple/XBMModel.java 2008-04-24 13:36:06 UTC (rev 64) @@ -148,12 +148,30 @@ String[] values = line.split(XBMModel.VALUE_SEPARATOR); for (int i = 0; i < values.length; i++) { - //XBMModel.log.debug("values[" + i + "] = " - //+ values[i]); + if (values[i].contains(XBMModel.HEX_LEADING)) { + values[i] = values[i].trim(); - if (values[i].contains(XBMModel.HEX_LEADING)) { + //XBMModel.log.debug("values[" + i + "] = " + // + values[i]); + + if ((values[i].length() + < XBMModel.VALUE_END_POS) + || !Character + .isLetterOrDigit(values[i] + .charAt(XBMModel + .VALUE_END_POS + - 1))) { + values[i] = values[i] + .substring(0, + XBMModel.VALUE_BEGINNING_POS) + + 0 + + values[i] + .substring(XBMModel + .VALUE_BEGINNING_POS); + } + String byteStr = - values[i].trim() + values[i] .substring(XBMModel.VALUE_BEGINNING_POS, XBMModel.VALUE_END_POS); byteValues.add(byteStr); Modified: trunk/src/picross/menus/LevelMenuUI.java =================================================================== --- trunk/src/picross/menus/LevelMenuUI.java 2008-04-23 19:13:48 UTC (rev 63) +++ trunk/src/picross/menus/LevelMenuUI.java 2008-04-24 13:36:06 UTC (rev 64) @@ -90,7 +90,7 @@ void displayLevels(SimpleListener listener, List<String> levels) { this.removeAll(); - int x = 150; + int x = 50; int y = 150; for (String level : levels) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2008-04-30 13:47:45
|
Revision: 72 http://picross.svn.sourceforge.net/picross/?rev=72&view=rev Author: yvan_norsa Date: 2008-04-30 06:47:52 -0700 (Wed, 30 Apr 2008) Log Message: ----------- unit tests Modified Paths: -------------- trunk/build.xml trunk/src/picross/tests/AbstractPicrossGridTest.java Added Paths: ----------- trunk/lib/testsHelper.jar trunk/src/picross/game/random/tests/ trunk/src/picross/game/random/tests/RandomPicrossModelTest.java trunk/src/picross/game/simple/tests/ trunk/src/picross/game/simple/tests/XBMModelTest.java trunk/src/picross/grid/tests/BoxTest.java trunk/src/picross/grid/tests/CompletedHintsTest.java trunk/src/picross/grid/tests/FillCommandTest.java trunk/src/picross/grid/tests/GridModelTest.java trunk/src/picross/grid/tests/PaintCommandTest.java Removed Paths: ------------- trunk/src/picross/game/random/RandomPicrossModelTest.java trunk/src/picross/game/simple/XBMModelTest.java trunk/src/picross/grid/BoxTest.java trunk/src/picross/grid/CompletedHintsTest.java trunk/src/picross/grid/FillCommandTest.java trunk/src/picross/grid/GridModelTest.java trunk/src/picross/grid/PaintCommandTest.java Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2008-04-29 09:32:57 UTC (rev 71) +++ trunk/build.xml 2008-04-30 13:47:52 UTC (rev 72) @@ -29,6 +29,8 @@ value="${lib.dir}/mmvcs.jar" /> <property name="simpleButton.jar" value="${lib.dir}/simpleButton.jar" /> + <property name="testsHelper.jar" + value="${lib.dir}/testsHelper.jar" /> <target name="-init" depends="-setmode"> @@ -65,6 +67,7 @@ <pathelement location="${log4j.jar}" /> <pathelement location="${mmvcs.jar}" /> <pathelement location="${simpleButton.jar}" /> + <pathelement location="${testsHelper.jar}" /> </path> <target name="compile" Added: trunk/lib/testsHelper.jar =================================================================== (Binary files differ) Property changes on: trunk/lib/testsHelper.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Deleted: trunk/src/picross/game/random/RandomPicrossModelTest.java =================================================================== --- trunk/src/picross/game/random/RandomPicrossModelTest.java 2008-04-29 09:32:57 UTC (rev 71) +++ trunk/src/picross/game/random/RandomPicrossModelTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -1,59 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2007 - * - * This software is governed by the CeCILL license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL license and that you accept its terms. - */ - - -package picross.game.random; - -import org.apache.log4j.PropertyConfigurator; - -import picross.PicrossGrid; - -import picross.tests.AbstractPicrossGridTest; - -/** - * Test class for the random model. - * - * @author Y. Norsa - */ -public class RandomPicrossModelTest extends AbstractPicrossGridTest { - /** Static block. */ - static { - PropertyConfigurator.configure("log4j.properties"); - } - - /*** Overloaded method from the class AbstractPicrossGridTest ***/ - - /** {@inheritDoc} */ - protected PicrossGrid getPicrossGrid() { - return new RandomPicrossModel(); - } -} Copied: trunk/src/picross/game/random/tests/RandomPicrossModelTest.java (from rev 63, trunk/src/picross/game/random/RandomPicrossModelTest.java) =================================================================== --- trunk/src/picross/game/random/tests/RandomPicrossModelTest.java (rev 0) +++ trunk/src/picross/game/random/tests/RandomPicrossModelTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -0,0 +1,66 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2008 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.game.random.tests; + +import fr.cle.tests.TestsHelper; + +import org.apache.log4j.PropertyConfigurator; + +import org.junit.Test; + +import picross.PicrossGrid; + +import picross.tests.AbstractPicrossGridTest; + +/** + * Test class for the random model. + * + * @author Y. Norsa + */ +public class RandomPicrossModelTest extends AbstractPicrossGridTest { + /** Static block. */ + static { + PropertyConfigurator.configure("log4j.properties"); + } + + /*** Overloaded method from the class AbstractPicrossGridTest ***/ + + /** {@inheritDoc} */ + @Override + protected PicrossGrid getPicrossGrid() throws Throwable { + //return new RandomPicrossModel(); + + return (PicrossGrid) TestsHelper.getInstance("picross.game.random.RandomPicrossModel"); + } +} Deleted: trunk/src/picross/game/simple/XBMModelTest.java =================================================================== --- trunk/src/picross/game/simple/XBMModelTest.java 2008-04-29 09:32:57 UTC (rev 71) +++ trunk/src/picross/game/simple/XBMModelTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -1,99 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2007-2008 - * - * This software is governed by the CeCILL license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL license and that you accept its terms. - */ - - -package picross.game.simple; - -import java.io.ByteArrayInputStream; -import java.io.IOException; - -import org.apache.log4j.PropertyConfigurator; - -import org.junit.Assert; -import org.junit.Test; - -import picross.Picross; -import picross.PicrossGrid; - -import picross.tests.AbstractPicrossGridTest; - -/** - * Unit tests for XBMModel. - * - * @author Y. Norsa - */ -public final class XBMModelTest extends AbstractPicrossGridTest { - /*** Static field ***/ - - /** Valid XBM model. */ - private static PicrossGrid realModel; - - /*** Static initialisation block. Loads a valid XBM file. ***/ - static { - PropertyConfigurator.configure("log4j.properties"); - - try { - XBMModelTest.realModel = - new XBMModel(Picross.loadDataFile("asterix.xbm")); - } catch (IOException ioEx) { - throw new ExceptionInInitializerError(ioEx); - } catch (XBMException xbmEx) { - throw new ExceptionInInitializerError(xbmEx); - } - } - - /*** Method overloaded from the class AbstractPicrossGridTest ***/ - - /** {@inheritDoc} */ - protected PicrossGrid getPicrossGrid() { - return XBMModelTest.realModel; - } - - /** - * Tests the XBMModel constructor. - * - * @throws IOException if there is a problem with a stream loading - * @throws XBMException if a file isn't valid - */ - @Test - public void testXBMModel() throws IOException, XBMException { - try { - new XBMModel(null); - Assert.fail("Tried to load a null model"); - } catch (IllegalArgumentException argEx) { } - - try { - new XBMModel(new ByteArrayInputStream("".getBytes())); - Assert.fail("Empty file"); - } catch (XBMException xbmEx) { } - } -} Copied: trunk/src/picross/game/simple/tests/XBMModelTest.java (from rev 67, trunk/src/picross/game/simple/XBMModelTest.java) =================================================================== --- trunk/src/picross/game/simple/tests/XBMModelTest.java (rev 0) +++ trunk/src/picross/game/simple/tests/XBMModelTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -0,0 +1,124 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2008 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.game.simple.tests; + +import fr.cle.tests.TestsHelper; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; + +import org.apache.log4j.PropertyConfigurator; + +import org.junit.Assert; +import org.junit.Test; + +import picross.Picross; +import picross.PicrossException; +import picross.PicrossGrid; + +import picross.tests.AbstractPicrossGridTest; + +/** + * Unit tests for XBMModel. + * + * @author Y. Norsa + */ +public final class XBMModelTest extends AbstractPicrossGridTest { + /*** Static field ***/ + + /** Valid XBM model. */ + private static PicrossGrid realModel; + + /*** Static initialisation block. Loads a valid XBM file. ***/ + static { + PropertyConfigurator.configure("log4j.properties"); + + try { + XBMModelTest.realModel = + //new XBMModel(Picross.loadDataFile("asterix.xbm")); + XBMModelTest.newXBMModel(Picross.loadDataFile("asterix.xbm")); + } catch (IOException ioEx) { + throw new ExceptionInInitializerError(ioEx); + } catch (PicrossException xbmEx) { + throw new ExceptionInInitializerError(xbmEx); + } + } + + /*** Method overloaded from the class AbstractPicrossGridTest ***/ + + /** {@inheritDoc} */ + protected PicrossGrid getPicrossGrid() { + return XBMModelTest.realModel; + } + + /** + * Tests the XBMModel constructor. + * + * @throws IOException if there is a problem with a stream loading + * @throws XBMException if a file isn't valid + */ + @Test + public void testXBMModel() throws IOException, PicrossException { + try { + //new XBMModel(null); + XBMModelTest.newXBMModel(null); + Assert.fail("Tried to load a null model"); + } catch (IllegalArgumentException argEx) { } + + try { + //new XBMModel(new ByteArrayInputStream("".getBytes())); + XBMModelTest.newXBMModel(new ByteArrayInputStream("".getBytes())); + Assert.fail("Empty file"); + } catch (PicrossException xbmEx) { } + } + + private static PicrossGrid newXBMModel(InputStream in) throws IOException, PicrossException { + try { + return (PicrossGrid) TestsHelper.getInstance("picross.game.simple.XBMModel", in); + } catch (Throwable throwable) { + if (throwable instanceof IOException) { + throw (IOException) throwable; + } + + if (throwable instanceof PicrossException) { + throw (PicrossException) throwable; + } + + //if (throwable instanceof RuntimeException) { + throw (RuntimeException) throwable; + //} + } + } +} Deleted: trunk/src/picross/grid/BoxTest.java =================================================================== --- trunk/src/picross/grid/BoxTest.java 2008-04-29 09:32:57 UTC (rev 71) +++ trunk/src/picross/grid/BoxTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -1,156 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2007 - * - * This software is governed by the CeCILL license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL license and that you accept its terms. - */ - - -package picross.grid; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -/** - * @author Y. Norsa - */ -public class BoxTest { - /*** Constante ***/ - - /*** Champ statique ***/ - - /*** Champ ***/ - - private Box box = null; - - /*** Constructeur ***/ - - /** - * Constructeur. - */ - /* - BoxTest() { - } - */ - /*** M\xE9thode ***/ - - @Before - public void setUp() { - this.box = new Box(); - } - - @Test - public void testCheck() { - this.box.check(); - Assert.assertTrue("box unchecked", this.box.isChecked()); - } - - @Test - public void testCross() { - this.box.cross(); - Assert.assertTrue("box not crossed", this.box.isCrossed()); - } - - @Test - public void testEmpty() { - this.box.empty(); - Assert.assertTrue("box not empty", this.box.isEmpty()); - } - - @Test - public void testEquals() { - Assert.assertFalse("this.box = null", this.box.equals(null)); - Assert.assertTrue("box != box", this.box.equals(this.box)); - - this.box.check(); - - Box box2 = new Box(); - Assert.assertFalse("box = box2", this.box.equals(box2)); - - box2.check(); - - Assert.assertTrue("box != box2", this.box.equals(box2)); - } - - @Test - public void testgetIcon() { - Assert.assertNotNull("empty icon = null", this.box.getIcon()); - - this.box.check(); - Assert.assertNotNull("checked icon = null", this.box.getIcon()); - - this.box.cross(); - Assert.assertNotNull("crossed icon = null", this.box.getIcon()); - } - - @Test - public void testGetRolloverIcon() { - Assert.assertNotNull("rollover empty icon = null", - this.box.getRolloverIcon()); - - this.box.check(); - Assert.assertNotNull("rollover checked icon = null", - this.box.getRolloverIcon()); - - this.box.cross(); - Assert.assertNotNull("rollover crossed icon = null", - this.box.getRolloverIcon()); - } - - @Test - public void testIsChecked() { - this.box.check(); - - Assert.assertFalse("box crossed AND checked", this.box.isCrossed()); - Assert.assertFalse("box empty AND checked", this.box.isEmpty()); - } - - @Test - public void testIsCrossed() { - this.box.cross(); - - Assert.assertFalse("box checked AND crossed", this.box.isChecked()); - Assert.assertFalse("box empty AND crossed", this.box.isEmpty()); - } - - @Test - public void testIsEmpty() { - Assert.assertFalse("box checked AND empty", this.box.isChecked()); - Assert.assertFalse("box crossed AND empty", this.box.isCrossed()); - } - - @Test - public void testSetRect() { - try { - this.box.setRect(null); - Assert.fail("box.setRect(null)"); - } catch (IllegalArgumentException argEx) { } - } -} - Deleted: trunk/src/picross/grid/CompletedHintsTest.java =================================================================== --- trunk/src/picross/grid/CompletedHintsTest.java 2008-04-29 09:32:57 UTC (rev 71) +++ trunk/src/picross/grid/CompletedHintsTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -1,205 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2007 - * - * This software is governed by the CeCILL license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL license and that you accept its terms. - */ - - -package picross.grid; - -import java.util.List; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -/** - * @author Y. Norsa - */ -public class CompletedHintsTest { - /*** Constante ***/ - - /*** Champ statique ***/ - - /*** Champ ***/ - - CompletedHints hints = null; - - /*** Constructeur ***/ - - /** - * Constructeur. - */ - /* - CompletedHintsTest() { - } - */ - /*** M\xE9thode ***/ - - @Before - public void setUp() { - this.hints = new CompletedHints(10, 10, 10, 10); - } - - @Test - public void testCompletedHints() { - try { - new CompletedHints(-1, -1, -1, -1); - Assert.fail("colsHintsWidth = -1"); - } catch (IllegalArgumentException argEx) { } - - try { - new CompletedHints(0, -1, -1, -1); - Assert.fail("colsHintsWidth = 0"); - } catch (IllegalArgumentException argEx) { } - - try { - new CompletedHints(1, -1, -1, -1); - Assert.fail("colsHintsHeight = -1"); - } catch (IllegalArgumentException argEx) { } - - try { - new CompletedHints(1, 0, -1, -1); - Assert.fail("colsHintsHeight = 0"); - } catch (IllegalArgumentException argEx) { } - - try { - new CompletedHints(1, 1, -1, -1); - Assert.fail("rowsHintsWidth = -1"); - } catch (IllegalArgumentException argEx) { } - - try { - new CompletedHints(1, 1, 0, -1); - Assert.fail("rowsHintsWidth = 0"); - } catch (IllegalArgumentException argEx) { } - - try { - new CompletedHints(1, 1, 1, -1); - Assert.fail("rowsHintsHeight = -1"); - } catch (IllegalArgumentException argEx) { } - - try { - new CompletedHints(1, 1, 1, 0); - Assert.fail("rowsHintsHeight = 0"); - } catch (IllegalArgumentException argEx) { } - } - - @Test - public void testClearColHint() { - this.hints.setCompleteColHint(3, 4); - this.hints.clearColHint(3, 4); - Assert.assertFalse(this.hints.isColHintComplete(3, 4)); - } - - @Test - public void testClearRowHint() { - this.hints.setCompleteRowHint(8, 2); - this.hints.clearRowHint(8, 2); - Assert.assertFalse(this.hints.isRowHintComplete(8, 2)); - } - - @Test - public void testGetCompleteColHints() { - try { - this.hints.getCompleteColHints(-1); - Assert.fail("column = -1"); - } catch (IllegalArgumentException argEx) { } - - try { - this.hints.getCompleteColHints(42); - Assert.fail("column = 42"); - } catch (IllegalArgumentException argEx) { } - - List<Integer> complete = this.hints.getCompleteColHints(4); - Assert.assertNotNull("complete = null", complete); - int size = complete.size(); - Assert.assertTrue("size = " + size, (size == 0)); - - this.hints.setCompleteColHint(4, 0); - this.hints.setCompleteColHint(4, 9); - - complete = this.hints.getCompleteColHints(4); - Assert.assertNotNull("complete = null", complete); - size = complete.size(); - Assert.assertTrue("size = " + size, (size == 2)); - - int nb1 = complete.get(0); - Assert.assertTrue("nb1 = " + nb1, (nb1 == 0)); - - int nb2 = complete.get(1); - Assert.assertTrue("nb2 = " + nb2, (nb2 == 9)); - } - - @Test - public void testGetCompleteRowHints() { - try { - this.hints.getCompleteRowHints(-1); - Assert.fail("row = -1"); - } catch (IllegalArgumentException argEx) { } - - try { - this.hints.getCompleteRowHints(42); - Assert.fail("row = 42"); - } catch (IllegalArgumentException argEx) { } - - List<Integer> complete = this.hints.getCompleteRowHints(9); - Assert.assertNotNull("complete = null", complete); - int size = complete.size(); - Assert.assertTrue("size = " + size, (size == 0)); - - this.hints.setCompleteRowHint(9, 3); - this.hints.setCompleteRowHint(9, 6); - - complete = this.hints.getCompleteRowHints(9); - Assert.assertNotNull("complete = null", complete); - size = complete.size(); - Assert.assertTrue("size = " + size, (size == 2)); - - int nb1 = complete.get(0); - Assert.assertTrue("nb1 = " + nb1, (nb1 == 3)); - - int nb2 = complete.get(1); - Assert.assertTrue("nb2 = " + nb2, (nb2 == 6)); - } - - @Test - public void testIsColHintCompleteAndSetCompleteColHint() { - Assert.assertFalse(this.hints.isColHintComplete(0, 0)); - this.hints.setCompleteColHint(0, 0); - Assert.assertTrue(this.hints.isColHintComplete(0, 0)); - } - - @Test - public void testIsRowHintCompleteAndSetCompleteRowHint() { - Assert.assertFalse(this.hints.isRowHintComplete(5, 5)); - this.hints.setCompleteRowHint(5, 5); - Assert.assertTrue(this.hints.isRowHintComplete(5, 5)); - } -} - Deleted: trunk/src/picross/grid/FillCommandTest.java =================================================================== --- trunk/src/picross/grid/FillCommandTest.java 2008-04-29 09:32:57 UTC (rev 71) +++ trunk/src/picross/grid/FillCommandTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -1,80 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2007 - * - * This software is governed by the CeCILL license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL license and that you accept its terms. - */ - - -package picross.grid; - -import org.junit.Assert; -import org.junit.Test; - -/** - * @author Y. Norsa - */ -public class FillCommandTest { - /*** Constante ***/ - - /*** Champ statique ***/ - - /*** Champ ***/ - - /*** Constructeur ***/ - - /** - * Constructeur. - */ - /* - FillCommandTest() { - } - */ - /*** M\xE9thode ***/ - - @Test - public void testFillCommand() { - try { - new FillCommand(-1, -1, GridAction.UNKNOWN); - Assert.fail("row = -1"); - } catch (IllegalArgumentException argEx) { } - - try { - new FillCommand(0, -1, GridAction.UNKNOWN); - Assert.fail("column = -1"); - } catch (IllegalArgumentException argEx) { } - - try { - new FillCommand(0, 0, GridAction.UNKNOWN); - Assert.fail("UNKNOWN type"); - } catch (IllegalArgumentException argEx) { } - - new FillCommand(0, 0, GridAction.CHECK); - } -} - Deleted: trunk/src/picross/grid/GridModelTest.java =================================================================== --- trunk/src/picross/grid/GridModelTest.java 2008-04-29 09:32:57 UTC (rev 71) +++ trunk/src/picross/grid/GridModelTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -1,110 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2007 - * - * This software is governed by the CeCILL license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL license and that you accept its terms. - */ - - -package picross.grid; - -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import picross.grid.tests.IGridMediatorStub; - -/** - * @author Y. Norsa - */ -public class GridModelTest { - /*** Constante ***/ - - /*** Champ statique ***/ - - /*** Champ ***/ - - private GridModel model = null; - - /*** Constructeur ***/ - - /** - * Constructeur. - */ - /* - GridModelTest() { - }*/ - - /*** M\xE9thode ***/ - - @Before - public void setUp() { - this.model = new GridModel(new IGridMediatorStub(), new boolean[3][5]); - } - - @Test - public void testGridModel() { - try { - new GridModel(null, null); - Assert.fail("mediator = null"); - } catch (IllegalArgumentException argEx) { } - - IGridMediator stub = new IGridMediatorStub(); - - try { - new GridModel(stub, null); - Assert.fail("data = null"); - } catch (IllegalArgumentException argEx) { } - - try { - new GridModel(stub, new boolean[0][0]); - Assert.fail("empty data"); - } catch (IllegalArgumentException argEx) { } - - try { - new GridModel(stub, new boolean[1][0]); - Assert.fail("empty data"); - } catch (IllegalArgumentException argEx) { } - } - - @Test - public void testActOnBox() { - try { - this.model.actOnBox(-1, -1, GridAction.CHECK); - Assert.fail("row = -1"); - } catch (IllegalArgumentException argEx) { } - - try { - this.model.actOnBox(0, -1, GridAction.CHECK); - Assert.fail("column = -1"); - } catch (IllegalArgumentException argEx) { } - - this.model.actOnBox(0, 0, GridAction.CHECK); - } -} - Deleted: trunk/src/picross/grid/PaintCommandTest.java =================================================================== --- trunk/src/picross/grid/PaintCommandTest.java 2008-04-29 09:32:57 UTC (rev 71) +++ trunk/src/picross/grid/PaintCommandTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -1,58 +0,0 @@ -/* - * $Id$ - * - * Copyright (c) 2007 - * - * This software is governed by the CeCILL license under French law and - * abiding by the rules of distribution of free software. You can use, - * modify and/ or redistribute the software under the terms of the CeCILL - * license as circulated by CEA, CNRS and INRIA at the following URL - * "http://www.cecill.info". - * - * As a counterpart to the access to the source code and rights to copy, - * modify and redistribute granted by the license, users are provided only - * with a limited warranty and the software's author, the holder of the - * economic rights, and the successive licensors have only limited - * liability. - * - * In this respect, the user's attention is drawn to the risks associated - * with loading, using, modifying and/or developing or reproducing the - * software by the user in light of its specific status of free software, - * that may mean that it is complicated to manipulate, and that also - * therefore means that it is reserved for developers and experienced - * professionals having in-depth computer knowledge. Users are therefore - * encouraged to load and test the software's suitability as regards their - * requirements in conditions enabling the security of their systems and/or - * data to be ensured and, more generally, to use and operate it in the - * same conditions as regards security. - * - * The fact that you are presently reading this means that you have had - * knowledge of the CeCILL license and that you accept its terms. - */ - - -package picross.grid; - -import org.junit.Assert; -import org.junit.Test; - -/** - * @author Y. Norsa - */ -public class PaintCommandTest { - @Test - public void testPaintCommand() { - try { - new PaintCommand(-1, -1); - Assert.fail("row = -1"); - } catch (IllegalArgumentException argEx) { } - - try { - new PaintCommand(0, -1); - Assert.fail("column = -1"); - } catch (IllegalArgumentException argEx) { } - - new PaintCommand(0, 0); - } -} - Copied: trunk/src/picross/grid/tests/BoxTest.java (from rev 63, trunk/src/picross/grid/BoxTest.java) =================================================================== --- trunk/src/picross/grid/tests/BoxTest.java (rev 0) +++ trunk/src/picross/grid/tests/BoxTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -0,0 +1,192 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2008 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.grid.tests; + +import fr.cle.tests.TestsHelper; + +import javax.swing.ImageIcon; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @author Y. Norsa + */ +public class BoxTest { + /*** Constante ***/ + + /*** Champ statique ***/ + + /*** Champ ***/ + + private Object box = null; + + /*** Constructeur ***/ + + /** + * Constructeur. + */ + /* + BoxTest() { + } + */ + /*** M\xE9thode ***/ + + @Before + public void setUp() throws Throwable { + this.box = BoxTest.getBox(); + } + + @Test + public void testCheck() throws Throwable { + BoxTest.checkBox(this.box); + Assert.assertTrue("box unchecked", BoxTest.isBoxChecked(this.box)); + } + + @Test + public void testCross() throws Throwable { + BoxTest.crossBox(this.box); + Assert.assertTrue("box not crossed", BoxTest.isBoxCrossed(this.box)); + } + + @Test + public void testEmpty() throws Throwable { + TestsHelper.invoke(this.box, "empty"); + Assert.assertTrue("box not empty", BoxTest.isBoxEmpty(this.box)); + } + + @Test + public void testEquals() throws Throwable { + Assert.assertFalse("this.box = null", this.box.equals(null)); + Assert.assertTrue("box != box", this.box.equals(this.box)); + + BoxTest.checkBox(this.box); + + Object box2 = BoxTest.getBox(); + Assert.assertFalse("box = box2", this.box.equals(box2)); + + BoxTest.checkBox(box2); + + Assert.assertTrue("box != box2", this.box.equals(box2)); + } + + @Test + public void testgetIcon() throws Throwable { + Assert.assertNotNull("empty icon = null", BoxTest.getBoxIcon(this.box)); + + BoxTest.checkBox(this.box); + Assert.assertNotNull("checked icon = null", BoxTest.getBoxIcon(this.box)); + + BoxTest.crossBox(this.box); + Assert.assertNotNull("crossed icon = null", BoxTest.getBoxIcon(this.box)); + } + + @Test + public void testGetRolloverIcon() throws Throwable { + Assert.assertNotNull("rollover empty icon = null", + BoxTest.getBoxRolloverIcon(this.box)); + + BoxTest.checkBox(this.box); + Assert.assertNotNull("rollover checked icon = null", + BoxTest.getBoxRolloverIcon(this.box)); + + BoxTest.crossBox(this.box); + Assert.assertNotNull("rollover crossed icon = null", + BoxTest.getBoxRolloverIcon(this.box)); + } + + @Test + public void testIsChecked() throws Throwable { + BoxTest.checkBox(this.box); + + Assert.assertFalse("box crossed AND checked", BoxTest.isBoxCrossed(this.box)); + Assert.assertFalse("box empty AND checked", BoxTest.isBoxEmpty(this.box)); + } + + @Test + public void testIsCrossed() throws Throwable { + BoxTest.crossBox(this.box); + + Assert.assertFalse("box checked AND crossed", BoxTest.isBoxChecked(this.box)); + Assert.assertFalse("box empty AND crossed", BoxTest.isBoxEmpty(this.box)); + } + + @Test + public void testIsEmpty() throws Throwable { + Assert.assertFalse("box checked AND empty", BoxTest.isBoxChecked(this.box)); + Assert.assertFalse("box crossed AND empty", BoxTest.isBoxCrossed(this.box)); + } + + @Test + public void testSetRect() throws Throwable { + try { + TestsHelper.invoke(this.box, "setRect", null); + Assert.fail("box.setRect(null)"); + } catch (IllegalArgumentException argEx) { } + } + + private static Object getBox() throws Throwable { + return TestsHelper.getInstance("picross.grid.Box"); + } + + private static void checkBox(Object box) throws Throwable { + TestsHelper.invoke(box, "check"); + } + + private static void crossBox(Object box) throws Throwable { + TestsHelper.invoke(box, "cross"); + } + + private static ImageIcon getBoxIcon(Object box) throws Throwable { + return (ImageIcon) TestsHelper.invoke(box, "getIcon"); + } + + private static ImageIcon getBoxRolloverIcon(Object box) throws Throwable { + return (ImageIcon) TestsHelper.invoke(box, "getRolloverIcon"); + } + + private static boolean isBoxCrossed(Object box) throws Throwable { + return ((Boolean) TestsHelper.invoke(box, "isCrossed")).booleanValue(); + } + + private static boolean isBoxEmpty(Object box) throws Throwable { + return ((Boolean) TestsHelper.invoke(box, "isEmpty")).booleanValue(); + } + + private static boolean isBoxChecked(Object box) throws Throwable { + return ((Boolean) TestsHelper.invoke(box, "isChecked")).booleanValue(); + } +} + Copied: trunk/src/picross/grid/tests/CompletedHintsTest.java (from rev 63, trunk/src/picross/grid/CompletedHintsTest.java) =================================================================== --- trunk/src/picross/grid/tests/CompletedHintsTest.java (rev 0) +++ trunk/src/picross/grid/tests/CompletedHintsTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -0,0 +1,235 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2008 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.grid.tests; + +import fr.cle.tests.TestsHelper; + +import java.util.List; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * @author Y. Norsa + */ +public class CompletedHintsTest { + /*** Constante ***/ + + /*** Champ statique ***/ + + /*** Champ ***/ + + Object hints = null; + + /*** Constructeur ***/ + + /** + * Constructeur. + */ + /* + CompletedHintsTest() { + } + */ + /*** M\xE9thode ***/ + + @Before + public void setUp() throws Throwable { + this.hints = CompletedHintsTest.getCompletedHints(10, 10, 10, 10); + } + + @Test + public void testCompletedHints() throws Throwable { + try { + CompletedHintsTest.getCompletedHints(-1, -1, -1, -1); + Assert.fail("colsHintsWidth = -1"); + } catch (IllegalArgumentException argEx) { } + + try { + CompletedHintsTest.getCompletedHints(0, -1, -1, -1); + Assert.fail("colsHintsWidth = 0"); + } catch (IllegalArgumentException argEx) { } + + try { + CompletedHintsTest.getCompletedHints(1, -1, -1, -1); + Assert.fail("colsHintsHeight = -1"); + } catch (IllegalArgumentException argEx) { } + + try { + CompletedHintsTest.getCompletedHints(1, 0, -1, -1); + Assert.fail("colsHintsHeight = 0"); + } catch (IllegalArgumentException argEx) { } + + try { + CompletedHintsTest.getCompletedHints(1, 1, -1, -1); + Assert.fail("rowsHintsWidth = -1"); + } catch (IllegalArgumentException argEx) { } + + try { + CompletedHintsTest.getCompletedHints(1, 1, 0, -1); + Assert.fail("rowsHintsWidth = 0"); + } catch (IllegalArgumentException argEx) { } + + try { + CompletedHintsTest.getCompletedHints(1, 1, 1, -1); + Assert.fail("rowsHintsHeight = -1"); + } catch (IllegalArgumentException argEx) { } + + try { + CompletedHintsTest.getCompletedHints(1, 1, 1, 0); + Assert.fail("rowsHintsHeight = 0"); + } catch (IllegalArgumentException argEx) { } + } + + @Test + public void testClearColHint() throws Throwable { + CompletedHintsTest.setCompleteColHint(this.hints, 3, 4); + TestsHelper.invoke(this.hints, "clearColHint", 3, 4); + Assert.assertFalse(CompletedHintsTest.isColHintComplete(this.hints, 3, 4)); + } + + @Test + public void testClearRowHint() throws Throwable { + CompletedHintsTest.setCompleteRowHint(this.hints, 8, 2); + TestsHelper.invoke(this.hints, "clearRowHint", 8, 2); + Assert.assertFalse(CompletedHintsTest.isRowHintComplete(this.hints, 8, 2)); + } + + @Test + public void testGetCompleteColHints() throws Throwable { + try { + CompletedHintsTest.getCompleteColHints(this.hints, -1); + Assert.fail("column = -1"); + } catch (IllegalArgumentException argEx) { } + + try { + CompletedHintsTest.getCompleteColHints(this.hints, 42); + Assert.fail("column = 42"); + } catch (IllegalArgumentException argEx) { } + + List<Integer> complete = CompletedHintsTest.getCompleteColHints(this.hints, 4); + Assert.assertNotNull("complete = null", complete); + int size = complete.size(); + Assert.assertTrue("size = " + size, (size == 0)); + + CompletedHintsTest.setCompleteColHint(this.hints, 4, 0); + CompletedHintsTest.setCompleteColHint(this.hints, 4, 9); + + complete = CompletedHintsTest.getCompleteColHints(this.hints, 4); + Assert.assertNotNull("complete = null", complete); + size = complete.size(); + Assert.assertTrue("size = " + size, (size == 2)); + + int nb1 = complete.get(0); + Assert.assertTrue("nb1 = " + nb1, (nb1 == 0)); + + int nb2 = complete.get(1); + Assert.assertTrue("nb2 = " + nb2, (nb2 == 9)); + } + + @Test + public void testGetCompleteRowHints() throws Throwable { + try { + CompletedHintsTest.getCompleteRowHints(this.hints, -1); + Assert.fail("row = -1"); + } catch (IllegalArgumentException argEx) { } + + try { + CompletedHintsTest.getCompleteRowHints(this.hints, 42); + Assert.fail("row = 42"); + } catch (IllegalArgumentException argEx) { } + + List<Integer> complete = CompletedHintsTest.getCompleteRowHints(this.hints, 9); + Assert.assertNotNull("complete = null", complete); + int size = complete.size(); + Assert.assertTrue("size = " + size, (size == 0)); + + CompletedHintsTest.setCompleteRowHint(this.hints, 9, 3); + CompletedHintsTest.setCompleteRowHint(this.hints, 9, 6); + + complete = CompletedHintsTest.getCompleteRowHints(this.hints, 9); + Assert.assertNotNull("complete = null", complete); + size = complete.size(); + Assert.assertTrue("size = " + size, (size == 2)); + + int nb1 = complete.get(0); + Assert.assertTrue("nb1 = " + nb1, (nb1 == 3)); + + int nb2 = complete.get(1); + Assert.assertTrue("nb2 = " + nb2, (nb2 == 6)); + } + + @Test + public void testIsColHintCompleteAndSetCompleteColHint() throws Throwable { + Assert.assertFalse(CompletedHintsTest.isColHintComplete(this.hints, 0, 0)); + CompletedHintsTest.setCompleteColHint(this.hints, 0, 0); + Assert.assertTrue(CompletedHintsTest.isColHintComplete(this.hints, 0, 0)); + } + + @Test + public void testIsRowHintCompleteAndSetCompleteRowHint() throws Throwable { + Assert.assertFalse(CompletedHintsTest.isRowHintComplete(this.hints, 5, 5)); + CompletedHintsTest.setCompleteRowHint(this.hints, 5, 5); + Assert.assertTrue(CompletedHintsTest.isRowHintComplete(this.hints, 5, 5)); + } + + private static Object getCompletedHints(int colHintsWidth, int colHintsHeight, int rowHintsWidth, int rowHintsHeight) throws Throwable { + return TestsHelper.getInstance("picross.grid.CompletedHints", colHintsWidth, colHintsHeight, rowHintsWidth, rowHintsHeight); + } + + private static void setCompleteColHint(Object hints, int col, int index) throws Throwable { + TestsHelper.invoke(hints, "setCompleteColHint", col, index); + } + + private static boolean isColHintComplete(Object hints, int x, int y) throws Throwable { + return ((Boolean) TestsHelper.invoke(hints, "isColHintComplete", x, y)).booleanValue(); + } + + private static void setCompleteRowHint(Object hints, int row, int index) throws Throwable { + TestsHelper.invoke(hints, "setCompleteRowHint", row, index); + } + + private static boolean isRowHintComplete(Object hints, int x, int y) throws Throwable { + return ((Boolean) TestsHelper.invoke(hints, "isRowHintComplete", x, y)).booleanValue(); + } + + private static List<Integer> getCompleteColHints(Object hints, int column) throws Throwable { + return (List<Integer>) TestsHelper.invoke(hints, "getCompleteColHints", column); + } + + private static List<Integer> getCompleteRowHints(Object hints, int row) throws Throwable { + return (List<Integer>) TestsHelper.invoke(hints, "getCompleteRowHints", row); + } +} + Copied: trunk/src/picross/grid/tests/FillCommandTest.java (from rev 63, trunk/src/picross/grid/FillCommandTest.java) =================================================================== --- trunk/src/picross/grid/tests/FillCommandTest.java (rev 0) +++ trunk/src/picross/grid/tests/FillCommandTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -0,0 +1,82 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2008 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.grid.tests; + +import org.junit.Assert; +import org.junit.Test; + +/** + * @author Y. Norsa + */ +public class FillCommandTest { + /*** Constante ***/ + + /*** Champ statique ***/ + + /*** Champ ***/ + + /*** Constructeur ***/ + + /** + * Constructeur. + */ + /* + FillCommandTest() { + } + */ + /*** M\xE9thode ***/ + + @Test + public void testFillCommand() { + /* try { + new FillCommand(-1, -1, GridAction.UNKNOWN); + Assert.fail("row = -1"); + } catch (IllegalArgumentException argEx) { } + + try { + new FillCommand(0, -1, GridAction.UNKNOWN); + Assert.fail("column = -1"); + } catch (IllegalArgumentException argEx) { } + + try { + new FillCommand(0, 0, GridAction.UNKNOWN); + Assert.fail("UNKNOWN type"); + } catch (IllegalArgumentException argEx) { } + + new FillCommand(0, 0, GridAction.CHECK); + */ + } + +} + Copied: trunk/src/picross/grid/tests/GridModelTest.java (from rev 63, trunk/src/picross/grid/GridModelTest.java) =================================================================== --- trunk/src/picross/grid/tests/GridModelTest.java (rev 0) +++ trunk/src/picross/grid/tests/GridModelTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -0,0 +1,122 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2008 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.grid.tests; + +import fr.cle.tests.TestsHelper; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +import picross.grid.IGridMediator; + +/** + * @author Y. Norsa + */ +public class GridModelTest { + /*** Constante ***/ + + /*** Champ statique ***/ + + /*** Champ ***/ + + private Object model = null; + + /*** Constructeur ***/ + + /** + * Constructeur. + */ + /* + GridModelTest() { + }*/ + + /*** M\xE9thode ***/ + + @Before + public void setUp() throws Throwable { + this.model = GridModelTest.getGridModel(new IGridMediatorStub(), new boolean[3][5]); + } + + @Test + public void testGridModel() throws Throwable { + try { + GridModelTest.getGridModel(null, null); + Assert.fail("mediator = null"); + } catch (IllegalArgumentException argEx) { } + + IGridMediator stub = new IGridMediatorStub(); + + try { + GridModelTest.getGridModel(stub, null); + Assert.fail("data = null"); + } catch (IllegalArgumentException argEx) { } + + try { + GridModelTest.getGridModel(stub, new boolean[0][0]); + Assert.fail("empty data"); + } catch (IllegalArgumentException argEx) { } + + try { + GridModelTest.getGridModel(stub, new boolean[1][0]); + Assert.fail("empty data"); + } catch (IllegalArgumentException argEx) { } + } + + /* + @Test + public void testActOnBox() { + try { + GridModelTest.actOnBox(this.model, -1, -1, GridAction.CHECK); + Assert.fail("row = -1"); + } catch (IllegalArgumentException argEx) { } + + try { + GridModelTest.actOnBox(this.model, 0, -1, GridAction.CHECK); + Assert.fail("column = -1"); + } catch (IllegalArgumentException argEx) { } + + GridModelTest.actOnBox(this.model, 0, 0, GridAction.CHECK); + } + */ + private static Object getGridModel(IGridMediator mediator, boolean[][] data) throws Throwable { + return TestsHelper.getInstance("picross.grid.GridModel", mediator, data); + } + /* + private static void actOnBox(Object gridModel, int row, int column, Object action) { + TestsHelper.invoke(gridModel, "actOnBox", row, colum, action); + } + */ +} + Copied: trunk/src/picross/grid/tests/PaintCommandTest.java (from rev 63, trunk/src/picross/grid/PaintCommandTest.java) =================================================================== --- trunk/src/picross/grid/tests/PaintCommandTest.java (rev 0) +++ trunk/src/picross/grid/tests/PaintCommandTest.java 2008-04-30 13:47:52 UTC (rev 72) @@ -0,0 +1,64 @@ +/* + * $Id$ + * + * Copyright (c) 2007-2008 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only l... [truncated message content] |
From: <yva...@us...> - 2008-05-07 09:34:48
|
Revision: 78 http://picross.svn.sourceforge.net/picross/?rev=78&view=rev Author: yvan_norsa Date: 2008-05-07 02:34:52 -0700 (Wed, 07 May 2008) Log Message: ----------- 'back button'; scroll for level selection Modified Paths: -------------- trunk/src/picross/game/simple/LevelMenuController.java trunk/src/picross/game/simple/LevelMenuMediator.java trunk/src/picross/game/simple/LevelMenuUI.java trunk/src/picross/menus/MenuController.java trunk/src/picross/menus/MenuUI.java Added Paths: ----------- trunk/images/en/button-back.png trunk/images/fr/button-back.png trunk/src/picross/game/simple/SizesListCommand.java Added: trunk/images/en/button-back.png =================================================================== (Binary files differ) Property changes on: trunk/images/en/button-back.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/images/fr/button-back.png =================================================================== (Binary files differ) Property changes on: trunk/images/fr/button-back.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/src/picross/game/simple/LevelMenuController.java =================================================================== --- trunk/src/picross/game/simple/LevelMenuController.java 2008-05-05 09:34:00 UTC (rev 77) +++ trunk/src/picross/game/simple/LevelMenuController.java 2008-05-07 09:34:52 UTC (rev 78) @@ -37,6 +37,10 @@ import org.apache.log4j.Logger; +import picross.PicrossController; + +import picross.game.GameCommand; + import picross.menus.MenuController; /** @@ -70,10 +74,14 @@ String cmd = e.getCommandName(); - if (cmd.equals(picross.game.GameCommand.GAME_CMD)) { + if (cmd.equals(GameCommand.GAME_CMD)) { return; } + if (cmd.equals(PicrossController.PLAY_CMD)) { + return; + } + if (cmd.equals(LevelMenuController.LEVELS_LIST_CMD)) { LevelsListCommand command = (LevelsListCommand) e.getCommand(); ((LevelMenuUI) this.getView()).displayLevels(this, @@ -82,6 +90,14 @@ return; } + if (cmd.equals(SizesListCommand.SIZES_CMD)) { + SizesListCommand command = (SizesListCommand) e.getCommand(); + ((LevelMenuUI) this.getView()).displaySizes(this, + command.getSizes()); + + return; + } + super.eventPerformed(e); } } Modified: trunk/src/picross/game/simple/LevelMenuMediator.java =================================================================== --- trunk/src/picross/game/simple/LevelMenuMediator.java 2008-05-05 09:34:00 UTC (rev 77) +++ trunk/src/picross/game/simple/LevelMenuMediator.java 2008-05-07 09:34:52 UTC (rev 78) @@ -114,6 +114,12 @@ return; } + if (cmd.equals(MenuController.BACK_CMD)) { + this.fireEventPerformed(new SizesListCommand(this.model + .getSizesList())); + return; + } + super.eventPerformed(e); } Modified: trunk/src/picross/game/simple/LevelMenuUI.java =================================================================== --- trunk/src/picross/game/simple/LevelMenuUI.java 2008-05-05 09:34:00 UTC (rev 77) +++ trunk/src/picross/game/simple/LevelMenuUI.java 2008-05-07 09:34:52 UTC (rev 78) @@ -34,12 +34,25 @@ package picross.game.simple; import fr.cle.mmvcs.SimpleEvent; -import fr.cle.mmvcs.SimpleListener; import java.awt.Dimension; +import java.awt.event.ActionListener; + import java.util.List; +import javax.swing.Box; +import javax.swing.BoxLayout; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JPanel; +import javax.swing.JScrollPane; + +import picross.Picross; + +import picross.PicrossController; + +import picross.menus.MenuController; import picross.menus.MenuUI; /** @@ -61,9 +74,23 @@ * @param listener listener for the buttons * @param sizes available grid sizes */ - LevelMenuUI(SimpleListener listener, List<Dimension> sizes) { + LevelMenuUI(MenuController listener, List<Dimension> sizes) { super(); + this.displaySizes(listener, sizes); + } + + /*** Method ***/ + + /** + * Displays the available level sizes. + * + * @param listener listener for the buttons + * @param sizes grid sizes + */ + void displaySizes(MenuController listener, List<Dimension> sizes) { + this.removeAll(); + int x = 150; int y = 150; @@ -82,36 +109,76 @@ y = 150; } } + + this.addBackButton(listener, PicrossController.PLAY_CMD); + + this.repaint(); } - /*** Method ***/ - /** * Displays the levels list. * * @param listener listener for the buttons * @param levels levels to display */ - void displayLevels(SimpleListener listener, List<String> levels) { + void displayLevels(MenuController listener, List<String> levels) { this.removeAll(); - int x = 50; - int y = 150; - for (String level : levels) { + JPanel panel = new JPanel(); + panel.setOpaque(false); + panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); + + int nbLevels = levels.size(); + + for (int i = 0; i < nbLevels; i++) { + String level = levels.get(i); + SimpleEvent event = new SimpleEvent(LevelMenuController.LEVEL_CMD, level); - this.addSimpleButton(level, event, listener, x, y); - y += 75; + panel.add(this.createSimpleButton(level, event, listener) + .getButton()); - if (y == 375) { - x = 250; - y = 150; + if (i != (nbLevels - 1)) { + panel.add(Box.createRigidArea(new Dimension(0, 20))); } } + JScrollPane scrollPane = new JScrollPane(panel); + scrollPane.setOpaque(false); + scrollPane.setBorder(null); + scrollPane.setBounds(150, 120, 294, 200); + + scrollPane.getViewport().setOpaque(false); + + this.add(scrollPane); + + this.addBackButton(listener, MenuController.BACK_CMD); + + this.revalidate(); this.repaint(); } + + /** + * Adds a "back" button. + * + * @param listener listener for the button + * @param command command associated to the button + */ + private void addBackButton(ActionListener listener, String command) { + ImageIcon backIcon = Picross.getLocalizedImage("button-back.png"); + + JButton backButton = new JButton(backIcon); + backButton.setActionCommand(command); + backButton.addActionListener(listener); + + backButton.setBorder(null); + backButton.setBounds(7, 318, + backIcon.getIconWidth(), + backIcon.getIconHeight()); + + this.add(backButton); + } } Added: trunk/src/picross/game/simple/SizesListCommand.java =================================================================== --- trunk/src/picross/game/simple/SizesListCommand.java (rev 0) +++ trunk/src/picross/game/simple/SizesListCommand.java 2008-05-07 09:34:52 UTC (rev 78) @@ -0,0 +1,82 @@ +/* + * $Id$ + * + * Copyright (c) 2008 + * + * This software is governed by the CeCILL license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL license and that you accept its terms. + */ + + +package picross.game.simple; + +import fr.cle.mmvcs.NamedCommand; + +import java.awt.Dimension; + +import java.util.List; + +/** + * Command used to display the available grid sizes. + * + * @author Y. Norsa + */ +final class SizesListCommand extends NamedCommand { + /*** Constant ***/ + + /** Command used to display the grid sizes. */ + static final String SIZES_CMD = "SIZES_CMD"; + + /*** Field ***/ + + /** The sizes list. */ + private List<Dimension> sizes; + + /*** Constructor ***/ + + /** + * Constructor. + * + * @param sizesList the sizes list + */ + SizesListCommand(List<Dimension> sizesList) { + super(SizesListCommand.SIZES_CMD); + + this.sizes = sizesList; + } + + /*** Accessor ***/ + + /** + * Return the sizes list. + * + * @return available grid sizes + */ + List<Dimension> getSizes() { + return this.sizes; + } +} + Property changes on: trunk/src/picross/game/simple/SizesListCommand.java ___________________________________________________________________ Name: svn:keywords + Id Modified: trunk/src/picross/menus/MenuController.java =================================================================== --- trunk/src/picross/menus/MenuController.java 2008-05-05 09:34:00 UTC (rev 77) +++ trunk/src/picross/menus/MenuController.java 2008-05-07 09:34:52 UTC (rev 78) @@ -47,6 +47,11 @@ * @author Y. Norsa */ public class MenuController extends Controller implements ActionListener { + /*** Constant ***/ + + /** Command used to redisplay the previous menu. */ + public static final String BACK_CMD = "BACK_CMD"; + /*** Static field ***/ /** The class' logger. */ Modified: trunk/src/picross/menus/MenuUI.java =================================================================== --- trunk/src/picross/menus/MenuUI.java 2008-05-05 09:34:00 UTC (rev 77) +++ trunk/src/picross/menus/MenuUI.java 2008-05-07 09:34:52 UTC (rev 78) @@ -149,19 +149,41 @@ SimpleListener listener, int x, int y) { PicrossButton button = + this.createSimpleButton(label, event, listener); + this.putButton(button.getButton(), x, y, 150, 50); + } + + /** + * Helper method to create a button. + * + * @param label the button's label + * @param event the event linked to the button + * @param listener listener for the button + * @return the created button + */ + protected final PicrossButton createSimpleButton(String label, + SimpleEvent event, + SimpleListener listener) { + PicrossButton button = new PicrossButton(label, Picross.getImage("empty-button.png"), event); button.addSimpleListener(listener); JButton realButton = button.getButton(); + realButton.setHorizontalTextPosition(JButton.CENTER); realButton.setVerticalTextPosition(JButton.CENTER); - + realButton.setFont(realButton.getFont() .deriveFont(MenuUI.BUTTON_TEXT_SIZE)); realButton.setForeground(Color.WHITE); - this.putButton(realButton, x, y, 150, 50); + Dimension dim = new Dimension(150, 50); + realButton.setMinimumSize(dim); + realButton.setMaximumSize(dim); + realButton.setPreferredSize(dim); + + return button; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yva...@us...> - 2008-05-14 12:50:40
|
Revision: 86 http://picross.svn.sourceforge.net/picross/?rev=86&view=rev Author: yvan_norsa Date: 2008-05-14 05:50:47 -0700 (Wed, 14 May 2008) Log Message: ----------- support for more XBM files Modified Paths: -------------- trunk/data/contents.txt trunk/src/picross/game/simple/XBMModel.java Added Paths: ----------- trunk/data/bitrabbit.xbm Added: trunk/data/bitrabbit.xbm =================================================================== --- trunk/data/bitrabbit.xbm (rev 0) +++ trunk/data/bitrabbit.xbm 2008-05-14 12:50:47 UTC (rev 86) @@ -0,0 +1,7 @@ +#define bitrabbit_width 19 +#define bitrabbit_height 14 +static unsigned char bitrabbit_bits[] = { + 0x60, 0x00, 0x00, 0xe0, 0x00, 0x00, 0xe0, 0x00, 0x00, 0xe0, 0x00, 0x00, + 0xe0, 0x00, 0x00, 0xf8, 0x00, 0x00, 0xfe, 0x78, 0x00, 0xf7, 0xfe, 0x00, + 0xff, 0xff, 0x02, 0xfe, 0xff, 0x07, 0xf8, 0xff, 0x07, 0xf8, 0xff, 0x07, + 0xfe, 0xff, 0x07, 0xff, 0xff, 0x03 }; Modified: trunk/data/contents.txt =================================================================== --- trunk/data/contents.txt 2008-05-14 08:55:22 UTC (rev 85) +++ trunk/data/contents.txt 2008-05-14 12:50:47 UTC (rev 86) @@ -2,6 +2,7 @@ asterix.xbm : 16x16 audio.xbm : 32x32 batman2.xbm : 32x32 +bitrabbit.xbm : 19x14 bunny.xbm : 16x16 halloween.xbm : 16x16 squares.xbm : 16x16 Modified: trunk/src/picross/game/simple/XBMModel.java =================================================================== --- trunk/src/picross/game/simple/XBMModel.java 2008-05-14 08:55:22 UTC (rev 85) +++ trunk/src/picross/game/simple/XBMModel.java 2008-05-14 12:50:47 UTC (rev 86) @@ -199,9 +199,8 @@ for (String byteStr : byteValues) { String binaryStr = XBMModel.toBits(byteStr); + //XBMModel.log.debug("binaryStr : " + binaryStr); - //XBMModel.log.debug(binaryStr); - for (int j = XBMModel.BYTE_LENGTH - 1; j >= 0; j--) { //XBMModel.log.debug("this.data[" + yIndex //+ "][" + xIndex + "] = " @@ -214,11 +213,16 @@ if (yIndex == this.width) { xIndex++; yIndex = 0; + + break; } + // Useless ? + /* if (xIndex == this.height) { xIndex = 0; } + */ } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |