manual cherry-pick of 45f8e6a523a096a3781f90d4fd5d54dcc0673a7e

Change-Id: I770948540f3aca9d930edea7a12119ff63fe9bdf
diff --git a/development/ide/eclipse/.classpath b/development/ide/eclipse/.classpath
new file mode 100644
index 0000000..841158a
--- /dev/null
+++ b/development/ide/eclipse/.classpath
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="cts/tests/ApiDemosReferenceTest/src"/>
+	<classpathentry kind="src" path="cts/tests/ProcessTest/src"/>
+	<classpathentry kind="src" path="cts/tests/ProcessTest/NoShareUidApp/src"/>
+	<classpathentry kind="src" path="cts/tests/ProcessTest/ShareUidApp/src"/>
+	<classpathentry kind="src" path="cts/tests/SignatureTest/src"/>
+	<classpathentry kind="src" path="cts/tests/SignatureTest/tests/src"/>
+	<classpathentry kind="src" path="cts/tests/accessibilityservice/src"/>
+	<classpathentry kind="src" path="cts/tests/appsecurity-tests/src"/>
+	<classpathentry kind="src" path="cts/tests/core/runner/src"/>
+	<classpathentry kind="src" path="cts/tests/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/accessibilityservice/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/accounts/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/app/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/bluetooth/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/content/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/database/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/dpi/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/dpi2/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/example/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/gesture/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/graphics/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/hardware/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/jni/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/location/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/media/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/net/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/os/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/performance/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/performance2/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/performance3/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/performance4/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/performance5/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/permission/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/permission2/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/provider/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/speech/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/telephony/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/text/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/util/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/view/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/webkit/src"/>
+	<classpathentry kind="src" path="cts/tests/tests/widget/src"/>
+        <classpathentry kind="src" path="cts/tools/annotation-helper/src"/>
+	<classpathentry kind="src" path="cts/tools/cts-reference-app-lib/src"/>
+	<classpathentry kind="src" path="cts/tools/dasm/src"/>
+        <classpathentry kind="src" path="cts/tools/device-setup/TestDeviceSetup/src"/>
+	<classpathentry kind="src" path="cts/tools/dex-tools/src"/>
+	<classpathentry kind="src" path="cts/tools/dx-tests/src"/>
+	<classpathentry kind="src" path="cts/tools/host/src"/>
+	<classpathentry kind="src" path="cts/tools/host/test"/>
+        <classpathentry kind="src" path="cts/tools/signature-tools/src"/>
+        <classpathentry kind="src" path="cts/tools/signature-tools/test"/>
+        <classpathentry kind="src" path="cts/tools/spec-progress/src"/>
+        <classpathentry kind="src" path="cts/tools/test-progress-new/src"/>
+        <classpathentry kind="src" path="cts/tools/utils"/>
+        <classpathentry kind="src" path="cts/tools/vm-tests/src"/>
+        <classpathentry kind="src" path="out/target/common/obj/APPS/CtsTestStubs_intermediates/src/src"/>
+        <classpathentry kind="src" path="out/target/common/obj/APPS/CtsAccessibilityServiceTestCases_intermediates/src/src"/>
+</classpath>
diff --git a/development/ide/eclipse/genclasspath.sh b/development/ide/eclipse/genclasspath.sh
new file mode 100755
index 0000000..00ee9b3
--- /dev/null
+++ b/development/ide/eclipse/genclasspath.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+# Outputs a classpath file containing classpaths from development/ide/eclipse
+# and additional classpaths from cts/development/ide/eclipse.
+#
+# From your $ANDROID_BUILD_TOP directory:
+# ./cts/development/ide/eclipse/genclasspath.sh > .classpath
+
+if [[ -z $ANDROID_BUILD_TOP ]]; then
+  echo "Run 'lunch' to set \$ANDROID_BUILD_TOP" >&2
+  exit 1
+fi
+
+echo '<?xml version="1.0" encoding="UTF-8"?>'
+echo '<classpath>'
+cat $ANDROID_BUILD_TOP/cts/development/ide/eclipse/.classpath | grep classpathentry
+cat $ANDROID_BUILD_TOP/development/ide/eclipse/.classpath | grep classpathentry
+echo '</classpath>'
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
index e5f1416..cdddffc 100644
--- a/tests/AndroidManifest.xml
+++ b/tests/AndroidManifest.xml
@@ -551,6 +551,22 @@
             android:screenOrientation="landscape">
         </activity>
 
+        <activity android:name="android.view.inputmethod.cts.InputMethodStubActivity"
+            android:label="InputMethodStubActivity">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN"/>
+                <category android:name="android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST" />
+            </intent-filter>
+        </activity>
+        <service android:name="android.view.inputmethod.cts.InputMethodInfoStub"
+            android:label="InputMethodInfoStub">
+            <intent-filter>
+                <action android:name="android.view.InputMethod" />
+            </intent-filter>
+            <meta-data android:name="android.view.im"
+                android:resource="@xml/method" />
+        </service>
+
         <activity android:name="android.view.cts.MenuInflaterStubActivity"
                                         android:label="MenuInflaterStubActivity">
             <intent-filter>
@@ -887,7 +903,9 @@
         </service>
         <service android:name="android.app.cts.IntentServiceStub"/>
 
-        <activity android:name="android.app.cts.LaunchpadActivity" android:multiprocess="true">
+        <activity android:name="android.app.cts.LaunchpadActivity" 
+                  android:configChanges="keyboardHidden|orientation"
+                  android:multiprocess="true">
         </activity>
 
         <service android:name="android.content.cts.MockSyncAdapterService" android:exported="true">
@@ -909,6 +927,9 @@
                        android:resource="@xml/authenticator" />
         </service>
 
+        <activity android:name="android.opengl.cts.GLSurfaceViewStubActivity"
+                  android:label="GLSurfaceViewStub"/>
+
     </application>
 
     <!--Test for PackageManager, please put this at the very beginning-->
diff --git a/tests/accessibilityservice/Android.mk b/tests/accessibilityservice/Android.mk
new file mode 100644
index 0000000..50fe6b0
--- /dev/null
+++ b/tests/accessibilityservice/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2010 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_JAVA_LIBRARIES := android.test.runner
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_SRC_FILES += \
+  src/android/accessibilityservice/IAccessibilityServiceDelegate.aidl \
+  src/android/accessibilityservice/IAccessibilityServiceDelegateConnection.aidl
+
+LOCAL_PACKAGE_NAME := CtsDelegatingAccessibilityService
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/tests/accessibilityservice/AndroidManifest.xml b/tests/accessibilityservice/AndroidManifest.xml
new file mode 100644
index 0000000..29164bc
--- /dev/null
+++ b/tests/accessibilityservice/AndroidManifest.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+          package="android.accessibilityservice.delegate">
+
+  <application>
+
+    <uses-library android:name="android.test.runner"/>
+
+    <service android:name=".DelegatingAccessibilityService"
+             android:label="@string/title_delegating_accessibility_service">
+      <intent-filter>
+        <action android:name="android.accessibilityservice.AccessibilityService"/>
+      </intent-filter>
+    </service>
+
+    <service android:name=".DelegatingAccessibilityService$DelegatingConnectionService"
+             android:exported="true"/>
+
+  </application>
+
+</manifest>
diff --git a/tests/accessibilityservice/res/values/strings.xml b/tests/accessibilityservice/res/values/strings.xml
new file mode 100644
index 0000000..4c717c1
--- /dev/null
+++ b/tests/accessibilityservice/res/values/strings.xml
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<resources>
+
+    <!-- String title of the mock accessibility service -->
+    <string name="title_delegating_accessibility_service">Delegating Accessibility Service</string>
+
+    <!-- String title of the accessibility end-to-end test activity -->
+    <string name="accessibility_end_to_end_test_activity">End-to-end test</string>
+
+    <!-- String value of used as text input -->
+    <string name="text_input_blah">Blah</string>
+
+    <!-- String value of used as text input -->
+    <string name="text_input_blah_blah">Blah blah</string>
+
+    <!-- String title of the button -->
+    <string name="button_title">Click me</string>
+
+    <!-- String value of the first list item -->
+    <string name="first_list_item">First list item</string>
+
+    <!-- String value of the second list item -->
+    <string name="second_list_item">Second list item</string>
+
+    <!-- String alert title -->
+    <string name="alert_title">Alert title</string>
+
+    <!-- String alert message -->
+    <string name="alert_message">Alert message</string>
+
+    <!-- String notification message -->
+    <string name="notification_message">Notification message</string>
+
+</resources>
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/IAccessibilityServiceDelegate.aidl b/tests/accessibilityservice/src/android/accessibilityservice/IAccessibilityServiceDelegate.aidl
new file mode 100644
index 0000000..b5ebf19
--- /dev/null
+++ b/tests/accessibilityservice/src/android/accessibilityservice/IAccessibilityServiceDelegate.aidl
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.accessibilityservice;
+
+import android.view.accessibility.AccessibilityEvent;
+
+/**
+ * Interface for interacting with the accessibility service mock.
+ */
+interface IAccessibilityServiceDelegate {
+
+    /**
+     * Delegate an {@link android.view.accessibility.AccessibilityEvent}.
+     */
+    void onAccessibilityEvent(in AccessibilityEvent event);
+
+    /**
+     * Delegate an interrupt request.
+     */
+    void onInterrupt();
+}
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/IAccessibilityServiceDelegateConnection.aidl b/tests/accessibilityservice/src/android/accessibilityservice/IAccessibilityServiceDelegateConnection.aidl
new file mode 100644
index 0000000..62703dc
--- /dev/null
+++ b/tests/accessibilityservice/src/android/accessibilityservice/IAccessibilityServiceDelegateConnection.aidl
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.accessibilityservice;
+
+import android.os.IBinder;
+
+/**
+ * Interface for registering an accessibility service delegate.
+ */
+oneway interface IAccessibilityServiceDelegateConnection {
+
+    /**
+     * Sets the delegate interface to which the
+     * {@link DelegatingAccessibilityService} to delegate.
+     */
+    void setAccessibilityServiceDelegate(in IBinder binder);
+}
diff --git a/tests/accessibilityservice/src/android/accessibilityservice/delegate/DelegatingAccessibilityService.java b/tests/accessibilityservice/src/android/accessibilityservice/delegate/DelegatingAccessibilityService.java
new file mode 100644
index 0000000..37a9c54
--- /dev/null
+++ b/tests/accessibilityservice/src/android/accessibilityservice/delegate/DelegatingAccessibilityService.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.accessibilityservice.delegate;
+
+import android.accessibilityservice.AccessibilityService;
+import android.accessibilityservice.AccessibilityServiceInfo;
+import android.accessibilityservice.IAccessibilityServiceDelegate;
+import android.accessibilityservice.IAccessibilityServiceDelegateConnection;
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.util.Log;
+import android.view.accessibility.AccessibilityEvent;
+
+/**
+ * This class is an accessibility service mock to which the system is bound and
+ * exposes a mock interface to the CTS accessibility tests.
+ * </p>
+ * Note: The end-to-end test is composed of two APKs, one with a mock accessibility
+ * service, another with the instrumented activity and test cases. The
+ * motivation for two APKs design is that CTS tests cannot access the secure
+ * settings which is required for enabling accessibility and accessibility
+ * services. Therefore, manual installation of this package is required. Once
+ * the package has been installed accessibility must be enabled (Settings ->
+ * Accessibility), the mock service must be enabled (Settings -> Accessibility
+ * -> Mock Accessibility Service), and then the CTS tests in this package
+ * <strong>CtsAccessibilityServiceTestCases.apk</strong> located in
+ * <strong>cts/tests/tests/accessibility</strong> can be successfully run.
+ * Further, the mock and tests run in separate processes since the
+ * instrumentation restarts the process in which it is running and this breaks
+ * the binding between the mock accessibility service and the system.
+ */
+public class DelegatingAccessibilityService extends AccessibilityService {
+
+    /**
+     * Tag used for logging.
+     */
+    private static final String LOG_TAG = "AccessibilityServiceDelegate";
+
+    /**
+     * Handle to the instance used by the accessibility service connection.
+     */
+    static DelegatingAccessibilityService sServiceDelegate;
+
+    /**
+     * Interface for delegating events and interrupt requests.
+     */
+    private IAccessibilityServiceDelegate mDelegateInterface;
+
+    @Override
+    protected void onServiceConnected() {
+        AccessibilityServiceInfo info = new AccessibilityServiceInfo();
+        info.eventTypes = AccessibilityEvent.TYPES_ALL_MASK;
+        info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
+        info.packageNames = new String[] {
+            "com.android.cts.accessibilityservice"
+        };
+        setServiceInfo(info);
+
+        // the service is ready to be used only
+        // after the system has bound to it
+        sServiceDelegate = this;
+    }
+
+    @Override
+    public void onAccessibilityEvent(AccessibilityEvent event) {
+        if (mDelegateInterface == null) {
+            return;
+        }
+
+        try {
+            mDelegateInterface.onAccessibilityEvent(event);
+        } catch (RemoteException re) {
+            Log.i(LOG_TAG, "Dead: " + mDelegateInterface.toString() + " cleaning up.");
+            mDelegateInterface = null;
+        }
+    }
+
+    @Override
+    public void onInterrupt() {
+        if (mDelegateInterface == null) {
+            return;
+        }
+
+        try {
+            mDelegateInterface.onInterrupt();
+        } catch (RemoteException re) {
+            Log.i(LOG_TAG, "Dead: " + mDelegateInterface.toString() + " cleaning up.");
+            mDelegateInterface = null;
+        }
+    }
+
+    /**
+     * Sets the interface to which to delegate.
+     *
+     * @param delegateInterface The delegate interface.
+     */
+    private void setDelegateInterface(IAccessibilityServiceDelegate delegateInterface) {
+        mDelegateInterface = delegateInterface;
+    }
+
+    /**
+     * This is a service to which the end-to-end CTS test connects to pass a
+     * delegate interface to which the {@link DelegatingAccessibilityService}
+     * to delegate.
+     */
+    public static class DelegatingConnectionService extends Service {
+
+        @Override
+        public IBinder onBind(Intent intent) {
+            if (sServiceDelegate == null) {
+                return null;
+            }
+            return new AccessibilityServiceDelegateConnection();
+        }
+
+        /**
+         * This class is the connection wrapper passed to the end-to-end CTS
+         * test, so the latter can pass a delegating interface.
+         */
+        private class AccessibilityServiceDelegateConnection extends
+                IAccessibilityServiceDelegateConnection.Stub {
+
+            public void setAccessibilityServiceDelegate(IBinder binder) {
+                sServiceDelegate.setDelegateInterface(IAccessibilityServiceDelegate.Stub
+                        .asInterface(binder));
+            }
+        }
+    }
+}
diff --git a/tests/appsecurity-tests/src/com/android/cts/appsecurity/AppSecurityTests.java b/tests/appsecurity-tests/src/com/android/cts/appsecurity/AppSecurityTests.java
index a4f85a1..2833fa4 100644
--- a/tests/appsecurity-tests/src/com/android/cts/appsecurity/AppSecurityTests.java
+++ b/tests/appsecurity-tests/src/com/android/cts/appsecurity/AppSecurityTests.java
@@ -166,18 +166,15 @@
                     getTestAppFilePath(TARGET_INSTRUMENT_APK), false);
             assertNull("failed to install target instrumentation app", installResult);
 
-            // the app will install, but will get error at runtime
+            // the app will install, but will get error at runtime when starting instrumentation
             installResult = getDevice().installPackage(getTestAppFilePath(INSTRUMENT_DIFF_CERT_APK),
                     false);
             assertNull("failed to install instrumentation app with diff cert", installResult);
-            // run INSTRUMENT_DIFF_CERT_PKG tests - expect the test run to fail
-            String runResults = runDeviceTestsWithRunResult(INSTRUMENT_DIFF_CERT_PKG);
-            assertNotNull("running instrumentation with diff cert unexpectedly succeeded",
-                    runResults);
-            String msg = String.format("Unexpected error message result from %s. Received %s",
-                    "instrumentation with diff cert. Expected starts with Permission Denial",
-                    runResults);
-            assertTrue(msg, runResults.startsWith("Permission Denial"));
+            // run INSTRUMENT_DIFF_CERT_PKG tests
+            // this test will attempt to call startInstrumentation directly and verify
+            // SecurityException is thrown 
+            assertTrue("running instrumentation with diff cert unexpectedly succeeded",
+                    runDeviceTests(INSTRUMENT_DIFF_CERT_PKG));
         }
         finally {
             getDevice().uninstallPackage(TARGET_INSTRUMENT_PKG);
@@ -248,18 +245,6 @@
         return listener;
     }
 
