final JButton turnDownButton = (JButton)TestUtilities.getField(panel, "turnDownButton");
JCheckBox backFaceShownCheckBox = (JCheckBox)TestUtilities.getField(panel, "backFaceShownCheckBox");
final JTextField nameTextField = (JTextField)TestUtilities.getField(panel, "nameTextField");
final JCheckBox addToCatalogCheckBox = (JCheckBox)TestUtilities.getField(panel, "addToCatalogCheckBox");
final JComboBox categoryComboBox = (JComboBox)TestUtilities.getField(panel, "categoryComboBox");
final JSpinner widthSpinner = (JSpinner)TestUtilities.getField(panel, "widthSpinner");
JSpinner heightSpinner = (JSpinner)TestUtilities.getField(panel, "heightSpinner");
JSpinner depthSpinner = (JSpinner)TestUtilities.getField(panel, "depthSpinner");
final JCheckBox keepProportionsCheckBox = (JCheckBox)TestUtilities.getField(panel, "keepProportionsCheckBox");
JSpinner elevationSpinner = (JSpinner)TestUtilities.getField(panel, "elevationSpinner");
JCheckBox movableCheckBox = (JCheckBox)TestUtilities.getField(panel, "movableCheckBox");
JCheckBox doorOrWindowCheckBox = (JCheckBox)TestUtilities.getField(panel, "doorOrWindowCheckBox");
ColorButton colorButton = (ColorButton)TestUtilities.getField(panel, "colorButton");
final JButton clearColorButton = (JButton)TestUtilities.getField(panel, "clearColorButton");
// Check current step is model
tester.waitForIdle();
assertStepShowing(panel, true, false, false, false);
// 3. Choose tested model
String modelChoiceOrChangeButtonText = modelChoiceOrChangeButton.getText();
tester.invokeAndWait(new Runnable() {
public void run() {
modelChoiceOrChangeButton.doClick();
}
});
// Wait 1 s to let time to Java 3D to load the model
Thread.sleep(1000);
// Check choice button text changed
assertFalse("Choice button text didn't change",
modelChoiceOrChangeButtonText.equals(modelChoiceOrChangeButton.getText()));
// Click on next button
WizardPane view = (WizardPane)TestUtilities.findComponent(frame, WizardPane.class);
// Retrieve wizard view next button
final JButton nextFinishOptionButton = (JButton)TestUtilities.getField(view, "nextFinishOptionButton");
assertTrue("Next button isn't enabled", nextFinishOptionButton.isEnabled());
tester.invokeAndWait(new Runnable() {
public void run() {
nextFinishOptionButton.doClick();
}
});
// Check current step is rotation
assertStepShowing(panel, false, true, false, false);
// Check back face shown check box isn't selected by default
assertFalse("Back face shown check box is selected", backFaceShownCheckBox.isSelected());
// 4. Click on left button
float width = (Float)widthSpinner.getValue();
float depth = (Float)depthSpinner.getValue();
float height = (Float)heightSpinner.getValue();
tester.invokeAndWait(new Runnable() {
public void run() {
turnLeftButton.doClick();
}
});
// Check depth and width values were swapped
float newWidth = (Float)widthSpinner.getValue();
float newDepth = (Float)depthSpinner.getValue();
float newHeight = (Float)heightSpinner.getValue();
TestUtilities.assertEqualsWithinEpsilon("Incorrect width", depth, newWidth, 1E-3f);
TestUtilities.assertEqualsWithinEpsilon("Incorrect depth", width, newDepth, 1E-3f);
TestUtilities.assertEqualsWithinEpsilon("Incorrect height", height, newHeight, 1E-3f);
// Click on down button
width = newWidth;
depth = newDepth;
height = newHeight;
tester.invokeAndWait(new Runnable() {
public void run() {
turnDownButton.doClick();
}
});
// Check height and depth values were swapped
newWidth = (Float)widthSpinner.getValue();
newDepth = (Float)depthSpinner.getValue();
newHeight = (Float)heightSpinner.getValue();
TestUtilities.assertEqualsWithinEpsilon("Incorrect width", width, newWidth, 1E-3f);
TestUtilities.assertEqualsWithinEpsilon("Incorrect depth", height, newDepth, 1E-3f);
TestUtilities.assertEqualsWithinEpsilon("Incorrect height", depth, newHeight, 1E-3f);
// 5. Click on next button
assertTrue("Next button isn't enabled", nextFinishOptionButton.isEnabled());
tester.invokeAndWait(new Runnable() {
public void run() {
nextFinishOptionButton.doClick();
}
});
// Check current step is attributes
assertStepShowing(panel, false, false, true, false);
// 6. Check default furniture name is the presentation name proposed by content manager
assertEquals("Wrong default name",
contentManager.getPresentationName(testedModelName.toString(), ContentManager.ContentType.MODEL),
nameTextField.getText());
// Check Add to catalog check box isn't selected and category combo box
// is disabled when furniture is imported in home
assertFalse("Add to catalog check box is selected", addToCatalogCheckBox.isSelected());
assertFalse("Category combo box isn't disabled", categoryComboBox.isEnabled());
// Check default category is first category
final FurnitureCategory firstCategory = preferences.getFurnitureCatalog().getCategories().get(0);
assertEquals("Wrong default category", firstCategory, categoryComboBox.getSelectedItem());
// Rename furniture with the name of the catalog first piece
tester.invokeAndWait(new Runnable() {
public void run() {
nameTextField.setText(firstCategory.getFurniture().get(0).getName());
}
});
// Check next button is enabled
assertTrue("Next button isn't enabled", nextFinishOptionButton.isEnabled());
// Select Add to catalog check box
tester.invokeAndWait(new Runnable() {
public void run() {
addToCatalogCheckBox.setSelected(true);
}
});
// Check next button is disabled because imported furniture has a wrong name
assertFalse("Next button isn't disabled", nextFinishOptionButton.isEnabled());
// Rename furniture and its category
final String pieceTestName = "#@" + System.currentTimeMillis() + "@#";
final String categoryTestName = "sdfghjkl";
tester.invokeAndWait(new Runnable() {
public void run() {
nameTextField.setText(pieceTestName);
categoryComboBox.getEditor().selectAll();
}
});
tester.actionKeyString(categoryComboBox.getEditor().getEditorComponent(), categoryTestName);
// Check next button is enabled again
assertTrue("Next button isn't enabled", nextFinishOptionButton.isEnabled());
// 7. Check keep proportions check box is selected by default
assertTrue("Keep proportions check box isn't selected", keepProportionsCheckBox.isSelected());
// Change width with a value 10 times greater
width = newWidth;
depth = newDepth;
height = newHeight;
final float enteredWidth = newWidth * 10;
tester.invokeAndWait(new Runnable() {
public void run() {
widthSpinner.setValue(enteredWidth);
}
});
// Check height and depth values are 10 times greater
newWidth = (Float)widthSpinner.getValue();
newDepth = (Float)depthSpinner.getValue();
newHeight = (Float)heightSpinner.getValue();
TestUtilities.assertEqualsWithinEpsilon("Incorrect width", 10 * width, newWidth, 1E-3f);
TestUtilities.assertEqualsWithinEpsilon("Incorrect depth", 10 * depth, newDepth, 1E-3f);
TestUtilities.assertEqualsWithinEpsilon("Incorrect height", 10 * height, newHeight, 1E-3f);
// Deselect keep proportions check box
tester.invokeAndWait(new Runnable() {
public void run() {
keepProportionsCheckBox.setSelected(false);
}
});
// Change width with a value 2 times greater
width = newWidth;
depth = newDepth;
height = newHeight;
final float twiceValue = newWidth * 2;
tester.invokeAndWait(new Runnable() {
public void run() {
widthSpinner.setValue(twiceValue);
}
});
// Check height and depth values didn't change
newWidth = (Float)widthSpinner.getValue();
newDepth = (Float)depthSpinner.getValue();
newHeight = (Float)heightSpinner.getValue();
TestUtilities.assertEqualsWithinEpsilon("Incorrect width", 2 * width, newWidth, 1E-3f);
TestUtilities.assertEqualsWithinEpsilon("Incorrect depth", depth, newDepth, 1E-3f);
TestUtilities.assertEqualsWithinEpsilon("Incorrect height", height, newHeight, 1E-3f);
// 8. Change elevation, movable, door or window, color default values
assertEquals("Wrong default elevation", 0f, (Float)elevationSpinner.getValue());
elevationSpinner.setValue(10);
assertTrue("Movable check box isn't selected", movableCheckBox.isSelected());
movableCheckBox.setSelected(false);
assertFalse("Door or window check box is selected", doorOrWindowCheckBox.isSelected());
doorOrWindowCheckBox.setSelected(true);
assertEquals("Wrong default color", null, colorButton.getColor());