Source Code Cross Referenced for JTabbedPaneTest.java in  » Testing » jacareto » jacareto » test » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » jacareto » jacareto.test 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Jacareto Copyright (c) 2002-2005
003:         * Applied Computer Science Research Group, Darmstadt University of
004:         * Technology, Institute of Mathematics & Computer Science,
005:         * Ludwigsburg University of Education, and Computer Based
006:         * Learning Research Group, Aachen University. All rights reserved.
007:         *
008:         * Jacareto is free software; you can redistribute it and/or
009:         * modify it under the terms of the GNU General Public
010:         * License as published by the Free Software Foundation; either
011:         * version 2 of the License, or (at your option) any later version.
012:         *
013:         * Jacareto is distributed in the hope that it will be useful,
014:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
015:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
016:         * General Public License for more details.
017:         *
018:         * You should have received a copy of the GNU General Public
019:         * License along with Jacareto; if not, write to the Free
020:         * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
021:         *
022:         */
023:
024:        package jacareto.test;
025:
026:        import jacareto.comp.Components;
027:        import jacareto.system.Environment;
028:
029:        import java.awt.Component;
030:
031:        import java.util.Iterator;
032:
033:        import javax.swing.JTabbedPane;
034:
035:        /**
036:         * Test class for testing <code>java.swing.JTabbedPane</code> components.  The following criteria
037:         * are tested by this class:
038:         * 
039:         * <ul>
040:         * <li>
041:         * <b>pane text</b> - testes if the text on the tested tabbed pane is correct
042:         * </li>
043:         * <li>
044:         * <b>selected index</b> - testes if the selected index of the tested tabbed pane is correct
045:         * </li>
046:         * </ul>
047:         * 
048:         *
049:         * @author <a href="mailto:cspannagel@web.de">Christian Spannagel</a>
050:         * @version 1.2
051:         */
052:        public class JTabbedPaneTest extends JComponentTest {
053:            /** Contains the expected selected index of the tested tabbed pane. */
054:            private int selectedIndex;
055:
056:            /** Contains the expected text of the tested tabbed pane. */
057:            private String paneText;
058:
059:            /**
060:             * Creates a new test with the specified values.
061:             *
062:             * @param env env the environment
063:             * @param componentName the name of the component
064:             * @param isIgnoring if the test result should be ignored
065:             * @param isCorrecting if the values of the component should be corrected when the test has
066:             *        failed
067:             * @param hasFocus if the component has the focus
068:             * @param isEnabled if the component is set enabled
069:             * @param selectedIndex index of the selected pane
070:             * @param paneText the text on the tabbed pane
071:             */
072:            public JTabbedPaneTest(Environment env, String componentName,
073:                    boolean isIgnoring, boolean isCorrecting, boolean hasFocus,
074:                    boolean isEnabled, int selectedIndex, String paneText) {
075:                super (env, componentName, isIgnoring, isCorrecting, hasFocus,
076:                        isEnabled);
077:                setSelectedIndex(selectedIndex);
078:                setPaneText(paneText);
079:            }
080:
081:            /**
082:             * Creates a new test with the values of the given component and default values.
083:             *
084:             * @param env the environment.
085:             * @param components the components instance
086:             * @param component the component to test. Must be of type
087:             *        <code>javax.swing.JToggleButton</code>.
088:             */
089:            public JTabbedPaneTest(Environment env, Components components,
090:                    Component component) {
091:                super (env, components, component);
092:                setSelectedIndex(((JTabbedPane) component).getSelectedIndex());
093:                setPaneText(((JTabbedPane) component)
094:                        .getTitleAt(((JTabbedPane) component)
095:                                .getSelectedIndex()));
096:            }
097:
098:            /**
099:             * Creates a new test with default values and no environment. The environment should be defined
100:             * with the method {@link jacareto.system.EnvironmentMember#setEnvironment(Environment)}
101:             * before environment instances will be accessed.
102:             */
103:            public JTabbedPaneTest() {
104:                this (null, "", false, false, false, true, 0, "");
105:            }
106:
107:            /**
108:             * DOCUMENT ME!
109:             *
110:             * @param selectedIndex the expected selected index of the tested tabbed pane.
111:             */
112:            public void setSelectedIndex(int selectedIndex) {
113:                this .selectedIndex = selectedIndex;
114:            }
115:
116:            /**
117:             * DOCUMENT ME!
118:             *
119:             * @return The expected selected index of the tested tabbed pane.
120:             */
121:            public int getSelectedIndex() {
122:                return selectedIndex;
123:            }
124:
125:            /**
126:             * @see jacareto.struct.StructureElement#getElementName()
127:             */
128:            public String getElementName() {
129:                return language.getString("Tests.JTabbedPaneTest.Name");
130:            }
131:
132:            /**
133:             * @see jacareto.struct.StructureElement#getElementDescription()
134:             */
135:            public String getElementDescription() {
136:                return language.getString("Tests.JTabbedPaneTest.Description");
137:            }
138:
139:            /**
140:             * @see jacareto.struct.StructureElement#toShortString()
141:             */
142:            public String toShortString() {
143:                return getElementName();
144:            }
145:
146:            /**
147:             * DOCUMENT ME!
148:             *
149:             * @return The expected text on the tested tabbed pane
150:             */
151:            public String getPaneText() {
152:                return paneText;
153:            }
154:
155:            /**
156:             * DOCUMENT ME!
157:             *
158:             * @param string the expected text on the tested tabbed pane
159:             */
160:            public void setPaneText(String string) {
161:                paneText = string;
162:            }
163:
164:            /**
165:             * @see jacareto.test.Test#evaluate(jacareto.comp.Components)
166:             */
167:            public boolean evaluate(Components components) {
168:                setLastIgnored(isIgnoring());
169:                setLastResult(false);
170:                setLastCorrected(false);
171:
172:                JTabbedPane pane = null;
173:
174:                // get the pane with the componentName
175:                Component component = components
176:                        .getComponent(getComponentName());
177:
178:                if (component == null) {
179:                    setEvaluationMessage(language
180:                            .getString("Tests.Test.Failure.NoComponent"));
181:
182:                    return false;
183:                }
184:
185:                if (!(component instanceof  JTabbedPane)) {
186:                    setEvaluationMessage(language
187:                            .getString("Tests.Test.Failure.WrongComponentType"));
188:
189:                    return false;
190:                }
191:
192:                pane = (JTabbedPane) component;
193:
194:                if (doTest(pane)) {
195:                    boolean result = true;
196:                    Iterator childIter = childrenIterator();
197:
198:                    while (childIter.hasNext() && result) {
199:                        result &= evaluateChild((Test) childIter.next(),
200:                                components);
201:                    }
202:
203:                    setLastResult(result);
204:
205:                    return result;
206:                }
207:
208:                if (isCorrecting()) {
209:                    //appendToEvaluationMessage("\n" + language.getString("Test.Correct"));
210:                    correct(pane);
211:                    setLastCorrected(true);
212:                }
213:
214:                //if(isIgnoring()) appendToEvaluationMessage("\n" + language.getString("Test.Ignored")); 
215:                return false;
216:            }
217:
218:            /**
219:             * @see jacareto.test.JComponentTest#doTest(java.awt.Component)
220:             */
221:            protected boolean doTest(Component component) {
222:                if (super .doTest(component)) {
223:                    JTabbedPane pane = (JTabbedPane) component;
224:
225:                    if (pane.getSelectedIndex() != getSelectedIndex()) {
226:                        setEvaluationMessage(language
227:                                .getString("Tests.JTabbedPaneTest.Failure.WrongIndex")
228:                                + "\n"
229:                                + language
230:                                        .getString("Tests.Test.Failure.Expected")
231:                                + ": "
232:                                + getSelectedIndex()
233:                                + "\n"
234:                                + language
235:                                        .getString("Tests.Test.Failure.Detected")
236:                                + ": " + pane.getSelectedIndex());
237:
238:                        return false;
239:                    }
240:
241:                    String currentText = pane.getTitleAt(pane
242:                            .getSelectedIndex());
243:                    String targetText = getPaneText();
244:
245:                    if (!(currentText.equals(getPaneText()))) {
246:                        setEvaluationMessage(language
247:                                .getString("Tests.TabbedPaneTest.Failure.WrongText")
248:                                + "\n"
249:                                + language
250:                                        .getString("Tests.Test.Failure.Expected")
251:                                + ": "
252:                                + targetText
253:                                + "\n"
254:                                + language
255:                                        .getString("Tests.Test.Failure.Detected")
256:                                + ": " + currentText);
257:
258:                        return false;
259:                    }
260:                } else {
261:                    return false;
262:                }
263:
264:                return true;
265:            }
266:
267:            /**
268:             * @see jacareto.test.JComponentTest#correct(java.awt.Component)
269:             */
270:            protected void correct(Component component) {
271:                super .correct(component);
272:
273:                JTabbedPane pane = (JTabbedPane) component;
274:
275:                if ((getSelectedIndex() >= 0)
276:                        && (getSelectedIndex() < pane.getTabCount())) {
277:                    pane.setSelectedIndex(getSelectedIndex());
278:                    pane.setTitleAt(pane.getSelectedIndex(), getPaneText());
279:                    appendToEvaluationMessage("\n"
280:                            + getElementName()
281:                            + ": "
282:                            + language
283:                                    .getString("Tests.JTabbedPaneTest.Correct.IndexAndTitle"));
284:                } else {
285:                    appendToEvaluationMessage("\n"
286:                            + getElementName()
287:                            + ": "
288:                            + language
289:                                    .getString("Tests.JTabbedPaneTest.Correct.IndexFailure"));
290:                }
291:            }
292:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.