Ejemplo n.º 1
0
 @Test
 public void addBallTest() {
   assertEquals(model.getBalls(), new ArrayList<Ball>());
   model.addBall("b1", 10, 10, 50, 50);
   model.addBall("b2", 10, 10, 50, 50);
   assertTrue(model.getBalls().size() == 1);
 }
Ejemplo n.º 2
0
 @Test
 public void setAbsorberTest() {
   Absorber absorb = new Absorber("absorb", 0, 0, 60, 60);
   model.setAbsorber(absorb);
   assertTrue(model.getAbsorber() != null);
   assertEquals(model.getAbsorber(), absorb);
 }
Ejemplo n.º 3
0
 @Test
 public void frictionTest() {
   assertTrue(model.getFrictionX() == 0.025);
   assertTrue(model.getFrictionY() == 0.025);
   model.setFriction(1.5, 1.5);
   assertTrue(model.getFrictionX() == 1.5);
   assertTrue(model.getFrictionY() == 1.5);
 }
Ejemplo n.º 4
0
 @Test
 public void setFlippersTest() {
   List<Flipper> flippers = new ArrayList<Flipper>();
   Flipper flip = new Flipper(0, 0, true, "flip");
   flippers.add(flip);
   model.setFlippers(flippers);
   assertTrue(model.getFlippers().size() == 1);
   assertEquals(model.getFlippers().get(0), flip);
 }
Ejemplo n.º 5
0
 @Test
 public void setBallsTest() {
   List<Ball> balls = new ArrayList<Ball>();
   Ball ball = new Ball("b1", 5, 5, 50, 50);
   balls.add(ball);
   model.setBalls(balls);
   assertTrue(model.getBalls().size() == 1);
   assertEquals(model.getBalls().get(0), ball);
 }
Ejemplo n.º 6
0
 @Test
 public void setGizmosTest() {
   List<Bumper> bumpers = new ArrayList<Bumper>();
   Bumper cBump = new CircularBumper(0, 0, 0, "cBump");
   bumpers.add(cBump);
   model.setBumpers(bumpers);
   assertTrue(model.getBumpers().size() == 1);
   assertEquals(model.getBumpers().get(0), cBump);
 }
Ejemplo n.º 7
0
 @Test
 public void keyConnectionTest() {
   assertTrue(model.addKeyConnectionAbs(10, new Absorber("ABS1", 0, 380, 400, 400), "down"));
   assertTrue(model.getKeyConnectionsAbs().size() == 1);
   assertTrue(model.getKeyConnectionsAbs().get(0).getKeyID() == 10);
   assertTrue(model.addKeyConnectionFlipper(20, new Flipper(0, 0, true, "F1"), "down"));
   assertTrue(model.getKeyConnectionsFlipper().size() == 1);
   assertTrue(model.getKeyConnectionsFlipper().get(0).getKeyID() == 20);
 }
Ejemplo n.º 8
0
 @Test
 public void connectionTest() {
   CircularBumper circularBumper = new CircularBumper(100, 100, 0, "cBump");
   Flipper flipper = new Flipper(200, 200, true, "f1");
   assertEquals(model.getConnections(), new ArrayList<Connection>());
   model.addConnection(circularBumper, flipper);
   assertTrue(model.getConnections().size() == 1);
   model.addConnection(circularBumper, flipper);
   assertTrue(model.getConnections().size() == 1);
 }
Ejemplo n.º 9
0
 @Test
 public void occupiedSpacesTest() {
   boolean[][] occupied = model.getOccupiedSpaces();
   for (int i = 0; i < occupied.length; i++) {
     for (int j = 0; j < occupied[i].length; j++) {
       assertFalse(occupied[i][j]);
     }
   }
   model.addCircularBumper(0, 0, 0, "cBump");
   assertTrue(model.getOccupiedSpaces()[0][0]);
 }
Ejemplo n.º 10
0
 @Test
 public void deleteElementTest() {
   assertFalse(model.deleteElement(0, 0));
   model.addSquareBumper(0, 0, 0, "sBump");
   assertTrue(model.deleteElement(0, 0));
   model.addFlipper(0, 0, true, "flipper");
   assertTrue(model.deleteElement(0, 0));
   model.addAbsorber("absorb", 0, 0, 20, 20);
   assertTrue(model.deleteElement(0, 0));
   model.addBall("b1", 10, 10, 50, 50);
   assertTrue(model.deleteElement(0, 0));
 }
Ejemplo n.º 11
0
 @Test
 public void moveElementTest() {
   assertFalse(model.moveElement(0, 0, 60, 60));
   model.addSquareBumper(40, 0, 0, "sBump");
   model.addFlipper(0, 0, true, "flipper");
   model.addAbsorber("absorb", 0, 40, 100, 60);
   model.addBall("b1", 70, 10, 50, 50);
   assertFalse(model.moveElement(40, 0, 0, 0));
   assertFalse(model.moveElement(0, 0, 20, 0));
   assertTrue(model.moveElement(40, 0, 80, 0));
   assertTrue(model.moveElement(0, 40, 0, 80));
   assertTrue(model.moveElement(0, 0, 0, 40));
   assertTrue(model.moveElement(60, 0, 10, 10));
 }
