Merge "Add Screen Layout Size and Long Tests" into ics-mr0
diff --git a/tests/src/android/app/cts/SearchManagerStubActivity.java b/tests/src/android/app/cts/SearchManagerStubActivity.java
index 0b64382..a6a0c99 100644
--- a/tests/src/android/app/cts/SearchManagerStubActivity.java
+++ b/tests/src/android/app/cts/SearchManagerStubActivity.java
@@ -49,11 +49,6 @@
         super.onCreate(icicle);
         mSearchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
         mComponentName = getComponentName();
-    }
-
-    @Override
-    protected void onResume() {
-        super.onResume();
         String action = getIntent().getAction();
         if (action.equals(TEST_STOP_SEARCH)) {
             testStopSearch();
diff --git a/tests/tests/app/src/android/app/cts/DialogTest.java b/tests/tests/app/src/android/app/cts/DialogTest.java
index 0afb051..fdcd395 100644
--- a/tests/tests/app/src/android/app/cts/DialogTest.java
+++ b/tests/tests/app/src/android/app/cts/DialogTest.java
@@ -58,8 +58,6 @@
 public class DialogTest extends ActivityInstrumentationTestCase2<DialogStubActivity> {
 
     protected static final long SLEEP_TIME = 200;
-    private static final float MOTION_X = -20.0f;
-    private static final float MOTION_Y = -20.0f;
     private static final String STUB_ACTIVITY_PACKAGE = "com.android.cts.stub";
     private static final long TEST_TIMEOUT = 1000L;
 
@@ -545,11 +543,13 @@
         assertNull(d.touchEvent);
         assertFalse(d.isOnTouchEventCalled);
 
-        long eventTime = SystemClock.uptimeMillis();
-        MotionEvent touchMotionEvent = MotionEvent.obtain(eventTime,
-                eventTime, MotionEvent.ACTION_DOWN,
-                MOTION_X, MOTION_Y, 0);
-        // send a touch motion event, and System will call onTouchEvent
+        // Send a touch event outside the activity.  The event will be ignored
+        // because closeOnTouchOutside is false.
+        d.setCanceledOnTouchOutside(false);
+
+        long now = SystemClock.uptimeMillis();
+        MotionEvent touchMotionEvent = MotionEvent.obtain(now, now, MotionEvent.ACTION_DOWN,
+                -20.0f, -20.0f, 0);
         mInstrumentation.sendPointerSync(touchMotionEvent);
 
         assertFalse(d.dispatchTouchEventResult);
@@ -560,12 +560,12 @@
         d.isOnTouchEventCalled = false;
         assertTrue(d.isShowing());
 
-        // set cancel on touch out side
+        // Send a touch event outside the activity.  This time the dialog will be dismissed
+        // because closeOnTouchOutside is true.
         d.setCanceledOnTouchOutside(true);
-        touchMotionEvent = MotionEvent.obtain(eventTime + 1,
-                eventTime, MotionEvent.ACTION_DOWN,
-                MOTION_X, MOTION_Y, 0);
-        // send a out side touch motion event, then the dialog will dismiss
+
+        touchMotionEvent = MotionEvent.obtain(now + 1, now, MotionEvent.ACTION_DOWN,
+                -20.0f, -20.0f, 0);
         mInstrumentation.sendPointerSync(touchMotionEvent);
 
         assertTrue(d.dispatchTouchEventResult);
@@ -593,7 +593,7 @@
         final TestDialog d = (TestDialog) mActivity.getDialog();
         long eventTime = SystemClock.uptimeMillis();
         final MotionEvent trackBallEvent = MotionEvent.obtain(eventTime, eventTime,
-                MotionEvent.ACTION_DOWN, MOTION_X, MOTION_Y, 0);
+                MotionEvent.ACTION_DOWN, -20.0f, -20.0f, 0);
 
         assertNull(d.trackballEvent);
         assertNull(d.onTrackballEvent);
diff --git a/tests/tests/app/src/android/app/cts/InstrumentationTest.java b/tests/tests/app/src/android/app/cts/InstrumentationTest.java
index d2c55c2..d911517 100644
--- a/tests/tests/app/src/android/app/cts/InstrumentationTest.java
+++ b/tests/tests/app/src/android/app/cts/InstrumentationTest.java
@@ -34,6 +34,7 @@
 import android.content.IntentFilter;
 import android.content.pm.ActivityInfo;
 import android.content.res.Configuration;
+import android.graphics.Point;
 import android.graphics.drawable.Drawable;
 import android.net.Uri;
 import android.os.Bundle;
@@ -62,22 +63,12 @@
     private Intent mIntent;
     private boolean mRunOnMainSyncResult;
     private Context mContext;
-    private MotionEvent mMotionEvent;
 
     @Override
     protected void setUp() throws Exception {
         super.setUp();
         mInstrumentation = getInstrumentation();
         mContext = mInstrumentation.getTargetContext();
-        final long downTime = SystemClock.uptimeMillis();
-        final long eventTime = SystemClock.uptimeMillis();
-        // use coordinates for MotionEvent that do not include the status bar
-        // TODO: is there a more deterministic way to get these values
-        final long x = 100;
-        final long y = 100;
-        final int metaState = 0;
-        mMotionEvent = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, x, y,
-                metaState);
         mIntent = new Intent(mContext, InstrumentationTestActivity.class);
         mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         mActivity = (InstrumentationTestActivity) mInstrumentation.startActivitySync(mIntent);
@@ -269,13 +260,16 @@
         args = {MotionEvent.class}
     )
     public void testSendTrackballEventSync() throws Exception {
-        mInstrumentation.sendTrackballEventSync(mMotionEvent);
+        long now = SystemClock.uptimeMillis();
+        MotionEvent orig = MotionEvent.obtain(now, now, MotionEvent.ACTION_DOWN,
+                100, 100, 0);
+        mInstrumentation.sendTrackballEventSync(orig);
         mInstrumentation.waitForIdleSync();
 
         MotionEvent motionEvent = mActivity.getMotionEvent();
-        assertEquals(mMotionEvent.getMetaState(), motionEvent.getMetaState());
-        assertEquals(mMotionEvent.getEventTime(), motionEvent.getEventTime());
-        assertEquals(mMotionEvent.getDownTime(), motionEvent.getDownTime());
+        assertEquals(orig.getMetaState(), motionEvent.getMetaState());
+        assertEquals(orig.getEventTime(), motionEvent.getEventTime());
+        assertEquals(orig.getDownTime(), motionEvent.getDownTime());
     }
 
     @TestTargetNew(
@@ -538,7 +532,20 @@
     public void testSendPointerSync() throws Exception {
         mInstrumentation.waitForIdleSync();
         mInstrumentation.setInTouchMode(true);
-        mInstrumentation.sendPointerSync(mMotionEvent);
+
+        // Send a touch event to the middle of the activity.
+        // We assume that the Activity is empty so there won't be anything in the middle
+        // to handle the touch.  Consequently the Activity should receive onTouchEvent
+        // because nothing else handled it.
+        Point size = new Point();
+        mActivity.getWindowManager().getDefaultDisplay().getSize(size);
+        final int x = size.x / 2;
+        final int y = size.y / 2;
+        long now = SystemClock.uptimeMillis();
+        MotionEvent orig = MotionEvent.obtain(now, now, MotionEvent.ACTION_DOWN,
+                x, y, 0);
+        mInstrumentation.sendPointerSync(orig);
+
         mInstrumentation.waitForIdleSync();
         assertTrue(mActivity.isOnTouchEventCalled());
         mActivity.setOnTouchEventCalled(false);
diff --git a/tests/tests/content/src/android/content/pm/cts/PackageManagerTest.java b/tests/tests/content/src/android/content/pm/cts/PackageManagerTest.java
index 1857f13..3e8eb0d 100644
--- a/tests/tests/content/src/android/content/pm/cts/PackageManagerTest.java
+++ b/tests/tests/content/src/android/content/pm/cts/PackageManagerTest.java
@@ -785,4 +785,19 @@
         assertEquals(xmlName, mPackageManager.getResourcesForApplication(PACKAGE_NAME)
                 .getResourceName(resourceId));
     }
+
+    public void testGetPackageArchiveInfo() throws Exception {
+        final String apkPath = getContext().getPackageCodePath();
+        final String apkName = getContext().getPackageName();
+
+        final int flags = PackageManager.GET_SIGNATURES;
+
+        final PackageInfo pkgInfo = mPackageManager.getPackageArchiveInfo(apkPath, flags);
+
+        assertEquals("getPackageArchiveInfo should return the correct package name",
+                apkName, pkgInfo.packageName);
+
+        assertNotNull("Signatures should have been collected when GET_SIGNATURES flag specified",
+                pkgInfo.signatures);
+    }
 }