-    /**
-     * Helper method to run the specified packages tests, and return the test run error message.
-     *
-     * @param pkgName Android application package for tests
-     * @return the test run error message or <code>null</code> if test run completed.
-     * @throws IOException if connection to device was lost
-     */
-    private String runDeviceTestsWithRunResult(String pkgName) throws IOException {
-        CollectingTestRunListener listener = doRunTests(pkgName);
-        return listener.getTestRunErrorMessage();
-    }
-
     private static class CollectingTestRunListener implements ITestRunListener {
 
         private boolean mAllTestsPassed = true;
diff --git a/tests/appsecurity-tests/test-apps/InstrumentationAppDiffCert/AndroidManifest.xml b/tests/appsecurity-tests/test-apps/InstrumentationAppDiffCert/AndroidManifest.xml
index e62f968..8102656 100644
--- a/tests/appsecurity-tests/test-apps/InstrumentationAppDiffCert/AndroidManifest.xml
+++ b/tests/appsecurity-tests/test-apps/InstrumentationAppDiffCert/AndroidManifest.xml
@@ -26,7 +26,15 @@
     </application>
 
     <!-- assumes com.android.cts.targetinstrumentationapp is signed with diff cert -->
-    <instrumentation android:name="android.test.InstrumentationTestRunner"
+    <instrumentation android:name="android.app.Instrumentation"
                      android:targetPackage="com.android.cts.targetinstrumentationapp"
+                     android:label="Instrumentation that targets app with different cert" />
+
+    <!--
+    A self-instrumenting test runner, that will try to start the above instrumentation and
+    verify it fails.
+     -->
+    <instrumentation android:name="android.test.InstrumentationTestRunner"
+                     android:targetPackage="com.android.cts.instrumentationdiffcertapp"
                      android:label="Test for instrumentation with different cert" />
 </manifest>
diff --git a/tests/appsecurity-tests/test-apps/InstrumentationAppDiffCert/src/com/android/cts/instrumentationdiffcertapp/InstrumentationFailToRunTest.java b/tests/appsecurity-tests/test-apps/InstrumentationAppDiffCert/src/com/android/cts/instrumentationdiffcertapp/InstrumentationFailToRunTest.java
index bd5de8c..9c320d9 100644
--- a/tests/appsecurity-tests/test-apps/InstrumentationAppDiffCert/src/com/android/cts/instrumentationdiffcertapp/InstrumentationFailToRunTest.java
+++ b/tests/appsecurity-tests/test-apps/InstrumentationAppDiffCert/src/com/android/cts/instrumentationdiffcertapp/InstrumentationFailToRunTest.java
@@ -16,17 +16,29 @@
 
 package com.android.cts.instrumentationdiffcertapp;
 
-import junit.framework.TestCase;
+import android.app.Instrumentation;
+import android.content.ComponentName;
+import android.content.Context;
+import android.os.Bundle;
+import android.test.InstrumentationTestCase;
 
 /**
- * Test that is expected not to run
+ * Test that a instrumentation targeting another app with a different cert fails.
  */
-public class InstrumentationFailToRunTest extends TestCase {
+public class InstrumentationFailToRunTest extends InstrumentationTestCase {
 
-    /**
-     * Test method that is expected not to run.
-     */
     public void testInstrumentationNotAllowed() {
-        fail("instrumentating app with different cert should fail");
+        Context myContext = getInstrumentation().getContext();
+        // assumes android.app.Instrumentation has been defined in this app's AndroidManifest.xml
+        // as targeting an app with a different cert
+        ComponentName appDiffCertInstrumentation = new ComponentName(myContext,
+                Instrumentation.class);
+        try {
+            getInstrumentation().getContext().startInstrumentation(appDiffCertInstrumentation,
+                null, new Bundle());
+            fail("could launch instrumentation");
+        } catch (SecurityException e) {
+            // expected
+        }
     }
 }
diff --git a/tests/res/layout/gridlayout_anim_controller_layout.xml b/tests/res/layout/gridlayout_anim_controller_layout.xml
index 4fe4237..0ff2d46 100644
--- a/tests/res/layout/gridlayout_anim_controller_layout.xml
+++ b/tests/res/layout/gridlayout_anim_controller_layout.xml
@@ -21,7 +21,7 @@
     android:padding="10dp"
     android:verticalSpacing="20dp"
     android:horizontalSpacing="20dp"
-    android:numColumns="auto_fit"
+    android:numColumns="3"
     android:columnWidth="60dp"
     android:stretchMode="columnWidth"
     android:gravity="center"
diff --git a/tests/res/layout/inputmethod_edittext.xml b/tests/res/layout/inputmethod_edittext.xml
new file mode 100755
index 0000000..849b411
--- /dev/null
+++ b/tests/res/layout/inputmethod_edittext.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+                  android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:background="@drawable/blue"
+                android:padding="10px">
+
+    <EditText android:id="@+id/entry"
+              android:layout_width="fill_parent"
+              android:layout_height="wrap_content"
+              android:background="@android:drawable/editbox_background"/>
+
+</RelativeLayout>
diff --git a/tests/res/xml/method.xml b/tests/res/xml/method.xml
new file mode 100644
index 0000000..763faa5
--- /dev/null
+++ b/tests/res/xml/method.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2008 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<input-method xmlns:android="http://schemas.android.com/apk/res/android"
+        android:settingsActivity="android.view.inputmethod.cts.InputMethodInfoStub"
+/>
diff --git a/tests/src/android/app/cts/ActivityTestsBase.java b/tests/src/android/app/cts/ActivityTestsBase.java
index 7bbedd8..426a8b8 100644
--- a/tests/src/android/app/cts/ActivityTestsBase.java
+++ b/tests/src/android/app/cts/ActivityTestsBase.java
@@ -27,6 +27,8 @@
     public static final String PERMISSION_GRANTED = "android.app.cts.permission.TEST_GRANTED";
     public static final String PERMISSION_DENIED = "android.app.cts.permission.TEST_DENIED";
 
+    private static final int TIMEOUT_MS = 60 * 1000;
+
     protected Intent mIntent;
 
     private PerformanceTestCase.Intermediates mIntermediates;
@@ -125,6 +127,11 @@
     }
 
     public int runLaunchpad(String action) {
+        startLaunchpadActivity(action);
+        return waitForResultOrThrow(TIMEOUT_MS);
+    }
+
+    private void startLaunchpadActivity(String action) {
         LaunchpadActivity.setCallingTest(this);
 
         synchronized (this) {
@@ -133,8 +140,6 @@
             mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
             mContext.startActivity(mIntent);
         }
-
-        return waitForResultOrThrow(60 * 1000);
     }
 
     public int waitForResultOrThrow(int timeoutMs) {
@@ -186,6 +191,7 @@
         return mResultCode;
     }
 
+
     public int getResultCode() {
         return mResultCode;
     }
diff --git a/tests/src/android/app/cts/LaunchpadActivity.java b/tests/src/android/app/cts/LaunchpadActivity.java
index 566e7b7..fa18ec5 100644
--- a/tests/src/android/app/cts/LaunchpadActivity.java
+++ b/tests/src/android/app/cts/LaunchpadActivity.java
@@ -30,6 +30,12 @@
 import android.os.Parcel;
 import android.os.Parcelable;
 import android.test.PerformanceTestCase;
+import android.util.Log;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 class MyBadParcelable implements Parcelable {
     public MyBadParcelable() {
@@ -86,8 +92,6 @@
     public static final String LIFECYCLE_BASIC = "android.app.cts.activity.LIFECYCLE_BASIC";
     public static final String LIFECYCLE_SCREEN = "android.app.cts.activity.LIFECYCLE_SCREEN";
     public static final String LIFECYCLE_DIALOG = "android.app.cts.activity.LIFECYCLE_DIALOG";
-    public static final String LIFECYCLE_FINISH_CREATE = "android.app.cts.activity.LIFECYCLE_FINISH_CREATE";
-    public static final String LIFECYCLE_FINISH_START = "android.app.cts.activity.LIFECYCLE_FINISH_START";
 
     public static final String BROADCAST_REGISTERED = "android.app.cts.activity.BROADCAST_REGISTERED";
     public static final String BROADCAST_LOCAL = "android.app.cts.activity.BROADCAST_LOCAL";
@@ -119,13 +123,15 @@
     public static final String ON_RESUME = "onResume";
     public static final String ON_FREEZE = "onSaveInstanceState";
     public static final String ON_PAUSE = "onPause";
-    public static final String ON_STOP = "onStop";
-    public static final String ON_DESTROY = "onDestroy";
+
+    // ON_STOP and ON_DESTROY are not tested because they may not be called.
 
     public static final String DO_FINISH = "finish";
     public static final String DO_LOCAL_SCREEN = "local-screen";
     public static final String DO_LOCAL_DIALOG = "local-dialog";
 
+    private static final String TAG = "LaunchpadActivity";
+
     private boolean mBadParcelable = false;
 
     private boolean mStarted = false;
@@ -134,9 +140,18 @@
     private Intent mData = new Intent().setAction("No result received");
     private RuntimeException mResultStack = null;
 
-    private String[] mExpectedLifecycle = null;
+    /** Index into the {@link #mNextLifecycle} array. */
     private int mNextLifecycle;
 
+    /** Current lifecycle expected to be followed. */
+    private String[] mExpectedLifecycle;
+
+    /** Other possible lifecycles. Never includes the current {@link #mExpectedLifecycle}. */
+    private List<String[]> mOtherPossibleLifecycles = new ArrayList<String[]>(2);
+
+    /** Map from lifecycle arrays to debugging log names. */
+    private Map<String[], String> mLifecycleNames = new HashMap<String[], String>(2);
+
     private String[] mExpectedReceivers = null;
     private int mNextReceiver;
 
@@ -157,40 +172,85 @@
     @Override
     protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);
+
+        resetLifecycles();
+
+        // ON_STOP and ON_DESTROY are not tested because they may not be called.
+
         final String action = getIntent().getAction();
         if (LIFECYCLE_BASIC.equals(action)) {
-            setExpectedLifecycle(new String[] {
-                    ON_START, ON_RESUME, DO_FINISH, ON_PAUSE, ON_STOP, ON_DESTROY
+            addPossibleLifecycle(LIFECYCLE_BASIC, new String[] {
+                    ON_START, ON_RESUME, DO_FINISH, ON_PAUSE
             });
         } else if (LIFECYCLE_SCREEN.equals(action)) {
-            setExpectedLifecycle(new String[] {
-                    ON_START, ON_RESUME, DO_LOCAL_SCREEN, ON_FREEZE, ON_PAUSE, ON_STOP, ON_RESTART,
-                    ON_START, ON_RESUME, DO_FINISH, ON_PAUSE, ON_STOP, ON_DESTROY
+            addPossibleLifecycle(LIFECYCLE_SCREEN + "_RESTART", new String[] {
+                    ON_START, ON_RESUME, DO_LOCAL_SCREEN, ON_FREEZE, ON_PAUSE,
+                    ON_RESTART, ON_START, ON_RESUME, DO_FINISH, ON_PAUSE
+            });
+            addPossibleLifecycle(LIFECYCLE_SCREEN + "_RESUME", new String[] {
+                    ON_START, ON_RESUME, DO_LOCAL_SCREEN, ON_FREEZE, ON_PAUSE,
+                    ON_RESUME, DO_FINISH, ON_PAUSE
             });
         } else if (LIFECYCLE_DIALOG.equals(action)) {
-            setExpectedLifecycle(new String[] {
-                    ON_START, ON_RESUME, DO_LOCAL_DIALOG, ON_FREEZE, ON_PAUSE, ON_RESUME,
-                    DO_FINISH, ON_PAUSE, ON_STOP, ON_DESTROY
+            addPossibleLifecycle(LIFECYCLE_DIALOG + "_RESTART", new String[] {
+                    ON_START, ON_RESUME, DO_LOCAL_DIALOG, ON_FREEZE, ON_PAUSE,
+                    ON_RESTART, ON_START, ON_RESUME, DO_FINISH, ON_PAUSE
             });
-        } else if (LIFECYCLE_FINISH_CREATE.equals(action)) {
-            // This one behaves a little differently when running in a group.
-            if (getParent() == null) {
-                setExpectedLifecycle(new String[] {
-                    ON_DESTROY
-                });
-            } else {
-                setExpectedLifecycle(new String[] {
-                        ON_START, ON_STOP, ON_DESTROY
-                });
-            }
-            finish();
-        } else if (LIFECYCLE_FINISH_START.equals(action)) {
-            setExpectedLifecycle(new String[] {
-                    ON_START, DO_FINISH, ON_STOP, ON_DESTROY
+            addPossibleLifecycle(LIFECYCLE_DIALOG + "_RESUME", new String[] {
+                    ON_START, ON_RESUME, DO_LOCAL_DIALOG, ON_FREEZE, ON_PAUSE,
+                    ON_RESUME, DO_FINISH, ON_PAUSE
             });
         }
     }
 
+    private void resetLifecycles() {
+        mNextLifecycle = 0;
+        mExpectedLifecycle = null;
+        mOtherPossibleLifecycles.clear();
+        mLifecycleNames.clear();
+    }
+
+    /**
+     * Add a potential lifecycle that this activity may follow, since there
+     * are usually multiple valid lifecycles. For instance, sometimes onPause
+     * will lead to onResume rather than onStop when another activity is
+     * raised over the current one.
+     *
+     * @param debugName for the lifecycle shown in the logs
+     * @param lifecycle array containing tokens indicating the expected lifecycle
+     */
+    private void addPossibleLifecycle(String debugName, String[] lifecycle) {
+        mLifecycleNames.put(lifecycle, debugName);
+        if (mExpectedLifecycle == null) {
+            mExpectedLifecycle = lifecycle;
+        } else {
+            mOtherPossibleLifecycles.add(lifecycle);
+        }
+    }
+
+    /**
+     * Switch to the next possible lifecycle and return if switching was
+     * successful. Call this method when mExpectedLifecycle doesn't match
+     * the current lifecycle and you need to check another possible lifecycle.
+     *
+     * @return whether on not there was a lifecycle to switch to
+     */
+    private boolean switchToNextPossibleLifecycle() {
+        if (!mOtherPossibleLifecycles.isEmpty()) {
+            String[] newLifecycle = mOtherPossibleLifecycles.remove(0);
+            Log.w(TAG, "Switching expected lifecycles from "
+                    + mLifecycleNames.get(mExpectedLifecycle) + " to "
+                    + mLifecycleNames.get(newLifecycle));
+            mExpectedLifecycle = newLifecycle;
+            return true;
+        } else {
+            Log.w(TAG, "No more lifecycles after "
+                    + mLifecycleNames.get(mExpectedLifecycle));
+            mExpectedLifecycle = null;
+            return false;
+        }
+    }
+
     @Override
     protected void onStart() {
         super.onStart();
@@ -352,12 +412,6 @@
     }
 
     @Override
-    protected void onStop() {
-        super.onStop();
-        checkLifecycle(ON_STOP);
-    }
-
-    @Override
     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
         switch (requestCode) {
             case LAUNCHED_RESULT:
@@ -381,50 +435,42 @@
         }
     }
 
-    @Override
-    protected void onDestroy() {
-        super.onDestroy();
-        checkLifecycle(ON_DESTROY);
-        sCallingTest.activityFinished(mResultCode, mData, mResultStack);
-    }
-
-    private void setExpectedLifecycle(String[] lifecycle) {
-        mExpectedLifecycle = lifecycle;
-        mNextLifecycle = 0;
-    }
-
     private void checkLifecycle(String where) {
+        String action = getIntent().getAction();
+
         if (mExpectedLifecycle == null) {
             return;
         }
 
         if (mNextLifecycle >= mExpectedLifecycle.length) {
-            finishBad("Activity lifecycle incorrect: received " + where
+            finishBad("Activity lifecycle for " + action + " incorrect: received " + where
                     + " but don't expect any more calls");
             mExpectedLifecycle = null;
             return;
         }
-        if (!mExpectedLifecycle[mNextLifecycle].equals(where)) {
-            finishBad("Activity lifecycle incorrect: received " + where + " but expected "
-                    + mExpectedLifecycle[mNextLifecycle] + " at " + mNextLifecycle);
-            mExpectedLifecycle = null;
+
+        do {
+            if (mExpectedLifecycle[mNextLifecycle].equals(where)) {
+                break;
+            }
+        } while (switchToNextPossibleLifecycle());
+
+        if (mExpectedLifecycle == null) {
+            finishBad("Activity lifecycle for " + action + " incorrect: received " + where
+                    + " but expected " + mExpectedLifecycle[mNextLifecycle]
+                    + " at " + mNextLifecycle);
             return;
         }
 
         mNextLifecycle++;
 
         if (mNextLifecycle >= mExpectedLifecycle.length) {
-            setTestResult(RESULT_OK, null);
+            finishGood();
             return;
         }
 
         final String next = mExpectedLifecycle[mNextLifecycle];
-        if (where.equals(ON_DESTROY)) {
-            finishBad("Activity lifecycle incorrect: received " + where
-                    + " but expected more actions (next is " + next + ")");
-            mExpectedLifecycle = null;
-            return;
-        } else if (next.equals(DO_FINISH)) {
+        if (next.equals(DO_FINISH)) {
             mNextLifecycle++;
             if (mNextLifecycle >= mExpectedLifecycle.length) {
                 setTestResult(RESULT_OK, null);
@@ -473,6 +519,9 @@
     private void finishWithResult(int resultCode, Intent data) {
         setTestResult(resultCode, data);
         finish();
+
+        // Member fields set by calling setTestResult above...
+        sCallingTest.activityFinished(mResultCode, mData, mResultStack);
     }
 
     private void setTestResult(int resultCode, Intent data) {
diff --git a/tests/src/android/opengl/cts/GLSurfaceViewStubActivity.java b/tests/src/android/opengl/cts/GLSurfaceViewStubActivity.java
new file mode 100644
index 0000000..5a8f310
--- /dev/null
+++ b/tests/src/android/opengl/cts/GLSurfaceViewStubActivity.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.opengl.cts;
+
+import android.app.Activity;
+import android.opengl.GLSurfaceView;
+import android.os.Bundle;
+
+import javax.microedition.khronos.egl.EGLConfig;
+import javax.microedition.khronos.opengles.GL10;
+
+/**
+ * A minimal activity for testing {@link android.opengl.GLSurfaceView}.
+ */
+public class GLSurfaceViewStubActivity extends Activity {
+
+    private static class Renderer implements GLSurfaceView.Renderer {
+
+        public void onDrawFrame(GL10 gl) {
+            // Do nothing.
+        }
+
+        public void onSurfaceChanged(GL10 gl, int width, int height) {
+            // Do nothing.
+        }
+
+        public void onSurfaceCreated(GL10 gl, EGLConfig config) {
+            // Do nothing.
+        }
+    }
+
+    private GLSurfaceView mView;
+
+    @Override
+    public void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        mView = new GLSurfaceView(this);
+        mView.setRenderer(new Renderer());
+        setContentView(mView);
+    }
+
+    public GLSurfaceView getView() {
+        return mView;
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        mView.onResume();
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+        mView.onPause();
+    }
+}
diff --git a/tests/src/android/view/cts/SurfaceViewStubActivity.java b/tests/src/android/view/cts/SurfaceViewStubActivity.java
index 319af05..75d5ff6 100644
--- a/tests/src/android/view/cts/SurfaceViewStubActivity.java
+++ b/tests/src/android/view/cts/SurfaceViewStubActivity.java
@@ -54,7 +54,6 @@
 
         private SurfaceHolder mHolder;
         private MockCanvas mCanvas;
-        private Thread mSurfaceViewThread;
 
         private boolean mIsDraw;
         private boolean mIsAttachedToWindow;
@@ -171,32 +170,23 @@
         }
 
         public void surfaceCreated(SurfaceHolder holder) {
-            // The Surface has been created, start our drawing thread.
-            mSurfaceViewThread = new Thread() {
-                @Override
-                public void run() {
-                    // Use mock canvas listening to the drawColor() calling.
-                    mCanvas = new MockCanvas(Bitmap.createBitmap( BITMAP_WIDTH,
-                                                                  BITMAP_HEIGHT,
-                                                                  Bitmap.Config.ARGB_8888));
-                    draw(mCanvas);
+            // Use mock canvas listening to the drawColor() calling.
+            mCanvas = new MockCanvas(Bitmap.createBitmap( BITMAP_WIDTH,
+                                                          BITMAP_HEIGHT,
+                                                          Bitmap.Config.ARGB_8888));
+            draw(mCanvas);
 
-                    // Lock the surface, this returns a Canvas that can be used to render into.
-                    Canvas canvas = mHolder.lockCanvas();
-                    Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
-                    paint.setColor(Color.BLUE);
-                    canvas.drawRect(RECT_LEFT, RECT_TOP, RECT_RIGHT, RECT_BOTTOM, paint);
+            // Lock the surface, this returns a Canvas that can be used to render into.
+            Canvas canvas = mHolder.lockCanvas();
+            Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
+            paint.setColor(Color.BLUE);
+            canvas.drawRect(RECT_LEFT, RECT_TOP, RECT_RIGHT, RECT_BOTTOM, paint);
 
-                    // And finally unlock and post the surface.
-                    mHolder.unlockCanvasAndPost(canvas);
-                }
-            };
-
-            mSurfaceViewThread.start();
+            // And finally unlock and post the surface.
+            mHolder.unlockCanvasAndPost(canvas);
         }
 
         public void surfaceDestroyed(SurfaceHolder holder) {
-            mSurfaceViewThread = null;
         }
 
         public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
diff --git a/tests/src/android/view/inputmethod/cts/InputMethodInfoStub.java b/tests/src/android/view/inputmethod/cts/InputMethodInfoStub.java
new file mode 100644
index 0000000..0eeefbe
--- /dev/null
+++ b/tests/src/android/view/inputmethod/cts/InputMethodInfoStub.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.view.inputmethod.cts;
+
+import android.inputmethodservice.InputMethodService;
+
+public class InputMethodInfoStub extends InputMethodService {
+
+}
diff --git a/tests/src/android/view/inputmethod/cts/InputMethodStubActivity.java b/tests/src/android/view/inputmethod/cts/InputMethodStubActivity.java
new file mode 100644
index 0000000..8117918
--- /dev/null
+++ b/tests/src/android/view/inputmethod/cts/InputMethodStubActivity.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.view.inputmethod.cts;
+
+import android.app.Activity;
+import android.os.Bundle;
+import com.android.cts.stub.R;
+
+public class InputMethodStubActivity extends Activity {
+    @Override
+    protected void onCreate(Bundle icicle) {
+        super.onCreate(icicle);
+        setContentView(R.layout.inputmethod_edittext);
+    }
+}
diff --git a/tests/src/android/widget/cts/WidgetTestUtils.java b/tests/src/android/widget/cts/WidgetTestUtils.java
index b6e0140..0a8f6dc 100644
--- a/tests/src/android/widget/cts/WidgetTestUtils.java
+++ b/tests/src/android/widget/cts/WidgetTestUtils.java
@@ -103,6 +103,12 @@
                 actual, 3);
     }
 
+    /** Converts dips into pixels using the {@link Context}'s density. */
+    public static int convertDipToPixels(Context context, int dip) {
+      float density = context.getResources().getDisplayMetrics().density;
+      return Math.round(density * dip);
+    }
+
     /**
      * Retrieve a bitmap that can be used for comparison on any density
      * @param resources
diff --git a/tests/tests/accessibilityservice/Android.mk b/tests/tests/accessibilityservice/Android.mk
new file mode 100644
index 0000000..401f7a4
--- /dev/null
+++ b/tests/tests/accessibilityservice/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2010 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_JAVA_LIBRARIES := android.test.runner
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_SRC_FILES += \
+  src/android/accessibilityservice/IAccessibilityServiceDelegate.aidl \
+  src/android/accessibilityservice/IAccessibilityServiceDelegateConnection.aidl
+
+LOCAL_PACKAGE_NAME := CtsAccessibilityServiceTestCases
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/tests/tests/accessibilityservice/AndroidManifest.xml b/tests/tests/accessibilityservice/AndroidManifest.xml
new file mode 100644
index 0000000..811c87f
--- /dev/null
+++ b/tests/tests/accessibilityservice/AndroidManifest.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!--
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ -->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+        package="com.android.cts.accessibilityservice">
+
+  <application>
+
+      <uses-library android:name="android.test.runner"/>
+
+      <activity android:label="@string/accessibility_end_to_end_test_activity"
+                android:name="android.accessibilityservice.cts.AccessibilityEndToEndTestActivity"/>
+
+  </application>
+
+  <instrumentation android:name="android.test.InstrumentationTestRunner"
+                   android:targetPackage="com.android.cts.accessibilityservice"
+                   android:label="Tests for the accessibility APIs."/>
+
+</manifest>
diff --git a/tests/tests/accessibilityservice/res/layout/end_to_end_test.xml b/tests/tests/accessibilityservice/res/layout/end_to_end_test.xml
new file mode 100644
index 0000000..351ea24
--- /dev/null
+++ b/tests/tests/accessibilityservice/res/layout/end_to_end_test.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:layout_width="fill_parent"
+              android:layout_height="fill_parent"
+              android:gravity="center" android:orientation="vertical">
+
+    <ListView android:id="@+id/listview"
+              android:layout_width="fill_parent"
+              android:layout_height="wrap_content">
+    </ListView>
+
+    <EditText android:id="@+id/edittext"
+              android:text="@string/text_input_blah"
+              android:layout_height="wrap_content"
+              android:layout_width="fill_parent">
+    </EditText>
+
+    <LinearLayout android:layout_width="fill_parent"
+                  android:layout_height="wrap_content"
+                  android:gravity="center">
+        <Button android:id="@+id/button"
+                android:text="@string/button_title"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content" android:bufferType="normal">
+        </Button>
+    </LinearLayout>
+
+</LinearLayout>
diff --git a/tests/tests/accessibilityservice/res/layout/list_view_row.xml b/tests/tests/accessibilityservice/res/layout/list_view_row.xml
new file mode 100644
index 0000000..05163c5
--- /dev/null
+++ b/tests/tests/accessibilityservice/res/layout/list_view_row.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<TextView xmlns:android="http://schemas.android.com/apk/res/android"
+          android:layout_width="wrap_content"
+          android:layout_height="wrap_content"
+          android:textSize="20px">
+</TextView>
diff --git a/tests/tests/accessibilityservice/res/values/strings.xml b/tests/tests/accessibilityservice/res/values/strings.xml
new file mode 100644
index 0000000..e86d3cc
--- /dev/null
+++ b/tests/tests/accessibilityservice/res/values/strings.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+     Licensed under the Apache License, Version 2.0 (the "License");
+     you may not use this file except in compliance with the License.
+     You may obtain a copy of the License at
+
+          http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing, software
+     distributed under the License is distributed on an "AS IS" BASIS,
+     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+     See the License for the specific language governing permissions and
+     limitations under the License.
+-->
+
+<resources>
+
+    <!-- String title of the accessibility end-to-end test activity -->
+    <string name="accessibility_end_to_end_test_activity">End-to-end test</string>
+
+    <!-- String value of used as text input -->
+    <string name="text_input_blah">Blah</string>
+
+    <!-- String value of used as text input -->
+    <string name="text_input_blah_blah">Blah blah</string>
+
+    <!-- String title of the button -->
+    <string name="button_title">Click me</string>
+
+    <!-- String value of the first list item -->
+    <string name="first_list_item">First list item</string>
+
+    <!-- String value of the second list item -->
+    <string name="second_list_item">Second list item</string>
+
+    <!-- String alert title -->
+    <string name="alert_title">Alert title</string>
+
+    <!-- String alert message -->
+    <string name="alert_message">Alert message</string>
+
+    <!-- String notification message -->
+    <string name="notification_message">Notification message</string>
+
+</resources>
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/IAccessibilityServiceDelegate.aidl b/tests/tests/accessibilityservice/src/android/accessibilityservice/IAccessibilityServiceDelegate.aidl
new file mode 100644
index 0000000..b5ebf19
--- /dev/null
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/IAccessibilityServiceDelegate.aidl
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.accessibilityservice;
+
+import android.view.accessibility.AccessibilityEvent;
+
+/**
+ * Interface for interacting with the accessibility service mock.
+ */
+interface IAccessibilityServiceDelegate {
+
+    /**
+     * Delegate an {@link android.view.accessibility.AccessibilityEvent}.
+     */
+    void onAccessibilityEvent(in AccessibilityEvent event);
+
+    /**
+     * Delegate an interrupt request.
+     */
+    void onInterrupt();
+}
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/IAccessibilityServiceDelegateConnection.aidl b/tests/tests/accessibilityservice/src/android/accessibilityservice/IAccessibilityServiceDelegateConnection.aidl
new file mode 100644
index 0000000..62703dc
--- /dev/null
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/IAccessibilityServiceDelegateConnection.aidl
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.accessibilityservice;
+
+import android.os.IBinder;
+
+/**
+ * Interface for registering an accessibility service delegate.
+ */
+oneway interface IAccessibilityServiceDelegateConnection {
+
+    /**
+     * Sets the delegate interface to which the
+     * {@link DelegatingAccessibilityService} to delegate.
+     */
+    void setAccessibilityServiceDelegate(in IBinder binder);
+}
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTest.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTest.java
new file mode 100644
index 0000000..5259753
--- /dev/null
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTest.java
@@ -0,0 +1,791 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.accessibilityservice.cts;
+
+import android.accessibilityservice.AccessibilityService;
+import android.accessibilityservice.IAccessibilityServiceDelegate;
+import android.accessibilityservice.IAccessibilityServiceDelegateConnection;
+import android.app.Activity;
+import android.app.ActivityManager;
+import android.app.AlertDialog;
+import android.app.Notification;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.app.Service;
+import android.app.ActivityManager.RunningServiceInfo;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.Intent;
+import android.content.ServiceConnection;
+import android.content.pm.PackageManager;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.Message;
+import android.os.RemoteException;
+import android.os.SystemClock;
+import android.test.ActivityInstrumentationTestCase2;
+import android.test.suitebuilder.annotation.LargeTest;
+import android.util.Log;
+import android.view.accessibility.AccessibilityEvent;
+import android.view.accessibility.AccessibilityManager;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ListView;
+
+import com.android.cts.accessibilityservice.R;
+
+import junit.framework.TestCase;
+
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Queue;
+
+/**
+ * This class performs end-to-end testing of the accessibility feature by
+ * creating an {@link Activity} and poking around so {@link AccessibilityEvent}s
+ * are generated and their correct dispatch verified.
+ * </p>
+ * Note: The end-to-end test is composed of two APKs, one with a delegating accessibility
+ * service, another with the instrumented activity and test cases. The motivation for
+ * two APKs design is that CTS tests cannot access the secure settings which is
+ * required for enabling accessibility and accessibility services. Therefore, manual
+ * installation of the <strong>CtsDelegatingAccessibilityService.apk</strong>
+ * whose source is located at <strong>cts/tests/accessibilityservice</strong> is required.
+ * Once the former package has been installed accessibility must be enabled (Settings ->
+ * Accessibility), the delegating service must be enabled (Settings -> Accessibility
+ * -> Delegating Accessibility Service), and then the CTS tests in this package can be
+ * successfully run. Further, the delegate and tests run in separate processes since
+ * the instrumentation restarts the process in which it is running and this
+ * breaks the binding between the delegating accessibility service and the system.
+ */
+public class AccessibilityEndToEndTest extends
+        ActivityInstrumentationTestCase2<AccessibilityEndToEndTestActivity> {
+
+    /**
+     * Timeout required for pending Binder calls or event processing to
+     * complete.
+     */
+    private static final long MAX_TIMEOUT_ASYNCHRONOUS_PROCESSING = 1000;
+
+    /**
+     * The count of the polling attempts during {@link #MAX_TIMEOUT_ASYNCHRONOUS_PROCESSING}
+     */
+    private static final long COUNT_POLLING_ATTEMPTS = 10;
+
+    /**
+     * The package of the accessibility service mock interface.
+     */
+    private static final String DELEGATING_SERVICE_PACKAGE =
+        "android.accessibilityservice.delegate";
+
+    /**
+     * The package of the delegating accessibility service interface.
+     */
+    private static final String DELEGATING_SERVICE_CLASS_NAME =
+        "android.accessibilityservice.delegate.DelegatingAccessibilityService";
+
+    /**
+     * The package of the delegating accessibility service connection interface.
+     */
+    private static final String DELEGATING_SERVICE_CONNECTION_CLASS_NAME =
+        "android.accessibilityservice.delegate."
+            + "DelegatingAccessibilityService$DelegatingConnectionService";
+
+    /**
+     * Creates a new instance for testing
+     * {@link AccessibilityEndToEndTestActivity}.
+     *
+     * @throws Exception If any error occurs.
+     */
+    public AccessibilityEndToEndTest() throws Exception {
+        super("com.android.cts.accessibilityservice", AccessibilityEndToEndTestActivity.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        // wait for the activity to settle down so we do not receive
+        // the event for its start, thus breaking the tests
+        getInstrumentation().waitForIdleSync();
+    }
+
+    @LargeTest
+    public void testTypeViewSelectedAccessibilityEvent() throws Throwable {
+        Activity activity = getActivity();
+
+        // create and populate the expected event
+        AccessibilityEvent selectedEvent = AccessibilityEvent.obtain();
+        selectedEvent.setEventType(AccessibilityEvent.TYPE_VIEW_SELECTED);
+        selectedEvent.setClassName(ListView.class.getName());
+        selectedEvent.setPackageName(getActivity().getPackageName());
+        selectedEvent.getText().add(activity.getString(R.string.second_list_item));
+        selectedEvent.setItemCount(2);
+        selectedEvent.setCurrentItemIndex(1);
+        selectedEvent.setEnabled(true);
+
+        // set expectations
+        MockAccessibilityService service = MockAccessibilityService.getInstance(activity);
+        service.expectEvent(selectedEvent);
+        service.replay();
+
+        // trigger the event
+        final ListView listView = (ListView) activity.findViewById(R.id.listview);
+        getActivity().runOnUiThread(new Runnable() {
+            public void run() {
+                listView.setSelection(1);
+            }
+        });
+
+        // verify if all expected methods have been called
+        assertMockServiceVerifiedWithinTimeout(service);
+    }
+
+    @LargeTest
+    public void testTypeViewClickedAccessibilityEvent() throws Throwable {
+        Activity activity = getActivity();
+
+        // create and populate the expected event
+        AccessibilityEvent clickedEvent = AccessibilityEvent.obtain();
+        clickedEvent.setEventType(AccessibilityEvent.TYPE_VIEW_CLICKED);
+        clickedEvent.setClassName(Button.class.getName());
+        clickedEvent.setPackageName(getActivity().getPackageName());
+        clickedEvent.getText().add(activity.getString(R.string.button_title));
+        clickedEvent.setEnabled(true);
+
+        // set expectations
+        MockAccessibilityService service = MockAccessibilityService.getInstance(activity);
+        service.expectEvent(clickedEvent);
+        service.replay();
+
+        // trigger the event
+        final Button button = (Button) activity.findViewById(R.id.button);
+        activity.runOnUiThread(new Runnable() {
+            public void run() {
+                button.performClick();
+            }
+        });
+
+        // verify if all expected methods have been called
+        assertMockServiceVerifiedWithinTimeout(service);
+    }
+
+    @LargeTest
+    public void testTypeViewLongClickedAccessibilityEvent() throws Throwable {
+        Activity activity = getActivity();
+
+        // create and populate the expected event
+        AccessibilityEvent longClickedEvent = AccessibilityEvent.obtain();
+        longClickedEvent.setEventType(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED);
+        longClickedEvent.setClassName(Button.class.getName());
+        longClickedEvent.setPackageName(getActivity().getPackageName());
+        longClickedEvent.getText().add(activity.getString(R.string.button_title));
+        longClickedEvent.setEnabled(true);
+
+        // set expectations
+        MockAccessibilityService service = MockAccessibilityService.getInstance(activity);
+        service.expectEvent(longClickedEvent);
+        service.replay();
+
+        // trigger the event
+        final Button button = (Button) activity.findViewById(R.id.button);
+        activity.runOnUiThread(new Runnable() {
+            public void run() {
+                button.performLongClick();
+            }
+        });
+
+        // verify if all expected methods have been called
+        assertMockServiceVerifiedWithinTimeout(service);
+    }
+
+    @LargeTest
+    public void testTypeViewFocusedAccessibilityEvent() throws Throwable {
+        Activity activity = getActivity();
+
+        // create and populate the expected event
+        AccessibilityEvent focusedEvent = AccessibilityEvent.obtain();
+        focusedEvent.setEventType(AccessibilityEvent.TYPE_VIEW_FOCUSED);
+        focusedEvent.setClassName(Button.class.getName());
+        focusedEvent.setPackageName(getActivity().getPackageName());
+        focusedEvent.getText().add(activity.getString(R.string.button_title));
+        focusedEvent.setItemCount(3);
+        focusedEvent.setCurrentItemIndex(2);
+        focusedEvent.setEnabled(true);
+
+        // set expectations
+        MockAccessibilityService service = MockAccessibilityService.getInstance(activity);
+        service.expectEvent(focusedEvent);
+        service.replay();
+
+        // trigger the event
+        final Button button = (Button) activity.findViewById(R.id.button);
+        activity.runOnUiThread(new Runnable() {
+            public void run() {
+                button.requestFocus();
+            }
+        });
+
+        // verify if all expected methods have been called
+        assertMockServiceVerifiedWithinTimeout(service);
+    }
+
+    @LargeTest
+    public void testTypeViewTextChangedAccessibilityEvent() throws Throwable {
+        Activity activity = getActivity();
+
+        // focus the edit text
+        final EditText editText = (EditText) activity.findViewById(R.id.edittext);
+        activity.runOnUiThread(new Runnable() {
+            public void run() {
+                editText.requestFocus();
+            }
+        });
+
+        // wait for the generated focus event to be dispatched
+        Thread.sleep(MAX_TIMEOUT_ASYNCHRONOUS_PROCESSING);
+
+        final String beforeText = activity.getString(R.string.text_input_blah);
+        final String newText = activity.getString(R.string.text_input_blah_blah);
+        final String afterText = beforeText.substring(0, 3) + newText;
+
+        // create and populate the expected event
+        AccessibilityEvent textChangedEvent = AccessibilityEvent.obtain();
+        textChangedEvent.setEventType(AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED);
+        textChangedEvent.setClassName(EditText.class.getName());
+        textChangedEvent.setPackageName(getActivity().getPackageName());
+        textChangedEvent.getText().add(afterText);
+        textChangedEvent.setBeforeText(beforeText);
+        textChangedEvent.setFromIndex(3);
+        textChangedEvent.setAddedCount(9);
+        textChangedEvent.setRemovedCount(1);
+        textChangedEvent.setEnabled(true);
+
+        // set expectations
+        MockAccessibilityService service = MockAccessibilityService.getInstance(activity);
+        service.expectEvent(textChangedEvent);
+        service.replay();
+
+        // trigger the event
+        activity.runOnUiThread(new Runnable() {
+            public void run() {
+                editText.getEditableText().replace(3, 4, newText);
+            }
+        });
+
+        // verify if all expected methods have been called
+        assertMockServiceVerifiedWithinTimeout(service);
+    }
+
+    @LargeTest
+    public void testTypeWindowStateChangedAccessibilityEvent() throws Throwable {
+        Activity activity = getActivity();
+        String title = activity.getString(R.string.alert_title);
+        String message = activity.getString(R.string.alert_message);
+
+        // create and populate the expected event
+        AccessibilityEvent windowStateChangedEvent = AccessibilityEvent.obtain();
+        windowStateChangedEvent.setEventType(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
+        windowStateChangedEvent.setClassName(AlertDialog.class.getName());
+        windowStateChangedEvent.setPackageName(getActivity().getPackageName());
+        windowStateChangedEvent.getText().add(title);
+        windowStateChangedEvent.getText().add(message);
+        windowStateChangedEvent.setEnabled(true);
+
+        // set expectations
+        MockAccessibilityService service = MockAccessibilityService.getInstance(activity);
+        service.expectEvent(windowStateChangedEvent);
+        service.replay();
+
+        // trigger the event
+        final EditText editText = (EditText) activity.findViewById(R.id.edittext);
+        activity.runOnUiThread(new Runnable() {
+            public void run() {
+                AlertDialog dialog = (new AlertDialog.Builder(getActivity())
+                        .setTitle(R.string.alert_title).setMessage(R.string.alert_message))
+                        .create();
+                dialog.show();
+            }
+        });
+
+        // verify if all expected methods have been called
+        assertMockServiceVerifiedWithinTimeout(service);
+    }
+
+    @LargeTest
+    public void testTypeNotificationStateChangedAccessibilityEvent() throws Throwable {
+        Activity activity = getActivity();
+        String message = activity.getString(R.string.notification_message);
+
+        // create the notification to send
+        int notificationId = 1;
+        Notification notification = new Notification();
+        notification.icon = android.R.drawable.stat_notify_call_mute;
+        notification.contentIntent = PendingIntent.getActivity(getActivity(), 0, new Intent(),
+                PendingIntent.FLAG_CANCEL_CURRENT);
+        notification.tickerText = message;
+        notification.setLatestEventInfo(getActivity(), "", "", notification.contentIntent);
+
+        // create and populate the expected event
+        AccessibilityEvent notificationChangedEvent = AccessibilityEvent.obtain();
+        notificationChangedEvent.setEventType(AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED);
+        notificationChangedEvent.setClassName(Notification.class.getName());
+        notificationChangedEvent.setPackageName(getActivity().getPackageName());
+        notificationChangedEvent.getText().add(message);
+        notificationChangedEvent.setParcelableData(notification);
+
+        // set expectations
+        MockAccessibilityService service = MockAccessibilityService.getInstance(activity);
+        service.expectEvent(notificationChangedEvent);
+        service.replay();
+
+        // trigger the event
+        NotificationManager notificationManager = (NotificationManager) activity
+                .getSystemService(Service.NOTIFICATION_SERVICE);
+        notificationManager.notify(notificationId, notification);
+
+        // verify if all expected methods have been called
+        assertMockServiceVerifiedWithinTimeout(service);
+
+        // remove the notification
+        notificationManager.cancel(notificationId);
+    }
+
+    /**
+     * Asserts the the mock accessibility service has been successfully verified
+     * (which is it has received the expected method calls with expected
+     * arguments) within the {@link #MAX_TIMEOUT_ASYNCHRONOUS_PROCESSING}. The
+     * verified state is checked by polling upon small intervals.
+     *
+     * @param service The service to verify.
+     * @throws Exception If the verification has failed with exception after the
+     *             {@link #MAX_TIMEOUT_ASYNCHRONOUS_PROCESSING}.
+     */
+    private void assertMockServiceVerifiedWithinTimeout(MockAccessibilityService service)
+            throws Throwable {
+        Throwable lastVerifyThrowable = null;
+        long beginTime = SystemClock.uptimeMillis();
+        long pollTmeout = MAX_TIMEOUT_ASYNCHRONOUS_PROCESSING / COUNT_POLLING_ATTEMPTS;
+
+        // poll until the timeout has elapsed
+        while (SystemClock.uptimeMillis() - beginTime < MAX_TIMEOUT_ASYNCHRONOUS_PROCESSING) {
+            // sleep first since immediate call will always fail
+            try {
+                Thread.sleep(pollTmeout);
+            } catch (InterruptedException ie) {
+                /* ignore */
+            }
+
+            try {
+                service.verify();
+                // success - reset so it is not accept more events
+                service.reset();
+                return;
+            } catch (IllegalStateException ise) {
+                // this exception is thrown if the expected event is not
+                // received yet, so we will keep trying within the timeout
+                lastVerifyThrowable = ise;
+                continue;
+            } catch (Throwable t) {
+                // we have just failed
+                lastVerifyThrowable = t;
+                break;
+            }
+        }
+
+        // failure - reset so it is not accept more events
+        service.reset();
+        throw lastVerifyThrowable;
+    }
+
+    static class MockAccessibilityService extends AccessibilityService implements
+            ServiceConnection {
+
+        /**
+         * The singleton instance.
+         */
+        private static MockAccessibilityService sInstance;
+
+        /**
+         * The events this service expects to receive.
+         */
+        private final Queue<AccessibilityEvent> mExpectedEvents =
+            new LinkedList<AccessibilityEvent>();
+
+        /**
+         * Interruption call this service expects to receive.
+         */
+        private boolean mExpectedInterrupt;
+
+        /**
+         * Flag if the mock is currently replaying.
+         */
+        private boolean mReplaying;
+
+        /**
+         * Flag indicating if this mock is initialized.
+         */
+        private boolean mInitialized;
+
+        /**
+         * The {@link Context} whose services to utilize.
+         */
+        private Context mContext;
+
+        /**
+         * Gets the {@link MockAccessibilityService} singleton.
+         *
+         * @param context A context handle.
+         * @return The mock service.
+         */
+        public static MockAccessibilityService getInstance(Context context) {
+            if (sInstance == null) {
+                // since we do bind once and do not unbind from the delegating
+                // service and JUnit3 does not support @BeforeTest and @AfterTest,
+                // we will leak a service connection after the test but this
+                // does not affect the test results and the test is twice as fast
+                sInstance = new MockAccessibilityService(context);
+            }
+            return sInstance;
+        }
+
+        /**
+         * Creates a new instance.
+         */
+        private MockAccessibilityService(Context context) {
+            mContext = context;
+            ensureSetupAndBoundToDelegatingAccessibilityService();
+        }
+
+        /**
+         * Ensures the required setup for the test performed and that it is bound to the
+         * DelegatingAccessibilityService which runs in another process. The setup is
+         * enabling accessibility and installing and enabling the delegating accessibility
+         * service this test binds to.
+         * </p>
+         * Note: Please look at the class description for information why such an
+         *       approach is taken.
+         */
+        public void ensureSetupAndBoundToDelegatingAccessibilityService() {
+            // check if accessibility is enabled
+            AccessibilityManager accessibilityManager = (AccessibilityManager) mContext
+                    .getSystemService(Service.ACCESSIBILITY_SERVICE);
+
+            if (!accessibilityManager.isEnabled()) {
+                throw new IllegalStateException("Accessibility not enabled. "
+                        + "(Settings -> Accessibility)");
+            }
+
+            // check if the delegating service is running
+            ComponentName delegatingServiceName = new ComponentName(
+                    DELEGATING_SERVICE_PACKAGE, DELEGATING_SERVICE_CLASS_NAME);
+            ActivityManager activityManager = (ActivityManager) mContext
+                    .getSystemService(Service.ACTIVITY_SERVICE);
+            boolean delegatingServiceRunning = false;
+
+            for (RunningServiceInfo runningServiceInfo : activityManager.getRunningServices(100)) {
+                if (delegatingServiceName.equals(runningServiceInfo.service)) {
+                    delegatingServiceRunning = true;
+                    break;
+                }
+            }
+
+            if (!delegatingServiceRunning) {
+                // delegating service not running, so check if it is installed at all
+                try {
+                    PackageManager packageManager = mContext.getPackageManager();
+                    packageManager.getServiceInfo(delegatingServiceName, 0);
+                } catch (NameNotFoundException nnfe) {
+                    throw new IllegalStateException("CtsDelegatingAccessibilityService.apk" +
+                            " not installed.");
+                }
+
+                throw new IllegalStateException("Delegating Accessibility Service not running."
+                         + "(Settings -> Accessibility -> Delegating Accessibility Service)");
+            }
+
+            Intent intent = new Intent().setClassName(DELEGATING_SERVICE_PACKAGE,
+                    DELEGATING_SERVICE_CONNECTION_CLASS_NAME);
+            mContext.bindService(intent, this, Context.BIND_AUTO_CREATE);
+
+            long beginTime = SystemClock.uptimeMillis();
+            long pollTmeout = MAX_TIMEOUT_ASYNCHRONOUS_PROCESSING / COUNT_POLLING_ATTEMPTS;
+
+            // bind to the delegating service which runs in another process by
+            // polling until the binder connection is established
+            while (SystemClock.uptimeMillis() - beginTime < MAX_TIMEOUT_ASYNCHRONOUS_PROCESSING) {
+                if (mInitialized) {
+                    // success
+                    return;
+                }
+                try {
+                    Thread.sleep(pollTmeout);
+                } catch (InterruptedException ie) {
+                    /* ignore */
+                }
+            }
+        }
+
+        /**
+         * Starts replaying the mock.
+         */
+        private void replay() {
+            mReplaying = true;
+        }
+
+        /**
+         * Verifies if all expected service methods have been called.
+         */
+        private void verify() {
+            synchronized (this) {
+                if (!mReplaying) {
+                    throw new IllegalStateException("Did you forget to call replay()");
+                }
+                if (mExpectedInterrupt) {
+                    throw new IllegalStateException("Expected call to #interrupt() not received");
+                }
+                if (!mExpectedEvents.isEmpty()) {
+                    throw new IllegalStateException("Expected a call to onAccessibilityEvent() for "
+                            + "events \"" + mExpectedEvents + "\" not received");
+                }
+            }
+        }
+
+        /**
+         * Resets this instance so it can be reused.
+         */
+        private void reset() {
+            synchronized (this) {
+                mExpectedEvents.clear();
+                mExpectedInterrupt = false;
+                mReplaying = false;
+            }
+        }
+
+        /**
+         * Sets an expected call to
+         * {@link #onAccessibilityEvent(AccessibilityEvent)} with given event as
+         * argument.
+         *
+         * @param expectedEvent The expected event argument.
+         */
+        private void expectEvent(AccessibilityEvent expectedEvent) {
+            mExpectedEvents.add(expectedEvent);
+        }
+
+        /**
+         * Sets an expected call of {@link #onInterrupt()}.
+         */
+        public void expectInterrupt() {
+            mExpectedInterrupt = true;
+        }
+
+        @Override
+        public void onAccessibilityEvent(AccessibilityEvent receivedEvent) {
+            synchronized (this) {
+                if (!mReplaying) {
+                    return;
+                }
+                if (mExpectedEvents.isEmpty()) {
+                    throw new IllegalStateException("Unexpected event: " + receivedEvent);
+                }
+                AccessibilityEvent expectedEvent = mExpectedEvents.poll();
+                assertEqualsAccessiblityEvent(expectedEvent, receivedEvent);
+
+            }
+        }
+
+        @Override
+        public void onInterrupt() {
+            synchronized (this) {
+                if (!mReplaying) {
+                    return;
+                }
+
+                if (!mExpectedInterrupt) {
+                    throw new IllegalStateException("Unexpected call to onInterrupt()");
+                }
+
+                mExpectedInterrupt = false;
+            }
+        }
+
+        /**
+         * {@inheritDoc ServiceConnection#onServiceConnected(ComponentName,IBinder)}
+         */
+        public void onServiceConnected(ComponentName name, IBinder service) {
+            IAccessibilityServiceDelegateConnection connection =
+                IAccessibilityServiceDelegateConnection.Stub
+                    .asInterface(service);
+            try {
+                connection.setAccessibilityServiceDelegate(new AccessibilityServiceDelegate(this));
+                mInitialized = true;
+            } catch (RemoteException re) {
+                fail("Could not set delegate to the delegating service.");
+            }
+        }
+
+        /**
+         * {@inheritDoc ServiceConnection#onServiceDisconnected(ComponentName)}
+         */
+        public void onServiceDisconnected(ComponentName name) {
+            mInitialized = false;
+            /* do nothing */
+        }
+
+        /**
+         * Compares all properties of the <code>expectedEvent</code> and the
+         * <code>receviedEvent</code> to verify that the received event is the
+         * one that is expected.
+         */
+        private void assertEqualsAccessiblityEvent(AccessibilityEvent expectedEvent,
+                AccessibilityEvent receivedEvent) {
+            TestCase.assertEquals("addedCount has incorrect value", expectedEvent.getAddedCount(),
+                    receivedEvent.getAddedCount());
+            TestCase.assertEquals("beforeText has incorrect value", expectedEvent.getBeforeText(),
+                    receivedEvent.getBeforeText());
+            TestCase.assertEquals("checked has incorrect value", expectedEvent.isChecked(),
+                    receivedEvent.isChecked());
+            TestCase.assertEquals("className has incorrect value", expectedEvent.getClassName(),
+                    receivedEvent.getClassName());
+            TestCase.assertEquals("contentDescription has incorrect value", expectedEvent
+                    .getContentDescription(), receivedEvent.getContentDescription());
+            TestCase.assertEquals("currentItemIndex has incorrect value", expectedEvent
+                    .getCurrentItemIndex(), receivedEvent.getCurrentItemIndex());
+            TestCase.assertEquals("enabled has incorrect value", expectedEvent.isEnabled(),
+                    receivedEvent.isEnabled());
+            TestCase.assertEquals("eventType has incorrect value", expectedEvent.getEventType(),
+                    receivedEvent.getEventType());
+            TestCase.assertEquals("fromIndex has incorrect value", expectedEvent.getFromIndex(),
+                    receivedEvent.getFromIndex());
+            TestCase.assertEquals("fullScreen has incorrect value", expectedEvent.isFullScreen(),
+                    receivedEvent.isFullScreen());
+            TestCase.assertEquals("itemCount has incorrect value", expectedEvent.getItemCount(),
+                    receivedEvent.getItemCount());
+            // This will fail due to a bug fixed in Gingerbread. Bug 2593810 (removed the method).
+            // assertEqualsNotificationAsParcelableData(expectedEvent, receivedEvent);
+            TestCase.assertEquals("password has incorrect value", expectedEvent.isPassword(),
+                    receivedEvent.isPassword());
+            TestCase.assertEquals("removedCount has incorrect value", expectedEvent
+                    .getRemovedCount(), receivedEvent.getRemovedCount());
+            assertEqualsText(expectedEvent, receivedEvent);
+        }
+
+        /**
+         * Compares the text of the <code>expectedEvent</code> and
+         * <code>receivedEvent</code> by comparing the string representation of
+         * the corresponding {@link CharSequence}s.
+         */
+        private void assertEqualsText(AccessibilityEvent expectedEvent,
+                AccessibilityEvent receivedEvent) {
+            String message = "text has incorrect value";
+            List<CharSequence> expectedText = expectedEvent.getText();
+            List<CharSequence> receivedText = receivedEvent.getText();
+
+            TestCase.assertEquals(message, expectedText.size(), receivedText.size());
+
+            Iterator<CharSequence> expectedTextIterator = expectedText.iterator();
+            Iterator<CharSequence> receivedTextIterator = receivedText.iterator();
+
+            for (int i = 0; i < expectedText.size(); i++) {
+                // compare the string representation
+                TestCase.assertEquals(message, expectedTextIterator.next().toString(),
+                        receivedTextIterator.next().toString());
+            }
+        }
+
+        /**
+         * This class is the delegate called by the DelegatingAccessibilityService.
+         */
+        private class AccessibilityServiceDelegate extends
+                IAccessibilityServiceDelegate.Stub implements Handler.Callback {
+
+            /**
+             * Tag for logging.
+             */
+            private static final String LOG_TAG = "AccessibilityServiceDelegate";
+
+            /**
+             * Message type for calling {@link #onInterrupt()}
+             */
+            private static final int DO_ON_INTERRUPT = 10;
+
+            /**
+             * Message type for calling {@link #onAccessibilityEvent(AccessibilityEvent)}
+             */
+            private static final int DO_ON_ACCESSIBILITY_EVENT = 20;
+
+            /**
+             * Caller for handling {@link Message}s
+             */
+            private final Handler mHandler;
+
+            /**
+             * The {@link MockAccessibilityService} to which to delegate;
+             */
+            private MockAccessibilityService mMockAccessibilityService;
+
+            /**
+             * Creates a new instance.
+             *
+             * @param mockAccessibilityService The service to whcih to delegate.
+             */
+            public AccessibilityServiceDelegate(MockAccessibilityService mockAccessibilityService) {
+                mMockAccessibilityService = mockAccessibilityService;
+                mHandler = new Handler(this);
+            }
+
+            /**
+             * {@inheritDoc IAccessibilityServiceDelegate#onAccessibilityEvent(AccessibilityEvent)}
+             */
+            public void onAccessibilityEvent(AccessibilityEvent event) {
+                Message message = Message.obtain(mHandler, DO_ON_ACCESSIBILITY_EVENT, event);
+                mHandler.sendMessage(message);
+            }
+
+            /**
+             * {@inheritDoc IAccessibilityServiceDelegate#onInterrupt()}
+             */
+            public void onInterrupt() {
+                Message message = mHandler.obtainMessage(DO_ON_INTERRUPT);
+                mHandler.sendMessage(message);
+            }
+
+            /**
+             * {@inheritDoc Handler.Callback#handleMessage(Message)}
+             */
+            public boolean handleMessage(Message message) {
+                switch (message.what) {
+                    case DO_ON_ACCESSIBILITY_EVENT:
+                        AccessibilityEvent event = (AccessibilityEvent) message.obj;
+                        if (event != null) {
+                            mMockAccessibilityService.onAccessibilityEvent(event);
+                            event.recycle();
+                        }
+                        return true;
+                    case DO_ON_INTERRUPT:
+                        mMockAccessibilityService.onInterrupt();
+                        return true;
+                    default:
+                        Log.w(LOG_TAG, "Unknown message type " + message.what);
+                        return false;
+                }
+            }
+        }
+    }
+}
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTestActivity.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTestActivity.java
new file mode 100644
index 0000000..e806622
--- /dev/null
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTestActivity.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.accessibilityservice.cts;
+
+import android.app.Activity;
+import android.content.Context;
+import android.os.Bundle;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.ListAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+
+import com.android.cts.accessibilityservice.R;
+
+/**
+ * This class is an {@link Activity} used to perform end-to-end
+ * testing of the accessibility feature by interaction with the
+ * UI widgets.
+ */
+public class AccessibilityEndToEndTestActivity extends Activity {
+
+    final Context context = this;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.end_to_end_test);
+
+        ListAdapter listAdapter = new BaseAdapter() {
+            public View getView(int position, View convertView, ViewGroup parent) {
+                TextView textView = (TextView) View
+                        .inflate(context, R.layout.list_view_row, null);
+                textView.setText((String) getItem(position));
+                return textView;
+            }
+
+            public long getItemId(int position) {
+                return position;
+            }
+
+            public Object getItem(int position) {
+                if (position == 0) {
+                    return context.getString(R.string.first_list_item);
+                } else {
+                    return context.getString(R.string.second_list_item);
+                }
+            }
+
+            public int getCount() {
+                return 2;
+            }
+        };
+
+        ListView listView = (ListView) findViewById(R.id.listview);
+        listView.setAdapter(listAdapter);
+    }
+}
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityServiceInfoTest.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityServiceInfoTest.java
new file mode 100644
index 0000000..48b4aae
--- /dev/null
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityServiceInfoTest.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.accessibilityservice.cts;
+
+import android.accessibilityservice.AccessibilityServiceInfo;
+import android.os.Parcel;
+import android.test.suitebuilder.annotation.SmallTest;
+import android.view.accessibility.AccessibilityEvent;
+
+import junit.framework.TestCase;
+
+/**
+ * Class for testing {@link AccessibilityServiceInfo}.
+ */
+public class AccessibilityServiceInfoTest extends TestCase {
+
+    @SmallTest
+    public void testMarshalling() throws Exception {
+
+        // fully populate the service info to marshal
+        AccessibilityServiceInfo sentInfo = new AccessibilityServiceInfo();
+        fullyPopulateSentAccessibilityServiceInfo(sentInfo);
+
+        // marshal and unmarshal the service info
+        Parcel parcel = Parcel.obtain();
+        sentInfo.writeToParcel(parcel, 0);
+        parcel.setDataPosition(0);
+        AccessibilityServiceInfo receivedInfo = AccessibilityServiceInfo.CREATOR
+                .createFromParcel(parcel);
+
+        // make sure all fields properly marshaled
+        assertAllFieldsProperlyMarshalled(sentInfo, receivedInfo);
+    }
+
+    /**
+     * Fully populates the {@link AccessibilityServiceInfo} to marshal.
+     *
+     * @param sentInfo The service info to populate.
+     */
+    private void fullyPopulateSentAccessibilityServiceInfo(AccessibilityServiceInfo sentInfo) {
+        sentInfo.eventTypes = AccessibilityEvent.TYPE_VIEW_CLICKED;
+        sentInfo.feedbackType = AccessibilityServiceInfo.FEEDBACK_SPOKEN;
+        sentInfo.flags = AccessibilityServiceInfo.DEFAULT;
+        sentInfo.notificationTimeout = 1000;
+        sentInfo.packageNames = new String[] {
+            "foo.bar.baz"
+        };
+    }
+
+    /**
+     * Compares all properties of the <code>sentInfo</code> and the
+     * <code>receviedInfo</code> to make sure marshalling is correctly
+     * implemented.
+     */
+    private void assertAllFieldsProperlyMarshalled(AccessibilityServiceInfo sentInfo,
+            AccessibilityServiceInfo receivedInfo) {
+        assertEquals("eventTypes not marshalled properly", sentInfo.eventTypes,
+                receivedInfo.eventTypes);
+        assertEquals("feedbackType not marshalled properly", sentInfo.feedbackType,
+                receivedInfo.feedbackType);
+        // This will fail here and is fixed in Froyo. Bug 2448479.
+        // assertEquals("flags not marshalled properly", sentInfo.flags, receivedInfo.flags);
+        assertEquals("notificationTimeout not marshalled properly", sentInfo.notificationTimeout,
+                receivedInfo.notificationTimeout);
+        assertEquals("packageNames not marshalled properly", sentInfo.packageNames.length,
+                receivedInfo.packageNames.length);
+        assertEquals("packageNames not marshalled properly", sentInfo.packageNames[0],
+                receivedInfo.packageNames[0]);
+    }
+}
diff --git a/tests/tests/app/src/android/app/cts/ActivityGroupTest.java b/tests/tests/app/src/android/app/cts/ActivityGroupTest.java
index 05287cd..0cf7998 100644
--- a/tests/tests/app/src/android/app/cts/ActivityGroupTest.java
+++ b/tests/tests/app/src/android/app/cts/ActivityGroupTest.java
@@ -16,7 +16,6 @@
 
 package android.app.cts;
 
-import dalvik.annotation.BrokenTest;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass;
 import dalvik.annotation.TestTargetNew;
@@ -167,7 +166,6 @@
             args = {}
         )
     })
-    @BrokenTest(value="bug 2189784, needs investigation")
     public void testTabScreen() throws Exception {
         mIntent = mTabIntent;
         runLaunchpad(LaunchpadActivity.LIFECYCLE_SCREEN);
@@ -235,143 +233,8 @@
             args = {}
         )
     })
-    @BrokenTest(value="bug 2189784, needs investigation")
     public void testTabDialog() throws Exception {
         mIntent = mTabIntent;
         runLaunchpad(LaunchpadActivity.LIFECYCLE_DIALOG);
     }
-
-    @TestTargets({
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            notes = "",
-            method = "ActivityGroup",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            notes = "",
-            method = "ActivityGroup",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            notes = "",
-            method = "onCreate",
-            args = {Bundle.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            notes = "",
-            method = "onResume",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            notes = "",
-            method = "onSaveInstanceState",
-            args = {Bundle.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            notes = "",
-            method = "onPause",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            notes = "",
-            method = "onStop",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            notes = "",
-            method = "onDestroy",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            notes = "",
-            method = "getCurrentActivity",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            notes = "",
-            method = "getLocalActivityManager",
-            args = {}
-        )
-    })
-     public void testTabFinishCreate() throws Exception {
-        mIntent = mTabIntent;
-        runLaunchpad(LaunchpadActivity.LIFECYCLE_FINISH_CREATE);
-    }
-
-    @TestTargets({
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            notes = "",
-            method = "ActivityGroup",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            notes = "",
-            method = "ActivityGroup",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            notes = "",
-            method = "onCreate",
-            args = {Bundle.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            notes = "",
-            method = "onResume",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            notes = "",
-            method = "onSaveInstanceState",
-            args = {Bundle.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            notes = "",
-            method = "onPause",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            notes = "",
-            method = "onStop",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            notes = "",
-            method = "onDestroy",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            notes = "",
-            method = "getCurrentActivity",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            notes = "",
-            method = "getLocalActivityManager",
-            args = {}
-        )
-    })
-    public void testTabFinishStart() throws Exception {
-        mIntent = mTabIntent;
-        runLaunchpad(LaunchpadActivity.LIFECYCLE_FINISH_START);
-    }
 }
diff --git a/tests/tests/app/src/android/app/cts/AlertDialog_BuilderTest.java b/tests/tests/app/src/android/app/cts/AlertDialog_BuilderTest.java
index 84c64a4..c56dc28 100644
--- a/tests/tests/app/src/android/app/cts/AlertDialog_BuilderTest.java
+++ b/tests/tests/app/src/android/app/cts/AlertDialog_BuilderTest.java
@@ -40,14 +40,10 @@
 import android.widget.ArrayAdapter;
 import android.widget.Button;
 import android.widget.FrameLayout;
-import android.widget.LinearLayout;
 import android.widget.ListAdapter;
 import android.widget.ListView;
-import android.widget.TextView;
 import android.widget.AdapterView.OnItemSelectedListener;
 
-import com.android.internal.R;
-
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass;
 import dalvik.annotation.TestTargetNew;
@@ -58,12 +54,8 @@
     private Context mContext;
     private Instrumentation mInstrumentation;
     private final CharSequence mTitle = "title";
-    private final CharSequence mMessage = "message";
-    private TextView mTitleView;
-    private TextView mMessageView;
     private Drawable mDrawable;
     private AlertDialog mDialog;
-    private LinearLayout mLinearLayout;
     private Button mButton;
     private boolean mResult;
     private boolean mItemSelected;
@@ -119,14 +111,11 @@
         super.setUp();
         mBuilder = null;
         mInstrumentation = getInstrumentation();
-        mContext = (Context)getActivity();
-        mTitleView = null;
-        mMessageView = null;
+        mContext = getActivity();
         mButton = null;
         mView = null;
         mListView = null;
         mDialog = null;
-        mLinearLayout = null;
         mItemSelected = false;
         mSelectedItem = null;
         mSelectedItems = new ArrayList<Integer>();
@@ -138,30 +127,6 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        method = "setCustomTitle",
-        args = {View.class}
-    )
-    public void testSetCustomTitle() throws Throwable {
-        final String expectecTitle = "test";
-        final TextView view = new TextView(mContext);
-        view.setText(expectecTitle);
-        runTestOnUiThread(new Runnable() {
-            public void run() {
-                mBuilder = new AlertDialog.Builder(mContext);
-                mBuilder.setCustomTitle(view);
-                mDialog = mBuilder.show();
-            }
-        });
-        mInstrumentation.waitForIdleSync();
-        final LinearLayout topPanel = (LinearLayout)mDialog.getWindow().findViewById(
-                com.android.internal.R.id.topPanel);
-        final TextView atv = (TextView)topPanel.getChildAt(2);
-        final String title = (String)atv.getText();
-        assertEquals(expectecTitle, title);
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
         method = "AlertDialog.Builder",
         args = {Context.class}
     )
@@ -171,87 +136,15 @@
 
     @TestTargetNew(
         level = TestLevel.COMPLETE,
-        method = "setTitle",
-        args = {int.class}
-    )
-    public void testSetTitleWithParamInt() throws Throwable {
-        runTestOnUiThread(new Runnable() {
-            public void run() {
-                mBuilder = new AlertDialog.Builder(mContext);
-                mBuilder.setTitle(R.string.am);
-                mDialog = mBuilder.show();
-                mTitleView = (TextView)mDialog.getWindow().findViewById(R.id.alertTitle);
-            }
-        });
-        mInstrumentation.waitForIdleSync();
-        assertEquals(mTitleView.getText(), mContext.getText(R.string.am));
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        method = "setTitle",
-        args = {CharSequence.class}
-    )
-    public void testSetTitleWithParamCharSequence() throws Throwable {
-        runTestOnUiThread(new Runnable() {
-            public void run() {
-                mBuilder = new AlertDialog.Builder(mContext);
-                mBuilder.setTitle(mTitle);
-                mDialog = mBuilder.show();
-                mTitleView = (TextView)mDialog.getWindow().findViewById(R.id.alertTitle);
-            }
-        });
-        mInstrumentation.waitForIdleSync();
-        assertEquals(mTitleView.getText(), mTitle);
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        method = "setMessage",
-        args = {int.class}
-    )
-    public void testSetMessageWithParamInt() throws Throwable {
-        runTestOnUiThread(new Runnable() {
-            public void run() {
-                mBuilder = new AlertDialog.Builder(mContext);
-                mBuilder.setMessage(R.string.am);
-                mDialog = mBuilder.show();
-                mMessageView = (TextView)mDialog.getWindow().findViewById(R.id.message);
-            }
-        });
-        mInstrumentation.waitForIdleSync();
-        assertEquals(mMessageView.getText(), mContext.getText(R.string.am));
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        method = "setMessage",
-        args = {CharSequence.class}
-    )
-    public void testSetMessageWithParamCharSequence() throws Throwable {
-        runTestOnUiThread(new Runnable() {
-            public void run() {
-                mBuilder = new AlertDialog.Builder(mContext);
-                mBuilder.setMessage(mMessage);
-                mDialog = mBuilder.show();
-                mMessageView = (TextView)mDialog.getWindow().findViewById(R.id.message);
-            }
-        });
-        mInstrumentation.waitForIdleSync();
-        assertEquals(mMessageView.getText(), mMessage);
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
         method = "setIcon",
         args = {int.class}
     )
     public void testSetIconWithParamInt() throws Throwable {
         runTestOnUiThread(new Runnable() {
             public void run() {
-                mDrawable = mContext.getResources().getDrawable(R.drawable.btn_check_on);
+                mDrawable = mContext.getResources().getDrawable(android.R.drawable.btn_default);
                 mBuilder = new AlertDialog.Builder(mContext);
-                mBuilder.setIcon(R.drawable.btn_check_on);
+                mBuilder.setIcon(android.R.drawable.btn_default);
                 mDialog = mBuilder.show();
             }
         });
@@ -266,7 +159,7 @@
     public void testSetIconWithParamDrawable() throws Throwable {
         runTestOnUiThread(new Runnable() {
             public void run() {
-                mDrawable = mContext.getResources().getDrawable(R.drawable.btn_check_on);
+                mDrawable = mContext.getResources().getDrawable(android.R.drawable.btn_default);
                 mBuilder = new AlertDialog.Builder(mContext);
                 mBuilder.setIcon(mDrawable);
                 mDialog = mBuilder.show();
@@ -284,15 +177,15 @@
        runTestOnUiThread(new Runnable() {
             public void run() {
                 mBuilder = new AlertDialog.Builder(mContext);
-                mBuilder.setPositiveButton(R.string.year, mOnClickListener);
+                mBuilder.setPositiveButton(android.R.string.yes, mOnClickListener);
                 mDialog = mBuilder.show();
-                mButton = (Button)mDialog.getWindow().findViewById(R.id.button1);
+                mButton = mDialog.getButton(DialogInterface.BUTTON_POSITIVE);
                 mButton.performClick();
             }
         });
         mInstrumentation.waitForIdleSync();
 
-        assertEquals(mContext.getText(R.string.year), mButton.getText());
+        assertEquals(mContext.getText(android.R.string.yes), mButton.getText());
         assertTrue(mResult);
     }
 
@@ -305,14 +198,14 @@
         runTestOnUiThread(new Runnable() {
             public void run() {
                 mBuilder = new AlertDialog.Builder(mContext);
-                mBuilder.setPositiveButton(R.string.year, mOnClickListener);
+                mBuilder.setPositiveButton(android.R.string.yes, mOnClickListener);
                 mDialog = mBuilder.show();
-                mButton = (Button)mDialog.getWindow().findViewById(R.id.button1);
+                mButton = mDialog.getButton(DialogInterface.BUTTON_POSITIVE);
                 mButton.performClick();
             }
         });
         mInstrumentation.waitForIdleSync();
-        assertEquals(mContext.getText(R.string.year), mButton.getText());
+        assertEquals(mContext.getText(android.R.string.yes), mButton.getText());
         assertTrue(mResult);
     }
 
@@ -327,7 +220,7 @@
                 mBuilder = new AlertDialog.Builder(mContext);
                 mBuilder.setNegativeButton(mTitle, mOnClickListener);
                 mDialog = mBuilder.show();
-                mButton = (Button)mDialog.getWindow().findViewById(R.id.button2);
+                mButton = mDialog.getButton(DialogInterface.BUTTON_NEGATIVE);
                 mButton.performClick();
             }
         });
@@ -347,7 +240,7 @@
                 mBuilder = new AlertDialog.Builder(mContext);
                 mBuilder.setNegativeButton(com.android.cts.stub.R.string.notify, mOnClickListener);
                 mDialog = mBuilder.show();
-                mButton = (Button)mDialog.getWindow().findViewById(R.id.button2);
+                mButton = mDialog.getButton(DialogInterface.BUTTON_NEGATIVE);
                 mButton.performClick();
             }
         });
@@ -367,7 +260,7 @@
                 mBuilder = new AlertDialog.Builder(mContext);
                 mBuilder.setNeutralButton(com.android.cts.stub.R.string.notify, mOnClickListener);
                 mDialog = mBuilder.show();
-                mButton = (Button)mDialog.getWindow().findViewById(R.id.button3);
+                mButton = mDialog.getButton(DialogInterface.BUTTON_NEUTRAL);
                 mButton.performClick();
             }
         });
