Source Code Cross Referenced for StepEditorTest.java in  » Testing » abbot-1.0.1 » abbot » editor » editors » 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 » abbot 1.0.1 » abbot.editor.editors 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package abbot.editor.editors;
002:
003:        import java.awt.event.*;
004:        import javax.swing.*;
005:
006:        import junit.extensions.abbot.*;
007:        import abbot.finder.matchers.*;
008:        import abbot.script.*;
009:        import abbot.tester.*;
010:
011:        /** Verify StepEditor operation. */
012:
013:        public class StepEditorTest extends ResolverFixture {
014:
015:            private Step step;
016:            private DefaultStepEditor editor;
017:            private String description = "default value";
018:            private JTextComponentTester tester = new JTextComponentTester();
019:            private JTextField textField;
020:
021:            private class DefaultStepEditor extends StepEditor {
022:                JTextField text;
023:
024:                public DefaultStepEditor(Step s) {
025:                    super (s);
026:                    text = addTextField("dummy field", "empty");
027:                }
028:
029:                public void actionPerformed(ActionEvent e) {
030:                    if (e.getSource() == text) {
031:                        StepEditorTest.this .description = text.getText();
032:                        // tell the editor the underlying step data has changed
033:                        fireStepChanged();
034:                    } else {
035:                        super .actionPerformed(e);
036:                    }
037:                }
038:
039:                public void descriptionChanged() {
040:                    fireStepChanged();
041:                }
042:            }
043:
044:            protected void setUp() throws Exception {
045:                step = new Step(getResolver(), (String) null) {
046:                    public String getDefaultDescription() {
047:                        return description;
048:                    }
049:
050:                    public String getUsage() {
051:                        return null;
052:                    }
053:
054:                    public String getXMLTag() {
055:                        return "step";
056:                    }
057:
058:                    public void runStep() {
059:                    }
060:                };
061:                editor = new DefaultStepEditor(step);
062:                textField = (JTextField) getFinder().find(editor,
063:                        new ClassMatcher(JTextField.class));
064:            }
065:
066:            public void testInit() {
067:                showFrame(editor);
068:                assertEquals("Step should match text field", step
069:                        .getDescription(), textField.getText());
070:            }
071:
072:            public void testRevertDescription() {
073:                showFrame(editor);
074:                textField.setText("");
075:                String text = step.getDescription();
076:                tester.actionEnterText(textField, "dummy");
077:                tester.actionKeyStroke(textField, KeyEvent.VK_ESCAPE);
078:                assertEquals("Text not reverted", text, textField.getText());
079:                assertEquals("Description not reverted", text, step
080:                        .getDescription());
081:            }
082:
083:            public void testSetDescription() {
084:                showFrame(editor);
085:                assertEquals("Wrong initial description", description,
086:                        textField.getText());
087:                textField.setText("");
088:                tester.actionEnterText(textField, "hello");
089:                assertEquals("Text entry did not change step data", "hello",
090:                        step.getDescription());
091:
092:                // Clearing it should result in the default description
093:                description = "default";
094:                textField.setText("");
095:                tester.actionKeyStroke(textField, KeyEvent.VK_ENTER);
096:                assertEquals("Step should revert to default when cleared",
097:                        description, step.getDescription());
098:                assertEquals(
099:                        "Text field should revert to default when cleared",
100:                        description, textField.getText());
101:
102:                // Now edit with key input
103:                tester.actionSetCaretPosition(textField, textField.getText()
104:                        .length());
105:                tester.actionKeyStroke(textField, KeyEvent.VK_BACK_SPACE);
106:                assertEquals("Step should be properly edited", description
107:                        .substring(0, description.length() - 1), textField
108:                        .getText());
109:            }
110:
111:            public void testClearDescription() {
112:                // clearing followed by enter or focus change should revert to default
113:                showFrame(editor);
114:                tester.actionSelectText(textField, 0, step.getDescription()
115:                        .length());
116:                tester.actionKeyStroke(textField, KeyEvent.VK_BACK_SPACE);
117:                tester.actionKeyStroke(textField, KeyEvent.VK_ENTER);
118:                assertEquals("Step should revert to default description", step
119:                        .getDefaultDescription(), step.getDescription());
120:                assertEquals("Text field should revert to default description",
121:                        step.getDefaultDescription(), textField.getText());
122:            }
123:
124:            public void testUpdateDefaultDescription() throws Throwable {
125:                showFrame(editor);
126:                // Change from underlying step data
127:                description = "something else";
128:                editor.descriptionChanged();
129:                assertEquals("Editor didn't pick up underlying data change",
130:                        description, textField.getText());
131:
132:                // Change from other field which affects the description should cause
133:                // the description field to update if the description is the default
134:                tester.actionKeyString(editor.text, "hello");
135:                assertEquals(
136:                        "Description  didn't change in response to step data",
137:                        description, textField.getText());
138:                // Remove the description, it should be restored
139:                textField.setText("");
140:                tester.actionKeyStroke(editor.text, KeyEvent.VK_ENTER);
141:                assertEquals(
142:                        "Description should revert to default when removed",
143:                        description, textField.getText());
144:            }
145:
146:            /** Construct a test case with the given name. */
147:            public StepEditorTest(String name) {
148:                super (name);
149:            }
150:
151:            /** Run the default test suite. */
152:            public static void main(String[] args) {
153:                TestHelper.runTests(args, StepEditorTest.class);
154:            }
155:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.