am 6d72f725: Merge change If32b488b into eclair-mr2
Merge commit '6d72f725f18a63afd68f14cc1e2ff8f21d254c77' into eclair-mr2-plus-aosp * commit '6d72f725f18a63afd68f14cc1e2ff8f21d254c77': Add new unit test for RadioGroup/RadioButton.
This commit is contained in:
@@ -955,6 +955,14 @@
|
|||||||
<action android:name="android.accessibilityservice.AccessibilityService" />
|
<action android:name="android.accessibilityservice.AccessibilityService" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
|
<activity android:name=".radiogroup.RadioGroupActivity" android:label="RadioGroupActivity">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
|||||||
44
tests/FrameworkTest/res/layout/radiogroup_checkedchild.xml
Normal file
44
tests/FrameworkTest/res/layout/radiogroup_checkedchild.xml
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2009 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<RadioGroup xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/group"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/value_one"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:textColor="#555555"
|
||||||
|
android:checked="true"
|
||||||
|
android:text="@string/visibility_1_view_1" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/value_two"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:textColor="#555555"
|
||||||
|
android:text="@string/visibility_1_view_2" />
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/value_three"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:textColor="#555555"
|
||||||
|
android:text="@string/visibility_1_view_3" />
|
||||||
|
|
||||||
|
</RadioGroup>
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2009 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
package com.android.frameworktest.radiogroup;
|
||||||
|
|
||||||
|
import com.android.frameworktest.R;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
public class RadioGroupActivity extends Activity {
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.radiogroup_checkedchild);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -42,6 +42,7 @@ public class AutoCompleteTextViewCallbacks
|
|||||||
textView.requestFocus();
|
textView.requestFocus();
|
||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
sendKeys("A");
|
sendKeys("A");
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
// give UI time to settle
|
// give UI time to settle
|
||||||
Thread.sleep(WAIT_TIME);
|
Thread.sleep(WAIT_TIME);
|
||||||
|
|
||||||
@@ -58,7 +59,7 @@ public class AutoCompleteTextViewCallbacks
|
|||||||
/** Test that arrow-down into the popup calls the onSelected callback. */
|
/** Test that arrow-down into the popup calls the onSelected callback. */
|
||||||
@FlakyTest(tolerance=3)
|
@FlakyTest(tolerance=3)
|
||||||
public void testPopupEnterSelection() throws Exception {
|
public void testPopupEnterSelection() throws Exception {
|
||||||
AutoCompleteTextViewSimple theActivity = getActivity();
|
final AutoCompleteTextViewSimple theActivity = getActivity();
|
||||||
AutoCompleteTextView textView = theActivity.getTextView();
|
AutoCompleteTextView textView = theActivity.getTextView();
|
||||||
final Instrumentation instrumentation = getInstrumentation();
|
final Instrumentation instrumentation = getInstrumentation();
|
||||||
|
|
||||||
@@ -67,9 +68,15 @@ public class AutoCompleteTextViewCallbacks
|
|||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
sendKeys("A");
|
sendKeys("A");
|
||||||
|
|
||||||
// prepare to move down into the popup
|
textView.post(new Runnable() {
|
||||||
theActivity.resetItemListeners();
|
public void run() {
|
||||||
|
// prepare to move down into the popup
|
||||||
|
theActivity.resetItemListeners();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
sendKeys("DPAD_DOWN");
|
sendKeys("DPAD_DOWN");
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
// give UI time to settle
|
// give UI time to settle
|
||||||
Thread.sleep(WAIT_TIME);
|
Thread.sleep(WAIT_TIME);
|
||||||
|
|
||||||
@@ -79,9 +86,15 @@ public class AutoCompleteTextViewCallbacks
|
|||||||
assertEquals("onItemSelected position", 0, theActivity.mItemSelectedPosition);
|
assertEquals("onItemSelected position", 0, theActivity.mItemSelectedPosition);
|
||||||
assertFalse("onNothingSelected should not be called", theActivity.mNothingSelectedCalled);
|
assertFalse("onNothingSelected should not be called", theActivity.mNothingSelectedCalled);
|
||||||
|
|
||||||
// try one more time - should move from 0 to 1
|
textView.post(new Runnable() {
|
||||||
theActivity.resetItemListeners();
|
public void run() {
|
||||||
|
// try one more time - should move from 0 to 1
|
||||||
|
theActivity.resetItemListeners();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
sendKeys("DPAD_DOWN");
|
sendKeys("DPAD_DOWN");
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
// give UI time to settle
|
// give UI time to settle
|
||||||
Thread.sleep(WAIT_TIME);
|
Thread.sleep(WAIT_TIME);
|
||||||
|
|
||||||
@@ -95,7 +108,7 @@ public class AutoCompleteTextViewCallbacks
|
|||||||
/** Test that arrow-up out of the popup calls the onNothingSelected callback */
|
/** Test that arrow-up out of the popup calls the onNothingSelected callback */
|
||||||
@FlakyTest(tolerance=3)
|
@FlakyTest(tolerance=3)
|
||||||
public void testPopupLeaveSelection() {
|
public void testPopupLeaveSelection() {
|
||||||
AutoCompleteTextViewSimple theActivity = getActivity();
|
final AutoCompleteTextViewSimple theActivity = getActivity();
|
||||||
AutoCompleteTextView textView = theActivity.getTextView();
|
AutoCompleteTextView textView = theActivity.getTextView();
|
||||||
final Instrumentation instrumentation = getInstrumentation();
|
final Instrumentation instrumentation = getInstrumentation();
|
||||||
|
|
||||||
@@ -103,13 +116,21 @@ public class AutoCompleteTextViewCallbacks
|
|||||||
textView.requestFocus();
|
textView.requestFocus();
|
||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
sendKeys("A");
|
sendKeys("A");
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
|
|
||||||
// move down into the popup
|
// move down into the popup
|
||||||
sendKeys("DPAD_DOWN");
|
sendKeys("DPAD_DOWN");
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
|
|
||||||
|
textView.post(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
// prepare to move down into the popup
|
||||||
|
theActivity.resetItemListeners();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// now move back up out of the popup
|
|
||||||
theActivity.resetItemListeners();
|
|
||||||
sendKeys("DPAD_UP");
|
sendKeys("DPAD_UP");
|
||||||
|
instrumentation.waitForIdleSync();
|
||||||
|
|
||||||
// now check for selection callbacks.
|
// now check for selection callbacks.
|
||||||
assertFalse("onItemClick should not be called", theActivity.mItemClickCalled);
|
assertFalse("onItemClick should not be called", theActivity.mItemClickCalled);
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2007 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.frameworktest.radiogroup;
|
||||||
|
|
||||||
|
import android.test.TouchUtils;
|
||||||
|
import android.widget.RadioButton;
|
||||||
|
import android.widget.RadioGroup;
|
||||||
|
import com.android.frameworktest.R;
|
||||||
|
|
||||||
|
import android.test.ActivityInstrumentationTestCase2;
|
||||||
|
import android.test.suitebuilder.annotation.LargeTest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exercises {@link android.widget.RadioGroup}'s check feature.
|
||||||
|
*/
|
||||||
|
public class RadioGroupPreCheckedTest extends ActivityInstrumentationTestCase2<RadioGroupActivity> {
|
||||||
|
public RadioGroupPreCheckedTest() {
|
||||||
|
super("com.android.frameworktest", RadioGroupActivity.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@LargeTest
|
||||||
|
public void testRadioButtonPreChecked() throws Exception {
|
||||||
|
final RadioGroupActivity activity = getActivity();
|
||||||
|
|
||||||
|
RadioButton radio = (RadioButton) activity.findViewById(R.id.value_one);
|
||||||
|
assertTrue("The first radio button should be checked", radio.isChecked());
|
||||||
|
|
||||||
|
RadioGroup group = (RadioGroup) activity.findViewById(R.id.group);
|
||||||
|
assertEquals("The first radio button should be checked", R.id.value_one,
|
||||||
|
group.getCheckedRadioButtonId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@LargeTest
|
||||||
|
public void testRadioButtonChangePreChecked() throws Exception {
|
||||||
|
final RadioGroupActivity activity = getActivity();
|
||||||
|
|
||||||
|
RadioButton radio = (RadioButton) activity.findViewById(R.id.value_two);
|
||||||
|
TouchUtils.clickView(this, radio);
|
||||||
|
|
||||||
|
RadioButton old = (RadioButton) activity.findViewById(R.id.value_one);
|
||||||
|
|
||||||
|
assertFalse("The first radio button should not be checked", old.isChecked());
|
||||||
|
assertTrue("The second radio button should be checked", radio.isChecked());
|
||||||
|
|
||||||
|
RadioGroup group = (RadioGroup) activity.findViewById(R.id.group);
|
||||||
|
assertEquals("The second radio button should be checked", R.id.value_two,
|
||||||
|
group.getCheckedRadioButtonId());
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user