@@ -387,7 +280,7 @@
                 mBuilder = new AlertDialog.Builder(mContext);
                 mBuilder.setNeutralButton(mTitle, mOnClickListener);
                 mDialog = mBuilder.show();
-                mButton = (Button)mDialog.getWindow().findViewById(R.id.button3);
+                mButton = mDialog.getButton(DialogInterface.BUTTON_NEUTRAL);
                 mButton.performClick();
             }
         });
@@ -476,8 +369,7 @@
                 mBuilder = new AlertDialog.Builder(mContext);
                 mBuilder.setItems(com.android.cts.stub.R.array.difficultyLevel, mOnClickListener);
                 mDialog = mBuilder.show();
-                mLinearLayout = (LinearLayout)mDialog.getWindow().findViewById(R.id.contentPanel);
-                mListView = (ListView)mLinearLayout.getChildAt(0);
+                mListView = mDialog.getListView();
             }
         });
         mInstrumentation.waitForIdleSync();
@@ -501,8 +393,7 @@
                 mBuilder = new AlertDialog.Builder(mContext);
                 mBuilder.setItems(expect, mOnClickListener);
                 mDialog = mBuilder.show();
-                mLinearLayout = (LinearLayout)mDialog.getWindow().findViewById(R.id.contentPanel);
-                mListView = (ListView)mLinearLayout.getChildAt(0);
+                mListView = mDialog.getListView();
             }
         });
         mInstrumentation.waitForIdleSync();
@@ -521,8 +412,7 @@
                 mBuilder = new AlertDialog.Builder(mContext);
                 mBuilder.setAdapter(adapter, mOnClickListener);
                 mDialog = mBuilder.show();
-                mLinearLayout = (LinearLayout)mDialog.getWindow().findViewById(R.id.contentPanel);
-                mListView = (ListView)mLinearLayout.getChildAt(0);
+                mListView = mDialog.getListView();
             }
         });
         mInstrumentation.waitForIdleSync();
@@ -544,8 +434,7 @@
                 mBuilder = new AlertDialog.Builder(mContext);
                 mBuilder.setCursor(c, mOnClickListener, People.NAME);
                 mDialog = mBuilder.show();
-                mLinearLayout = (LinearLayout)mDialog.getWindow().findViewById(R.id.contentPanel);
-                mListView = (ListView)mLinearLayout.getChildAt(0);
+                mListView = mDialog.getListView();
                 mListView.performItemClick(null, 0, 0);
             }
         });
@@ -571,8 +460,7 @@
                 mBuilder.setMultiChoiceItems(com.android.cts.stub.R.array.difficultyLevel, null,
                         mOnMultiChoiceClickListener);
                 mDialog = mBuilder.show();
-                mLinearLayout = (LinearLayout)mDialog.getWindow().findViewById(R.id.contentPanel);
-                mListView = (ListView)mLinearLayout.getChildAt(0);
+                mListView = mDialog.getListView();
                 mSelectedItem = (CharSequence)mListView.getSelectedItem();
                 mListView.performItemClick(null, 0, 0);
                 mListView.performItemClick(null, 1, 0);
@@ -599,8 +487,7 @@
                 mBuilder = new AlertDialog.Builder(mContext);
                 mBuilder.setMultiChoiceItems(items, null, mOnMultiChoiceClickListener);
                 mDialog = mBuilder.show();
-                mLinearLayout = (LinearLayout)mDialog.getWindow().findViewById(R.id.contentPanel);
-                mListView = (ListView)mLinearLayout.getChildAt(0);
+                mListView = mDialog.getListView();
                 mSelectedItem = (CharSequence)mListView.getSelectedItem();
                 mListView.performItemClick(null, 0, 0);
                 mListView.performItemClick(null, 1, 0);
@@ -629,8 +516,7 @@
                 mBuilder.setMultiChoiceItems(c, People.NAME, People.NAME,
                         mOnMultiChoiceClickListener);
                 mDialog = mBuilder.show();
-                mLinearLayout = (LinearLayout)mDialog.getWindow().findViewById(R.id.contentPanel);
-                mListView = (ListView)mLinearLayout.getChildAt(0);
+                mListView = mDialog.getListView();
                 mListView.performItemClick(null, 0, 0);
                 mListView.performItemClick(null, 1, 0);
             }
@@ -657,8 +543,7 @@
                 mBuilder.setSingleChoiceItems(com.android.cts.stub.R.array.difficultyLevel, 0,
                         mOnClickListener);
                 mDialog = mBuilder.show();
-                mLinearLayout = (LinearLayout)mDialog.getWindow().findViewById(R.id.contentPanel);
-                mListView = (ListView)mLinearLayout.getChildAt(0);
+                mListView = mDialog.getListView();
                 mSelectedItem = (CharSequence)mListView.getSelectedItem();
                 mListView.performItemClick(null, 0, 0);
             }
@@ -696,8 +581,7 @@
                 mBuilder = new AlertDialog.Builder(mContext);
                 mBuilder.setSingleChoiceItems(c, 0, People.NAME, mOnClickListener);
                 mDialog = mBuilder.show();
-                mLinearLayout = (LinearLayout)mDialog.getWindow().findViewById(R.id.contentPanel);
-                mListView = (ListView)mLinearLayout.getChildAt(0);
+                mListView = mDialog.getListView();
                 mListView.performItemClick(null, 0, 0);
             }
         });
@@ -721,8 +605,7 @@
                 mBuilder = new AlertDialog.Builder(mContext);
                 mBuilder.setSingleChoiceItems(items, 0, mOnClickListener);
                 mDialog = mBuilder.show();
-                mLinearLayout = (LinearLayout)mDialog.getWindow().findViewById(R.id.contentPanel);
-                mListView = (ListView)mLinearLayout.getChildAt(0);
+                mListView = mDialog.getListView();
                 mSelectedItem = (CharSequence)mListView.getSelectedItem();
                 mListView.performItemClick(null, 0, 0);
             }
@@ -746,11 +629,10 @@
             public void run() {
                 mBuilder = new AlertDialog.Builder(mContext);
                 mBuilder.setSingleChoiceItems(new ArrayAdapter<CharSequence>(mContext,
-                        R.layout.select_dialog_singlechoice, R.id.text1, items), 0,
+                        android.R.layout.select_dialog_singlechoice, android.R.id.text1, items), 0,
                         mOnClickListener);
                 mDialog = mBuilder.show();
-                mLinearLayout = (LinearLayout)mDialog.getWindow().findViewById(R.id.contentPanel);
-                mListView = (ListView)mLinearLayout.getChildAt(0);
+                mListView = mDialog.getListView();
                 mSelectedItem = (CharSequence)mListView.getSelectedItem();
                 mListView.performItemClick(null, 0, 0);
             }
@@ -773,8 +655,7 @@
                 mBuilder.setOnItemSelectedListener(mOnItemSelectedListener);
                 mBuilder.setItems(com.android.cts.stub.R.array.difficultyLevel, mOnClickListener);
                 mDialog = mBuilder.show();
-                mLinearLayout = (LinearLayout)mDialog.getWindow().findViewById(R.id.contentPanel);
-                mListView = (ListView)mLinearLayout.getChildAt(0);
+                mListView = mDialog.getListView();
                 mListView.pointToPosition(0, 0);
             }
         });
