Testing JFC Components: Testing Menus and Toolbars
Verifying the contents of an AWT menu required the use of the JavaStar API. However, you can verify JFC menus and toolbars while recording. This section allows you to try that verification.
- If you are still in the Record/Playback window with SwingSet running, you can just record a different script here. If you are not in that window, Click Create test script and start the applet.
- Record a script. Name it
testMenu
.
- Select the Menus & ToolBars tabbed pane from the Swingset applet.
Check a Menu Bar Label
- Verify that the Colors menu item has the correct label. Click Verify, and select the Color menu.
- JavaStar will suggest using the Gold File as a default. Since we just want to check the label, click Customize.
- Select Using simple methods and data items, and click Select simple methods and data items.
- Choose the method
getLabel()
, and click Enter a purpose.
- Enter a purpose if you'd like, and click Insert verification into test.
- Click Continue.
Check a Menu Item's Mnemonic
Continue to record the test. Verify that the proper mnemonic was used for a menu item.
- Pull down the File menu on the tabbed pane. Use the sample menu on the pane, not the real one for the SwingSet applet.
Leave the menu pulled down, and return to the Record/Playback window.
- Click Verify. Return to the applet, and select the Save menu item.
- Return to the Record/Playback window. Click Customize.
- Select Using simple methods and data items, and select the
getMnemonic()
method.
- Click Enter a purpose, and Insert verification into test.
Check a Toolbar
The ability to use abstract buttons with images, rather than text, in them makes the creation of a button icon easy when using JFC components. You can verify these buttons. Verify to see if a button is enabled. This continues the test we are building, and selects a button on a toolbar within the Menus and Toolbar tabbed pane.
- Click Verify.
- Select a toolbar button on the tabbed pane. We chose the Paste button at the end of the bar.
Notice the code that was generated. The button was labeled with the word "paste
" rather than a sequential number. The text map we used chooses the tool tip for a label of some components.
JS.lookup("Main SwingSet Panel").
member("com.sun.java.swing.JButton", "paste")
- Return to the playback window, and click Customize.
- Click Using enabled.
- Click Enter a purpose, and Insert verification into test.
- Click Continue, and stop the recording.
- Playback the recording.
Now try a more complex component that will use the non-component locator, and use the JavaStar API to test it.
Send feedback to
JavaStar-feedback@suntest.com
Copyright © 1998
Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, CA 94303.
All rights reserved.