wall1.setLeftSideColor(10);
wall1.setRightSideColor(20);
home.setSelectedItems(Arrays.asList(new Wall [] {wall1}));
// 2. Create a wall panel to edit the selected wall
WallController wallController = new WallController(home, preferences, viewFactory, null, null);
// Check values stored by wall panel components are equal to the ones set
assertWallControllerEquals(wall1.getXStart(), wall1.getYStart(),
wall1.getXEnd(), wall1.getYEnd(),
(float)Point2D.distance(wall1.getXStart(), wall1.getYStart(),
wall1.getXEnd(), wall1.getYEnd()),
wall1.getThickness(), home.getWallHeight(), wall1.getHeightAtEnd(),
wall1.getLeftSideColor(), wall1.getLeftSideTexture(),
wall1.getRightSideColor(), wall1.getRightSideTexture(), wallController);
// 3. Modify wall right side texture with first available texture
TextureImage firstTexture = preferences.getTexturesCatalog().getCategories().get(0).getTexture(0);
wall1.setRightSideColor(null);
wall1.setRightSideTexture(new HomeTexture(firstTexture));
wallController = new WallController(home, preferences, viewFactory, null, null);
assertWallControllerEquals(wall1.getXStart(), wall1.getYStart(),
wall1.getXEnd(), wall1.getYEnd(),
(float)Point2D.distance(wall1.getXStart(), wall1.getYStart(),
wall1.getXEnd(), wall1.getYEnd()),
wall1.getThickness(), home.getWallHeight(), wall1.getHeightAtEnd(),
wall1.getLeftSideColor(), wall1.getLeftSideTexture(),
null, wall1.getRightSideTexture(), wallController);
// 4. Increase length in dialog
DialogView wallView = wallController.getView();
JSpinner distanceToEndPointSpinner =
(JSpinner)TestUtilities.getField(wallView, "distanceToEndPointSpinner");
distanceToEndPointSpinner.setValue((Float)distanceToEndPointSpinner.getValue() + 20f);
// Check wall end coordinates changed accordingly
assertTrue("Wrong X end", Math.abs(wall1.getXEnd() + 20f * (float)Math.cos(Math.PI / 4) - wallController.getXEnd()) < 1E-5);
assertTrue("Wrong Y end", Math.abs(wall1.getYEnd() + 20f * (float)Math.sin(Math.PI / 4) - wallController.getYEnd()) < 1E-5);
// 5. Add a second selected wall to home
Wall wall2 = new Wall(0.1f, 0.3f, 200.1f, 200.2f, 5f);
home.addWall(wall2);
wall2.setHeight(300f);
wall2.setLeftSideColor(10);
wall2.setRightSideColor(50);
home.setSelectedItems(Arrays.asList(new Wall [] {wall1, wall2}));
// Check if wall panel edits null values if walls thickness or colors are the same
wallController = new WallController(home, preferences, viewFactory, null, null);
// Check values stored by furniture panel components are equal to the ones set
assertWallControllerEquals(0.1f, null, null,
null, null, null, null, null, 10, null, null, null, wallController);
}