01: package com.canoo.webtest.extension.applet.jemmy;
02:
03: import org.netbeans.jemmy.ComponentChooser;
04:
05: import java.awt.Component;
06:
07: /**
08: * Specifies criteria for component lookup basing on the type of the component.
09: * This chooser takes a String instead of a Class to reduce the coupling between the applet and the scenario.
10: *
11: * @author Denis N. Antonioli
12: */
13: public class ClassNameComponentChooser implements ComponentChooser {
14: private final String fDescription;
15: private final String fClassName;
16:
17: /**
18: * Creates an instance to search for a component by the name of its class.
19: *
20: * @param description A description for the chooser.
21: * @param className Expected component class name.
22: */
23: public ClassNameComponentChooser(final String description,
24: final String className) {
25: fDescription = description;
26: fClassName = className;
27: }
28:
29: public boolean checkComponent(Component comp) {
30: return comp.getClass().getName().equals(fClassName);
31: }
32:
33: public String getDescription() {
34: return "component '" + fDescription + "'";
35: }
36: }
|