// 11. Edit 3D view modal dialog box
JDialog attributesDialog = showHome3DAttributesPanel(preferences, controller, frame, tester);
// Retrieve Home3DAttributesPanel components
Home3DAttributesPanel panel = (Home3DAttributesPanel)TestUtilities.findComponent(
attributesDialog, Home3DAttributesPanel.class);
Home3DAttributesController panelController =
(Home3DAttributesController)TestUtilities.getField(panel, "controller");
JSpinner observerFieldOfViewSpinner =
(JSpinner)TestUtilities.getField(panel, "observerFieldOfViewSpinner");
JSpinner observerHeightSpinner =
(JSpinner)TestUtilities.getField(panel, "observerHeightSpinner");
ColorButton groundColorButton =
(ColorButton)TestUtilities.getField(panel, "groundColorButton");
ColorButton skyColorButton =
(ColorButton)TestUtilities.getField(panel, "skyColorButton");
JSlider brightnessSlider =
(JSlider)TestUtilities.getField(panel, "brightnessSlider");
JSlider wallsTransparencySlider =
(JSlider)TestUtilities.getField(panel, "wallsTransparencySlider");
// Check edited values
float oldCameraFieldOfView = observerCamera.getFieldOfView();
float oldCameraHeight = observerCamera.getHeight();
int oldGroundColor = home.getEnvironment().getGroundColor();
TextureImage oldGroundTexture = home.getEnvironment().getGroundTexture();
int oldSkyColor = home.getEnvironment().getSkyColor();
int oldLightColor = home.getEnvironment().getLightColor();
float oldWallsAlpha = home.getEnvironment().getWallsAlpha();
assertEquals("Wrong field of view", (int)Math.round(Math.toDegrees(oldCameraFieldOfView)),
observerFieldOfViewSpinner.getValue());
assertEquals("Wrong height", (float)Math.round(oldCameraHeight * 100) / 100,
observerHeightSpinner.getValue());
assertEquals("Wrong ground color", oldGroundColor,
groundColorButton.getColor().intValue());
assertEquals("Wrong ground texture", oldGroundTexture,
panelController.getGroundTextureController().getTexture());
assertEquals("Wrong sky color", oldSkyColor,
skyColorButton.getColor().intValue());
assertEquals("Wrong brightness", oldLightColor & 0xFF,
brightnessSlider.getValue());
assertEquals("Wrong transparency", (int)(oldWallsAlpha * 255),
wallsTransparencySlider.getValue());
// 12. Change dialog box values
observerFieldOfViewSpinner.setValue(90);
observerHeightSpinner.setValue(300f);
groundColorButton.setColor(0xFFFFFF);
skyColorButton.setColor(0x000000);
brightnessSlider.setValue(128);
wallsTransparencySlider.setValue(128);
// Click on Ok in dialog box
doClickOnOkInDialog(attributesDialog, tester);
// Check home attributes are modified accordingly
assert3DAttributesEqualHomeAttributes((float)Math.toRadians(90), 300f,
0xFFFFFF, null, 0x000000, 0x808080, 1 / 255f * 128f, home);
// 13. Undo changes
runAction(controller, HomePane.ActionType.UNDO, tester);
// Check home attributes have previous values
assert3DAttributesEqualHomeAttributes(oldCameraFieldOfView, oldCameraHeight,
oldGroundColor, null, oldSkyColor, oldLightColor, oldWallsAlpha, home);
// Redo
runAction(controller, HomePane.ActionType.REDO, tester);
// Check home attributes are modified accordingly
assert3DAttributesEqualHomeAttributes((float)Math.toRadians(90), 300f,
0xFFFFFF, null, 0x000000, 0x808080, 1 / 255f * 128f, home);
// 14. Edit 3D view modal dialog box to change ground texture
attributesDialog = showHome3DAttributesPanel(preferences, controller, frame, tester);
panel = (Home3DAttributesPanel)TestUtilities.findComponent(
attributesDialog, Home3DAttributesPanel.class);
panelController = (Home3DAttributesController)TestUtilities.getField(panel, "controller");
JRadioButton groundColorRadioButton =
(JRadioButton)TestUtilities.getField(panel, "groundColorRadioButton");
final TextureChoiceComponent groundTextureButton =
(TextureChoiceComponent)panelController.getGroundTextureController().getView();
JRadioButton groundTextureRadioButton =
(JRadioButton)TestUtilities.getField(panel, "groundTextureRadioButton");
// Check color and texture radio buttons
assertTrue("Ground color radio button isn't checked",