From 73eb97f628b298c7bd032aa9db11dadf05f5b539 Mon Sep 17 00:00:00 2001 From: Amith Yamasani Date: Tue, 14 Feb 2012 15:45:15 -0800 Subject: Revert "Incorrect behavior of View clear focus." This reverts commit c6fd88e213703a581fe4680259981f09ae0444f2 --- .../src/android/widget/focus/RequestFocus.java | 2 + .../src/android/widget/focus/RequestFocusTest.java | 161 +-------------------- 2 files changed, 9 insertions(+), 154 deletions(-) (limited to 'core/tests/coretests') diff --git a/core/tests/coretests/src/android/widget/focus/RequestFocus.java b/core/tests/coretests/src/android/widget/focus/RequestFocus.java index 21d762a..af9ee17 100644 --- a/core/tests/coretests/src/android/widget/focus/RequestFocus.java +++ b/core/tests/coretests/src/android/widget/focus/RequestFocus.java @@ -21,7 +21,9 @@ import com.android.frameworks.coretests.R; import android.app.Activity; import android.os.Bundle; import android.os.Handler; +import android.widget.LinearLayout; import android.widget.Button; +import android.view.View; /** * Exercises cases where elements of the UI are requestFocus()ed. diff --git a/core/tests/coretests/src/android/widget/focus/RequestFocusTest.java b/core/tests/coretests/src/android/widget/focus/RequestFocusTest.java index baf587e..a78b0c9 100644 --- a/core/tests/coretests/src/android/widget/focus/RequestFocusTest.java +++ b/core/tests/coretests/src/android/widget/focus/RequestFocusTest.java @@ -16,27 +16,21 @@ package android.widget.focus; +import android.widget.focus.RequestFocus; +import com.android.frameworks.coretests.R; + import android.os.Handler; -import android.test.ActivityInstrumentationTestCase2; -import android.test.UiThreadTest; +import android.test.ActivityInstrumentationTestCase; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.MediumTest; -import android.util.AndroidRuntimeException; -import android.view.View; -import android.view.View.OnFocusChangeListener; -import android.view.ViewTreeObserver.OnGlobalFocusChangeListener; import android.widget.Button; - -import com.android.frameworks.coretests.R; - -import java.util.ArrayList; -import java.util.List; +import android.util.AndroidRuntimeException; /** * {@link RequestFocusTest} is set up to exercise cases where the views that * have focus become invisible or GONE. */ -public class RequestFocusTest extends ActivityInstrumentationTestCase2 { +public class RequestFocusTest extends ActivityInstrumentationTestCase { private Button mTopLeftButton; private Button mBottomLeftButton; @@ -45,7 +39,7 @@ public class RequestFocusTest extends ActivityInstrumentationTestCase2 mInvocations = new ArrayList(); - - public CallbackOrderChecker(View clearingFocusView, View gainingFocusView) { - mClearingFocusView = clearingFocusView; - mGainingFocusView = gainingFocusView; - } - - @Override - public void onFocusChange(View view, boolean hasFocus) { - CallbackInvocation invocation = new CallbackInvocation( - "OnFocusChangeListener#onFocusChange", new Object[] {view, hasFocus}); - mInvocations.add(invocation); - } - - @Override - public void onGlobalFocusChanged(View oldFocus, View newFocus) { - CallbackInvocation invocation = new CallbackInvocation( - "OnFocusChangeListener#onFocusChange", new Object[] {oldFocus, newFocus}); - mInvocations.add(invocation); - } - - public void verify() { - assertSame("All focus change callback should be invoked.", 3, mInvocations.size()); - assertInvioked("Callback for View clearing focus explected.", 0, - "OnFocusChangeListener#onFocusChange", - new Object[] {mClearingFocusView, false}); - assertInvioked("Callback for View global focus change explected.", 1, - "OnFocusChangeListener#onFocusChange", new Object[] {mClearingFocusView, - mGainingFocusView}); - assertInvioked("Callback for View gaining focus explected.", 2, - "OnFocusChangeListener#onFocusChange", new Object[] {mGainingFocusView, true}); - } - - private void assertInvioked(String message, int order, String methodName, - Object[] arguments) { - CallbackInvocation invocation = mInvocations.get(order); - assertEquals(message, methodName, invocation.mMethodName); - assertEquals(message, arguments[0], invocation.mArguments[0]); - assertEquals(message, arguments[1], invocation.mArguments[1]); - } - } } -- cgit v1.1