Source Code Cross Referenced for TabPanelTest.java in  » Ajax » GWT » com » google » gwt » user » client » ui » 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 » Ajax » GWT » com.google.gwt.user.client.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2007 Google Inc.
003:         * 
004:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005:         * use this file except in compliance with the License. You may obtain a copy of
006:         * the License at
007:         * 
008:         * http://www.apache.org/licenses/LICENSE-2.0
009:         * 
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013:         * License for the specific language governing permissions and limitations under
014:         * the License.
015:         */
016:        package com.google.gwt.user.client.ui;
017:
018:        import com.google.gwt.junit.client.GWTTestCase;
019:
020:        import java.util.Iterator;
021:
022:        /**
023:         * Tests the TabPanel.
024:         */
025:        public class TabPanelTest extends GWTTestCase {
026:
027:            static class Adder implements  HasWidgetsTester.WidgetAdder {
028:                public void addChild(HasWidgets container, Widget child) {
029:                    ((TabPanel) container).add(child, "foo");
030:                }
031:            }
032:
033:            public String getModuleName() {
034:                return "com.google.gwt.user.User";
035:            }
036:
037:            public void testAttachDetachOrder() {
038:                HasWidgetsTester.testAll(new TabPanel(), new Adder());
039:            }
040:
041:            public void testInsertMultipleTimes() {
042:                TabPanel p = new TabPanel();
043:
044:                TextBox tb = new TextBox();
045:                p.add(tb, "Title");
046:                p.add(tb, "Title");
047:                p.add(tb, "Title3");
048:
049:                assertEquals(1, p.getWidgetCount());
050:                assertEquals(0, p.getWidgetIndex(tb));
051:                Iterator i = p.iterator();
052:                assertTrue(i.hasNext());
053:                assertTrue(tb.equals(i.next()));
054:                assertFalse(i.hasNext());
055:
056:                Label l = new Label();
057:                p.add(l, "Title");
058:                p.add(l, "Title");
059:                p.add(l, "Title3");
060:                assertEquals(2, p.getWidgetCount());
061:                assertEquals(0, p.getWidgetIndex(tb));
062:                assertEquals(1, p.getWidgetIndex(l));
063:
064:                p.insert(l, "Title", 0);
065:                assertEquals(2, p.getWidgetCount());
066:                assertEquals(0, p.getWidgetIndex(l));
067:                assertEquals(1, p.getWidgetIndex(tb));
068:
069:                p.insert(l, "Title", 1);
070:                assertEquals(2, p.getWidgetCount());
071:                assertEquals(0, p.getWidgetIndex(l));
072:                assertEquals(1, p.getWidgetIndex(tb));
073:
074:                p.insert(l, "Title", 2);
075:                assertEquals(2, p.getWidgetCount());
076:                assertEquals(0, p.getWidgetIndex(tb));
077:                assertEquals(1, p.getWidgetIndex(l));
078:            }
079:
080:            public void testInsertWithHTML() {
081:                TabPanel p = new TabPanel();
082:                Label l = new Label();
083:                p.add(l, "three");
084:                p.insert(new HTML("<b>hello</b>"), "two", true, 0);
085:                p.insert(new HTML("goodbye"), "one", false, 0);
086:                assertEquals(3, p.getWidgetCount());
087:            }
088:
089:            /**
090:             * Tests to ensure that arbitrary widgets can be added/inserted effectively.
091:             */
092:            public void testInsertWithWidgets() {
093:                TabPanel p = new TabPanel();
094:
095:                TextBox wa = new TextBox();
096:                CheckBox wb = new CheckBox();
097:                VerticalPanel wc = new VerticalPanel();
098:                wc.add(new Label("First"));
099:                wc.add(new Label("Second"));
100:
101:                p.add(new Label("Content C"), wc);
102:                p.insert(new Label("Content B"), wb, 0);
103:                p.insert(new Label("Content A"), wa, 0);
104:
105:                // Call these to ensure we don't throw an exception.
106:                assertTrue(p.getTabBar().getTabHTML(0).length() > 0);
107:                assertTrue(p.getTabBar().getTabHTML(1).length() > 0);
108:                assertTrue(p.getTabBar().getTabHTML(2).length() > 0);
109:                assertEquals(3, p.getWidgetCount());
110:            }
111:
112:            public void testIterator() {
113:                TabPanel p = new TabPanel();
114:                HTML foo = new HTML("foo");
115:                HTML bar = new HTML("bar");
116:                HTML baz = new HTML("baz");
117:                p.add(foo, "foo");
118:                p.add(bar, "bar");
119:                p.add(baz, "baz");
120:
121:                // Iterate over the entire set and make sure it stops correctly.
122:                Iterator it = p.iterator();
123:                assertTrue(it.hasNext());
124:                assertTrue(it.next() == foo);
125:                assertTrue(it.hasNext());
126:                assertTrue(it.next() == bar);
127:                assertTrue(it.hasNext());
128:                assertTrue(it.next() == baz);
129:                assertFalse(it.hasNext());
130:
131:                // Test removing using the iterator.
132:                it = p.iterator();
133:                it.next();
134:                it.remove();
135:                assertTrue(it.next() == bar);
136:                assertTrue(p.getWidgetCount() == 2);
137:                assertTrue(p.getWidget(0) == bar);
138:                assertTrue(p.getWidget(1) == baz);
139:            }
140:
141:            public void testSelectionEvents() {
142:                TabPanel p = new TabPanel();
143:                RootPanel.get().add(p);
144:
145:                p.add(new Button("foo"), "foo");
146:                p.add(new Button("bar"), "bar");
147:
148:                // Make sure selecting a tab fires both events in the right order.
149:                p.addTabListener(new TabListener() {
150:                    private boolean onBeforeFired;
151:
152:                    public boolean onBeforeTabSelected(SourcesTabEvents sender,
153:                            int tabIndex) {
154:                        onBeforeFired = true;
155:                        return true;
156:                    }
157:
158:                    public void onTabSelected(SourcesTabEvents sender,
159:                            int tabIndex) {
160:                        assertTrue(onBeforeFired);
161:                        finishTest();
162:                    }
163:                });
164:
165:                this .delayTestFinish(1000);
166:                p.selectTab(1);
167:            }
168:
169:            public void testUnmodifiableDeckPanelSubclasses() {
170:                TabPanel p = new TabPanel();
171:                DeckPanel d = p.getDeckPanel();
172:
173:                try {
174:                    d.add(new Label("No"));
175:                    fail("Internal DeckPanel should not allow add() method");
176:                } catch (UnsupportedOperationException e) {
177:                    // Expected behavior
178:                }
179:
180:                try {
181:                    d.insert(new Label("No"), 0);
182:                    fail("Internal DeckPanel should not allow insert() method");
183:                } catch (UnsupportedOperationException e) {
184:                    // Expected behavior
185:                }
186:
187:                try {
188:                    d.clear();
189:                    fail("Internal DeckPanel should not allow clear() method");
190:                } catch (UnsupportedOperationException e) {
191:                    // Expected behavior
192:                }
193:            }
194:
195:            public void testUnmodifiableTabBarSubclasses() {
196:                TabPanel p = new TabPanel();
197:                TabBar b = p.getTabBar();
198:
199:                try {
200:                    b.addTab("no");
201:                    fail("Internal TabBar should not allow addTab() method");
202:                } catch (UnsupportedOperationException e) {
203:                    // Expected behavior
204:                }
205:
206:                try {
207:                    b.addTab("no", true);
208:                    fail("Internal TabBar should not allow addTab() method");
209:                } catch (UnsupportedOperationException e) {
210:                    // Expected behavior
211:                }
212:
213:                try {
214:                    b.addTab(new Label("no"));
215:                    fail("Internal TabBar should not allow addTab() method");
216:                } catch (UnsupportedOperationException e) {
217:                    // Expected behavior
218:                }
219:
220:                try {
221:                    b.insertTab("no", 0);
222:                    fail("Internal TabBar should not allow insertTab() method");
223:                } catch (UnsupportedOperationException e) {
224:                    // Expected behavior
225:                }
226:
227:                try {
228:                    b.insertTab("no", true, 0);
229:                    fail("Internal TabBar should not allow insertTab() method");
230:                } catch (UnsupportedOperationException e) {
231:                    // Expected behavior
232:                }
233:
234:                try {
235:                    b.insertTab(new Label("no"), 0);
236:                    fail("Internal TabBar should not allow insertTab() method");
237:                } catch (UnsupportedOperationException e) {
238:                    // Expected behavior
239:                }
240:
241:                try {
242:                    b.removeTab(0);
243:                    fail("Internal TabBar should not allow removeTab() method");
244:                } catch (UnsupportedOperationException e) {
245:                    // Expected behavior
246:                }
247:            }
248:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.