Source Code Cross Referenced for TestNewSetCurrent.java in  » 6.0-JDK-Modules » j2me » javax » microedition » lcdui » 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 » 6.0 JDK Modules » j2me » javax.microedition.lcdui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        /*
0002:         *  
0003:         *
0004:         * Copyright  1990-2007 Sun Microsystems, Inc. All Rights Reserved.
0005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
0006:         * 
0007:         * This program is free software; you can redistribute it and/or
0008:         * modify it under the terms of the GNU General Public License version
0009:         * 2 only, as published by the Free Software Foundation.
0010:         * 
0011:         * This program is distributed in the hope that it will be useful, but
0012:         * WITHOUT ANY WARRANTY; without even the implied warranty of
0013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0014:         * General Public License version 2 for more details (a copy is
0015:         * included at /legal/license.txt).
0016:         * 
0017:         * You should have received a copy of the GNU General Public License
0018:         * version 2 along with this work; if not, write to the Free Software
0019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
0020:         * 02110-1301 USA
0021:         * 
0022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
0023:         * Clara, CA 95054 or visit www.sun.com if you need additional
0024:         * information or have any questions.
0025:         */
0026:
0027:        package javax.microedition.lcdui;
0028:
0029:        import com.sun.midp.i3test.TestCase;
0030:        import com.sun.midp.util.LcduiTestMIDlet;
0031:        import com.sun.midp.util.LcduiTestCanvas;
0032:        import com.sun.midp.util.LiveTracer;
0033:        import com.sun.midp.util.LiveTraceCallback;
0034:        import com.sun.midp.util.LiveTraceListener;
0035:        import com.sun.midp.util.SerialCallback;
0036:
0037:        import javax.microedition.midlet.MIDlet;
0038:
0039:        /**
0040:         * Tests proper behavior of Display.setCurrent() for a single midlet in the
0041:         * foreground. Various combinations of "normal" (i.e., non-Alert) Displayable
0042:         * instances are tested with the one-arg and two-arg Alert forms of the
0043:         * setCurrent() method.
0044:         *
0045:         * The notation used to name tests is as follows.
0046:         *
0047:         * The operations initiated by the tests are:
0048:         *
0049:         * <code>
0050:         * N  setCurrent(normal [non-Alert] Displayable)
0051:         * A  setCurrent(Alert)
0052:         * 2  setCurrent(Alert, Displayable)
0053:         * D  dismiss the current Alert
0054:         * </code>
0055:         *
0056:         * Codes for context or waits for event processing are:
0057:         * <code>
0058:         * 0  tests Display's initial state (current == null)
0059:         * _  wait for a screen-change event to be processed
0060:         * s  suffix indicating a displayable is the same as a previous one
0061:         * </code>
0062:         *
0063:         * For example, testA_2 first calls setCurrent(alert1), waits for the alert to 
0064:         * become current, then calls setCurrent(alert2, disp1). Note that this 
0065:         * notation doesn't include an initial setCurrentWait() call that is typically 
0066:         * used to establish the initial state for the test. In such cases the initial 
0067:         * displayable will be numbered zero, that is, disp0 or cv0. This is in 
0068:         * contrast to displayables and alerts that are used in the operations being 
0069:         * tested, which are numbered starting at one.
0070:         *
0071:         * Quite often it is necessary to execute code atomically on the event thread,
0072:         * that is, ensuring that no events are processed within a group of 
0073:         * statements. Code running on the test thread is arbitrarily interleaved with 
0074:         * code running on the event thread. For example, suppose Displayable d0 is 
0075:         * current. If the following code were executed on the test thread,
0076:         *
0077:         * <code>
0078:         *     dpy.setCurrent(d1);
0079:         *     dpy.setCurrent(alert);
0080:         * </code>
0081:         *
0082:         * there would be a race condition between d1 becoming current and the call to
0083:         * setCurrent(alert). Runnable blocks are used to group a set of statements to
0084:         * be executed atomically.  Runnable blocks are used in two different ways:
0085:         * using callSerially() and using await(). In both cases the run() method is
0086:         * executed on the event thread. This prevents any other events from being
0087:         * dispatched in the midst of the code of the run() method.  For example:
0088:         *
0089:         * <code>
0090:         *     dpy.callSerially(
0091:         *         new Runnable() {
0092:         *             public void run() {
0093:         *                 // (1)
0094:         *             }
0095:         *         });
0096:         * 
0097:         *     scl.await(
0098:         *         new Runnable() {
0099:         *             public void run() {
0100:         *                 // (2)
0101:         *             }
0102:         *         });
0103:         * </code>
0104:         *
0105:         * The code (1) is executed atomically on the event thread, and the calling
0106:         * thread continues. The code (2) is executed atomically on the event thread
0107:         * immediately after the next screen change occurs. The calling thread is
0108:         * blocked until the screen change occurs and the run() method has completed.
0109:         */
0110:        public class TestNewSetCurrent extends TestCase {
0111:
0112:            Display dpy;
0113:            LiveTraceCallback scl; // scl = screen change listener
0114:            boolean thrown;
0115:
0116:            // ===== utility functions =====
0117:
0118:            /**
0119:             * Creates a new alert and sets its timeout to FOREVER so that it must be 
0120:             * dismissed explicitly.
0121:             */
0122:            Alert makeAlert(String title) {
0123:                Alert a = new Alert(title);
0124:                a.setTimeout(Alert.FOREVER);
0125:                return a;
0126:            }
0127:
0128:            /**
0129:             * Simulates dismissing an alert from this display. The logic here mimics 
0130:             * the logic of what occurs when the Alert times out and executes its 
0131:             * default (DISMISS) command. This allows tests to set the alert timeout 
0132:             * to FOREVER and to call this function in the right sequence, without 
0133:             * having to deal with timing issues.
0134:             */
0135:            void dismiss(Alert alert) {
0136:                synchronized (Display.LCDUILock) {
0137:                    alert.lDismiss();
0138:                }
0139:            }
0140:
0141:            /**
0142:             * Dismisses the alert and then waits for the resulting screen-change
0143:             * event to be processed.
0144:             */
0145:            void dismissWait(Alert alert) {
0146:                dismiss(alert);
0147:                scl.await();
0148:            }
0149:
0150:            /**
0151:             * Checks a variety of invariants on test canvas cv, depending upon 
0152:             * whether the canvas should or should not be current.
0153:             */
0154:            void checkCurrent(String s, LcduiTestCanvas cv, boolean isCurrent) {
0155:                if (isCurrent) {
0156:                    assertTrue(s + ".showCalled must be true", cv.showCalled());
0157:                    assertTrue(s + ".isShown must be true", cv.isShown());
0158:                    assertSame(s + " must be current", cv, dpy.getCurrent());
0159:                } else {
0160:                    assertFalse(s + ".showCalled must be false", cv
0161:                            .showCalled());
0162:                    assertFalse(s + ".isShown must be false", cv.isShown());
0163:                    assertNotSame(s + " must not be current", cv, dpy
0164:                            .getCurrent());
0165:                }
0166:            }
0167:
0168:            /**
0169:             * Checks a variety of invariants on an alert, depending upon 
0170:             * whether the alert should or should not be current.
0171:             */
0172:            void checkCurrent(String s, Alert alert, boolean shouldBeCurrent) {
0173:                if (shouldBeCurrent) {
0174:                    assertTrue(s + ".isShown must be true", alert.isShown());
0175:                    assertSame(s + " must be current", alert, dpy.getCurrent());
0176:                } else {
0177:                    assertFalse(s + ".isShown must be false", alert.isShown());
0178:                    assertNotSame(s + " must not be current", alert, dpy
0179:                            .getCurrent());
0180:                }
0181:            }
0182:
0183:            /**
0184:             * Sets the Displayable to be current, waits for it to become visible, and
0185:             * returns.
0186:             */
0187:            void setCurrentWait(Displayable d) {
0188:                dpy.setCurrent(d);
0189:                scl.await();
0190:            }
0191:
0192:            /**
0193:             * Creates the test MIDlet and get its display.
0194:             */
0195:            void init() throws Throwable {
0196:                dpy = new StubDisplay();
0197:                scl = new LiveTraceCallback();
0198:                dpy.liveTracer.add(Display.LTR_SCREENCHANGE_DONE, scl);
0199:            }
0200:
0201:            /**
0202:             * Cleans up the test MIDlet.
0203:             */
0204:            void fini() {
0205:                dpy.liveTracer.clear();
0206:                scl.shutdown();
0207:            }
0208:
0209:            // ===== the tests =====
0210:
0211:            /**
0212:             * Tests whether the display has been initialized properly.
0213:             */
0214:            void testInit() {
0215:                assertNotNull("dpy must be non-null", dpy);
0216:                assertNull("current must be null", dpy.getCurrent());
0217:            }
0218:
0219:            /**
0220:             * Case: 0A0A. Tests whether the system returns to the original (null)
0221:             * state after an alert. Does so twice in order to ensure that the first
0222:             * setCurrent doesn't have any side effects.  WARNING: this must be run on
0223:             * a fresh display.
0224:             */
0225:            void test0A0A() {
0226:                final Alert alert1 = makeAlert("alert1");
0227:                final Alert alert2 = makeAlert("alert2");
0228:
0229:                assertNull("current null", dpy.getCurrent());
0230:
0231:                setCurrentWait(alert1);
0232:                checkCurrent("alert1", alert1, true);
0233:
0234:                dismissWait(alert1);
0235:                checkCurrent("alert1", alert1, false);
0236:                assertNull("current null", dpy.getCurrent());
0237:
0238:                setCurrentWait(alert2);
0239:                checkCurrent("alert1", alert1, false);
0240:                checkCurrent("alert2", alert2, true);
0241:
0242:                dismissWait(alert2);
0243:                checkCurrent("alert1", alert1, false);
0244:                checkCurrent("alert2", alert2, false);
0245:                assertNull("current null", dpy.getCurrent());
0246:            }
0247:
0248:            /**
0249:             * Case: N.
0250:             */
0251:            void testN() {
0252:                LcduiTestCanvas cv1 = new LcduiTestCanvas();
0253:                setCurrentWait(cv1);
0254:                checkCurrent("cv1", cv1, true);
0255:            }
0256:
0257:            /**
0258:             * Case: A.
0259:             */
0260:            void testA() {
0261:                LcduiTestCanvas cv0 = new LcduiTestCanvas();
0262:                Alert alert = makeAlert("alert");
0263:
0264:                // establish initial conditions
0265:                setCurrentWait(cv0);
0266:                checkCurrent("cv0", cv0, true);
0267:
0268:                setCurrentWait(alert);
0269:                checkCurrent("alert", alert, true);
0270:                checkCurrent("cv0", cv0, false);
0271:
0272:                dismissWait(alert);
0273:                checkCurrent("alert", alert, false);
0274:                checkCurrent("cv0", cv0, true);
0275:            }
0276:
0277:            /**
0278:             * Case: 2.
0279:             */
0280:            void test2() {
0281:                LcduiTestCanvas cv0 = new LcduiTestCanvas();
0282:                LcduiTestCanvas cv1 = new LcduiTestCanvas();
0283:                Alert alert = makeAlert("alert");
0284:
0285:                // establish initial conditions
0286:                setCurrentWait(cv0);
0287:                checkCurrent("cv0", cv0, true);
0288:
0289:                dpy.setCurrent(alert, cv1);
0290:                scl.await();
0291:                checkCurrent("cv0", cv0, false);
0292:                checkCurrent("alert", alert, true);
0293:
0294:                dismissWait(alert);
0295:                checkCurrent("cv1", cv1, true);
0296:                checkCurrent("alert", alert, false);
0297:            }
0298:
0299:            /**
0300:             * Case: NN.
0301:             */
0302:            void testNN() {
0303:                final LcduiTestCanvas cv1 = new LcduiTestCanvas();
0304:                final LcduiTestCanvas cv2 = new LcduiTestCanvas();
0305:
0306:                // Use callSerially to make sure both setCurrent() calls
0307:                // occur before the first screen-change event is processed.
0308:
0309:                dpy.callSerially(new Runnable() {
0310:                    public void run() {
0311:                        dpy.setCurrent(cv1);
0312:                        dpy.setCurrent(cv2);
0313:                    }
0314:                });
0315:
0316:                // Use await(Runnable) to ensure that the assertion checks
0317:                // are done after the first screen-change event and before
0318:                // the second screen-change event.
0319:
0320:                scl.await(new Runnable() {
0321:                    public void run() {
0322:                        checkCurrent("cv1", cv1, true);
0323:                        checkCurrent("cv2", cv2, false);
0324:                    }
0325:                });
0326:
0327:                scl.await();
0328:                checkCurrent("cv1", cv1, false);
0329:                checkCurrent("cv2", cv2, true);
0330:            }
0331:
0332:            /**
0333:             * Case: NNsN.
0334:             */
0335:            void testNNsN() {
0336:                final LcduiTestCanvas cv1 = new LcduiTestCanvas();
0337:                final LcduiTestCanvas cv2 = new LcduiTestCanvas();
0338:
0339:                dpy.callSerially(new Runnable() {
0340:                    public void run() {
0341:                        dpy.setCurrent(cv1);
0342:                        dpy.setCurrent(cv1);
0343:                        dpy.setCurrent(cv2);
0344:                    }
0345:                });
0346:
0347:                scl.await(new Runnable() {
0348:                    public void run() {
0349:                        checkCurrent("cv1", cv1, true);
0350:                        checkCurrent("cv2", cv2, false);
0351:                    }
0352:                });
0353:
0354:                scl.await();
0355:                checkCurrent("cv1", cv1, false);
0356:                checkCurrent("cv2", cv2, true);
0357:            }
0358:
0359:            /**
0360:             * Case: N_N.
0361:             */
0362:            void testN_N() {
0363:                LcduiTestCanvas cv1 = new LcduiTestCanvas();
0364:                LcduiTestCanvas cv2 = new LcduiTestCanvas();
0365:
0366:                setCurrentWait(cv1);
0367:                checkCurrent("cv1", cv1, true);
0368:
0369:                setCurrentWait(cv2);
0370:                checkCurrent("cv1", cv1, false);
0371:                checkCurrent("cv2", cv2, true);
0372:            }
0373:
0374:            /**
0375:             * Case: N_NNs.
0376:             */
0377:            void testN_NNs() {
0378:                final LcduiTestCanvas cv1 = new LcduiTestCanvas();
0379:                final LcduiTestCanvas cv2 = new LcduiTestCanvas();
0380:
0381:                setCurrentWait(cv1);
0382:                checkCurrent("cv1", cv1, true);
0383:
0384:                dpy.callSerially(new Runnable() {
0385:                    public void run() {
0386:                        dpy.setCurrent(cv2);
0387:                        dpy.setCurrent(cv1);
0388:                    }
0389:                });
0390:
0391:                scl.await(new Runnable() {
0392:                    public void run() {
0393:                        checkCurrent("cv1", cv1, false);
0394:                        checkCurrent("cv2", cv2, true);
0395:                    }
0396:                });
0397:
0398:                scl.await();
0399:                checkCurrent("cv1", cv1, true);
0400:                checkCurrent("cv2", cv2, false);
0401:            }
0402:
0403:            /**
0404:             * Case: NA.
0405:             */
0406:            void testNA() {
0407:                final LcduiTestCanvas cv0 = new LcduiTestCanvas();
0408:                final LcduiTestCanvas cv1 = new LcduiTestCanvas();
0409:                final Alert alert = makeAlert("alert");
0410:
0411:                // establish initial conditions
0412:
0413:                setCurrentWait(cv0);
0414:                checkCurrent("cv0", cv0, true);
0415:
0416:                dpy.callSerially(new Runnable() {
0417:                    public void run() {
0418:                        dpy.setCurrent(cv1);
0419:                        dpy.setCurrent(alert);
0420:                    }
0421:                });
0422:
0423:                // wait for cv1 to become current
0424:
0425:                scl.await(new Runnable() {
0426:                    public void run() {
0427:                        checkCurrent("alert", alert, false);
0428:                        checkCurrent("cv0", cv0, false);
0429:                        checkCurrent("cv1", cv1, true);
0430:                    }
0431:                });
0432:
0433:                // wait for alert to become current
0434:
0435:                scl.await();
0436:                checkCurrent("alert", alert, true);
0437:                checkCurrent("cv0", cv0, false);
0438:                checkCurrent("cv1", cv1, false);
0439:
0440:                dismissWait(alert);
0441:
0442:                // This checks for the behavior reported as a CR in
0443:                // CR 6225060: after the alert is dismissed, current
0444:                // returns to cv0.
0445:                // checkCurrent("alert", alert, false);
0446:                // checkCurrent("cv0", cv0, true);
0447:                // checkCurrent("cv1", cv1, false);
0448:
0449:                // The following checks for behavior expected by most programs: after 
0450:                // the alert is dismissed, cv1 should become current, 
0451:                // because a setCurrent request on it was issued prior to the 
0452:                // setCurrent request on the alert.
0453:
0454:                checkCurrent("alert", alert, false);
0455:                checkCurrent("cv0", cv0, false);
0456:                checkCurrent("cv1", cv1, true);
0457:            }
0458:
0459:            /**
0460:             * Case: N2.
0461:             */
0462:            void testN2() {
0463:                final LcduiTestCanvas cv1 = new LcduiTestCanvas();
0464:                final LcduiTestCanvas cv2 = new LcduiTestCanvas();
0465:                final Alert alert = makeAlert("alert");
0466:
0467:                dpy.callSerially(new Runnable() {
0468:                    public void run() {
0469:                        dpy.setCurrent(cv1);
0470:                        dpy.setCurrent(alert, cv2);
0471:                    }
0472:                });
0473:
0474:                scl.await(new Runnable() {
0475:                    public void run() {
0476:                        checkCurrent("alert", alert, false);
0477:                        checkCurrent("cv1", cv1, true);
0478:                        checkCurrent("cv2", cv2, false);
0479:                    }
0480:                });
0481:
0482:                scl.await();
0483:                checkCurrent("alert", alert, true);
0484:                checkCurrent("cv1", cv1, false);
0485:                checkCurrent("cv2", cv2, false);
0486:
0487:                dismissWait(alert);
0488:                checkCurrent("alert", alert, false);
0489:                checkCurrent("cv1", cv1, false);
0490:                checkCurrent("cv2", cv2, true);
0491:            }
0492:
0493:            /**
0494:             * Case: AN.
0495:             */
0496:            void testAN() {
0497:                final LcduiTestCanvas cv0 = new LcduiTestCanvas();
0498:                final LcduiTestCanvas cv1 = new LcduiTestCanvas();
0499:                final Alert alert = makeAlert("alert");
0500:
0501:                // establish initial conditions
0502:                setCurrentWait(cv0);
0503:                checkCurrent("cv0", cv0, true);
0504:
0505:                dpy.callSerially(new Runnable() {
0506:                    public void run() {
0507:                        dpy.setCurrent(alert);
0508:                        dpy.setCurrent(cv1);
0509:                    }
0510:                });
0511:
0512:                scl.await(new Runnable() {
0513:                    public void run() {
0514:                        checkCurrent("alert", alert, true);
0515:                        checkCurrent("cv0", cv0, false);
0516:                        checkCurrent("cv1", cv1, false);
0517:                    }
0518:                });
0519:
0520:                dismissWait(alert);
0521:                checkCurrent("alert", alert, false);
0522:                checkCurrent("cv0", cv0, false);
0523:                checkCurrent("cv1", cv1, true);
0524:            }
0525:
0526:            /**
0527:             * Case: AND.
0528:             * Tests alert timeout while it's shown, while another screen change event 
0529:             * is in the queue.
0530:             */
0531:            void testAND() {
0532:                final LcduiTestCanvas cv0 = new LcduiTestCanvas();
0533:                final LcduiTestCanvas cv1 = new LcduiTestCanvas();
0534:                final Alert alert = makeAlert("alert");
0535:
0536:                // establish initial conditions
0537:                setCurrentWait(cv0);
0538:                checkCurrent("cv0", cv0, true);
0539:
0540:                dpy.callSerially(new Runnable() {
0541:                    public void run() {
0542:                        dpy.setCurrent(alert);
0543:                        dpy.setCurrent(cv1);
0544:                    }
0545:                });
0546:
0547:                scl.await(new Runnable() {
0548:                    public void run() {
0549:                        checkCurrent("alert", alert, true);
0550:                        checkCurrent("cv0", cv0, false);
0551:                        checkCurrent("cv1", cv1, false);
0552:                        dismiss(alert);
0553:                    }
0554:                });
0555:
0556:                scl.await(new Runnable() {
0557:                    public void run() {
0558:                        checkCurrent("alert", alert, false);
0559:                        checkCurrent("cv0", cv0, false);
0560:                        checkCurrent("cv1", cv1, true);
0561:                    }
0562:                });
0563:
0564:                // The setCurrent(cv1) call supersedes the
0565:                // alert, so dismissing the alert should not
0566:                // return to cv0.
0567:
0568:                new SerialCallback(dpy).invokeAndWait();
0569:                checkCurrent("alert", alert, false);
0570:                checkCurrent("cv0", cv0, false);
0571:                checkCurrent("cv1", cv1, true);
0572:            }
0573:
0574:            /**
0575:             * Case: A_N.
0576:             */
0577:            void testA_N() {
0578:                final LcduiTestCanvas cv0 = new LcduiTestCanvas();
0579:                final LcduiTestCanvas cv1 = new LcduiTestCanvas();
0580:                final Alert alert = makeAlert("alert");
0581:
0582:                // establish initial conditions
0583:                setCurrentWait(cv0);
0584:                checkCurrent("cv0", cv0, true);
0585:
0586:                dpy.setCurrent(alert);
0587:                scl.await();
0588:                checkCurrent("alert", alert, true);
0589:                checkCurrent("cv0", cv0, false);
0590:
0591:                setCurrentWait(cv1);
0592:                checkCurrent("alert", alert, false);
0593:                checkCurrent("cv0", cv0, false);
0594:                checkCurrent("cv1", cv1, true);
0595:
0596:                dismiss(alert);
0597:                new SerialCallback(dpy).invokeAndWait();
0598:                checkCurrent("alert", alert, false);
0599:                checkCurrent("cv0", cv0, false);
0600:                checkCurrent("cv1", cv1, true);
0601:            }
0602:
0603:            /**
0604:             * Case: AA.
0605:             */
0606:            void testAA() {
0607:                final LcduiTestCanvas cv0 = new LcduiTestCanvas();
0608:                final Alert alert1 = makeAlert("alert1");
0609:                final Alert alert2 = makeAlert("alert2");
0610:
0611:                // establish initial conditions
0612:                setCurrentWait(cv0);
0613:                checkCurrent("cv0", cv0, true);
0614:
0615:                thrown = false;
0616:                new SerialCallback(dpy) {
0617:                    public void run() {
0618:                        dpy.setCurrent(alert1);
0619:                        try {
0620:                            dpy.setCurrent(alert2);
0621:                        } catch (IllegalArgumentException iae) {
0622:                            thrown = true;
0623:                        }
0624:                    }
0625:                }.invokeAndWait();
0626:
0627:                scl.await();
0628:                checkCurrent("alert1", alert1, true);
0629:                assertTrue("IAE should be thrown", thrown);
0630:
0631:                dismissWait(alert1);
0632:                checkCurrent("cv0", cv0, true);
0633:                checkCurrent("alert1", alert1, false);
0634:                checkCurrent("alert2", alert2, false);
0635:            }
0636:
0637:            /**
0638:             * Case: AAs.
0639:             */
0640:            void testAAs() {
0641:                final LcduiTestCanvas cv0 = new LcduiTestCanvas();
0642:                final Alert alert1 = makeAlert("alert1");
0643:
0644:                // establish initial conditions
0645:                setCurrentWait(cv0);
0646:                checkCurrent("cv0", cv0, true);
0647:
0648:                thrown = false;
0649:                new SerialCallback(dpy) {
0650:                    public void run() {
0651:                        dpy.setCurrent(alert1);
0652:                        try {
0653:                            dpy.setCurrent(alert1);
0654:                        } catch (IllegalArgumentException iae) {
0655:                            thrown = true;
0656:                        }
0657:                    }
0658:                }.invokeAndWait();
0659:
0660:                scl.await();
0661:                checkCurrent("alert1", alert1, true);
0662:                assertFalse("IAE should not be thrown", thrown);
0663:
0664:                dismissWait(alert1);
0665:                checkCurrent("cv0", cv0, true);
0666:                checkCurrent("alert1", alert1, false);
0667:            }
0668:
0669:            /**
0670:             * Tests setCurrent(Alert) when an alert is already visible.
0671:             * Case: A_A.
0672:             */
0673:            void testA_A() {
0674:                LcduiTestCanvas cv0 = new LcduiTestCanvas();
0675:                Alert alert1 = makeAlert("alert1");
0676:                Alert alert2 = makeAlert("alert2");
0677:
0678:                // establish initial conditions
0679:                setCurrentWait(cv0);
0680:                checkCurrent("cv0", cv0, true);
0681:
0682:                setCurrentWait(alert1);
0683:                checkCurrent("cv0", cv0, false);
0684:                checkCurrent("alert1", alert1, true);
0685:
0686:                thrown = false;
0687:                try {
0688:                    dpy.setCurrent(alert2);
0689:                } catch (IllegalArgumentException iae) {
0690:                    thrown = true;
0691:                }
0692:                assertTrue("IAE should be thrown", thrown);
0693:
0694:                dismissWait(alert1);
0695:                checkCurrent("cv0", cv0, true);
0696:                checkCurrent("alert1", alert1, false);
0697:                checkCurrent("alert2", alert2, false);
0698:            }
0699:
0700:            /**
0701:             * Tests setCurrent on the same alert when it is already visible.
0702:             * Case: A_As.
0703:             */
0704:            void testA_As() {
0705:                LcduiTestCanvas cv0 = new LcduiTestCanvas();
0706:                Alert alert1 = makeAlert("alert1");
0707:
0708:                // establish initial conditions
0709:                setCurrentWait(cv0);
0710:                checkCurrent("cv0", cv0, true);
0711:
0712:                setCurrentWait(alert1);
0713:                checkCurrent("cv0", cv0, false);
0714:                checkCurrent("alert1", alert1, true);
0715:
0716:                thrown = false;
0717:                try {
0718:                    dpy.setCurrent(alert1);
0719:                } catch (IllegalArgumentException iae) {
0720:                    thrown = true;
0721:                }
0722:                assertFalse("IAE should not be thrown", thrown);
0723:
0724:                dismissWait(alert1);
0725:                checkCurrent("cv0", cv0, true);
0726:                checkCurrent("alert1", alert1, false);
0727:            }
0728:
0729:            /**
0730:             * Case: A2.
0731:             */
0732:            void testA2() {
0733:                final LcduiTestCanvas cv0 = new LcduiTestCanvas();
0734:                final LcduiTestCanvas cv1 = new LcduiTestCanvas();
0735:                final Alert alert1 = makeAlert("alert1");
0736:                final Alert alert2 = makeAlert("alert2");
0737:
0738:                // establish initial conditions
0739:                setCurrentWait(cv0);
0740:                checkCurrent("cv0", cv0, true);
0741:
0742:                dpy.callSerially(new Runnable() {
0743:                    public void run() {
0744:                        dpy.setCurrent(alert1);
0745:                        dpy.setCurrent(alert2, cv1);
0746:                    }
0747:                });
0748:
0749:                scl.await(new Runnable() {
0750:                    public void run() {
0751:                        checkCurrent("alert1", alert1, true);
0752:                        checkCurrent("alert2", alert2, false);
0753:                        checkCurrent("cv0", cv0, false);
0754:                        checkCurrent("cv1", cv1, false);
0755:                    }
0756:                });
0757:
0758:                scl.await(new Runnable() {
0759:                    public void run() {
0760:                        checkCurrent("alert1", alert1, false);
0761:                        checkCurrent("alert2", alert2, true);
0762:                        checkCurrent("cv0", cv0, false);
0763:                        checkCurrent("cv1", cv1, false);
0764:                        dismiss(alert1);
0765:                    }
0766:                });
0767:
0768:                // Dismissing alert1 should do nothing, since it has
0769:                // been superseded by alert2.
0770:
0771:                new SerialCallback(dpy).invokeAndWait();
0772:                checkCurrent("alert1", alert1, false);
0773:                checkCurrent("alert2", alert2, true);
0774:                checkCurrent("cv0", cv0, false);
0775:                checkCurrent("cv1", cv1, false);
0776:
0777:                dismissWait(alert2);
0778:                checkCurrent("alert1", alert1, false);
0779:                checkCurrent("alert2", alert2, false);
0780:                checkCurrent("cv0", cv0, false);
0781:                checkCurrent("cv1", cv1, true);
0782:            }
0783:
0784:            /**
0785:             * Case: A2s.
0786:             */
0787:            void testA2s() {
0788:                final LcduiTestCanvas cv0 = new LcduiTestCanvas();
0789:                final LcduiTestCanvas cv1 = new LcduiTestCanvas();
0790:                final Alert alert1 = makeAlert("alert1");
0791:
0792:                // establish initial conditions
0793:                setCurrentWait(cv0);
0794:                checkCurrent("cv0", cv0, true);
0795:
0796:                dpy.callSerially(new Runnable() {
0797:                    public void run() {
0798:                        dpy.setCurrent(alert1);
0799:                        dpy.setCurrent(alert1, cv1);
0800:                    }
0801:                });
0802:
0803:                scl.await(new Runnable() {
0804:                    public void run() {
0805:                        checkCurrent("alert1", alert1, true);
0806:                        checkCurrent("cv0", cv0, false);
0807:                        checkCurrent("cv1", cv1, false);
0808:                    }
0809:                });
0810:
0811:                // Ensure that the second setCurrent had no effect.
0812:
0813:                new SerialCallback(dpy).invokeAndWait();
0814:                checkCurrent("alert1", alert1, true);
0815:                checkCurrent("cv0", cv0, false);
0816:                checkCurrent("cv1", cv1, false);
0817:
0818:                dismissWait(alert1);
0819:                checkCurrent("alert1", alert1, false);
0820:                checkCurrent("cv0", cv0, false);
0821:                checkCurrent("cv1", cv1, true);
0822:            }
0823:
0824:            /**
0825:             * Case: A_2.
0826:             */
0827:            void testA_2() {
0828:                final LcduiTestCanvas cv0 = new LcduiTestCanvas();
0829:                final LcduiTestCanvas cv1 = new LcduiTestCanvas();
0830:                final Alert alert1 = makeAlert("alert1");
0831:                final Alert alert2 = makeAlert("alert2");
0832:
0833:                // establish initial conditions
0834:                setCurrentWait(cv0);
0835:                checkCurrent("cv0", cv0, true);
0836:
0837:                dpy.setCurrent(alert1);
0838:                scl.await();
0839:                checkCurrent("alert1", alert1, true);
0840:                checkCurrent("cv0", cv0, false);
0841:
0842:                dpy.setCurrent(alert2, cv1);
0843:                scl.await();
0844:                checkCurrent("alert1", alert1, false);
0845:                checkCurrent("alert2", alert2, true);
0846:                checkCurrent("cv0", cv0, false);
0847:                checkCurrent("cv1", cv1, false);
0848:
0849:                // Dismiss alert1. Nothing should happen, since it has
0850:                // been superseded by alert2.
0851:
0852:                dismiss(alert1);
0853:                new SerialCallback(dpy).invokeAndWait();
0854:                checkCurrent("alert1", alert1, false);
0855:                checkCurrent("alert2", alert2, true);
0856:                checkCurrent("cv0", cv0, false);
0857:                checkCurrent("cv1", cv1, false);
0858:
0859:                dismissWait(alert2);
0860:                checkCurrent("alert1", alert1, false);
0861:                checkCurrent("alert2", alert2, false);
0862:                checkCurrent("cv0", cv0, false);
0863:                checkCurrent("cv1", cv1, true);
0864:            }
0865:
0866:            /**
0867:             * Case: A_2s.
0868:             */
0869:            void testA_2s() {
0870:                final LcduiTestCanvas cv0 = new LcduiTestCanvas();
0871:                final LcduiTestCanvas cv1 = new LcduiTestCanvas();
0872:                final Alert alert1 = makeAlert("alert1");
0873:
0874:                // establish initial conditions
0875:                setCurrentWait(cv0);
0876:                checkCurrent("cv0", cv0, true);
0877:
0878:                setCurrentWait(alert1);
0879:                checkCurrent("alert1", alert1, true);
0880:                checkCurrent("cv0", cv0, false);
0881:
0882:                // The two-arg call should update the next displayable
0883:                // but should otherwise do nothing.
0884:                dpy.setCurrent(alert1, cv1);
0885:                new SerialCallback(dpy).invokeAndWait();
0886:                checkCurrent("alert1", alert1, true);
0887:                checkCurrent("cv0", cv0, false);
0888:                checkCurrent("cv1", cv1, false);
0889:
0890:                dismissWait(alert1);
0891:                checkCurrent("alert1", alert1, false);
0892:                checkCurrent("cv0", cv0, false);
0893:                checkCurrent("cv1", cv1, true);
0894:            }
0895:
0896:            /**
0897:             * Case: 2N.
0898:             */
0899:            void test2N() {
0900:                final LcduiTestCanvas cv1 = new LcduiTestCanvas();
0901:                final LcduiTestCanvas cv2 = new LcduiTestCanvas();
0902:                final Alert alert = makeAlert("alert");
0903:
0904:                dpy.callSerially(new Runnable() {
0905:                    public void run() {
0906:                        dpy.setCurrent(alert, cv1);
0907:                        dpy.setCurrent(cv2);
0908:                    }
0909:                });
0910:
0911:                scl.await(new Runnable() {
0912:                    public void run() {
0913:                        checkCurrent("alert", alert, true);
0914:                        checkCurrent("cv1", cv1, false);
0915:                        checkCurrent("cv2", cv2, false);
0916:                    }
0917:                });
0918:
0919:                scl.await(new Runnable() {
0920:                    public void run() {
0921:                        checkCurrent("alert", alert, false);
0922:                        checkCurrent("cv1", cv1, false);
0923:                        checkCurrent("cv2", cv2, true);
0924:                    }
0925:                });
0926:
0927:                // Dismiss alert. Nothing should happen, since it has
0928:                // been superseded by cv2.
0929:
0930:                dismiss(alert);
0931:                new SerialCallback(dpy).invokeAndWait();
0932:                checkCurrent("alert", alert, false);
0933:                checkCurrent("cv1", cv1, false);
0934:                checkCurrent("cv2", cv2, true);
0935:                assertFalse("cv1 should not have been shown", cv1.wasShown());
0936:            }
0937:
0938:            /**
0939:             * Case: 2_N.
0940:             */
0941:            void test2_N() {
0942:                final LcduiTestCanvas cv1 = new LcduiTestCanvas();
0943:                final LcduiTestCanvas cv2 = new LcduiTestCanvas();
0944:                final Alert alert = makeAlert("alert");
0945:
0946:                dpy.setCurrent(alert, cv1);
0947:                scl.await(new Runnable() {
0948:                    public void run() {
0949:                        checkCurrent("alert", alert, true);
0950:                        checkCurrent("cv1", cv1, false);
0951:                    }
0952:                });
0953:
0954:                setCurrentWait(cv2);
0955:                checkCurrent("alert", alert, false);
0956:                checkCurrent("cv1", cv1, false);
0957:                checkCurrent("cv2", cv2, true);
0958:
0959:                // Dismiss alert. Nothing should happen, since it has
0960:                // been superseded by cv2.
0961:                dismiss(alert);
0962:                new SerialCallback(dpy).invokeAndWait();
0963:                checkCurrent("alert", alert, false);
0964:                checkCurrent("cv1", cv1, false);
0965:                checkCurrent("cv2", cv2, true);
0966:                assertFalse("cv1 should not have been shown", cv1.wasShown());
0967:            }
0968:
0969:            /**
0970:             * Case: 2A.
0971:             */
0972:            void test2A() {
0973:                final LcduiTestCanvas cv1 = new LcduiTestCanvas();
0974:                final LcduiTestCanvas cv2 = new LcduiTestCanvas();
0975:                final Alert alert1 = makeAlert("alert1");
0976:                final Alert alert2 = makeAlert("alert2");
0977:
0978:                thrown = false;
0979:                dpy.callSerially(new Runnable() {
0980:                    public void run() {
0981:                        dpy.setCurrent(alert1, cv1);
0982:                        try {
0983:                            dpy.setCurrent(alert2);
0984:                        } catch (IllegalArgumentException IAE) {
0985:                            thrown = true;
0986:                        }
0987:                    }
0988:                });
0989:
0990:                scl.await(new Runnable() {
0991:                    public void run() {
0992:                        checkCurrent("alert1", alert1, true);
0993:                        checkCurrent("alert2", alert2, false);
0994:                        checkCurrent("cv1", cv1, false);
0995:                        assertTrue("IAE should be thrown", thrown);
0996:                    }
0997:                });
0998:
0999:                dismissWait(alert1);
1000:                checkCurrent("alert1", alert1, false);
1001:                checkCurrent("alert2", alert2, false);
1002:                checkCurrent("cv1", cv1, true);
1003:            }
1004:
1005:            /**
1006:             * Case: 2_A.
1007:             */
1008:            void test2_A() {
1009:                final LcduiTestCanvas cv1 = new LcduiTestCanvas();
1010:                final LcduiTestCanvas cv2 = new LcduiTestCanvas();
1011:                final Alert alert1 = makeAlert("alert1");
1012:                final Alert alert2 = makeAlert("alert2");
1013:
1014:                dpy.setCurrent(alert1, cv1);
1015:
1016:                scl.await();
1017:                checkCurrent("alert1", alert1, true);
1018:                checkCurrent("cv1", cv1, false);
1019:
1020:                thrown = false;
1021:                try {
1022:                    dpy.setCurrent(alert2);
1023:                } catch (IllegalArgumentException IAE) {
1024:                    thrown = true;
1025:                }
1026:                assertTrue("IAE should be thrown", thrown);
1027:
1028:                dismissWait(alert1);
1029:                checkCurrent("alert1", alert1, false);
1030:                checkCurrent("alert2", alert2, false);
1031:                checkCurrent("cv1", cv1, true);
1032:            }
1033:
1034:            /**
1035:             * Case: 22.
1036:             */
1037:            void test22() {
1038:                final LcduiTestCanvas cv1 = new LcduiTestCanvas();
1039:                final LcduiTestCanvas cv2 = new LcduiTestCanvas();
1040:                final Alert alert1 = makeAlert("alert1");
1041:                final Alert alert2 = makeAlert("alert2");
1042:
1043:                dpy.callSerially(new Runnable() {
1044:                    public void run() {
1045:                        dpy.setCurrent(alert1, cv1);
1046:                        dpy.setCurrent(alert2, cv2);
1047:                    }
1048:                });
1049:
1050:                scl.await(new Runnable() {
1051:                    public void run() {
1052:                        checkCurrent("alert1", alert1, true);
1053:                        checkCurrent("alert2", alert2, false);
1054:                        checkCurrent("cv1", cv1, false);
1055:                        checkCurrent("cv2", cv2, false);
1056:                    }
1057:                });
1058:
1059:                scl.await(new Runnable() {
1060:                    public void run() {
1061:                        checkCurrent("alert1", alert1, false);
1062:                        checkCurrent("alert2", alert2, true);
1063:                        checkCurrent("cv1", cv1, false);
1064:                        checkCurrent("cv2", cv2, false);
1065:                    }
1066:                });
1067:
1068:                // Dismiss alert1. Nothing should happen, since it has
1069:                // been superseded by cv2.
1070:                dismiss(alert1);
1071:                new SerialCallback(dpy).invokeAndWait();
1072:                checkCurrent("alert1", alert1, false);
1073:                checkCurrent("alert2", alert2, true);
1074:                checkCurrent("cv1", cv1, false);
1075:                checkCurrent("cv2", cv2, false);
1076:
1077:                dismissWait(alert2);
1078:                checkCurrent("alert1", alert1, false);
1079:                checkCurrent("alert2", alert2, false);
1080:                checkCurrent("cv1", cv1, false);
1081:                checkCurrent("cv2", cv2, true);
1082:                assertFalse("cv1 should never have been shown", cv1.wasShown());
1083:            }
1084:
1085:            /**
1086:             * Case: 2_2.
1087:             */
1088:            void test2_2() {
1089:                final LcduiTestCanvas cv1 = new LcduiTestCanvas();
1090:                final LcduiTestCanvas cv2 = new LcduiTestCanvas();
1091:                final Alert alert1 = makeAlert("alert1");
1092:                final Alert alert2 = makeAlert("alert2");
1093:
1094:                dpy.setCurrent(alert1, cv1);
1095:                scl.await();
1096:                checkCurrent("alert1", alert1, true);
1097:                checkCurrent("cv1", cv1, false);
1098:
1099:                dpy.setCurrent(alert2, cv2);
1100:                scl.await();
1101:                checkCurrent("alert1", alert1, false);
1102:                checkCurrent("alert2", alert2, true);
1103:                checkCurrent("cv1", cv1, false);
1104:                checkCurrent("cv2", cv2, false);
1105:
1106:                // Dismiss alert1. Nothing should happen, since it has
1107:                // been superseded by cv2.
1108:
1109:                dismiss(alert1);
1110:                new SerialCallback(dpy).invokeAndWait();
1111:                checkCurrent("alert1", alert1, false);
1112:                checkCurrent("alert2", alert2, true);
1113:                checkCurrent("cv1", cv1, false);
1114:                checkCurrent("cv2", cv2, false);
1115:
1116:                dismissWait(alert2);
1117:                checkCurrent("alert1", alert1, false);
1118:                checkCurrent("alert2", alert2, false);
1119:                checkCurrent("cv1", cv1, false);
1120:                checkCurrent("cv2", cv2, true);
1121:                assertFalse("cv1 should never have been shown", cv1.wasShown());
1122:            }
1123:
1124:            /**
1125:             * Case 22s. Tests the behavior of two, two-arg setCurrent calls, where 
1126:             * the alert in question is the same in both cases.
1127:             */
1128:            void test22s() {
1129:                final Alert alert = makeAlert("alert");
1130:                final LcduiTestCanvas cv1 = new LcduiTestCanvas();
1131:                final LcduiTestCanvas cv2 = new LcduiTestCanvas();
1132:
1133:                dpy.callSerially(new Runnable() {
1134:                    public void run() {
1135:                        dpy.setCurrent(alert, cv1);
1136:                        dpy.setCurrent(alert, cv2);
1137:                    }
1138:                });
1139:
1140:                scl.await(new Runnable() {
1141:                    public void run() {
1142:                        checkCurrent("alert", alert, true);
1143:                        checkCurrent("cv1", cv1, false);
1144:                        checkCurrent("cv2", cv2, false);
1145:                    }
1146:                });
1147:
1148:                // Dismiss alert, then cv2 should become current.
1149:
1150:                dismissWait(alert);
1151:                checkCurrent("alert", alert, false);
1152:                checkCurrent("cv1", cv1, false);
1153:                checkCurrent("cv2", cv2, true);
1154:                assertFalse("cv1 should never have been shown", cv1.wasShown());
1155:            }
1156:
1157:            /**
1158:             * Case 2_2s. Tests the behavior of two, two-arg setCurrent calls, where 
1159:             * the alert in question is the same in both cases.
1160:             */
1161:            void test2_2s() {
1162:                final Alert alert = makeAlert("alert");
1163:                final LcduiTestCanvas cv1 = new LcduiTestCanvas();
1164:                final LcduiTestCanvas cv2 = new LcduiTestCanvas();
1165:
1166:                dpy.setCurrent(alert, cv1);
1167:                scl.await();
1168:                checkCurrent("alert", alert, true);
1169:                checkCurrent("cv1", cv1, false);
1170:
1171:                // Call setCurrent again and dismiss the alert before
1172:                // the event can be processed.
1173:
1174:                dpy.callSerially(new Runnable() {
1175:                    public void run() {
1176:                        dpy.setCurrent(alert, cv2);
1177:                        dismiss(alert);
1178:                    }
1179:                });
1180:
1181:                scl.await();
1182:                checkCurrent("alert", alert, false);
1183:                checkCurrent("cv1", cv1, false);
1184:                checkCurrent("cv2", cv2, true);
1185:                assertFalse("cv1 should never have been shown", cv1.wasShown());
1186:            }
1187:
1188:            /**
1189:             * Tests setCurrent(alert, alert). This is basically an API test.
1190:             */
1191:            void testAlertAlert() {
1192:                Alert alert1 = makeAlert("alert1");
1193:                Alert alert2 = makeAlert("alert2");
1194:
1195:                thrown = false;
1196:                try {
1197:                    dpy.setCurrent(alert1, alert2);
1198:                } catch (IllegalArgumentException iae) {
1199:                    thrown = true;
1200:                }
1201:
1202:                assertTrue("IAE should be thrown", thrown);
1203:            }
1204:
1205:            /**
1206:             * Case: A_NA.
1207:             */
1208:            void testA_NA() {
1209:                final Alert alert1 = makeAlert("alert1");
1210:                final Alert alert2 = makeAlert("alert2");
1211:                final LcduiTestCanvas cv0 = new LcduiTestCanvas();
1212:                final LcduiTestCanvas cv1 = new LcduiTestCanvas();
1213:
1214:                // establish initial conditions
1215:                setCurrentWait(cv0);
1216:                checkCurrent("cv0", cv0, true);
1217:
1218:                dpy.setCurrent(alert1);
1219:                scl.await(new Runnable() {
1220:                    public void run() {
1221:                        checkCurrent("alert1", alert1, true);
1222:                        checkCurrent("cv0", cv0, false);
1223:                        dpy.setCurrent(cv1);
1224:                        dpy.setCurrent(alert2);
1225:                    }
1226:                });
1227:
1228:                scl.await(new Runnable() {
1229:                    public void run() {
1230:                        checkCurrent("alert1", alert1, false);
1231:                        checkCurrent("alert2", alert2, false);
1232:                        checkCurrent("cv0", cv0, false);
1233:                        checkCurrent("cv1", cv1, true);
1234:                        dismiss(alert1);
1235:                    }
1236:                });
1237:
1238:                // Dismissing alert1 should be ignored since it has been
1239:                // superseded by cv1; then alert2 should become current.
1240:
1241:                scl.await(new Runnable() {
1242:                    public void run() {
1243:                        checkCurrent("alert1", alert1, false);
1244:                        checkCurrent("alert2", alert2, true);
1245:                        checkCurrent("cv0", cv0, false);
1246:                        checkCurrent("cv1", cv1, false);
1247:                        dismiss(alert2);
1248:                    }
1249:                });
1250:
1251:                scl.await();
1252:                checkCurrent("alert1", alert1, false);
1253:                checkCurrent("alert2", alert2, false);
1254:                checkCurrent("cv0", cv0, false);
1255:                checkCurrent("cv1", cv1, true);
1256:            }
1257:
1258:            /**
1259:             * Runs all tests.
1260:             */
1261:            public void runTests() throws Throwable {
1262:                init();
1263:                try {
1264:                    declare("testInit");
1265:                    testInit();
1266:
1267:                    declare("test0A0A");
1268:                    test0A0A();
1269:
1270:                    declare("testN");
1271:                    testN();
1272:
1273:                    declare("testA");
1274:                    testA();
1275:
1276:                    declare("test2");
1277:                    test2();
1278:
1279:                    declare("testNN");
1280:                    testNN();
1281:
1282:                    declare("testNNsN");
1283:                    testNNsN();
1284:
1285:                    declare("testN_N");
1286:                    testN_N();
1287:
1288:                    declare("testN_NNs");
1289:                    testN_NNs();
1290:
1291:                    declare("testNA");
1292:                    testNA();
1293:
1294:                    declare("testN2");
1295:                    testN2();
1296:
1297:                    declare("testAN");
1298:                    testAN();
1299:
1300:                    declare("testAND");
1301:                    testAND();
1302:
1303:                    declare("testA_N");
1304:                    testA_N();
1305:
1306:                    declare("testAA");
1307:                    testAA();
1308:
1309:                    declare("testAAs");
1310:                    testAAs();
1311:
1312:                    declare("testA_A");
1313:                    testA_A();
1314:
1315:                    declare("testA_As");
1316:                    testA_As();
1317:
1318:                    declare("testA2");
1319:                    testA2();
1320:
1321:                    declare("testA2s");
1322:                    testA2s();
1323:
1324:                    declare("testA_2");
1325:                    testA_2();
1326:
1327:                    declare("testA_2s");
1328:                    testA_2s();
1329:
1330:                    declare("test2N");
1331:                    test2N();
1332:
1333:                    declare("test2_N");
1334:                    test2_N();
1335:
1336:                    declare("test2A");
1337:                    test2A();
1338:
1339:                    declare("test2_A");
1340:                    test2_A();
1341:
1342:                    declare("test22");
1343:                    test22();
1344:
1345:                    declare("test2_2");
1346:                    test2_2();
1347:
1348:                    declare("test22s");
1349:                    test22s();
1350:
1351:                    declare("test2_2s");
1352:                    test2_2s();
1353:
1354:                    declare("testAlertAlert");
1355:                    testAlertAlert();
1356:
1357:                    declare("testA_NA");
1358:                    testA_NA();
1359:                } finally {
1360:                    fini();
1361:                }
1362:            }
1363:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.