Skip to content
Snippets Groups Projects
Commit 6e9d9bf6 authored by LABOUREL Arnaud's avatar LABOUREL Arnaud
Browse files

Ajout test pour les Empty classes

parent 4b3ec7c9
Branches
No related tags found
No related merge requests found
Pipeline #2382 passed
# Image
# Tuiles de Wang
## Description du projet
Ce projet est l'occasion de travailler sur la représentation et la manipulation d'images. Ces images seront constituées de pixels caractérisés par une couleur représentant un niveau de gris.
Ce sujet est construit sur l'idée de réaliser des pavages du plan, à l'aide d'objets simples nommés des tuiles de Wang. Il s'agit de tuiles carrées divisées en quatre triangles. Chaque triangle est associé à un côté du carré, et coloré d'une couleur particulière.
## Membres du projet
......
......@@ -8,6 +8,10 @@ import java.util.List;
import java.util.Random;
public class GridController {
public static final Color COLOR_FIRST_NAME_ONE = Color.RED;
public static final Color COLOR_LAST_NAME_ONE = Color.BLUE;
public static final Color COLOR_FIRST_NAME_TWO = Color.GREEN;
public static final Color COLOR_LAST_NAME_TWO = Color.YELLOW;
Random random = new Random();
@FXML
public GridTileCanvas gridTileCanvas;
......@@ -40,39 +44,57 @@ public class GridController {
}
@FXML
public void updateRedUniformTile(){
public void updateFirstNameOneUniformTile(){
// TODO : uncomment the code to test UniformTileGenerator
// updateGrid(new UniformTileGenerator(new InternalSide(Color.RED)));
// updateGrid(new UniformTileGenerator(new InternalSide(COLOR_FIRST_NAME_ONE)));
}
@FXML
public void updateFirstNameTwoUniformTile() {
// TODO : uncomment the code to test UniformTileGenerator
// updateGrid(new UniformTileGenerator(new InternalSide(COLOR_FIRST_NAME_TWO)));
}
@FXML
public void updateLastNameOneUniformTile(){
// TODO : uncomment the code to test UniformTileGenerator
// updateGrid(new UniformTileGenerator(new InternalSide(COLOR_LAST_NAME_ONE)));
}
@FXML
public void updateLastNameTwoUniformTile() {
// TODO : uncomment the code to test UniformTileGenerator
// updateGrid(new UniformTileGenerator(new InternalSide(COLOR_LAST_NAME_TWO)));
}
@FXML
public void updateRandomColorUniformTile(){
// TODO : uncomment the code to test RandomUniformTileGenerator
// updateGrid(new RandomUniformTileGenerator(List.of(Color.RED, Color.BLUE, Color.BLACK), random));
// updateGrid(new RandomUniformTileGenerator(List.of(COLOR_FIRST_NAME_ONE, COLOR_LAST_NAME_ONE, COLOR_LAST_NAME_TWO), random));
}
@FXML
public void updateRandomTruchetTile(){
// TODO : uncomment the code to test RandomRotatedTruchetTileGenerator
// updateGrid(new RandomRotatedTruchetTileGenerator(Color.RED, Color.BLUE, random));
// updateGrid(new RandomRotatedTruchetTileGenerator(COLOR_FIRST_NAME_ONE, COLOR_LAST_NAME_ONE, random));
}
@FXML
public void updateRandomWangTile() {
// TODO : uncomment the code to test RandomWangTileGenerator
// updateGrid(new RandomWangTileGenerator(List.of(Color.RED, Color.BLUE, Color.GREEN, Color.YELLOW), random));
// updateGrid(new RandomWangTileGenerator(List.of(COLOR_FIRST_NAME_ONE, COLOR_LAST_NAME_ONE, COLOR_FIRST_NAME_TWO, COLOR_LAST_NAME_TWO), random));
}
@FXML
public void updateRandomConstrainedWangTile() {
// TODO : uncomment the code to test RandomConstrainedWangTileGenerator
// updateGrid(new RandomConstrainedWangTileGenerator(List.of(Color.RED, Color.BLUE, Color.GREEN, Color.YELLOW), random));
// updateGrid(new RandomConstrainedWangTileGenerator(List.of(COLOR_FIRST_NAME_ONE, COLOR_LAST_NAME_ONE, COLOR_FIRST_NAME_TWO, Color.YELLOW), random));
}
@FXML
public void updateConstrainedTruchetTile() {
// TODO : uncomment the code to test ConstrainedRotatedTruchetTileGenerator
// updateGrid(new ConstrainedRotatedTruchetTileGenerator(Color.RED, Color.BLUE, random));
// updateGrid(new ConstrainedRotatedTruchetTileGenerator(COLOR_FIRST_NAME_ONE, COLOR_LAST_NAME_ONE, random));
}
@FXML
......@@ -80,15 +102,16 @@ public class GridController {
// TODO : uncomment the code to test RandomTileSetGenerator
/*
updateGrid(new RandomTileSetGenerator(List.of(
new WangTile(new Side[]{new InternalSide(Color.RED), new InternalSide(Color.BLUE), new InternalSide(Color.RED), new InternalSide(Color.RED)}),
new WangTile(new Side[]{new InternalSide(Color.RED), new InternalSide(Color.RED), new InternalSide(Color.BLUE), new InternalSide(Color.BLUE)}),
new WangTile(new Side[]{new InternalSide(Color.RED), new InternalSide(Color.GREEN), new InternalSide(Color.GREEN), new InternalSide(Color.GREEN)}),
new WangTile(new Side[]{new InternalSide(Color.BLUE), new InternalSide(Color.GREEN), new InternalSide(Color.RED), new InternalSide(Color.BLUE)}),
new WangTile(new Side[]{new InternalSide(Color.BLUE), new InternalSide(Color.BLUE), new InternalSide(Color.BLUE), new InternalSide(Color.RED)}),
new WangTile(new Side[]{new InternalSide(Color.BLUE), new InternalSide(Color.RED), new InternalSide(Color.GREEN), new InternalSide(Color.GREEN)}),
new WangTile(new Side[]{new InternalSide(Color.GREEN), new InternalSide(Color.GREEN), new InternalSide(Color.BLUE), new InternalSide(Color.GREEN)}),
new WangTile(new Side[]{new InternalSide(Color.GREEN), new InternalSide(Color.RED), new InternalSide(Color.RED), new InternalSide(Color.RED)}),
new WangTile(new Side[]{new InternalSide(Color.GREEN), new InternalSide(Color.BLUE), new InternalSide(Color.GREEN), new InternalSide(Color.BLUE)})), random));
new WangTile(new Side[]{new InternalSide(COLOR_LAST_NAME_ONE), new InternalSide(COLOR_FIRST_NAME_ONE), new InternalSide(COLOR_FIRST_NAME_ONE), new InternalSide(COLOR_FIRST_NAME_ONE)}),
new WangTile(new Side[]{new InternalSide(COLOR_LAST_NAME_TWO), new InternalSide(COLOR_FIRST_NAME_ONE), new InternalSide(COLOR_FIRST_NAME_ONE), new InternalSide(COLOR_FIRST_NAME_ONE)}),
new WangTile(new Side[]{new InternalSide(COLOR_LAST_NAME_ONE), new InternalSide(COLOR_FIRST_NAME_ONE), new InternalSide(COLOR_LAST_NAME_ONE), new InternalSide(COLOR_FIRST_NAME_TWO)}),
new WangTile(new Side[]{new InternalSide(COLOR_LAST_NAME_TWO), new InternalSide(COLOR_FIRST_NAME_ONE), new InternalSide(COLOR_LAST_NAME_ONE), new InternalSide(COLOR_FIRST_NAME_TWO)}),
new WangTile(new Side[]{new InternalSide(COLOR_FIRST_NAME_ONE), new InternalSide(COLOR_FIRST_NAME_TWO), new InternalSide(COLOR_LAST_NAME_TWO), new InternalSide(COLOR_FIRST_NAME_ONE)}),
new WangTile(new Side[]{new InternalSide(COLOR_FIRST_NAME_TWO), new InternalSide(COLOR_FIRST_NAME_TWO), new InternalSide(COLOR_LAST_NAME_TWO), new InternalSide(COLOR_FIRST_NAME_ONE)}),
new WangTile(new Side[]{new InternalSide(COLOR_FIRST_NAME_ONE), new InternalSide(COLOR_FIRST_NAME_TWO), new InternalSide(COLOR_FIRST_NAME_TWO), new InternalSide(COLOR_FIRST_NAME_TWO)}),
new WangTile(new Side[]{new InternalSide(COLOR_FIRST_NAME_TWO), new InternalSide(COLOR_FIRST_NAME_TWO), new InternalSide(COLOR_FIRST_NAME_TWO), new InternalSide(COLOR_FIRST_NAME_TWO)})), random));
*/
}
}
......@@ -17,7 +17,13 @@
<Menu mnemonicParsing="false" text="Uniform Tiles">
<MenuItem mnemonicParsing="false" onAction="#updateEmptyUniformTile" text="Empty">
</MenuItem>
<MenuItem mnemonicParsing="false" onAction="#updateRedUniformTile" text="Red">
<MenuItem mnemonicParsing="false" onAction="#updateFirstNameOneUniformTile" text="Firstname 1">
</MenuItem>
<MenuItem mnemonicParsing="false" onAction="#updateLastNameOneUniformTile" text="Lastname 1">
</MenuItem>
<MenuItem mnemonicParsing="false" onAction="#updateFirstNameTwoUniformTile" text="Firstname 2">
</MenuItem>
<MenuItem mnemonicParsing="false" onAction="#updateLastNameTwoUniformTile" text="Lastname 2">
</MenuItem>
<MenuItem mnemonicParsing="false" onAction="#updateRandomColorUniformTile" text="Random color">
</MenuItem>
......
import model.EmptyGrid;
import model.EmptySquare;
import model.Grid;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class EmptyGridTest {
@Test
void testGetNumberOfRows(){
assertThat(new EmptyGrid(10,20).getNumberOfRows()).isEqualTo(10);
assertThat(new EmptyGrid(100,200).getNumberOfRows()).isEqualTo(100);
}
@Test
void testGetNumberOfColumns(){
assertThat(new EmptyGrid(10,20).getNumberOfColumns()).isEqualTo(20);
assertThat(new EmptyGrid(100,200).getNumberOfColumns()).isEqualTo(200);
}
@Test
void testGetSquare(){
Grid emptyGrid = new EmptyGrid(100,20);
assertThat(emptyGrid.getSquare(0, 0)).isEqualTo(EmptySquare.EMPTY_SQUARE);
assertThat(emptyGrid.getSquare(10, 9)).isEqualTo(EmptySquare.EMPTY_SQUARE);
assertThat(emptyGrid.getSquare(99, 19)).isEqualTo(EmptySquare.EMPTY_SQUARE);
}
}
import javafx.scene.paint.Color;
import model.EmptySide;
import model.Side;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class EmptySideTest {
@Test
void testCompatibleSides(){
List<Side> sides = List.of(EmptySide.EMPTY_SIDE);
assertThat(EmptySide.EMPTY_SIDE.compatibleSides(sides)).containsExactly(EmptySide.EMPTY_SIDE);
}
@Test
void testColor(){
assertThat(EmptySide.EMPTY_SIDE.color()).isEqualTo(Color.WHITE);
}
@Test
void testAccept(){
assertThat(EmptySide.EMPTY_SIDE.accept(EmptySide.EMPTY_SIDE)).isTrue();
}
}
import model.CardinalDirection;
import model.EmptySide;
import model.EmptySquare;
import model.EmptyTile;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class EmptySquareTest {
@Test
void testAccept(){
assertThat(EmptySquare.EMPTY_SQUARE.accept(EmptyTile.EMPTY_TILE)).isTrue();
}
@Test
void testGetTile(){
assertThat(EmptySquare.EMPTY_SQUARE.getTile()).isEqualTo(EmptyTile.EMPTY_TILE);
}
@Test
void testCompatibleTiles(){
assertThat(EmptySquare.EMPTY_SQUARE.compatibleTiles(List.of(EmptyTile.EMPTY_TILE))).containsExactly(EmptyTile.EMPTY_TILE);
}
@Test
void testCompatibleSides(){
assertThat(EmptySquare.EMPTY_SQUARE.compatibleSides(List.of(EmptySide.EMPTY_SIDE), CardinalDirection.NORTH)).containsExactly(EmptySide.EMPTY_SIDE);
}
@Test
void testGetNeighbor(){
assertThat(EmptySquare.EMPTY_SQUARE.getNeighbor(CardinalDirection.NORTH)).isEqualTo(EmptySquare.EMPTY_SQUARE);
}
}
import model.EmptySquare;
import model.EmptyTile;
import model.EmptyTileGenerator;
import model.TileGenerator;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class EmptyTileGeneratorTest {
@Test
void testNextTile(){
TileGenerator tileGenerator = new EmptyTileGenerator();
assertThat(tileGenerator.nextTile(EmptySquare.EMPTY_SQUARE)).isEqualTo(EmptyTile.EMPTY_TILE);
assertThat(tileGenerator.nextTile(EmptySquare.EMPTY_SQUARE)).isEqualTo(EmptyTile.EMPTY_TILE);
}
}
import model.CardinalDirection;
import model.EmptySide;
import model.EmptyTile;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class EmptyTileTest {
@Test
void testSide(){
assertThat(EmptyTile.EMPTY_TILE.side(CardinalDirection.NORTH)).isEqualTo(EmptySide.EMPTY_SIDE);
assertThat(EmptyTile.EMPTY_TILE.side(CardinalDirection.SOUTH)).isEqualTo(EmptySide.EMPTY_SIDE);
assertThat(EmptyTile.EMPTY_TILE.side(CardinalDirection.EAST)).isEqualTo(EmptySide.EMPTY_SIDE);
assertThat(EmptyTile.EMPTY_TILE.side(CardinalDirection.WEST)).isEqualTo(EmptySide.EMPTY_SIDE);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment