frame, PrintPreviewPanel.class);
JToolBar toolBar =
(JToolBar)TestUtilities.getField(printPreviewPanel, "toolBar");
JButton previousButton = (JButton)toolBar.getComponent(0);
final JButton nextButton = (JButton)toolBar.getComponent(1);
HomePrintableComponent printableComponent =
(HomePrintableComponent)TestUtilities.getField(printPreviewPanel, "printableComponent");;
// Check if buttons are enabled and if printable component displays the first page
assertFalse("Previous button is enabled", previousButton.isEnabled());
assertTrue("Next button is disabled", nextButton.isEnabled());
assertEquals("Printable component doesn't display first page", 0, printableComponent.getPage());
assertEquals("Wrong printable component page count", 2, printableComponent.getPageCount());
// 6. Click on next page button
tester.invokeAndWait(new Runnable() {
public void run() {
nextButton.doClick();
}
});
// Check if buttons are enabled and if printable component displays the second page
assertTrue("Previous button is enabled", previousButton.isEnabled());
assertFalse("Next button is disabled", nextButton.isEnabled());
assertEquals("Printable component doesn't display second page", 1, printableComponent.getPage());
// Click on Ok in dialog box
final JOptionPane printPreviewOptionPane = (JOptionPane)TestUtilities.findComponent(
printPreviewDialog, JOptionPane.class);
tester.invokeAndWait(new Runnable() {