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
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<requestFocus />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/editText"
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
<requestFocus />
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="vertical"
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user