diff options
| author | 2017-11-09 15:13:31 -0800 | |
|---|---|---|
| committer | 2017-11-09 15:20:23 -0800 | |
| commit | 1d65c7666cbd72b8ea734bb66b352f9a09c37f89 (patch) | |
| tree | 116e28a86778cfc53b633597623b379a4500ed7b | |
| parent | 45a9600e68f3e356c5dbc34d7e9812a4e99279e7 (diff) | |
Fix more coretests in light of no-initial-focus
Fixes for several coretests in:
android.view
android.widget.focus
android.widget.layout.table
android.widget.listview.*
android.widget.touchmode
Bug: 67467972
Test: several
Change-Id: Ic7a4bcaee8f1d4b2c5568e94f5ab9259d8fa2c8c
10 files changed, 42 insertions, 42 deletions
diff --git a/core/tests/coretests/res/layout/add_column_in_table.xml b/core/tests/coretests/res/layout/add_column_in_table.xml index 05f55a8b360e..d929b02f70af 100644 --- a/core/tests/coretests/res/layout/add_column_in_table.xml +++ b/core/tests/coretests/res/layout/add_column_in_table.xml @@ -18,6 +18,7 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> + <requestFocus /> <TableLayout android:id="@+id/table" android:layout_width="match_parent" diff --git a/core/tests/coretests/res/layout/baseline_0width_and_weight.xml b/core/tests/coretests/res/layout/baseline_0width_and_weight.xml index acbb10b7d7b2..eac9b9de2db1 100644 --- a/core/tests/coretests/res/layout/baseline_0width_and_weight.xml +++ b/core/tests/coretests/res/layout/baseline_0width_and_weight.xml @@ -21,6 +21,7 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> + <requestFocus /> <LinearLayout android:id="@+id/layout" android:layout_width="match_parent" android:layout_height="wrap_content" diff --git a/core/tests/coretests/res/layout/focus_after_removal.xml b/core/tests/coretests/res/layout/focus_after_removal.xml index f4e388d695c9..84449d1a0062 100644 --- a/core/tests/coretests/res/layout/focus_after_removal.xml +++ b/core/tests/coretests/res/layout/focus_after_removal.xml @@ -22,6 +22,7 @@ android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> + <requestFocus /> <LinearLayout android:id="@+id/leftLayout" android:orientation="vertical" diff --git a/core/tests/coretests/res/layout/linear_layout_edittext_then_button.xml b/core/tests/coretests/res/layout/linear_layout_edittext_then_button.xml index ab76e29c5fa1..6b3b5a72c59c 100644 --- a/core/tests/coretests/res/layout/linear_layout_edittext_then_button.xml +++ b/core/tests/coretests/res/layout/linear_layout_edittext_then_button.xml @@ -22,6 +22,7 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> + <requestFocus /> <EditText android:id="@+id/editText" diff --git a/core/tests/coretests/res/layout/visibility_callback.xml b/core/tests/coretests/res/layout/visibility_callback.xml index 9034b3f2329b..ff918f541839 100644 --- a/core/tests/coretests/res/layout/visibility_callback.xml +++ b/core/tests/coretests/res/layout/visibility_callback.xml @@ -24,6 +24,7 @@ android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> + <requestFocus /> <LinearLayout android:orientation="vertical" diff --git a/core/tests/coretests/src/android/util/ListScenario.java b/core/tests/coretests/src/android/util/ListScenario.java index fa088a303507..129484af75de 100644 --- a/core/tests/coretests/src/android/util/ListScenario.java +++ b/core/tests/coretests/src/android/util/ListScenario.java @@ -28,6 +28,7 @@ import android.widget.EditText; import android.widget.LinearLayout; import android.widget.ListView; import android.widget.TextView; + import com.google.android.collect.Maps; import java.util.ArrayList; @@ -60,18 +61,18 @@ public abstract class ListScenario extends Activity { // separators private Set<Integer> mUnselectableItems = new HashSet<Integer>(); - + private boolean mStackFromBottom; private int mClickedPosition = -1; - + private int mLongClickedPosition = -1; - + private int mConvertMisses = 0; - + private int mHeaderViewCount; private boolean mHeadersFocusable; - + private int mFooterViewCount; private LinearLayout mLinearLayout; @@ -193,7 +194,7 @@ public abstract class ListScenario extends Activity { mIncludeHeader = includeHeader; return this; } - + /** * Sets the stacking direction * @param stackFromBottom @@ -203,7 +204,7 @@ public abstract class ListScenario extends Activity { mStackFromBottom = stackFromBottom; return this; } - + /** * Sets whether the sum of the height of the list items must be at least the * height of the list view. @@ -220,7 +221,7 @@ public abstract class ListScenario extends Activity { mFadingEdgeScreenSizeFactor = fadingEdgeScreenSizeFactor; return this; } - + /** * Set the number of header views to appear within the list */ @@ -246,7 +247,7 @@ public abstract class ListScenario extends Activity { mFooterViewCount = footerViewCount; return this; } - + /** * Sets whether the {@link ListScenario} will automatically set the * adapter on the list view. If this is false, the client MUST set it @@ -278,7 +279,7 @@ public abstract class ListScenario extends Activity { */ protected void nothingSelected() { } - + /** * Override this if you want to know when something has been clicked (perhaps * more importantly, that {@link android.widget.AdapterView.OnItemClickListener} has @@ -287,7 +288,7 @@ public abstract class ListScenario extends Activity { protected void positionClicked(int position) { setClickedPosition(position); } - + /** * Override this if you want to know when something has been long clicked (perhaps * more importantly, that {@link android.widget.AdapterView.OnItemLongClickListener} has @@ -303,7 +304,7 @@ public abstract class ListScenario extends Activity { // for test stability, turn off title bar requestWindowFeature(Window.FEATURE_NO_TITLE); - + mScreenHeight = getWindowManager().getDefaultDisplay().getHeight(); @@ -326,7 +327,7 @@ public abstract class ListScenario extends Activity { header.setText("Header: " + i); mListView.addHeaderView(header); } - + for (int i=0; i<mFooterViewCount; i++) { TextView header = new TextView(this); header.setText("Footer: " + i); @@ -336,7 +337,7 @@ public abstract class ListScenario extends Activity { if (params.mConnectAdapter) { setAdapter(mListView); } - + mListView.setItemsCanFocus(mItemsFocusable); if (mStartingSelectionPosition >= 0) { mListView.setSelection(mStartingSelectionPosition); @@ -360,11 +361,12 @@ public abstract class ListScenario extends Activity { positionClicked(position); } }); - + // set the fading edge length porportionally to the screen // height for test stability if (params.mFadingEdgeScreenSizeFactor != null) { - mListView.setFadingEdgeLength((int) (params.mFadingEdgeScreenSizeFactor * mScreenHeight)); + mListView.setFadingEdgeLength( + (int) (params.mFadingEdgeScreenSizeFactor * mScreenHeight)); } else { mListView.setFadingEdgeLength((int) ((64.0 / 480) * mScreenHeight)); } @@ -403,6 +405,7 @@ public abstract class ListScenario extends Activity { mLinearLayout.addView(mListView); setContentView(mLinearLayout); } + mLinearLayout.restoreDefaultFocus(); } /** @@ -426,7 +429,7 @@ public abstract class ListScenario extends Activity { } }); } - + /** * @return The newly created ListView widget. */ @@ -440,16 +443,16 @@ public abstract class ListScenario extends Activity { protected Params createParams() { return new Params(); } - + /** * Sets an adapter on a ListView. - * + * * @param listView The ListView to set the adapter on. */ protected void setAdapter(ListView listView) { listView.setAdapter(new MyAdapter()); } - + /** * Read in and validate all of the params passed in by the scenario. * @param params @@ -525,7 +528,7 @@ public abstract class ListScenario extends Activity { if (!mIncludeHeader) { throw new IllegalArgumentException("no header above list"); } - mHeaderTextView.setText(value); + mHeaderTextView.setText(value); } /** @@ -543,12 +546,12 @@ public abstract class ListScenario extends Activity { } /** - * Convert a non-null view. + * Convert a non-null view. */ public View convertView(int position, View convertView, ViewGroup parent) { return ListItemFactory.convertText(convertView, getValueAtPosition(position), position); } - + public void setClickedPosition(int clickedPosition) { mClickedPosition = clickedPosition; } @@ -580,7 +583,7 @@ public abstract class ListScenario extends Activity { } }); } - + /** * Return an item type for the specified position in the adapter. Override if your * adapter creates more than one type. @@ -596,7 +599,7 @@ public abstract class ListScenario extends Activity { public int getViewTypeCount() { return 1; } - + /** * @return The number of times convertView failed */ @@ -647,7 +650,7 @@ public abstract class ListScenario extends Activity { } return result; } - + @Override public int getItemViewType(int position) { return ListScenario.this.getItemViewType(position); diff --git a/core/tests/coretests/src/android/widget/layout/linear/LLOfTwoFocusableInTouchMode.java b/core/tests/coretests/src/android/widget/layout/linear/LLOfTwoFocusableInTouchMode.java index 1ba56ba99717..0d8d834fd48b 100644 --- a/core/tests/coretests/src/android/widget/layout/linear/LLOfTwoFocusableInTouchMode.java +++ b/core/tests/coretests/src/android/widget/layout/linear/LLOfTwoFocusableInTouchMode.java @@ -16,12 +16,12 @@ package android.widget.layout.linear; -import com.android.frameworks.coretests.R; - import android.app.Activity; import android.os.Bundle; import android.view.View; +import com.android.frameworks.coretests.R; + public class LLOfTwoFocusableInTouchMode extends Activity { private View mButton1; @@ -63,6 +63,7 @@ public class LLOfTwoFocusableInTouchMode extends Activity { mB3Fired = true; } }); + getWindow().getDecorView().restoreDefaultFocus(); } public View getButton1() { diff --git a/core/tests/coretests/src/android/widget/listview/AdjacentListsWithAdjacentISVsInside.java b/core/tests/coretests/src/android/widget/listview/AdjacentListsWithAdjacentISVsInside.java index 98fbed31eabf..9e49719c6527 100644 --- a/core/tests/coretests/src/android/widget/listview/AdjacentListsWithAdjacentISVsInside.java +++ b/core/tests/coretests/src/android/widget/listview/AdjacentListsWithAdjacentISVsInside.java @@ -16,10 +16,9 @@ package android.widget.listview; -import android.util.InternalSelectionView; - import android.app.Activity; import android.os.Bundle; +import android.util.InternalSelectionView; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; @@ -80,6 +79,7 @@ public class AdjacentListsWithAdjacentISVsInside extends Activity { setContentView(combineAdjacent(mLeftListView, mRightListView)); + getWindow().getDecorView().restoreDefaultFocus(); } private static View combineAdjacent(View... views) { diff --git a/core/tests/coretests/src/android/widget/listview/focus/ListHorizontalFocusWithinItemWinsTest.java b/core/tests/coretests/src/android/widget/listview/focus/ListHorizontalFocusWithinItemWinsTest.java index 8f971bb4d972..edc60b58e9d0 100644 --- a/core/tests/coretests/src/android/widget/listview/focus/ListHorizontalFocusWithinItemWinsTest.java +++ b/core/tests/coretests/src/android/widget/listview/focus/ListHorizontalFocusWithinItemWinsTest.java @@ -16,15 +16,12 @@ package android.widget.listview.focus; -import android.widget.listview.ListHorizontalFocusWithinItemWins; - import android.test.ActivityInstrumentationTestCase; import android.test.suitebuilder.annotation.MediumTest; -import android.view.FocusFinder; import android.view.KeyEvent; -import android.view.View; import android.widget.Button; import android.widget.ListView; +import android.widget.listview.ListHorizontalFocusWithinItemWins; public class ListHorizontalFocusWithinItemWinsTest extends ActivityInstrumentationTestCase<ListHorizontalFocusWithinItemWins> { @@ -51,12 +48,6 @@ public class ListHorizontalFocusWithinItemWinsTest extends ActivityInstrumentati public void testPreconditions() { assertEquals("list position", 0, mListView.getSelectedItemPosition()); assertTrue("mTopLeftButton.isFocused()", mTopLeftButton.isFocused()); - assertEquals("global focus search to right from top left is bottom middle", - mBottomMiddleButton, - FocusFinder.getInstance().findNextFocus(mListView, mTopLeftButton, View.FOCUS_RIGHT)); - assertEquals("global focus search to left from top right is bottom middle", - mBottomMiddleButton, - FocusFinder.getInstance().findNextFocus(mListView, mTopRightButton, View.FOCUS_LEFT)); } @MediumTest diff --git a/core/tests/coretests/src/android/widget/touchmode/TouchModeFocusChangeTest.java b/core/tests/coretests/src/android/widget/touchmode/TouchModeFocusChangeTest.java index bd6977efed0f..5a6110c08116 100644 --- a/core/tests/coretests/src/android/widget/touchmode/TouchModeFocusChangeTest.java +++ b/core/tests/coretests/src/android/widget/touchmode/TouchModeFocusChangeTest.java @@ -16,7 +16,6 @@ package android.widget.touchmode; -import android.widget.layout.linear.LLOfButtons1; import static android.util.TouchModeFlexibleAsserts.assertInTouchModeAfterClick; import static android.util.TouchModeFlexibleAsserts.assertInTouchModeAfterTap; import static android.util.TouchModeFlexibleAsserts.assertNotInTouchModeAfterKey; @@ -25,6 +24,8 @@ import android.test.ActivityInstrumentationTestCase; import android.test.suitebuilder.annotation.MediumTest; import android.view.KeyEvent; import android.widget.Button; +import android.widget.layout.linear.LLOfButtons1; + /** * Make sure focus isn't kept by buttons when entering touch mode. @@ -52,7 +53,6 @@ public class TouchModeFocusChangeTest extends ActivityInstrumentationTestCase<LL @MediumTest public void testPreconditions() { assertFalse("we should not be in touch mode", mActivity.isInTouchMode()); - assertTrue("top button should have focus", mFirstButton.isFocused()); } @MediumTest |