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.junit.client;
017:
018: import com.google.gwt.user.client.Timer;
019:
020: /**
021: * This test must be run manually to inspect for correct results. Five of these
022: * tests are designed to fail in specific ways, the other five should succeed.
023: * The name of each test method indicates how it should behave.
024: */
025: public class TestManualAsync extends GWTTestCase {
026:
027: public String getModuleName() {
028: return "com.google.gwt.junit.JUnit";
029: }
030:
031: /**
032: * Fails normally
033: */
034: public void testDelayFail() {
035: delayTestFinish(100);
036: fail();
037: finishTest();
038: }
039:
040: /**
041: * Completes normally
042: */
043: public void testDelayNormal() {
044: delayTestFinish(100);
045: finishTest();
046: }
047:
048: /**
049: * Fails normally
050: */
051: public void testFail() {
052: fail();
053: }
054:
055: /**
056: * Async fails
057: */
058: public void testFailAsync() {
059: delayTestFinish(200);
060: new Timer() {
061: public void run() {
062: fail();
063: }
064: }.schedule(100);
065: }
066:
067: /**
068: * Completes normally
069: */
070: public void testNormal() {
071: }
072:
073: /**
074: * Completes async
075: */
076: public void testNormalAsync() {
077: delayTestFinish(200);
078: new Timer() {
079: public void run() {
080: finishTest();
081: }
082: }.schedule(100);
083: }
084:
085: /**
086: * Completes async
087: */
088: public void testRepeatingNormal() {
089: delayTestFinish(200);
090: new Timer() {
091: public void run() {
092: if (++i < 4) {
093: delayTestFinish(200);
094: } else {
095: cancel();
096: finishTest();
097: }
098: }
099:
100: private int i = 0;
101: }.scheduleRepeating(100);
102: }
103:
104: /**
105: * Completes normally
106: */
107: public void testSpuriousFinishTest() {
108: try {
109: finishTest();
110: fail();
111: } catch (IllegalArgumentException e) {
112: }
113: }
114:
115: /**
116: * Times out
117: */
118: public void testTimeoutAsync() {
119: delayTestFinish(100);
120: new Timer() {
121: public void run() {
122: finishTest();
123: }
124: }.schedule(200);
125: }
126:
127: }
|