2 * Copyright (C) 2007 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package android
.widget
;
19 import com
.android
.frameworks
.coretests
.R
;
21 import android
.test
.ActivityInstrumentationTestCase2
;
22 import android
.test
.TouchUtils
;
23 import android
.test
.suitebuilder
.annotation
.LargeTest
;
24 import android
.test
.suitebuilder
.annotation
.MediumTest
;
27 * Exercises {@link android.widget.RadioGroup}'s check feature.
29 public class RadioGroupPreCheckedTest
extends ActivityInstrumentationTestCase2
<RadioGroupActivity
> {
30 public RadioGroupPreCheckedTest() {
31 super(RadioGroupActivity
.class);
35 public void testRadioButtonPreChecked() throws Exception
{
36 final RadioGroupActivity activity
= getActivity();
38 RadioButton radio
= (RadioButton
) activity
.findViewById(R
.id
.value_one
);
39 assertTrue("The first radio button should be checked", radio
.isChecked());
41 RadioGroup group
= (RadioGroup
) activity
.findViewById(R
.id
.group
);
42 assertEquals("The first radio button should be checked", R
.id
.value_one
,
43 group
.getCheckedRadioButtonId());
47 public void testRadioButtonChangePreChecked() throws Exception
{
48 final RadioGroupActivity activity
= getActivity();
50 RadioButton radio
= (RadioButton
) activity
.findViewById(R
.id
.value_two
);
51 TouchUtils
.clickView(this, radio
);
53 RadioButton old
= (RadioButton
) activity
.findViewById(R
.id
.value_one
);
55 assertFalse("The first radio button should not be checked", old
.isChecked());
56 assertTrue("The second radio button should be checked", radio
.isChecked());
58 RadioGroup group
= (RadioGroup
) activity
.findViewById(R
.id
.group
);
59 assertEquals("The second radio button should be checked", R
.id
.value_two
,
60 group
.getCheckedRadioButtonId());