Roll android_tools support library to 25.1.0
[android_tools.git] / sdk / sources / android-23 / android / widget / RadioGroupPreCheckedTest.java
blob1ab362835bbebd66f45462b9ad225e63b948b8f4
1 /*
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;
26 /**
27 * Exercises {@link android.widget.RadioGroup}'s check feature.
29 public class RadioGroupPreCheckedTest extends ActivityInstrumentationTestCase2<RadioGroupActivity> {
30 public RadioGroupPreCheckedTest() {
31 super(RadioGroupActivity.class);
34 @MediumTest
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());
46 @LargeTest
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());