Fix view tests to account for alternate actionbars
don't assume action bar is on the top; and initial focus may be different when an action bar is present
omit actionbar on window tests because the initial focus difference is not relevant for those tests
TESTED= on tablet and tv
Change-Id: Icdc6525ff9627d7532c4737da9cff21cfdd5ce79
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
index 6f302a6..bcc81a7 100644
--- a/tests/AndroidManifest.xml
+++ b/tests/AndroidManifest.xml
@@ -314,6 +314,7 @@
</activity>
<activity android:name="android.view.cts.WindowStubActivity"
+ android:theme="@android:style/Theme.Holo.NoActionBar"
android:label="WindowStubActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
diff --git a/tests/tests/view/src/android/view/cts/ViewTest.java b/tests/tests/view/src/android/view/cts/ViewTest.java
index d78de3a..c5f0104 100644
--- a/tests/tests/view/src/android/view/cts/ViewTest.java
+++ b/tests/tests/view/src/android/view/cts/ViewTest.java
@@ -2437,12 +2437,12 @@
View mockView = mActivity.findViewById(R.id.mock_view);
mockView.getLocationOnScreen(location);
- assertEquals(0, location[0]);
+ assertEquals(layoutLocation[0], location[0]);
assertEquals(layoutLocation[1], location[1]);
View scrollView = mActivity.findViewById(R.id.scroll_view);
scrollView.getLocationOnScreen(location);
- assertEquals(0, location[0]);
+ assertEquals(layoutLocation[0], location[0]);
assertEquals(layoutLocation[1] + mockView.getHeight(), location[1]);
try {
diff --git a/tests/tests/view/src/android/view/cts/View_UsingViewsTest.java b/tests/tests/view/src/android/view/cts/View_UsingViewsTest.java
index 7bdcfd2..3bc500c 100644
--- a/tests/tests/view/src/android/view/cts/View_UsingViewsTest.java
+++ b/tests/tests/view/src/android/view/cts/View_UsingViewsTest.java
@@ -469,6 +469,8 @@
})
@UiThreadTest
public void testSetFocus() throws Throwable {
+ boolean focusWasOnEditText = mEditText.hasFocus();
+
MockOnFocusChangeListener editListener = new MockOnFocusChangeListener();
MockOnFocusChangeListener okListener = new MockOnFocusChangeListener();
MockOnFocusChangeListener cancelListener = new MockOnFocusChangeListener();
@@ -491,7 +493,7 @@
assertFalse(mSymbolTextView.hasFocus());
assertFalse(mWarningTextView.hasFocus());
- assertTrue(editListener.hasFocus());
+ assertTrue(editListener.hasFocus() || focusWasOnEditText);
assertFalse(okListener.hasFocus());
assertFalse(cancelListener.hasFocus());
assertFalse(symbolListener.hasFocus());