01: /*
02: * Copyright 2007 Google Inc.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package com.google.gwt.junit.client;
17:
18: /**
19: * This class tests the -remoteweb parallel execution features in GWT's JUnit
20: * support. This test should not be part of the automatically run test suite,
21: * because it intentionally generates failures at different browser clients.
22: *
23: * What we're looking for in the output of this test is that the failures
24: * additionally contain the host and browser at which the test failed.
25: *
26: * To run this test correctly, you should be using the -remoteweb option
27: * with at least three different clients.
28: *
29: */
30: public class ParallelRemoteTest extends GWTTestCase {
31:
32: public String getModuleName() {
33: return "com.google.gwt.junit.JUnit";
34: }
35:
36: public void testAssertFailsOnNotIE() {
37: String agent = getAgent().toLowerCase();
38: if (agent.indexOf("msie") == -1) {
39: fail("Browser is not IE.");
40: }
41: }
42:
43: public void testAssertFailsOnNotSafari() {
44: String agent = getAgent().toLowerCase();
45: if (agent.indexOf("safari") == -1) {
46: fail("Browser is not Safari.");
47: }
48: }
49:
50: public void testExceptionFailsOnNotIE() {
51: String agent = getAgent().toLowerCase();
52: if (agent.indexOf("msie") == -1) {
53: throw new RuntimeException("Browser is not IE.");
54: }
55: }
56:
57: public void testExceptionFailsOnNotSafari() {
58: String agent = getAgent().toLowerCase();
59: if (agent.indexOf("safari") == -1) {
60: throw new RuntimeException("Browser is not Safari.");
61: }
62: }
63:
64: private native String getAgent() /*-{
65: return navigator.userAgent.toString();
66: }-*/;
67: }
|