public class FontChooserTest
extends junit.framework.TestCase
Title: Test the font chooser
Description:
Copyright: Copyright (c) 2006-2014
Company:
Modifier and Type | Field and Description |
---|---|
private javax.swing.JCheckBox |
bold
Attribute: bold
|
private javax.swing.JButton |
cancel
Cancel button - close dialog and discard changes
|
private FontChooser |
chooser
The font chooser instance
|
private static int |
DEFAULT_FONT_SIZE
Default font size to choose
|
private javax.swing.JComboBox |
fontName
Font name choices
|
private javax.swing.JTextField |
fontSize
Font size entry
|
private javax.swing.JCheckBox |
italic
Attribute: italic
|
private static org.apache.log4j.Logger |
LOGGER
Logger
|
private javax.swing.JButton |
ok
Ok button - close dialog and keep changes
|
Constructor and Description |
---|
FontChooserTest()
Setup the test class
|
Modifier and Type | Method and Description |
---|---|
private void |
cancelDialog()
Mimic pressing the Cancel button
|
private void |
closeDialog()
Mimic pressing the Ok button
|
private void |
displayComponents(java.awt.Component[] components,
int level)
Loop through the collection of components and process the component based
on the type of component
|
private void |
findControls()
Find the controls on the dialog
|
private void |
processContainer(javax.swing.JLayeredPane pane,
int level)
Obtain the components in a layered pane and call display on them
|
private void |
processContainer(javax.swing.JPanel panel,
int level)
Obtain the components on the panel and call display on them
|
private void |
processContainer(javax.swing.JRootPane pane,
int level)
Obtain the components on the pane and call display on them
|
private void |
processJButton(javax.swing.JButton button,
int level)
Process the event on a button.
|
private void |
processJCheckBox(javax.swing.JCheckBox box,
int level)
Process the event on a checkbox.
|
private void |
processJComboBox(javax.swing.JComboBox box,
int level)
Use the current value in the combobox as the chosen font name
|
private void |
processJTextField(javax.swing.JTextField field,
int level)
Use the current value of the text field as the font size
|
void |
setUp()
Setup the test
|
void |
testBoldControl()
Test selecting the bold checkbox
|
void |
testCancel()
Test canceling the dialog
|
void |
testFontNameControl()
Test selecting a font name
|
void |
testFontSizeControl()
Test choosing a font size
|
void |
testGetNewFont()
Test getting the new font
|
void |
testItalicControl()
Test selecting the italic checkbox
|
void |
testWindowClose()
Test closing the dialog directly
|
countTestCases, createResult, getName, run, run, runBare, runTest, setName, tearDown, toString
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
private static final org.apache.log4j.Logger LOGGER
private static final int DEFAULT_FONT_SIZE
private FontChooser chooser
private javax.swing.JButton ok
private javax.swing.JButton cancel
private javax.swing.JComboBox fontName
private javax.swing.JTextField fontSize
private javax.swing.JCheckBox bold
private javax.swing.JCheckBox italic
public void setUp()
setUp
in class junit.framework.TestCase
public void testGetNewFont()
public void testCancel()
public void testWindowClose()
public void testFontSizeControl()
public void testBoldControl()
public void testItalicControl()
public void testFontNameControl()
private void findControls()
private void processContainer(javax.swing.JRootPane pane, int level)
pane
- The pane containing a set of componentslevel
- The recursive depth leveldisplayComponents(Component[], int)
private void processContainer(javax.swing.JPanel panel, int level)
panel
- The panel containing a set of componentslevel
- The recursive depth leveldisplayComponents(Component[], int)
private void processContainer(javax.swing.JLayeredPane pane, int level)
pane
- The layered pan containing a set of componentslevel
- The recursive depth leveldisplayComponents(Component[], int)
private void processJButton(javax.swing.JButton button, int level)
button
- The buttonlevel
- The recursive depth levelprivate void processJCheckBox(javax.swing.JCheckBox box, int level)
box
- The checkboxlevel
- The recursive depth levelprivate void processJComboBox(javax.swing.JComboBox box, int level)
box
- The comboboxlevel
- The recursive depth levelprivate void processJTextField(javax.swing.JTextField field, int level)
field
- The test fieldlevel
- The recursive depth levelprivate void displayComponents(java.awt.Component[] components, int level)
components
- The collection of componentslevel
- The recursive depth levelprocessContainer(JLayeredPane, int)
,
processContainer(JPanel, int)
,
processContainer(JRootPane, int)
,
processJButton(JButton, int)
,
processJCheckBox(JCheckBox, int)
,
processJComboBox(JComboBox, int)
,
processJTextField(JTextField, int)
private void closeDialog()
private void cancelDialog()