@@ -789,13 +670,13 @@
     )
     public void testSetView() throws Throwable {
         final View view = new View(mContext);
+        view.setId(100);
         runTestOnUiThread(new Runnable() {
             public void run() {
                 mBuilder = new AlertDialog.Builder(mContext);
                 mBuilder.setView(view);
                 mDialog = mBuilder.show();
-                mFrameLayout = (FrameLayout)mDialog.getWindow().findViewById(R.id.custom);
-                mView = mFrameLayout.getChildAt(0);
+                mView = mDialog.getWindow().findViewById(100);
             }
         });
         mInstrumentation.waitForIdleSync();
@@ -813,22 +694,18 @@
         final int viewSpacingRight = 30;
         final int viewSpacingBottom = 40;
         final View view = new View(mContext);
+        view.setId(100);
         runTestOnUiThread(new Runnable() {
             public void run() {
                 mBuilder = new AlertDialog.Builder(mContext);
                 mBuilder.setView(view, viewSpacingLeft, viewSpacingTop, viewSpacingRight,
                         viewSpacingBottom);
                 mDialog = mBuilder.show();
-                mFrameLayout = (FrameLayout)mDialog.getWindow().findViewById(R.id.custom);
-                mView = mFrameLayout.getChildAt(0);
+                mView = mDialog.getWindow().findViewById(100);
             }
         });
         mInstrumentation.waitForIdleSync();
         assertEquals(view, mView);
-        assertEquals(viewSpacingTop, mFrameLayout.getPaddingTop());
-        assertEquals(viewSpacingLeft, mFrameLayout.getPaddingLeft());
-        assertEquals(viewSpacingRight, mFrameLayout.getPaddingRight());
-        assertEquals(viewSpacingBottom, mFrameLayout.getPaddingBottom());
     }
 
     @TestTargetNew(
diff --git a/tests/tests/app/src/android/app/cts/InstrumentationTest.java b/tests/tests/app/src/android/app/cts/InstrumentationTest.java
index d883c86..1861ae2 100644
--- a/tests/tests/app/src/android/app/cts/InstrumentationTest.java
+++ b/tests/tests/app/src/android/app/cts/InstrumentationTest.java
@@ -37,6 +37,7 @@
 import android.os.SystemClock;
 import android.test.InstrumentationTestCase;
 import android.view.InputQueue;
+import android.view.KeyCharacterMap;
 import android.view.KeyEvent;
 import android.view.LayoutInflater;
 import android.view.MotionEvent;
@@ -51,7 +52,6 @@
 import dalvik.annotation.TestTargetClass;
 import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargets;
-import dalvik.annotation.ToBeFixed;
 
 @TestTargetClass(Instrumentation.class)
 public class InstrumentationTest extends InstrumentationTestCase {
@@ -493,12 +493,13 @@
         assertEquals(text.length(), keyDownList.size());
         assertEquals(text.length(), keyUpList.size());
 
-        for (int i = 0; i < keyDownList.size(); i++) {
-            assertEquals(KeyEvent.KEYCODE_A + i, keyDownList.get(i).getKeyCode());
-        }
+        KeyCharacterMap kcm = KeyCharacterMap.load(KeyCharacterMap.BUILT_IN_KEYBOARD);
+        KeyEvent[] keyEvents = kcm.getEvents(text.toCharArray());
 
-        for (int i = 0; i < keyUpList.size(); i++) {
-            assertEquals(KeyEvent.KEYCODE_A + i, keyUpList.get(i).getKeyCode());
+        int i = 0;
+        for (int j = 0; j < keyDownList.size(); j++) {
+            assertEquals(keyEvents[i++].getKeyCode(), keyDownList.get(j).getKeyCode());
+            assertEquals(keyEvents[i++].getKeyCode(), keyUpList.get(j).getKeyCode());
         }
     }
 
diff --git a/tests/tests/app/src/android/app/cts/LifecycleTest.java b/tests/tests/app/src/android/app/cts/LifecycleTest.java
index 56517ae..aa28628 100644
--- a/tests/tests/app/src/android/app/cts/LifecycleTest.java
+++ b/tests/tests/app/src/android/app/cts/LifecycleTest.java
@@ -17,6 +17,11 @@
 
 package android.app.cts;
 
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
 import android.app.Activity;
 import android.app.Dialog;
 import android.content.ComponentName;
@@ -40,10 +45,6 @@
 import android.view.ViewGroup;
 import android.view.ContextMenu.ContextMenuInfo;
 import android.view.WindowManager.LayoutParams;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetClass;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargets;
 
 @TestTargetClass(Activity.class)
 public class LifecycleTest extends ActivityTestsBase {
@@ -81,2735 +82,6 @@
         ),
         @TestTargetNew(
             level = TestLevel.COMPLETE,
-            method = "finalize",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getInstanceCount",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "closeContextMenu",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getIntent",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setIntent",
-            args = {Intent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getApplication",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "isChild",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getParent",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getWindowManager",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getWindow",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getCurrentFocus",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getWallpaperDesiredMinimumWidth",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getWallpaperDesiredMinimumHeight",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreate",
-            args = {Bundle.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onRestoreInstanceState",
-            args = {Bundle.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPostCreate",
-            args = {Bundle.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onStart",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onRestart",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onResume",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPostResume",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onNewIntent",
-            args = {Intent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onSaveInstanceState",
-            args = {Bundle.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPause",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreateThumbnail",
-            args = {Bitmap.class, Canvas.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreateDescription",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onStop",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onDestroy",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onConfigurationChanged",
-            args = {Configuration.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getChangingConfigurations",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getLastNonConfigurationInstance",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onRetainNonConfigurationInstance",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onLowMemory",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "managedQuery",
-            args = {Uri.class, String[].class, String.class, String.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "managedQuery",
-            args = {Uri.class, String[].class, String.class, String[].class, String.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "managedCommitUpdates",
-            args = {Cursor.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startManagingCursor",
-            args = {Cursor.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "stopManagingCursor",
-            args = {Cursor.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setPersistent",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "findViewById",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setContentView",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setContentView",
-            args = {View.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setContentView",
-            args = {View.class, ViewGroup.LayoutParams.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "addContentView",
-            args = {View.class, ViewGroup.LayoutParams.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setDefaultKeyMode",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onKeyDown",
-            args = {int.class, KeyEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onKeyUp",
-            args = {int.class, KeyEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onKeyMultiple",
-            args = {int.class, int.class, KeyEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onTouchEvent",
-            args = {MotionEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onTrackballEvent",
-            args = {MotionEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onWindowAttributesChanged",
-            args = {LayoutParams.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onContentChanged",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onWindowFocusChanged",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "hasWindowFocus",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "dispatchKeyEvent",
-            args = {KeyEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "dispatchTouchEvent",
-            args = {MotionEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "dispatchTrackballEvent",
-            args = {MotionEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreatePanelView",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreatePanelMenu",
-            args = {int.class, Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPreparePanel",
-            args = {int.class, View.class, Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-             method = "onMenuOpened",
-            args = {int.class, Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onMenuItemSelected",
-            args = {int.class, MenuItem.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-             method = "onPanelClosed",
-            args = {int.class, Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreateOptionsMenu",
-            args = {Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPrepareOptionsMenu",
-            args = {Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onOptionsItemSelected",
-            args = {MenuItem.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onOptionsMenuClosed",
-            args = {Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "openOptionsMenu",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "closeOptionsMenu",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreateContextMenu",
-            args = {ContextMenu.class, View.class, ContextMenuInfo.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "registerForContextMenu",
-            args = {View.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "unregisterForContextMenu",
-            args = {View.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "openContextMenu",
-            args = {View.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onContextItemSelected",
-            args = {MenuItem.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onContextMenuClosed",
-            args = {Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreateDialog",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPrepareDialog",
-            args = {int.class, Dialog.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "showDialog",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "dismissDialog",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "removeDialog",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onSearchRequested",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startSearch",
-            args = {String.class, boolean.class, Bundle.class, boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "takeKeyEvents",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "requestWindowFeature",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setFeatureDrawableResource",
-            args = {int.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setFeatureDrawableUri",
-            args = {int.class, Uri.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setFeatureDrawable",
-            args = {int.class, Drawable.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setFeatureDrawableAlpha",
-            args = {int.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getLayoutInflater",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getMenuInflater",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onApplyThemeResource",
-            args = {Theme.class, int.class, boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startActivityForResult",
-            args = {Intent.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startActivity",
-            args = {Intent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startActivityIfNeeded",
-            args = {Intent.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startNextMatchingActivity",
-            args = {Intent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startActivityFromChild",
-            args = {Activity.class, Intent.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setResult",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setResult",
-            args = {int.class, Intent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getCallingPackage",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getCallingActivity",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "isFinishing",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "finish",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "finishFromChild",
-            args = {Activity.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "finishActivity",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "finishActivityFromChild",
-            args = {Activity.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onActivityResult",
-            args = {int.class, int.class, Intent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "createPendingResult",
-            args = {int.class, Intent.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setRequestedOrientation",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getRequestedOrientation",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getTaskId",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "isTaskRoot",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "moveTaskToBack",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getLocalClassName",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getComponentName",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getPreferences",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getSystemService",
-            args = {String.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setTitle",
-            args = {CharSequence.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setTitle",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setTitleColor",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getTitle",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getTitleColor",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onTitleChanged",
-            args = {CharSequence.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onChildTitleChanged",
-            args = {Activity.class, CharSequence.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setProgressBarVisibility",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setProgressBarIndeterminateVisibility",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setProgressBarIndeterminate",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setProgress",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setSecondaryProgress",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setVolumeControlStream",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getVolumeControlStream",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "runOnUiThread",
-            args = {Runnable.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreateView",
-            args = {String.class, Context.class, AttributeSet.class}
-        )
-    })
-    public void testTabFinishStart() {
-        mIntent = mTabIntent;
-        runLaunchpad(LaunchpadActivity.LIFECYCLE_FINISH_START);
-    }
-
-    @TestTargets({
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "Activity",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "finalize",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onUserInteraction",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onUserLeaveHint",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setVisible",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "closeContextMenu",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getInstanceCount",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getIntent",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setIntent",
-            args = {Intent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getApplication",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "isChild",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getParent",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getWindowManager",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getWindow",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getCurrentFocus",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getWallpaperDesiredMinimumWidth",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getWallpaperDesiredMinimumHeight",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreate",
-            args = {Bundle.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onRestoreInstanceState",
-            args = {Bundle.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPostCreate",
-            args = {Bundle.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onStart",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onRestart",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onResume",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPostResume",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onNewIntent",
-            args = {Intent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onSaveInstanceState",
-            args = {Bundle.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPause",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreateThumbnail",
-            args = {Bitmap.class, Canvas.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreateDescription",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onStop",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onDestroy",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onConfigurationChanged",
-            args = {Configuration.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getChangingConfigurations",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getLastNonConfigurationInstance",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onRetainNonConfigurationInstance",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onLowMemory",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "managedQuery",
-            args = {Uri.class, String[].class, String.class, String.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "managedQuery",
-            args = {Uri.class, String[].class, String.class, String[].class, String.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "managedCommitUpdates",
-            args = {Cursor.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startManagingCursor",
-            args = {Cursor.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "stopManagingCursor",
-            args = {Cursor.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setPersistent",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "findViewById",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setContentView",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setContentView",
-            args = {View.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setContentView",
-            args = {View.class, ViewGroup.LayoutParams.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "addContentView",
-            args = {View.class, ViewGroup.LayoutParams.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setDefaultKeyMode",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onKeyDown",
-            args = {int.class, KeyEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onKeyUp",
-            args = {int.class, KeyEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onKeyMultiple",
-            args = {int.class, int.class, KeyEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onTouchEvent",
-            args = {MotionEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onTrackballEvent",
-            args = {MotionEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onWindowAttributesChanged",
-            args = {LayoutParams.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onContentChanged",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onWindowFocusChanged",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "hasWindowFocus",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "dispatchKeyEvent",
-            args = {KeyEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "dispatchTouchEvent",
-            args = {MotionEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "dispatchTrackballEvent",
-            args = {MotionEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreatePanelView",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreatePanelMenu",
-            args = {int.class, Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPreparePanel",
-            args = {int.class, View.class, Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onMenuOpened",
-            args = {int.class, Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onMenuItemSelected",
-            args = {int.class, MenuItem.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPanelClosed",
-            args = {int.class, Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreateOptionsMenu",
-            args = {Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPrepareOptionsMenu",
-            args = {Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onOptionsItemSelected",
-            args = {MenuItem.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onOptionsMenuClosed",
-            args = {Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "openOptionsMenu",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "closeOptionsMenu",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreateContextMenu",
-            args = {ContextMenu.class, View.class, ContextMenuInfo.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "registerForContextMenu",
-            args = {View.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "unregisterForContextMenu",
-            args = {View.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "openContextMenu",
-            args = {View.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onContextItemSelected",
-            args = {MenuItem.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onContextMenuClosed",
-            args = {Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreateDialog",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPrepareDialog",
-            args = {int.class, Dialog.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "showDialog",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "dismissDialog",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "removeDialog",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onSearchRequested",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startSearch",
-            args = {String.class, boolean.class, Bundle.class, boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "takeKeyEvents",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "requestWindowFeature",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setFeatureDrawableResource",
-            args = {int.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setFeatureDrawableUri",
-            args = {int.class, Uri.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setFeatureDrawable",
-            args = {int.class, Drawable.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setFeatureDrawableAlpha",
-            args = {int.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getLayoutInflater",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getMenuInflater",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onApplyThemeResource",
-            args = {Theme.class, int.class, boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startActivityForResult",
-            args = {Intent.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startActivity",
-            args = {Intent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startActivityIfNeeded",
-            args = {Intent.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startNextMatchingActivity",
-            args = {Intent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startActivityFromChild",
-            args = {Activity.class, Intent.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setResult",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setResult",
-            args = {int.class, Intent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getCallingPackage",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getCallingActivity",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "isFinishing",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "finish",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "finishFromChild",
-            args = {Activity.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "finishActivity",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "finishActivityFromChild",
-            args = {Activity.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onActivityResult",
-            args = {int.class, int.class, Intent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "createPendingResult",
-            args = {int.class, Intent.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setRequestedOrientation",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getRequestedOrientation",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getTaskId",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "isTaskRoot",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "moveTaskToBack",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getLocalClassName",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getComponentName",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getPreferences",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getSystemService",
-            args = {String.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setTitle",
-            args = {CharSequence.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setTitle",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setTitleColor",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getTitle",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getTitleColor",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onTitleChanged",
-            args = {CharSequence.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onChildTitleChanged",
-            args = {Activity.class, CharSequence.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setProgressBarVisibility",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setProgressBarIndeterminateVisibility",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setProgressBarIndeterminate",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setProgress",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setSecondaryProgress",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setVolumeControlStream",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getVolumeControlStream",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "runOnUiThread",
-            args = {Runnable.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreateView",
-            args = {String.class, Context.class, AttributeSet.class}
-        )
-    })
-    public void testFinishStart() {
-        mIntent = mTopIntent;
-        runLaunchpad(LaunchpadActivity.LIFECYCLE_FINISH_START);
-    }
-
-    @TestTargets({
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "Activity",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onUserInteraction",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onUserLeaveHint",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setVisible",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "finalize",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "closeContextMenu",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getInstanceCount",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-
-            method = "getIntent",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setIntent",
-            args = {Intent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getApplication",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "isChild",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getParent",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getWindowManager",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getWindow",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getCurrentFocus",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getWallpaperDesiredMinimumWidth",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getWallpaperDesiredMinimumHeight",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreate",
-            args = {Bundle.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onRestoreInstanceState",
-            args = {Bundle.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPostCreate",
-            args = {Bundle.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onStart",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onRestart",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onResume",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPostResume",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onNewIntent",
-            args = {Intent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onSaveInstanceState",
-            args = {Bundle.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPause",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreateThumbnail",
-            args = {Bitmap.class, Canvas.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreateDescription",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onStop",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onDestroy",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onConfigurationChanged",
-            args = {Configuration.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getChangingConfigurations",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getLastNonConfigurationInstance",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onRetainNonConfigurationInstance",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onLowMemory",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "managedQuery",
-            args = {Uri.class, String[].class, String.class, String.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "managedQuery",
-            args = {Uri.class, String[].class, String.class, String[].class, String.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "managedCommitUpdates",
-            args = {Cursor.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startManagingCursor",
-            args = {Cursor.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "stopManagingCursor",
-            args = {Cursor.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setPersistent",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "findViewById",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setContentView",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setContentView",
-            args = {View.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setContentView",
-            args = {View.class, ViewGroup.LayoutParams.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "addContentView",
-            args = {View.class, ViewGroup.LayoutParams.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setDefaultKeyMode",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onKeyDown",
-            args = {int.class, KeyEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onKeyUp",
-            args = {int.class, KeyEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onKeyMultiple",
-            args = {int.class, int.class, KeyEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onTouchEvent",
-            args = {MotionEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onTrackballEvent",
-            args = {MotionEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onWindowAttributesChanged",
-            args = {LayoutParams.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onContentChanged",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onWindowFocusChanged",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "hasWindowFocus",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "dispatchKeyEvent",
-            args = {KeyEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "dispatchTouchEvent",
-            args = {MotionEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "dispatchTrackballEvent",
-            args = {MotionEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreatePanelView",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreatePanelMenu",
-            args = {int.class, Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPreparePanel",
-            args = {int.class, View.class, Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onMenuOpened",
-            args = {int.class, Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onMenuItemSelected",
-            args = {int.class, MenuItem.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPanelClosed",
-            args = {int.class, Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreateOptionsMenu",
-            args = {Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPrepareOptionsMenu",
-            args = {Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onOptionsItemSelected",
-            args = {MenuItem.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onOptionsMenuClosed",
-            args = {Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "openOptionsMenu",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "closeOptionsMenu",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreateContextMenu",
-            args = {ContextMenu.class, View.class, ContextMenuInfo.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "registerForContextMenu",
-            args = {View.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "unregisterForContextMenu",
-            args = {View.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "openContextMenu",
-            args = {View.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onContextItemSelected",
-            args = {MenuItem.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onContextMenuClosed",
-            args = {Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreateDialog",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPrepareDialog",
-            args = {int.class, Dialog.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "showDialog",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "dismissDialog",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "removeDialog",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onSearchRequested",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startSearch",
-            args = {String.class, boolean.class, Bundle.class, boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "takeKeyEvents",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "requestWindowFeature",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setFeatureDrawableResource",
-            args = {int.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setFeatureDrawableUri",
-            args = {int.class, Uri.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setFeatureDrawable",
-            args = {int.class, Drawable.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setFeatureDrawableAlpha",
-            args = {int.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getLayoutInflater",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getMenuInflater",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onApplyThemeResource",
-            args = {Theme.class, int.class, boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startActivityForResult",
-            args = {Intent.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startActivity",
-            args = {Intent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startActivityIfNeeded",
-            args = {Intent.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startNextMatchingActivity",
-            args = {Intent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startActivityFromChild",
-            args = {Activity.class, Intent.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setResult",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setResult",
-            args = {int.class, Intent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getCallingPackage",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getCallingActivity",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "isFinishing",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "finish",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "finishFromChild",
-            args = {Activity.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "finishActivity",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "finishActivityFromChild",
-            args = {Activity.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onActivityResult",
-            args = {int.class, int.class, Intent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "createPendingResult",
-            args = {int.class, Intent.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setRequestedOrientation",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getRequestedOrientation",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getTaskId",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "isTaskRoot",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "moveTaskToBack",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getLocalClassName",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getComponentName",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getPreferences",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getSystemService",
-            args = {String.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setTitle",
-            args = {CharSequence.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setTitle",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setTitleColor",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getTitle",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getTitleColor",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onTitleChanged",
-            args = {CharSequence.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onChildTitleChanged",
-            args = {Activity.class, CharSequence.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setProgressBarVisibility",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setProgressBarIndeterminateVisibility",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setProgressBarIndeterminate",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setProgress",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setSecondaryProgress",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setVolumeControlStream",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getVolumeControlStream",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "runOnUiThread",
-            args = {Runnable.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreateView",
-            args = {String.class, Context.class, AttributeSet.class}
-        )
-    })
-    public void testTabFinishCreate() {
-        mIntent = mTabIntent;
-        runLaunchpad(LaunchpadActivity.LIFECYCLE_FINISH_CREATE);
-    }
-
-    @TestTargets({
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "Activity",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onUserInteraction",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onUserLeaveHint",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setVisible",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "closeContextMenu",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "finalize",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getInstanceCount",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getIntent",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setIntent",
-            args = {Intent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getApplication",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "isChild",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getParent",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getWindowManager",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getWindow",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getCurrentFocus",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getWallpaperDesiredMinimumWidth",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getWallpaperDesiredMinimumHeight",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreate",
-            args = {Bundle.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onRestoreInstanceState",
-            args = {Bundle.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPostCreate",
-            args = {Bundle.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onStart",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onRestart",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onResume",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPostResume",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onNewIntent",
-            args = {Intent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onSaveInstanceState",
-            args = {Bundle.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPause",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreateThumbnail",
-            args = {Bitmap.class, Canvas.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreateDescription",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onStop",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onDestroy",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onConfigurationChanged",
-            args = {Configuration.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getChangingConfigurations",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getLastNonConfigurationInstance",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onRetainNonConfigurationInstance",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onLowMemory",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "managedQuery",
-            args = {Uri.class, String[].class, String.class, String.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "managedQuery",
-            args = {Uri.class, String[].class, String.class, String[].class, String.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "managedCommitUpdates",
-            args = {Cursor.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startManagingCursor",
-            args = {Cursor.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "stopManagingCursor",
-            args = {Cursor.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setPersistent",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "findViewById",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setContentView",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setContentView",
-            args = {View.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setContentView",
-            args = {View.class, ViewGroup.LayoutParams.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "addContentView",
-            args = {View.class, ViewGroup.LayoutParams.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setDefaultKeyMode",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onKeyDown",
-            args = {int.class, KeyEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onKeyUp",
-            args = {int.class, KeyEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onKeyMultiple",
-            args = {int.class, int.class, KeyEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onTouchEvent",
-            args = {MotionEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onTrackballEvent",
-            args = {MotionEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onWindowAttributesChanged",
-            args = {LayoutParams.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onContentChanged",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onWindowFocusChanged",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "hasWindowFocus",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "dispatchKeyEvent",
-            args = {KeyEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "dispatchTouchEvent",
-            args = {MotionEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "dispatchTrackballEvent",
-            args = {MotionEvent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreatePanelView",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreatePanelMenu",
-            args = {int.class, Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPreparePanel",
-            args = {int.class, View.class, Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onMenuOpened",
-            args = {int.class, Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onMenuItemSelected",
-            args = {int.class, MenuItem.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPanelClosed",
-            args = {int.class, Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreateOptionsMenu",
-            args = {Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPrepareOptionsMenu",
-            args = {Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onOptionsItemSelected",
-            args = {MenuItem.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onOptionsMenuClosed",
-            args = {Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "openOptionsMenu",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "closeOptionsMenu",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreateContextMenu",
-            args = {ContextMenu.class, View.class, ContextMenuInfo.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "registerForContextMenu",
-            args = {View.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "unregisterForContextMenu",
-            args = {View.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "openContextMenu",
-            args = {View.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onContextItemSelected",
-            args = {MenuItem.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onContextMenuClosed",
-            args = {Menu.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreateDialog",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onPrepareDialog",
-            args = {int.class, Dialog.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "showDialog",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "dismissDialog",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "removeDialog",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onSearchRequested",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startSearch",
-            args = {String.class, boolean.class, Bundle.class, boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "takeKeyEvents",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "requestWindowFeature",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setFeatureDrawableResource",
-            args = {int.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setFeatureDrawableUri",
-            args = {int.class, Uri.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setFeatureDrawable",
-            args = {int.class, Drawable.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setFeatureDrawableAlpha",
-            args = {int.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getLayoutInflater",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getMenuInflater",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onApplyThemeResource",
-            args = {Theme.class, int.class, boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startActivityForResult",
-            args = {Intent.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startActivity",
-            args = {Intent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startActivityIfNeeded",
-            args = {Intent.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startNextMatchingActivity",
-            args = {Intent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "startActivityFromChild",
-            args = {Activity.class, Intent.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setResult",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setResult",
-            args = {int.class, Intent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getCallingPackage",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getCallingActivity",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "isFinishing",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "finish",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "finishFromChild",
-            args = {Activity.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "finishActivity",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "finishActivityFromChild",
-            args = {Activity.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onActivityResult",
-            args = {int.class, int.class, Intent.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "createPendingResult",
-            args = {int.class, Intent.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setRequestedOrientation",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getRequestedOrientation",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getTaskId",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "isTaskRoot",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "moveTaskToBack",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getLocalClassName",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getComponentName",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getPreferences",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getSystemService",
-            args = {String.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setTitle",
-            args = {CharSequence.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setTitle",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setTitleColor",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getTitle",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getTitleColor",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onTitleChanged",
-            args = {CharSequence.class, int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onChildTitleChanged",
-            args = {Activity.class, CharSequence.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setProgressBarVisibility",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setProgressBarIndeterminateVisibility",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setProgressBarIndeterminate",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setProgress",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setSecondaryProgress",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setVolumeControlStream",
-            args = {int.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "getVolumeControlStream",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "runOnUiThread",
-            args = {Runnable.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onCreateView",
-            args = {String.class, Context.class, AttributeSet.class}
-        )
-    })
-    public void testFinishCreate() {
-        mIntent = mTopIntent;
-        runLaunchpad(LaunchpadActivity.LIFECYCLE_FINISH_CREATE);
-    }
-
-    @TestTargets({
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "Activity",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onUserInteraction",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "onUserLeaveHint",
-            args = {}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
-            method = "setVisible",
-            args = {boolean.class}
-        ),
-        @TestTargetNew(
-            level = TestLevel.COMPLETE,
             method = "closeContextMenu",
             args = {}
         ),
diff --git a/tests/tests/bluetooth/AndroidManifest.xml b/tests/tests/bluetooth/AndroidManifest.xml
index 8345f5d..486460d 100644
--- a/tests/tests/bluetooth/AndroidManifest.xml
+++ b/tests/tests/bluetooth/AndroidManifest.xml
@@ -17,6 +17,9 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.android.cts.bluetooth">
 
+    <uses-permission android:name="android.permission.BLUETOOTH" />
+    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
+
     <application>
         <uses-library android:name="android.test.runner" />
     </application>
diff --git a/tests/tests/bluetooth/src/android/bluetooth/cts/BasicAdapterTest.java b/tests/tests/bluetooth/src/android/bluetooth/cts/BasicAdapterTest.java
index c6be1d6..a3032bb 100644
--- a/tests/tests/bluetooth/src/android/bluetooth/cts/BasicAdapterTest.java
+++ b/tests/tests/bluetooth/src/android/bluetooth/cts/BasicAdapterTest.java
@@ -17,6 +17,12 @@
 package android.bluetooth.cts;
 
 import android.bluetooth.BluetoothAdapter;
+import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothServerSocket;
+
+import java.io.IOException;
+import java.util.Set;
+import java.util.UUID;
 
 import junit.framework.TestCase;
 
@@ -25,6 +31,10 @@
  * BluetoothAdapter}.
  */
 public class BasicAdapterTest extends TestCase {
+    private static final int DISABLE_TIMEOUT = 5000;  // ms timeout for BT disable
+    private static final int ENABLE_TIMEOUT = 10000;  // ms timeout for BT enable
+    private static final int POLL_TIME = 100;         // ms to poll BT state
+
     public void test_getDefaultAdapter() {
         /*
          * Note: If the target doesn't support Bluetooth at all, then
@@ -92,4 +102,133 @@
         assertTrue(BluetoothAdapter.checkBluetoothAddress(
             "DE:F0:FE:DC:B8:76"));
     }
+
+    /** Checks enable(), disable(), getState(), isEnabled() */
+    public void test_enableDisable() {
+        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
+
+        for (int i=0; i<5; i++) {
+            disable(adapter);
+            enable(adapter);
+        }
+    }
+
+    public void test_getAddress() {
+        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
+        enable(adapter);
+
+        assertTrue(BluetoothAdapter.checkBluetoothAddress(adapter.getAddress()));
+    }
+
+    public void test_getName() {
+        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
+        enable(adapter);
+
+        String name = adapter.getName();
+        assertNotNull(name);
+    }
+
+    public void test_getBondedDevices() {
+        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
+        enable(adapter);
+
+        Set<BluetoothDevice> devices = adapter.getBondedDevices();
+        assertNotNull(devices);
+        for (BluetoothDevice device : devices) {
+            assertTrue(BluetoothAdapter.checkBluetoothAddress(device.getAddress()));
+        }
+    }
+
+    public void test_getRemoteDevice() {
+        // getRemoteDevice() should work even with Bluetooth disabled
+        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
+        disable(adapter);
+
+        // test bad addresses
+        try {
+            adapter.getRemoteDevice(null);
+            fail("IllegalArgumentException not thrown");
+        } catch (IllegalArgumentException e) {}
+        try {
+            adapter.getRemoteDevice("00:00:00:00:00:00:00:00");
+            fail("IllegalArgumentException not thrown");
+        } catch (IllegalArgumentException e) {}
+
+        // test success
+        BluetoothDevice device = adapter.getRemoteDevice("00:11:22:AA:BB:CC");
+        assertNotNull(device);
+        assertEquals("00:11:22:AA:BB:CC", device.getAddress());
+    }
+
+    public void test_listenUsingRfcommWithServiceRecord() throws IOException {
+        BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
+        enable(adapter);
+
+        BluetoothServerSocket socket = adapter.listenUsingRfcommWithServiceRecord(
+                "test", UUID.randomUUID());
+        assertNotNull(socket);
+        socket.close();
+    }
+
+    /** Helper to turn BT off.
+     * This method will either fail on an assert, or return with BT turned off.
+     * Behavior of getState() and isEnabled() are validated along the way.
+     */
+    private void disable(BluetoothAdapter adapter) {
+        if (adapter.getState() == BluetoothAdapter.STATE_OFF) {
+            assertFalse(adapter.isEnabled());
+            return;
+        }
+
+        assertEquals(BluetoothAdapter.STATE_ON, adapter.getState());
+        assertTrue(adapter.isEnabled());
+        adapter.disable();
+        for (int i=0; i<DISABLE_TIMEOUT/POLL_TIME; i++) {
+            switch (adapter.getState()) {
+            case BluetoothAdapter.STATE_OFF:
+                assertFalse(adapter.isEnabled());
+                return;
+            default:
+                assertEquals(BluetoothAdapter.STATE_TURNING_OFF, adapter.getState());
+                assertFalse(adapter.isEnabled());
+                break;
+            }
+            sleep(POLL_TIME);
+        }
+        fail("disable() timeout");
+    }
+
+    /** Helper to turn BT on.
+     * This method will either fail on an assert, or return with BT turned on.
+     * Behavior of getState() and isEnabled() are validated along the way.
+     */
+    private void enable(BluetoothAdapter adapter) {
+        if (adapter.getState() == BluetoothAdapter.STATE_ON) {
+            assertTrue(adapter.isEnabled());
+            return;
+        }
+
+        assertEquals(BluetoothAdapter.STATE_OFF, adapter.getState());
+        assertFalse(adapter.isEnabled());
+        adapter.enable();
+        for (int i=0; i<ENABLE_TIMEOUT/POLL_TIME; i++) {
+            switch (adapter.getState()) {
+            case BluetoothAdapter.STATE_ON:
+                assertTrue(adapter.isEnabled());
+                return;
+            default:
+                assertEquals(BluetoothAdapter.STATE_TURNING_ON, adapter.getState());
+                assertFalse(adapter.isEnabled());
+                break;
+            }
+            sleep(POLL_TIME);
+        }
+        fail("enable() timeout");
+    }
+
+    private static void sleep(long t) {
+        try {
+            Thread.sleep(t);
+        } catch (InterruptedException e) {}
+    }
 }
diff --git a/tests/tests/content/src/android/content/cts/ContextWrapperTest.java b/tests/tests/content/src/android/content/cts/ContextWrapperTest.java
index 0648d32..265ec06 100644
--- a/tests/tests/content/src/android/content/cts/ContextWrapperTest.java
+++ b/tests/tests/content/src/android/content/cts/ContextWrapperTest.java
@@ -1185,7 +1185,7 @@
         assertNull(mContextWrapper.getSystemService("invalid"));
 
         // Test valid service name
-        assertNotNull(mContextWrapper.getSystemService("window"));
+        assertNotNull(mContextWrapper.getSystemService(Context.WINDOW_SERVICE));
     }
 
     @TestTargetNew(
diff --git a/tests/tests/content/src/android/content/res/cts/ConfigurationTest.java b/tests/tests/content/src/android/content/res/cts/ConfigurationTest.java
index 153097a..01620b5 100644
--- a/tests/tests/content/src/android/content/res/cts/ConfigurationTest.java
+++ b/tests/tests/content/src/android/content/res/cts/ConfigurationTest.java
@@ -352,29 +352,53 @@
         args = {android.os.Parcel.class, int.class}
     )
     public void testWriteToParcel() {
-        final Parcel parcel = Parcel.obtain();
-        mConfigDefault.writeToParcel(parcel, 0);
+        assertWriteToParcel(createConfig(null), Parcel.obtain());
+        assertWriteToParcel(createConfig(Locale.JAPAN), Parcel.obtain());
+    }
 
+    private Configuration createConfig(Locale locale) {
+        Configuration config = new Configuration();
+        config.fontScale = 13.37f;
+        config.mcc = 0;
+        config.mnc = 1;
+        config.locale = locale;
+        config.touchscreen = Configuration.TOUCHSCREEN_STYLUS;
+        config.keyboard = Configuration.KEYBOARD_UNDEFINED;
+        config.keyboardHidden = Configuration.KEYBOARDHIDDEN_YES;
+        config.hardKeyboardHidden = Configuration.KEYBOARDHIDDEN_UNDEFINED;
+        config.navigation = Configuration.NAVIGATION_DPAD;
+        config.navigationHidden = Configuration.NAVIGATIONHIDDEN_UNDEFINED;
+        config.orientation = Configuration.ORIENTATION_PORTRAIT;
+        config.screenLayout = Configuration.SCREENLAYOUT_LONG_UNDEFINED;
+        return config;
+    }
+
+    private void assertWriteToParcel(Configuration config, Parcel parcel) {
+        config.writeToParcel(parcel, 0);
         parcel.setDataPosition(0);
-        assertEquals(mConfigDefault.fontScale, parcel.readFloat());
-        assertEquals(mConfigDefault.mcc, parcel.readInt());
-        assertEquals(mConfigDefault.mnc, parcel.readInt());
-        if (mConfigDefault.locale == null) {
+        assertEquals(config.fontScale, parcel.readFloat());
+        assertEquals(config.mcc, parcel.readInt());
+        assertEquals(config.mnc, parcel.readInt());
+        if (config.locale == null) {
             assertEquals(0, parcel.readInt());
         } else {
             assertEquals(1, parcel.readInt());
-            assertEquals(mConfigDefault.locale.getLanguage(),
+            assertEquals(config.locale.getLanguage(),
                     parcel.readString());
-            assertEquals(mConfigDefault.locale.getCountry(),
+            assertEquals(config.locale.getCountry(),
                     parcel.readString());
-            assertEquals(mConfigDefault.locale.getVariant(),
+            assertEquals(config.locale.getVariant(),
                     parcel.readString());
         }
-        assertEquals(mConfigDefault.touchscreen, parcel.readInt());
-        assertEquals(mConfigDefault.keyboard, parcel.readInt());
-        assertEquals(mConfigDefault.keyboardHidden, parcel.readInt());
-        assertEquals(mConfigDefault.navigation, parcel.readInt());
-        assertEquals(mConfigDefault.orientation, parcel.readInt());
+        parcel.readInt();
+        assertEquals(config.touchscreen, parcel.readInt());
+        assertEquals(config.keyboard, parcel.readInt());
+        assertEquals(config.keyboardHidden, parcel.readInt());
+        assertEquals(config.hardKeyboardHidden, parcel.readInt());
+        assertEquals(config.navigation, parcel.readInt());
+        assertEquals(config.navigationHidden, parcel.readInt());
+        assertEquals(config.orientation, parcel.readInt());
+        assertEquals(config.screenLayout, parcel.readInt());
     }
 
 }
diff --git a/tests/tests/database/src/android/database/cts/AbstractCursorTest.java b/tests/tests/database/src/android/database/cts/AbstractCursorTest.java
index 2927a13..47c52ba 100644
--- a/tests/tests/database/src/android/database/cts/AbstractCursorTest.java
+++ b/tests/tests/database/src/android/database/cts/AbstractCursorTest.java
@@ -73,7 +73,9 @@
         mDatabaseCursor.close();
         mTestAbstractCursor.close();
         mDatabase.close();
-        mDatabaseFile.delete();
+        if (mDatabaseFile.exists()) {
+            mDatabaseFile.delete();
+        }
         super.tearDown();
     }
 
diff --git a/tests/tests/database/src/android/database/cts/CursorWrapperTest.java b/tests/tests/database/src/android/database/cts/CursorWrapperTest.java
index 1373db8..dba9784 100644
--- a/tests/tests/database/src/android/database/cts/CursorWrapperTest.java
+++ b/tests/tests/database/src/android/database/cts/CursorWrapperTest.java
@@ -16,8 +16,10 @@
 
 package android.database.cts;
 
-import java.io.File;
-import java.util.Arrays;
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
 
 import android.content.ContentResolver;
 import android.content.Context;
@@ -33,13 +35,12 @@
 import android.os.Bundle;
 import android.os.Handler;
 import android.test.AndroidTestCase;
-import dalvik.annotation.TestTargets;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetClass;
+
+import java.io.File;
+import java.util.Arrays;
 
 @TestTargetClass(android.database.CursorWrapper.class)
-public class CursorWrapperTest extends DatabaseCursorTest {
+public class CursorWrapperTest extends AndroidTestCase {
 
     private static final String FIRST_NUMBER = "123";
     private static final String SECOND_NUMBER = "5555";
@@ -61,7 +62,6 @@
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        setupTestType(TYPE_CURSORWRAPPER);
         setupDatabase();
     }
 
@@ -510,12 +510,12 @@
         final String STRING_TEXT2 = "Test String2";
         final double NUMBER_DOUBLE = Double.MAX_VALUE;
         final double NUMBER_FLOAT = (float) NUMBER_DOUBLE;
-        final long NUMBER_LONG_INTEGER = (long) 0xaabbccddffL;
+        final long NUMBER_LONG_INTEGER = 0xaabbccddffL;
         final long NUMBER_INTEGER = (int) NUMBER_LONG_INTEGER;
         final long NUMBER_SHORT = (short) NUMBER_INTEGER;
 
-        assertTrue(NUMBER_DOUBLE != (double) NUMBER_FLOAT);
-        assertTrue(NUMBER_LONG_INTEGER != (long) NUMBER_INTEGER);
+        assertTrue(NUMBER_DOUBLE != NUMBER_FLOAT);
+        assertTrue(NUMBER_LONG_INTEGER != NUMBER_INTEGER);
         assertTrue(NUMBER_LONG_INTEGER != (short) NUMBER_SHORT);
         assertTrue(NUMBER_INTEGER != (int) NUMBER_SHORT);
 
diff --git a/tests/tests/database/src/android/database/sqlite/cts/SQLiteDatabaseTest.java b/tests/tests/database/src/android/database/sqlite/cts/SQLiteDatabaseTest.java
index 49df6b2..7a18cd8 100644
--- a/tests/tests/database/src/android/database/sqlite/cts/SQLiteDatabaseTest.java
+++ b/tests/tests/database/src/android/database/sqlite/cts/SQLiteDatabaseTest.java
@@ -463,17 +463,26 @@
     })
     @ToBeFixed(bug = "1676383", explanation = "setPageSize does not work as javadoc declares.")
     public void testAccessPageSize() {
-        mDatabaseFile = new File(mDatabaseDir, "database.db");
-        if (mDatabaseFile.exists()) {
-            mDatabaseFile.delete();
+        File databaseFile = new File(mDatabaseDir, "database.db");
+        if (databaseFile.exists()) {
+            databaseFile.delete();
         }
-        mDatabase = SQLiteDatabase.openOrCreateDatabase(mDatabaseFile.getPath(), null);
+        SQLiteDatabase database = null;
+        try {
+            database = SQLiteDatabase.openOrCreateDatabase(databaseFile.getPath(), null);
 
-        long initialValue = mDatabase.getPageSize();
-        // check that this does not throw an exception
-        // setting a different page size may not be supported after the DB has been created
-        mDatabase.setPageSize(initialValue);
-        assertEquals(initialValue, mDatabase.getPageSize());
+            long initialValue = database.getPageSize();
+            // check that this does not throw an exception
+            // setting a different page size may not be supported after the DB has been created
+            database.setPageSize(initialValue);
+            assertEquals(initialValue, database.getPageSize());
+
+        } finally {
+            if (database != null) {
+                database.close();
+                databaseFile.delete();
+            }
+        }
     }
 
     @TestTargetNew(
@@ -861,9 +870,16 @@
     public void testIsReadOnly() {
         assertFalse(mDatabase.isReadOnly());
 
-        mDatabase = SQLiteDatabase.openDatabase(mDatabaseFilePath, null,
-                SQLiteDatabase.OPEN_READONLY);
-        assertTrue(mDatabase.isReadOnly());
+        SQLiteDatabase database = null;
+        try {
+            database = SQLiteDatabase.openDatabase(mDatabaseFilePath, null,
+                    SQLiteDatabase.OPEN_READONLY);
+            assertTrue(database.isReadOnly());
+        } finally {
+            if (database != null) {
+                database.close();
+            }
+        }
     }
 
     @TestTargetNew(
diff --git a/tests/tests/graphics/src/android/graphics/cts/MovieTest.java b/tests/tests/graphics/src/android/graphics/cts/MovieTest.java
index ab875bb..accb08f 100644
--- a/tests/tests/graphics/src/android/graphics/cts/MovieTest.java
+++ b/tests/tests/graphics/src/android/graphics/cts/MovieTest.java
@@ -29,12 +29,12 @@
 import android.graphics.Movie;
 import android.graphics.Paint;
 import android.test.ActivityInstrumentationTestCase2;
-import dalvik.annotation.BrokenTest;
+import android.widget.cts.WidgetTestUtils;
+
 import dalvik.annotation.TestTargets;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargetClass;
-import dalvik.annotation.ToBeFixed;
 
 @TestTargetClass(Movie.class)
 public class MovieTest extends ActivityInstrumentationTestCase2<MockActivity> {
@@ -54,11 +54,9 @@
     @TestTargetNew(
         level = TestLevel.COMPLETE,
         method = "draw",
-        args = {android.graphics.Canvas.class, float.class, float.class, 
+        args = {android.graphics.Canvas.class, float.class, float.class,
                 android.graphics.Paint.class}
     )
-    @ToBeFixed(bug = "1790416", explanation = "mMovie shouldn't be null")
-    @BrokenTest("mMovie is null")
     public void testDraw1() {
         Canvas c = new Canvas();
         Paint p = new Paint();
@@ -70,8 +68,6 @@
         method = "draw",
         args = {android.graphics.Canvas.class, float.class, float.class}
     )
-    @ToBeFixed(bug = "1790416", explanation = "mMovie shouldn't be null")
-    @BrokenTest("mMovie is null")
     public void testDraw2() {
         Canvas c = new Canvas();
         mMovie.draw(c, 100, 200);
@@ -82,8 +78,6 @@
         method = "decodeFile",
         args = {java.lang.String.class}
     )
-    @ToBeFixed(bug = "1790416", explanation = "mMovie shouldn't be null")
-    @BrokenTest("mMovie is null")
     public void testDecodeFile() throws Exception {
         mMovie = null;
         File dbDir = getInstrumentation().getTargetContext().getDir("tests",
@@ -143,8 +137,6 @@
         method = "decodeByteArray",
         args = {byte[].class, int.class, int.class}
     )
-    @ToBeFixed(bug="1491795", explanation="always return null")
-    @BrokenTest("mMovie is null")
     public void testDecodeByteArray() throws Exception {
         mMovie = null;
         InputStream is = getActivity().getResources().openRawResource(MOVIE);
@@ -160,8 +152,6 @@
         method = "decodeStream",
         args = {java.io.InputStream.class}
     )
-    @ToBeFixed(bug = "1790416", explanation = "mMovie shouldn't be null")
-    @BrokenTest("mMovie is null")
     public void testDecodeStream() {
         assertFalse(mMovie.isOpaque());
         mMovie = null;
@@ -182,8 +172,6 @@
         method = "setTime",
         args = {int.class}
     )
-    @ToBeFixed(bug = "1790416", explanation = "mMovie shouldn't be null")
-    @BrokenTest("mMovie is null")
     public void testSetTime() {
         assertTrue(mMovie.setTime(1000));
         assertFalse(mMovie.setTime(Integer.MAX_VALUE));
@@ -213,16 +201,17 @@
             args = {}
         )
     })
-    @ToBeFixed(bug = "1790416", explanation = "mMovie shouldn't be null")
-    @BrokenTest("mMovie is null")
     public void testGetMovieProperties() {
         assertEquals(1000, mMovie.duration());
         assertFalse(mMovie.isOpaque());
-        int expectedHeight = getActivity().getResources().getDrawable(MOVIE)
-                .getIntrinsicHeight();
-        assertEquals(expectedHeight, mMovie.height());
-        int expectedWidth = getActivity().getResources().getDrawable(MOVIE)
-                .getIntrinsicWidth();
-        assertEquals(expectedWidth, mMovie.width());
+
+        int expectedHeight = getActivity().getResources().getDrawable(MOVIE).getIntrinsicHeight();
+        int scaledHeight = WidgetTestUtils.convertDipToPixels(getActivity(), mMovie.height());
+        assertEquals(expectedHeight, scaledHeight);
+
+        int expectedWidth = getActivity().getResources().getDrawable(MOVIE).getIntrinsicWidth();
+        int scaledWidth = WidgetTestUtils.convertDipToPixels(getActivity(), mMovie.width());
+        assertEquals(expectedWidth, scaledWidth);
+
     }
 }
\ No newline at end of file
diff --git a/tests/tests/graphics/src/android/graphics/drawable/cts/NinePatchDrawableTest.java b/tests/tests/graphics/src/android/graphics/drawable/cts/NinePatchDrawableTest.java
index 608d931..064c45a 100644
--- a/tests/tests/graphics/src/android/graphics/drawable/cts/NinePatchDrawableTest.java
+++ b/tests/tests/graphics/src/android/graphics/drawable/cts/NinePatchDrawableTest.java
@@ -76,9 +76,6 @@
             args = {android.graphics.NinePatch.class}
         )
     })
-    @ToBeFixed(bug = "1417734", explanation = "should add @throws clause into javadoc of "
-            + "NinePatchDrawable#NinePatchDrawable(Bitmap, byte[], Rect, String) "
-            + "when param bitmap, chunk, padding or srcName is null")
     @SuppressWarnings("deprecation")
     public void testConstructors() {
         byte[] chunk = new byte[MIN_CHUNK_SIZE];
@@ -91,41 +88,7 @@
 
         new NinePatchDrawable(bmp, chunk, r, name);
 
-        try {
-            new NinePatchDrawable(null, chunk, r, name);
-            fail("The constructor should check whether the bitmap is null.");
-        } catch (NullPointerException e) {
-        }
-
-        // These codes will crash the test cases though the exceptions are caught.
-        // try {
-        //     new NinePatchDrawable(bmp, null, r, name);
-        //     fail("The constructor should check whether the chunk is null.");
-        // } catch (Exception e) {
-        // }
-
-        try {
-            mNinePatchDrawable = new NinePatchDrawable(bmp, chunk, null, name);
-            fail("The constructor should not accept null padding.");
-        } catch (NullPointerException e) {
-        }
-
-        try {
-            new NinePatchDrawable(bmp, chunk, r, null);
-        } catch (NullPointerException e) {
-            fail("The constructor should accept null srcname.");
-        }
-
-        // Known Failure - should not throw NPE bug 2136234
-        // still test for this so test can be adjusted once framework fixed
-        try {
-            new NinePatchDrawable(new NinePatch(bmp, chunk, name));
-        } catch (NullPointerException e) {
-            // expected
-        }
-
-        // constructor should accept a null NinePatch
-        mNinePatchDrawable = new NinePatchDrawable(null);
+        new NinePatchDrawable(new NinePatch(bmp, chunk, name));
 
         chunk = new byte[MIN_CHUNK_SIZE - 1];
         chunk[MIN_CHUNK_SIZE - 2] = 1;
diff --git a/tests/tests/graphics/src/android/opengl/cts/GLSurfaceViewTest.java b/tests/tests/graphics/src/android/opengl/cts/GLSurfaceViewTest.java
new file mode 100644
index 0000000..4f55f96
--- /dev/null
+++ b/tests/tests/graphics/src/android/opengl/cts/GLSurfaceViewTest.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.opengl.cts;
+
+import android.opengl.GLSurfaceView;
+import android.test.ActivityInstrumentationTestCase2;
+import android.test.UiThreadTest;
+import android.util.Log;
+
+import dalvik.annotation.TestTargetClass;
+
+/**
+ * Tests for the GLSurfaceView class.
+ */
+@TestTargetClass(GLSurfaceView.class)
+public class GLSurfaceViewTest extends
+        ActivityInstrumentationTestCase2<GLSurfaceViewStubActivity> {
+
+    private static final int NUM_PAUSE_RESUME_ITERATIONS_WITHOUT_DELAY = 1000;
+
+    private static final int NUM_PAUSE_RESUME_ITERATIONS_WITH_DELAY = 100;
+
+    private static final int PAUSE_RESUME_DELAY = 10;
+
+    private static final boolean LOG_PAUSE_RESUME = false;
+
+    private static final String TAG = "GLSurfaceViewTest";
+
+    private GLSurfaceViewStubActivity mActivity;
+
+    public GLSurfaceViewTest() {
+        super("com.android.cts.stub", GLSurfaceViewStubActivity.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mActivity = getActivity();
+    }
+
+    /**
+     * Test repeated pausing and resuming of a GLSurfaceView with a delay
+     * between iterations.
+     * <p>
+     * This test simply verifies that the system is able to perform multiple
+     * pause/resume sequences without crashing. The delay is used to allow
+     * asynchronous events to occur in between the pause and resume operations.
+     * </p>
+     *
+     * @throws InterruptedException
+     */
+    @UiThreadTest
+    public void testPauseResumeWithDelay() throws InterruptedException {
+        GLSurfaceView view = mActivity.getView();
+        for (int i = 0; i < NUM_PAUSE_RESUME_ITERATIONS_WITH_DELAY; i++) {
+            Thread.sleep(PAUSE_RESUME_DELAY);
+            if (LOG_PAUSE_RESUME) {
+                Log.w(TAG, "Pause/Resume (w/ delay) step " + i + " - pause");
+            }
+            view.onPause();
+            Thread.sleep(PAUSE_RESUME_DELAY);
+            if (LOG_PAUSE_RESUME) {
+                Log.w(TAG, "Pause/Resume (w/ delay) step " + i + " - resume");
+            }
+            view.onResume();
+        }
+    }
+
+    /**
+     * Test repeated pausing and resuming of a GLSurfaceView.
+     * <p>
+     * This test simply verifies that the system is able to perform multiple
+     * pause/resume sequences without crashing. No delay is used so that a
+     * larger number of iterations can be done in a short amount of time.
+     * </p>
+     */
+    @UiThreadTest
+    public void testPauseResumeWithoutDelay() {
+        GLSurfaceView view = mActivity.getView();
+        for (int i = 0; i < NUM_PAUSE_RESUME_ITERATIONS_WITHOUT_DELAY; i++) {
+            if (LOG_PAUSE_RESUME) {
+                Log.w(TAG, "Pause/Resume (no delay) step " + i + " - pause");
+            }
+            view.onPause();
+            if (LOG_PAUSE_RESUME) {
+                Log.w(TAG, "Pause/Resume (no delay) step " + i + " - resume");
+            }
+            view.onResume();
+        }
+    }
+}
diff --git a/tests/tests/net/src/android/net/cts/ListeningPortsTest.java b/tests/tests/net/src/android/net/cts/ListeningPortsTest.java
new file mode 100644
index 0000000..ff6b4e9
--- /dev/null
+++ b/tests/tests/net/src/android/net/cts/ListeningPortsTest.java
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net.cts;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Scanner;
+import java.util.regex.Pattern;
+
+import junit.framework.TestCase;
+
+public class ListeningPortsTest extends TestCase {
+
+    /** Address patterns used to check whether we're checking the right column in /proc/net. */
+    private static final List<String> ADDRESS_PATTERNS = new ArrayList<String>(2);
+
+    static {
+        ADDRESS_PATTERNS.add("[0-9A-F]{8}:[0-9A-F]{4}");
+        ADDRESS_PATTERNS.add("[0-9A-F]{32}:[0-9A-F]{4}");
+    }
+
+    /** Ports that are allowed to be listening on the emulator. */
+    private static final List<String> EXCEPTION_PATTERNS = new ArrayList<String>(6);
+
+    static {
+        // IPv4 exceptions
+        EXCEPTION_PATTERNS.add("00000000:15B3"); // 0.0.0.0:5555   - emulator port
+        EXCEPTION_PATTERNS.add("0F02000A:15B3"); // 10.0.2.15:5555 - net forwarding for emulator
+        EXCEPTION_PATTERNS.add("[0-9A-F]{6}7F:[0-9A-F]{4}"); // IPv4 Loopback
+
+        // IPv6 exceptions
+        EXCEPTION_PATTERNS.add("[0]{31}1:[0-9A-F]{4}"); // IPv6 Loopback
+        EXCEPTION_PATTERNS.add("[0]{16}[0]{4}[0]{4}[0-9A-F]{6}7F:[0-9A-F]{4}"); // IPv4-6 Conversion
+        EXCEPTION_PATTERNS.add("[0]{16}[F]{4}[0]{4}[0-9A-F]{6}7F:[0-9A-F]{4}"); // IPv4-6 Conversion
+    }
+
+    public static void testNoListeningPorts() {
+        final boolean isTcp = true;
+        assertNoListeningPorts("/proc/net/tcp", isTcp);
+        assertNoListeningPorts("/proc/net/tcp6", isTcp);
+        assertNoListeningPorts("/proc/net/udp", !isTcp);
+        assertNoListeningPorts("/proc/net/udp6", !isTcp);
+    }
+
+    private static void assertNoListeningPorts(String procFilePath, boolean isTcp) {
+
+        /*
+         * Sample output of "cat /proc/net/tcp" on emulator:
+         *
+         * sl  local_address rem_address   st tx_queue rx_queue tr tm->when retrnsmt   uid  ...
+         * 0: 0100007F:13AD 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0   ...
+         * 1: 00000000:15B3 00000000:0000 0A 00000000:00000000 00:00000000 00000000     0   ...
+         * 2: 0F02000A:15B3 0202000A:CE8A 01 00000000:00000000 00:00000000 00000000     0   ...
+         *
+         */
+
+        File procFile = new File(procFilePath);
+        Scanner scanner = null;
+        try {
+            scanner = new Scanner(procFile);
+            while (scanner.hasNextLine()) {
+                String line = scanner.nextLine().trim();
+
+                // Skip column headers
+                if (line.startsWith("sl")) {
+                    continue;
+                }
+
+                String[] fields = line.split("\\s+");
+                final int expectedNumColumns = 12;
+                assertTrue(procFilePath + " should have at least " + expectedNumColumns
+                        + " columns of output " + fields, fields.length >= expectedNumColumns);
+
+                String localAddress = fields[1];
+                String state = fields[3];
+
+                assertTrue(procFilePath + " should have an IP address in the second column",
+                        isAddress(localAddress));
+
+                if (!isException(localAddress) && isPortListening(state, isTcp)) {
+                    fail("Found port listening on " + localAddress + " in " + procFilePath);
+                }
+            }
+        } catch (FileNotFoundException notFound) {
+            fail("Could not open file " + procFilePath + " to check for listening ports.");
+        } finally {
+            if (scanner != null) {
+                scanner.close();
+            }
+        }
+    }
+
+    private static boolean isAddress(String localAddress) {
+        return isPatternMatch(ADDRESS_PATTERNS, localAddress);
+    }
+
+    private static boolean isException(String localAddress) {
+        return isPatternMatch(EXCEPTION_PATTERNS, localAddress);
+    }
+
+    private static boolean isPatternMatch(List<String> patterns, String input) {
+        for (String pattern : patterns) {
+            if (Pattern.matches(pattern, input)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private static boolean isPortListening(String state, boolean isTcp) {
+        // 0A = TCP_LISTEN from include/net/tcp_states.h
+        String listeningState = isTcp ? "0A" : "07";
+        return listeningState.equals(state);
+    }
+}
diff --git a/tests/tests/os/src/android/os/cts/Debug_InstructionCountTest.java b/tests/tests/os/src/android/os/cts/Debug_InstructionCountTest.java
new file mode 100644
index 0000000..d6e9a68
--- /dev/null
+++ b/tests/tests/os/src/android/os/cts/Debug_InstructionCountTest.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.os.cts;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+import android.os.Debug;
+
+import junit.framework.TestCase;
+
+@TestTargetClass(Debug.InstructionCount.class)
+public class Debug_InstructionCountTest extends TestCase {
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "Debug.InstructionCount",
+            args = {}
+            ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "resetAndStart",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "collect",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "globalTotal",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "globalMethodInvocations",
+            args = {}
+        )
+    })
+    public void testDebugInstructionCount() {
+        Debug.InstructionCount instructionCount = new Debug.InstructionCount();
+
+        assertTrue(instructionCount.resetAndStart());
+        addTest(1, 2);
+        instructionCount.collect();
+        int insCountsFirst = instructionCount.globalTotal();
+        int methodInvFirst = instructionCount.globalMethodInvocations();
+
+        assertTrue(instructionCount.resetAndStart());
+        addTest(1, 2);
+        addTest(1, 2);
+        instructionCount.collect();
+        int insCountsSecond = instructionCount.globalTotal();
+        int methodInvSecond = instructionCount.globalMethodInvocations();
+
+        assertTrue(instructionCount.resetAndStart());
+        addTest(1, 2);
+        addTest(1, 2);
+        addTest(1, 2);
+        instructionCount.collect();
+        int insCountsThird = instructionCount.globalTotal();
+        int methodInvThird = instructionCount.globalMethodInvocations();
+
+        assertEquals(insCountsThird - insCountsFirst, (insCountsSecond - insCountsFirst) * 2);
+        assertEquals(methodInvThird - methodInvFirst, (methodInvSecond - methodInvFirst) * 2);
+    }
+
+    // must not be private, otherwise javac may inline the code
+    protected int addTest(int a, int b) {
+        return a + b;
+    }
+}
diff --git a/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java b/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java
index 90b2bf9..9ecbf20 100644
--- a/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java
+++ b/tests/tests/telephony/src/android/telephony/cts/TelephonyManagerTest.java
@@ -22,6 +22,8 @@
 import dalvik.annotation.TestTargets;
 
 import android.content.Context;
+import android.net.wifi.WifiInfo;
+import android.net.wifi.WifiManager;
 import android.os.Looper;
 import android.os.cts.TestThread;
 import android.telephony.CellLocation;
@@ -29,6 +31,8 @@
 import android.telephony.TelephonyManager;
 import android.test.AndroidTestCase;
 
+import java.util.regex.Pattern;
+
 @TestTargetClass(TelephonyManager.class)
 public class TelephonyManagerTest extends AndroidTestCase {
     private TelephonyManager mTelephonyManager;
@@ -266,4 +270,137 @@
         mTelephonyManager.getDeviceId();
         mTelephonyManager.getDeviceSoftwareVersion();
     }
+
+    /**
+     * Tests that the device properly reports either a valid IMEI if GSM,
+     * a valid MEID if CDMA, or a valid MAC address if only a WiFi device.
+     */
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "getDeviceId",
+        args = {}
+    )
+    public void testGetDeviceId() {
+        String deviceId = mTelephonyManager.getDeviceId();
+        int phoneType = mTelephonyManager.getPhoneType();
+        switch (phoneType) {
+            case TelephonyManager.PHONE_TYPE_GSM:
+                assertImeiDeviceId(deviceId);
+                break;
+
+            case TelephonyManager.PHONE_TYPE_CDMA:
+                assertMeidDeviceId(deviceId);
+                break;
+
+            case TelephonyManager.PHONE_TYPE_NONE:
+                assertMacAddressReported();
+                break;
+
+            default:
+                throw new IllegalArgumentException("Did you add a new phone type? " + phoneType);
+        }
+    }
+
+    private static void assertImeiDeviceId(String deviceId) {
+        assertImeiFormat(deviceId);
+        assertImeiCheckDigit(deviceId);
+        assertReportingBodyIdentifier(deviceId, true); // Must be decimal identifier
+    }
+
+    private static void assertImeiFormat(String deviceId) {
+        // IMEI must include the check digit
+        String imeiPattern = "[0-9]{15}";
+        assertTrue("IMEI device id " + deviceId + " does not match pattern " + imeiPattern,
+                Pattern.matches(imeiPattern, deviceId));
+    }
+
+    private static void assertImeiCheckDigit(String deviceId) {
+        int expectedCheckDigit = getLuhnCheckDigit(deviceId.substring(0, 14));
+        int actualCheckDigit = Character.digit(deviceId.charAt(14), 10);
+        assertEquals("Incorrect check digit for " + deviceId, expectedCheckDigit, actualCheckDigit);
+    }
+
+    /**
+     * Use decimal value (0-9) to index into array to get sum of its digits
+     * needed by Lunh check.
+     *
+     * Example: DOUBLE_DIGIT_SUM[6] = 3 because 6 * 2 = 12 => 1 + 2 = 3
+     */
+    private static final int[] DOUBLE_DIGIT_SUM = {0, 2, 4, 6, 8, 1, 3, 5, 7, 9};
+
+    /**
+     * Calculate the check digit by starting from the right, doubling every
+     * each digit, summing all the digits including the doubled ones, and
+     * finding a number to make the sum divisible by 10.
+     *
+     * @param deviceId not including the check digit
+     * @return the check digit
+     */
+    private static int getLuhnCheckDigit(String deviceId) {
+        int sum = 0;
+        int dontDoubleModulus = deviceId.length() % 2;
+        for (int i = deviceId.length() - 1; i >= 0; --i) {
+            int digit = Character.digit(deviceId.charAt(i), 10);
+            if (i % 2 == dontDoubleModulus) {
+                sum += digit;
+            } else {
+                sum += DOUBLE_DIGIT_SUM[digit];
+            }
+        }
+        sum %= 10;
+        return sum == 0 ? 0 : 10 - sum;
+    }
+
+    private static void assertReportingBodyIdentifier(String deviceId, boolean decimalIdentifier) {
+        // Check the reporting body identifier
+        int reportingBodyIdentifier = Integer.parseInt(deviceId.substring(0, 2), 16);
+        int decimalBound = 0xA0;
+        String message = String.format("%s RR %x not %s than %x",
+                decimalIdentifier ? "IMEI" : "MEID",
+                reportingBodyIdentifier,
+                decimalIdentifier ? "<" : ">=",
+                decimalBound);
+        assertEquals(message, decimalIdentifier, reportingBodyIdentifier < decimalBound);
+    }
+
+    private static void assertMeidDeviceId(String deviceId) {
+        assertHexadecimalMeidFormat(deviceId);
+        assertReportingBodyIdentifier(deviceId, false); // Must be hexadecimal identifier
+    }
+
+    private static void assertHexadecimalMeidFormat(String deviceId) {
+        // MEID must NOT include the check digit.
+        String meidPattern = "[0-9a-fA-F]{14}";
+        assertTrue("MEID hex device id " + deviceId + " does not match pattern " + meidPattern,
+                Pattern.matches(meidPattern, deviceId));
+    }
+
+    private void assertMacAddressReported() {
+        String macAddress = getMacAddress();
+        String macPattern = "([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}";
+        assertTrue("MAC Address " + macAddress + " does not match pattern " + macPattern,
+                Pattern.matches(macPattern, macAddress));
+    }
+
+    /** @return mac address which requires the WiFi system to be enabled */
+    private String getMacAddress() {
+        WifiManager wifiManager = (WifiManager) getContext()
+                .getSystemService(Context.WIFI_SERVICE);
+
+        boolean enabled = wifiManager.isWifiEnabled();
+
+        try {
+            if (!enabled) {
+                wifiManager.setWifiEnabled(true);
+            }
+
+            WifiInfo wifiInfo = wifiManager.getConnectionInfo();
+            return wifiInfo.getMacAddress();
+
+        } finally {
+            if (!enabled) {
+                wifiManager.setWifiEnabled(false);
+            }
+        }
+    }
 }
diff --git a/tests/tests/text/src/android/text/method/cts/DateTimeKeyListenerTest.java b/tests/tests/text/src/android/text/method/cts/DateTimeKeyListenerTest.java
index dd85b55..225c4b4 100644
--- a/tests/tests/text/src/android/text/method/cts/DateTimeKeyListenerTest.java
+++ b/tests/tests/text/src/android/text/method/cts/DateTimeKeyListenerTest.java
@@ -124,15 +124,15 @@
         assertEquals("", mTextView.getText().toString());
 
         // press '1' key.
-        sendKeys(KeyEvent.KEYCODE_1);
+        mInstrumentation.sendStringSync("1");
         assertEquals("1", mTextView.getText().toString());
 
         // press '2' key.
-        sendKeys(KeyEvent.KEYCODE_2);
+        mInstrumentation.sendStringSync("2");
         assertEquals("12", mTextView.getText().toString());
 
         // press 'a' key.
-        sendKeys(KeyEvent.KEYCODE_A);
+        mInstrumentation.sendStringSync("a");
         assertEquals("12a", mTextView.getText().toString());
 
         // press an unaccepted key if it exists.
@@ -152,7 +152,7 @@
         mInstrumentation.waitForIdleSync();
         assertEquals("12a", mTextView.getText().toString());
 
-        sendKeys(KeyEvent.KEYCODE_1);
+        mInstrumentation.sendStringSync("1");
         assertEquals("12a", mTextView.getText().toString());
     }
 
diff --git a/tests/tests/text/src/android/text/method/cts/ScrollingMovementMethodTest.java b/tests/tests/text/src/android/text/method/cts/ScrollingMovementMethodTest.java
index 907b522..9968bda 100644
--- a/tests/tests/text/src/android/text/method/cts/ScrollingMovementMethodTest.java
+++ b/tests/tests/text/src/android/text/method/cts/ScrollingMovementMethodTest.java
@@ -38,6 +38,7 @@
 import android.view.ViewGroup.LayoutParams;
 import android.widget.TextView;
 import android.widget.TextView.BufferType;
+import android.widget.cts.WidgetTestUtils;
 
 /**
  * Test {@link ScrollingMovementMethod}. The class is an implementation of interface
@@ -117,9 +118,9 @@
                 mTextView.setText("hello world", BufferType.SPANNABLE);
                 mTextView.setSingleLine();
                 mSpannable = (Spannable) mTextView.getText();
+                int width = WidgetTestUtils.convertDipToPixels(getActivity(), LITTLE_SPACE);
                 getActivity().setContentView(mTextView,
-                        new ViewGroup.LayoutParams(LITTLE_SPACE,
-                                ViewGroup.LayoutParams.WRAP_CONTENT));
+                        new ViewGroup.LayoutParams(width, ViewGroup.LayoutParams.WRAP_CONTENT));
             }
         });
         assertNotNull(mTextView.getLayout());
@@ -340,9 +341,9 @@
          */
         runActionOnUiThread(new Runnable() {
             public void run() {
+                int width = WidgetTestUtils.convertDipToPixels(getActivity(), LITTLE_SPACE);
                 getActivity().setContentView(mTextView,
-                        new ViewGroup.LayoutParams(LITTLE_SPACE,
-                                ViewGroup.LayoutParams.WRAP_CONTENT));
+                        new ViewGroup.LayoutParams(width, ViewGroup.LayoutParams.WRAP_CONTENT));
             }
         });
         assertNotNull(mTextView.getLayout());
@@ -474,9 +475,9 @@
             public void run() {
                 mTextView.setText("short");
                 mTextView.setSingleLine();
+                int width = WidgetTestUtils.convertDipToPixels(getActivity(), LITTLE_SPACE);
                 getActivity().setContentView(mTextView,
-                        new ViewGroup.LayoutParams(LITTLE_SPACE,
-                                ViewGroup.LayoutParams.WRAP_CONTENT));
+                        new ViewGroup.LayoutParams(width, ViewGroup.LayoutParams.WRAP_CONTENT));
             }
         });
         assertNotNull(mTextView.getLayout());
@@ -832,9 +833,10 @@
 
         runActionOnUiThread(new Runnable() {
             public void run() {
+                int height = WidgetTestUtils.convertDipToPixels(getActivity(), LITTLE_SPACE);
                 getActivity().setContentView(mTextView,
                         new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
-                                LITTLE_SPACE));
+                                height));
             }
         });
         Layout layout = mTextView.getLayout();
@@ -889,12 +891,6 @@
             args = {TextView.class, Spannable.class}
         )
     })
-    @ToBeFixed(bug = "1695243", explanation = "Android API javadocs are incomplete. @throws clause "
-            + "should be added into javadoc of "
-            + "ScrollingMovementMethod#left(TextView, Spannable) and "
-            + "ScrollingMovementMethod#right(TextView, Spannable)"
-            + "when the param widget or buffer is null")
-    @KnownFailure(value="bug 2323405, needs investigation")
     public void testHorizontalMovement() throws Throwable {
         /*
          * All these assertions depends on whether the TextView has a layout.The text view will not
@@ -909,9 +905,9 @@
             public void run() {
                 mTextView.setText("short");
                 mTextView.setSingleLine();
+                int width = WidgetTestUtils.convertDipToPixels(getActivity(), LITTLE_SPACE);
                 getActivity().setContentView(mTextView,
-                        new ViewGroup.LayoutParams(LITTLE_SPACE,
-                                ViewGroup.LayoutParams.WRAP_CONTENT));
+                        new ViewGroup.LayoutParams(width, ViewGroup.LayoutParams.WRAP_CONTENT));
             }
         });
         assertNotNull(mTextView.getLayout());
@@ -948,34 +944,6 @@
             }
         }));
         assertEquals(previousScrollX, mTextView.getScrollX());
-
-        runActionOnUiThread(new Runnable() {
-            public void run() {
-                try {
-                    method.right(null, mSpannable);
-                } catch (NullPointerException e) {
-                    // NPE is acceptable
-                }
-
-                try {
-                    method.right(mTextView, null);
-                } catch (NullPointerException e) {
-                    // NPE is acceptable
-                }
-
-                try {
-                    method.left(null, mSpannable);
-                } catch (NullPointerException e) {
-                    // NPE is acceptable
-                }
-
-                try {
-                    method.left(mTextView, null);
-                } catch (NullPointerException e) {
-                    // NPE is acceptable
-                }
-            }
-        });
     }
 
     @TestTargetNew(
diff --git a/tests/tests/text/src/android/text/method/cts/TimeKeyListenerTest.java b/tests/tests/text/src/android/text/method/cts/TimeKeyListenerTest.java
index 7f2f6ef..278af6b 100644
--- a/tests/tests/text/src/android/text/method/cts/TimeKeyListenerTest.java
+++ b/tests/tests/text/src/android/text/method/cts/TimeKeyListenerTest.java
@@ -118,15 +118,15 @@
         assertEquals("", mTextView.getText().toString());
 
         // press '1' key.
-        sendKeys(KeyEvent.KEYCODE_1);
+        mInstrumentation.sendStringSync("1");
         assertEquals("1", mTextView.getText().toString());
 
         // press '2' key.
-        sendKeys(KeyEvent.KEYCODE_2);
+        mInstrumentation.sendStringSync("2");
         assertEquals("12", mTextView.getText().toString());
 
         // press 'a' key.
-        sendKeys(KeyEvent.KEYCODE_A);
+        mInstrumentation.sendStringSync("a");
         assertEquals("12a", mTextView.getText().toString());
 
         // press an unaccepted key if it exists.
@@ -137,7 +137,7 @@
         }
 
         // press 'm' key.
-        sendKeys(KeyEvent.KEYCODE_M);
+        mInstrumentation.sendStringSync("m");
         assertEquals("12am", mTextView.getText().toString());
 
         mActivity.runOnUiThread(new Runnable() {
@@ -149,7 +149,7 @@
         mInstrumentation.waitForIdleSync();
 
         // press '1' key.
-        sendKeys(KeyEvent.KEYCODE_1);
+        mInstrumentation.sendStringSync("1");
         assertEquals("12am", mTextView.getText().toString());
     }
 
diff --git a/tests/tests/view/src/android/view/cts/AccessibilityEventTest.java b/tests/tests/view/src/android/view/cts/AccessibilityEventTest.java
new file mode 100644
index 0000000..731784a
--- /dev/null
+++ b/tests/tests/view/src/android/view/cts/AccessibilityEventTest.java
@@ -0,0 +1,210 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.view.cts;
+
+import android.os.Message;
+import android.os.Parcel;
+import android.test.suitebuilder.annotation.MediumTest;
+import android.view.accessibility.AccessibilityEvent;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+/**
+ * Class for testing {@link AccessibilityEvent}.
+ */
+public class AccessibilityEventTest extends TestCase {
+
+    /** The number of properties of the {@link AccessibilityEvent} class. */
+    private static final int NON_STATIC_FIELD_COUNT = 16;
+
+    @MediumTest
+    public void testMarshalling() throws Exception {
+        // no new fields, so we are testing marshaling of all such
+        assertNoNewNonStaticFieldsAdded();
+
+        // fully populate the event to marshal
+        AccessibilityEvent sentEvent = AccessibilityEvent.obtain();
+        fullyPopulateSentAccessibilityEvent(sentEvent);
+
+        // marshal and unmarshal the event
+        Parcel parcel = Parcel.obtain();
+        sentEvent.writeToParcel(parcel, 0);
+        parcel.setDataPosition(0);
+        AccessibilityEvent receivedEvent = AccessibilityEvent.CREATOR.createFromParcel(parcel);
+
+        // make sure all fields properly marshaled
+        assertEqualsAccessiblityEvent(sentEvent, receivedEvent);
+    }
+
+    /**
+     * Tests if {@link AccessibilityEvent} are properly reused.
+     */
+    @MediumTest
+    public void testReuse() {
+        AccessibilityEvent firstEvent = AccessibilityEvent.obtain();
+        firstEvent.recycle();
+        AccessibilityEvent secondEvent = AccessibilityEvent.obtain();
+        assertSame("AccessibilityEvent not properly reused", firstEvent, secondEvent);
+    }
+
+    /**
+     * Tests if {@link AccessibilityEvent} are properly recycled.
+     */
+    @MediumTest
+    public void testRecycle() {
+        // obtain and populate an event
+        AccessibilityEvent populatedEvent = AccessibilityEvent.obtain();
+        fullyPopulateSentAccessibilityEvent(populatedEvent);
+
+        // recycle and obtain the same recycled instance
+        populatedEvent.recycle();
+        AccessibilityEvent recycledEvent = AccessibilityEvent.obtain();
+
+        // check expectations
+        assertAccessibilityEventCleared(recycledEvent);
+    }
+
+    /**
+     * Asserts that no new fields have been added, so we are testing marshaling
+     * of all such.
+     */
+    private void assertNoNewNonStaticFieldsAdded() {
+        int nonStaticFieldCount = 0;
+
+        for (Field field : AccessibilityEvent.class.getDeclaredFields()) {
+            if ((field.getModifiers() & Modifier.STATIC) == 0) {
+                nonStaticFieldCount++;
+            }
+        }
+
+        String message = "New fields have been added, so add code to test marchalling them.";
+        assertEquals(message, NON_STATIC_FIELD_COUNT, nonStaticFieldCount);
+    }
+
+    /**
+     * Fully populates the {@link AccessibilityEvent} to marshal.
+     *
+     * @param sentEvent The event to populate.
+     */
+    private void fullyPopulateSentAccessibilityEvent(AccessibilityEvent sentEvent) {
+        sentEvent.setAddedCount(1);
+        sentEvent.setBeforeText("BeforeText");
+        sentEvent.setChecked(true);
+        sentEvent.setClassName("foo.bar.baz.Class");
+        sentEvent.setContentDescription("ContentDescription");
+        sentEvent.setCurrentItemIndex(1);
+        sentEvent.setEnabled(true);
+        sentEvent.setEventType(AccessibilityEvent.TYPE_VIEW_FOCUSED);
+        sentEvent.setEventTime(1000);
+        sentEvent.setFromIndex(1);
+        sentEvent.setFullScreen(true);
+        sentEvent.setItemCount(1);
+        sentEvent.setPackageName("foo.bar.baz");
+        sentEvent.setParcelableData(Message.obtain(null, 1, 2, 3));
+        sentEvent.setPassword(true);
+        sentEvent.setRemovedCount(1);
+        sentEvent.getText().add("Foo");
+    }
+
+    /**
+     * Compares all properties of the <code>expectedEvent</code> and the
+     * <code>receviedEvent</code> to verify that the received event is the one
+     * that is expected.
+     */
+    public static void assertEqualsAccessiblityEvent(AccessibilityEvent expectedEvent,
+            AccessibilityEvent receivedEvent) {
+        assertEquals("addedCount has incorrect value", expectedEvent.getAddedCount(), receivedEvent
+                .getAddedCount());
+        assertEquals("beforeText has incorrect value", expectedEvent.getBeforeText(), receivedEvent
+                .getBeforeText());
+        assertEquals("checked has incorrect value", expectedEvent.isChecked(), receivedEvent
+                .isChecked());
+        assertEquals("className has incorrect value", expectedEvent.getClassName(), receivedEvent
+                .getClassName());
+        assertEquals("contentDescription has incorrect value", expectedEvent
+                .getContentDescription(), receivedEvent.getContentDescription());
+        assertEquals("currentItemIndex has incorrect value", expectedEvent.getCurrentItemIndex(),
+                receivedEvent.getCurrentItemIndex());
+        assertEquals("enabled has incorrect value", expectedEvent.isEnabled(), receivedEvent
+                .isEnabled());
+        assertEquals("eventType has incorrect value", expectedEvent.getEventType(), receivedEvent
+                .getEventType());
+        assertEquals("fromIndex has incorrect value", expectedEvent.getFromIndex(), receivedEvent
+                .getFromIndex());
+        assertEquals("fullScreen has incorrect value", expectedEvent.isFullScreen(), receivedEvent
+                .isFullScreen());
+        assertEquals("itemCount has incorrect value", expectedEvent.getItemCount(), receivedEvent
+                .getItemCount());
+        assertEquals("password has incorrect value", expectedEvent.isPassword(), receivedEvent
+                .isPassword());
+        assertEquals("removedCount has incorrect value", expectedEvent.getRemovedCount(),
+                receivedEvent.getRemovedCount());
+        assertEqualsText(expectedEvent, receivedEvent);
+    }
+
+    /**
+     * Compares the text of the <code>expectedEvent</code> and
+     * <code>receivedEvent</code> by comparing the string representation of the
+     * corresponding {@link CharSequence}s.
+     */
+    public static void assertEqualsText(AccessibilityEvent expectedEvent,
+            AccessibilityEvent receivedEvent) {
+        String message = "text has incorrect value";
+        List<CharSequence> expectedText = expectedEvent.getText();
+        List<CharSequence> receivedText = receivedEvent.getText();
+
+        TestCase.assertEquals(message, expectedText.size(), receivedText.size());
+
+        Iterator<CharSequence> expectedTextIterator = expectedText.iterator();
+        Iterator<CharSequence> receivedTextIterator = receivedText.iterator();
+
+        for (int i = 0; i < expectedText.size(); i++) {
+            // compare the string representation
+            TestCase.assertEquals(message, expectedTextIterator.next().toString(),
+                    receivedTextIterator.next().toString());
+        }
+    }
+
+    /**
+     * Asserts that an {@link AccessibilityEvent} is cleared.
+     *
+     * @param event The event to check.
+     */
+    public static void assertAccessibilityEventCleared(AccessibilityEvent event) {
+        TestCase.assertEquals("addedCount not properly recycled", 0, event.getAddedCount());
+        TestCase.assertNull("beforeText not properly recycled", event.getBeforeText());
+        TestCase.assertNull("className not properly recycled", event.getClassName());
+        TestCase.assertNull("contentDescription not properly recycled", event
+                .getContentDescription());
+        TestCase.assertEquals("currentItemIndex not properly recycled", -1, event
+                .getCurrentItemIndex());
+        TestCase.assertEquals("eventTime not properly recycled", 0, event.getEventTime());
+        TestCase.assertEquals("eventType not properly recycled", 0, event.getEventType());
+        TestCase.assertEquals("fromIndex not properly recycled", 0, event.getFromIndex());
+        TestCase.assertEquals("itemCount not properly recycled", 0, event.getItemCount());
+        TestCase.assertNull("packageName not properly recycled", event.getPackageName());
+        // This will fail and is fixed in Gingerbread Bug: 2593810
+        // TestCase.assertNull("parcelableData not properly recycled", event.getParcelableData());
+        TestCase.assertEquals("removedCount not properly recycled", 0, event.getRemovedCount());
+        TestCase.assertTrue("text not properly recycled", event.getText().isEmpty());
+    }
+}
diff --git a/tests/tests/view/src/android/view/cts/KeyCharacterMapTest.java b/tests/tests/view/src/android/view/cts/KeyCharacterMapTest.java
index a96f384..4ab38df 100644
--- a/tests/tests/view/src/android/view/cts/KeyCharacterMapTest.java
+++ b/tests/tests/view/src/android/view/cts/KeyCharacterMapTest.java
@@ -21,6 +21,7 @@
 import android.view.KeyCharacterMap;
 import android.view.KeyEvent;
 import android.view.KeyCharacterMap.KeyData;
+
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass;
 import dalvik.annotation.TestTargetNew;
@@ -113,7 +114,6 @@
         assertFalse(mKeyCharacterMap.isPrintingKey(KeyEvent.KEYCODE_TAB));
         assertFalse(mKeyCharacterMap.isPrintingKey(KeyEvent.KEYCODE_SPACE));
         assertFalse(mKeyCharacterMap.isPrintingKey(KeyEvent.KEYCODE_NUM));
-        assertFalse(mKeyCharacterMap.isPrintingKey(KeyEvent.KEYCODE_SYM));
         assertFalse(mKeyCharacterMap.isPrintingKey(KeyEvent.KEYCODE_EXPLORER));
         assertFalse(mKeyCharacterMap.isPrintingKey(KeyEvent.KEYCODE_ENVELOPE));
         assertFalse(mKeyCharacterMap.isPrintingKey(KeyEvent.KEYCODE_ENTER));
@@ -182,9 +182,17 @@
             fail("should throw exception");
         } catch (Exception e) {
         }
-        assertEquals('\0', mKeyCharacterMap.getMatch(KeyEvent.KEYCODE_E, chars));
-        assertEquals('A', mKeyCharacterMap.getMatch(KeyEvent.KEYCODE_A, chars));
-        assertEquals('B', mKeyCharacterMap.getMatch(KeyEvent.KEYCODE_B, chars));
+
+        assertEquals('\0', mKeyCharacterMap.getMatch(getCharacterKeyCode('E'), chars));
+        assertEquals('A', mKeyCharacterMap.getMatch(getCharacterKeyCode('A'), chars));
+        assertEquals('B', mKeyCharacterMap.getMatch(getCharacterKeyCode('B'), chars));
+    }
+
+    private int getCharacterKeyCode(char oneChar) {
+        // Lowercase the character to avoid getting modifiers in the KeyEvent array.
+        char[] chars = new char[] {Character.toLowerCase(oneChar)};
+        KeyEvent[] events = mKeyCharacterMap.getEvents(chars);
+        return events[0].getKeyCode();
     }
 
     @TestTargetNew(
@@ -200,9 +208,9 @@
         }
         assertEquals('\0', mKeyCharacterMap.getMatch(1000, chars, 2));
         assertEquals('\0', mKeyCharacterMap.getMatch(10000, chars, 2));
-        assertEquals('\0', mKeyCharacterMap.getMatch(KeyEvent.KEYCODE_E, chars, 0));
-        assertEquals('A', mKeyCharacterMap.getMatch(KeyEvent.KEYCODE_A, chars, 0));
-        assertEquals('B', mKeyCharacterMap.getMatch(KeyEvent.KEYCODE_B, chars, 0));
+        assertEquals('\0', mKeyCharacterMap.getMatch(getCharacterKeyCode('E'), chars));
+        assertEquals('A', mKeyCharacterMap.getMatch(getCharacterKeyCode('A'), chars));
+        assertEquals('B', mKeyCharacterMap.getMatch(getCharacterKeyCode('B'), chars));
     }
 
     @TestTargetNew(
diff --git a/tests/tests/view/src/android/view/cts/ViewTest.java b/tests/tests/view/src/android/view/cts/ViewTest.java
index 462f164..77624e8 100644
--- a/tests/tests/view/src/android/view/cts/ViewTest.java
+++ b/tests/tests/view/src/android/view/cts/ViewTest.java
@@ -782,7 +782,12 @@
         getInstrumentation().waitForIdleSync();
         assertFalse(view.getGlobalVisibleRect(rect, point));
 
-        final LinearLayout.LayoutParams layoutParams3 = new LinearLayout.LayoutParams(200, 300);
+        Display display = getActivity().getWindowManager().getDefaultDisplay();
+        int halfWidth = display.getWidth() / 2;
+        int halfHeight = display.getHeight() /2;
+
+        final LinearLayout.LayoutParams layoutParams3 =
+                new LinearLayout.LayoutParams(halfWidth, halfHeight);
         runTestOnUiThread(new Runnable() {
             public void run() {
                 view.setLayoutParams(layoutParams3);
@@ -792,8 +797,8 @@
         assertTrue(view.getGlobalVisibleRect(rect, point));
         assertEquals(rcParent.left, rect.left);
         assertEquals(rcParent.top, rect.top);
-        assertEquals(rect.left + 200, rect.right);
-        assertEquals(rect.top + 300, rect.bottom);
+        assertEquals(rect.left + halfWidth, rect.right);
+        assertEquals(rect.top + halfHeight, rect.bottom);
         assertEquals(ptParent.x, point.x);
         assertEquals(ptParent.y, point.y);
     }
@@ -836,7 +841,12 @@
         getInstrumentation().waitForIdleSync();
         assertFalse(view.getGlobalVisibleRect(rect));
 
-        final LinearLayout.LayoutParams layoutParams3 = new LinearLayout.LayoutParams(200, 300);
+        Display display = getActivity().getWindowManager().getDefaultDisplay();
+        int halfWidth = display.getWidth() / 2;
+        int halfHeight = display.getHeight() /2;
+
+        final LinearLayout.LayoutParams layoutParams3 =
+                new LinearLayout.LayoutParams(halfWidth, halfHeight);
         runTestOnUiThread(new Runnable() {
             public void run() {
                 view.setLayoutParams(layoutParams3);
@@ -846,8 +856,8 @@
         assertTrue(view.getGlobalVisibleRect(rect));
         assertEquals(rcParent.left, rect.left);
         assertEquals(rcParent.top, rect.top);
-        assertEquals(rect.left + 200, rect.right);
-        assertEquals(rect.top + 300, rect.bottom);
+        assertEquals(rect.left + halfWidth, rect.right);
+        assertEquals(rect.top + halfHeight, rect.bottom);
     }
 
     @TestTargets({
@@ -2893,9 +2903,6 @@
         method = "getLocalVisibleRect",
         args = {android.graphics.Rect.class}
     )
-    @ToBeFixed(bug = "1695243", explanation =
-            "the javadoc for getLocalVisibleRect() is incomplete." +
-            "1. not clear what is supposed to happen if the input Rect is null.")
     public void testGetLocalVisibleRect() throws Throwable {
         final View view = mActivity.findViewById(R.id.mock_view);
         Rect rect = new Rect();
@@ -2924,7 +2931,12 @@
         getInstrumentation().waitForIdleSync();
         assertFalse(view.getLocalVisibleRect(rect));
 
-        final LinearLayout.LayoutParams layoutParams3 = new LinearLayout.LayoutParams(200, 300);
+        Display display = getActivity().getWindowManager().getDefaultDisplay();
+        int halfWidth = display.getWidth() / 2;
+        int halfHeight = display.getHeight() /2;
+
+        final LinearLayout.LayoutParams layoutParams3 =
+                new LinearLayout.LayoutParams(halfWidth, halfHeight);
         runTestOnUiThread(new Runnable() {
             public void run() {
                 view.setLayoutParams(layoutParams3);
@@ -2935,8 +2947,8 @@
         assertTrue(view.getLocalVisibleRect(rect));
         assertEquals(20, rect.left);
         assertEquals(-30, rect.top);
-        assertEquals(200 + 20, rect.right);
-        assertEquals(300 - 30, rect.bottom);
+        assertEquals(halfWidth + 20, rect.right);
+        assertEquals(halfHeight - 30, rect.bottom);
 
         try {
             view.getLocalVisibleRect(null);
@@ -4804,10 +4816,10 @@
         public String tag;
         public View firstChild;
     }
-    
+
     private static final class MockRunnable implements Runnable {
         public boolean hasRun = false;
-        
+
         public void run() {
             hasRun = true;
         }
diff --git a/tests/tests/view/src/android/view/cts/View_AnimationTest.java b/tests/tests/view/src/android/view/cts/View_AnimationTest.java
index 06763f5..d071781 100644
--- a/tests/tests/view/src/android/view/cts/View_AnimationTest.java
+++ b/tests/tests/view/src/android/view/cts/View_AnimationTest.java
@@ -65,7 +65,7 @@
         )
     })
     public void testAnimation() throws Throwable {
-        final View view = mActivity.findViewById(R.id.fit_windows);
+        final View view = mActivity.findViewById(R.id.mock_view);
         // set null animation
         view.setAnimation(null);
         assertNull(view.getAnimation());
@@ -89,7 +89,7 @@
     })
     @ToBeFixed(bug = "1695243", explanation = "Android API javadocs are incomplete")
     public void testStartAnimation() throws Throwable {
-        final View view = mActivity.findViewById(R.id.fit_windows);
+        final View view = mActivity.findViewById(R.id.mock_view);
         // start null animation
         try {
             view.startAnimation(null);
@@ -120,7 +120,7 @@
         )
     })
     public void testClearBeforeAnimation() throws Throwable {
-        final View view = mActivity.findViewById(R.id.fit_windows);
+        final View view = mActivity.findViewById(R.id.mock_view);
         assertFalse(mAnimation.hasStarted());
 
         view.setAnimation(mAnimation);
@@ -147,7 +147,7 @@
         )
     })
     public void testClearDuringAnimation() throws Throwable {
-        final View view = mActivity.findViewById(R.id.fit_windows);
+        final View view = mActivity.findViewById(R.id.mock_view);
         runTestOnUiThread(new Runnable() {
             public void run() {
                 view.startAnimation(mAnimation);
diff --git a/tests/tests/view/src/android/view/inputmethod/cts/BaseInputConnectionTest.java b/tests/tests/view/src/android/view/inputmethod/cts/BaseInputConnectionTest.java
new file mode 100644
index 0000000..8540a7c
--- /dev/null
+++ b/tests/tests/view/src/android/view/inputmethod/cts/BaseInputConnectionTest.java
@@ -0,0 +1,352 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.view.inputmethod.cts;
+
+import com.android.cts.stub.R;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+import android.app.Instrumentation;
+import android.content.Context;
+import android.os.Bundle;
+import android.test.ActivityInstrumentationTestCase2;
+import android.text.Editable;
+import android.text.Spannable;
+import android.text.SpannableString;
+import android.text.TextUtils;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.Window;
+import android.view.animation.cts.DelayedCheck;
+import android.view.inputmethod.BaseInputConnection;
+import android.view.inputmethod.CompletionInfo;
+import android.view.inputmethod.ExtractedTextRequest;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
+
+@TestTargetClass(BaseInputConnection.class)
+public class BaseInputConnectionTest extends
+        ActivityInstrumentationTestCase2<InputMethodStubActivity> {
+
+    private InputMethodStubActivity mActivity;
+    private Window mWindow;
+    private EditText mView;
+    private BaseInputConnection mConnection;
+    private Instrumentation mInstrumentation;
+
+    public BaseInputConnectionTest() {
+        super("com.android.cts.stub", InputMethodStubActivity.class);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mInstrumentation = getInstrumentation();
+        mActivity = getActivity();
+        mWindow = mActivity.getWindow();
+        mView = (EditText) mWindow.findViewById(R.id.entry);
+        mConnection = new BaseInputConnection(mView, true);
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "beginBatchEdit",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "commitCompletion",
+            args = {CompletionInfo.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "endBatchEdit",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getExtractedText",
+            args = {ExtractedTextRequest.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "performContextMenuAction",
+            args = {int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "performEditorAction",
+            args = {int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "performPrivateCommand",
+            args = {String.class, Bundle.class}
+        )
+    })
+    public void testDefaultMethods() {
+        // These methods are default to return fixed result.
+
+        assertFalse(mConnection.beginBatchEdit());
+        assertFalse(mConnection.endBatchEdit());
+
+        // only fit for test default implementation of commitCompletion.
+        int completionId = 1;
+        String completionString = "commitCompletion test";
+        assertFalse(mConnection.commitCompletion(new CompletionInfo(completionId,
+                0, completionString)));
+
+        assertNull(mConnection.getExtractedText(new ExtractedTextRequest(), 0));
+
+        // only fit for test default implementation of performEditorAction.
+        int actionCode = 1;
+        int actionId = 2;
+        String action = "android.intent.action.MAIN";
+        assertTrue(mConnection.performEditorAction(actionCode));
+        assertFalse(mConnection.performContextMenuAction(actionId));
+        assertFalse(mConnection.performPrivateCommand(action, new Bundle()));
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.NOT_FEASIBLE,
+            method = "getComposingSpanEnd",
+            args = {Spannable.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.NOT_FEASIBLE,
+            method = "getComposingSpanStart",
+            args = {Spannable.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.NOT_FEASIBLE,
+            method = "removeComposingSpans",
+            args = {Spannable.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.NOT_FEASIBLE,
+            method = "setComposingSpans",
+            args = {Spannable.class}
+        )
+    })
+    public void testOpComposingSpans() {
+        Spannable text = new SpannableString("Test ComposingSpans");
+        BaseInputConnection.setComposingSpans(text);
+        assertTrue(BaseInputConnection.getComposingSpanStart(text) > -1);
+        assertTrue(BaseInputConnection.getComposingSpanEnd(text) > -1);
+        BaseInputConnection.removeComposingSpans(text);
+        assertTrue(BaseInputConnection.getComposingSpanStart(text) == -1);
+        assertTrue(BaseInputConnection.getComposingSpanEnd(text) == -1);
+    }
+
+    /**
+     * getEditable: Return the target of edit operations. The default implementation
+     *              returns its own fake editable that is just used for composing text.
+     * clearMetaKeyStates: Default implementation uses
+     *              MetaKeyKeyListener#clearMetaKeyState(long, int) to clear the state.
+     *              BugId:1738511
+     * commitText: 1. Default implementation replaces any existing composing text with the given
+     *                text.
+     *             2. In addition, only if dummy mode, a key event is sent for the new text and the
+     *                current editable buffer cleared.
+     * deleteSurroundingText: The default implementation performs the deletion around the current
+     *              selection position of the editable text.
+     * getCursorCapsMode: 1. The default implementation uses TextUtils.getCapsMode to get the
+     *                  cursor caps mode for the current selection position in the editable text.
+     *                  TextUtils.getCapsMode is tested fully in TextUtilsTest#testGetCapsMode.
+     *                    2. In dummy mode in which case 0 is always returned.
+     * getTextBeforeCursor, getTextAfterCursor: The default implementation performs the deletion
+     *                          around the current selection position of the editable text.
+     * setSelection: changes the selection position in the current editable text.
+     */
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "BaseInputConnection",
+            args = {View.class, boolean.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "clearMetaKeyStates",
+            args = {int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "commitText",
+            args = {CharSequence.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "deleteSurroundingText",
+            args = {int.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getCursorCapsMode",
+            args = {int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getEditable",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "setSelection",
+            args = {int.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getTextAfterCursor",
+            args = {int.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getTextBeforeCursor",
+            args = {int.class, int.class}
+        )
+    })
+    public void testOpTextMethods() {
+        // return is an default Editable instance with empty source
+        final Editable text = mConnection.getEditable();
+        assertNotNull(text);
+        assertEquals(0, text.length());
+
+        // Test commitText, not dummy mode
+        CharSequence str = "TestCommit ";
+        Editable inputText = Editable.Factory.getInstance().newEditable(str);
+        mConnection.commitText(inputText, inputText.length());
+        final Editable text2 = mConnection.getEditable();
+        int strLength = str.length();
+        assertEquals(strLength, text2.length());
+        assertEquals(str.toString(), text2.toString());
+        assertEquals(TextUtils.CAP_MODE_WORDS,
+                mConnection.getCursorCapsMode(TextUtils.CAP_MODE_WORDS));
+        int offLength = 3;
+        CharSequence expected = str.subSequence(strLength - offLength, strLength);
+        assertEquals(expected.toString(), mConnection.getTextBeforeCursor(offLength,
+                BaseInputConnection.GET_TEXT_WITH_STYLES).toString());
+        mConnection.setSelection(0, 0);
+        expected = str.subSequence(0, offLength);
+        assertEquals(expected.toString(), mConnection.getTextAfterCursor(offLength,
+                BaseInputConnection.GET_TEXT_WITH_STYLES).toString());
+
+        // dummy mode
+        BaseInputConnection dummyConnection = new BaseInputConnection(mView, false);
+        dummyConnection.commitText(inputText, inputText.length());
+        new DelayedCheck() {
+            @Override
+            protected boolean check() {
+                return text2.toString().equals(mView.getText().toString());
+            }
+        }.run();
+        assertEquals(0, dummyConnection.getCursorCapsMode(TextUtils.CAP_MODE_WORDS));
+
+        // Test deleteSurroudingText
+        int end = text2.length();
+        mConnection.setSelection(end, end);
+        // Delete the ending space
+        assertTrue(mConnection.deleteSurroundingText(1, 2));
+        Editable text3 = mConnection.getEditable();
+        assertEquals(strLength - 1, text3.length());
+        String expectedDelString = "TestCommit";
+        assertEquals(expectedDelString, text3.toString());
+    }
+
+    /**
+     * finishComposingText: 1. The default implementation removes the composing state from the
+     *                         current editable text.
+     *                      2. In addition, only if dummy mode, a key event is sent for the new
+     *                         text and the current editable buffer cleared.
+     * setComposingText: The default implementation places the given text into the editable,
+     *                  replacing any existing composing text
+     */
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "finishComposingText",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "setComposingText",
+            args = {CharSequence.class, int.class}
+        )
+    })
+    public void testFinishComposingText() {
+        CharSequence str = "TestFinish";
+        Editable inputText = Editable.Factory.getInstance().newEditable(str);
+        mConnection.commitText(inputText, inputText.length());
+        final Editable text = mConnection.getEditable();
+        // Test finishComposingText, not dummy mode
+        BaseInputConnection.setComposingSpans(text);
+        assertTrue(BaseInputConnection.getComposingSpanStart(text) > -1);
+        assertTrue(BaseInputConnection.getComposingSpanEnd(text) > -1);
+        mConnection.finishComposingText();
+        assertTrue(BaseInputConnection.getComposingSpanStart(text) == -1);
+        assertTrue(BaseInputConnection.getComposingSpanEnd(text) == -1);
+        // dummy mode
+        BaseInputConnection dummyConnection = new BaseInputConnection(mView, false);
+        dummyConnection.setComposingText(str, str.length());
+        dummyConnection.finishComposingText();
+        new DelayedCheck() {
+            @Override
+            protected boolean check() {
+                return text.toString().equals(mView.getText().toString());
+            }
+        }.run();
+    }
+
+    /**
+     * Provides standard implementation for sending a key event to the window
+     * attached to the input connection's view
+     */
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "sendKeyEvent",
+        args = {KeyEvent.class}
+    )
+    public void testSendKeyEvent() {
+        mConnection.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_Q));
+        new DelayedCheck() {
+            @Override
+            protected boolean check() {
+                return "q".equals(mView.getText().toString());
+            }
+        }.run();
+    }
+
+    /**
+     * Updates InputMethodManager with the current fullscreen mode.
+     */
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "reportFullscreenMode",
+        args = {boolean.class}
+    )
+    public void testReportFullscreenMode() {
+        InputMethodManager imManager = (InputMethodManager) mInstrumentation.getTargetContext()
+                .getSystemService(Context.INPUT_METHOD_SERVICE);
+        assertFalse(imManager.isFullscreenMode());
+        mConnection.reportFullscreenMode(true);
+        assertTrue(imManager.isFullscreenMode());
+    }
+}
diff --git a/tests/tests/view/src/android/view/inputmethod/cts/CompletionInfoTest.java b/tests/tests/view/src/android/view/inputmethod/cts/CompletionInfoTest.java
new file mode 100644
index 0000000..ba4358f
--- /dev/null
+++ b/tests/tests/view/src/android/view/inputmethod/cts/CompletionInfoTest.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.view.inputmethod.cts;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+import android.os.Parcel;
+import android.test.AndroidTestCase;
+import android.view.inputmethod.CompletionInfo;
+
+@TestTargetClass(CompletionInfo.class)
+public class CompletionInfoTest extends AndroidTestCase {
+    private static final int ID = 1;
+    private static final int POSITION = 1;
+    private static final String TEXT = "CompletionInfoText";
+    private static final String LABEL = "CompletionInfoLabel";
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "describeContents",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "writeToParcel",
+            args = {Parcel.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "CompletionInfo",
+            args = {long.class, int.class, CharSequence.class, CharSequence.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "CompletionInfo",
+            args = {long.class, int.class, CharSequence.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getId",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getPosition",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getText",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getLabel",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "toString",
+            args = {}
+        )
+    })
+    public void testCompletionInfo() {
+        new CompletionInfo(ID, POSITION, TEXT);
+        CompletionInfo info = new CompletionInfo(ID, POSITION, TEXT, LABEL);
+        assertCompletionInfo(info);
+
+        assertEquals(0, info.describeContents());
+        assertNotNull(info.toString());
+
+        Parcel p = Parcel.obtain();
+        info.writeToParcel(p, 0);
+        p.setDataPosition(0);
+        CompletionInfo targetInfo = CompletionInfo.CREATOR.createFromParcel(p);
+        p.recycle();
+        assertCompletionInfo(targetInfo);
+    }
+
+    private void assertCompletionInfo(CompletionInfo info) {
+        assertEquals(ID, info.getId());
+        assertEquals(POSITION, info.getPosition());
+        assertEquals(TEXT, info.getText().toString());
+        assertEquals(LABEL, info.getLabel().toString());
+    }
+}
diff --git a/tests/tests/view/src/android/view/inputmethod/cts/EditorInfoTest.java b/tests/tests/view/src/android/view/inputmethod/cts/EditorInfoTest.java
new file mode 100644
index 0000000..cd28b3f
--- /dev/null
+++ b/tests/tests/view/src/android/view/inputmethod/cts/EditorInfoTest.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.view.inputmethod.cts;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+import android.os.Bundle;
+import android.os.Parcel;
+import android.test.AndroidTestCase;
+import android.text.TextUtils;
+import android.util.Printer;
+import android.view.inputmethod.EditorInfo;
+
+
+@TestTargetClass(EditorInfo.class)
+public class EditorInfoTest extends AndroidTestCase {
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "describeContents",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "writeToParcel",
+            args = {Parcel.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "dump",
+            args = {Printer.class, String.class}
+        )
+    })
+    public void testEditorInfo() {
+        EditorInfo info = new EditorInfo();
+
+        info.actionId = 1;
+        info.actionLabel = "actionLabel";
+        info.fieldId = 2;
+        info.fieldName = "fieldName";
+        info.hintText = "hintText";
+        info.imeOptions = EditorInfo.IME_FLAG_NO_ENTER_ACTION;
+        info.initialCapsMode = TextUtils.CAP_MODE_CHARACTERS;
+        info.initialSelEnd = 10;
+        info.initialSelStart = 0;
+        info.inputType = EditorInfo.TYPE_MASK_CLASS;
+        info.label = "label";
+        info.packageName = "com.android.cts.stub";
+        info.privateImeOptions = "privateIme";
+        Bundle b = new Bundle();
+        String key = "bundleKey";
+        String value = "bundleValue";
+        b.putString(key, value);
+        info.extras = b;
+
+        assertEquals(0, info.describeContents());
+
+        Parcel p = Parcel.obtain();
+        info.writeToParcel(p, 0);
+        p.setDataPosition(0);
+        EditorInfo targetInfo = EditorInfo.CREATOR.createFromParcel(p);
+        p.recycle();
+        assertEquals(info.actionId, targetInfo.actionId);
+        assertEquals(info.fieldId, targetInfo.fieldId);
+        assertEquals(info.fieldName, targetInfo.fieldName);
+        assertEquals(info.imeOptions, targetInfo.imeOptions);
+        assertEquals(info.initialCapsMode, targetInfo.initialCapsMode);
+        assertEquals(info.initialSelEnd, targetInfo.initialSelEnd);
+        assertEquals(info.initialSelStart, targetInfo.initialSelStart);
+        assertEquals(info.inputType, targetInfo.inputType);
+        assertEquals(info.packageName, targetInfo.packageName);
+        assertEquals(info.privateImeOptions, targetInfo.privateImeOptions);
+        assertEquals(info.hintText.toString(), targetInfo.hintText.toString());
+        assertEquals(info.actionLabel.toString(), targetInfo.actionLabel.toString());
+        assertEquals(info.label.toString(), targetInfo.label.toString());
+        assertEquals(info.extras.getString(key), targetInfo.extras.getString(key));
+
+        TestPrinter printer = new TestPrinter();
+        String prefix = "TestEditorInfo";
+        info.dump(printer, prefix);
+        assertTrue(printer.isPrintlnCalled);
+    }
+
+    private class TestPrinter implements Printer {
+        public boolean isPrintlnCalled;
+        public void println(String x) {
+            isPrintlnCalled = true;
+        }
+    }
+}
diff --git a/tests/tests/view/src/android/view/inputmethod/cts/ExtractedTextRequestTest.java b/tests/tests/view/src/android/view/inputmethod/cts/ExtractedTextRequestTest.java
new file mode 100644
index 0000000..0f0a987
--- /dev/null
+++ b/tests/tests/view/src/android/view/inputmethod/cts/ExtractedTextRequestTest.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.view.inputmethod.cts;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+import android.os.Parcel;
+import android.test.AndroidTestCase;
+import android.view.inputmethod.ExtractedTextRequest;
+
+@TestTargetClass(ExtractedTextRequest.class)
+public class ExtractedTextRequestTest extends AndroidTestCase {
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "describeContents",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "writeToParcel",
+            args = {Parcel.class, int.class}
+        )
+    })
+    public void testExtractedTextRequest() {
+        ExtractedTextRequest request = new ExtractedTextRequest();
+        request.flags = 1;
+        request.hintMaxChars = 100;
+        request.hintMaxLines = 10;
+        request.token = 2;
+
+        assertEquals(0, request.describeContents());
+
+        Parcel p = Parcel.obtain();
+        request.writeToParcel(p, 0);
+        p.setDataPosition(0);
+        ExtractedTextRequest target = ExtractedTextRequest.CREATOR.createFromParcel(p);
+        p.recycle();
+        assertEquals(request.flags, target.flags);
+        assertEquals(request.hintMaxChars, request.hintMaxChars);
+        assertEquals(request.hintMaxLines, target.hintMaxLines);
+        assertEquals(request.token, target.token);
+    }
+}
diff --git a/tests/tests/view/src/android/view/inputmethod/cts/ExtractedTextTest.java b/tests/tests/view/src/android/view/inputmethod/cts/ExtractedTextTest.java
new file mode 100644
index 0000000..c115902
--- /dev/null
+++ b/tests/tests/view/src/android/view/inputmethod/cts/ExtractedTextTest.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.view.inputmethod.cts;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+import android.os.Parcel;
+import android.test.AndroidTestCase;
+import android.view.inputmethod.ExtractedText;
+
+@TestTargetClass(ExtractedText.class)
+public class ExtractedTextTest extends AndroidTestCase {
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "describeContents",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "writeToParcel",
+            args = {android.os.Parcel.class, int.class}
+        )
+    })
+    public void testWriteToParcel() {
+
+        ExtractedText extractedText = new ExtractedText();
+        extractedText.flags = 1;
+        extractedText.selectionEnd = 11;
+        extractedText.selectionStart = 2;
+        extractedText.startOffset = 1;
+        CharSequence text = "test";
+        extractedText.text = text;
+        Parcel p = Parcel.obtain();
+        extractedText.writeToParcel(p, 0);
+        p.setDataPosition(0);
+        ExtractedText target = ExtractedText.CREATOR.createFromParcel(p);
+        assertEquals(extractedText.flags, target.flags);
+        assertEquals(extractedText.selectionEnd, target.selectionEnd);
+        assertEquals(extractedText.selectionStart, target.selectionStart);
+        assertEquals(extractedText.startOffset, target.startOffset);
+        assertEquals(extractedText.partialStartOffset, target.partialStartOffset);
+        assertEquals(extractedText.partialEndOffset, target.partialEndOffset);
+        assertEquals(extractedText.text.toString(), target.text.toString());
+
+        assertEquals(0, extractedText.describeContents());
+    }
+}
diff --git a/tests/tests/view/src/android/view/inputmethod/cts/InputBindingTest.java b/tests/tests/view/src/android/view/inputmethod/cts/InputBindingTest.java
new file mode 100644
index 0000000..8e0102e
--- /dev/null
+++ b/tests/tests/view/src/android/view/inputmethod/cts/InputBindingTest.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.view.inputmethod.cts;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+import android.os.Binder;
+import android.os.Parcel;
+import android.test.AndroidTestCase;
+import android.view.View;
+import android.view.inputmethod.BaseInputConnection;
+import android.view.inputmethod.InputBinding;
+
+@TestTargetClass(InputBinding.class)
+public class InputBindingTest extends AndroidTestCase {
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "describeContents",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getConnection",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getConnectionToken",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getPid",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getUid",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "InputBinding",
+            args = {android.view.inputmethod.InputConnection.class,
+                    android.view.inputmethod.InputBinding.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "InputBinding",
+            args = {android.view.inputmethod.InputConnection.class, android.os.IBinder.class,
+                    int.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "toString",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "writeToParcel",
+            args = {android.os.Parcel.class, int.class}
+        )
+    })
+    public void testInputBinding() {
+        View view = new View(getContext());
+        BaseInputConnection bic = new BaseInputConnection(view, false);
+        Binder binder = new Binder();
+        int uid = 1;
+        int pid = 2;
+        InputBinding inputBinding = new InputBinding(bic, binder, uid, pid);
+        new InputBinding(bic, inputBinding);
+        assertSame(bic, inputBinding.getConnection());
+        assertSame(binder, inputBinding.getConnectionToken());
+        assertEquals(uid, inputBinding.getUid());
+        assertEquals(pid, inputBinding.getPid());
+
+        assertNotNull(inputBinding.toString());
+        assertEquals(0, inputBinding.describeContents());
+
+        Parcel p = Parcel.obtain();
+        inputBinding.writeToParcel(p, 0);
+        p.setDataPosition(0);
+        InputBinding target = InputBinding.CREATOR.createFromParcel(p);
+        assertEquals(uid, target.getUid());
+        assertEquals(pid, target.getPid());
+        assertSame(binder, target.getConnectionToken());
+    }
+}
diff --git a/tests/tests/view/src/android/view/inputmethod/cts/InputConnectionWrapperTest.java b/tests/tests/view/src/android/view/inputmethod/cts/InputConnectionWrapperTest.java
new file mode 100644
index 0000000..896e99f
--- /dev/null
+++ b/tests/tests/view/src/android/view/inputmethod/cts/InputConnectionWrapperTest.java
@@ -0,0 +1,299 @@
+/*
+ * Copyright (C) 2009 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.view.inputmethod.cts;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+import android.os.Bundle;
+import android.test.AndroidTestCase;
+import android.text.TextUtils;
+import android.view.KeyEvent;
+import android.view.inputmethod.CompletionInfo;
+import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.ExtractedText;
+import android.view.inputmethod.ExtractedTextRequest;
+import android.view.inputmethod.InputConnection;
+import android.view.inputmethod.InputConnectionWrapper;
+
+@TestTargetClass(InputConnectionWrapper.class)
+public class InputConnectionWrapperTest extends AndroidTestCase {
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "InputConnectionWrapper",
+            args = {InputConnection.class, boolean.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "setTarget",
+            args = {InputConnection.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "beginBatchEdit",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "commitCompletion",
+            args = {CompletionInfo.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "endBatchEdit",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getExtractedText",
+            args = {ExtractedTextRequest.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "performContextMenuAction",
+            args = {int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "performEditorAction",
+            args = {int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "performPrivateCommand",
+            args = {String.class, Bundle.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "setSelection",
+            args = {int.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getTextAfterCursor",
+            args = {int.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getTextBeforeCursor",
+            args = {int.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getCursorCapsMode",
+            args = {int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "clearMetaKeyStates",
+            args = {int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "commitText",
+            args = {CharSequence.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "deleteSurroundingText",
+            args = {int.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "finishComposingText",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "setComposingText",
+            args = {CharSequence.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "sendKeyEvent",
+            args = {KeyEvent.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "reportFullscreenMode",
+            args = {boolean.class}
+        )
+    })
+    public void testInputConnectionWrapper() {
+        MockInputConnection inputConnection = new MockInputConnection();
+        InputConnectionWrapper wrapper = new InputConnectionWrapper(null, true);
+        try {
+            wrapper.beginBatchEdit();
+            fail("Failed to throw NullPointerException!");
+        } catch (NullPointerException e) {
+            // expected
+        }
+        wrapper.setTarget(inputConnection);
+
+        wrapper.beginBatchEdit();
+        assertTrue(inputConnection.isBeginBatchEditCalled);
+        wrapper.clearMetaKeyStates(KeyEvent.META_ALT_ON);
+        assertTrue(inputConnection.isClearMetaKeyStatesCalled);
+        wrapper.commitCompletion(new CompletionInfo(1, 1, "testText"));
+        assertTrue(inputConnection.isCommitCompletionCalled);
+        wrapper.commitText("Text", 1);
+        assertTrue(inputConnection.isCommitTextCalled);
+        wrapper.deleteSurroundingText(10, 100);
+        assertTrue(inputConnection.isDeleteSurroundingTextCalled);
+        wrapper.endBatchEdit();
+        assertTrue(inputConnection.isEndBatchEditCalled);
+        wrapper.finishComposingText();
+        assertTrue(inputConnection.isFinishComposingTextCalled);
+        wrapper.getCursorCapsMode(TextUtils.CAP_MODE_CHARACTERS);
+        assertTrue(inputConnection.isGetCursorCapsModeCalled);
+        wrapper.getExtractedText(new ExtractedTextRequest(), 0);
+        assertTrue(inputConnection.isGetExtractedTextCalled);
+        wrapper.getTextAfterCursor(5, 0);
+        assertTrue(inputConnection.isGetTextAfterCursorCalled);
+        wrapper.getTextBeforeCursor(3, 0);
+        assertTrue(inputConnection.isGetTextBeforeCursorCalled);
+        wrapper.performContextMenuAction(1);
+        assertTrue(inputConnection.isPerformContextMenuActionCalled);
+        wrapper.performEditorAction(EditorInfo.IME_ACTION_GO);
+        assertTrue(inputConnection.isPerformEditorActionCalled);
+        wrapper.performPrivateCommand("com.android.action.MAIN", new Bundle());
+        assertTrue(inputConnection.isPerformPrivateCommandCalled);
+        wrapper.reportFullscreenMode(true);
+        assertTrue(inputConnection.isReportFullscreenModeCalled);
+        wrapper.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_0));
+        assertTrue(inputConnection.isSendKeyEventCalled);
+        wrapper.setComposingText("Text", 1);
+        assertTrue(inputConnection.isSetComposingTextCalled);
+        wrapper.setSelection(0, 10);
+        assertTrue(inputConnection.isSetSelectionCalled);
+    }
+
+    private class MockInputConnection implements InputConnection {
+        public boolean isBeginBatchEditCalled;
+        public boolean isClearMetaKeyStatesCalled;
+        public boolean isCommitCompletionCalled;
+        public boolean isCommitTextCalled;
+        public boolean isDeleteSurroundingTextCalled;
+        public boolean isEndBatchEditCalled;
+        public boolean isFinishComposingTextCalled;
+        public boolean isGetCursorCapsModeCalled;
+        public boolean isGetExtractedTextCalled;
+        public boolean isGetTextAfterCursorCalled;
+        public boolean isGetTextBeforeCursorCalled;
+        public boolean isPerformContextMenuActionCalled;
+        public boolean isPerformEditorActionCalled;
+        public boolean isPerformPrivateCommandCalled;
+        public boolean isReportFullscreenModeCalled;
+        public boolean isSendKeyEventCalled;
+        public boolean isSetComposingTextCalled;
+        public boolean isSetSelectionCalled;
+
+        public boolean beginBatchEdit() {
+            isBeginBatchEditCalled = true;
+            return false;
+        }
+
+        public boolean clearMetaKeyStates(int states) {
+            isClearMetaKeyStatesCalled = true;
+            return false;
+        }
+
+        public boolean commitCompletion(CompletionInfo text) {
+            isCommitCompletionCalled = true;
+            return false;
+        }
+
+        public boolean commitText(CharSequence text, int newCursorPosition) {
+            isCommitTextCalled = true;
+            return false;
+        }
+
+        public boolean deleteSurroundingText(int leftLength, int rightLength) {
+            isDeleteSurroundingTextCalled = true;
+            return false;
+        }
+
+        public boolean endBatchEdit() {
+            isEndBatchEditCalled = true;
+            return false;
+        }
+
+        public boolean finishComposingText() {
+            isFinishComposingTextCalled = true;
+            return false;
+        }
+
+        public int getCursorCapsMode(int reqModes) {
+            isGetCursorCapsModeCalled = true;
+            return 0;
+        }
+
+        public ExtractedText getExtractedText(ExtractedTextRequest request, int flags) {
+            isGetExtractedTextCalled = true;
+            return null;
+        }
+
+        public CharSequence getTextAfterCursor(int n, int flags) {
+            isGetTextAfterCursorCalled = true;
+            return null;
+        }
+
+        public CharSequence getTextBeforeCursor(int n, int flags) {
+            isGetTextBeforeCursorCalled = true;
+            return null;
+        }
+
+        public boolean performContextMenuAction(int id) {
+            isPerformContextMenuActionCalled = true;
+            return false;
+        }
+
+        public boolean performEditorAction(int editorAction) {
+            isPerformEditorActionCalled = true;
+            return false;
+        }
+
+        public boolean performPrivateCommand(String action, Bundle data) {
+            isPerformPrivateCommandCalled = true;
+            return false;
+        }
+
+        public boolean reportFullscreenMode(boolean enabled) {
+            isReportFullscreenModeCalled = true;
+            return false;
+        }
+
+        public boolean sendKeyEvent(KeyEvent event) {
+            isSendKeyEventCalled = true;
+            return false;
+        }
+
+        public boolean setComposingText(CharSequence text, int newCursorPosition) {
+            isSetComposingTextCalled = true;
+            return false;
+        }
+
+        public boolean setSelection(int start, int end) {
+            isSetSelectionCalled = true;
+            return false;
+        }
+    }
+}
diff --git a/tests/tests/view/src/android/view/inputmethod/cts/InputMethodInfoTest.java b/tests/tests/view/src/android/view/inputmethod/cts/InputMethodInfoTest.java
new file mode 100644
index 0000000..35a5a44
--- /dev/null
+++ b/tests/tests/view/src/android/view/inputmethod/cts/InputMethodInfoTest.java
@@ -0,0 +1,226 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.view.inputmethod.cts;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+import android.content.ComponentName;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.content.pm.ServiceInfo;
+import android.os.Parcel;
+import android.test.AndroidTestCase;
+import android.util.Printer;
+import android.view.inputmethod.InputMethod;
+import android.view.inputmethod.InputMethodInfo;
+
+import org.xmlpull.v1.XmlPullParserException;
+
+import java.io.IOException;
+import java.util.List;
+
+@TestTargetClass(InputMethodInfo.class)
+public class InputMethodInfoTest extends AndroidTestCase {
+    private InputMethodInfo mInputMethodInfo;
+    private String mPackageName;
+    private String mClassName;
+    private CharSequence mLabel;
+    private String mSettingsActivity;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mPackageName = mContext.getPackageName();
+        mClassName = InputMethodInfoStub.class.getName();
+        mLabel = "test";
+        mSettingsActivity = "android.view.inputmethod.cts.InputMethodInfoStub";
+        mInputMethodInfo = new InputMethodInfo(mPackageName, mClassName, mLabel, mSettingsActivity);
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "describeContents",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getComponent",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getId",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.PARTIAL,
+            notes = "Can't make sure how to make the default id non-0",
+            method = "getIsDefaultResourceId",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getPackageName",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getServiceInfo",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getServiceName",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getSettingsActivity",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "loadIcon",
+            args = {android.content.pm.PackageManager.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "InputMethodInfo",
+            args = {android.content.Context.class, android.content.pm.ResolveInfo.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "InputMethodInfo",
+            args = {java.lang.String.class, java.lang.String.class, java.lang.CharSequence.class,
+                    java.lang.String.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "toString",
+            args = {}
+        )
+    })
+    public void testInputMethodInfoProperties() throws XmlPullParserException, IOException {
+        assertEquals(0, mInputMethodInfo.describeContents());
+        assertNotNull(mInputMethodInfo.toString());
+
+        assertInfo(mInputMethodInfo);
+        assertEquals(0, mInputMethodInfo.getIsDefaultResourceId());
+
+        Intent intent = new Intent(InputMethod.SERVICE_INTERFACE);
+        intent.setClass(mContext, InputMethodInfoStub.class);
+        PackageManager pm = mContext.getPackageManager();
+        List<ResolveInfo> ris = pm.queryIntentServices(intent, PackageManager.GET_META_DATA);
+        for (int i = 0; i < ris.size(); i++) {
+            ResolveInfo resolveInfo = ris.get(i);
+            mInputMethodInfo = new InputMethodInfo(mContext, resolveInfo);
+            assertService(resolveInfo.serviceInfo, mInputMethodInfo.getServiceInfo());
+            assertInfo(mInputMethodInfo);
+        }
+    }
+
+    private void assertService(ServiceInfo expected, ServiceInfo actual) {
+        assertEquals(expected.getIconResource(), actual.getIconResource());
+        assertEquals(expected.labelRes, actual.labelRes);
+        assertEquals(expected.nonLocalizedLabel, actual.nonLocalizedLabel);
+        assertEquals(expected.icon, actual.icon);
+        assertEquals(expected.permission, actual.permission);
+    }
+
+    private void assertInfo(InputMethodInfo info) {
+        assertEquals(mPackageName, info.getPackageName());
+        assertEquals(mSettingsActivity, info.getSettingsActivity());
+        ComponentName component = info.getComponent();
+        assertEquals(mClassName, component.getClassName());
+        String expectedId = component.flattenToShortString();
+        assertEquals(expectedId, info.getId());
+        assertEquals(mClassName, info.getServiceName());
+    }
+
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "dump",
+        args = {android.util.Printer.class, java.lang.String.class}
+    )
+    public void testDump() {
+        MockPrinter printer = new MockPrinter();
+        String prefix = "test";
+        mInputMethodInfo.dump(printer, prefix);
+    }
+
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "loadIcon",
+        args = {android.content.pm.PackageManager.class}
+    )
+    public void testLoadIcon() {
+        PackageManager pm = mContext.getPackageManager();
+        assertNotNull(mInputMethodInfo.loadIcon(pm));
+    }
+
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "equals",
+        args = {java.lang.Object.class}
+    )
+    public void testEquals() {
+        InputMethodInfo inputMethodInfo = new InputMethodInfo(mPackageName, mClassName, mLabel,
+                mSettingsActivity);
+        assertTrue(inputMethodInfo.equals(mInputMethodInfo));
+    }
+
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "loadLabel",
+        args = {android.content.pm.PackageManager.class}
+    )
+    public void testLoadLabel() {
+        CharSequence expected = "test";
+        PackageManager pm = mContext.getPackageManager();
+        assertEquals(expected.toString(), mInputMethodInfo.loadLabel(pm).toString());
+    }
+
+    @TestTargetNew(
+        level = TestLevel.COMPLETE,
+        method = "writeToParcel",
+        args = {android.os.Parcel.class, int.class}
+    )
+    public void testWriteToParcel() {
+        Parcel p = Parcel.obtain();
+        mInputMethodInfo.writeToParcel(p, 0);
+        p.setDataPosition(0);
+        InputMethodInfo inputMethodInfo = InputMethodInfo.CREATOR.createFromParcel(p);
+
+        assertEquals(mInputMethodInfo.getPackageName(), inputMethodInfo.getPackageName());
+        assertEquals(mInputMethodInfo.getServiceName(), inputMethodInfo.getServiceName());
+        assertEquals(mInputMethodInfo.getSettingsActivity(), inputMethodInfo.getSettingsActivity());
+        assertEquals(mInputMethodInfo.getId(), inputMethodInfo.getId());
+        assertEquals(mInputMethodInfo.getIsDefaultResourceId(), inputMethodInfo
+                .getIsDefaultResourceId());
+        assertService(mInputMethodInfo.getServiceInfo(), inputMethodInfo.getServiceInfo());
+    }
+
+    class MockPrinter implements Printer {
+        public void println(String x) {
+        }
+    }
+}
diff --git a/tests/tests/view/src/android/view/inputmethod/cts/InputMethodManagerTest.java b/tests/tests/view/src/android/view/inputmethod/cts/InputMethodManagerTest.java
new file mode 100755
index 0000000..d92f446
--- /dev/null
+++ b/tests/tests/view/src/android/view/inputmethod/cts/InputMethodManagerTest.java
@@ -0,0 +1,200 @@
+/*
+ * Copyright (C) 2008 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.view.inputmethod.cts;
+
+import com.android.cts.stub.R;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+import android.app.Instrumentation;
+import android.content.Context;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.ResultReceiver;
+import android.test.ActivityInstrumentationTestCase2;
+import android.test.UiThreadTest;
+import android.view.KeyEvent;
+import android.view.View;
+import android.view.Window;
+import android.view.inputmethod.BaseInputConnection;
+import android.view.inputmethod.InputMethodInfo;
+import android.view.inputmethod.InputMethodManager;
+import android.widget.EditText;
+
+import java.util.List;
+
+@TestTargetClass(InputMethodManager.class)
+public class InputMethodManagerTest
+                  extends ActivityInstrumentationTestCase2<InputMethodStubActivity> {
+
+    public InputMethodManagerTest() {
+        super("com.android.cts.stub", InputMethodStubActivity.class);
+    }
+
+    private InputMethodStubActivity mActivity;
+    private Instrumentation mInstrumentation;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mActivity = getActivity();
+        mInstrumentation = getInstrumentation();
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        // Close soft input just in case.
+        sendKeys(KeyEvent.KEYCODE_BACK);
+        super.tearDown();
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.PARTIAL,
+            method = "hideSoftInputFromInputMethod",
+            args = {IBinder.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.PARTIAL,
+            method = "hideSoftInputFromWindow",
+            args = {IBinder.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.PARTIAL,
+            method = "hideSoftInputFromWindow",
+            args = {IBinder.class, int.class, ResultReceiver.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.PARTIAL,
+            method = "isAcceptingText",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.PARTIAL,
+            method = "isActive",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.PARTIAL,
+            method = "isActive",
+            args = {View.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "isFullscreenMode",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "isWatchingCursor",
+            args = {View.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.NOT_FEASIBLE,
+            method = "restartInput",
+            args = {View.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.SUFFICIENT,
+            method = "getEnabledInputMethodList",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.SUFFICIENT,
+            method = "getInputMethodList",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.SUFFICIENT,
+            method = "setInputMethod",
+            args = {IBinder.class, String.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.PARTIAL,
+            method = "showSoftInput",
+            args = {View.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.PARTIAL,
+            method = "showSoftInput",
+            args = {View.class, int.class, ResultReceiver.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.PARTIAL,
+            method = "showSoftInputFromInputMethod",
+            args = {IBinder.class, int.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.PARTIAL,
+            method = "toggleSoftInputFromWindow",
+            args = {IBinder.class, int.class, int.class}
+        )
+    })
+    @UiThreadTest
+    public void testInputMethodManager() {
+        Window window = mActivity.getWindow();
+        EditText view = (EditText) window.findViewById(R.id.entry);
+
+        BaseInputConnection connection = new BaseInputConnection(view, false);
+        Context context = mInstrumentation.getTargetContext();
+        InputMethodManager imManager = (InputMethodManager) context
+                .getSystemService(Context.INPUT_METHOD_SERVICE);
+        assertTrue(imManager.isActive());
+        assertTrue(imManager.isAcceptingText());
+        assertTrue(imManager.isActive(view));
+
+        connection.reportFullscreenMode(false);
+        assertFalse(imManager.isFullscreenMode());
+        connection.reportFullscreenMode(true);
+        assertTrue(imManager.isFullscreenMode());
+
+        // Currently can't set this status, always false.
+        assertFalse(imManager.isWatchingCursor(view));
+
+        IBinder token = view.getWindowToken();
+
+        // Show and hide input method.
+        assertTrue(imManager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT));
+        assertTrue(imManager.hideSoftInputFromWindow(token, 0));
+
+        Handler handler = new Handler();
+        ResultReceiver receiver = new ResultReceiver(handler);
+        assertTrue(imManager.showSoftInput(view, 0, receiver));
+        receiver = new ResultReceiver(handler);
+        assertTrue(imManager.hideSoftInputFromWindow(token, 0, receiver));
+
+        imManager.showSoftInputFromInputMethod(token, InputMethodManager.SHOW_FORCED);
+        imManager.hideSoftInputFromInputMethod(token, InputMethodManager.HIDE_NOT_ALWAYS);
+
+        // status: hide to show to hide
+        imManager.toggleSoftInputFromWindow(token, 0, InputMethodManager.HIDE_NOT_ALWAYS);
+        imManager.toggleSoftInputFromWindow(token, 0, InputMethodManager.HIDE_NOT_ALWAYS);
+
+        List<InputMethodInfo> enabledImList = imManager.getEnabledInputMethodList();
+        if (enabledImList != null && enabledImList.size() > 0) {
+            imManager.setInputMethod(token, enabledImList.get(0).getId());
+            // cannot test whether setting was successful
+        }
+
+        List<InputMethodInfo> imList = imManager.getInputMethodList();
+        if (imList != null && enabledImList != null) {
+            assertTrue(imList.size() >= enabledImList.size());
+        }
+    }
+}
diff --git a/tests/tests/webkit/src/android/webkit/cts/CookieSyncManagerTest.java b/tests/tests/webkit/src/android/webkit/cts/CookieSyncManagerTest.java
new file mode 100644
index 0000000..2f4c35a
--- /dev/null
+++ b/tests/tests/webkit/src/android/webkit/cts/CookieSyncManagerTest.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.webkit.cts;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
+
+import android.content.Context;
+import android.test.ActivityInstrumentationTestCase2;
+import android.view.animation.cts.DelayedCheck;
+import android.webkit.CookieManager;
+import android.webkit.CookieSyncManager;
+
+@TestTargetClass(android.webkit.CookieSyncManager.class)
+public class CookieSyncManagerTest
+        extends ActivityInstrumentationTestCase2<CookieSyncManagerStubActivity> {
+
+    public CookieSyncManagerTest() {
+        super("com.android.cts.stub", CookieSyncManagerStubActivity.class);
+    }
+
+    @TestTargets({
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "createInstance",
+            args = {Context.class}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "getInstance",
+            args = {}
+        ),
+        @TestTargetNew(
+            level = TestLevel.COMPLETE,
+            method = "sync",
+            args = {}
+        )
+    })
+    public void testCookieSyncManager() {
+        CookieSyncManager csm1 = CookieSyncManager.createInstance(getActivity());
+        assertNotNull(csm1);
+
+        CookieSyncManager csm2 = CookieSyncManager.getInstance();
+        assertNotNull(csm2);
+
+        assertSame(csm1, csm2);
+
+        final CookieManager cookieManager = CookieManager.getInstance();
+        assertFalse(cookieManager.hasCookies());
+
+        cookieManager.setAcceptCookie(true);
+        assertTrue(cookieManager.acceptCookie());
+
+        String cookieValue = "a = b";
+        cookieManager.setCookie(TestHtmlConstants.HELLO_WORLD_URL, cookieValue);
+        assertEquals(cookieValue, cookieManager.getCookie(TestHtmlConstants.HELLO_WORLD_URL));
+
+        // Cookie is stored in RAM but not in the database.
+        assertFalse(cookieManager.hasCookies());
+
+        // Store the cookie to the database.
+        csm1.sync();
+        new DelayedCheck(10000) {
+            @Override
+            protected boolean check() {
+                return cookieManager.hasCookies();
+            }
+        }.run();
+
+        // Remove all cookies from the database.
+        cookieManager.removeAllCookie();
+        new DelayedCheck(10000) {
+            @Override
+            protected boolean check() {
+                return !cookieManager.hasCookies();
+            }
+        }.run();
+    }
+}
diff --git a/tests/tests/widget/src/android/widget/cts/AbsListViewTest.java b/tests/tests/widget/src/android/widget/cts/AbsListViewTest.java
index ffd57df..0995f28 100644
--- a/tests/tests/widget/src/android/widget/cts/AbsListViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/AbsListViewTest.java
@@ -504,11 +504,16 @@
 
         setAdapter();
 
+        View row = mListView.getChildAt(0);
+        int rowHeight = row.getHeight();
+        int middleOfSecondRow = rowHeight + rowHeight/2;
+
         int position1 = mListView.pointToPosition(0, 0);
-        int position2 = mListView.pointToPosition(50, 200);
+        int position2 = mListView.pointToPosition(50, middleOfSecondRow);
 
         assertEquals(mAdapter_countries.getItemId(position1), mListView.pointToRowId(0, 0));
-        assertEquals(mAdapter_countries.getItemId(position2), mListView.pointToRowId(50, 200));
+        assertEquals(mAdapter_countries.getItemId(position2),
+                mListView.pointToRowId(50, middleOfSecondRow));
 
         assertTrue(position2 > position1);
     }
diff --git a/tests/tests/widget/src/android/widget/cts/DialerFilterTest.java b/tests/tests/widget/src/android/widget/cts/DialerFilterTest.java
index 76de651..0b436b2 100644
--- a/tests/tests/widget/src/android/widget/cts/DialerFilterTest.java
+++ b/tests/tests/widget/src/android/widget/cts/DialerFilterTest.java
@@ -117,7 +117,7 @@
         });
         mInstrumentation.waitForIdleSync();
 
-        sendKeys(KeyEvent.KEYCODE_1, KeyEvent.KEYCODE_2, KeyEvent.KEYCODE_3);
+        mInstrumentation.sendStringSync("123");
         assertEquals("", mDialerFilter.getLetters().toString());
         assertEquals("123", mDialerFilter.getDigits().toString());
 
@@ -129,7 +129,7 @@
         });
         mInstrumentation.waitForIdleSync();
 
-        sendKeys(KeyEvent.KEYCODE_A, KeyEvent.KEYCODE_D, KeyEvent.KEYCODE_G);
+        mInstrumentation.sendStringSync("adg");
         assertEquals("ADG", mDialerFilter.getLetters().toString());
         assertEquals("", mDialerFilter.getDigits().toString());
 
@@ -141,7 +141,7 @@
         });
         mInstrumentation.waitForIdleSync();
 
-        sendKeys(KeyEvent.KEYCODE_A, KeyEvent.KEYCODE_D, KeyEvent.KEYCODE_G);
+        mInstrumentation.sendStringSync("adg");
         assertEquals("ADG", mDialerFilter.getLetters().toString());
         // A, D, K may map to numbers on some keyboards. Don't test.
 
@@ -153,7 +153,7 @@
         });
         mInstrumentation.waitForIdleSync();
 
-        sendKeys(KeyEvent.KEYCODE_1, KeyEvent.KEYCODE_2, KeyEvent.KEYCODE_3);
+        mInstrumentation.sendStringSync("123");
         // 1, 2, 3 may map to letters on some keyboards. Don't test.
         assertEquals("123", mDialerFilter.getDigits().toString());
     }
diff --git a/tests/tests/widget/src/android/widget/cts/HorizontalScrollViewTest.java b/tests/tests/widget/src/android/widget/cts/HorizontalScrollViewTest.java
index d26b217..31b0b7b 100644
--- a/tests/tests/widget/src/android/widget/cts/HorizontalScrollViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/HorizontalScrollViewTest.java
@@ -669,10 +669,12 @@
         mScrollView.setSmoothScrollingEnabled(true);
         assertEquals(0, mScrollView.getScrollX());
 
+        final int velocityX = WidgetTestUtils.convertDipToPixels(getActivity(), 2000);
+
         // fling towards right
         runTestOnUiThread(new Runnable() {
             public void run() {
-                mScrollView.fling(2000);
+                mScrollView.fling(velocityX);
             }
         });
         delayedCheckFling(0, true);
@@ -681,7 +683,7 @@
         // fling towards left
         runTestOnUiThread(new Runnable() {
             public void run() {
-                mScrollView.fling(-2000);
+                mScrollView.fling(-velocityX);
             }
         });
         delayedCheckFling(currentX, false);
@@ -872,7 +874,7 @@
                 }
                 return mScrollView.getScrollX() < startPosition;
             }
-        };
+        }.run();
 
         new DelayedCheck() {
             private int mPreviousScrollX = mScrollView.getScrollX();
diff --git a/tests/tests/widget/src/android/widget/cts/ListViewTest.java b/tests/tests/widget/src/android/widget/cts/ListViewTest.java
index f283681..e7b872a 100644
--- a/tests/tests/widget/src/android/widget/cts/ListViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/ListViewTest.java
@@ -61,6 +61,7 @@
     private final String[] mNameList = new String[] {
         "Jacky", "David", "Kevin", "Michael", "Andy"
     };
+    private final String[] mEmptyList = new String[0];
 
     private ListView mListView;
     private Activity mActivity;
@@ -68,6 +69,7 @@
     private AttributeSet mAttributeSet;
     private ArrayAdapter<String> mAdapter_countries;
     private ArrayAdapter<String> mAdapter_names;
+    private ArrayAdapter<String> mAdapter_empty;
 
     public ListViewTest() {
         super("com.android.cts.stub", ListViewStubActivity.class);
@@ -85,6 +87,8 @@
                 android.R.layout.simple_list_item_1, mCountryList);
         mAdapter_names = new ArrayAdapter<String>(mActivity, android.R.layout.simple_list_item_1,
                 mNameList);
+        mAdapter_empty = new ArrayAdapter<String>(mActivity, android.R.layout.simple_list_item_1,
+                mEmptyList);
 
         mListView = (ListView) mActivity.findViewById(R.id.listview_default);
     }
@@ -147,26 +151,22 @@
         )
     })
     public void testGetMaxScrollAmount() {
+        setAdapter(mAdapter_empty);
+        int scrollAmount = mListView.getMaxScrollAmount();
+        assertEquals(0, scrollAmount);
+
+        setAdapter(mAdapter_names);
+        scrollAmount = mListView.getMaxScrollAmount();
+        assertTrue(scrollAmount > 0);
+    }
+
+    private void setAdapter(final ArrayAdapter<String> adapter) {
         mInstrumentation.runOnMainSync(new Runnable() {
             public void run() {
-                mListView.setAdapter(mAdapter_countries);
+                mListView.setAdapter(adapter);
             }
         });
         mInstrumentation.waitForIdleSync();
-
-        int amount1 = mListView.getMaxScrollAmount();
-        assertTrue(amount1 > 0);
-
-        mInstrumentation.runOnMainSync(new Runnable() {
-            public void run() {
-                mListView.setAdapter(mAdapter_names);
-            }
-        });
-        mInstrumentation.waitForIdleSync();
-
-        int amount2 = mListView.getMaxScrollAmount();
-        assertTrue(amount2 > 0);
-        assertTrue(amount2 < amount1); // because NAMES list is shorter than COUNTRIES list
     }
 
     @TestTargets({
diff --git a/tests/tests/widget/src/android/widget/cts/TextViewTest.java b/tests/tests/widget/src/android/widget/cts/TextViewTest.java
index 5d95f86..aad008c 100644
--- a/tests/tests/widget/src/android/widget/cts/TextViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/TextViewTest.java
@@ -80,8 +80,11 @@
 import android.util.TypedValue;
 import android.view.ContextMenu;
 import android.view.Gravity;
+import android.view.KeyCharacterMap;
 import android.view.KeyEvent;
 import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowManager;
 import android.view.ContextMenu.ContextMenuInfo;
 import android.view.View.OnCreateContextMenuListener;
 import android.view.View.OnLongClickListener;
@@ -90,6 +93,8 @@
 import android.view.inputmethod.EditorInfo;
 import android.view.inputmethod.ExtractedText;
 import android.view.inputmethod.ExtractedTextRequest;
+import android.widget.AbsoluteLayout;
+import android.widget.FrameLayout;
 import android.widget.Scroller;
 import android.widget.TextView;
 import android.widget.TextView.BufferType;
@@ -247,19 +252,19 @@
         assertEquals("", mTextView.getText().toString());
 
         // press '-' key.
-        sendKeys(KeyEvent.KEYCODE_MINUS);
+        mInstrumentation.sendStringSync("-");
         assertEquals("", mTextView.getText().toString());
 
         // press '1' key.
-        sendKeys(KeyEvent.KEYCODE_1);
+        mInstrumentation.sendStringSync("1");
         assertEquals("1", mTextView.getText().toString());
 
         // press '.' key.
-        sendKeys(KeyEvent.KEYCODE_PERIOD);
+        mInstrumentation.sendStringSync(".");
         assertEquals("1", mTextView.getText().toString());
 
         // press 'a' key.
-        sendKeys(KeyEvent.KEYCODE_A);
+        mInstrumentation.sendStringSync("a");
         assertEquals("1", mTextView.getText().toString());
 
         final QwertyKeyListener qwertyKeyListener
@@ -275,7 +280,8 @@
         assertEquals("1", mTextView.getText().toString());
 
         // press 'a' key.
-        sendKeys(KeyEvent.KEYCODE_A);
+        mInstrumentation.sendStringSync("a");
+
         assertEquals("1a", mTextView.getText().toString());
     }
 
@@ -1793,13 +1799,13 @@
 
         assertEquals(errorText, mTextView.getError().toString());
 
-        sendKeys(KeyEvent.KEYCODE_A);
+        mInstrumentation.sendStringSync("a");
         // a key event that will not change the TextView's text
         assertEquals("", mTextView.getText().toString());
         // The icon and error message will not be reset to null
         assertNotNull(mTextView.getError());
 
-        sendKeys(KeyEvent.KEYCODE_1);
+        mInstrumentation.sendStringSync("1");
         // a key event cause changes to the TextView's text
         assertEquals("1", mTextView.getText().toString());
         // the error message and icon will be cleared.
@@ -1840,13 +1846,13 @@
 
         assertSame(expected, mTextView.getFilters());
 
-        sendKeys(KeyEvent.KEYCODE_A);
+        mInstrumentation.sendStringSync("a");
         // the text is capitalized by InputFilter.AllCaps
         assertEquals("A", mTextView.getText().toString());
-        sendKeys(KeyEvent.KEYCODE_B);
+        mInstrumentation.sendStringSync("b");
         // the text is capitalized by InputFilter.AllCaps
         assertEquals("AB", mTextView.getText().toString());
-        sendKeys(KeyEvent.KEYCODE_C);
+        mInstrumentation.sendStringSync("c");
         // 'C' could not be accepted, because there is a length filter.
         assertEquals("AB", mTextView.getText().toString());
 
@@ -2024,9 +2030,9 @@
         });
         mInstrumentation.waitForIdleSync();
 
-        sendKeys(KeyEvent.KEYCODE_A);
+        mInstrumentation.sendStringSync("a");
         assertEquals("a", mTextView.getText().toString());
-        sendKeys(KeyEvent.KEYCODE_B);
+        mInstrumentation.sendStringSync("b");
         assertEquals("ab", mTextView.getText().toString());
         sendKeys(KeyEvent.KEYCODE_DEL);
         assertEquals("a", mTextView.getText().toString());
@@ -3329,17 +3335,23 @@
             args = {boolean.class}
         )
     })
+
     public void testMarquee() {
         final MockTextView textView = new MockTextView(mActivity);
         textView.setText(LONG_TEXT);
         textView.setSingleLine();
         textView.setEllipsize(TruncateAt.MARQUEE);
+        textView.setLayoutParams(new ViewGroup.LayoutParams(100, 100));
+
+        final FrameLayout layout = new FrameLayout(mActivity);
+        layout.addView(textView);
+
         // make the fading to be shown
         textView.setHorizontalFadingEdgeEnabled(true);
 
         mActivity.runOnUiThread(new Runnable() {
             public void run() {
-                mActivity.setContentView(textView);
+                mActivity.setContentView(layout);
             }
         });
         mInstrumentation.waitForIdleSync();
diff --git a/tools/device-setup/TestDeviceSetup/src/android/tests/getinfo/DeviceInfoInstrument.java b/tools/device-setup/TestDeviceSetup/src/android/tests/getinfo/DeviceInfoInstrument.java
index d360c40..a54ee4c 100644
--- a/tools/device-setup/TestDeviceSetup/src/android/tests/getinfo/DeviceInfoInstrument.java
+++ b/tools/device-setup/TestDeviceSetup/src/android/tests/getinfo/DeviceInfoInstrument.java
@@ -20,14 +20,28 @@
 import android.app.Instrumentation;
 import android.content.Context;
 import android.content.Intent;
+import android.content.pm.FeatureInfo;
+import android.content.pm.PackageManager;
 import android.os.Build;
 import android.os.Bundle;
 import android.telephony.TelephonyManager;
 import android.util.DisplayMetrics;
+import android.util.Log;
 import android.view.Display;
 import android.view.WindowManager;
 
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
 public class DeviceInfoInstrument extends Instrumentation {
+
+    private static final String TAG = "DeviceInfoInstrument";
+
+    private static final String PROCESSES = "processes";
+    private static final String FEATURES = "features";
     private static final String PHONE_NUMBER = "phoneNumber";
     public static final String LOCALES = "locales";
     private static final String IMSI = "imsi";
@@ -122,6 +136,14 @@
         String phoneNumber = tm.getLine1Number();
         addResult(PHONE_NUMBER, phoneNumber);
 
+        // features
+        String features = getFeatures();
+        addResult(FEATURES, features);
+
+        // processes
+        String processes = getProcesses();
+        addResult(PROCESSES, processes);
+
         finish(Activity.RESULT_OK, mResults);
     }
 
@@ -154,4 +176,84 @@
     private void addResult(final String key, final float value){
         mResults.putFloat(key, value);
     }
+
+    /**
+     * Return a summary of the device's feature as a semi-colon-delimited list of colon separated
+     * name and availability pairs like "feature1:sdk:true;feature2:sdk:false;feature3:other:true;".
+     */
+    private String getFeatures() {
+        StringBuilder features = new StringBuilder();
+
+        try {
+            Set<String> checkedFeatures = new HashSet<String>();
+
+            PackageManager packageManager = getContext().getPackageManager();
+            for (String featureName : getPackageManagerFeatures()) {
+                checkedFeatures.add(featureName);
+                boolean hasFeature = packageManager.hasSystemFeature(featureName);
+                addFeature(features, featureName, "sdk", hasFeature);
+            }
+
+            FeatureInfo[] featureInfos = packageManager.getSystemAvailableFeatures();
+            if (featureInfos != null) {
+                for (FeatureInfo featureInfo : featureInfos) {
+                    if (featureInfo.name != null && !checkedFeatures.contains(featureInfo.name)) {
+                        addFeature(features, featureInfo.name, "other", true);
+                    }
+                }
+            }
+        } catch (Exception exception) {
+            Log.e(TAG, "Error getting features: " + exception.getMessage(), exception);
+        }
+
+        return features.toString();
+    }
+
+    private static void addFeature(StringBuilder features, String name, String type,
+            boolean available) {
+        features.append(name).append(':').append(type).append(':').append(available).append(';');
+    }
+
+    /**
+     * Use reflection to get the features defined by the SDK. If there are features that do not fit
+     * the convention of starting with "FEATURE_" then they will still be shown under the
+     * "Other Features" section.
+     *
+     * @return list of feature names from sdk
+     */
+    private List<String> getPackageManagerFeatures() {
+        try {
+            List<String> features = new ArrayList<String>();
+            Field[] fields = PackageManager.class.getFields();
+            for (Field field : fields) {
+                if (field.getName().startsWith("FEATURE_")) {
+                    String feature = (String) field.get(null);
+                    features.add(feature);
+                }
+            }
+            return features;
+        } catch (IllegalAccessException illegalAccess) {
+            throw new RuntimeException(illegalAccess);
+        }
+    }
+
+    /**
+     * Return a semi-colon-delimited list of the root processes that were running on the phone
+     * or an error message.
+     */
+    private static String getProcesses() {
+        StringBuilder builder = new StringBuilder();
+
+        try {
+            String[] rootProcesses = RootProcessScanner.getRootProcesses();
+            for (String rootProcess : rootProcesses) {
+                builder.append(rootProcess).append(';');
+            }
+        } catch (Exception exception) {
+            Log.e(TAG, "Error getting processes: " + exception.getMessage(), exception);
+            builder.append(exception.getMessage());
+        }
+
+        return builder.toString();
+    }
 }
diff --git a/tools/device-setup/TestDeviceSetup/src/android/tests/getinfo/RootProcessScanner.java b/tools/device-setup/TestDeviceSetup/src/android/tests/getinfo/RootProcessScanner.java
new file mode 100644
index 0000000..4763287
--- /dev/null
+++ b/tools/device-setup/TestDeviceSetup/src/android/tests/getinfo/RootProcessScanner.java
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.tests.getinfo;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Scanner;
+import java.util.regex.Pattern;
+
+/** Crawls /proc to find processes that are running as root. */
+class RootProcessScanner {
+
+    /** Processes that are allowed to run as root. */
+    private static final Pattern ROOT_PROCESS_WHITELIST_PATTERN = getRootProcessWhitelistPattern(
+            "debuggerd",
+            "init",
+            "installd",
+            "servicemanager",
+            "vold",
+            "zygote"
+    );
+
+    /** Combine the individual patterns into one super pattern. */
+    private static Pattern getRootProcessWhitelistPattern(String... patterns) {
+        StringBuilder rootProcessPattern = new StringBuilder();
+        for (int i = 0; i < patterns.length; i++) {
+            rootProcessPattern.append(patterns[i]);
+            if (i + 1 < patterns.length) {
+                rootProcessPattern.append('|');
+            }
+        }
+        return Pattern.compile(rootProcessPattern.toString());
+    }
+
+    /** Test that there are no unapproved root processes running on the system. */
+    public static String[] getRootProcesses()
+            throws FileNotFoundException, MalformedStatMException {
+        List<File> rootProcessDirs = getRootProcessDirs();
+        String[] rootProcessNames = new String[rootProcessDirs.size()];
+        for (int i = 0; i < rootProcessNames.length; i++) {
+            rootProcessNames[i] = getProcessName(rootProcessDirs.get(i));
+        }
+        return rootProcessNames;
+    }
+
+    private static List<File> getRootProcessDirs()
+            throws FileNotFoundException, MalformedStatMException {
+        File proc = new File("/proc");
+        if (!proc.exists()) {
+            throw new FileNotFoundException(proc + " is missing (man 5 proc)");
+        }
+
+        List<File> rootProcesses = new ArrayList<File>();
+        File[] processDirs = proc.listFiles();
+        if (processDirs != null && processDirs.length > 0) {
+            for (File processDir : processDirs) {
+                if (isUnapprovedRootProcess(processDir)) {
+                    rootProcesses.add(processDir);
+                }
+            }
+        }
+        return rootProcesses;
+    }
+
+    /**
+     * Filters out processes in /proc that are not approved.
+     * @throws FileNotFoundException
+     * @throws MalformedStatMException
+     */
+    private static boolean isUnapprovedRootProcess(File pathname)
+            throws FileNotFoundException, MalformedStatMException {
+        return isPidDirectory(pathname)
+                && !isKernelProcess(pathname)
+                && isRootProcess(pathname);
+    }
+
+    private static boolean isPidDirectory(File pathname) {
+        return pathname.isDirectory() && Pattern.matches("\\d+", pathname.getName());
+    }
+
+    private static boolean isKernelProcess(File processDir)
+            throws FileNotFoundException, MalformedStatMException {
+        File statm = getProcessStatM(processDir);
+        Scanner scanner = null;
+        try {
+            scanner = new Scanner(statm);
+
+            boolean allZero = true;
+            for (int i = 0; i < 7; i++) {
+                if (scanner.nextInt() != 0) {
+                    allZero = false;
+                }
+            }
+
+            if (scanner.hasNext()) {
+                throw new MalformedStatMException(processDir
+                        + " statm expected to have 7 integers (man 5 proc)");
+            }
+
+            return allZero;
+        } finally {
+            if (scanner != null) {
+                scanner.close();
+            }
+        }
+    }
+
+    private static File getProcessStatM(File processDir) {
+        return new File(processDir, "statm");
+    }
+
+    public static class MalformedStatMException extends Exception {
+        MalformedStatMException(String detailMessage) {
+            super(detailMessage);
+        }
+    }
+
+    /**
+     * Return whether or not this process is running as root without being approved.
+     *
+     * @param processDir with the status file
+     * @return whether or not it is a unwhitelisted root process
+     * @throws FileNotFoundException
+     */
+    private static boolean isRootProcess(File processDir) throws FileNotFoundException {
+        File status = getProcessStatus(processDir);
+        Scanner scanner = null;
+        try {
+            scanner = new Scanner(status);
+
+            scanner = findToken(scanner, "Name:");
+            String name = scanner.next();
+
+            scanner = findToken(scanner, "Uid:");
+            boolean rootUid = hasRootId(scanner);
+
+            scanner = findToken(scanner, "Gid:");
+            boolean rootGid = hasRootId(scanner);
+
+            return !ROOT_PROCESS_WHITELIST_PATTERN.matcher(name).matches()
+                    && (rootUid || rootGid);
+        } finally {
+            if (scanner != null) {
+                scanner.close();
+            }
+        }
+    }
+
+    /**
+     * Get the status {@link File} that has name:value pairs.
+     * <pre>
+     * Name:   init
+     * ...
+     * Uid:    0       0       0       0
+     * Gid:    0       0       0       0
+     * </pre>
+     */
+    private static File getProcessStatus(File processDir) {
+        return new File(processDir, "status");
+    }
+
+    /**
+     * Convenience method to move the scanner's position to the point after the given token.
+     *
+     * @param scanner to call next() until the token is found
+     * @param token to find like "Name:"
+     * @return scanner after finding token
+     */
+    private static Scanner findToken(Scanner scanner, String token) {
+        while (true) {
+            String next = scanner.next();
+            if (next.equals(token)) {
+                return scanner;
+            }
+        }
+
+        // Scanner will exhaust input and throw an exception before getting here.
+    }
+
+    /**
+     * Uid and Gid lines have four values: "Uid:    0       0       0       0"
+     *
+     * @param scanner that has just processed the "Uid:" or "Gid:" token
+     * @return whether or not any of the ids are root
+     */
+    private static boolean hasRootId(Scanner scanner) {
+        int realUid = scanner.nextInt();
+        int effectiveUid = scanner.nextInt();
+        int savedSetUid = scanner.nextInt();
+        int fileSystemUid = scanner.nextInt();
+        return realUid == 0 || effectiveUid == 0 || savedSetUid == 0 || fileSystemUid == 0;
+    }
+
+    /** Returns the name of the process corresponding to its process directory in /proc. */
+    private static String getProcessName(File processDir) throws FileNotFoundException {
+        File status = getProcessStatus(processDir);
+        Scanner scanner = new Scanner(status);
+        try {
+            scanner = findToken(scanner, "Name:");
+            return scanner.next();
+        } finally {
+            scanner.close();
+        }
+    }
+}
diff --git a/tools/host/src/com/android/cts/ConsoleUi.java b/tools/host/src/com/android/cts/ConsoleUi.java
index 27173a4..679ecc0 100644
--- a/tools/host/src/com/android/cts/ConsoleUi.java
+++ b/tools/host/src/com/android/cts/ConsoleUi.java
@@ -970,7 +970,7 @@
      * @param resultType The result type.
      */
     private void createPlanFromSession(final String name, TestSession ts, final String resultType)
-            throws FileNotFoundException, ParserConfigurationException,
+            throws FileNotFoundException, IOException, ParserConfigurationException,
             TransformerFactoryConfigurationError, TransformerException {
 
         HashMap<String, ArrayList<String>> selectedResult =
diff --git a/tools/host/src/com/android/cts/TestDevice.java b/tools/host/src/com/android/cts/TestDevice.java
index e384824..690742d 100644
--- a/tools/host/src/com/android/cts/TestDevice.java
+++ b/tools/host/src/com/android/cts/TestDevice.java
@@ -418,6 +418,8 @@
         public static final String IMEI = "imei";
         public static final String IMSI = "imsi";
         public static final String PHONE_NUMBER = "phoneNumber";
+        public static final String FEATURES = "features";
+        public static final String PROCESSES = "processes";
 
         private HashMap<String, String> mInfoMap;
 
@@ -785,6 +787,24 @@
         public String getPhoneNumber() {
             return mInfoMap.get(PHONE_NUMBER);
         }
+
+        /**
+         * Get features.
+         *
+         * @return Features.
+         */
+        public String getFeatures() {
+            return mInfoMap.get(FEATURES);
+        }
+
+        /**
+         * Get processes.
+         *
+         * @return Processes.
+         */
+        public String getProcesses() {
+            return mInfoMap.get(PROCESSES);
+        }
     }
 
     /**
diff --git a/tools/host/src/com/android/cts/TestSessionBuilder.java b/tools/host/src/com/android/cts/TestSessionBuilder.java
index c592476..b4e69f1 100644
--- a/tools/host/src/com/android/cts/TestSessionBuilder.java
+++ b/tools/host/src/com/android/cts/TestSessionBuilder.java
@@ -544,7 +544,7 @@
      */
     public void serialize(String planName,
             ArrayList<String> packageNames, HashMap<String, ArrayList<String>> selectedResult)
-            throws ParserConfigurationException, FileNotFoundException,
+            throws ParserConfigurationException, FileNotFoundException, IOException,
             TransformerFactoryConfigurationError, TransformerException {
         File plan = new File(HostConfig.getInstance().getPlanRepository()
                 .getPlanPath(planName));
diff --git a/tools/host/src/com/android/cts/TestSessionLog.java b/tools/host/src/com/android/cts/TestSessionLog.java
index f874cae..b37e5a2 100644
--- a/tools/host/src/com/android/cts/TestSessionLog.java
+++ b/tools/host/src/com/android/cts/TestSessionLog.java
@@ -69,6 +69,9 @@
     static final String ATTRIBUTE_BUILD_NAME = "buildName";
     static final String ATTRIBUTE_ARCH = "arch";
     static final String ATTRIBUTE_VALUE = "value";
+    static final String ATTRIBUTE_AVAILABLE = "available";
+    static final String ATTRIBUTE_TYPE = "type";
+    static final String ATTRIBUTE_UID = "uid";
 
     static final String ATTRIBUTE_PASS = "pass";
     static final String ATTRIBUTE_FAILED = "failed";
@@ -84,6 +87,10 @@
     static final String TAG_SUMMARY = "Summary";
     static final String TAG_SCREEN = "Screen";
     static final String TAG_BUILD_INFO = "BuildInfo";
+    static final String TAG_FEATURE_INFO = "FeatureInfo";
+    static final String TAG_FEATURE = "Feature";
+    static final String TAG_PROCESS_INFO = "ProcessInfo";
+    static final String TAG_PROCESS = "Process";
     static final String TAG_PHONE_SUB_INFO = "PhoneSubInfo";
     static final String TAG_TEST_RESULT = "TestResult";
     static final String TAG_TESTPACKAGE = "TestPackage";
@@ -327,6 +334,9 @@
                         DeviceParameterCollector.BUILD_ABI2, bldInfo.getBuildAbi2());
 
                 deviceSettingNode.appendChild(devInfoNode);
+
+                addFeatureInfo(doc, deviceSettingNode, bldInfo);
+                addProcessInfo(doc, deviceSettingNode, bldInfo);
             }
 
             Node hostInfo = doc.createElement(TAG_HOSTINFO);
@@ -393,6 +403,86 @@
     }
 
     /**
+     * Creates a {@link #TAG_FEATURE_INFO} tag with {@link #TAG_FEATURE} elements indicating
+     * what features are supported by the device. It parses a string from the deviceInfo argument
+     * that is in the form of "feature1:true;feature2:false;featuer3;true;" with a trailing
+     * semi-colon.
+     *
+     * <pre>
+     *  <FeatureInfo>
+     *     <Feature name="android.name.of.feature" available="true" />
+     *     ...
+     *   </FeatureInfo>
+     * </pre>
+     * @param document used to create elements
+     * @param parentNode to attach the FeatureInfo element to
+     * @param deviceInfo to get the feature data from
+     */
+    private void addFeatureInfo(Document document, Node parentNode,
+            DeviceParameterCollector deviceInfo) {
+        Node featureInfo = document.createElement(TAG_FEATURE_INFO);
+        parentNode.appendChild(featureInfo);
+
+        String features = deviceInfo.getFeatures();
+        if (features == null) {
+            features = "";
+        }
+
+        String[] featurePairs = features.split(";");
+        for (String featurePair : featurePairs) {
+            String[] nameTypeAvailability = featurePair.split(":");
+            if (nameTypeAvailability.length >= 3) {
+                Node feature = document.createElement(TAG_FEATURE);
+                featureInfo.appendChild(feature);
+
+                setAttribute(document, feature, ATTRIBUTE_NAME, nameTypeAvailability[0]);
+                setAttribute(document, feature, ATTRIBUTE_TYPE, nameTypeAvailability[1]);
+                setAttribute(document, feature, ATTRIBUTE_AVAILABLE, nameTypeAvailability[2]);
+            }
+        }
+    }
+
+    /**
+     * Creates a {@link #TAG_PROCESS_INFO} tag with {@link #TAG_PROCESS} elements indicating
+     * what particular processes of interest were running on the device. It parses a string from
+     * the deviceInfo argument that is in the form of "processName1;processName2;..." with a
+     * trailing semi-colon.
+     *
+     * <pre>
+     *   <ProcessInfo>
+     *     <Process name="long_cat_viewer" uid="0" />
+     *     ...
+     *   </ProcessInfo>
+     * </pre>
+     *
+     * @param document
+     * @param parentNode
+     * @param deviceInfo
+     */
+    private void addProcessInfo(Document document, Node parentNode,
+            DeviceParameterCollector deviceInfo) {
+        Node processInfo = document.createElement(TAG_PROCESS_INFO);
+        parentNode.appendChild(processInfo);
+
+        String rootProcesses = deviceInfo.getProcesses();
+        if (rootProcesses == null) {
+            rootProcesses = "";
+        }
+
+        String[] processNames = rootProcesses.split(";");
+        for (String processName : processNames) {
+            processName = processName.trim();
+            if (processName.length() > 0) {
+                Node process = document.createElement(TAG_PROCESS);
+                processInfo.appendChild(process);
+
+                setAttribute(document, process, ATTRIBUTE_NAME, processName);
+                setAttribute(document, process, ATTRIBUTE_UID, "0");
+            }
+        }
+    }
+
+    /**
      * Output TestSuite and result to XML DOM Document.
      *
      * @param doc The document.
@@ -443,7 +533,7 @@
                     testNode.appendChild(failedMessageNode);
                     setAttribute(doc, failedMessageNode,TAG_FAILED_MESSAGE, failedMessage);
 
-                    String stackTrace = result.getStackTrace();
+                    String stackTrace = sanitizeStackTrace(result.getStackTrace());
                     if (stackTrace != null) {
                         Node stackTraceNode = doc.createElement(TAG_STACK_TRACE);
                         failedMessageNode.appendChild(stackTraceNode);
@@ -462,6 +552,18 @@
     }
 
     /**
+     * Strip out any invalid XML characters that might cause the report to be unviewable.
+     * http://www.w3.org/TR/REC-xml/#dt-character
+     */
+    private static String sanitizeStackTrace(String trace) {
+        if (trace != null) {
+            return trace.replaceAll("[^\\u0009\\u000A\\u000D\\u0020-\\uD7FF\\uE000-\\uFFFD]", "");
+        } else {
+            return null;
+        }
+    }
+
+    /**
      * Fetch failed file name and line number
      *
      * @param failedResult failed message
diff --git a/tools/host/src/com/android/cts/XMLResourceHandler.java b/tools/host/src/com/android/cts/XMLResourceHandler.java
index f77b27b..f44a574 100644
--- a/tools/host/src/com/android/cts/XMLResourceHandler.java
+++ b/tools/host/src/com/android/cts/XMLResourceHandler.java
@@ -18,6 +18,7 @@
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
+import java.io.IOException;
 
 import javax.xml.transform.Transformer;
 import javax.xml.transform.TransformerException;
@@ -125,11 +126,16 @@
      * @param doc DOM Document
      */
     protected static void writeToFile(File file, Document doc) throws FileNotFoundException,
-            TransformerFactoryConfigurationError, TransformerException {
+            IOException, TransformerFactoryConfigurationError, TransformerException {
         Transformer t = TransformerFactory.newInstance().newTransformer();
         // enable indent in result file
         t.setOutputProperty("indent", "yes");
-        t.transform(new DOMSource(doc),
-                new StreamResult(new FileOutputStream(file)));
+        FileOutputStream fos = new FileOutputStream(file);
+        try {
+            StreamResult sr = new StreamResult(fos);
+            t.transform(new DOMSource(doc), sr);
+        } finally {
+            fos.close();
+        }
     }
 }
diff --git a/tools/host/src/res/cts_result.css b/tools/host/src/res/cts_result.css
index 869c4dd..b5b4009 100644
--- a/tools/host/src/res/cts_result.css
+++ b/tools/host/src/res/cts_result.css
@@ -66,6 +66,7 @@
     border-color: gray;
     border-style: inset;
     font-size:1em;
+    vertical-align: top;
 }
 
 #summaryinfo table {
@@ -79,6 +80,7 @@
 #summaryinfo td {
     padding:1px;
     border-width: 0px 0px 0px 0px;
+    vertical-align: top;
 }
 
 /* The test summary */
diff --git a/tools/host/src/res/cts_result.xsl b/tools/host/src/res/cts_result.xsl
index 8f5f77c..72b0f86 100644
--- a/tools/host/src/res/cts_result.xsl
+++ b/tools/host/src/res/cts_result.xsl
@@ -116,7 +116,9 @@
                                     <TR>
                                         <TD class="rowtitle">Supported Locales</TD>
                                         <TD>
-                                            <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@locales"/>
+                                            <xsl:call-template name="formatDelimitedString">
+                                                <xsl:with-param name="string" select="TestResult/DeviceInfo/BuildInfo/@locales"/>
+                                            </xsl:call-template>
                                         </TD>
                                     </TR>
                                     <TR>
@@ -179,6 +181,46 @@
                                             <xsl:value-of select="TestResult/DeviceInfo/BuildInfo/@imsi"/>
                                         </TD>
                                     </TR>
+                                    <TR>
+                                        <TD class="rowtitle">Features</TD>
+                                        <TD>
+                                            <xsl:for-each select="TestResult/DeviceInfo/FeatureInfo/Feature[@type='sdk']">
+                                                <xsl:text>[</xsl:text>
+                                                <xsl:choose>
+                                                    <xsl:when test="@available = 'true'">
+                                                        <xsl:text>X</xsl:text>
+                                                    </xsl:when>
+                                                    <xsl:otherwise>
+                                                        <xsl:text>_</xsl:text>
+                                                    </xsl:otherwise>
+                                                </xsl:choose>
+                                                <xsl:text>] </xsl:text>
+
+                                                <xsl:value-of select="@name" />
+                                                <br />
+                                            </xsl:for-each>
+                                        </TD>
+                                    </TR>
+                                    <TR>
+                                        <TD class="rowtitle">Other Features</TD>
+                                        <TD>
+                                            <UL>
+                                                <xsl:for-each select="TestResult/DeviceInfo/FeatureInfo/Feature[@type='other']">
+                                                    <LI><xsl:value-of select="@name" /></LI>
+                                                </xsl:for-each>
+                                            </UL>
+                                        </TD>
+                                    </TR>
+                                    <TR>
+                                        <TD class="rowtitle">Root Processes</TD>
+                                        <TD>
+                                            <UL>
+                                                <xsl:for-each select="TestResult/DeviceInfo/ProcessInfo/Process[@uid='0']">
+                                                    <LI><xsl:value-of select="@name" /></LI>
+                                                </xsl:for-each>
+                                            </UL>
+                                        </TD>
+                                    </TR>
                                 </TABLE>
                             </div>
                         </TD>
@@ -417,10 +459,31 @@
                     </TABLE>
                 </xsl:for-each> <!-- end test package -->
             </DIV>
+            </body>
+        </html>
+    </xsl:template>
 
-        </body>
-    </html>
-</xsl:template>
+    <!-- Take a delimited string and insert line breaks after a some number of elements. --> 
+    <xsl:template name="formatDelimitedString">
+        <xsl:param name="string" />
+        <xsl:param name="numTokensPerRow" select="10" />
+        <xsl:param name="tokenIndex" select="1" />
+        <xsl:if test="$string">
+            <!-- Requires the last element to also have a delimiter after it. -->
+            <xsl:variable name="token" select="substring-before($string, ';')" />
+            <xsl:value-of select="$token" />
+            <xsl:text>&#160;</xsl:text>
+          
+            <xsl:if test="$tokenIndex mod $numTokensPerRow = 0">
+                <br />
+            </xsl:if>
 
+            <xsl:call-template name="formatDelimitedString">
+                <xsl:with-param name="string" select="substring-after($string, ';')" />
+                <xsl:with-param name="numTokensPerRow" select="$numTokensPerRow" />
+                <xsl:with-param name="tokenIndex" select="$tokenIndex + 1" />
+            </xsl:call-template>
+        </xsl:if>
+    </xsl:template>
 
 </xsl:stylesheet>
diff --git a/tools/utils/buildCts.py b/tools/utils/buildCts.py
index b3e9183..b1a6700 100755
--- a/tools/utils/buildCts.py
+++ b/tools/utils/buildCts.py
@@ -121,6 +121,7 @@
     """Generate the test description for the signature check."""
     self.__LogGenerateDescription('android.tests.sigtest')
     package = tools.TestPackage('SignatureTest', 'android.tests.sigtest')
+    package.AddAttribute('appNameSpace', 'android.tests.sigtest')
     package.AddAttribute('signatureCheck', 'true')
     package.AddAttribute('runner', '.InstrumentationRunner')
     package.AddTest('android.tests.sigtest.SignatureTest.signatureTest')
@@ -132,6 +133,7 @@
     """Generate the test description for the reference app tests."""
     self.__LogGenerateDescription('android.apidemos.cts')
     package = tools.TestPackage('ApiDemosReferenceTest', 'android.apidemos.cts')
+    package.AddAttribute('appNameSpace', 'android.apidemos.cts')
     package.AddAttribute('packageToTest', 'com.example.android.apis')
     package.AddAttribute('apkToTestName', 'ApiDemos')
     package.AddAttribute('runner', 'android.test.InstrumentationTestRunner')