Ejemplo n.º 12
0
 @Test
 public void moveBallTest() {
   model.addSquareBumper(40, 0, 0, "sBump");
   model.addFlipper(60, 60, false, "flipper");
   model.addAbsorber("absorb", 0, 180, 200, 200);
   model.addBall("b1", 10, 10, 50, 50);
   model.moveModel();
   assertTrue(model.getBalls().get(0).getX() != 10);
   assertTrue(model.getBalls().get(0).getY() != 10);
   model.reset();
   assertTrue(model.getBalls().get(0).getX() == 10);
   assertTrue(model.getBalls().get(0).getX() == 10);
 }
Ejemplo n.º 13
0
 @Test
 public void objectNameTest() {
   assertTrue(model.getObjectTypeForKeyConnection("sBump") == null);
   model.addSquareBumper(40, 0, 0, "sBump");
   assertTrue(model.getObjectTypeForKeyConnection("sBump") == null);
   model.addFlipper(60, 60, false, "flipper");
   model.addAbsorber("absorb", 0, 180, 200, 200);
   assertEquals(model.getObjectTypeForKeyConnection("flipper"), "Flipper");
   assertEquals(model.getObjectTypeForKeyConnection("absorb"), "Absorber");
 }
Ejemplo n.º 14
0
 @Test
 public void clearTest() {
   model.addSquareBumper(0, 0, 0, "sBump");
   model.addCircularBumper(0, 20, 0, "cBump");
   model.addTriangularBumper(0, 40, 0, "tBump");
   model.clear();
   assertTrue(model.getBumper("sBump") == null);
   assertTrue(model.getBumper("cBump") == null);
   assertTrue(model.getBumper("tBump") == null);
   assertTrue(model.getBumpers().size() == 0);
 }
Ejemplo n.º 15
0
 @Test
 public void rotateElementTest() {
   assertFalse(model.rotateElement(0, 0));
   model.addTriangularBumper(0, 40, 0, "tBump");
   model.addFlipper(0, 0, true, "flipper");
   assertTrue(model.rotateElement(0, 40));
   assertTrue(model.getBumper("tBump").getRotation() == 1);
   assertTrue(model.rotateElement(0, 0));
 }
Ejemplo n.º 16
0
 @Test
 public void addFlipperTest() {
   model.addFlipper(0, 0, true, "flipper");
   assertTrue(model.getFlippers().size() == 1);
   model.addFlipper(0, 0, true, "flipper");
   assertTrue(model.getFlippers().size() == 1);
   model.addFlipper(60, 0, true, "flipper");
   assertTrue(model.getFlippers().size() == 2);
 }
Ejemplo n.º 17
0
 @Test
 public void addAbsorberTest() {
   assertTrue(model.getAbsorber() == null);
   model.addAbsorber("absorb", 0, 0, 20, 20);
   model.addAbsorber("absorb", 0, 20, 60, 80);
   assertFalse(model.getAbsorber() == null);
   assertTrue(model.getAbsorber().getXTopLeft() == 0);
   assertTrue(model.getAbsorber().getYTopLeft() == 20);
   assertTrue(model.getAbsorber().getXBottomRight() == 60);
   assertTrue(model.getAbsorber().getYBottomRight() == 80);
 }
Ejemplo n.º 18
0
 @Test
 public void fileTest() {
   assertTrue(model.getLoadFile() == null);
   model.setLoadFile(new File("test.txt"));
   assertEquals(model.getLoadFile(), new File("test.txt"));
 }
Ejemplo n.º 19
0
 @Test
 public void gravityTest() {
   assertTrue(model.getGravity() == 25);
   model.setGravity(50);
   assertTrue(model.getGravity() == 50);
 }
Ejemplo n.º 20
0
 @Test
 public void addBumpersTest() {
   model.addSquareBumper(0, 0, 0, "sBump");
   model.addCircularBumper(0, 20, 0, "cBump");
   model.addTriangularBumper(0, 40, 0, "tBump");
   assertFalse(model.getBumper("sBump") == null);
   assertTrue(model.getBumper("") == null);
   assertTrue(model.getBumper("sBump") instanceof SquareBumper);
   assertTrue(model.getBumper("cBump") instanceof CircularBumper);
   assertTrue(model.getBumper("tBump") instanceof TriangularBumper);
   model.addSquareBumper(0, 0, 0, "sBump");
   model.addCircularBumper(0, 20, 0, "cBump");
   model.addTriangularBumper(0, 40, 0, "tBump");
   assertTrue(model.getBumpers().size() == 3);
 }