@Override
public void finish() {
finished [0] = true;
}
};
WizardPane view = (WizardPane)controller.getView();
// Retrieve view back and next buttons
final JButton backOptionButton = (JButton)TestUtilities.getField(view, "backOptionButton");
final JButton nextFinishOptionButton = (JButton)TestUtilities.getField(view, "nextFinishOptionButton");
String nextFinishOptionButtonText = nextFinishOptionButton.getText();
// Check view displays first step view
assertEquals("First step view class isn't correct",
ControllerTest.FirstStepView.class,
((BorderLayout)((JPanel)view.getMessage()).getLayout()).getLayoutComponent(BorderLayout.CENTER).getClass());
// Check back button is disabled and next button is enabled
assertFalse("Back button isn't disabled", backOptionButton.isEnabled());
assertTrue("Next button isn't enabled", nextFinishOptionButton.isEnabled());
// 2. Click on nextFinishButton
JComponentTester tester = new JComponentTester();
tester.invokeAndWait(new Runnable() {
public void run() {
nextFinishOptionButton.doClick();
}
});
// Check view displays second step view
assertEquals("Second step view class isn't correct",
ControllerTest.SecondStepView.class,
((BorderLayout)((JPanel)view.getMessage()).getLayout()).getLayoutComponent(BorderLayout.CENTER).getClass());
// Check back button is enabled and next button is disabled
assertTrue("Back button isn't enabled", backOptionButton.isEnabled());
assertFalse("Next button isn't disabled", nextFinishOptionButton.isEnabled());
// Check next button text changed
assertFalse("Next button text didn't changed",
nextFinishOptionButton.getText().equals(nextFinishOptionButtonText));
// 3. Click on backButton
tester.invokeAndWait(new Runnable() {
public void run() {
backOptionButton.doClick();
}
});
// Check view displays first step view
assertEquals("First step view class isn't correct",
ControllerTest.FirstStepView.class,
((BorderLayout)((JPanel)view.getMessage()).getLayout()).getLayoutComponent(BorderLayout.CENTER).getClass());
// Check back button is disabled and next button is enabled
assertFalse("Back button isn't disabled", backOptionButton.isEnabled());
assertTrue("Next button isn't enabled", nextFinishOptionButton.isEnabled());
// Check next button text changed back to its first value
assertEquals("Next button text didn't changed",
nextFinishOptionButtonText, nextFinishOptionButton.getText());
// 4. Click on nextFinishButton
tester.invokeAndWait(new Runnable() {
public void run() {
nextFinishOptionButton.doClick();
}
});
// Check view displays second step view
assertEquals("Second step view class isn't correct",
ControllerTest.SecondStepView.class,
((BorderLayout)((JPanel)view.getMessage()).getLayout()).getLayoutComponent(BorderLayout.CENTER).getClass());
// Check the check box in second step view isn't selected
final JCheckBox yesCheckBox = (JCheckBox)TestUtilities.findComponent(view, JCheckBox.class);
assertFalse("Check box is selected", yesCheckBox.isSelected());
// Select the check box in second step view
tester.invokeAndWait(new Runnable() {