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.user.client.ui;
17:
18: import com.google.gwt.junit.client.GWTTestCase;
19:
20: /**
21: * Tests the RadioButton class.
22: */
23: public class RadioButtonTest extends GWTTestCase {
24:
25: public String getModuleName() {
26: return "com.google.gwt.user.User";
27: }
28:
29: /**
30: * Test the name and grouping methods.
31: */
32: public void testGrouping() {
33: // Create some radio buttons
34: RadioButton r1 = new RadioButton("group1", "Radio 1");
35: RadioButton r2 = new RadioButton("group1", "Radio 2");
36: RadioButton r3 = new RadioButton("group2", "Radio 3");
37: RootPanel.get().add(r1);
38: RootPanel.get().add(r2);
39: RootPanel.get().add(r3);
40:
41: // Check one button in each group
42: r2.setChecked(true);
43: r3.setChecked(true);
44:
45: // Move a button over
46: r2.setName("group2");
47:
48: // Check that the correct buttons are checked
49: assertTrue(r2.isChecked());
50: assertFalse(r3.isChecked());
51:
52: r1.setChecked(true);
53: assertTrue(r1.isChecked());
54: assertTrue(r2.isChecked());
55:
56: r3.setChecked(true);
57: assertTrue(r1.isChecked());
58: assertFalse(r2.isChecked());
59: assertTrue(r3.isChecked());
60: }
61: }
|