Merge remote branch 'goog/honeycomb' into honeycomb-mr1
diff --git a/CtsTestCaseList.mk b/CtsTestCaseList.mk
index 51d7491..bf67a15 100644
--- a/CtsTestCaseList.mk
+++ b/CtsTestCaseList.mk
@@ -37,6 +37,7 @@
 	CtsDatabaseTestCases \
 	CtsDpiTestCases \
 	CtsDpiTestCases2 \
+	CtsDrmTestCases \
 	CtsExampleTestCases \
 	CtsGestureTestCases \
 	CtsGraphicsTestCases \
@@ -51,6 +52,7 @@
 	CtsPermission2TestCases \
 	CtsPreferenceTestCases \
 	CtsProviderTestCases \
+	CtsRenderscriptTestCases \
 	CtsSaxTestCases \
 	CtsSecurityTestCases \
 	CtsSpeechTestCases \
@@ -71,3 +73,6 @@
 	ApiDemosReferenceTest \
 	$(CTS_COVERAGE_TEST_CASE_LIST) \
 	$(CTS_SECURITY_APPS_LIST)
+
+# The following files will be placed in the tools directory of the CTS distribution
+CTS_TOOLS_LIST :=
diff --git a/apps/CtsVerifier/Android.mk b/apps/CtsVerifier/Android.mk
index fb7f8a6..4176676 100644
--- a/apps/CtsVerifier/Android.mk
+++ b/apps/CtsVerifier/Android.mk
@@ -55,10 +55,11 @@
 verifier-zip := $(cts-dir)/$(verifier-zip-name)
 
 cts : $(verifier-zip)
-$(verifier-zip) : CtsVerifier $(ACP)
+$(verifier-zip) : CtsVerifier $(ACP) $(HOST_OUT)/bin/cts-usb-accessory
 		$(hide) mkdir -p $(verifier-dir)
 		$(hide) $(ACP) -fp $(call intermediates-dir-for,APPS,CtsVerifier)/package.apk \
 				$(verifier-dir)/CtsVerifier.apk
+		$(hide) $(ACP) -fp $(HOST_OUT)/bin/cts-usb-accessory $(verifier-dir)/cts-usb-accessory
 		$(hide) cd $(cts-dir) && zip -rq $(verifier-dir-name) $(verifier-dir-name)
 
 ifneq ($(filter cts, $(MAKECMDGOALS)),)
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index 112a8d4..b1e4ef3 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -17,8 +17,8 @@
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
       package="com.android.cts.verifier"
-      android:versionCode="1"
-      android:versionName="3.0_r1">
+      android:versionCode="2"
+      android:versionName="3.1_r2">
 
     <!-- Using 10 for more complete NFC support... -->
     <uses-sdk android:minSdkVersion="10"></uses-sdk>
@@ -47,7 +47,20 @@
             </intent-filter>
         </activity>
 
-        <activity android:name=".TestListActivity" android:label="@string/test_list_title" />
+        <activity android:name=".TestListActivity" android:label="@string/app_name">
+            <!--
+                TestListActivity will have the USB accessory Test in its test list, but it
+                does not have any code to handle the USB accessory. The test has to be started
+                from TestListActivity or the pass/fail status won't be properly recorded. Also
+                this is to prevent the dialog saying there is no application able to support the
+                accessory from being shown.
+            -->
+            <intent-filter>
+                <action android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED" />
+            </intent-filter>
+            <meta-data android:name="android.hardware.usb.action.USB_ACCESSORY_ATTACHED"
+                    android:resource="@xml/accessory_filter" />
+        </activity>
 
         <activity android:name=".ReportViewerActivity"
                 android:configChanges="keyboardHidden|orientation"
@@ -256,6 +269,17 @@
 
         <service android:name=".audioquality.ExperimentService" />
 
+        <activity android:name=".usb.UsbAccessoryTestActivity"
+                android:label="@string/usb_accessory_test"
+                android:configChanges="keyboardHidden|orientation">
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+                <category android:name="android.cts.intent.category.MANUAL_TEST" />
+            </intent-filter>
+            <meta-data android:name="test_category" android:value="@string/test_category_hardware" />
+            <meta-data android:name="test_required_features" android:value="android.hardware.usb.accessory" />
+        </activity>
+
    </application>
 
 </manifest> 
diff --git a/apps/CtsVerifier/res/layout-land/usb_main.xml b/apps/CtsVerifier/res/layout-land/usb_main.xml
new file mode 100644
index 0000000..139b54b
--- /dev/null
+++ b/apps/CtsVerifier/res/layout-land/usb_main.xml
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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:orientation="vertical"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        >
+    <LinearLayout android:orientation="horizontal"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:layout_weight="1"
+            >
+        <LinearLayout android:orientation="vertical"
+                android:layout_width="1px"
+                android:layout_height="match_parent"
+                android:layout_weight="1"
+                >
+            <TextView android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:text="@string/usb_sent_messages"
+                    style="?android:attr/listSeparatorTextViewStyle"
+                    />
+            <FrameLayout android:orientation="vertical"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1"
+                    >
+                <ListView android:id="@+id/usb_sent_messages"
+                        android:layout_width="match_parent"
+                        android:layout_height="match_parent"
+                        />
+                <TextView android:id="@+id/usb_empty_sent_messages"
+                        android:layout_width="match_parent"
+                        android:layout_height="match_parent"
+                        android:gravity="center"
+                        android:text="@string/usb_no_messages"
+                        android:visibility="gone"
+                        />
+            </FrameLayout>
+        </LinearLayout>
+        <include layout="@layout/vertical_divider" />
+        <LinearLayout android:orientation="vertical"
+                android:layout_width="1px"
+                android:layout_height="match_parent"
+                android:layout_weight="1"
+                >
+            <TextView android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:text="@string/usb_received_messages"
+                    style="?android:attr/listSeparatorTextViewStyle"
+                    />
+            <FrameLayout android:orientation="vertical"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_weight="1"
+                    >
+                <ListView android:id="@+id/usb_received_messages"
+                        android:layout_width="match_parent"
+                        android:layout_height="match_parent"
+                        />
+                <TextView android:id="@+id/usb_empty_received_messages"
+                        android:layout_width="match_parent"
+                        android:layout_height="match_parent"
+                        android:gravity="center"
+                        android:text="@string/usb_no_messages"
+                        android:visibility="gone"
+                        />
+            </FrameLayout>
+        </LinearLayout>
+    </LinearLayout>
+
+    <include layout="@layout/pass_fail_buttons" />
+
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/bt_message_row.xml b/apps/CtsVerifier/res/layout/bt_message_row.xml
index c37eece..3bb228a 100644
--- a/apps/CtsVerifier/res/layout/bt_message_row.xml
+++ b/apps/CtsVerifier/res/layout/bt_message_row.xml
@@ -16,6 +16,5 @@
 <TextView xmlns:android="http://schemas.android.com/apk/res/android"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
-        android:textSize="18sp"
-        android:padding="5dp"
+        style="@style/MessageRow"
         />
diff --git a/apps/CtsVerifier/res/layout/usb_main.xml b/apps/CtsVerifier/res/layout/usb_main.xml
new file mode 100644
index 0000000..5c16612
--- /dev/null
+++ b/apps/CtsVerifier/res/layout/usb_main.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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:orientation="vertical"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        >
+    <TextView android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:text="@string/usb_sent_messages"
+            style="?android:attr/listSeparatorTextViewStyle"
+            />
+    <FrameLayout android:orientation="vertical"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_weight="1"
+            >
+        <ListView android:id="@+id/usb_sent_messages"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                />
+        <TextView android:id="@+id/usb_empty_sent_messages"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:gravity="center"
+                android:text="@string/usb_no_messages"
+                android:visibility="gone"
+                />
+    </FrameLayout>
+
+    <TextView android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:text="@string/usb_received_messages"
+            style="?android:attr/listSeparatorTextViewStyle"
+            />
+    <FrameLayout android:orientation="vertical"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:layout_weight="1"
+            >
+        <ListView android:id="@+id/usb_received_messages"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                />
+        <TextView android:id="@+id/usb_empty_received_messages"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:gravity="center"
+                android:text="@string/usb_no_messages"
+                android:visibility="gone"
+                />
+    </FrameLayout>
+
+    <include layout="@layout/pass_fail_buttons" />
+
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/usb_message_row.xml b/apps/CtsVerifier/res/layout/usb_message_row.xml
new file mode 100644
index 0000000..3bb228a
--- /dev/null
+++ b/apps/CtsVerifier/res/layout/usb_message_row.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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="match_parent"
+        android:layout_height="wrap_content"
+        style="@style/MessageRow"
+        />
diff --git a/apps/CtsVerifier/res/layout/vertical_divider.xml b/apps/CtsVerifier/res/layout/vertical_divider.xml
new file mode 100644
index 0000000..068ff8e
--- /dev/null
+++ b/apps/CtsVerifier/res/layout/vertical_divider.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+<View xmlns:android="http://schemas.android.com/apk/res/android"
+        android:background="#333"
+        android:layout_width="1px"
+        android:layout_height="match_parent"
+        />
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index a0faf71..f3d0c14 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -363,6 +363,29 @@
     <string name="aq_recording_error">Error reading data from AudioRecord instance</string>
     <string name="aq_exception_error">Exception thrown during test: %1$s</string>
 
+    <!-- Strings for USB accessory test activity -->
+    <string name="usb_accessory_test">USB Accessory Test</string>
+    <string name="usb_accessory_test_info">
+        1. Connect your Android device to a computer and run the \'cts-usb-accessory\' program 
+        included with the CTS Verifier bundle.
+        \n\n2. If you have not started the CTS Verifier, press \'OK\' when asked to open the CTS
+        Verifier when the accessory is connected. \n\nIf you are already in this test,
+        then you can press \'Cancel\' but press \'OK\' in the next dialog asking whether to allow
+        CTS Verifier to access the accessory.
+        \n\n3. You should see the accessory and the CTS Verifier display a series of messages
+        which indicates that the accessory support is working properly.
+    </string>
+    <string name="usb_not_available_title">USB accessory feature is not available?</string>
+    <string name="usb_not_available_message">If your device is supposed to support USB accessories, your API implementation is not behaving correctly!</string>
+    <string name="usb_received_messages">Received Messages</string>
+    <string name="usb_sent_messages">Sent Messages</string>
+    <string name="usb_no_messages">No messages</string>
+    <string name="usb_message_thread_started">Starting message processing...</string>
+    <string name="usb_message_thread_exception">Exception occurred while processing a message...</string>
+    <string name="usb_message_thread_ended">Stopping message processing...</string>
+    <string name="usb_test_passed">Received all expected messages. Pass button enabled!</string>
+    <string name="usb_file_descriptor_error">Could not open file descriptor for USB accessory... try reconnecting and restarting the accessory?</string>
+
     <!-- Strings for StreamingVideoActivity -->
     <string name="streaming_video">Streaming Video Quality Verifier</string>
     <string name="streaming_video_info">This is a test for assessing the quality of streaming videos.  Play each stream and verify that the video is smooth and in sync with the audio, and that there are no quality problems.</string>
diff --git a/apps/CtsVerifier/res/values/styles.xml b/apps/CtsVerifier/res/values/styles.xml
index b5dd7cc..51f996d 100644
--- a/apps/CtsVerifier/res/values/styles.xml
+++ b/apps/CtsVerifier/res/values/styles.xml
@@ -9,4 +9,9 @@
     <style name="VersionFont" parent="@android:style/TextAppearance.Large">
         <item name="android:textColor">#ffffff</item>
     </style>
-</resources>
\ No newline at end of file
+    <style name="MessageRow">
+        <item name="android:gravity">center_vertical</item>
+        <item name="android:textSize">18sp</item>
+        <item name="android:padding">5dp</item>
+    </style>
+</resources>
diff --git a/apps/CtsVerifier/res/xml/accessory_filter.xml b/apps/CtsVerifier/res/xml/accessory_filter.xml
new file mode 100644
index 0000000..21caaa4
--- /dev/null
+++ b/apps/CtsVerifier/res/xml/accessory_filter.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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>
+    <usb-accessory manufacturer="Android CTS" model="CTS USB Accessory" version="1.0" />
+</resources>
\ No newline at end of file
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
index 35b26aa..6ed4773 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/features/FeatureSummaryActivity.java
@@ -152,6 +152,11 @@
             new Feature("android.hardware.faketouch", true),
     };
 
+    public static final Feature[] ALL_HONEYCOMB_MR1_FEATURES = {
+            new Feature("android.hardware.usb.host", false),
+            new Feature("android.hardware.usb.accessory", true),
+    };
+
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
@@ -182,6 +187,9 @@
 
         // add features from latest to last so that the latest requirements are put in the set first
         int apiVersion = Build.VERSION.SDK_INT;
+        if (apiVersion >= Build.VERSION_CODES.HONEYCOMB_MR1) {
+            Collections.addAll(features, ALL_HONEYCOMB_MR1_FEATURES);
+        }
         if (apiVersion >= Build.VERSION_CODES.HONEYCOMB) {
             Collections.addAll(features, ALL_HONEYCOMB_FEATURES);
         }
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/usb/UsbAccessoryTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/usb/UsbAccessoryTestActivity.java
new file mode 100644
index 0000000..4132807
--- /dev/null
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/usb/UsbAccessoryTestActivity.java
@@ -0,0 +1,354 @@
+/*
+ * Copyright (C) 2011 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 com.android.cts.verifier.usb;
+
+import com.android.cts.verifier.PassFailButtons;
+import com.android.cts.verifier.R;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.app.PendingIntent;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.pm.PackageManager;
+import android.content.res.Configuration;
+import android.hardware.usb.UsbAccessory;
+import android.hardware.usb.UsbManager;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.Message;
+import android.os.ParcelFileDescriptor;
+import android.util.Log;
+import android.view.View;
+import android.widget.ArrayAdapter;
+import android.widget.ListView;
+import android.widget.Toast;
+
+import java.io.FileDescriptor;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * Test for USB accessories. The test activity interacts with a cts-usb-accessory program that
+ * acts as an accessory by exchanging a series of messages.
+ */
+public class UsbAccessoryTestActivity extends PassFailButtons.Activity {
+
+    private static final String TAG = UsbAccessoryTestActivity.class.getSimpleName();
+
+    private static final int FILE_DESCRIPTOR_PROBLEM_DIALOG_ID = 1;
+
+    private static final String ACTION_USB_PERMISSION =
+            "com.android.cts.verifier.usb.USB_PERMISSION";
+
+    private ArrayAdapter<String> mReceivedMessagesAdapter;
+    private ArrayAdapter<String> mSentMessagesAdapter;
+    private MessageHandler mHandler;
+
+    private UsbManager mUsbManager;
+    private PendingIntent mPermissionIntent;
+    private boolean mPermissionRequestPending;
+    private UsbReceiver mUsbReceiver;
+
+    private ParcelFileDescriptor mFileDescriptor;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        setContentView(R.layout.usb_main);
+        setInfoResources(R.string.usb_accessory_test, R.string.usb_accessory_test_info, -1);
+        setPassFailButtonClickListeners();
+
+        // Don't allow a test pass until the accessory and the Android device exchange messages...
+        getPassButton().setEnabled(false);
+
+        if (!hasUsbAccessorySupport()) {
+            showNoUsbAccessoryDialog();
+        }
+
+        mReceivedMessagesAdapter = new ArrayAdapter<String>(this, R.layout.usb_message_row);
+        mSentMessagesAdapter = new ArrayAdapter<String>(this, R.layout.usb_message_row);
+        mHandler = new MessageHandler();
+
+        mUsbManager = (UsbManager) getSystemService(USB_SERVICE);
+        mPermissionIntent = PendingIntent.getBroadcast(this, 0,
+                new Intent(ACTION_USB_PERMISSION), 0);
+
+        mUsbReceiver = new UsbReceiver();
+        IntentFilter filter = new IntentFilter(ACTION_USB_PERMISSION);
+        filter.addAction(UsbManager.ACTION_USB_ACCESSORY_ATTACHED);
+        registerReceiver(mUsbReceiver, filter);
+
+        setupListViews();
+    }
+
+    private boolean hasUsbAccessorySupport() {
+        return getPackageManager().hasSystemFeature(PackageManager.FEATURE_USB_ACCESSORY);
+    }
+
+    private void showNoUsbAccessoryDialog() {
+        new AlertDialog.Builder(this)
+            .setIcon(android.R.drawable.ic_dialog_alert)
+            .setTitle(R.string.usb_not_available_title)
+            .setMessage(R.string.usb_not_available_message)
+            .setCancelable(false)
+            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+                @Override
+                public void onClick(DialogInterface dialog, int which) {
+                    finish();
+                }
+            })
+            .show();
+    }
+
+    private void setupListViews() {
+        ListView sentMessages = (ListView) findViewById(R.id.usb_sent_messages);
+        ListView receivedMessages = (ListView) findViewById(R.id.usb_received_messages);
+
+        View emptySentView = findViewById(R.id.usb_empty_sent_messages);
+        View emptyReceivedView = findViewById(R.id.usb_empty_received_messages);
+        sentMessages.setEmptyView(emptySentView);
+        receivedMessages.setEmptyView(emptyReceivedView);
+
+        receivedMessages.setAdapter(mReceivedMessagesAdapter);
+        sentMessages.setAdapter(mSentMessagesAdapter);
+    }
+
+    class UsbReceiver extends BroadcastReceiver {
+        @Override
+        public void onReceive(Context context, Intent intent) {
+            if (ACTION_USB_PERMISSION.equals(intent.getAction())
+                    || UsbManager.ACTION_USB_ACCESSORY_ATTACHED.equals(intent.getAction())) {
+                UsbAccessory accessory = intent.getParcelableExtra(UsbManager.EXTRA_ACCESSORY);
+                if (intent.getBooleanExtra(UsbManager.EXTRA_PERMISSION_GRANTED, false)) {
+                    openAccessory(accessory);
+                } else {
+                    Log.i(TAG, "Permission denied...");
+                }
+                mPermissionRequestPending = false;
+            }
+        }
+    }
+
+    private void openAccessory(UsbAccessory accessory) {
+        mFileDescriptor = mUsbManager.openAccessory(accessory);
+        if (mFileDescriptor != null) {
+            FileDescriptor fileDescriptor = mFileDescriptor.getFileDescriptor();
+            FileInputStream inputStream = new FileInputStream(fileDescriptor);
+            FileOutputStream outputStream = new FileOutputStream(fileDescriptor);
+            new MessageThread(inputStream, outputStream, mHandler).start();
+        } else {
+            showDialog(FILE_DESCRIPTOR_PROBLEM_DIALOG_ID);
+        }
+    }
+
+    static class MessageThread extends Thread {
+
+        private final InputStream mInputStream;
+
+        private final OutputStream mOutputStream;
+
+        private final MessageHandler mHandler;
+
+        private int mNextMessageNumber = 0;
+
+        MessageThread(InputStream inputStream, OutputStream outputStream, MessageHandler handler) {
+            this.mInputStream = inputStream;
+            this.mOutputStream = outputStream;
+            this.mHandler = handler;
+        }
+
+        @Override
+        public void run() {
+            mHandler.sendEmptyMessage(MessageHandler.MESSAGE_THREAD_STARTING);
+
+            try {
+                // Wait a bit or else the messages can appear to quick and be confusing...
+                Thread.sleep(2000);
+                sendMessage();
+
+                // Wait for response and send message acks...
+                int numRead = 0;
+                byte[] buffer = new byte[16384];
+                while (numRead >= 0) {
+                    numRead = mInputStream.read(buffer);
+                    if (numRead > 0) {
+                        handleReceivedMessage(buffer, numRead);
+                    }
+                }
+            } catch (IOException e) {
+                Log.e(TAG, "Exception while reading from input stream", e);
+                mHandler.sendEmptyMessage(MessageHandler.MESSAGE_THREAD_EXCEPTION);
+            } catch (InterruptedException e) {
+                Log.e(TAG, "Exception while reading from input stream", e);
+                mHandler.sendEmptyMessage(MessageHandler.MESSAGE_THREAD_EXCEPTION);
+            }
+            mHandler.sendEmptyMessage(MessageHandler.MESSAGE_THREAD_ENDING);
+        }
+
+        private void handleReceivedMessage(byte[] buffer, int numRead) throws IOException {
+            // TODO: Check the contents of the message?
+            String text = new String(buffer, 0, numRead).trim();
+            mHandler.sendReceivedMessage(text);
+
+            // Send back a response..
+            if (mNextMessageNumber <= 10) {
+                sendMessage();
+            } else {
+                mHandler.sendEmptyMessage(MessageHandler.TEST_PASSED);
+            }
+        }
+
+        private void sendMessage() throws IOException {
+            String text = "Message from Android device #" + mNextMessageNumber++;
+            mOutputStream.write(text.getBytes());
+            mHandler.sendSentMessage(text);
+        }
+    }
+
+    class MessageHandler extends Handler {
+
+        static final int RECEIVED_MESSAGE = 1;
+
+        static final int SENT_MESSAGE = 2;
+
+        static final int MESSAGE_THREAD_STARTING = 3;
+
+        static final int MESSAGE_THREAD_EXCEPTION = 4;
+
+        static final int MESSAGE_THREAD_ENDING = 5;
+
+        static final int TEST_PASSED = 6;
+
+        @Override
+        public void handleMessage(Message msg) {
+            super.handleMessage(msg);
+            switch (msg.what) {
+                case RECEIVED_MESSAGE:
+                    mReceivedMessagesAdapter.add((String) msg.obj);
+                    break;
+
+                case SENT_MESSAGE:
+                    mSentMessagesAdapter.add((String) msg.obj);
+                    break;
+
+                case MESSAGE_THREAD_STARTING:
+                    showToast(R.string.usb_message_thread_started);
+                    break;
+
+                case MESSAGE_THREAD_EXCEPTION:
+                    showToast(R.string.usb_message_thread_exception);
+                    break;
+
+                case MESSAGE_THREAD_ENDING:
+                    showToast(R.string.usb_message_thread_ended);
+                    break;
+
+                case TEST_PASSED:
+                    showToast(R.string.usb_test_passed);
+                    getPassButton().setEnabled(true);
+                    break;
+
+                default:
+                    throw new IllegalArgumentException("Bad message type: " + msg.what);
+            }
+        }
+
+        private void showToast(int messageId) {
+            Toast.makeText(UsbAccessoryTestActivity.this, messageId, Toast.LENGTH_SHORT).show();
+        }
+
+        void sendReceivedMessage(String text) {
+            Message message = Message.obtain(this, RECEIVED_MESSAGE);
+            message.obj = text;
+            sendMessage(message);
+        }
+
+        void sendSentMessage(String text) {
+            Message message = Message.obtain(this, SENT_MESSAGE);
+            message.obj = text;
+            sendMessage(message);
+        }
+    }
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        UsbAccessory[] accessories = mUsbManager.getAccessoryList();
+        UsbAccessory accessory = accessories != null && accessories.length > 0
+                ? accessories[0]
+                : null;
+        if (accessory != null) {
+            if (mUsbManager.hasPermission(accessory)) {
+                openAccessory(accessory);
+            } else {
+                if (!mPermissionRequestPending) {
+                    mUsbManager.requestPermission(accessory, mPermissionIntent);
+                    mPermissionRequestPending = true;
+                }
+            }
+        }
+    }
+
+    @Override
+    protected void onPause() {
+        super.onPause();
+        if (mFileDescriptor != null) {
+            try {
+                mFileDescriptor.close();
+            } catch (IOException e) {
+                Log.e(TAG, "Exception while closing file descriptor", e);
+            } finally {
+                mFileDescriptor = null;
+            }
+        }
+    }
+
+    @Override
+    public void onConfigurationChanged(Configuration newConfig) {
+        super.onConfigurationChanged(newConfig);
+        setContentView(R.layout.usb_main);
+        setupListViews();
+    }
+
+    @Override
+    public Dialog onCreateDialog(int id, Bundle args) {
+        switch (id) {
+            case FILE_DESCRIPTOR_PROBLEM_DIALOG_ID:
+                return new AlertDialog.Builder(this)
+                    .setIcon(android.R.drawable.ic_dialog_alert)
+                    .setTitle(R.string.usb_accessory_test)
+                    .setMessage(R.string.usb_file_descriptor_error)
+                    .create();
+
+            default:
+                return super.onCreateDialog(id, args);
+        }
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        unregisterReceiver(mUsbReceiver);
+    }
+}
diff --git a/apps/cts-usb-accessory/Android.mk b/apps/cts-usb-accessory/Android.mk
new file mode 100644
index 0000000..c4d014f
--- /dev/null
+++ b/apps/cts-usb-accessory/Android.mk
@@ -0,0 +1,36 @@
+#
+# Copyright (C) 2011 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.
+#
+
+# Build for Linux (desktop) host
+ifeq ($(HOST_OS),linux)
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SRC_FILES := cts-usb-accessory.c
+
+LOCAL_MODULE := cts-usb-accessory
+
+LOCAL_C_INCLUDES += bionic/libc/kernel/common
+LOCAL_STATIC_LIBRARIES := libusbhost libcutils
+LOCAL_LDLIBS += -lpthread
+LOCAL_CFLAGS := -g -O0
+
+include $(BUILD_HOST_EXECUTABLE)
+
+endif
diff --git a/apps/cts-usb-accessory/cts-usb-accessory.c b/apps/cts-usb-accessory/cts-usb-accessory.c
new file mode 100644
index 0000000..4e747bb
--- /dev/null
+++ b/apps/cts-usb-accessory/cts-usb-accessory.c
@@ -0,0 +1,194 @@
+/*
+ * Copyright (C) 2011 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.
+ */
+
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <pthread.h>
+#include <time.h>
+
+#include <usbhost/usbhost.h>
+#include <linux/usb/f_accessory.h>
+
+struct usb_device *sDevice = NULL;
+
+static void* message_thread(void* arg) {
+    int *endpoints = (int *)arg;
+    int ret = 0;
+    int num = 0;
+    char message[50];
+
+    while (sDevice && ret >= 0) {
+        char buffer[16384];
+        ret = usb_device_bulk_transfer(sDevice, endpoints[0], buffer, sizeof(buffer), 1000);
+        if (ret < 0 && errno == ETIMEDOUT) {
+            ret = 0;
+        }
+        if (ret > 0) {
+            printf("[RECV] ");
+            fwrite(buffer, 1, ret, stdout);
+            printf("\n");
+
+            // Respond by sending a message back
+            sprintf(message, "Message from Android accessory #%d", num++);
+            printf("[SENT] %s\n", message);
+            fflush(stdout);
+            usb_device_bulk_transfer(sDevice, endpoints[1], message, strlen(message), 1000);
+        }
+    }
+
+    return NULL;
+}
+
+static void milli_sleep(int millis) {
+    struct timespec tm;
+
+    tm.tv_sec = 0;
+    tm.tv_nsec = millis * 1000000;
+    nanosleep(&tm, NULL);
+}
+
+static void send_string(struct usb_device *device, int index, const char* string) {
+    int ret = usb_device_control_transfer(device, USB_DIR_OUT | USB_TYPE_VENDOR,
+            ACCESSORY_SEND_STRING, 0, index, (void *)string, strlen(string) + 1, 0);
+
+    // some devices can't handle back-to-back requests, so delay a bit
+    milli_sleep(10);
+}
+
+static int usb_device_added(const char *devname, void* client_data) {
+    struct usb_descriptor_header* desc;
+    struct usb_descriptor_iter iter;
+    uint16_t vendorId, productId;
+    int ret;
+    pthread_t th;
+
+    struct usb_device *device = usb_device_open(devname);
+    if (!device) {
+        fprintf(stderr, "usb_device_open failed\n");
+        return 0;
+    }
+
+    vendorId = usb_device_get_vendor_id(device);
+    productId = usb_device_get_product_id(device);
+
+    if (!sDevice && (vendorId == 0x18D1 && (productId == 0x2D00 || productId == 0x2D01))) {
+        struct usb_descriptor_header* desc;
+        struct usb_descriptor_iter iter;
+        struct usb_interface_descriptor *intf = NULL;
+        struct usb_endpoint_descriptor *ep1 = NULL;
+        struct usb_endpoint_descriptor *ep2 = NULL;
+
+        printf("Found Android device in accessory mode (%x:%x)...\n",
+               vendorId, productId);
+        sDevice = device;
+
+        usb_descriptor_iter_init(device, &iter);
+        while ((desc = usb_descriptor_iter_next(&iter)) != NULL && (!intf || !ep1 || !ep2)) {
+            if (desc->bDescriptorType == USB_DT_INTERFACE) {
+                intf = (struct usb_interface_descriptor *)desc;
+            } else if (desc->bDescriptorType == USB_DT_ENDPOINT) {
+                if (ep1)
+                    ep2 = (struct usb_endpoint_descriptor *)desc;
+                else
+                    ep1 = (struct usb_endpoint_descriptor *)desc;
+            }
+        }
+
+        if (!intf) {
+            fprintf(stderr, "Interface not found\n");
+            exit(1);
+        }
+        if (!ep1 || !ep2) {
+            fprintf(stderr, "Endpoints not found\n");
+            exit(1);
+        }
+
+        if (usb_device_claim_interface(device, intf->bInterfaceNumber)) {
+            fprintf(stderr, "usb_device_claim_interface failed errno: %d\n", errno);
+            exit(1);
+        }
+
+        int endpoints[2];
+        if ((ep1->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN) {
+            endpoints[0] = ep1->bEndpointAddress;
+            endpoints[1] = ep2->bEndpointAddress;
+        } else {
+            endpoints[0] = ep2->bEndpointAddress;
+            endpoints[1] = ep1->bEndpointAddress;
+        }
+        pthread_create(&th, NULL, message_thread, (void *)endpoints);
+    } else {
+        printf("Found possible Android device (%x:%x) "
+                "- attempting to switch to accessory mode...\n", vendorId, productId);
+
+        uint16_t protocol = 0;
+        ret = usb_device_control_transfer(device, USB_DIR_IN | USB_TYPE_VENDOR,
+                ACCESSORY_GET_PROTOCOL, 0, 0, &protocol, sizeof(protocol), 0);
+        if (ret == 2)
+            printf("Device supports protocol version %d\n", protocol);
+        else
+            fprintf(stderr, "Failed to read protocol version\n");
+
+        send_string(device, ACCESSORY_STRING_MANUFACTURER, "Android CTS");
+        send_string(device, ACCESSORY_STRING_MODEL, "CTS USB Accessory");
+        send_string(device, ACCESSORY_STRING_DESCRIPTION, "CTS USB Accessory");
+        send_string(device, ACCESSORY_STRING_VERSION, "1.0");
+        send_string(device, ACCESSORY_STRING_URI,
+                "http://source.android.com/compatibility/cts-intro.html");
+        send_string(device, ACCESSORY_STRING_SERIAL, "1234567890");
+
+        ret = usb_device_control_transfer(device, USB_DIR_OUT | USB_TYPE_VENDOR,
+                ACCESSORY_START, 0, 0, 0, 0, 0);
+        return 0;
+    }
+
+    if (device != sDevice)
+        usb_device_close(device);
+
+    return 0;
+}
+
+static int usb_device_removed(const char *devname, void* client_data) {
+    if (sDevice && !strcmp(usb_device_get_name(sDevice), devname)) {
+        usb_device_close(sDevice);
+        sDevice = NULL;
+        // exit when we are disconnected
+        return 1;
+    }
+    return 0;
+}
+
+
+int main(int argc, char* argv[]) {
+    printf("CTS USB Accessory Tester\n");
+
+    struct usb_host_context* context = usb_host_init();
+    if (!context) {
+        fprintf(stderr, "usb_host_init failed");
+        return 1;
+    }
+
+    // this will never return so it is safe to pass thiz directly
+    usb_host_run(context, usb_device_added, usb_device_removed, NULL, NULL);
+    return 0;
+}
diff --git a/development/ide/eclipse/.classpath b/development/ide/eclipse/.classpath
index af2ce98..01d5c73 100644
--- a/development/ide/eclipse/.classpath
+++ b/development/ide/eclipse/.classpath
@@ -26,6 +26,7 @@
     <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/drm/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"/>
@@ -44,6 +45,7 @@
     <classpathentry kind="src" path="cts/tests/tests/permission2/src"/>
     <classpathentry kind="src" path="cts/tests/tests/preference/src"/>
     <classpathentry kind="src" path="cts/tests/tests/provider/src"/>
+    <classpathentry kind="src" path="cts/tests/tests/renderscript/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"/>
diff --git a/tests/Android.mk b/tests/Android.mk
index 838d01d..641d053 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -18,6 +18,7 @@
 LOCAL_MODULE_TAGS := tests
 
 LOCAL_SRC_FILES := $(call all-java-files-under, src)\
+              $(call all-renderscript-files-under, src)\
               $(call all-java-files-under, core/runner/src)\
               src/android/app/cts/ISecondary.aidl\
               src/android/os/cts/IEmptyService.aidl
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
index f1c82b5..c6907a9 100644
--- a/tests/AndroidManifest.xml
+++ b/tests/AndroidManifest.xml
@@ -316,6 +316,7 @@
         </activity>
 
         <activity android:name="android.view.cts.WindowStubActivity"
+            android:theme="@android:style/Theme.Holo.NoActionBar"
             android:label="WindowStubActivity">
             <intent-filter>
                 <action android:name="android.intent.action.MAIN" />
@@ -943,6 +944,11 @@
                 
         <activity android:name="android.content.cts.ClipboardManagerListenerActivity"/>
 
+        <activity android:name="android.app.cts.ActivityManagerMemoryClassLaunchActivity" />
+
+        <activity android:name="android.app.cts.ActivityManagerMemoryClassTestActivity"
+                android:process=":memoryclass" />
+
     </application>
 
     <!--Test for PackageManager, please put this at the very beginning-->
diff --git a/tests/assets/sphere.a3d b/tests/assets/sphere.a3d
new file mode 100644
index 0000000..3d78b01
--- /dev/null
+++ b/tests/assets/sphere.a3d
Binary files differ
diff --git a/tests/core/runner/src/android/test/InstrumentationCtsTestRunner.java b/tests/core/runner/src/android/test/InstrumentationCtsTestRunner.java
index 5aa2c3b..b2be76a 100644
--- a/tests/core/runner/src/android/test/InstrumentationCtsTestRunner.java
+++ b/tests/core/runner/src/android/test/InstrumentationCtsTestRunner.java
@@ -81,7 +81,7 @@
         System.setProperty("java.io.tmpdir", cacheDir.getAbsolutePath());
         System.setProperty("user.dir", cacheDir.getAbsolutePath());
         System.setProperty("javax.net.ssl.trustStore",
-                "/etc/security/cacerts.bks");
+                "/system/etc/security/cacerts.bks");
 
         TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
 
diff --git a/tests/expectations/knownfailures.txt b/tests/expectations/knownfailures.txt
index c9b11fb..addf048 100644
--- a/tests/expectations/knownfailures.txt
+++ b/tests/expectations/knownfailures.txt
@@ -4,53 +4,55 @@
   bug: 4993068
 },
 {
+  name: "android.graphics.cts.TypefaceTest#testCreateFromAsset",
+  bug: 5092227
+},
+{
+  name: "android.graphics.cts.TypefaceTest#testCreateFromFile1",
+  bug: 5092227
+},
+{
+  name: "android.graphics.cts.TypefaceTest#testCreateFromFile2",
+  bug: 5092227
+},
+{
   name: "android.media.cts.MediaRecorderTest#testSetCamera",
   bug: 4464677
 },
 {
-  name: "android.media.cts.MediaRecorderTest#testSetMaxDuration",
-  bug: 5104153
-},
-{
-  name: "android.media.cts.MediaRecorderTest#testSetMaxFileSize",
-  bug: 5103805
+  name: "android.security.cts.BrowserTest",
+  description: "Fixed in HC MR2"
 },
 {
   name: "android.telephony.cts.PhoneNumberFormattingTextWatcherTest#testPhoneNumberFormattingTextWatcher",
   bug: 3198578
 },
 {
-  name: "android.text.cts.StaticLayoutTest#testGetEllipsisCount",
-  bug: 3422121
-},
-{
-  name: "android.text.cts.StaticLayoutTest#testGetEllipsisStart",
-  bug: 3422121
-},
-{
-  name: "android.text.cts.StaticLayoutTest#testGetEllipsizedWidth",
-  bug: 3422121
-},
-{
   name: "android.webkit.cts.WebViewTest#testRequestFocusNodeHref",
   bug: 3241968
 },
-
+{
+  name: "android.webkit.cts.CookieSyncManagerTest#testCookieSyncManager",
+  bug: 4442572
+},
+{
+  name: "android.graphics.cts.PaintTest#testBreakText",
+  bug: 4355524
+},
+{
+  name: "android.graphics.cts.PaintTest#testMeasureText",
+  bug: 4361123
+},
 {
   description: "Need investigation.",
   names: [
+    "android.content.cts.ContextWrapperTest#testAccessTheme",
     "android.provider.cts.Contacts_PeopleTest#testAddToGroup",
     "android.provider.cts.MediaStore_Audio_Playlists_MembersTest",
     "android.webkit.cts.WebViewTest#testRequestImageRef",
     "tests.api.java.util.CalendarTest#test_getInstance"
   ]
 },
-
-{
-  description: "Test should be made independent from theme.",
-  name: "android.content.cts.ContextWrapperTest#testAccessTheme"
-},
-  
 {
   description: "Flakey",
   names: [
@@ -60,11 +62,5 @@
     "android.webkit.cts.WebChromeClientTest#testOnReceivedIcon",
     "android.widget.cts.AbsListViewTest#testGetContextMenuInfo"
   ]
-},
-
-{
-  description: "Crashes the VM",
-  name: "org.apache.harmony.luni.tests.java.net.InetAddressTest#test_getHostName"
 }
-
 ]
diff --git a/tests/jni/android_net_cts_NetlinkSocket.cpp b/tests/jni/android_net_cts_NetlinkSocket.cpp
index 7f430d8..1e671c6 100644
--- a/tests/jni/android_net_cts_NetlinkSocket.cpp
+++ b/tests/jni/android_net_cts_NetlinkSocket.cpp
@@ -21,6 +21,7 @@
 #include <sys/socket.h>
 #include <linux/netlink.h>
 #include <errno.h>
+#include <string.h>
 #include "JNIHelp.h"
 
 #include "android_net_cts_NetlinkSocket.h"
diff --git a/tests/res/raw/samplefont.ttf b/tests/res/raw/samplefont.ttf
new file mode 100644
index 0000000..49f1c62
--- /dev/null
+++ b/tests/res/raw/samplefont.ttf
Binary files differ
diff --git a/tests/res/raw/sphere.a3d b/tests/res/raw/sphere.a3d
new file mode 100644
index 0000000..3d78b01
--- /dev/null
+++ b/tests/res/raw/sphere.a3d
Binary files differ
diff --git a/tests/src/android/app/cts/ActivityManagerMemoryClassLaunchActivity.java b/tests/src/android/app/cts/ActivityManagerMemoryClassLaunchActivity.java
new file mode 100644
index 0000000..f1f95b8
--- /dev/null
+++ b/tests/src/android/app/cts/ActivityManagerMemoryClassLaunchActivity.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2011 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.app.cts;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * {@link Activity} that just launches {@link ActivityManagerMemoryClassTestActivity} and
+ * returns the result of that activity.
+ */
+public class ActivityManagerMemoryClassLaunchActivity extends Activity {
+
+    public static final String MEMORY_CLASS_EXTRA = "activityMemoryClass";
+
+    private static final int TEST_ACTIVITY_REQUEST_CODE = 1337;
+
+    private final CountDownLatch mLatch = new CountDownLatch(1);
+
+    private int mChildResult = RESULT_CANCELED;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+
+        // Start the activity that runs in a separate process to do the actual testing,
+        // since the test itself cannot start an activity in a separate process. A separate
+        // process is used to avoid including the overhead of the test instrumentation process.
+
+        Intent intent = getIntent();
+        int memoryClass = intent.getIntExtra(MEMORY_CLASS_EXTRA, -1);
+
+        Intent testIntent = new Intent(this, ActivityManagerMemoryClassTestActivity.class);
+        testIntent.putExtra(MEMORY_CLASS_EXTRA, memoryClass);
+        startActivityForResult(testIntent, TEST_ACTIVITY_REQUEST_CODE);
+    }
+
+    @Override
+    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+        super.onActivityResult(requestCode, resultCode, data);
+        if (requestCode == 1337) {
+            synchronized (this) {
+                mChildResult = resultCode;
+            }
+        } else {
+            throw new IllegalStateException("Request code: " + requestCode);
+        }
+    }
+
+    public int getResult() throws InterruptedException {
+        mLatch.await(5, TimeUnit.SECONDS);
+        synchronized (this) {
+            return mChildResult;
+        }
+    }
+}
diff --git a/tests/src/android/app/cts/ActivityManagerMemoryClassTestActivity.java b/tests/src/android/app/cts/ActivityManagerMemoryClassTestActivity.java
new file mode 100644
index 0000000..e717b03
--- /dev/null
+++ b/tests/src/android/app/cts/ActivityManagerMemoryClassTestActivity.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2011 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.app.cts;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.util.Log;
+
+/**
+ * {@link Activity} that allocates arrays of 256k until reaching 75% of the specified memory class.
+ */
+public class ActivityManagerMemoryClassTestActivity extends Activity {
+
+    private static final String TAG = "ActivityManagerMemoryClassTest";
+
+    private static final double FREE_MEMORY_PERCENTAGE = 0.75;
+
+    private static final int ARRAY_BYTES_SIZE = 256 * 1024;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        Intent intent = getIntent();
+        int memoryClass =
+                intent.getIntExtra(ActivityManagerMemoryClassLaunchActivity.MEMORY_CLASS_EXTRA, -1);
+        new AllocateMemoryTask(memoryClass).execute();
+    }
+
+    private class AllocateMemoryTask extends AsyncTask<Void, Void, Void> {
+
+        private final int mMemoryClass;
+
+        AllocateMemoryTask(int memoryClass) {
+            this.mMemoryClass = memoryClass;
+        }
+
+        @Override
+        protected Void doInBackground(Void... params) {
+            int targetMbs = (int) (mMemoryClass * FREE_MEMORY_PERCENTAGE);
+            int numArrays = targetMbs * 1024 * 1024 / ARRAY_BYTES_SIZE;
+            Log.i(TAG, "Memory class: " + mMemoryClass + "mb Target memory: "
+                    + targetMbs + "mb Number of arrays: " + numArrays);
+
+            byte[][] arrays = new byte[numArrays][];
+            for (int i = 0; i < arrays.length; i++) {
+                Log.i(TAG, "Allocating array " + i + " of " + arrays.length
+                        + " (" + (i * ARRAY_BYTES_SIZE / 1024 / 1024) + "mb)");
+                arrays[i] = new byte[ARRAY_BYTES_SIZE];
+            }
+            return null;
+        }
+
+        @Override
+        protected void onPostExecute(Void result) {
+            super.onPostExecute(result);
+            setResult(RESULT_OK);
+            finish();
+        }
+    }
+}
diff --git a/tests/src/android/renderscript/cts/graphics_runner.rs b/tests/src/android/renderscript/cts/graphics_runner.rs
new file mode 100644
index 0000000..b8ec15f
--- /dev/null
+++ b/tests/src/android/renderscript/cts/graphics_runner.rs
@@ -0,0 +1,45 @@
+// Copyright (C) 2011 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.
+
+#include "shared.rsh"
+#include "rs_graphics.rsh"
+
+#include "structs.rsh"
+
+static void drawQuad() {
+    float startX = 0, startY = 0;
+    float width = 4, height = 4;
+    rsgDrawQuadTexCoords(startX, startY, 0, 0, 0,
+                         startX, startY + height, 0, 0, 1,
+                         startX + width, startY + height, 0, 1, 1,
+                         startX + width, startY, 0, 1, 0);
+}
+
+void testProgramVertex(rs_program_vertex pv) {
+    rsDebug("Set Program Vertex, drew quad", 0);
+    rsgBindProgramVertex(pv);
+    drawQuad();
+}
+
+void testProgramFragment(rs_program_fragment pf) {
+    rsDebug("Set Program Fragment, drew quad", 0);
+    rsgBindProgramFragment(pf);
+    drawQuad();
+}
+
+// Just draw a quad with previously setup state
+int root(int launchID) {
+    rsDebug("Running script", 0);
+    return 0;
+}
diff --git a/tests/src/android/renderscript/cts/passthrough.rs b/tests/src/android/renderscript/cts/passthrough.rs
new file mode 100644
index 0000000..008f7f2
--- /dev/null
+++ b/tests/src/android/renderscript/cts/passthrough.rs
@@ -0,0 +1,8 @@
+#pragma version(1)
+#pragma rs java_package_name(android.renderscript.cts)
+
+void passthrough(int i) {
+    rsDebug("i: ", i);
+    return;
+}
+
diff --git a/tests/src/android/renderscript/cts/primitives.rs b/tests/src/android/renderscript/cts/primitives.rs
new file mode 100644
index 0000000..55710cd
--- /dev/null
+++ b/tests/src/android/renderscript/cts/primitives.rs
@@ -0,0 +1,118 @@
+#include "shared.rsh"
+#include "structs.rsh"
+
+// Testing primitive types
+float floatTest = 1.99f;
+double doubleTest = 2.05;
+char charTest = -8;
+short shortTest = -16;
+int intTest = -32;
+long longTest = 17179869184l; // 1 << 34
+long long longlongTest = 68719476736l; // 1 << 36
+
+uchar ucharTest = 8;
+ushort ushortTest = 16;
+uint uintTest = 32;
+ulong ulongTest = 4611686018427387904L;
+int64_t int64_tTest = -17179869184l; // - 1 << 34
+uint64_t uint64_tTest = 117179869184l;
+
+static bool test_primitive_types() {
+    bool failed = false;
+    start();
+
+    _RS_ASSERT(floatTest == 2.99f);
+    _RS_ASSERT(doubleTest == 3.05);
+    _RS_ASSERT(charTest == -16);
+    _RS_ASSERT(shortTest == -32);
+    _RS_ASSERT(intTest == -64);
+    _RS_ASSERT(longTest == 17179869185l);
+    _RS_ASSERT(longlongTest == 68719476735l);
+
+    _RS_ASSERT(ucharTest == 8);
+    _RS_ASSERT(ushortTest == 16);
+    _RS_ASSERT(uintTest == 32);
+    _RS_ASSERT(ulongTest == 4611686018427387903L);
+    _RS_ASSERT(int64_tTest == -17179869184l);
+    _RS_ASSERT(uint64_tTest == 117179869185l);
+
+    float time = end();
+
+    if (failed) {
+        rsDebug("test_primitive_types FAILED", time);
+    }
+    else {
+        rsDebug("test_primitive_types PASSED", time);
+    }
+
+    return failed;
+}
+
+static bool test_vector_types() {
+    bool failed = false;
+    start();
+    _RS_ASSERT(avt->b2.x == 1);
+    _RS_ASSERT(avt->b2.y == 2);
+    _RS_ASSERT(avt->b3.x == 1);
+    _RS_ASSERT(avt->b3.y == 2);
+    _RS_ASSERT(avt->b3.z == 3);
+    _RS_ASSERT(avt->b4.x == 1);
+    _RS_ASSERT(avt->b4.y == 2);
+    _RS_ASSERT(avt->b4.z == 3);
+    _RS_ASSERT(avt->b4.w == 4);
+
+    _RS_ASSERT(avt->s2.x == 1);
+    _RS_ASSERT(avt->s2.y == 2);
+    _RS_ASSERT(avt->s3.x == 1);
+    _RS_ASSERT(avt->s3.y == 2);
+    _RS_ASSERT(avt->s3.z == 3);
+    _RS_ASSERT(avt->s4.x == 1);
+    _RS_ASSERT(avt->s4.y == 2);
+    _RS_ASSERT(avt->s4.z == 3);
+    _RS_ASSERT(avt->s4.w == 4);
+
+    _RS_ASSERT(avt->i2.x == 1);
+    _RS_ASSERT(avt->i2.y == 2);
+    _RS_ASSERT(avt->i3.x == 1);
+    _RS_ASSERT(avt->i3.y == 2);
+    _RS_ASSERT(avt->i3.z == 3);
+    _RS_ASSERT(avt->i4.x == 1);
+    _RS_ASSERT(avt->i4.y == 2);
+    _RS_ASSERT(avt->i4.z == 3);
+    _RS_ASSERT(avt->i4.w == 4);
+
+    _RS_ASSERT(avt->f2.x == 1.0f);
+    _RS_ASSERT(avt->f2.y == 2.0f);
+    _RS_ASSERT(avt->f3.x == 1.0f);
+    _RS_ASSERT(avt->f3.y == 2.0f);
+    _RS_ASSERT(avt->f3.z == 3.0f);
+    _RS_ASSERT(avt->f4.x == 1.0f);
+    _RS_ASSERT(avt->f4.y == 2.0f);
+    _RS_ASSERT(avt->f4.z == 3.0f);
+    _RS_ASSERT(avt->f4.w == 4.0f);
+
+    float time = end();
+
+    if (failed) {
+        rsDebug("test_vector_types FAILED", time);
+    }
+    else {
+        rsDebug("test_vector_types PASSED", time);
+    }
+
+    return failed;
+}
+
+void test() {
+    bool failed = false;
+    failed |= test_primitive_types();
+    failed |= test_vector_types();
+
+    if (failed) {
+        rsSendToClientBlocking(RS_MSG_TEST_FAILED);
+    }
+    else {
+        rsSendToClientBlocking(RS_MSG_TEST_PASSED);
+    }
+}
+
diff --git a/tests/src/android/renderscript/cts/shared.rsh b/tests/src/android/renderscript/cts/shared.rsh
new file mode 100644
index 0000000..b91611d
--- /dev/null
+++ b/tests/src/android/renderscript/cts/shared.rsh
@@ -0,0 +1,27 @@
+#pragma version(1)
+#pragma rs java_package_name(android.renderscript.cts)
+
+static int64_t g_time;
+
+static void start(void) {
+    g_time = rsUptimeMillis();
+}
+
+static float end(void) {
+    int64_t t = rsUptimeMillis() - g_time;
+    return ((float)t) / 1000.f;
+}
+
+#define _RS_ASSERT(b) \
+do { \
+    if (!(b)) { \
+        failed = true; \
+        rsDebug(#b " FAILED", 0); \
+    } \
+\
+} while (0)
+
+/* These constants must match those in UnitTest.java */
+static const int RS_MSG_TEST_PASSED = 100;
+static const int RS_MSG_TEST_FAILED = 101;
+
diff --git a/tests/src/android/renderscript/cts/structs.rsh b/tests/src/android/renderscript/cts/structs.rsh
new file mode 100755
index 0000000..e7d2efd
--- /dev/null
+++ b/tests/src/android/renderscript/cts/structs.rsh
@@ -0,0 +1,56 @@
+// Copyright (C) 2011 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.
+
+typedef struct ConstMatrix {
+    rs_matrix4x4 MATRIX;
+} ConstMatrix_s;
+ConstMatrix_s *c1;
+
+typedef struct ConstComplex {
+    rs_matrix4x4 MATRIX;
+    rs_matrix4x4 EXTRA;
+    float extra1;
+    float2 extra2;
+    float3 extra3;
+    float4 extra4;
+} ConstComplex_s;
+ConstComplex_s *c2;
+
+typedef struct ConstExtra {
+    rs_matrix4x4 EXTRA;
+    float extra1;
+    float2 extra2;
+    float3 extra3;
+    float4 extra4;
+} ConstExtra_s;
+ConstExtra_s *c3;
+
+typedef struct AllVectorTypes {
+    char2 b2;
+    char3 b3;
+    char4 b4;
+
+    short2 s2;
+    short3 s3;
+    short4 s4;
+
+    int2 i2;
+    int3 i3;
+    int4 i4;
+
+    float2 f2;
+    float3 f3;
+    float4 f4;
+} AllVectorTypes_s;
+AllVectorTypes_s *avt;
diff --git a/tests/tests/accessibilityservice/AndroidManifest.xml b/tests/tests/accessibilityservice/AndroidManifest.xml
index b4fe6ab..70e1092 100644
--- a/tests/tests/accessibilityservice/AndroidManifest.xml
+++ b/tests/tests/accessibilityservice/AndroidManifest.xml
@@ -19,7 +19,7 @@
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
         package="com.android.cts.accessibilityservice">
 
-  <application>
+  <application android:theme="@android:style/Theme.Holo.NoActionBar" >
 
       <uses-library android:name="android.test.runner"/>
 
diff --git a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTest.java b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTest.java
index 89e5473..07812b8 100644
--- a/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTest.java
+++ b/tests/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTest.java
@@ -84,7 +84,7 @@
      * Timeout required for pending Binder calls or event processing to
      * complete.
      */
-    private static final long MAX_TIMEOUT_ASYNCHRONOUS_PROCESSING = 1000;
+    private static final long MAX_TIMEOUT_ASYNCHRONOUS_PROCESSING = 2000;
 
     /**
      * The count of the polling attempts during {@link #MAX_TIMEOUT_ASYNCHRONOUS_PROCESSING}
@@ -219,13 +219,8 @@
         focusedEvent.setClassName(Button.class.getName());
         focusedEvent.setPackageName(getActivity().getPackageName());
         focusedEvent.getText().add(activity.getString(R.string.button_title));
-        if (hasActivityActionBar()) {
-            focusedEvent.setItemCount(4);
-            focusedEvent.setCurrentItemIndex(3);
-        } else {
-            focusedEvent.setItemCount(3);
-            focusedEvent.setCurrentItemIndex(2);
-        }
+        focusedEvent.setItemCount(3);
+        focusedEvent.setCurrentItemIndex(2);
         focusedEvent.setEnabled(true);
 
         // set expectations
@@ -413,14 +408,6 @@
         throw lastVerifyThrowable;
     }
 
-    /**
-     * @return Whether the activity has action bar.
-     */
-    private boolean hasActivityActionBar() {
-        return (getActivity().getApplicationInfo().targetSdkVersion
-                >= Build.VERSION_CODES.HONEYCOMB);
-    }
-
     static class MockAccessibilityService extends AccessibilityService implements
             ServiceConnection {
 
diff --git a/tests/tests/app/src/android/app/cts/ActivityManagerMemoryClassTest.java b/tests/tests/app/src/android/app/cts/ActivityManagerMemoryClassTest.java
new file mode 100644
index 0000000..5ff5e67
--- /dev/null
+++ b/tests/tests/app/src/android/app/cts/ActivityManagerMemoryClassTest.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2011 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.app.cts;
+
+import android.app.Activity;
+import android.app.ActivityManager;
+import android.content.Context;
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.test.ActivityInstrumentationTestCase2;
+import android.util.DisplayMetrics;
+import android.view.Display;
+import android.view.WindowManager;
+
+/**
+ * {@link ActivityInstrumentationTestCase2} that tests {@link ActivityManager#getMemoryClass()}
+ * by checking that the memory class matches the proper screen density and by launching an
+ * application that attempts to allocate memory on the heap.
+ */
+public class ActivityManagerMemoryClassTest
+        extends ActivityInstrumentationTestCase2<ActivityManagerMemoryClassLaunchActivity> {
+
+    /**
+     * A density value used by some TV devices, but not yet in {link DisplayMetrics}.
+     */
+    private static final int DENSITY_TV = 213;
+
+    public ActivityManagerMemoryClassTest() {
+        super(ActivityManagerMemoryClassLaunchActivity.class);
+    }
+
+    public void testGetMemoryClass() throws Exception {
+        int memoryClass = getMemoryClass();
+        int screenDensity = getScreenDensity();
+        int screenSize = getScreenSize();
+        assertMemoryForScreenDensity(memoryClass, screenDensity, screenSize);
+
+        runHeapTestApp(memoryClass);
+    }
+
+    private int getMemoryClass() {
+        Context context = getInstrumentation().getTargetContext();
+        ActivityManager activityManager =
+                (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
+        return activityManager.getMemoryClass();
+    }
+
+    private int getScreenDensity() {
+        Context context = getInstrumentation().getTargetContext();
+        WindowManager windowManager =
+                (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
+        Display display = windowManager.getDefaultDisplay();
+        DisplayMetrics metrics = new DisplayMetrics();
+        display.getMetrics(metrics);
+        return metrics.densityDpi;
+    }
+
+    private int getScreenSize() {
+        Context context = getInstrumentation().getTargetContext();
+        Configuration config = context.getResources().getConfiguration();
+        return config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK;
+    }
+
+    private void assertMemoryForScreenDensity(int memoryClass, int screenDensity, int screenSize) {
+        int expectedMinimumMemory = -1;
+        boolean isXLarge = screenSize == Configuration.SCREENLAYOUT_SIZE_XLARGE;
+        switch (screenDensity) {
+            case DisplayMetrics.DENSITY_LOW:
+                expectedMinimumMemory = 16;
+                break;
+
+            case DisplayMetrics.DENSITY_MEDIUM:
+                expectedMinimumMemory = isXLarge ? 32 : 16;
+                break;
+
+            case DisplayMetrics.DENSITY_HIGH:
+            case DisplayMetrics.DENSITY_XHIGH:
+            case DENSITY_TV:
+                expectedMinimumMemory = isXLarge ? 48 : 32;
+                break;
+
+            default:
+                throw new IllegalArgumentException("No memory requirement specified "
+                        + " for screen density " + screenDensity);
+        }
+
+        assertTrue("Expected to have at least " + expectedMinimumMemory
+                + "mb of memory for screen density " + screenDensity,
+                        memoryClass >= expectedMinimumMemory);
+    }
+
+    private void runHeapTestApp(int memoryClass) throws InterruptedException {
+        Intent intent = new Intent();
+        intent.putExtra(ActivityManagerMemoryClassLaunchActivity.MEMORY_CLASS_EXTRA,
+                memoryClass);
+        setActivityIntent(intent);
+        ActivityManagerMemoryClassLaunchActivity activity = getActivity();
+        assertEquals("The test application couldn't allocate memory close to the amount "
+                + " specified by the memory class.", Activity.RESULT_OK, activity.getResult());
+    }
+}
diff --git a/tests/tests/app/src/android/app/cts/InstrumentationTest.java b/tests/tests/app/src/android/app/cts/InstrumentationTest.java
index 6ab9ac6..d2c55c2 100644
--- a/tests/tests/app/src/android/app/cts/InstrumentationTest.java
+++ b/tests/tests/app/src/android/app/cts/InstrumentationTest.java
@@ -954,6 +954,11 @@
             }
 
             @Override
+            public boolean superDispatchGenericMotionEvent(MotionEvent event) {
+                return false;
+            }
+
+            @Override
             public void takeKeyEvents(boolean get) {
             }
 
diff --git a/tests/tests/app/src/android/app/cts/SystemFeaturesTest.java b/tests/tests/app/src/android/app/cts/SystemFeaturesTest.java
index 1f7c9f8..e4d306c 100644
--- a/tests/tests/app/src/android/app/cts/SystemFeaturesTest.java
+++ b/tests/tests/app/src/android/app/cts/SystemFeaturesTest.java
@@ -333,6 +333,9 @@
         // TODO: Add tests for the other touchscreen features.
     }
 
+    public void testUsbAccessory() {
+        assertAvailable(PackageManager.FEATURE_USB_ACCESSORY);
+    }
 
     public void testWifiFeature() throws Exception {
         boolean enabled = mWifiManager.isWifiEnabled();
diff --git a/tests/tests/content/src/android/content/cts/ContentResolverSyncTestCase.java b/tests/tests/content/src/android/content/cts/ContentResolverSyncTestCase.java
index 1cc4cfb..2da0bfb 100644
--- a/tests/tests/content/src/android/content/cts/ContentResolverSyncTestCase.java
+++ b/tests/tests/content/src/android/content/cts/ContentResolverSyncTestCase.java
@@ -57,6 +57,9 @@
         // Need to clean up created account
         removeAccount(sAccountManager, ACCOUNT, null /* callback */);
 
+        // Need to cancel any sync that was started.
+        cancelSync(null, AUTHORITY, LATCH_TIMEOUT_MS);
+
         super.tearDown();
     }
 
@@ -87,8 +90,8 @@
     }
 
     private CountDownLatch setNewLatch(CountDownLatch latch) {
-        getMockSyncAdapter().setLatch(latch);
         getMockSyncAdapter().clearData();
+        getMockSyncAdapter().setLatch(latch);
         return latch;
     }
 
@@ -101,7 +104,9 @@
 
         // Wait with timeout for the callback to do its work
         try {
-            latch.await(latchTimeoutMs, TimeUnit.MILLISECONDS);
+            if (!latch.await(latchTimeoutMs, TimeUnit.MILLISECONDS)) {
+                fail("should not time out waiting on latch");
+            }
         } catch (InterruptedException e) {
             fail("should not throw an InterruptedException");
         }
diff --git a/tests/tests/content/src/android/content/cts/IntentTest.java b/tests/tests/content/src/android/content/cts/IntentTest.java
index 15400be..995c668 100644
--- a/tests/tests/content/src/android/content/cts/IntentTest.java
+++ b/tests/tests/content/src/android/content/cts/IntentTest.java
@@ -16,11 +16,13 @@
 
 package android.content.cts;
 
-import java.io.IOException;
-import java.io.Serializable;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Set;
+import com.android.internal.app.ResolverActivity;
+import com.android.internal.util.XmlUtils;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+import dalvik.annotation.TestTargets;
 
 import org.xmlpull.v1.XmlPullParser;
 import org.xmlpull.v1.XmlPullParserException;
@@ -45,13 +47,11 @@
 import android.util.AttributeSet;
 import android.util.Xml;
 
-import com.android.internal.app.ResolverActivity;
-import com.android.internal.util.XmlUtils;
-
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetClass;
-import dalvik.annotation.TestTargetNew;
-import dalvik.annotation.TestTargets;
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Set;
 
 @TestTargetClass(Intent.class)
 public class IntentTest extends AndroidTestCase {
@@ -1746,7 +1746,7 @@
         assertEquals(Intent.FILL_IN_DATA, destIntent.fillIn(sourceIntent, Intent.FILL_IN_DATA));
         assertEquals(TEST_URI, destIntent.getData());
     }
-    
+
     /**
      * Test that fillIn copies data type.
      */
@@ -2087,8 +2087,6 @@
         assertFalse(mIntent.filterEquals(target));
         mIntent.addCategory(TEST_CATEGORY + "test");
         assertFalse(mIntent.filterEquals(target));
-        mIntent.addCategory(null);
-        assertFalse(mIntent.filterEquals(target));
         mIntent.addCategory(TEST_CATEGORY);
         assertFalse(mIntent.filterEquals(target));
     }
diff --git a/tests/tests/dpi/src/android/dpi/cts/ConfigurationTest.java b/tests/tests/dpi/src/android/dpi/cts/ConfigurationTest.java
index 2af36ff..b4b4d40 100644
--- a/tests/tests/dpi/src/android/dpi/cts/ConfigurationTest.java
+++ b/tests/tests/dpi/src/android/dpi/cts/ConfigurationTest.java
@@ -30,6 +30,12 @@
  */
 public class ConfigurationTest extends AndroidTestCase {
 
+    /**
+     * Starting in HC MR2, this is in the public SDK and can be directly referenced instead
+     * of this constant.
+     */
+    private static final int DENSITY_TV = 213;
+
     public void testScreenConfiguration() {
         WindowManager windowManager =
             (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
@@ -57,10 +63,13 @@
         allowedDensities.add(DisplayMetrics.DENSITY_LOW);
         allowedDensities.add(DisplayMetrics.DENSITY_MEDIUM);
         allowedDensities.add(DisplayMetrics.DENSITY_HIGH);
+        allowedDensities.add(DENSITY_TV);
         allowedDensities.add(DisplayMetrics.DENSITY_XHIGH);
         assertTrue("DisplayMetrics#densityDpi must be one of the DisplayMetrics.DENSITY_* values: "
                 + allowedDensities, allowedDensities.contains(metrics.densityDpi));
 
-        assertEquals(metrics.density, (float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT);
+        assertEquals(metrics.density,
+                (float) metrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT,
+                0.5f / DisplayMetrics.DENSITY_DEFAULT);
     }
 }
diff --git a/tests/tests/drm/Android.mk b/tests/tests/drm/Android.mk
new file mode 100644
index 0000000..61e1f10
--- /dev/null
+++ b/tests/tests/drm/Android.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2011 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)
+
+# don't include this package in any target
+LOCAL_MODULE_TAGS := optional
+# and when built explicitly put it in the data partition
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+LOCAL_JAVA_LIBRARIES := android.test.runner
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_PACKAGE_NAME := CtsDrmTestCases
+
+LOCAL_INSTRUMENTATION_FOR := CtsTestStubs
+
+# uncomment when dalvik.annotation.Test* are removed or part of SDK
+#LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/tests/tests/drm/AndroidManifest.xml b/tests/tests/drm/AndroidManifest.xml
new file mode 100644
index 0000000..fe515f3
--- /dev/null
+++ b/tests/tests/drm/AndroidManifest.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.drm">
+
+    <application>
+        <uses-library android:name="android.test.runner" />
+    </application>
+
+    <instrumentation android:name="android.test.InstrumentationCtsTestRunner"
+                     android:targetPackage="com.android.cts.stub"
+                     android:label="CTS tests of android.drm"/>
+
+</manifest>
+
diff --git a/tests/tests/drm/README b/tests/tests/drm/README
new file mode 100644
index 0000000..dd0ef17
--- /dev/null
+++ b/tests/tests/drm/README
@@ -0,0 +1,6 @@
+- User of CTS code needs to edit configuration files in
+  "src/android/drm/cts/configs/" according to the specification
+  of user's DRM plug-in.
+- If new plug-in is added, user should add corresponding configuration
+  file under "src/android/drm/cts/configs/" and update
+  "src/android/drm/cts/ConfigFactory.java".
diff --git a/tests/tests/drm/src/android/drm/cts/Config.java b/tests/tests/drm/src/android/drm/cts/Config.java
new file mode 100644
index 0000000..736c0ad
--- /dev/null
+++ b/tests/tests/drm/src/android/drm/cts/Config.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2011 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.drm.cts;
+
+import java.util.HashMap;
+
+public interface Config {
+    String getPluginName();
+    String getMimeType();
+    String getAccountId();
+    String getRightsPath();
+    String getContentPath();
+    HashMap<String, String> getInfoOfRegistration();
+    HashMap<String, String> getInfoOfUnregistration();
+    HashMap<String, String> getInfoOfRightsAcquisition();
+}
diff --git a/tests/tests/drm/src/android/drm/cts/ConfigFactory.java b/tests/tests/drm/src/android/drm/cts/ConfigFactory.java
new file mode 100644
index 0000000..643bb67
--- /dev/null
+++ b/tests/tests/drm/src/android/drm/cts/ConfigFactory.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2011 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.drm.cts;
+
+import android.util.Log;
+
+import android.drm.cts.configs.PassthruConfig;
+import android.drm.cts.configs.FwdLockConfig;
+
+public final class ConfigFactory {
+    private static final String TAG = "ConfigFactory";
+
+    /**
+     * Get configurations of specified plug-in name.
+     *
+     * @param plugInName Name of DRM plug-in. The name SHOULD be consistent with
+     *                   the name defined in plug-in's onGetSupportInfo().
+     */
+    public static Config getConfig(String plugInName) {
+        if (plugInName.equals("Passthru plug-in")) {
+            return PassthruConfig.getInstance();
+        } else if (plugInName.equals("OMA V1 Forward Lock")) {
+            return FwdLockConfig.getInstance();
+        } else {
+            Log.e(TAG, "Configuration for " + plugInName + " is not registered.");
+            return null;
+        }
+    }
+}
diff --git a/tests/tests/drm/src/android/drm/cts/DRMTest.java b/tests/tests/drm/src/android/drm/cts/DRMTest.java
new file mode 100644
index 0000000..dc87530
--- /dev/null
+++ b/tests/tests/drm/src/android/drm/cts/DRMTest.java
@@ -0,0 +1,246 @@
+/*
+ * Copyright (C) 2011 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.drm.cts;
+
+import dalvik.annotation.TestLevel;
+import dalvik.annotation.TestTargetClass;
+import dalvik.annotation.TestTargetNew;
+
+import android.content.ContentValues;
+import android.test.AndroidTestCase;
+import android.util.Log;
+import java.io.IOException;
+import java.io.File;
+import java.util.HashMap;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import android.drm.DrmManagerClient;
+import android.drm.DrmConvertedStatus;
+import android.drm.DrmEvent;
+import android.drm.DrmInfo;
+import android.drm.DrmInfoRequest;
+import android.drm.DrmInfoStatus;
+import android.drm.DrmRights;
+import android.drm.DrmStore;
+import android.drm.DrmUtils;
+
+@TestTargetClass(DrmManagerClient.class)
+public class DRMTest extends AndroidTestCase {
+    private static String TAG = "CtsDRMTest";
+    private static final int WAIT_TIME = 60000; // 1 min max
+
+    private Object mLock = new Object();
+    private ArrayList<Config> mConfigs = new ArrayList<Config>();
+    private DrmRights mDrmRights;
+    private DrmManagerClient mDrmManagerClient;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mDrmManagerClient = new DrmManagerClient(getContext());
+        String[] plugins = mDrmManagerClient.getAvailableDrmEngines();
+
+        mConfigs.clear();
+        for(String plugInName : plugins) {
+            Config config = ConfigFactory.getConfig(plugInName);
+            if (null != config) {
+                mConfigs.add(config);
+            }
+        }
+    }
+
+    private void register(Config config) throws Exception {
+        DrmInfo drmInfo = executeAcquireDrmInfo(DrmInfoRequest.TYPE_REGISTRATION_INFO,
+                                            config.getInfoOfRegistration(),
+                                            config.getMimeType());
+        executeProcessDrmInfo(drmInfo, config);
+    }
+
+    private void acquireRights(Config config) throws Exception {
+        DrmInfo drmInfo = executeAcquireDrmInfo(DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_INFO,
+                                            config.getInfoOfRightsAcquisition(),
+                                            config.getMimeType());
+        executeProcessDrmInfo(drmInfo, config);
+    }
+
+    private void deregister(Config config) throws Exception {
+        DrmInfo drmInfo = executeAcquireDrmInfo(DrmInfoRequest.TYPE_UNREGISTRATION_INFO,
+                                            config.getInfoOfRegistration(),
+                                            config.getMimeType());
+        executeProcessDrmInfo(drmInfo, config);
+    }
+
+    public void testIsDrmDirectoryExist() {
+        assertTrue("/data/drm/ does not exist", new File("/data/drm/").exists());
+    }
+
+    public void testRegisterAndDeregister() throws Exception {
+        for (Config config : mConfigs) {
+            register(config);
+            deregister(config);
+        }
+    }
+
+    public void testAcquireRights() throws Exception {
+        for (Config config : mConfigs) {
+            register(config);
+            acquireRights(config);
+            deregister(config);
+        }
+    }
+
+    public void testGetConstraints() throws Exception {
+        for (Config config : mConfigs) {
+            register(config);
+            acquireRights(config);
+            ContentValues constraints = mDrmManagerClient.getConstraints(
+                                            config.getContentPath(),
+                                            DrmStore.Action.DEFAULT);
+            assertNotNull("Failed on plugin: " + config.getPluginName(), constraints);
+            deregister(config);
+        }
+    }
+
+    public void testCanHandle() throws Exception {
+        for (Config config : mConfigs) {
+            assertTrue("Failed on plugin: " + config.getPluginName(),
+                    mDrmManagerClient.canHandle(config.getContentPath(), config.getMimeType()));
+        }
+    }
+
+    public void testGetOriginalMimeType() throws Exception {
+        for (Config config : mConfigs) {
+            assertNotNull("Failed on plugin: " + config.getPluginName(),
+                    mDrmManagerClient.getOriginalMimeType(config.getContentPath()));
+        }
+    }
+
+    public void testCheckRightsStatus() throws Exception {
+        for (Config config : mConfigs) {
+            register(config);
+            acquireRights(config);
+            int rightsStatus = mDrmManagerClient.checkRightsStatus(
+                                                config.getContentPath(),
+                                                DrmStore.Action.PLAY);
+            assertEquals("Failed on plugin: " + config.getPluginName(),
+                    DrmStore.RightsStatus.RIGHTS_VALID, rightsStatus);
+            deregister(config);
+        }
+    }
+
+    public void testRemoveRights() throws Exception {
+        for (Config config : mConfigs) {
+            assertEquals("Failed on plugin: " + config.getPluginName(),
+                    DrmManagerClient.ERROR_NONE,
+                    mDrmManagerClient.removeRights(config.getContentPath()));
+        }
+    }
+
+    public void testRemoveAllRights() throws Exception {
+        for (Config config : mConfigs) {
+            assertEquals("Failed on plugin: " + config.getPluginName(),
+                    mDrmManagerClient.removeAllRights(), DrmManagerClient.ERROR_NONE);
+        }
+    }
+
+    public void testConvertData() throws Exception {
+        for (Config config : mConfigs) {
+            byte[] inputData = new byte[]{'T','E','S','T'};
+
+            int convertId = mDrmManagerClient.openConvertSession(config.getMimeType());
+            DrmConvertedStatus drmConvertStatus
+                                = mDrmManagerClient.convertData(convertId, inputData);
+            mDrmManagerClient.closeConvertSession(convertId);
+        }
+    }
+
+    private DrmInfo executeAcquireDrmInfo(
+            int type, HashMap<String, String> request, String mimeType) throws Exception {
+        DrmInfoRequest infoRequest = new DrmInfoRequest(type, mimeType);
+
+        for (Iterator it = request.keySet().iterator(); it.hasNext(); ) {
+            String key = (String) it.next();
+            String value = request.get(key);
+            infoRequest.put(key, value);
+        }
+
+        return mDrmManagerClient.acquireDrmInfo(infoRequest);
+    }
+
+    private void executeProcessDrmInfo(DrmInfo drmInfo, Config config) throws Exception {
+        assertNotNull("Failed on plugin: " + config.getPluginName(), drmInfo);
+
+        mDrmManagerClient.setOnEventListener(new OnEventListenerImpl(config));
+        drmInfo.put(DrmInfoRequest.ACCOUNT_ID, config.getAccountId());
+        assertEquals("Failed on plugin: " + config.getPluginName(),
+                DrmManagerClient.ERROR_NONE, mDrmManagerClient.processDrmInfo(drmInfo));
+
+        synchronized(mLock) {
+            try {
+                mLock.wait(WAIT_TIME);
+            } catch(Exception e) {
+                Log.v(TAG, "ProcessDrmInfo: wait was interrupted.");
+            }
+        }
+    }
+
+    private class OnEventListenerImpl implements DrmManagerClient.OnEventListener {
+        private Config mConfig;
+        public OnEventListenerImpl(Config config) {
+            mConfig = config;
+        }
+
+        @Override
+        public void onEvent(DrmManagerClient client, DrmEvent event) {
+            switch (event.getType()) {
+            case DrmEvent.TYPE_DRM_INFO_PROCESSED:
+                Log.d(TAG, "processDrmInfo() completed");
+                DrmInfoStatus infoStatus
+                        = (DrmInfoStatus) event.getAttribute(DrmEvent.DRM_INFO_STATUS_OBJECT);
+                switch (infoStatus.infoType) {
+                case DrmInfoRequest.TYPE_RIGHTS_ACQUISITION_INFO:
+                    mDrmRights = new DrmRights(infoStatus.data, infoStatus.mimeType);
+                    assertNotNull(mDrmRights);
+                    try {
+                        assertEquals(DrmManagerClient.ERROR_NONE, mDrmManagerClient.saveRights(
+                                    mDrmRights, mConfig.getRightsPath(), mConfig.getContentPath()));
+                        Log.d(TAG, "Rights saved");
+                    } catch (IOException e) {
+                        Log.e(TAG, "Save Rights failed");
+                        e.printStackTrace();
+                    }
+                    break;
+                case DrmInfoRequest.TYPE_REGISTRATION_INFO:
+                    Log.d(TAG, "Registration completed");
+                    break;
+                case DrmInfoRequest.TYPE_UNREGISTRATION_INFO:
+                    Log.d(TAG, "Deregistration completed");
+                    break;
+                default:
+                    break;
+                }
+                break;
+            default:
+                break;
+            }
+            synchronized (mLock) {
+                mLock.notify();
+            }
+        }
+    }
+}
diff --git a/tests/tests/drm/src/android/drm/cts/configs/FwdLockConfig.java b/tests/tests/drm/src/android/drm/cts/configs/FwdLockConfig.java
new file mode 100644
index 0000000..e67ff03
--- /dev/null
+++ b/tests/tests/drm/src/android/drm/cts/configs/FwdLockConfig.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2011 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.drm.cts.configs;
+
+import java.util.HashMap;
+
+import android.drm.cts.Config;
+
+public class FwdLockConfig implements Config {
+    private static FwdLockConfig sInstance = new FwdLockConfig();
+    private FwdLockConfig() {}
+    public static FwdLockConfig getInstance() {
+        return sInstance;
+    }
+    public String getPluginName() {
+        return "Forward Lock";
+    }
+    public String getMimeType() {
+        return "application/x-android-drm-fl";
+    }
+    public String getAccountId() {
+        return "01234567";
+    }
+    public String getRightsPath() {
+        // Fwd lock does not have rights but send back dummy string anyways.
+        return "/sdcard/non_existing_rights.xml";
+    }
+    public String getContentPath() {
+        return "/sdcard/dummy_fwdlock_content.dm";
+    }
+    public HashMap<String, String> getInfoOfRegistration() {
+        return sInfoOfRegistration;
+    }
+    public HashMap<String, String> getInfoOfUnregistration() {
+        return sInfoOfUnregistration;
+    }
+    public HashMap<String, String> getInfoOfRightsAcquisition(){
+        return sInfoOfRightsAcquisition;
+    }
+
+    private static HashMap<String, String> sInfoOfRegistration = new HashMap<String, String>();
+    private static HashMap<String, String> sInfoOfUnregistration = new HashMap<String, String>();
+    private static HashMap<String, String> sInfoOfRightsAcquisition =
+        new HashMap<String, String>();
+
+    static {
+        sInfoOfRegistration.put("Dummy-FwdLock-1", "Dummy-FwdLock-1");
+
+        sInfoOfUnregistration.put("Dummy-FwdLock-2", "Dummy-FwdLock-2");
+
+        sInfoOfRightsAcquisition.put("Dummy-FwdLock-3", "Dummy-FwdLock-3");
+    }
+}
diff --git a/tests/tests/drm/src/android/drm/cts/configs/PassthruConfig.java b/tests/tests/drm/src/android/drm/cts/configs/PassthruConfig.java
new file mode 100644
index 0000000..7310825
--- /dev/null
+++ b/tests/tests/drm/src/android/drm/cts/configs/PassthruConfig.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2011 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.drm.cts.configs;
+
+import java.util.HashMap;
+
+import android.drm.cts.Config;
+
+public class PassthruConfig implements Config {
+    private static PassthruConfig sInstance = new PassthruConfig();
+    private PassthruConfig() {}
+    public static PassthruConfig getInstance() {
+        return sInstance;
+    }
+    public String getPluginName() {
+        return "Passthru";
+    }
+    public String getMimeType() {
+        return "application/vnd.passthru.drm";
+    }
+    public String getAccountId() {
+        return "01234567";
+    }
+    public String getRightsPath() {
+        return "/sdcard/dummy_passthru_rights.xml";
+    }
+    public String getContentPath() {
+        return "/sdcard/dummy_passthru_content.passthru";
+    }
+    public HashMap<String, String> getInfoOfRegistration() {
+        return sInfoOfRegistration;
+    }
+    public HashMap<String, String> getInfoOfUnregistration() {
+        return sInfoOfUnregistration;
+    }
+    public HashMap<String, String> getInfoOfRightsAcquisition(){
+        return sInfoOfRightsAcquisition;
+    }
+
+    private static HashMap<String, String> sInfoOfRegistration = new HashMap<String, String>();
+    private static HashMap<String, String> sInfoOfUnregistration = new HashMap<String, String>();
+    private static HashMap<String, String> sInfoOfRightsAcquisition = new HashMap<String, String>();
+
+    static {
+        sInfoOfRegistration.put("Foo-1", "foo-1");
+
+        sInfoOfUnregistration.put("Foo-2", "foo-2");
+
+        sInfoOfRightsAcquisition.put("Foo-3", "foo-3");
+    }
+}
diff --git a/tests/tests/graphics/src/android/graphics/cts/RadialGradientTest.java b/tests/tests/graphics/src/android/graphics/cts/RadialGradientTest.java
deleted file mode 100644
index 3db864b..0000000
--- a/tests/tests/graphics/src/android/graphics/cts/RadialGradientTest.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * 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.graphics.cts;
-
-import dalvik.annotation.TestLevel;
-import dalvik.annotation.TestTargetClass;
-import dalvik.annotation.TestTargetNew;
-
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.RadialGradient;
-import android.graphics.Shader;
-import android.graphics.Shader.TileMode;
-
-import junit.framework.TestCase;
-
-@TestTargetClass(RadialGradient.class)
-public class RadialGradientTest extends TestCase {
-    private static final int SIZE = 200;
-    private static final int RADIUS = 80;
-    private static final int CENTER = SIZE / 2;
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        method = "RadialGradient",
-        args = {float.class, float.class, float.class, int[].class, float[].class,
-                TileMode.class}
-    )
-    public void testRadialGradient() {
-        final int[] colors = { Color.BLUE, Color.GREEN, Color.RED };
-        final float[] positions = { 0f, 0.3f, 1f };
-        int tolerance = (int)(0xFF / (0.3f * RADIUS) * 2);
-        RadialGradient rg = new RadialGradient(CENTER, CENTER, RADIUS, colors, positions,
-                Shader.TileMode.CLAMP);
-        Bitmap b = Bitmap.createBitmap(SIZE, SIZE, Bitmap.Config.ARGB_8888);
-        Canvas canvas = new Canvas(b);
-        Paint p = new Paint();
-        p.setShader(rg);
-        canvas.drawRect(0, 0, SIZE, SIZE, p);
-        checkPixels(b, colors, positions, tolerance);
-    }
-
-    @TestTargetNew(
-        level = TestLevel.COMPLETE,
-        method = "RadialGradient",
-        args = {float.class, float.class, float.class, int.class, int.class, TileMode.class}
-    )
-    public void testRadialGradientWithColor() {
-        final int[] colors = { Color.BLUE, Color.GREEN };
-        final float[] positions = { 0f, 1f };
-        int tolerance = (int)(0xFF / RADIUS * 2);
-        RadialGradient rg = new RadialGradient(CENTER, CENTER, RADIUS, colors[0], colors[1],
-                Shader.TileMode.CLAMP);
-        Bitmap b = Bitmap.createBitmap(SIZE, SIZE, Bitmap.Config.ARGB_8888);
-        Canvas canvas = new Canvas(b);
-        Paint p = new Paint();
-        p.setShader(rg);
-        canvas.drawRect(0, 0, SIZE, SIZE, p);
-        checkPixels(b, colors, positions, tolerance);
-    }
-
-    private void checkPixels(Bitmap bitmap, int[] colors, float[] positions, int tolerance) {
-        for (int y = 0; y < SIZE; y++) {
-            for (int x = 0; x < SIZE; x++) {
-                double dist = dist(x, y, CENTER, CENTER) / RADIUS;
-                int idx;
-                int color;
-                for (idx = 0; idx < positions.length; idx++) {
-                    if (positions[idx] > dist) {
-                        break;
-                    }
-                }
-                if (idx == 0) {
-                    // use start color
-                    color = colors[0];
-                } else if (idx == positions.length) {
-                    // clamp to end color
-                    color = colors[positions.length - 1];
-                } else {
-                    // linear interpolation
-                    int i1 = idx - 1; // index of next lower color and position
-                    int i2 = idx; // index of next higher color and position
-                    double delta = (dist - positions[i1]) / (positions[i2] - positions[i1]);
-                    int alpha = (int) ((1d - delta) * Color.alpha(colors[i1]) +
-                            delta * Color.alpha(colors[i2]));
-                    int red = (int) ((1d - delta) * Color.red(colors[i1]) +
-                            delta * Color.red(colors[i2]));
-                    int green = (int) ((1d - delta) * Color.green(colors[i1]) +
-                            delta * Color.green(colors[i2]));
-                    int blue = (int) ((1d - delta) * Color.blue(colors[i1]) +
-                            delta * Color.blue(colors[i2]));
-                    color = Color.argb(alpha, red, green, blue);
-                }
-                int pixel = bitmap.getPixel(x, y);
-
-                assertEquals(Color.alpha(color), Color.alpha(pixel), tolerance);
-                assertEquals(Color.red(color), Color.red(pixel), tolerance);
-                assertEquals(Color.green(color), Color.green(pixel), tolerance);
-                assertEquals(Color.blue(color), Color.blue(pixel), tolerance);
-            }
-        }
-    }
-
-    /**
-     * Calculate distance between two points.
-     */
-    private double dist(int x1, int y1, int x2, int y2) {
-        int distX = x1 - x2;
-        int distY = y1 - y2;
-        return Math.sqrt(distX * distX + distY * distY);
-    }
-
-}
diff --git a/tests/tests/hardware/src/android/hardware/cts/CameraTest.java b/tests/tests/hardware/src/android/hardware/cts/CameraTest.java
index ec6c5b7..a336328 100644
--- a/tests/tests/hardware/src/android/hardware/cts/CameraTest.java
+++ b/tests/tests/hardware/src/android/hardware/cts/CameraTest.java
@@ -162,7 +162,9 @@
         public void onPreviewFrame(byte [] data, Camera camera) {
             assertNotNull(data);
             Size size = camera.getParameters().getPreviewSize();
-            assertEquals(size.width * size.height * 3 / 2, data.length);
+            int format = camera.getParameters().getPreviewFormat();
+            int bitsPerPixel = ImageFormat.getBitsPerPixel(format);
+            assertEquals(size.width * size.height * bitsPerPixel / 8, data.length);
             mPreviewCallbackResult = true;
             mCamera.stopPreview();
             if (LOGV) Log.v(TAG, "notify the preview callback");
@@ -223,7 +225,7 @@
     private final class TestErrorCallback implements ErrorCallback {
         public void onError(int error, Camera camera) {
             mErrorCallbackResult = true;
-            fail("The Error code is: " + error);
+            fail("Got camera error from ErrorCallback: " + error);
         }
     }
 
@@ -577,7 +579,6 @@
         // Parameters constants
         final int PICTURE_FORMAT = ImageFormat.JPEG;
         final int PREVIEW_FORMAT = ImageFormat.NV21;
-        final int PREVIEW_FRAMERATE = 10;
 
         // Before setting Parameters
         final int origPictureFormat = parameters.getPictureFormat();
@@ -623,7 +624,9 @@
         int jpegThumnailQuality = parameters.getJpegThumbnailQuality();
         assertTrue(previewSizes != null && previewSizes.size() != 0);
         assertTrue(pictureSizes != null && pictureSizes.size() != 0);
-        assertTrue(previewFormats != null && previewFormats.size() != 0);
+        assertTrue(previewFormats != null && previewFormats.size() >= 2);
+        assertTrue(previewFormats.contains(ImageFormat.NV21));
+        assertTrue(previewFormats.contains(ImageFormat.YV12));
         assertTrue(pictureFormats != null && pictureFormats.size() != 0);
         assertTrue(frameRates != null && frameRates.size() != 0);
         assertTrue(focusModes != null && focusModes.size() != 0);
@@ -899,6 +902,7 @@
         assertEquals((float)latitude, latLong[0], 0.0001f);
         assertEquals((float)longitude, latLong[1], 0.0001f);
         assertEquals(altitude, exif.getAltitude(-1), 1);
+        assertEquals(timestamp, exif.getGpsDateTime() / 1000);
     }
 
     private void checkGpsDataNull(ExifInterface exif) {
@@ -1039,9 +1043,11 @@
             callback.mNumCbWithBuffer1 = 0;
             callback.mNumCbWithBuffer2 = 0;
             callback.mNumCbWithBuffer3 = 0;
-            callback.mBuffer1 = new byte[size.width * size.height * 3 / 2];
-            callback.mBuffer2 = new byte[size.width * size.height * 3 / 2];
-            callback.mBuffer3 = new byte[size.width * size.height * 3 / 2];
+            int format = mCamera.getParameters().getPreviewFormat();
+            int bitsPerPixel = ImageFormat.getBitsPerPixel(format);
+            callback.mBuffer1 = new byte[size.width * size.height * bitsPerPixel / 8];
+            callback.mBuffer2 = new byte[size.width * size.height * bitsPerPixel / 8];
+            callback.mBuffer3 = new byte[size.width * size.height * bitsPerPixel / 8];
 
             // Test if we can get the preview callbacks with specified buffers.
             mCamera.addCallbackBuffer(callback.mBuffer1);
@@ -1549,7 +1555,10 @@
             assertNotNull(data);
             Size size = camera.getParameters().getPreviewSize();
             assertEquals(expectedPreviewSize, size);
-            assertEquals(size.width * size.height * 3 / 2, data.length);
+            int format = camera.getParameters().getPreviewFormat();
+            int bitsPerPixel = ImageFormat.getBitsPerPixel(format);
+            assertEquals(size.width * size.height * bitsPerPixel / 8, data.length);
+            camera.setPreviewCallback(null);
             mPreviewCallbackResult = true;
             mPreviewDone.open();
         }
@@ -1596,9 +1605,11 @@
 
         // Test if the actual fps is within fps range.
         Size size = parameters.getPreviewSize();
-        byte[] buffer1 = new byte[size.width * size.height * 3 / 2];
-        byte[] buffer2 = new byte[size.width * size.height * 3 / 2];
-        byte[] buffer3 = new byte[size.width * size.height * 3 / 2];
+        int format = mCamera.getParameters().getPreviewFormat();
+        int bitsPerPixel = ImageFormat.getBitsPerPixel(format);
+        byte[] buffer1 = new byte[size.width * size.height * bitsPerPixel / 8];
+        byte[] buffer2 = new byte[size.width * size.height * bitsPerPixel / 8];
+        byte[] buffer3 = new byte[size.width * size.height * bitsPerPixel / 8];
         FpsRangePreviewCb callback = new FpsRangePreviewCb();
         int[] readBackFps = new int[2];
         for (int[] fps: fpsList) {
@@ -1894,4 +1905,64 @@
 
         terminateMessageLooper();
     }
+
+    public void testGetParameterDuringFocus() throws Exception {
+        int nCameras = Camera.getNumberOfCameras();
+        for (int id = 0; id < nCameras; id++) {
+            Log.v(TAG, "Camera id=" + id);
+            testGetParameterDuringFocusByCamera(id);
+        }
+    }
+
+    private void testGetParameterDuringFocusByCamera(int cameraId) throws Exception {
+        initializeMessageLooper(cameraId);
+        mCamera.setPreviewDisplay(getActivity().getSurfaceView().getHolder());
+        mCamera.setErrorCallback(mErrorCallback);
+        mCamera.startPreview();
+        Parameters parameters = mCamera.getParameters();
+        for (String focusMode: parameters.getSupportedFocusModes()) {
+            if (focusMode.equals(parameters.FOCUS_MODE_AUTO)
+                    || focusMode.equals(parameters.FOCUS_MODE_MACRO)) {
+                parameters.setFocusMode(focusMode);
+                mCamera.setParameters(parameters);
+                mCamera.autoFocus(mAutoFocusCallback);
+                // This should not crash or throw exception.
+                mCamera.getParameters();
+                waitForFocusDone();
+
+
+                mCamera.autoFocus(mAutoFocusCallback);
+                // Add a small delay to make sure focus has started.
+                Thread.sleep(100);
+                // This should not crash or throw exception.
+                mCamera.getParameters();
+            }
+        }
+        terminateMessageLooper();
+    }
+
+    public void testPreviewFormats() throws Exception {
+        int nCameras = Camera.getNumberOfCameras();
+        for (int id = 0; id < nCameras; id++) {
+            Log.v(TAG, "Camera id=" + id);
+            testPreviewFormatsByCamera(id);
+        }
+    }
+
+    private void testPreviewFormatsByCamera(int cameraId) throws Exception {
+        initializeMessageLooper(cameraId);
+        mCamera.setPreviewDisplay(getActivity().getSurfaceView().getHolder());
+        mCamera.setErrorCallback(mErrorCallback);
+        Parameters parameters = mCamera.getParameters();
+        for (int format: parameters.getSupportedPreviewFormats()) {
+            Log.v(TAG, "Test preview format " + format);
+            parameters.setPreviewFormat(format);
+            mCamera.setParameters(parameters);
+            mCamera.setOneShotPreviewCallback(mPreviewCallback);
+            mCamera.startPreview();
+            waitForPreviewDone();
+            assertTrue(mPreviewCallbackResult);
+        }
+        terminateMessageLooper();
+    }
 }
diff --git a/tests/tests/jni/src/android/jni/cts/InstanceNonce.java b/tests/tests/jni/src/android/jni/cts/InstanceNonce.java
index a5bb01d..e1a7dea 100644
--- a/tests/tests/jni/src/android/jni/cts/InstanceNonce.java
+++ b/tests/tests/jni/src/android/jni/cts/InstanceNonce.java
@@ -22,7 +22,9 @@
  */
 public class InstanceNonce {
     static {
-        System.loadLibrary("jnitest");
+        if (!JniTestCase.isCpuAbiNone()) {
+            System.loadLibrary("jnitest");
+        }
     }
 
     /**
diff --git a/tests/tests/jni/src/android/jni/cts/JniCTest.java b/tests/tests/jni/src/android/jni/cts/JniCTest.java
index 950b534..eb14504 100644
--- a/tests/tests/jni/src/android/jni/cts/JniCTest.java
+++ b/tests/tests/jni/src/android/jni/cts/JniCTest.java
@@ -16,16 +16,17 @@
 
 package android.jni.cts;
 
-import junit.framework.TestCase;
 
 /**
  * Basic tests of calling the C functions that make up the JNI. This
  * class merely calls into native code and reports back if there was
  * a problem.
  */
-public class JniCTest extends TestCase {
+public class JniCTest extends JniTestCase {
     static {
-        System.loadLibrary("jnitest");
+        if (!JniTestCase.isCpuAbiNone()) {
+            System.loadLibrary("jnitest");
+        }
     }
 
     /**
diff --git a/tests/tests/jni/src/android/jni/cts/JniCppTest.java b/tests/tests/jni/src/android/jni/cts/JniCppTest.java
index ad4f377..6993b29 100644
--- a/tests/tests/jni/src/android/jni/cts/JniCppTest.java
+++ b/tests/tests/jni/src/android/jni/cts/JniCppTest.java
@@ -16,16 +16,17 @@
 
 package android.jni.cts;
 
-import junit.framework.TestCase;
 
 /**
  * Basic tests of calling the C++ functions that make up the JNI. This
  * class merely calls into native code and reports back if there was
  * a problem.
  */
-public class JniCppTest extends TestCase {
+public class JniCppTest extends JniTestCase {
     static {
-        System.loadLibrary("jnitest");
+        if (!JniTestCase.isCpuAbiNone()) {
+            System.loadLibrary("jnitest");
+        }
     }
 
     /**
diff --git a/tests/tests/jni/src/android/jni/cts/JniInstanceTest.java b/tests/tests/jni/src/android/jni/cts/JniInstanceTest.java
index a66e072..7c16a3a 100644
--- a/tests/tests/jni/src/android/jni/cts/JniInstanceTest.java
+++ b/tests/tests/jni/src/android/jni/cts/JniInstanceTest.java
@@ -16,14 +16,13 @@
 
 package android.jni.cts;
 
-import junit.framework.TestCase;
 
 /**
  * Basic native instance method tests. The "nonce" class being tested
  * by this class is a class defined in this package that declares the
  * bulk of its methods as native.
  */
-public class JniInstanceTest extends TestCase {
+public class JniInstanceTest extends JniTestCase {
     /** instance to use for all the tests */
     private InstanceNonce target;
 
@@ -165,7 +164,7 @@
     public void test_takeShort() {
         assertTrue(target.takeShort((short) 19991));
     }
-    
+
     /**
      * Test a simple value-taking method call, that returns whether it
      * got the expected value.
diff --git a/tests/tests/jni/src/android/jni/cts/JniStaticTest.java b/tests/tests/jni/src/android/jni/cts/JniStaticTest.java
index ff4411d..3036c71 100644
--- a/tests/tests/jni/src/android/jni/cts/JniStaticTest.java
+++ b/tests/tests/jni/src/android/jni/cts/JniStaticTest.java
@@ -16,14 +16,14 @@
 
 package android.jni.cts;
 
-import junit.framework.TestCase;
 
 /**
  * Basic static method tests. The "nonce" class being tested by this
  * class is a class defined in this package that declares the bulk of
  * its methods as native.
  */
-public class JniStaticTest extends TestCase {
+public class JniStaticTest extends JniTestCase {
+
     /**
      * Test a simple no-op and void-returning method call.
      */
@@ -166,7 +166,7 @@
     public void test_takeShort() {
         assertTrue(StaticNonce.takeShort((short) 19991));
     }
-    
+
     /**
      * Test a simple value-taking method call, that returns whether it
      * got the expected value.
diff --git a/tests/tests/jni/src/android/jni/cts/JniTestCase.java b/tests/tests/jni/src/android/jni/cts/JniTestCase.java
new file mode 100644
index 0000000..a137ff7
--- /dev/null
+++ b/tests/tests/jni/src/android/jni/cts/JniTestCase.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2011 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.jni.cts;
+
+import android.os.Build;
+
+import junit.framework.TestCase;
+
+class JniTestCase extends TestCase {
+
+    static boolean isCpuAbiNone() {
+        return "none".equalsIgnoreCase(Build.CPU_ABI);
+    }
+
+    @Override
+    protected void runTest() throws Throwable {
+        // Skip the JNI tests if ABI is none...
+        if (!isCpuAbiNone()) {
+            super.runTest();
+        }
+    }
+}
diff --git a/tests/tests/jni/src/android/jni/cts/StaticNonce.java b/tests/tests/jni/src/android/jni/cts/StaticNonce.java
index f9b3310..c84e899 100644
--- a/tests/tests/jni/src/android/jni/cts/StaticNonce.java
+++ b/tests/tests/jni/src/android/jni/cts/StaticNonce.java
@@ -22,7 +22,9 @@
  */
 public class StaticNonce {
     static {
-        System.loadLibrary("jnitest");
+        if (!JniTestCase.isCpuAbiNone()) {
+            System.loadLibrary("jnitest");
+        }
     }
 
     /**
diff --git a/tests/tests/media/src/android/media/cts/AudioRecordTest.java b/tests/tests/media/src/android/media/cts/AudioRecordTest.java
index 74b0952..1ddcdd5 100644
--- a/tests/tests/media/src/android/media/cts/AudioRecordTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioRecordTest.java
@@ -139,6 +139,9 @@
         )
     })
     public void testAudioRecordProperties() throws Exception {
+        if (!hasMicrophone()) {
+            return;
+        }
         assertEquals(AudioFormat.ENCODING_PCM_16BIT, mAudioRecord.getAudioFormat());
         assertEquals(MediaRecorder.AudioSource.DEFAULT, mAudioRecord.getAudioSource());
         assertEquals(1, mAudioRecord.getChannelCount());
@@ -226,6 +229,9 @@
         )
     })
     public void testAudioRecordOP() throws Exception {
+        if (!hasMicrophone()) {
+            return;
+        }
         final int SLEEP_TIME = 10;
         final int RECORD_TIME = 10000;
         assertEquals(AudioRecord.STATE_INITIALIZED, mAudioRecord.getState());
@@ -330,4 +336,8 @@
         mAudioRecord.release();
         assertEquals(AudioRecord.STATE_UNINITIALIZED, mAudioRecord.getState());
     }
+
+    private boolean hasMicrophone() {
+        return getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_MICROPHONE);
+    }
 }
diff --git a/tests/tests/media/src/android/media/cts/AudioRecord_BufferSizeTest.java b/tests/tests/media/src/android/media/cts/AudioRecord_BufferSizeTest.java
index d5a5ef6..504a304 100644
--- a/tests/tests/media/src/android/media/cts/AudioRecord_BufferSizeTest.java
+++ b/tests/tests/media/src/android/media/cts/AudioRecord_BufferSizeTest.java
@@ -16,6 +16,7 @@
 
 package android.media.cts;
 
+import android.content.pm.PackageManager;
 import android.media.AudioFormat;
 import android.media.AudioRecord;
 import android.media.MediaRecorder.AudioSource;
@@ -42,6 +43,9 @@
     private AudioRecord mAudioRecord;
 
     public void testGetMinBufferSize() throws Exception {
+        if (!hasMicrophone()) {
+            return;
+        }
         List<Integer> failedSampleRates = new ArrayList<Integer>();
         for (int i = 0; i < SAMPLE_RATES_IN_HZ.length; i++) {
             try {
@@ -88,4 +92,9 @@
             }
         }.run();
     }
+
+    private boolean hasMicrophone() {
+        return getContext().getPackageManager().hasSystemFeature(
+                PackageManager.FEATURE_MICROPHONE);
+    }
 }
diff --git a/tests/tests/media/src/android/media/cts/MediaPlayerTest.java b/tests/tests/media/src/android/media/cts/MediaPlayerTest.java
index 863c19c..ad8e008 100644
--- a/tests/tests/media/src/android/media/cts/MediaPlayerTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaPlayerTest.java
@@ -17,6 +17,7 @@
 
 import com.android.cts.stub.R;
 
+import android.content.pm.PackageManager;
 import android.content.res.AssetFileDescriptor;
 import android.media.AudioManager;
 import android.media.MediaPlayer;
@@ -362,6 +363,9 @@
     }
 
     public void testRecordAndPlay() throws Exception {
+        if (!hasMicrophone()) {
+            return;
+        }
         File outputFile = new File(Environment.getExternalStorageDirectory(),
                 "record_and_play.3gp");
         String outputFileLocation = outputFile.getAbsolutePath();
@@ -432,4 +436,9 @@
             mr.release();
         }
     }
+
+    private boolean hasMicrophone() {
+        return getActivity().getPackageManager().hasSystemFeature(
+                PackageManager.FEATURE_MICROPHONE);
+    }
 }
diff --git a/tests/tests/media/src/android/media/cts/MediaRecorderTest.java b/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
index 1962f59..db136f2 100644
--- a/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
+++ b/tests/tests/media/src/android/media/cts/MediaRecorderTest.java
@@ -20,6 +20,7 @@
 import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargets;
 
+import android.content.pm.PackageManager;
 import android.hardware.Camera;
 import android.media.MediaRecorder;
 import android.media.MediaRecorder.OnErrorListener;
@@ -150,7 +151,7 @@
         )
     })
     public void testRecorderCamera() throws Exception {
-        if (Camera.getNumberOfCameras() < 1) {
+        if (!hasCamera()) {
             return;
         }
         mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
@@ -265,7 +266,7 @@
         )
     })
     public void testRecorderVideo() throws Exception {
-        if (Camera.getNumberOfCameras() < 1) {
+        if (!hasCamera()) {
             return;
         }
         mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
@@ -335,6 +336,9 @@
         )
     })
     public void testRecorderAudio() throws Exception {
+        if (!hasMicrophone()) {
+            return;
+        }
         mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
         assertEquals(0, mMediaRecorder.getMaxAmplitude());
         mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
@@ -391,6 +395,9 @@
         )
     })
     public void testOnInfoListener() throws Exception {
+        if (!hasMicrophone()) {
+            return;
+        }
         mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
         mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
         mMediaRecorder.setMaxDuration(MAX_DURATION_MSEC);
@@ -407,6 +414,9 @@
         args = {int.class}
     )
     public void testSetMaxDuration() throws Exception {
+        if (!hasMicrophone()) {
+            return;
+        }
         mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
         mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
         mMediaRecorder.setMaxDuration(0);
@@ -424,15 +434,18 @@
         args = {int.class}
     )
     public void testSetMaxFileSize() throws Exception {
-            mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
-            mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
-            mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
-            mMediaRecorder.setMaxFileSize(0);
-            mMediaRecorder.prepare();
-            mMediaRecorder.start();
-            Thread.sleep(RECORD_TIME * 30);
-            mMediaRecorder.stop();
-            checkOutputExist();
+        if (!hasMicrophone()) {
+            return;
+        }
+        mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
+        mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
+        mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
+        mMediaRecorder.setMaxFileSize(0);
+        mMediaRecorder.prepare();
+        mMediaRecorder.start();
+        Thread.sleep(RECORD_TIME * 30);
+        mMediaRecorder.stop();
+        checkOutputExist();
     }
 
     @TestTargets({
@@ -483,6 +496,9 @@
         )
     })
     public void testOnErrorListener() throws Exception {
+        if (!hasMicrophone()) {
+            return;
+        }
         mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
         mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
         mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
@@ -504,4 +520,13 @@
         assertTrue(outFile.length() < 1.1 * maxFileSize);
         assertTrue(outFile.length() > 0);
     }
+
+    private boolean hasCamera() {
+        return getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA);
+    }
+
+    private boolean hasMicrophone() {
+        return getActivity().getPackageManager().hasSystemFeature(
+                PackageManager.FEATURE_MICROPHONE);
+    }
 }
diff --git a/tests/tests/os/src/android/os/cts/BuildVersionTest.java b/tests/tests/os/src/android/os/cts/BuildVersionTest.java
index 2ef5167..954507b 100644
--- a/tests/tests/os/src/android/os/cts/BuildVersionTest.java
+++ b/tests/tests/os/src/android/os/cts/BuildVersionTest.java
@@ -32,8 +32,8 @@
 
     private static final String LOG_TAG = "BuildVersionTest";
     private static final Set<String> EXPECTED_RELEASES =
-        new HashSet<String>(Arrays.asList("3.0", "3.0.1"));
-    private static final int EXPECTED_SDK = 11;
+        new HashSet<String>(Arrays.asList("3.1"));
+    private static final int EXPECTED_SDK = 12;
 
     public void testReleaseVersion() {
         // Applications may rely on the exact release version
diff --git a/tests/tests/os/src/android/os/cts/ParcelTest.java b/tests/tests/os/src/android/os/cts/ParcelTest.java
index 28d7728..52b068f 100644
--- a/tests/tests/os/src/android/os/cts/ParcelTest.java
+++ b/tests/tests/os/src/android/os/cts/ParcelTest.java
@@ -776,6 +776,30 @@
             assertEquals(c[i], d[i]);
         }
         p.recycle();
+
+        // Test array bounds checks (null already checked above).
+        p = Parcel.obtain();
+        try {
+            p.writeByteArray(c, -1, 1); // Negative offset.
+            fail();
+        } catch (RuntimeException expected) {
+        }
+        try {
+            p.writeByteArray(c, 0, -1); // Negative count.
+            fail();
+        } catch (RuntimeException expected) {
+        }
+        try {
+            p.writeByteArray(c, c.length + 1, 1); // High offset.
+            fail();
+        } catch (RuntimeException expected) {
+        }
+        try {
+            p.writeByteArray(c, 0, c.length + 1); // High count.
+            fail();
+        } catch (RuntimeException expected) {
+        }
+        p.recycle();
     }
 
     @TestTargets({
@@ -875,12 +899,11 @@
         d = new byte[c.length - 2];
         p.setDataPosition(0);
         p.readByteArray(d);
-        assertEquals(7, d.length);;
         for (int i = 0; i < d.length; i++) {
             Log.d("Trace", "i=" + i + " d[i]=" + d[i]);
         }
         for (int i = 0; i < 7; i++) {
-            assertEquals(c[i], d[i]);
+            assertEquals(c[i + 1], d[i]);
         }
         p.recycle();
     }
diff --git a/tests/tests/provider/src/android/provider/cts/BrowserTest.java b/tests/tests/provider/src/android/provider/cts/BrowserTest.java
index 9eb5b82..73db4c3 100644
--- a/tests/tests/provider/src/android/provider/cts/BrowserTest.java
+++ b/tests/tests/provider/src/android/provider/cts/BrowserTest.java
@@ -52,6 +52,7 @@
     private ContentResolver mContentResolver;
     private IContentProvider mProvider;
     private BrowserStubActivity mActivity;
+    private boolean mMasterSyncEnabled;
 
     // the backup for the 2 tables which we will modify in test cases
     private ArrayList<ContentValues> mBookmarksBackup;
@@ -72,14 +73,23 @@
         mBookmarksBackup = new ArrayList<ContentValues>();
         mSearchesBackup = new ArrayList<ContentValues>();
 
-        // backup the current contents in database (_id=1 is a fixed id root)
-        Cursor cursor = mProvider.query(Bookmarks.CONTENT_URI, null, "_id != 1", null, null);
+        // Disable sync
+        mMasterSyncEnabled = ContentResolver.getMasterSyncAutomatically();
+        ContentResolver.setMasterSyncAutomatically(false);
+
+        // backup the current contents in database
+        Cursor cursor = mProvider.query(Bookmarks.CONTENT_URI, null, null, null, null);
         if (cursor.moveToFirst()) {
             String[] colNames = cursor.getColumnNames();
             while (!cursor.isAfterLast()) {
                 ContentValues value = new ContentValues();
 
                 for (int i = 0; i < colNames.length; i++) {
+                    if (Bookmarks.PARENT_SOURCE_ID.equals(colNames[i])
+                            || Bookmarks.INSERT_AFTER_SOURCE_ID.equals(colNames[i])) {
+                        // These aren't actual columns, so skip them in the backup
+                        continue;
+                    }
                     switch (cursor.getType(i)) {
                     case Cursor.FIELD_TYPE_BLOB:
                         value.put(colNames[i], cursor.getBlob(i));
@@ -130,6 +140,7 @@
     @Override
     protected void tearDown() throws Exception {
         try {
+
             // clear all new contents added in test cases.
             Uri uri = Bookmarks.CONTENT_URI.buildUpon()
                 .appendQueryParameter(BrowserContract.CALLER_IS_SYNCADAPTER, "true")
@@ -139,12 +150,15 @@
 
             // recover the old backup contents
             for (ContentValues value : mBookmarksBackup) {
-                mProvider.insert(Bookmarks.CONTENT_URI, value);
+                mProvider.insert(uri, value);
             }
 
             for (ContentValues value : mSearchesBackup) {
                 mProvider.insert(Browser.SEARCHES_URI, value);
             }
+
+            // Re-enable sync
+            ContentResolver.setMasterSyncAutomatically(mMasterSyncEnabled);
         } finally {
             super.tearDown();
         }
diff --git a/tests/tests/provider/src/android/provider/cts/MediaStore_Audio_Playlists_MembersTest.java b/tests/tests/provider/src/android/provider/cts/MediaStore_Audio_Playlists_MembersTest.java
index c53393f..36d4303 100644
--- a/tests/tests/provider/src/android/provider/cts/MediaStore_Audio_Playlists_MembersTest.java
+++ b/tests/tests/provider/src/android/provider/cts/MediaStore_Audio_Playlists_MembersTest.java
@@ -155,8 +155,9 @@
         Uri membersUri = Members.getContentUri(MediaStoreAudioTestHelper.EXTERNAL_VOLUME_NAME,
                 playlistId);
         Uri audioUri = mContentResolver.insert(membersUri, values);
+
         assertNotNull(audioUri);
-        assertEquals(Uri.withAppendedPath(membersUri, Long.toString(mIdOfAudio1)), audioUri);
+        assertTrue(audioUri.toString().startsWith(membersUri.toString()));
 
         try {
             // query the audio info
@@ -164,7 +165,7 @@
             assertEquals(1, c.getCount());
             c.moveToFirst();
             long memberId = c.getLong(c.getColumnIndex(Members._ID));
-            assertTrue(memberId > 0);
+            assertEquals(memberId, Long.parseLong(audioUri.getPathSegments().get(5)));
             assertEquals(Audio1.EXTERNAL_DATA, c.getString(c.getColumnIndex(Members.DATA)));
             assertTrue(c.getLong(c.getColumnIndex(Members.DATE_ADDED)) > 0);
             assertEquals(Audio1.DATE_MODIFIED, c.getLong(c.getColumnIndex(Members.DATE_MODIFIED)));
diff --git a/tests/tests/renderscript/Android.mk b/tests/tests/renderscript/Android.mk
new file mode 100644
index 0000000..fc64614
--- /dev/null
+++ b/tests/tests/renderscript/Android.mk
@@ -0,0 +1,37 @@
+# Copyright (C) 2011 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)
+
+# Replace "Example" with your name.
+LOCAL_PACKAGE_NAME := CtsRenderscriptTestCases
+
+# Don't include this package in any target.
+LOCAL_MODULE_TAGS := optional
+
+# When built, explicitly put it in the data partition.
+LOCAL_MODULE_PATH := $(TARGET_OUT_DATA_APPS)
+
+# All tests should include android.test.runner.
+LOCAL_JAVA_LIBRARIES := android.test.runner
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_INSTRUMENTATION_FOR := CtsTestStubs
+
+LOCAL_SDK_VERSION := current
+
+include $(BUILD_PACKAGE)
diff --git a/tests/tests/renderscript/AndroidManifest.xml b/tests/tests/renderscript/AndroidManifest.xml
new file mode 100644
index 0000000..7205b3c
--- /dev/null
+++ b/tests/tests/renderscript/AndroidManifest.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 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.
+-->
+
+<!-- Replace all the "example" stuff below with your package name, and
+     remove this comment.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="com.android.cts.renderscript">
+
+    <application>
+        <uses-library android:name="android.test.runner" />
+    </application>
+
+    <!-- This is a self-instrumenting test package. -->
+    <instrumentation android:name="android.test.InstrumentationTestRunner"
+                     android:targetPackage="com.android.cts.stub"
+                     android:label="CTS tests of Renderscript component"/>
+
+</manifest>
+
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/AllocationTest.java b/tests/tests/renderscript/src/android/renderscript/cts/AllocationTest.java
new file mode 100644
index 0000000..b6afb70
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/AllocationTest.java
@@ -0,0 +1,417 @@
+/*
+ * Copyright (C) 2011 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.renderscript.cts;
+
+import com.android.cts.stub.R;
+
+import android.graphics.Bitmap;
+import android.renderscript.Allocation;
+import android.renderscript.AllocationAdapter;
+import android.renderscript.Allocation.MipmapControl;
+import android.renderscript.Element;
+import android.renderscript.RSIllegalArgumentException;
+import android.renderscript.Type;
+import android.renderscript.Type.Builder;
+import android.renderscript.Type.CubemapFace;
+
+public class AllocationTest extends RSBaseGraphics {
+
+    // Test power of two and non power of two, equal and non-equal sizes
+    void createTypedHelper(Element e) {
+
+        Type.Builder typeBuilder = new Type.Builder(mRS, e);
+        for (int mips = 0; mips <= 1; mips ++) {
+            boolean useMips = (mips == 1);
+
+            for (int faces = 0; faces <= 1; faces++) {
+                boolean useFaces = (faces == 1);
+
+                for (int x = 1; x < 8; x ++) {
+                    for (int y = 1; y < 8; y ++) {
+                        typeBuilder.setMipmaps(useMips);
+                        typeBuilder.setFaces(useFaces);
+                        typeBuilder.setX(x).setY(y);
+                        Allocation.createTyped(mRS, typeBuilder.create());
+                    }
+                }
+            }
+        }
+
+    }
+
+    void createTypedTextureHelper(Element e) {
+        // No mips graphics
+        Type.Builder typeBuilder = new Type.Builder(mRS, e);
+        Allocation.createTyped(mRS, typeBuilder.setX(8).create(),
+                               MipmapControl.MIPMAP_NONE,
+                               Allocation.USAGE_GRAPHICS_TEXTURE);
+        Allocation.createTyped(mRS, typeBuilder.setY(8).create(),
+                               MipmapControl.MIPMAP_NONE,
+                               Allocation.USAGE_GRAPHICS_TEXTURE);
+        // No mips graphics and script
+        Allocation.createTyped(mRS, typeBuilder.create(),
+                               MipmapControl.MIPMAP_NONE,
+                               Allocation.USAGE_GRAPHICS_TEXTURE |
+                               Allocation.USAGE_SCRIPT);
+        // With mips
+        Allocation.createTyped(mRS, typeBuilder.create(),
+                               MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
+                               Allocation.USAGE_GRAPHICS_TEXTURE);
+        Allocation.createTyped(mRS, typeBuilder.create(),
+                               MipmapControl.MIPMAP_FULL,
+                               Allocation.USAGE_GRAPHICS_TEXTURE |
+                               Allocation.USAGE_SCRIPT);
+
+        // Only texture npot
+        Allocation.createTyped(mRS, typeBuilder.setX(7).setY(1).create(),
+                               MipmapControl.MIPMAP_NONE,
+                               Allocation.USAGE_GRAPHICS_TEXTURE);
+        Allocation.createTyped(mRS, typeBuilder.setX(7).setY(3).create(),
+                               MipmapControl.MIPMAP_NONE,
+                               Allocation.USAGE_GRAPHICS_TEXTURE);
+        Allocation.createTyped(mRS, typeBuilder.setX(7).setY(7).create(),
+                               MipmapControl.MIPMAP_NONE,
+                               Allocation.USAGE_GRAPHICS_TEXTURE);
+
+        // Script and texture
+        Allocation.createTyped(mRS, typeBuilder.setX(7).setY(1).create(),
+                               MipmapControl.MIPMAP_NONE,
+                               Allocation.USAGE_GRAPHICS_TEXTURE |
+                               Allocation.USAGE_SCRIPT);
+        Allocation.createTyped(mRS, typeBuilder.setX(7).setY(3).create(),
+                               MipmapControl.MIPMAP_NONE,
+                               Allocation.USAGE_GRAPHICS_TEXTURE |
+                               Allocation.USAGE_SCRIPT);
+        Allocation.createTyped(mRS, typeBuilder.setX(7).setY(7).create(),
+                               MipmapControl.MIPMAP_NONE,
+                               Allocation.USAGE_GRAPHICS_TEXTURE |
+                               Allocation.USAGE_SCRIPT);
+    }
+
+    void createSizedHelper(Element e) {
+        for (int i = 1; i <= 8; i ++) {
+            Allocation A = Allocation.createSized(mRS, e, i);
+            assertEquals(A.getType().getElement(), e);
+            assertEquals(A.getType().getX(), i);
+        }
+    }
+
+    public void testCreateTyped() {
+         createTypedHelper(Element.A_8(mRS));
+         createTypedHelper(Element.RGB_565(mRS));
+         createTypedHelper(Element.RGB_888(mRS));
+         createTypedHelper(Element.RGBA_8888(mRS));
+         createTypedHelper(Element.F32(mRS));
+         createTypedHelper(Element.F32_2(mRS));
+         createTypedHelper(Element.F32_3(mRS));
+         createTypedHelper(Element.F32_4(mRS));
+         createTypedHelper(Element.BOOLEAN(mRS));
+         createTypedHelper(Element.F64(mRS));
+         createTypedHelper(Element.I8(mRS));
+         createTypedHelper(Element.I16(mRS));
+         createTypedHelper(Element.I32(mRS));
+         createTypedHelper(Element.I64(mRS));
+         createTypedHelper(Element.U8(mRS));
+         createTypedHelper(Element.U8_4(mRS));
+         createTypedHelper(Element.U16(mRS));
+         createTypedHelper(Element.U32(mRS));
+         createTypedHelper(Element.U64(mRS));
+         createTypedHelper(Element.MATRIX_2X2(mRS));
+         createTypedHelper(Element.MATRIX_3X3(mRS));
+         createTypedHelper(Element.MATRIX_4X4(mRS));
+         createTypedHelper(Element.MESH(mRS));
+         createTypedHelper(Element.PROGRAM_FRAGMENT(mRS));
+         createTypedHelper(Element.PROGRAM_RASTER(mRS));
+         createTypedHelper(Element.PROGRAM_STORE(mRS));
+         createTypedHelper(Element.PROGRAM_VERTEX(mRS));
+         createTypedHelper(Element.ALLOCATION(mRS));
+         createTypedHelper(Element.SAMPLER(mRS));
+         createTypedHelper(Element.SCRIPT(mRS));
+         createTypedHelper(Element.TYPE(mRS));
+
+         createTypedTextureHelper(Element.A_8(mRS));
+         createTypedTextureHelper(Element.RGB_565(mRS));
+         createTypedTextureHelper(Element.RGB_888(mRS));
+         createTypedTextureHelper(Element.RGBA_8888(mRS));
+    }
+
+    public void testCreateSized() {
+         createSizedHelper(Element.A_8(mRS));
+         createSizedHelper(Element.RGB_565(mRS));
+         createSizedHelper(Element.RGB_888(mRS));
+         createSizedHelper(Element.RGBA_8888(mRS));
+         createSizedHelper(Element.F32(mRS));
+         createSizedHelper(Element.F32_2(mRS));
+         createSizedHelper(Element.F32_3(mRS));
+         createSizedHelper(Element.F32_4(mRS));
+         createSizedHelper(Element.BOOLEAN(mRS));
+         createSizedHelper(Element.F64(mRS));
+         createSizedHelper(Element.I8(mRS));
+         createSizedHelper(Element.I16(mRS));
+         createSizedHelper(Element.I32(mRS));
+         createSizedHelper(Element.I64(mRS));
+         createSizedHelper(Element.U8(mRS));
+         createSizedHelper(Element.U8_4(mRS));
+         createSizedHelper(Element.U16(mRS));
+         createSizedHelper(Element.U32(mRS));
+         createSizedHelper(Element.U64(mRS));
+         createSizedHelper(Element.MATRIX_2X2(mRS));
+         createSizedHelper(Element.MATRIX_3X3(mRS));
+         createSizedHelper(Element.MATRIX_4X4(mRS));
+         createSizedHelper(Element.MESH(mRS));
+         createSizedHelper(Element.PROGRAM_FRAGMENT(mRS));
+         createSizedHelper(Element.PROGRAM_RASTER(mRS));
+         createSizedHelper(Element.PROGRAM_STORE(mRS));
+         createSizedHelper(Element.PROGRAM_VERTEX(mRS));
+         createSizedHelper(Element.ALLOCATION(mRS));
+         createSizedHelper(Element.SAMPLER(mRS));
+         createSizedHelper(Element.SCRIPT(mRS));
+         createSizedHelper(Element.TYPE(mRS));
+    }
+
+    static int bDimX = 48;
+    static int bDimY = 8;
+
+    void helperCreateFromBitmap(Bitmap B,
+                                Allocation.MipmapControl mc) {
+        for (int i = 0; i < 1; i++) {
+            for (int j = 0; j < 1; j++) {
+                for (int k = 0; k < 1; k++) {
+                    for (int l = 0; l < 1; l++) {
+                        int u = 0;
+                        u |= (i * Allocation.USAGE_SCRIPT);
+                        u |= (j * Allocation.USAGE_GRAPHICS_TEXTURE);
+                        u |= (k * Allocation.USAGE_GRAPHICS_VERTEX);
+                        u |= (l * Allocation.USAGE_GRAPHICS_CONSTANTS);
+                        assertTrue(null !=
+                            Allocation.createFromBitmap(mRS, B, mc, u));
+                        assertTrue(null !=
+                            Allocation.createCubemapFromBitmap(mRS, B, mc, u));
+                    }
+                }
+            }
+        }
+    }
+
+    public void testCreateFromBitmap() {
+        Bitmap B = Bitmap.createBitmap(bDimX, bDimY, Bitmap.Config.ARGB_8888);
+        Allocation.createFromBitmap(mRS, B);
+        Allocation.createCubemapFromBitmap(mRS, B);
+        for (Allocation.MipmapControl mc : Allocation.MipmapControl.values()) {
+            helperCreateFromBitmap(B, mc);
+        }
+
+        try {
+            int invalidUsage = 0x0010;
+            Allocation.createFromBitmap(mRS, B,
+                Allocation.MipmapControl.MIPMAP_NONE, invalidUsage);
+            fail("should throw RSIllegalArgumentException.");
+        } catch (RSIllegalArgumentException e) {
+        }
+
+        try {
+            // width % 6 != 0
+            Bitmap badB = Bitmap.createBitmap(47, 8, Bitmap.Config.ARGB_8888);
+            Allocation.createCubemapFromBitmap(mRS, badB,
+                Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
+            fail("should throw RSIllegalArgumentException.");
+        } catch (RSIllegalArgumentException e) {
+        }
+
+        try {
+            // width / 6 != height
+            Bitmap badB = Bitmap.createBitmap(48, 4, Bitmap.Config.ARGB_8888);
+            Allocation.createCubemapFromBitmap(mRS, badB,
+                Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
+            fail("should throw RSIllegalArgumentException.");
+        } catch (RSIllegalArgumentException e) {
+        }
+
+        try {
+            // height not power of 2
+            Bitmap badB = Bitmap.createBitmap(36, 6, Bitmap.Config.ARGB_8888);
+            Allocation.createCubemapFromBitmap(mRS, badB,
+                Allocation.MipmapControl.MIPMAP_NONE, Allocation.USAGE_SCRIPT);
+            fail("should throw RSIllegalArgumentException.");
+        } catch (RSIllegalArgumentException e) {
+        }
+    }
+
+    public void testAllocationMipmapControl() {
+        assertEquals(MipmapControl.MIPMAP_NONE,
+                     MipmapControl.valueOf("MIPMAP_NONE"));
+        assertEquals(MipmapControl.MIPMAP_FULL,
+                     MipmapControl.valueOf("MIPMAP_FULL"));
+        assertEquals(MipmapControl.MIPMAP_ON_SYNC_TO_TEXTURE,
+                     MipmapControl.valueOf("MIPMAP_ON_SYNC_TO_TEXTURE"));
+        // Make sure no new enums are added
+        assertEquals(3, Allocation.MipmapControl.values().length);
+
+        for (Allocation.MipmapControl mc : Allocation.MipmapControl.values()) {
+            Type.Builder b = new Type.Builder(mRS, Element.U8(mRS));
+            b.setX(8).setY(8);
+            Allocation.createTyped(mRS, b.create(), mc,
+                                   Allocation.USAGE_GRAPHICS_TEXTURE);
+        }
+    }
+
+    public void testCubemapFaces() {
+        Type.Builder b = new Type.Builder(mRS, Element.U8(mRS));
+        b.setX(8).setY(8).setFaces(true);
+        Allocation cubemap = Allocation.createTyped(mRS, b.create(),
+                                                    MipmapControl.MIPMAP_NONE,
+                                                    Allocation.USAGE_SCRIPT);
+        AllocationAdapter adapter = AllocationAdapter.create2D(mRS, cubemap);
+        for (Type.CubemapFace cf : Type.CubemapFace.values()) {
+            adapter.setFace(cf);
+        }
+    }
+
+    /*
+     * Test all copy from/to routines for byte/short/int/float
+     */
+
+    void helperFloatCopy(int nElems) {
+        Allocation A = Allocation.createSized(mRS, Element.F32(mRS), nElems);
+
+        float src[], dst[];
+        src = new float[nElems];
+        dst = new float[nElems];
+        for (int i = 0; i < nElems; i++) {
+            src[i] = (float)i;
+            dst[i] = -1.0f;
+        }
+
+        A.copyFrom(src);
+        A.copyTo(dst);
+
+        for (int i = 0; i < nElems; i++) {
+            assertEquals(dst[i], src[i]);
+        }
+    }
+
+    void helperByteCopy(int nElems) {
+        Allocation A = Allocation.createSized(mRS, Element.I8(mRS), nElems);
+
+        byte src[], dst[];
+        src = new byte[nElems];
+        dst = new byte[nElems];
+        for (int i = 0; i < nElems; i++) {
+            src[i] = (byte)i;
+            dst[i] = -1;
+        }
+
+        A.copyFrom(src);
+        A.copyTo(dst);
+
+        for (int i = 0; i < nElems; i++) {
+            assertEquals(dst[i], src[i]);
+        }
+    }
+
+    void helperShortCopy(int nElems) {
+        Allocation A = Allocation.createSized(mRS, Element.I16(mRS), nElems);
+
+        short src[], dst[];
+        src = new short[nElems];
+        dst = new short[nElems];
+        for (int i = 0; i < nElems; i++) {
+            src[i] = (short)i;
+            dst[i] = -1;
+        }
+
+        A.copyFrom(src);
+        A.copyTo(dst);
+
+        for (int i = 0; i < nElems; i++) {
+            assertEquals(dst[i], src[i]);
+        }
+    }
+
+    void helperIntCopy(int nElems) {
+        Allocation A = Allocation.createSized(mRS, Element.I32(mRS), nElems);
+
+        int src[], dst[];
+        src = new int[nElems];
+        dst = new int[nElems];
+        for (int i = 0; i < nElems; i++) {
+            src[i] = i;
+            dst[i] = -1;
+        }
+
+        A.copyFrom(src);
+        A.copyTo(dst);
+
+        for (int i = 0; i < nElems; i++) {
+            assertEquals(dst[i], src[i]);
+        }
+    }
+
+    void helperBaseObjCopy(int nElems) {
+        Allocation A =
+            Allocation.createSized(mRS, Element.ELEMENT(mRS), nElems);
+        Element E[] = new Element[nElems];
+        for (int i = 0; i < nElems; i++) {
+            E[i] = Element.BOOLEAN(mRS);
+        }
+
+        A.copyFrom(E);
+    }
+
+    void helperBitmapCopy(int x, int y) {
+        Bitmap bSrc = Bitmap.createBitmap(x, y, Bitmap.Config.ARGB_8888);
+        Bitmap bDst = Bitmap.createBitmap(x, y, Bitmap.Config.ARGB_8888);
+
+        for (int j = 0; j < y; j++) {
+            for (int i = 0; i < x; i++) {
+                bSrc.setPixel(i, j, 9);
+                bDst.setPixel(i, j, 0);
+            }
+        }
+
+        Type.Builder typeBuilder =
+            new Type.Builder(mRS, Element.RGBA_8888(mRS));
+        typeBuilder.setMipmaps(false);
+        typeBuilder.setFaces(false);
+        typeBuilder.setX(x).setY(y);
+        Allocation A = Allocation.createTyped(mRS, typeBuilder.create());
+
+        A.copyFrom(bSrc);
+        A.copyTo(bDst);
+
+        for (int j = 0; j < y; j++) {
+            for (int i = 0; i < x; i++) {
+                assertEquals(bSrc.getPixel(i, j), bDst.getPixel(i, j));
+            }
+        }
+    }
+
+    static int elemsToTest = 20;
+
+    public void testCopyOperations() {
+        for (int s = 8; s <= elemsToTest; s += 2) {
+            helperFloatCopy(s);
+            helperByteCopy(s);
+            helperShortCopy(s);
+            helperIntCopy(s);
+            helperBaseObjCopy(s);
+        }
+        helperBitmapCopy(bDimX, bDimY);
+    }
+}
+
+
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ComputeTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ComputeTest.java
new file mode 100644
index 0000000..8d24227
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ComputeTest.java
@@ -0,0 +1,244 @@
+/*
+ * Copyright (C) 2011 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.renderscript.cts;
+
+import android.renderscript.Allocation;
+
+import android.renderscript.Byte2;
+import android.renderscript.Byte3;
+import android.renderscript.Byte4;
+
+import android.renderscript.Float2;
+import android.renderscript.Float3;
+import android.renderscript.Float4;
+
+import android.renderscript.Int2;
+import android.renderscript.Int3;
+import android.renderscript.Int4;
+
+import android.renderscript.Long2;
+import android.renderscript.Long3;
+import android.renderscript.Long4;
+
+import android.renderscript.Short2;
+import android.renderscript.Short3;
+import android.renderscript.Short4;
+
+import com.android.cts.stub.R;
+
+public class ComputeTest extends RSBaseCompute {
+
+    public void testJavaVectorTypes() {
+        Byte2 b2 = new Byte2();
+        b2.x = 1;
+        b2.y = 2;
+        Byte3 b3 = new Byte3();
+        b3.x = 1;
+        b3.y = 2;
+        b3.z = 2;
+        Byte4 b4 = new Byte4();
+        b4.x = 1;
+        b4.y = 2;
+        b4.x = 3;
+        b4.w = 4;
+
+        Float2 f2 = new Float2();
+        f2.x = 1.0f;
+        f2.y = 2.0f;
+        f2 = new Float2(1.0f, 2.0f);
+        assertTrue(f2.x == 1.0f);
+        assertTrue(f2.y == 2.0f);
+        Float3 f3 = new Float3();
+        f3.x = 1.0f;
+        f3.y = 2.0f;
+        f3.z = 3.0f;
+        f3 = new Float3(1.0f, 2.0f, 3.0f);
+        assertTrue(f3.x == 1.0f);
+        assertTrue(f3.y == 2.0f);
+        assertTrue(f3.z == 3.0f);
+        Float4 f4 = new Float4();
+        f4.x = 1.0f;
+        f4.y = 2.0f;
+        f4.x = 3.0f;
+        f4.w = 4.0f;
+        f4 = new Float4(1.0f, 2.0f, 3.0f, 4.0f);
+        assertTrue(f4.x == 1.0f);
+        assertTrue(f4.y == 2.0f);
+        assertTrue(f4.z == 3.0f);
+        assertTrue(f4.w == 4.0f);
+
+        Int2 i2 = new Int2();
+        i2.x = 1;
+        i2.y = 2;
+        Int3 i3 = new Int3();
+        i3.x = 1;
+        i3.y = 2;
+        i3.z = 3;
+        Int4 i4 = new Int4();
+        i4.x = 1;
+        i4.y = 2;
+        i4.x = 3;
+        i4.w = 4;
+
+        Long2 l2 = new Long2();
+        l2.x = 1;
+        l2.y = 2;
+        Long3 l3 = new Long3();
+        l3.x = 1;
+        l3.y = 2;
+        l3.z = 3;
+        Long4 l4 = new Long4();
+        l4.x = 1;
+        l4.y = 2;
+        l4.x = 3;
+        l4.w = 4;
+
+        Short2 s2 = new Short2();
+        s2.x = 1;
+        s2.y = 2;
+        Short3 s3 = new Short3();
+        s3.x = 1;
+        s3.y = 2;
+        s3.z = 3;
+        Short4 s4 = new Short4();
+        s4.x = 1;
+        s4.y = 2;
+        s4.x = 3;
+        s4.w = 4;
+    }
+
+    private boolean initializeGlobals(ScriptC_primitives s) {
+        float pF = s.get_floatTest();
+        if (pF != 1.99f) {
+            return false;
+        }
+        s.set_floatTest(2.99f);
+
+        double pD = s.get_doubleTest();
+        if (pD != 2.05) {
+            return false;
+        }
+        s.set_doubleTest(3.05);
+
+        byte pC = s.get_charTest();
+        if (pC != -8) {
+            return false;
+        }
+        s.set_charTest((byte)-16);
+
+        short pS = s.get_shortTest();
+        if (pS != -16) {
+            return false;
+        }
+        s.set_shortTest((short)-32);
+
+        int pI = s.get_intTest();
+        if (pI != -32) {
+            return false;
+        }
+        s.set_intTest(-64);
+
+        long pL = s.get_longTest();
+        if (pL != 17179869184l) {
+            return false;
+        }
+        s.set_longTest(17179869185l);
+
+        long puL = s.get_ulongTest();
+        if (puL != 4611686018427387904L) {
+            return false;
+        }
+        s.set_ulongTest(4611686018427387903L);
+
+        long pLL = s.get_longlongTest();
+        if (pLL != 68719476736L) {
+            return false;
+        }
+        s.set_longlongTest(68719476735L);
+
+        long pu64 = s.get_uint64_tTest();
+        if (pu64 != 117179869184l) {
+            return false;
+        }
+        s.set_uint64_tTest(117179869185l);
+
+        ScriptField_AllVectorTypes avt;
+        avt = new ScriptField_AllVectorTypes(mRS, 1,
+                                             Allocation.USAGE_SCRIPT);
+        ScriptField_AllVectorTypes.Item avtItem;
+        avtItem = new ScriptField_AllVectorTypes.Item();
+        avtItem.b2.x = 1;
+        avtItem.b2.y = 2;
+        avtItem.b3.x = 1;
+        avtItem.b3.y = 2;
+        avtItem.b3.z = 3;
+        avtItem.b4.x = 1;
+        avtItem.b4.y = 2;
+        avtItem.b4.z = 3;
+        avtItem.b4.w = 4;
+
+        avtItem.s2.x = 1;
+        avtItem.s2.y = 2;
+        avtItem.s3.x = 1;
+        avtItem.s3.y = 2;
+        avtItem.s3.z = 3;
+        avtItem.s4.x = 1;
+        avtItem.s4.y = 2;
+        avtItem.s4.z = 3;
+        avtItem.s4.w = 4;
+
+        avtItem.i2.x = 1;
+        avtItem.i2.y = 2;
+        avtItem.i3.x = 1;
+        avtItem.i3.y = 2;
+        avtItem.i3.z = 3;
+        avtItem.i4.x = 1;
+        avtItem.i4.y = 2;
+        avtItem.i4.z = 3;
+        avtItem.i4.w = 4;
+
+        avtItem.f2.x = 1.0f;
+        avtItem.f2.y = 2.0f;
+        avtItem.f3.x = 1.0f;
+        avtItem.f3.y = 2.0f;
+        avtItem.f3.z = 3.0f;
+        avtItem.f4.x = 1.0f;
+        avtItem.f4.y = 2.0f;
+        avtItem.f4.z = 3.0f;
+        avtItem.f4.w = 4.0f;
+
+        avt.set(avtItem, 0, true);
+        s.bind_avt(avt);
+
+        return true;
+    }
+
+    /**
+     * Test primitive types.
+     */
+    public void testPrimitives() {
+        ScriptC_primitives t = new ScriptC_primitives(mRS,
+                                                      mRes,
+                                                      R.raw.primitives);
+
+        assertTrue(initializeGlobals(t));
+        t.invoke_test();
+        waitForMessage();
+        assertEquals(result, RS_MSG_TEST_PASSED);
+    }
+
+}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ElementTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ElementTest.java
new file mode 100644
index 0000000..7723c20
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ElementTest.java
@@ -0,0 +1,258 @@
+/*
+ * Copyright (C) 2011 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.renderscript.cts;
+
+import android.renderscript.Element;
+import android.renderscript.Element.DataType;
+import android.renderscript.Element.DataKind;
+
+public class ElementTest extends RSBaseCompute {
+
+    public void testCreatePixel() {
+        assertTrue(Element.createPixel(mRS,
+                                       DataType.UNSIGNED_8,
+                                       DataKind.PIXEL_A) != null);
+        assertTrue(Element.createPixel(mRS,
+                                       DataType.UNSIGNED_5_6_5,
+                                       DataKind.PIXEL_RGB) != null);
+        assertTrue(Element.createPixel(mRS,
+                                       DataType.UNSIGNED_8,
+                                       DataKind.PIXEL_RGB) != null);
+        assertTrue(Element.createPixel(mRS,
+                                       DataType.UNSIGNED_5_5_5_1,
+                                       DataKind.PIXEL_RGBA) != null);
+        assertTrue(Element.createPixel(mRS,
+                                       DataType.UNSIGNED_4_4_4_4,
+                                       DataKind.PIXEL_RGBA) != null);
+        assertTrue(Element.createPixel(mRS,
+                                       DataType.UNSIGNED_8,
+                                       DataKind.PIXEL_RGBA) != null);
+    }
+
+    public void testCreateVector() {
+
+        Element e = null;
+        for (int len = 2; len <= 4; len ++) {
+            assertTrue(Element.createVector(mRS, DataType.FLOAT_32, len) != null);
+            assertTrue(Element.createVector(mRS, DataType.FLOAT_64, len) != null);
+            assertTrue(Element.createVector(mRS, DataType.SIGNED_8, len) != null);
+            assertTrue(Element.createVector(mRS, DataType.SIGNED_16, len) != null);
+            assertTrue(Element.createVector(mRS, DataType.SIGNED_32, len) != null);
+            assertTrue(Element.createVector(mRS, DataType.SIGNED_64, len) != null);
+            assertTrue(Element.createVector(mRS, DataType.UNSIGNED_8, len) != null);
+            assertTrue(Element.createVector(mRS, DataType.UNSIGNED_16, len) != null);
+            assertTrue(Element.createVector(mRS, DataType.UNSIGNED_32, len) != null);
+            assertTrue(Element.createVector(mRS, DataType.UNSIGNED_64, len) != null);
+        }
+    }
+
+    public void testPrebuiltElements() {
+        assertTrue(Element.A_8(mRS) != null);
+        assertTrue(Element.RGBA_4444(mRS) != null);
+        assertTrue(Element.RGBA_5551(mRS) != null);
+        assertTrue(Element.RGB_565(mRS) != null);
+        assertTrue(Element.RGB_888(mRS) != null);
+        assertTrue(Element.RGBA_8888(mRS) != null);
+        assertTrue(Element.F32(mRS) != null);
+        assertTrue(Element.F32_2(mRS) != null);
+        assertTrue(Element.F32_3(mRS) != null);
+        assertTrue(Element.F32_4(mRS) != null);
+        assertTrue(Element.F64(mRS) != null);
+        assertTrue(Element.I8(mRS) != null);
+        assertTrue(Element.I16(mRS) != null);
+        assertTrue(Element.I32(mRS) != null);
+        assertTrue(Element.I64(mRS) != null);
+        assertTrue(Element.U8(mRS) != null);
+        assertTrue(Element.U8_4(mRS) != null);
+        assertTrue(Element.U16(mRS) != null);
+        assertTrue(Element.U32(mRS) != null);
+        assertTrue(Element.U64(mRS) != null);
+        assertTrue(Element.MATRIX_2X2(mRS) != null);
+        assertTrue(Element.MATRIX_3X3(mRS) != null);
+        assertTrue(Element.MATRIX_4X4(mRS) != null);
+        assertTrue(Element.MATRIX4X4(mRS) != null);
+        assertTrue(Element.MESH(mRS) != null);
+        assertTrue(Element.PROGRAM_FRAGMENT(mRS) != null);
+        assertTrue(Element.PROGRAM_RASTER(mRS) != null);
+        assertTrue(Element.PROGRAM_STORE(mRS) != null);
+        assertTrue(Element.PROGRAM_VERTEX(mRS) != null);
+        assertTrue(Element.ALLOCATION(mRS) != null);
+        assertTrue(Element.SAMPLER(mRS) != null);
+        assertTrue(Element.SCRIPT(mRS) != null);
+        assertTrue(Element.TYPE(mRS) != null);
+        assertTrue(Element.BOOLEAN(mRS) != null);
+        assertTrue(Element.ELEMENT(mRS) != null);
+    }
+
+    public void testElementBuilder() {
+        for (int arraySize = 1; arraySize <= 3; arraySize++) {
+            // Now test array size
+            Element.Builder eb = new Element.Builder(mRS);
+            eb.add(Element.A_8(mRS), "A_8", arraySize);
+            eb.add(Element.RGBA_4444(mRS), "RGBA_4444", arraySize);
+            eb.add(Element.RGBA_5551(mRS), "RGBA_5551", arraySize);
+            eb.add(Element.RGB_565(mRS), "RGB_565", arraySize);
+            eb.add(Element.RGB_888(mRS), "RGB_888", arraySize);
+            eb.add(Element.RGBA_8888(mRS), "RGBA_8888", arraySize);
+            eb.add(Element.F32(mRS), "F32", arraySize);
+            eb.add(Element.F32_2(mRS), "F32_2", arraySize);
+            eb.add(Element.F32_3(mRS), "F32_3", arraySize);
+            eb.add(Element.F32_4(mRS), "F32_4", arraySize);
+            eb.add(Element.F64(mRS), "F64", arraySize);
+            eb.add(Element.I8(mRS), "I8", arraySize);
+            eb.add(Element.I16(mRS), "I16", arraySize);
+            eb.add(Element.I32(mRS), "I32", arraySize);
+            eb.add(Element.I64(mRS), "I64", arraySize);
+            eb.add(Element.U8(mRS), "U8", arraySize);
+            eb.add(Element.U8_4(mRS), "U8_4", arraySize);
+            eb.add(Element.U16(mRS), "U16", arraySize);
+            eb.add(Element.U32(mRS), "U32", arraySize);
+            eb.add(Element.U64(mRS), "U64", arraySize);
+            eb.add(Element.MATRIX_2X2(mRS), "MATRIX_2X2", arraySize);
+            eb.add(Element.MATRIX_3X3(mRS), "MATRIX_3X3", arraySize);
+            eb.add(Element.MATRIX_4X4(mRS), "MATRIX_4X4", arraySize);
+            eb.add(Element.MATRIX4X4(mRS), "MATRIX4X4", arraySize);
+            eb.add(Element.MESH(mRS), "MESH", arraySize);
+            eb.add(Element.PROGRAM_FRAGMENT(mRS), "PROGRAM_FRAGMENT", arraySize);
+            eb.add(Element.PROGRAM_RASTER(mRS), "PROGRAM_RASTER", arraySize);
+            eb.add(Element.PROGRAM_STORE(mRS), "PROGRAM_STORE", arraySize);
+            eb.add(Element.PROGRAM_VERTEX(mRS), "PROGRAM_VERTEX", arraySize);
+            eb.add(Element.ALLOCATION(mRS), "ALLOCATION", arraySize);
+            eb.add(Element.SAMPLER(mRS), "SAMPLER", arraySize);
+            eb.add(Element.SCRIPT(mRS), "SCRIPT", arraySize);
+            eb.add(Element.TYPE(mRS), "TYPE", arraySize);
+            eb.add(Element.BOOLEAN(mRS), "BOOLEAN", arraySize);
+            eb.add(Element.ELEMENT(mRS), "ELEMENT", arraySize);
+            assertTrue(eb.create() != null);
+        }
+    }
+
+    public void testIsComplex() {
+        assertFalse(Element.A_8(mRS).isComplex());
+        assertFalse(Element.RGBA_4444(mRS).isComplex());
+        assertFalse(Element.RGBA_5551(mRS).isComplex());
+        assertFalse(Element.RGB_565(mRS).isComplex());
+        assertFalse(Element.RGB_888(mRS).isComplex());
+        assertFalse(Element.RGBA_8888(mRS).isComplex());
+        assertFalse(Element.F32(mRS).isComplex());
+        assertFalse(Element.F32_2(mRS).isComplex());
+        assertFalse(Element.F32_3(mRS).isComplex());
+        assertFalse(Element.F32_4(mRS).isComplex());
+        assertFalse(Element.F64(mRS).isComplex());
+        assertFalse(Element.I8(mRS).isComplex());
+        assertFalse(Element.I16(mRS).isComplex());
+        assertFalse(Element.I32(mRS).isComplex());
+        assertFalse(Element.I64(mRS).isComplex());
+        assertFalse(Element.U8(mRS).isComplex());
+        assertFalse(Element.U8_4(mRS).isComplex());
+        assertFalse(Element.U16(mRS).isComplex());
+        assertFalse(Element.U32(mRS).isComplex());
+        assertFalse(Element.U64(mRS).isComplex());
+        assertFalse(Element.MATRIX_2X2(mRS).isComplex());
+        assertFalse(Element.MATRIX_3X3(mRS).isComplex());
+        assertFalse(Element.MATRIX_4X4(mRS).isComplex());
+        assertFalse(Element.MATRIX4X4(mRS).isComplex());
+        assertFalse(Element.MESH(mRS).isComplex());
+        assertFalse(Element.PROGRAM_FRAGMENT(mRS).isComplex());
+        assertFalse(Element.PROGRAM_RASTER(mRS).isComplex());
+        assertFalse(Element.PROGRAM_STORE(mRS).isComplex());
+        assertFalse(Element.PROGRAM_VERTEX(mRS).isComplex());
+        assertFalse(Element.ALLOCATION(mRS).isComplex());
+        assertFalse(Element.SAMPLER(mRS).isComplex());
+        assertFalse(Element.SCRIPT(mRS).isComplex());
+        assertFalse(Element.TYPE(mRS).isComplex());
+        assertFalse(Element.BOOLEAN(mRS).isComplex());
+        assertFalse(Element.ELEMENT(mRS).isComplex());
+
+        Element.Builder eb = new Element.Builder(mRS);
+        eb.add(Element.F32(mRS), "FLOAT");
+        eb.add(Element.SAMPLER(mRS), "SAMPLER");
+        Element e1 = eb.create();
+        assertFalse(e1.isComplex());
+
+        eb = new Element.Builder(mRS);
+        eb.add(Element.A_8(mRS), "A_8");
+        eb.add(Element.RGBA_4444(mRS), "RGBA_4444");
+        Element e2 = eb.create();
+        assertFalse(e2.isComplex());
+
+        eb = new Element.Builder(mRS);
+        eb.add(e1, "e1");
+        eb.add(e2, "e2");
+        assertTrue(eb.create().isComplex());
+    }
+
+    public void testDataType() {
+        assertEquals(DataType.FLOAT_32, DataType.valueOf("FLOAT_32"));
+        assertEquals(DataType.FLOAT_64, DataType.valueOf("FLOAT_64"));
+        assertEquals(DataType.SIGNED_8, DataType.valueOf("SIGNED_8"));
+        assertEquals(DataType.SIGNED_16, DataType.valueOf("SIGNED_16"));
+        assertEquals(DataType.SIGNED_32, DataType.valueOf("SIGNED_32"));
+        assertEquals(DataType.SIGNED_64, DataType.valueOf("SIGNED_64"));
+        assertEquals(DataType.UNSIGNED_8, DataType.valueOf("UNSIGNED_8"));
+        assertEquals(DataType.UNSIGNED_16, DataType.valueOf("UNSIGNED_16"));
+        assertEquals(DataType.UNSIGNED_32, DataType.valueOf("UNSIGNED_32"));
+        assertEquals(DataType.UNSIGNED_64, DataType.valueOf("UNSIGNED_64"));
+
+        assertEquals(DataType.BOOLEAN, DataType.valueOf("BOOLEAN"));
+
+        assertEquals(DataType.UNSIGNED_5_6_5, DataType.valueOf("UNSIGNED_5_6_5"));
+        assertEquals(DataType.UNSIGNED_5_5_5_1, DataType.valueOf("UNSIGNED_5_5_5_1"));
+        assertEquals(DataType.UNSIGNED_4_4_4_4, DataType.valueOf("UNSIGNED_4_4_4_4"));
+
+        assertEquals(DataType.MATRIX_4X4, DataType.valueOf("MATRIX_4X4"));
+        assertEquals(DataType.MATRIX_3X3, DataType.valueOf("MATRIX_3X3"));
+        assertEquals(DataType.MATRIX_2X2, DataType.valueOf("MATRIX_2X2"));
+
+        assertEquals(DataType.RS_ELEMENT, DataType.valueOf("RS_ELEMENT"));
+        assertEquals(DataType.RS_TYPE, DataType.valueOf("RS_TYPE"));
+        assertEquals(DataType.RS_ALLOCATION, DataType.valueOf("RS_ALLOCATION"));
+        assertEquals(DataType.RS_SAMPLER, DataType.valueOf("RS_SAMPLER"));
+        assertEquals(DataType.RS_SCRIPT, DataType.valueOf("RS_SCRIPT"));
+        assertEquals(DataType.RS_MESH, DataType.valueOf("RS_MESH"));
+        assertEquals(DataType.RS_PROGRAM_FRAGMENT, DataType.valueOf("RS_PROGRAM_FRAGMENT"));
+        assertEquals(DataType.RS_PROGRAM_VERTEX, DataType.valueOf("RS_PROGRAM_VERTEX"));
+        assertEquals(DataType.RS_PROGRAM_RASTER, DataType.valueOf("RS_PROGRAM_RASTER"));
+        assertEquals(DataType.RS_PROGRAM_STORE, DataType.valueOf("RS_PROGRAM_STORE"));
+        // Make sure no new enums are added
+        assertEquals(27, DataType.values().length);
+
+        for (DataType dt : DataType.values()) {
+            Element.createVector(mRS, dt, 2);
+        }
+    }
+
+    public void testDataKind() {
+        assertEquals(DataKind.USER, DataKind.valueOf("USER"));
+
+        assertEquals(DataKind.PIXEL_L, DataKind.valueOf("PIXEL_L"));
+        assertEquals(DataKind.PIXEL_A, DataKind.valueOf("PIXEL_A"));
+        assertEquals(DataKind.PIXEL_LA, DataKind.valueOf("PIXEL_LA"));
+        assertEquals(DataKind.PIXEL_RGB, DataKind.valueOf("PIXEL_RGB"));
+        assertEquals(DataKind.PIXEL_RGBA, DataKind.valueOf("PIXEL_RGBA"));
+        // Make sure no new enums are added
+        assertEquals(6, DataKind.values().length);
+
+        for (DataKind dk : DataKind.values()) {
+            if (dk != DataKind.USER) {
+                Element.createPixel(mRS, DataType.UNSIGNED_8, dk);
+            }
+        }
+    }
+}
+
+
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ExceptionTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ExceptionTest.java
new file mode 100644
index 0000000..3a9df46
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ExceptionTest.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2011 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.renderscript.cts;
+
+import android.renderscript.RSIllegalArgumentException;
+import android.renderscript.RSInvalidStateException;
+import android.renderscript.RSRuntimeException;
+import android.renderscript.RSDriverException;
+
+import android.test.AndroidTestCase;
+
+public class ExceptionTest extends AndroidTestCase {
+    public void testExceptions() {
+        try {
+            throw new RSIllegalArgumentException("IAE");
+        } catch (RSIllegalArgumentException e) {
+            assertEquals(e.getMessage(), "IAE");
+        }
+
+        try {
+            throw new RSInvalidStateException("ISE");
+        } catch (RSInvalidStateException e) {
+            assertEquals(e.getMessage(), "ISE");
+        }
+
+        try {
+            throw new RSRuntimeException("RE");
+        } catch (RSRuntimeException e) {
+            assertEquals(e.getMessage(), "RE");
+        }
+
+        try {
+            throw new RSDriverException("DE");
+        } catch (RSDriverException e) {
+            assertEquals(e.getMessage(), "DE");
+        }
+    }
+}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/FieldPackerTest.java b/tests/tests/renderscript/src/android/renderscript/cts/FieldPackerTest.java
new file mode 100644
index 0000000..f986d4b
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/FieldPackerTest.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2011 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.renderscript.cts;
+
+import android.renderscript.Byte2;
+import android.renderscript.Byte3;
+import android.renderscript.Byte4;
+import android.renderscript.FieldPacker;
+import android.renderscript.Float2;
+import android.renderscript.Float3;
+import android.renderscript.Float4;
+import android.renderscript.Int2;
+import android.renderscript.Int3;
+import android.renderscript.Int4;
+import android.renderscript.Long2;
+import android.renderscript.Long3;
+import android.renderscript.Long4;
+import android.renderscript.Matrix2f;
+import android.renderscript.Matrix3f;
+import android.renderscript.Matrix4f;
+import android.renderscript.Short2;
+import android.renderscript.Short3;
+import android.renderscript.Short4;
+
+public class FieldPackerTest extends RSBaseCompute {
+
+    public void testAddAllTypes() {
+        FieldPacker fp = new FieldPacker(1024);
+        fp.addBoolean(true);
+        fp.addF32(0.1f);
+        fp.addF32(new Float3());
+        fp.addF32(new Float4());
+        fp.addF32(new Float2());
+        fp.addF64(0.2);
+        fp.addI16(new Short3());
+        fp.addI16(new Short2());
+        fp.addI16((short)-2);
+        fp.addI16(new Short4());
+        fp.addI32(new Int3());
+        fp.addI32(-4);
+        fp.addI32(new Int4());
+        fp.addI32(new Int2());
+        fp.addI64(-8);
+        fp.addI8((byte)-1);
+        fp.addI8(new Byte4());
+        fp.addI8(new Byte2());
+        fp.addI8(new Byte3());
+        fp.addMatrix(new Matrix4f());
+        fp.addMatrix(new Matrix3f());
+        fp.addMatrix(new Matrix2f());
+        fp.addObj(null);
+        fp.addU16(new Int2());
+        fp.addU16(new Int4());
+        fp.addU16((short)2);
+        fp.addU16(new Int3());
+        fp.addU32(new Long4());
+        fp.addU32(new Long2());
+        fp.addU32(new Long3());
+        fp.addU32(4);
+        fp.addU64(8);
+        fp.addU8(new Short2());
+        fp.addU8(new Short4());
+        fp.addU8((byte)1);
+        fp.addU8(new Short3());
+    }
+
+    public void testAlign() {
+        /*
+        fp.align(int v);
+        final byte[]     getData();
+        fp.reset(int i);
+        fp.reset();
+        fp.skip(int i);
+        */
+    }
+}
+
+
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/FileA3DTest.java b/tests/tests/renderscript/src/android/renderscript/cts/FileA3DTest.java
new file mode 100644
index 0000000..ca2bb38
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/FileA3DTest.java
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 2011 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.renderscript.cts;
+
+import java.io.File;
+
+import com.android.cts.stub.R;
+
+import android.renderscript.RSRuntimeException;
+import android.renderscript.FileA3D;
+import android.renderscript.FileA3D.EntryType;
+import android.renderscript.FileA3D.IndexEntry;
+
+public class FileA3DTest extends RSBaseGraphics {
+
+    public void testCreateFromResource() {
+        FileA3D model = FileA3D.createFromResource(mRS, mRes, R.raw.sphere);
+        assertTrue(model != null);
+    }
+
+    public void testCreateFromAsset() {
+        FileA3D model = FileA3D.createFromAsset(mRS, mRes.getAssets(), "sphere.a3d");
+        assertTrue(model != null);
+    }
+
+    public void testGetIndexEntryCount() {
+        FileA3D model = FileA3D.createFromResource(mRS, mRes, R.raw.sphere);
+        assertTrue(model != null);
+        assertTrue(model.getIndexEntryCount() == 1);
+    }
+
+    public void testGetIndexEntry() {
+        FileA3D model = FileA3D.createFromResource(mRS, mRes, R.raw.sphere);
+        assertTrue(model != null);
+        assertTrue(model.getIndexEntryCount() == 1);
+        assertTrue(model.getIndexEntry(0) != null);
+    }
+
+    public void testIndexEntryGetEntryType() {
+        FileA3D model = FileA3D.createFromResource(mRS, mRes, R.raw.sphere);
+        assertTrue(model != null);
+        assertTrue(model.getIndexEntryCount() == 1);
+        FileA3D.IndexEntry entry = model.getIndexEntry(0);
+        assertTrue(entry != null);
+        assertTrue(entry.getEntryType() == FileA3D.EntryType.MESH);
+        boolean isOneOfEntries = false;
+        for(FileA3D.EntryType et : FileA3D.EntryType.values()) {
+            if (et == entry.getEntryType()) {
+                isOneOfEntries = true;
+                break;
+            }
+        }
+        assertTrue(isOneOfEntries);
+    }
+
+    public void testIndexEntryGetMesh() {
+        FileA3D model = FileA3D.createFromResource(mRS, mRes, R.raw.sphere);
+        assertTrue(model != null);
+        assertTrue(model.getIndexEntryCount() == 1);
+        FileA3D.IndexEntry entry = model.getIndexEntry(0);
+        assertTrue(entry != null);
+        assertTrue(entry.getEntryType() == FileA3D.EntryType.MESH);
+        assertTrue(entry.getMesh() != null);
+    }
+
+    public void testIndexEntryGetName() {
+        FileA3D model = FileA3D.createFromResource(mRS, mRes, R.raw.sphere);
+        assertTrue(model != null);
+        assertTrue(model.getIndexEntryCount() == 1);
+        FileA3D.IndexEntry entry = model.getIndexEntry(0);
+        assertTrue(entry != null);
+        assertTrue(entry.getName() != null);
+    }
+
+    public void testIndexEntryGetObject() {
+        FileA3D model = FileA3D.createFromResource(mRS, mRes, R.raw.sphere);
+        assertTrue(model != null);
+        assertTrue(model.getIndexEntryCount() == 1);
+        FileA3D.IndexEntry entry = model.getIndexEntry(0);
+        assertTrue(entry != null);
+        assertTrue(entry.getObject() != null);
+    }
+
+    public void testFileA3DEntryType() {
+        assertEquals(FileA3D.EntryType.UNKNOWN, FileA3D.EntryType.valueOf("UNKNOWN"));
+        assertEquals(FileA3D.EntryType.MESH, FileA3D.EntryType.valueOf("MESH"));
+        // Make sure no new enums are added
+        assertEquals(2, FileA3D.EntryType.values().length);
+    }
+
+    public void testCreateFromFile() {
+        File fileDesc = new File("bogusFile");
+        try {
+            FileA3D model = FileA3D.createFromFile(mRS, fileDesc);
+            fail("should throw RSRuntimeException.");
+        } catch (RSRuntimeException e) {
+        }
+        try {
+            FileA3D model = FileA3D.createFromFile(mRS, "bogus");
+            fail("should throw RSRuntimeException.");
+        } catch (RSRuntimeException e) {
+        }
+    }
+}
+
+
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/FontTest.java b/tests/tests/renderscript/src/android/renderscript/cts/FontTest.java
new file mode 100644
index 0000000..e2405e8
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/FontTest.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2011 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.renderscript.cts;
+
+import java.io.File;
+import com.android.cts.stub.R;
+
+import android.os.Environment;
+import android.renderscript.Font;
+import android.renderscript.Font.Style;
+import android.renderscript.RSIllegalArgumentException;
+
+public class FontTest extends RSBaseGraphics {
+
+    public void testCreate() {
+        for (int fontSize = 8; fontSize <= 12; fontSize += 2) {
+            for (Font.Style style : Font.Style.values()) {
+                Font F = null;
+                F = Font.create(mRS, mRes, "sans-serif", style, fontSize);
+                assertTrue(F != null);
+                F.setName("sans-serif");
+                try {
+                    F.setName("sans-serif");
+                    fail("set name twice for a font");
+                } catch (RSIllegalArgumentException e) {
+                }
+                F.destroy();
+
+                F = Font.create(mRS, mRes, "serif", style, fontSize);
+                assertTrue(F != null);
+                try {
+                    F.setName("");
+                    fail("set empty name for a font");
+                } catch (RSIllegalArgumentException e) {
+                }
+                F.setName("serif");
+                F.destroy();
+
+                F = Font.create(mRS, mRes, "mono", style, fontSize);
+                assertTrue(F != null);
+                try {
+                    F.setName(null);
+                    fail("set name as null string reference for a font");
+                } catch (RSIllegalArgumentException e) {
+                }
+                F.setName("mono");
+                F.destroy();
+            }
+        }
+    }
+
+    public void testCreateFromFile() {
+        String fontFile = "DroidSans.ttf";
+        String fontPath = Environment.getRootDirectory().getAbsolutePath();
+        fontPath += "/fonts/" + fontFile;
+        File fileDesc = new File(fontPath);
+        assertTrue(Font.createFromFile(mRS, mRes, fontPath, 8) != null);
+        assertTrue(Font.createFromFile(mRS, mRes, fileDesc, 8) != null);
+    }
+
+    public void testCreateFromAsset() {
+        assertTrue(Font.createFromAsset(mRS, mRes, "samplefont.ttf", 8) != null);
+    }
+
+    public void testFontStyle() {
+        assertEquals(Font.Style.NORMAL, Font.Style.valueOf("NORMAL"));
+        assertEquals(Font.Style.BOLD, Font.Style.valueOf("BOLD"));
+        assertEquals(Font.Style.ITALIC, Font.Style.valueOf("ITALIC"));
+        assertEquals(Font.Style.BOLD_ITALIC, Font.Style.valueOf("BOLD_ITALIC"));
+        // Make sure no new enums are added
+        assertEquals(4, Font.Style.values().length);
+    }
+
+    public void testCreateFromResource() {
+        assertTrue(Font.createFromResource(mRS, mRes, R.raw.samplefont, 8) != null);
+    }
+}
+
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/Matrix2fTest.java b/tests/tests/renderscript/src/android/renderscript/cts/Matrix2fTest.java
new file mode 100755
index 0000000..fa7c5d5
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/Matrix2fTest.java
@@ -0,0 +1,214 @@
+/*
+ * Copyright (C) 2011 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.renderscript.cts;
+import android.renderscript.Matrix2f;
+
+public class Matrix2fTest extends RSBaseCompute {
+
+    final float delta = 0.00001f;
+    final float[] setData = {
+            1.0f, 2.0f,
+            3.0f, 4.0f
+        };
+
+    void checkIdentity(Matrix2f m, float delta) {
+        for (int i = 0; i < 2; i ++) {
+            for (int j = 0; j < 2; j ++) {
+                if (i == j) {
+                    assertEquals(1.0f, m.getArray()[i*2 + j], delta);
+                } else {
+                    assertEquals(0.0f, m.getArray()[i*2 + j], delta);
+                }
+            }
+        }
+    }
+
+    String getString(float[] array) {
+        StringBuilder builder = new StringBuilder();
+        for (int i = 0; i < 2; i ++) {
+            builder.append("[");
+            for (int j = 0; j < 2; j ++) {
+                builder.append(array[i*2 + j]);
+                builder.append(" ");
+            }
+            builder.append("]");
+        }
+        return builder.toString();
+    }
+
+    void checkData(Matrix2f m, float[] data, float delta) {
+        for (int i = 0; i < data.length; i ++) {
+            assertEquals(data[i], m.getArray()[i], delta);
+        }
+    }
+
+    void checkData(Matrix2f m, float[] data) {
+        String s1 = getString(m.getArray());
+        String s2 = getString(data);
+        assertEquals(s2, s1);
+    }
+
+    public void testCreation() {
+        Matrix2f m = new Matrix2f();
+        assertTrue(m.getArray() != null);
+        checkIdentity(m, 0.0f);
+
+        m = new Matrix2f(setData);
+        checkData(m, setData);
+    }
+
+    public void testGet() {
+
+        Matrix2f m = new Matrix2f(setData);
+
+        for (int i = 0; i < 2; i ++) {
+            for (int j = 0; j < 2; j ++) {
+                assertEquals(setData[i*2 + j], m.get(i, j), 0.0f);
+            }
+        }
+    }
+
+    public void testSet() {
+        Matrix2f m = new Matrix2f();
+        for (int i = 0; i < 2; i ++) {
+            for (int j = 0; j < 2; j ++) {
+                float valToSet = setData[i*2 + j];
+                m.set(i, j, valToSet);
+                assertEquals(valToSet, m.get(i, j), 0.0f);
+            }
+        }
+    }
+
+    public void testLoadIdentity() {
+        Matrix2f m = new Matrix2f(setData);
+        m.loadIdentity();
+        checkIdentity(m, 0.0f);
+    }
+
+    public void testLoad() {
+        Matrix2f m1 = new Matrix2f();
+        Matrix2f m2 = new Matrix2f(setData);
+
+        m1.load(m2);
+        checkData(m1, setData);
+    }
+
+    public void testLoadScale() {
+        float[] expectedData = {
+            2.0f, 0.0f,
+            0.0f, 3.0f
+        };
+
+        Matrix2f m = new Matrix2f(setData);
+        m.loadScale(2.0f, 3.0f);
+        checkData(m, expectedData);
+    }
+
+    public void testMultiply() {
+        float[] lhsData = {
+            1.0f, 1.0f,
+            1.0f, 1.0f
+        };
+
+        float[] rhsData = {
+            2.0f, 2.0f,
+            3.0f, 3.0f
+        };
+
+        float[] expected = {
+            2.0f*2.0f, 2.0f*2.0f,
+            2.0f*3.0f, 2.0f*3.0f
+        };
+
+        // Due to column major nature of OpenGL,
+        // left hand side and right hand side
+        // are reversed. Premultiplying by row major
+        // and post multiplying by column major
+        // are the same. So lhs and rhs get reversed here.
+        Matrix2f lhs = new Matrix2f(lhsData);
+        Matrix2f rhs = new Matrix2f(rhsData);
+        Matrix2f loadMul = new Matrix2f();
+
+        loadMul.loadMultiply(lhs, rhs);
+        checkData(loadMul, expected);
+
+        lhs.multiply(rhs);
+        checkData(lhs, expected);
+    }
+
+    public void testScale() {
+        float[] expectedData = new float[setData.length];
+        System.arraycopy(setData, 0, expectedData, 0, setData.length);
+        float scaleX = 2.0f;
+        float scaleY = 3.0f;
+        expectedData[0] *= scaleX;
+        expectedData[1] *= scaleX;
+        expectedData[2] *= scaleY;
+        expectedData[3] *= scaleY;
+
+        Matrix2f m = new Matrix2f(setData);
+        m.scale(scaleX, scaleY);
+        checkData(m, expectedData);
+    }
+
+    public void testTranspose() {
+        float[] expectedData = new float[setData.length];
+        System.arraycopy(setData, 0, expectedData, 0, setData.length);
+        float temp = expectedData[1];
+        expectedData[1] = expectedData[2];
+        expectedData[2] = temp;
+
+        Matrix2f m = new Matrix2f(setData);
+        m.transpose();
+
+        checkData(m, expectedData);
+    }
+
+    public void testRotateLoadRotate() {
+
+        float theta = 30.0f * (float)(java.lang.Math.PI / 180.0f);
+        float cosTheta = (float)Math.cos((float)theta);
+        float sinTheta = (float)Math.sin((float)theta);
+        float[] rotate = new float[4];
+        rotate[0] = cosTheta;
+        rotate[1] = -sinTheta;
+        rotate[2] = sinTheta;
+        rotate[3] = cosTheta;
+
+        Matrix2f m = new Matrix2f();
+        m.loadRotate(30.0f);
+        checkData(m, rotate);
+
+        m = new Matrix2f();
+        m.rotate(30.0f);
+        checkData(m, rotate);
+
+        float[] sourceData = {
+            2.0f, 3.0f,
+            4.0f, 5.0f
+        };
+        float[] rotated = new float[4];
+        rotated[0] = rotate[0] * sourceData[0] + rotate[1] * sourceData[2];
+        rotated[1] = rotate[0] * sourceData[1] + rotate[1] * sourceData[3];
+        rotated[2] = rotate[2] * sourceData[0] + rotate[3] * sourceData[2];
+        rotated[3] = rotate[2] * sourceData[1] + rotate[3] * sourceData[3];
+        m = new Matrix2f(sourceData);
+        m.rotate(30.0f);
+
+        checkData(m, rotated);
+    }
+}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/Matrix3fTest.java b/tests/tests/renderscript/src/android/renderscript/cts/Matrix3fTest.java
new file mode 100755
index 0000000..f817cab
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/Matrix3fTest.java
@@ -0,0 +1,229 @@
+/*
+ * Copyright (C) 2011 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.renderscript.cts;
+import android.renderscript.Matrix3f;
+
+public class Matrix3fTest extends RSBaseCompute {
+
+    final float delta = 0.00001f;
+    final float[] setData = {
+            1.0f, 2.0f, 3.0f,
+            4.0f, 5.0f, 6.0f,
+            7.0f, 8.0f, 9.0f
+        };
+
+    void checkIdentity(Matrix3f m, float delta) {
+        for (int i = 0; i < 3; i ++) {
+            for (int j = 0; j < 3; j ++) {
+                if (i == j) {
+                    assertEquals(1.0f, m.getArray()[i*3 + j], delta);
+                } else {
+                    assertEquals(0.0f, m.getArray()[i*3 + j], delta);
+                }
+            }
+        }
+    }
+
+    String getString(float[] array) {
+        StringBuilder builder = new StringBuilder();
+        for (int i = 0; i < 3; i ++) {
+            builder.append("[");
+            for (int j = 0; j < 3; j ++) {
+                builder.append(array[i*3 + j]);
+                builder.append(" ");
+            }
+            builder.append("]");
+        }
+        return builder.toString();
+    }
+
+    void checkData(Matrix3f m, float[] data, float delta) {
+        for (int i = 0; i < data.length; i ++) {
+            assertEquals(data[i], m.getArray()[i], delta);
+        }
+    }
+
+    void checkData(Matrix3f m, float[] data) {
+        String s1 = getString(m.getArray());
+        String s2 = getString(data);
+        assertEquals(s2, s1);
+    }
+
+    public void testCreation() {
+        Matrix3f m = new Matrix3f();
+        assertTrue(m.getArray() != null);
+        checkIdentity(m, 0.0f);
+
+        m = new Matrix3f(setData);
+        checkData(m, setData);
+    }
+
+    public void testGet() {
+
+        Matrix3f m = new Matrix3f(setData);
+
+        for (int i = 0; i < 3; i ++) {
+            for (int j = 0; j < 3; j ++) {
+                assertEquals(setData[i*3 + j], m.get(i, j), 0.0f);
+            }
+        }
+    }
+
+    public void testSet() {
+        Matrix3f m = new Matrix3f();
+        for (int i = 0; i < 3; i ++) {
+            for (int j = 0; j < 3; j ++) {
+                float valToSet = setData[i*3 + j];
+                m.set(i, j, valToSet);
+                assertEquals(valToSet, m.get(i, j), 0.0f);
+            }
+        }
+    }
+
+    public void testLoadIdentity() {
+        Matrix3f m = new Matrix3f(setData);
+        m.loadIdentity();
+        checkIdentity(m, 0.0f);
+    }
+
+    public void testLoad() {
+        Matrix3f m1 = new Matrix3f();
+        Matrix3f m2 = new Matrix3f(setData);
+
+        m1.load(m2);
+        checkData(m1, setData);
+    }
+
+    public void testLoadScale() {
+        float[] expectedData = {
+            2.0f, 0.0f, 0.0f,
+            0.0f, 3.0f, 0.0f,
+            0.0f, 0.0f, 4.0f,
+        };
+        float[] expectedData2 = {
+            2.0f, 0.0f, 0.0f,
+            0.0f, 3.0f, 0.0f,
+            0.0f, 0.0f, 1.0f,
+        };
+
+        Matrix3f m = new Matrix3f(setData);
+        m.loadScale(2.0f, 3.0f, 4.0f);
+        checkData(m, expectedData);
+
+        m = new Matrix3f(setData);
+        m.loadScale(2.0f, 3.0f);
+        checkData(m, expectedData2);
+    }
+
+    public void testLoadTranslate() {
+        float[] expectedData = {
+            1.0f, 0.0f, 0.0f,
+            0.0f, 1.0f, 0.0f,
+            2.0f, 3.0f, 1.0f,
+        };
+
+        Matrix3f m = new Matrix3f(setData);
+        m.loadTranslate(2.0f, 3.0f);
+        checkData(m, expectedData);
+    }
+
+    public void testScale() {
+        float[] expectedData = new float[setData.length];
+        System.arraycopy(setData, 0, expectedData, 0, setData.length);
+        float scaleX = 2.0f;
+        float scaleY = 3.0f;
+        float scaleZ = 4.0f;
+        expectedData[0] *= scaleX;
+        expectedData[1] *= scaleX;
+        expectedData[2] *= scaleX;
+        expectedData[3] *= scaleY;
+        expectedData[4] *= scaleY;
+        expectedData[5] *= scaleY;
+        expectedData[6] *= scaleZ;
+        expectedData[7] *= scaleZ;
+        expectedData[8] *= scaleZ;
+
+        Matrix3f m = new Matrix3f(setData);
+        m.scale(scaleX, scaleY, scaleZ);
+        checkData(m, expectedData);
+
+        System.arraycopy(setData, 0, expectedData, 0, setData.length);
+        expectedData[0] *= scaleX;
+        expectedData[1] *= scaleX;
+        expectedData[2] *= scaleX;
+        expectedData[3] *= scaleY;
+        expectedData[4] *= scaleY;
+        expectedData[5] *= scaleY;
+
+        m = new Matrix3f(setData);
+        m.scale(scaleX, scaleY);
+        checkData(m, expectedData);
+    }
+
+    public void testMultiply() {
+        float[] lhsData = {
+            1.0f, 1.0f, 1.0f,
+            1.0f, 1.0f, 1.0f,
+            1.0f, 1.0f, 1.0f
+        };
+
+        float[] rhsData = {
+            2.0f, 2.0f, 2.0f,
+            3.0f, 3.0f, 3.0f,
+            4.0f, 4.0f, 4.0f
+        };
+
+        float[] expected = {
+            3.0f*2.0f, 3.0f*2.0f, 3.0f*2.0f,
+            3.0f*3.0f, 3.0f*3.0f, 3.0f*3.0f,
+            3.0f*4.0f, 3.0f*4.0f, 3.0f*4.0f
+        };
+
+        // Due to column major nature of OpenGL,
+        // left hand side and right hand side
+        // are reversed. Premultiplying by row major
+        // and post multiplying by column major
+        // are the same. So lhs and rhs get reversed here.
+        Matrix3f lhs = new Matrix3f(lhsData);
+        Matrix3f rhs = new Matrix3f(rhsData);
+        Matrix3f loadMul = new Matrix3f();
+
+        loadMul.loadMultiply(lhs, rhs);
+        checkData(loadMul, expected);
+
+        lhs.multiply(rhs);
+        checkData(lhs, expected);
+    }
+
+    public void testTranspose() {
+        float[] expectedData = new float[setData.length];
+        System.arraycopy(setData, 0, expectedData, 0, setData.length);
+
+        for(int i = 0; i < 2; i++) {
+            for(int j = i + 1; j < 3; j++) {
+                float temp = expectedData[i*3 + j];
+                expectedData[i*3 + j] = expectedData[j*3 + i];
+                expectedData[j*3 + i] = temp;
+            }
+        }
+
+        Matrix3f m = new Matrix3f(setData);
+        m.transpose();
+
+        checkData(m, expectedData);
+    }
+}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/Matrix4fTest.java b/tests/tests/renderscript/src/android/renderscript/cts/Matrix4fTest.java
new file mode 100755
index 0000000..8678578
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/Matrix4fTest.java
@@ -0,0 +1,233 @@
+/*
+ * Copyright (C) 2011 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.renderscript.cts;
+import android.renderscript.Matrix4f;
+
+public class Matrix4fTest extends RSBaseCompute {
+
+    final float delta = 0.00001f;
+    final float[] setData = {
+            1.0f, 2.0f, 3.0f, 4.0f,
+            5.0f, 6.0f, 7.0f, 8.0f,
+            9.0f, 10.0f, 11.0f, 12.0f,
+            13.0f, 14.0f, 15.0f, 16.0f
+        };
+
+    void checkIdentity(Matrix4f m, float delta) {
+        for (int i = 0; i < 4; i ++) {
+            for (int j = 0; j < 4; j ++) {
+                if (i == j) {
+                    assertEquals(1.0f, m.getArray()[i*4 + j], delta);
+                } else {
+                    assertEquals(0.0f, m.getArray()[i*4 + j], delta);
+                }
+            }
+        }
+    }
+
+    String getString(float[] array) {
+        StringBuilder builder = new StringBuilder();
+        for (int i = 0; i < 4; i ++) {
+            builder.append("[");
+            for (int j = 0; j < 4; j ++) {
+                builder.append(array[i*4 + j]);
+                builder.append(" ");
+            }
+            builder.append("]");
+        }
+        return builder.toString();
+    }
+
+    void checkData(Matrix4f m, float[] data, float delta) {
+        for (int i = 0; i < data.length; i ++) {
+            assertEquals(data[i], m.getArray()[i], delta);
+        }
+    }
+
+    void checkData(Matrix4f m, float[] data) {
+        String s1 = getString(m.getArray());
+        String s2 = getString(data);
+        assertEquals(s2, s1);
+    }
+
+    public void testCreation() {
+        Matrix4f m = new Matrix4f();
+        assertTrue(m.getArray() != null);
+        checkIdentity(m, 0.0f);
+
+
+        m = new Matrix4f(setData);
+        checkData(m, setData);
+    }
+
+    public void testGet() {
+
+        Matrix4f m = new Matrix4f(setData);
+
+        for (int i = 0; i < 4; i ++) {
+            for (int j = 0; j < 4; j ++) {
+                assertEquals(setData[i*4 + j], m.get(i, j), 0.0f);
+            }
+        }
+    }
+
+    public void testSet() {
+        Matrix4f m = new Matrix4f();
+        for (int i = 0; i < 4; i ++) {
+            for (int j = 0; j < 4; j ++) {
+                float valToSet = setData[i*4 + j];
+                m.set(i, j, valToSet);
+                assertEquals(valToSet, m.get(i, j), 0.0f);
+            }
+        }
+    }
+
+    public void testLoadIdentity() {
+        Matrix4f m = new Matrix4f(setData);
+        m.loadIdentity();
+        checkIdentity(m, 0.0f);
+    }
+
+    public void testLoad() {
+        Matrix4f m1 = new Matrix4f();
+        Matrix4f m2 = new Matrix4f(setData);
+
+        m1.load(m2);
+        checkData(m1, setData);
+    }
+
+    public void testLoadScale() {
+        float[] expectedData = {
+            2.0f, 0.0f, 0.0f, 0.0f,
+            0.0f, 3.0f, 0.0f, 0.0f,
+            0.0f, 0.0f, 4.0f, 0.0f,
+            0.0f, 0.0f, 0.0f, 1.0f
+        };
+
+        Matrix4f m = new Matrix4f(setData);
+        m.loadScale(2.0f, 3.0f, 4.0f);
+        checkData(m, expectedData);
+    }
+
+    public void testLoadTranslate() {
+        float[] expectedData = {
+            1.0f, 0.0f, 0.0f, 0.0f,
+            0.0f, 1.0f, 0.0f, 0.0f,
+            0.0f, 0.0f, 1.0f, 0.0f,
+            2.0f, 3.0f, 4.0f, 1.0f
+        };
+
+        Matrix4f m = new Matrix4f(setData);
+        m.loadTranslate(2.0f, 3.0f, 4.0f);
+        checkData(m, expectedData);
+    }
+
+    public void testScale() {
+        float[] expectedData = new float[setData.length];
+        System.arraycopy(setData, 0, expectedData, 0, setData.length);
+        float scaleX = 2.0f;
+        float scaleY = 3.0f;
+        float scaleZ = 4.0f;
+        expectedData[0] *= scaleX;
+        expectedData[1] *= scaleX;
+        expectedData[2] *= scaleX;
+        expectedData[3] *= scaleX;
+        expectedData[4] *= scaleY;
+        expectedData[5] *= scaleY;
+        expectedData[6] *= scaleY;
+        expectedData[7] *= scaleY;
+        expectedData[8] *= scaleZ;
+        expectedData[9] *= scaleZ;
+        expectedData[10] *= scaleZ;
+        expectedData[11] *= scaleZ;
+
+        Matrix4f m = new Matrix4f(setData);
+        m.scale(scaleX, scaleY, scaleZ);
+        checkData(m, expectedData);
+    }
+
+    public void testTranspose() {
+        float[] expectedData = new float[setData.length];
+        System.arraycopy(setData, 0, expectedData, 0, setData.length);
+
+        for(int i = 0; i < 3; i++) {
+            for(int j = i + 1; j < 4; j++) {
+                float temp = expectedData[i*4 + j];
+                expectedData[i*4 + j] = expectedData[j*4 + i];
+                expectedData[j*4 + i] = temp;
+            }
+        }
+
+        Matrix4f m = new Matrix4f(setData);
+        m.transpose();
+
+        checkData(m, expectedData);
+    }
+
+    public void testMultiply() {
+        float[] lhsData = {
+            1.0f, 1.0f, 1.0f, 1.0f,
+            1.0f, 1.0f, 1.0f, 1.0f,
+            1.0f, 1.0f, 1.0f, 1.0f,
+            1.0f, 1.0f, 1.0f, 1.0f
+        };
+
+        float[] rhsData = {
+            2.0f, 2.0f, 2.0f, 2.0f,
+            3.0f, 3.0f, 3.0f, 3.0f,
+            4.0f, 4.0f, 4.0f, 4.0f,
+            5.0f, 5.0f, 5.0f, 5.0f
+        };
+
+        float[] expected = {
+            4.0f*2.0f, 4.0f*2.0f, 4.0f*2.0f, 4.0f*2.0f,
+            4.0f*3.0f, 4.0f*3.0f, 4.0f*3.0f, 4.0f*3.0f,
+            4.0f*4.0f, 4.0f*4.0f, 4.0f*4.0f, 4.0f*4.0f,
+            4.0f*5.0f, 4.0f*5.0f, 4.0f*5.0f, 4.0f*5.0f
+        };
+
+        // Due to column major nature of OpenGL,
+        // left hand side and right hand side
+        // are reversed. Premultiplying by row major
+        // and post multiplying by column major
+        // are the same. So lhs and rhs get reversed here.
+        Matrix4f lhs = new Matrix4f(lhsData);
+        Matrix4f rhs = new Matrix4f(rhsData);
+        Matrix4f loadMul = new Matrix4f();
+
+        loadMul.loadMultiply(lhs, rhs);
+        checkData(loadMul, expected);
+
+        lhs.multiply(rhs);
+        checkData(lhs, expected);
+    }
+
+    public void testInverse() {
+        Matrix4f m = new Matrix4f();
+        assertTrue(m.inverse());
+        checkIdentity(m, delta);
+
+        m = new Matrix4f();
+        m.scale(2.0f, 2.0f, 2.0f);
+        m.translate(5.0f, 6.0f, 7.0f);
+
+        Matrix4f m2 = new Matrix4f(m.getArray());
+        assertTrue(m2.inverse());
+        m.multiply(m2);
+        checkIdentity(m, delta);
+    }
+}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/MeshTest.java b/tests/tests/renderscript/src/android/renderscript/cts/MeshTest.java
new file mode 100644
index 0000000..ffa733a
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/MeshTest.java
@@ -0,0 +1,202 @@
+/*
+ * Copyright (C) 2011 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.renderscript.cts;
+
+import android.renderscript.Allocation;
+import android.renderscript.Element;
+import android.renderscript.Type;
+import android.renderscript.Mesh;
+import android.renderscript.Mesh.Primitive;
+import android.renderscript.Mesh.AllocationBuilder;
+import android.renderscript.Mesh.Builder;
+import android.renderscript.Mesh.TriangleMeshBuilder;
+
+public class MeshTest extends RSBaseGraphics {
+
+    Allocation mAttrAlloc;
+    Allocation mIndexAlloc;
+    Element mPosElem;
+    Type mPosType;
+    Type mIndexType;
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        Element.Builder eb = new Element.Builder(mRS);
+        eb.add(Element.F32_4(mRS), "position");
+        mPosElem = eb.create();
+        Type.Builder typeB = new Type.Builder(mRS, mPosElem);
+        mPosType = typeB.setX(3).create();
+        typeB = new Type.Builder(mRS, Element.U16(mRS));
+        mIndexType = typeB.setX(3).create();
+
+        mAttrAlloc = Allocation.createSized(mRS, mPosElem, 3);
+        mIndexAlloc = Allocation.createSized(mRS, Element.U16(mRS), 3);
+    }
+
+    public void testMeshAllocationBuilder() {
+        Mesh.AllocationBuilder mab;
+        for(Primitive prim : Primitive.values()) {
+            mab = new Mesh.AllocationBuilder(mRS);
+            mab.addVertexAllocation(mAttrAlloc);
+            mab.getCurrentVertexTypeIndex();
+            mab.addIndexSetType(prim);
+            assertTrue(mab.create() != null);
+
+            mab = new Mesh.AllocationBuilder(mRS);
+            mab.addVertexAllocation(mAttrAlloc);
+            mab.getCurrentVertexTypeIndex();
+            mab.addIndexSetAllocation(mIndexAlloc, prim);
+            mab.getCurrentIndexSetIndex();
+            mab.addIndexSetType(prim);
+
+            Mesh mesh = mab.create();
+            assertTrue(mesh != null);
+            assertTrue(mesh.getVertexAllocationCount() == 1);
+            assertTrue(mesh.getVertexAllocation(0) == mAttrAlloc);
+            assertTrue(mesh.getPrimitiveCount() == 2);
+            assertTrue(mesh.getPrimitive(0) == prim);
+            assertTrue(mesh.getPrimitive(1) == prim);
+            assertTrue(mesh.getIndexSetAllocation(0) == mIndexAlloc);
+        }
+    }
+
+    public void testMeshBuilder() {
+        Mesh.Builder mb;
+        for(Primitive prim : Primitive.values()) {
+            mb = new Mesh.Builder(mRS,
+                                  Allocation.USAGE_SCRIPT |
+                                  Allocation.USAGE_GRAPHICS_VERTEX);
+            mb.addVertexType(mPosElem, 3);
+            mb.getCurrentVertexTypeIndex();
+            mb.addIndexSetType(prim);
+            Mesh mesh = mb.create();
+            assertTrue(mesh != null);
+            assertTrue(mesh.getVertexAllocationCount() != 0);
+
+            mb = new Mesh.Builder(mRS,
+                                  Allocation.USAGE_SCRIPT |
+                                  Allocation.USAGE_GRAPHICS_VERTEX);
+            mb.addVertexType(mPosElem, 3);
+            mb.getCurrentVertexTypeIndex();
+            mb.addIndexSetType(Element.U16(mRS), 3, prim);
+            mb.getCurrentIndexSetIndex();
+            mesh = mb.create();
+            assertTrue(mesh != null);
+            assertTrue(mesh.getVertexAllocationCount() != 0);
+            assertTrue(mesh.getPrimitiveCount() != 0);
+
+            mb = new Mesh.Builder(mRS,
+                                  Allocation.USAGE_SCRIPT |
+                                  Allocation.USAGE_GRAPHICS_VERTEX);
+            mb.addVertexType(mPosElem, 3);
+            mb.getCurrentVertexTypeIndex();
+            mb.addIndexSetType(mIndexType, prim);
+            mb.getCurrentIndexSetIndex();
+            assertTrue(mb.create() != null);
+
+            mb = new Mesh.Builder(mRS,
+                                  Allocation.USAGE_SCRIPT |
+                                  Allocation.USAGE_GRAPHICS_VERTEX);
+            mb.addVertexType(mPosType);
+            mb.getCurrentVertexTypeIndex();
+            mb.addIndexSetType(prim);
+            assertTrue(mb.create() != null);
+
+            mb = new Mesh.Builder(mRS,
+                                  Allocation.USAGE_SCRIPT |
+                                  Allocation.USAGE_GRAPHICS_VERTEX);
+            mb.addVertexType(mPosType);
+            mb.getCurrentVertexTypeIndex();
+            mb.addIndexSetType(Element.U16(mRS), 3, prim);
+            mb.getCurrentIndexSetIndex();
+            assertTrue(mb.create() != null);
+
+            mb = new Mesh.Builder(mRS,
+                                  Allocation.USAGE_SCRIPT |
+                                  Allocation.USAGE_GRAPHICS_VERTEX);
+            mb.addVertexType(mPosType);
+            mb.getCurrentVertexTypeIndex();
+            mb.addIndexSetType(mIndexType, prim);
+            mb.getCurrentIndexSetIndex();
+            assertTrue(mb.create() != null);
+        }
+    }
+
+    void triangleMeshBuilderHelper(int size, int flags) {
+        // Test various num vertices and triangles
+        for (int numVerts = 3; numVerts < 100; numVerts += 15) {
+            for (int numTries = 1; numTries < 100; numTries += 15) {
+                Mesh.TriangleMeshBuilder tmb = new Mesh.TriangleMeshBuilder(mRS, size, flags);
+                // Append all the vertices
+                for (int numVertsI = 0; numVertsI < numVerts; numVertsI++) {
+                    if (size == 2) {
+                        tmb.addVertex(1.0f, 1.0f);
+                    } else {
+                        tmb.addVertex(1.0f, 1.0f, 1.0f);
+                    }
+                    if ((flags & TriangleMeshBuilder.COLOR) != 0) {
+                        tmb.setColor(1.0f, 1.0f, 1.0f, 1.0f);
+                    }
+                    if ((flags & TriangleMeshBuilder.NORMAL) != 0) {
+                        tmb.setNormal(1.0f, 1.0f, 1.0f);
+                    }
+                    if ((flags & TriangleMeshBuilder.TEXTURE_0) != 0) {
+                        tmb.setTexture(1.0f, 1.0f);
+                    }
+                }
+                // Add triangles to index them
+                for (int numTriesI = 0; numTriesI < numTries; numTriesI ++) {
+                    tmb.addTriangle(0, 1, 2);
+                }
+                assertTrue(tmb.create(false) != null);
+                assertTrue(tmb.create(true) != null);
+            }
+        }
+    }
+
+    public void testMeshTriangleMeshBuilder() {
+        for (int size = 2; size <= 3; size ++) {
+            triangleMeshBuilderHelper(size, 0);
+            triangleMeshBuilderHelper(size, TriangleMeshBuilder.COLOR);
+            triangleMeshBuilderHelper(size, TriangleMeshBuilder.COLOR |
+                                            TriangleMeshBuilder.NORMAL);
+            triangleMeshBuilderHelper(size, TriangleMeshBuilder.COLOR |
+                                            TriangleMeshBuilder.TEXTURE_0);
+            triangleMeshBuilderHelper(size, TriangleMeshBuilder.COLOR |
+                                            TriangleMeshBuilder.NORMAL |
+                                            TriangleMeshBuilder.TEXTURE_0);
+            triangleMeshBuilderHelper(size, TriangleMeshBuilder.NORMAL);
+            triangleMeshBuilderHelper(size, TriangleMeshBuilder.NORMAL|
+                                            TriangleMeshBuilder.TEXTURE_0);
+            triangleMeshBuilderHelper(size, TriangleMeshBuilder.TEXTURE_0);
+        }
+    }
+
+    public void testMeshPrimitive() {
+        assertEquals(Mesh.Primitive.POINT, Mesh.Primitive.valueOf("POINT"));
+        assertEquals(Mesh.Primitive.LINE, Mesh.Primitive.valueOf("LINE"));
+        assertEquals(Mesh.Primitive.LINE_STRIP, Mesh.Primitive.valueOf("LINE_STRIP"));
+        assertEquals(Mesh.Primitive.TRIANGLE, Mesh.Primitive.valueOf("TRIANGLE"));
+        assertEquals(Mesh.Primitive.TRIANGLE_STRIP, Mesh.Primitive.valueOf("TRIANGLE_STRIP"));
+        assertEquals(Mesh.Primitive.TRIANGLE_FAN, Mesh.Primitive.valueOf("TRIANGLE_FAN"));
+        // Make sure no new enums are added
+        assertEquals(6, Mesh.Primitive.values().length);
+    }
+}
+
+
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ProgramFragmentFixedFunctionTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ProgramFragmentFixedFunctionTest.java
new file mode 100644
index 0000000..ac54b74
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ProgramFragmentFixedFunctionTest.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright (C) 2011 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.renderscript.cts;
+
+import com.android.cts.stub.R;
+import android.renderscript.Element;
+import android.renderscript.Type;
+import android.renderscript.Allocation;
+import android.renderscript.Sampler;
+import android.renderscript.ProgramFragment;
+import android.renderscript.ProgramFragmentFixedFunction;
+import android.renderscript.ProgramFragmentFixedFunction.Builder;
+
+public class ProgramFragmentFixedFunctionTest extends RSBaseGraphics {
+
+    ScriptC_graphics_runner mScript;
+
+    Allocation mTex2D;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        Type.Builder typeB = new Type.Builder(mRS, Element.RGB_888(mRS));
+        typeB.setX(8).setY(8);
+        mTex2D = Allocation.createTyped(mRS, typeB.create(),
+                                        Allocation.USAGE_SCRIPT |
+                                        Allocation.USAGE_GRAPHICS_TEXTURE);
+
+        mScript = new ScriptC_graphics_runner(mRS, mRes, R.raw.graphics_runner);
+        mRS.bindRootScript(mScript);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        mRS.bindRootScript(null);
+        super.tearDown();
+    }
+
+    void testProgramFragmentFixedFunctionBuilder(boolean testBind) {
+        ProgramFragmentFixedFunction.Builder b;
+        for (int tCount = 0; tCount <= Builder.MAX_TEXTURE; tCount ++) {
+            for (int varC = 0; varC <= 1; varC++) {
+                for (int pSprite = 0; pSprite <= 1; pSprite++) {
+                    for (Builder.EnvMode env : Builder.EnvMode.values()) {
+                        for (Builder.Format format : Builder.Format.values()) {
+                            b = new ProgramFragmentFixedFunction.Builder(mRS);
+                            b.setVaryingColor(varC == 1);
+                            b.setPointSpriteTexCoordinateReplacement(pSprite == 1);
+                            for (int t = 0; t < tCount; t++) {
+                                b.setTexture(env, format, t);
+                            }
+
+                            ProgramFragment pf = b.create();
+                            assertTrue(pf != null);
+                            for (int t = 0; t < tCount; t++) {
+                                pf.bindTexture(mTex2D, t);
+                                pf.bindSampler(Sampler.CLAMP_NEAREST(mRS), t);
+                            }
+                            if (testBind) {
+                                mScript.invoke_testProgramFragment(pf);
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    public void testProgramFragmentFixedFunctionBuilder() {
+        testProgramFragmentFixedFunctionBuilder(false);
+        testProgramFragmentFixedFunctionBuilder(true);
+    }
+
+    public void testBuilderEnvMode() {
+        assertEquals(Builder.EnvMode.DECAL, Builder.EnvMode.valueOf("DECAL"));
+        assertEquals(Builder.EnvMode.MODULATE, Builder.EnvMode.valueOf("MODULATE"));
+        assertEquals(Builder.EnvMode.REPLACE, Builder.EnvMode.valueOf("REPLACE"));
+
+        // Make sure no new enums are added
+        assertEquals(3, Builder.EnvMode.values().length);
+    }
+
+    public void testBuilderFormat() {
+        assertEquals(Builder.Format.ALPHA, Builder.Format.valueOf("ALPHA"));
+        assertEquals(Builder.Format.LUMINANCE_ALPHA, Builder.Format.valueOf("LUMINANCE_ALPHA"));
+        assertEquals(Builder.Format.RGB, Builder.Format.valueOf("RGB"));
+        assertEquals(Builder.Format.RGBA, Builder.Format.valueOf("RGBA"));
+
+        // Make sure no new enums are added
+        assertEquals(4, Builder.Format.values().length);
+    }
+
+}
+
+
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ProgramFragmentTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ProgramFragmentTest.java
new file mode 100644
index 0000000..9a71386
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ProgramFragmentTest.java
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2011 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.renderscript.cts;
+
+import com.android.cts.stub.R;
+
+import android.renderscript.Allocation;
+import android.renderscript.Element;
+import android.renderscript.Program;
+import android.renderscript.ProgramFragment;
+import android.renderscript.Sampler;
+import android.renderscript.Type;
+
+public class ProgramFragmentTest extends RSBaseGraphics {
+
+    ScriptC_graphics_runner mScript;
+
+    Allocation mConstMatrix;
+    Allocation mConstComplex;
+    Allocation mConstExtra;
+
+    Allocation mTex2D;
+    Allocation mTexCube;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        Type.Builder typeB = new Type.Builder(mRS, Element.RGB_888(mRS));
+        typeB.setX(8).setY(8);
+        mTex2D = Allocation.createTyped(mRS, typeB.create(),
+                                        Allocation.USAGE_SCRIPT |
+                                        Allocation.USAGE_GRAPHICS_TEXTURE);
+        typeB.setFaces(true);
+        mTexCube = Allocation.createTyped(mRS, typeB.create(),
+                                          Allocation.USAGE_SCRIPT |
+                                          Allocation.USAGE_GRAPHICS_TEXTURE);
+
+        ScriptField_ConstMatrix c1 = new ScriptField_ConstMatrix(mRS, 1,
+                                                                 Allocation.USAGE_SCRIPT |
+                                                                 Allocation.USAGE_GRAPHICS_CONSTANTS);
+        c1.set(new ScriptField_ConstMatrix.Item(), 0, true);
+        mConstMatrix = c1.getAllocation();
+
+        ScriptField_ConstComplex c2 = new ScriptField_ConstComplex(mRS, 1,
+                                                                   Allocation.USAGE_SCRIPT |
+                                                                   Allocation.USAGE_GRAPHICS_CONSTANTS);
+        c2.set(new ScriptField_ConstComplex.Item(), 0, true);
+        mConstComplex = c2.getAllocation();
+
+        ScriptField_ConstExtra c3 = new ScriptField_ConstExtra(mRS, 1,
+                                                               Allocation.USAGE_SCRIPT |
+                                                               Allocation.USAGE_GRAPHICS_CONSTANTS);
+        c3.set(new ScriptField_ConstExtra.Item(), 0, true);
+        mConstExtra = c3.getAllocation();
+
+        mScript = new ScriptC_graphics_runner(mRS, mRes, R.raw.graphics_runner);
+        mRS.bindRootScript(mScript);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        mRS.bindRootScript(null);
+        super.tearDown();
+    }
+
+    ProgramFragment buildShader(Allocation[] textures, Allocation[] constInput, String shader) {
+        ProgramFragment.Builder pfb = new ProgramFragment.Builder(mRS);
+        Program.BaseProgramBuilder bpb = pfb;
+        if (textures != null) {
+            for (int i = 0; i < textures.length; i++) {
+                Program.TextureType tType = Program.TextureType.TEXTURE_2D;
+                if (textures[i].getType().hasFaces()) {
+                    tType = Program.TextureType.TEXTURE_CUBE;
+                }
+                // Add textures through the base program builder
+                bpb.addTexture(tType);
+                bpb.getCurrentTextureIndex();
+            }
+        }
+
+        if (constInput != null) {
+            for (int i = 0; i < constInput.length; i++) {
+                bpb.addConstant(constInput[i].getType());
+                bpb.getCurrentConstantIndex();
+            }
+        }
+
+        bpb.setShader(shader);
+        ProgramFragment pf = pfb.create();
+        if (constInput != null) {
+            for (int i = 0; i < constInput.length; i++) {
+                pf.bindConstants(constInput[i], i);
+                // Test the base class path too
+                Program p = pf;
+                p.bindConstants(constInput[i], i);
+            }
+        }
+        if (textures != null) {
+            for (int i = 0; i < textures.length; i++) {
+                pf.bindTexture(textures[i], i);
+                pf.bindSampler(Sampler.CLAMP_NEAREST(mRS), i);
+                // Test the base class path too
+                Program p = pf;
+                p.bindTexture(textures[i], i);
+                p.bindSampler(Sampler.CLAMP_NEAREST(mRS), i);
+            }
+        }
+        return pf;
+    }
+
+    void testProgramFragmentBuilderHelper(boolean testBind) {
+        String simpleFrag = "void main() {\n"+
+                            "  vec4 col = vec4(0.1, 0.2, 0.3, 0.4);"+
+                            "  gl_FragColor = col;\n"+
+                            "}";
+
+        String simpleUni = "void main() {\n"+
+                           "  vec4 col = vec4(0.1, 0.2, 0.3, 0.4);\n"+
+                           "  col = UNI_MATRIX * col;\n"+
+                           "  gl_FragColor = col;\n"+
+                           "}";
+
+        String simpleUniTex = "void main() {\n"+
+                              "  vec4 col = vec4(0.1, 0.2, 0.3, 0.4);"+
+                              "  col += texture2D(UNI_Tex0, vec2(0.1, 0.1));\n"+
+                              "  col += textureCube(UNI_Tex1, vec3(0.1, 0.2, 0.3));\n"+
+                              "  col = UNI_MATRIX * col;\n"+
+                              "  gl_FragColor = col;\n"+
+                              "}";
+
+        String multiUni = "void main() {\n"+
+                          "  vec4 col = vec4(0.1, 0.2, 0.3, 0.4);"+
+                          "  col = UNI_MATRIX * col;\n"+
+                          "  col = UNI_EXTRA * col;\n"+
+                          "  col += UNI_extra4;\n"+
+                          "  col.xyz += UNI_extra3;\n "+
+                          "  col.xy += UNI_extra2;\n"+
+                          "  col.x += UNI_extra1;\n"+
+                          "  gl_FragColor = col;\n"+
+                          "}";
+
+        // Create a series of shaders that do nothing useful
+        // but exercise creation pipeline
+        ProgramFragment pf = buildShader(null, null, simpleFrag);
+        if (testBind) {
+            mScript.invoke_testProgramFragment(pf);
+        }
+
+        Allocation[] constInput = new Allocation[1];
+        constInput[0] = mConstMatrix;
+        pf = buildShader(null, constInput, simpleUni);
+        if (testBind) {
+            mScript.invoke_testProgramFragment(pf);
+            mRS.bindProgramFragment(pf);
+        }
+
+        constInput[0] = mConstComplex;
+        pf = buildShader(null, constInput, multiUni);
+        if (testBind) {
+            mScript.invoke_testProgramFragment(pf);
+            mRS.bindProgramFragment(pf);
+        }
+
+        Allocation[] textures = new Allocation[2];
+        textures[0] = mTex2D;
+        textures[1] = mTexCube;
+        pf = buildShader(textures, constInput, simpleUniTex);
+        if (testBind) {
+            mScript.invoke_testProgramFragment(pf);
+            mRS.bindProgramFragment(pf);
+        }
+
+        constInput = new Allocation[2];
+        constInput[0] = mConstMatrix;
+        constInput[1] = mConstExtra;
+        pf = buildShader(null, constInput, multiUni);
+        if (testBind) {
+            mScript.invoke_testProgramFragment(pf);
+            mRS.bindProgramFragment(pf);
+        }
+    }
+
+    public void testProgramFragmentBuilder() {
+        testProgramFragmentBuilderHelper(false);
+    }
+
+    public void testProgramFragmentCreation() {
+        testProgramFragmentBuilderHelper(true);
+    }
+
+    public void testProgramTextureType() {
+        assertEquals(Program.TextureType.TEXTURE_2D,
+                     Program.TextureType.valueOf("TEXTURE_2D"));
+        assertEquals(Program.TextureType.TEXTURE_CUBE,
+                     Program.TextureType.valueOf("TEXTURE_CUBE"));
+        // Make sure no new enums are added
+        assertEquals(2, Program.TextureType.values().length);
+
+        ProgramFragment.Builder pfb = new ProgramFragment.Builder(mRS);
+        for (Program.TextureType tt : Program.TextureType.values()) {
+            pfb.addTexture(tt);
+        }
+    }
+}
+
+
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ProgramRasterTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ProgramRasterTest.java
new file mode 100644
index 0000000..befa926
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ProgramRasterTest.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2011 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.renderscript.cts;
+
+import android.renderscript.ProgramRaster;
+import android.renderscript.ProgramRaster.Builder;
+import android.renderscript.ProgramRaster.CullMode;
+
+public class ProgramRasterTest extends RSBaseGraphics {
+
+    public void testProgramRasterBuilder() {
+        ProgramRaster.Builder b = new ProgramRaster.Builder(mRS);
+        for (int p = 0; p <= 1; p++) {
+            boolean pSprite = (p == 1);
+            b.setPointSpriteEnabled(pSprite);
+            for (CullMode cull : CullMode.values()) {
+                b.setCullMode(cull);
+                ProgramRaster pr = b.create();
+                assertTrue(pr != null);
+                mRS.bindProgramRaster(pr);
+            }
+        }
+    }
+
+    public void testPrebuiltProgramRaster() {
+        assertTrue(ProgramRaster.CULL_BACK(mRS) != null);
+        assertTrue(ProgramRaster.CULL_FRONT(mRS) != null);
+        assertTrue(ProgramRaster.CULL_NONE(mRS) != null);
+    }
+
+    public void testProgramRasterCullMode() {
+        assertEquals(CullMode.BACK, CullMode.valueOf("BACK"));
+        assertEquals(CullMode.FRONT, CullMode.valueOf("FRONT"));
+        assertEquals(CullMode.NONE, CullMode.valueOf("NONE"));
+        // Make sure no new enums are added
+        assertEquals(3, CullMode.values().length);
+    }
+}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ProgramStoreTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ProgramStoreTest.java
new file mode 100644
index 0000000..b7f5eff
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ProgramStoreTest.java
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2011 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.renderscript.cts;
+
+import android.renderscript.ProgramStore;
+import android.renderscript.ProgramStore.DepthFunc;
+import android.renderscript.ProgramStore.BlendSrcFunc;
+import android.renderscript.ProgramStore.BlendDstFunc;
+
+public class ProgramStoreTest extends RSBaseGraphics {
+
+    void varyBuilderColorAndDither(ProgramStore.Builder pb) {
+        for (int r = 0; r <= 1; r++) {
+            boolean isR = (r == 1);
+            for (int g = 0; g <= 1; g++) {
+                boolean isG = (g == 1);
+                for (int b = 0; b <= 1; b++) {
+                    boolean isB = (b == 1);
+                    for (int a = 0; a <= 1; a++) {
+                        boolean isA = (a == 1);
+                        for (int dither = 0; dither <= 1; dither++) {
+                            boolean isDither = (dither == 1);
+                            pb.setDitherEnabled(isDither);
+                            pb.setColorMaskEnabled(isR, isG, isB, isA);
+                            ProgramStore ps = pb.create();
+                            assertTrue(ps != null);
+                            mRS.bindProgramStore(ps);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    public void testProgramStoreBuilder() {
+        for (int depth = 0; depth <= 1; depth++) {
+            boolean depthMask = (depth == 1);
+            for (DepthFunc df : DepthFunc.values()) {
+                for (BlendSrcFunc bsf : BlendSrcFunc.values()) {
+                    for (BlendDstFunc bdf : BlendDstFunc.values()) {
+                        ProgramStore.Builder b = new ProgramStore.Builder(mRS);
+                        b.setDepthFunc(df);
+                        b.setDepthMaskEnabled(depthMask);
+                        b.setBlendFunc(bsf, bdf);
+                        varyBuilderColorAndDither(b);
+                    }
+                }
+            }
+        }
+    }
+
+    public void testPrebuiltProgramStore() {
+        assertTrue(ProgramStore.BLEND_ALPHA_DEPTH_NONE(mRS) != null);
+        assertTrue(ProgramStore.BLEND_ALPHA_DEPTH_TEST(mRS) != null);
+        assertTrue(ProgramStore.BLEND_NONE_DEPTH_NONE(mRS) != null);
+        assertTrue(ProgramStore.BLEND_NONE_DEPTH_TEST(mRS) != null);
+    }
+
+    public void testProgramStoreBlendDstFunc() {
+        assertEquals(BlendDstFunc.ZERO,
+                     BlendDstFunc.valueOf("ZERO"));
+        assertEquals(BlendDstFunc.ONE,
+                     BlendDstFunc.valueOf("ONE"));
+        assertEquals(BlendDstFunc.SRC_COLOR,
+                     BlendDstFunc.valueOf("SRC_COLOR"));
+        assertEquals(BlendDstFunc.ONE_MINUS_SRC_COLOR,
+                     BlendDstFunc.valueOf("ONE_MINUS_SRC_COLOR"));
+        assertEquals(BlendDstFunc.SRC_ALPHA,
+                     BlendDstFunc.valueOf("SRC_ALPHA"));
+        assertEquals(BlendDstFunc.ONE_MINUS_SRC_ALPHA,
+                     BlendDstFunc.valueOf("ONE_MINUS_SRC_ALPHA"));
+        assertEquals(BlendDstFunc.DST_ALPHA,
+                     BlendDstFunc.valueOf("DST_ALPHA"));
+        assertEquals(BlendDstFunc.ONE_MINUS_DST_ALPHA,
+                     BlendDstFunc.valueOf("ONE_MINUS_DST_ALPHA"));
+        // Make sure no new enums are added
+        assertEquals(8, BlendDstFunc.values().length);
+    }
+
+    public void testProgramStoreBlendSrcFunc() {
+        assertEquals(BlendSrcFunc.ZERO,
+                     BlendSrcFunc.valueOf("ZERO"));
+        assertEquals(BlendSrcFunc.ONE,
+                     BlendSrcFunc.valueOf("ONE"));
+        assertEquals(BlendSrcFunc.DST_COLOR,
+                     BlendSrcFunc.valueOf("DST_COLOR"));
+        assertEquals(BlendSrcFunc.ONE_MINUS_DST_COLOR,
+                     BlendSrcFunc.valueOf("ONE_MINUS_DST_COLOR"));
+        assertEquals(BlendSrcFunc.SRC_ALPHA,
+                     BlendSrcFunc.valueOf("SRC_ALPHA"));
+        assertEquals(BlendSrcFunc.ONE_MINUS_SRC_ALPHA,
+                     BlendSrcFunc.valueOf("ONE_MINUS_SRC_ALPHA"));
+        assertEquals(BlendSrcFunc.DST_ALPHA,
+                     BlendSrcFunc.valueOf("DST_ALPHA"));
+        assertEquals(BlendSrcFunc.ONE_MINUS_DST_ALPHA,
+                     BlendSrcFunc.valueOf("ONE_MINUS_DST_ALPHA"));
+        assertEquals(BlendSrcFunc.SRC_ALPHA_SATURATE,
+                     BlendSrcFunc.valueOf("SRC_ALPHA_SATURATE"));
+        // Make sure no new enums are added
+        assertEquals(9, BlendSrcFunc.values().length);
+    }
+    public void testProgramStoreDepthFunc() {
+        assertEquals(DepthFunc.ALWAYS,
+                     DepthFunc.valueOf("ALWAYS"));
+        assertEquals(DepthFunc.LESS,
+                     DepthFunc.valueOf("LESS"));
+        assertEquals(DepthFunc.LESS_OR_EQUAL,
+                     DepthFunc.valueOf("LESS_OR_EQUAL"));
+        assertEquals(DepthFunc.GREATER,
+                     DepthFunc.valueOf("GREATER"));
+        assertEquals(DepthFunc.GREATER_OR_EQUAL,
+                     DepthFunc.valueOf("GREATER_OR_EQUAL"));
+        assertEquals(DepthFunc.EQUAL,
+                     DepthFunc.valueOf("EQUAL"));
+        assertEquals(DepthFunc.NOT_EQUAL,
+                     DepthFunc.valueOf("NOT_EQUAL"));
+        // Make sure no new enums are added
+        assertEquals(7, DepthFunc.values().length);
+    }
+}
+
+
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ProgramVertexFixedFunctionTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ProgramVertexFixedFunctionTest.java
new file mode 100644
index 0000000..0adab9a
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ProgramVertexFixedFunctionTest.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2011 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.renderscript.cts;
+
+import com.android.cts.stub.R;
+
+import android.renderscript.ProgramVertexFixedFunction;
+import android.renderscript.ProgramVertexFixedFunction.Builder;
+import android.renderscript.ScriptC;
+import android.renderscript.Matrix4f;
+
+public class ProgramVertexFixedFunctionTest extends RSBaseGraphics {
+
+    ScriptC_graphics_runner mScript;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mScript = new ScriptC_graphics_runner(mRS, mRes, R.raw.graphics_runner);
+        mRS.bindRootScript(mScript);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        mRS.bindRootScript(null);
+        super.tearDown();
+    }
+
+    public void testConstants() {
+        ProgramVertexFixedFunction.Constants pva;
+        for (int isM = 0; isM <= 1; isM++) {
+            for (int isP = 0; isP <= 1; isP++) {
+                for (int isT = 0; isT <= 1; isT++) {
+                    pva = new ProgramVertexFixedFunction.Constants(mRS);
+                    if (isM == 1) {
+                        pva.setModelview(new Matrix4f());
+                    }
+                    if (isP == 1) {
+                        pva.setProjection(new Matrix4f());
+                    }
+                    if (isT == 1) {
+                        pva.setTexture(new Matrix4f());
+                    }
+                    pva.destroy();
+                }
+            }
+        }
+    }
+
+    void testProgramVertexFixedFunctionBuilder(boolean testBind) {
+        ProgramVertexFixedFunction.Constants pva;
+        pva = new ProgramVertexFixedFunction.Constants(mRS);
+
+        ProgramVertexFixedFunction.Builder b;
+        b = new ProgramVertexFixedFunction.Builder(mRS);
+        b.setTextureMatrixEnable(false);
+        ProgramVertexFixedFunction pv = b.create();
+        assertTrue(pv != null);
+        pv.bindConstants(pva);
+        if (testBind) {
+            mScript.invoke_testProgramVertex(pv);
+        }
+        pv.destroy();
+        b.setTextureMatrixEnable(true);
+        pv = b.create();
+        assertTrue(pv != null);
+        pv.bindConstants(pva);
+        if (testBind) {
+            mScript.invoke_testProgramVertex(pv);
+        }
+        pv.destroy();
+    }
+
+    public void testProgramVertexFixedFunctionBuilder() {
+        testProgramVertexFixedFunctionBuilder(false);
+        testProgramVertexFixedFunctionBuilder(true);
+    }
+
+}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ProgramVertexTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ProgramVertexTest.java
new file mode 100644
index 0000000..3c2c188
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ProgramVertexTest.java
@@ -0,0 +1,243 @@
+/*
+ * Copyright (C) 2011 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.renderscript.cts;
+
+import com.android.cts.stub.R;
+
+import android.renderscript.Allocation;
+import android.renderscript.Element;
+import android.renderscript.Program;
+import android.renderscript.ProgramVertex;
+
+public class ProgramVertexTest extends RSBaseGraphics {
+
+    ScriptC_graphics_runner mScript;
+    Element mAttrPosElem;
+    Element mAttrNormTexElem;
+    Element mAttrPosNormTexElem;
+    Element mAttrExtra;
+
+    Allocation mConstMatrix;
+    Allocation mConstComplex;
+    Allocation mConstExtra;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // Build elements for shader inputs
+        Element.Builder eb = new Element.Builder(mRS);
+        eb.add(Element.F32_4(mRS), "position");
+        mAttrPosElem = eb.create();
+
+        eb = new Element.Builder(mRS);
+        eb.add(Element.F32_3(mRS), "normal");
+        eb.add(Element.F32_2(mRS), "texture0");
+        mAttrNormTexElem = eb.create();
+
+        eb = new Element.Builder(mRS);
+        eb.add(Element.F32_4(mRS), "position");
+        eb.add(Element.F32_3(mRS), "normal");
+        eb.add(Element.F32_2(mRS), "texture0");
+        mAttrPosNormTexElem = eb.create();
+
+        eb.add(Element.F32(mRS), "extra1");
+        eb.add(Element.F32_2(mRS), "extra2");
+        eb.add(Element.F32_3(mRS), "extra3");
+        eb.add(Element.F32_4(mRS), "extra4");
+        mAttrExtra = eb.create();
+
+        ScriptField_ConstMatrix c1 = new ScriptField_ConstMatrix(mRS, 1,
+                                                                 Allocation.USAGE_SCRIPT |
+                                                                 Allocation.USAGE_GRAPHICS_CONSTANTS);
+        c1.set(new ScriptField_ConstMatrix.Item(), 0, true);
+        mConstMatrix = c1.getAllocation();
+
+        ScriptField_ConstComplex c2 = new ScriptField_ConstComplex(mRS, 1,
+                                                                   Allocation.USAGE_SCRIPT |
+                                                                   Allocation.USAGE_GRAPHICS_CONSTANTS);
+        c2.set(new ScriptField_ConstComplex.Item(), 0, true);
+        mConstComplex = c2.getAllocation();
+
+        ScriptField_ConstExtra c3 = new ScriptField_ConstExtra(mRS, 1,
+                                                               Allocation.USAGE_SCRIPT |
+                                                               Allocation.USAGE_GRAPHICS_CONSTANTS);
+        c3.set(new ScriptField_ConstExtra.Item(), 0, true);
+        mConstExtra = c3.getAllocation();
+
+        mScript = new ScriptC_graphics_runner(mRS, mRes, R.raw.graphics_runner);
+        mRS.bindRootScript(mScript);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        mRS.bindRootScript(null);
+        super.tearDown();
+    }
+
+    ProgramVertex buildShader(Element[] input, Allocation[] constInput, String shader) {
+        ProgramVertex.Builder pvb = new ProgramVertex.Builder(mRS);
+        Program.BaseProgramBuilder bpb = pvb;
+        if (input != null) {
+            for (int i = 0; i < input.length; i++) {
+                pvb.addInput(input[i]);
+            }
+        }
+        if (constInput != null) {
+            for (int i = 0; i < constInput.length; i++) {
+                // Add constants through the base builder class to
+                // tick cts test coverage (doesn't register through subclass)
+                bpb.addConstant(constInput[i].getType());
+                bpb.getCurrentConstantIndex();
+            }
+        }
+
+        bpb.setShader(shader);
+        ProgramVertex pv = pvb.create();
+        if (constInput != null) {
+            for (int i = 0; i < constInput.length; i++) {
+                pv.bindConstants(constInput[i], i);
+                // Go through the base class code as well
+                Program p = pv;
+                p.bindConstants(constInput[i], i);
+            }
+        }
+        return pv;
+    }
+
+    void testProgramVertexBuilderHelper(boolean testBind) {
+        String simpleAttr = "void main() {\n"+
+                            "  gl_Position = ATTRIB_position;\n"+
+                            "}";
+
+        String multiAttr = "void main() {\n"+
+                           "  vec4 temp = ATTRIB_position;\n"+
+                           "  temp.xyz += ATTRIB_normal;\n"+
+                           "  temp.xy += ATTRIB_texture0;\n"+
+                           "  gl_Position = temp;\n"+
+                           "}";
+
+        String multiAttr2 = "void main() {\n"+
+                            "  vec4 temp = ATTRIB_position;\n"+
+                            "  temp.xyz += ATTRIB_normal;\n"+
+                            "  temp.xy += ATTRIB_texture0;\n"+
+                            "  temp += ATTRIB_extra4;\n"+
+                            "  temp.xyz += ATTRIB_extra3;\n "+
+                            "  temp.xy += ATTRIB_extra2;\n"+
+                            "  temp.x += ATTRIB_extra1;\n"+
+                            "  gl_Position = temp;\n"+
+                            "}";
+
+        String simpleAttrSimpleUni = "void main() {\n"+
+                                     "  gl_Position = UNI_MATRIX * ATTRIB_position;\n"+
+                                     "}";
+
+        String multiAttrMultiUni = "void main() {\n"+
+                                   "  vec4 temp = UNI_MATRIX * ATTRIB_position;\n"+
+                                   "  temp = UNI_EXTRA * temp;\n"+
+                                   "  temp.xyz += ATTRIB_normal;\n"+
+                                   "  temp.xy += ATTRIB_texture0;\n"+
+                                   "  temp += UNI_extra4;\n"+
+                                   "  temp.xyz += UNI_extra3;\n "+
+                                   "  temp.xy += UNI_extra2;\n"+
+                                   "  temp.x += UNI_extra1;\n"+
+                                   "  gl_Position = temp;\n"+
+                                   "}";
+
+        // Create a series of shaders that do nothing useful
+        // but exercise creation pipeline
+        Element[] inputs = new Element[1];
+        inputs[0] = mAttrPosElem;
+        ProgramVertex pv = buildShader(inputs, null, simpleAttr);
+        if (testBind) {
+            mScript.invoke_testProgramVertex(pv);
+            mRS.bindProgramVertex(pv);
+        }
+
+        inputs[0] = mAttrPosNormTexElem;
+        pv = buildShader(inputs, null, multiAttr);
+        if (testBind) {
+            mScript.invoke_testProgramVertex(pv);
+            mRS.bindProgramVertex(pv);
+        }
+
+        inputs[0] = mAttrExtra;
+        pv = buildShader(inputs, null, multiAttr2);
+        if (testBind) {
+            mScript.invoke_testProgramVertex(pv);
+            mRS.bindProgramVertex(pv);
+        }
+
+        // Now with constant inputs
+        Allocation[] constInput = new Allocation[1];
+        inputs[0] = mAttrPosElem;
+        constInput[0] = mConstMatrix;
+        pv = buildShader(inputs, constInput, simpleAttrSimpleUni);
+        if (testBind) {
+            mScript.invoke_testProgramVertex(pv);
+            mRS.bindProgramVertex(pv);
+        }
+
+        inputs[0] = mAttrPosNormTexElem;
+        constInput[0] = mConstComplex;
+        pv = buildShader(inputs, constInput, multiAttrMultiUni);
+        if (testBind) {
+            mScript.invoke_testProgramVertex(pv);
+            mRS.bindProgramVertex(pv);
+        }
+
+        // Now with multiple input and const structs
+        constInput = new Allocation[2];
+        constInput[0] = mConstMatrix;
+        constInput[1] = mConstExtra;
+        inputs[0] = mAttrPosNormTexElem;
+        pv = buildShader(inputs, constInput, multiAttrMultiUni);
+        if (testBind) {
+            mScript.invoke_testProgramVertex(pv);
+            mRS.bindProgramVertex(pv);
+        }
+
+        inputs = new Element[2];
+        inputs[0] = mAttrPosElem;
+        inputs[1] = mAttrNormTexElem;
+        pv = buildShader(inputs, null, multiAttr);
+        if (testBind) {
+            mScript.invoke_testProgramVertex(pv);
+            mRS.bindProgramVertex(pv);
+        }
+
+        constInput[0] = mConstMatrix;
+        constInput[1] = mConstExtra;
+        inputs[0] = mAttrPosElem;
+        inputs[1] = mAttrNormTexElem;
+        pv = buildShader(inputs, constInput, multiAttrMultiUni);
+        if (testBind) {
+            mScript.invoke_testProgramVertex(pv);
+            mRS.bindProgramVertex(pv);
+        }
+    }
+
+    public void testProgramVertexBuilder() {
+        testProgramVertexBuilderHelper(false);
+    }
+
+    public void testProgramVertexCreation() {
+        testProgramVertexBuilderHelper(true);
+    }
+}
+
+
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/RSBase.java b/tests/tests/renderscript/src/android/renderscript/cts/RSBase.java
new file mode 100644
index 0000000..56838e1
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/RSBase.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2011 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.renderscript.cts;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.renderscript.RenderScript.RSMessageHandler;
+import android.test.AndroidTestCase;
+
+/**
+ * Base RenderScript test class. This class provides a message handler and a
+ * convenient way to wait for compute scripts to complete their execution.
+ */
+class RSBase extends AndroidTestCase {
+
+    Context mCtx;
+    Resources mRes;
+
+    public int result;
+    private boolean msgHandled;
+
+    public static final int RS_MSG_TEST_PASSED = 100;
+    public static final int RS_MSG_TEST_FAILED = 101;
+
+    RSMessageHandler mRsMessage = new RSMessageHandler() {
+        public void run() {
+            if (result == 0) {
+                switch (mID) {
+                    case RS_MSG_TEST_PASSED:
+                    case RS_MSG_TEST_FAILED:
+                        result = mID;
+                        break;
+                    default:
+                        fail("Got unexpected RS message");
+                        return;
+                }
+            }
+            msgHandled = true;
+        }
+    };
+
+    protected void waitForMessage() {
+        while (!msgHandled) {
+            Thread.yield();
+        }
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        result = 0;
+        msgHandled = false;
+        mCtx = getContext();
+        mRes = mCtx.getResources();
+    }
+}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/RSBaseCompute.java b/tests/tests/renderscript/src/android/renderscript/cts/RSBaseCompute.java
new file mode 100644
index 0000000..3278113
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/RSBaseCompute.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2011 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.renderscript.cts;
+
+import android.renderscript.RenderScript;
+
+/**
+ * Base RenderScript test class. This class provides a message handler and a
+ * convenient way to wait for compute scripts to complete their execution.
+ */
+class RSBaseCompute extends RSBase {
+    RenderScript mRS;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mRS = RenderScript.create(mCtx);
+        mRS.setMessageHandler(mRsMessage);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        if (mRS != null) {
+            mRS.destroy();
+            mRS = null;
+        }
+        super.tearDown();
+    }
+
+}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/RSBaseGraphics.java b/tests/tests/renderscript/src/android/renderscript/cts/RSBaseGraphics.java
new file mode 100644
index 0000000..986a50d
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/RSBaseGraphics.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2011 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.renderscript.cts;
+
+import android.renderscript.RenderScriptGL;
+import android.renderscript.RenderScriptGL.SurfaceConfig;
+
+/**
+ * Base RenderScript test class. This class provides a message handler and a
+ * convenient way to wait for compute scripts to complete their execution.
+ */
+class RSBaseGraphics extends RSBase {
+    RenderScriptGL mRS;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        mRS = new RenderScriptGL(mCtx, new SurfaceConfig());
+        mRS.setMessageHandler(mRsMessage);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        if (mRS != null) {
+            mRS.destroy();
+            mRS = null;
+        }
+        super.tearDown();
+    }
+
+}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/RSSurfaceViewTest.java b/tests/tests/renderscript/src/android/renderscript/cts/RSSurfaceViewTest.java
new file mode 100644
index 0000000..9cf8f65
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/RSSurfaceViewTest.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2011 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.renderscript.cts;
+
+import android.renderscript.RSSurfaceView;
+import android.renderscript.RenderScriptGL;
+import android.renderscript.RenderScriptGL.SurfaceConfig;
+import android.util.AttributeSet;
+
+public class RSSurfaceViewTest extends RSBaseGraphics {
+
+    public void testCreation() {
+        RSSurfaceView view = new RSSurfaceView(mCtx);
+        view = new RSSurfaceView(mCtx, null);
+    }
+
+    public void testCreateRenderScriptGL() {
+        RSSurfaceView view = new RSSurfaceView(mCtx);
+        RenderScriptGL rs = view.createRenderScriptGL(new SurfaceConfig());
+        assertTrue(rs != null);
+    }
+
+    public void testGetSetRenderScriptGL() {
+        RSSurfaceView view = new RSSurfaceView(mCtx);
+        RenderScriptGL rs = view.createRenderScriptGL(new SurfaceConfig());
+        assertTrue(rs != null);
+        assertEquals(view.getRenderScriptGL(), rs);
+
+        view = new RSSurfaceView(mCtx);
+        view.setRenderScriptGL(mRS);
+        assertEquals(view.getRenderScriptGL(), mRS);
+    }
+
+    public void testDestroyRenderScriptGL() {
+        RSSurfaceView view = new RSSurfaceView(mCtx);
+        RenderScriptGL rs = view.createRenderScriptGL(new SurfaceConfig());
+        assertTrue(rs != null);
+        view.destroyRenderScriptGL();
+        assertTrue(view.getRenderScriptGL() == null);
+    }
+
+    public void testPauseResume() {
+        RSSurfaceView view = new RSSurfaceView(mCtx);
+        view.pause();
+        view.resume();
+
+        view.setRenderScriptGL(mRS);
+        view.pause();
+        view.resume();
+    }
+}
+
+
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/RenderScriptTest.java b/tests/tests/renderscript/src/android/renderscript/cts/RenderScriptTest.java
new file mode 100644
index 0000000..9e61526
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/RenderScriptTest.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2011 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.renderscript.cts;
+
+import com.android.cts.stub.R;
+
+import android.renderscript.RenderScript;
+import android.test.AndroidTestCase;
+
+public class RenderScriptTest extends AndroidTestCase {
+
+    /**
+     * Simple test for Renderscript that executes a passthrough function
+     * from cts/tests/src/android/renderscript/cts/passthrough.rs.
+     */
+    public void testRenderScript() {
+        RenderScript mRS = RenderScript.create(getContext());
+        ScriptC_passthrough t = new ScriptC_passthrough(mRS,
+            getContext().getResources(), R.raw.passthrough);
+        t.invoke_passthrough(5);
+        mRS.destroy();
+    }
+
+    /**
+     * Excercise all API calls in the basic RenderScript class.
+     */
+    public void testAPI() {
+        try {
+            RenderScript mRS = RenderScript.create(null);
+            fail("should throw NullPointerException.");
+        } catch (NullPointerException e) {
+        }
+
+        RenderScript mRS = RenderScript.create(getContext());
+        mRS.contextDump();
+        mRS.finish();
+        assertEquals(mRS.getApplicationContext(),
+                     getContext().getApplicationContext());
+        RenderScript.RSErrorHandler mEH = mRS.getErrorHandler();
+        RenderScript.RSMessageHandler mMH = mRS.getMessageHandler();
+        mRS.setErrorHandler(mEH);
+        mRS.setMessageHandler(mMH);
+        mRS.setPriority(RenderScript.Priority.LOW);
+        mRS.setPriority(RenderScript.Priority.NORMAL);
+        mRS.destroy();
+    }
+
+    /**
+     * Verify Priority enum properties.
+     */
+    public void testPriority() {
+        assertEquals(RenderScript.Priority.LOW,
+            RenderScript.Priority.valueOf("LOW"));
+        assertEquals(RenderScript.Priority.NORMAL,
+            RenderScript.Priority.valueOf("NORMAL"));
+        assertEquals(2, RenderScript.Priority.values().length);
+    }
+
+    /**
+     * Create a base RSMessageHandler object and run() it.
+     * Note that most developers will subclass RSMessageHandler and use
+     * their own non-empty implementation.
+     */
+    public void testRSMessageHandler() {
+        RenderScript.RSMessageHandler mMH = new RenderScript.RSMessageHandler();
+        mMH.run();
+    }
+
+    /**
+     * Create a base RSErrorHandler object and run() it.
+     * Note that most developers will subclass RSErrorHandler and use
+     * their own non-empty implementation.
+     */
+    public void testRSErrorHandler() {
+        RenderScript.RSErrorHandler mEH = new RenderScript.RSErrorHandler();
+        mEH.run();
+    }
+}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/SamplerTest.java b/tests/tests/renderscript/src/android/renderscript/cts/SamplerTest.java
new file mode 100644
index 0000000..35e813e
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/SamplerTest.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2011 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.renderscript.cts;
+
+import android.renderscript.Sampler;
+import android.renderscript.Sampler.Value;
+
+public class SamplerTest extends RSBaseGraphics {
+
+    Sampler.Value[] mMinValues;
+    Sampler.Value[] mMagValues;
+    Sampler.Value[] mWrapValues;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        mMinValues = new Sampler.Value[4];
+        mMinValues[0] = Sampler.Value.NEAREST;
+        mMinValues[1] = Sampler.Value.LINEAR;
+        mMinValues[2] = Sampler.Value.LINEAR_MIP_LINEAR;
+        mMinValues[3] = Sampler.Value.LINEAR_MIP_NEAREST;
+
+        mMagValues = new Sampler.Value[2];
+        mMagValues[0] = Sampler.Value.NEAREST;
+        mMagValues[1] = Sampler.Value.LINEAR;
+
+        mWrapValues = new Sampler.Value[2];
+        mWrapValues[0] = Sampler.Value.CLAMP;
+        mWrapValues[1] = Sampler.Value.WRAP;
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        mMinValues = null;
+        mMagValues = null;
+        mWrapValues = null;
+        super.tearDown();
+    }
+
+    boolean contains(Sampler.Value[] array, Sampler.Value val) {
+        for (int i = 0; i < array.length; i ++) {
+            if (array[i] == val) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public void testSamplerBuilder() {
+        for (int aniso = 1; aniso <= 4; aniso++) {
+            for (Sampler.Value minV : Sampler.Value.values()) {
+                for (Sampler.Value magV : Sampler.Value.values()) {
+                    for (Sampler.Value wrapSV : Sampler.Value.values()) {
+                        for (Sampler.Value wrapTV : Sampler.Value.values()) {
+                            Sampler.Builder b = new Sampler.Builder(mRS);
+                            b.setAnisotropy(aniso);
+
+                            // Some value combinations are illegal
+                            boolean validMin = contains(mMinValues, minV);
+                            boolean validMag = contains(mMagValues, magV);
+                            boolean validS = contains(mWrapValues, wrapSV);
+                            boolean validT = contains(mWrapValues, wrapTV);
+
+                            try {
+                                b.setMinification(minV);
+                            } catch (IllegalArgumentException e) {
+                                assertFalse(validMin);
+                            }
+                            try {
+                                b.setMagnification(magV);
+                            } catch (IllegalArgumentException e) {
+                                assertFalse(validMag);
+                            }
+                            try {
+                                b.setWrapS(wrapSV);
+                            } catch (IllegalArgumentException e) {
+                                assertFalse(validS);
+                            }
+                            try {
+                                b.setWrapT(wrapTV);
+                            } catch (IllegalArgumentException e) {
+                                assertFalse(validT);
+                            }
+
+                            if (validMin && validMag && validS && validT) {
+                                b.create();
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+
+    public void testPrebuiltSamplers() {
+        assertTrue(Sampler.CLAMP_LINEAR(mRS) != null);
+        assertTrue(Sampler.CLAMP_LINEAR_MIP_LINEAR(mRS) != null);
+        assertTrue(Sampler.CLAMP_NEAREST(mRS) != null);
+        assertTrue(Sampler.WRAP_LINEAR(mRS) != null);
+        assertTrue(Sampler.WRAP_LINEAR_MIP_LINEAR(mRS) != null);
+        assertTrue(Sampler.WRAP_NEAREST(mRS) != null);
+    }
+
+    public void testSamplerValue() {
+        assertEquals(Value.NEAREST, Value.valueOf("NEAREST"));
+        assertEquals(Value.LINEAR, Value.valueOf("LINEAR"));
+        assertEquals(Value.LINEAR_MIP_LINEAR, Value.valueOf("LINEAR_MIP_LINEAR"));
+        assertEquals(Value.LINEAR_MIP_NEAREST, Value.valueOf("LINEAR_MIP_NEAREST"));
+        assertEquals(Value.WRAP, Value.valueOf("WRAP"));
+        assertEquals(Value.CLAMP, Value.valueOf("CLAMP"));
+
+        // Make sure no new enums are added
+        assertEquals(6, Value.values().length);
+    }
+}
+
+
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/SurfaceConfigTest.java b/tests/tests/renderscript/src/android/renderscript/cts/SurfaceConfigTest.java
new file mode 100644
index 0000000..94d784e
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/SurfaceConfigTest.java
@@ -0,0 +1,154 @@
+/*
+ * Copyright (C) 2011 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.renderscript.cts;
+import android.test.AndroidTestCase;
+
+import android.renderscript.RSIllegalArgumentException;
+import android.renderscript.RenderScriptGL.SurfaceConfig;
+
+public class SurfaceConfigTest extends AndroidTestCase {
+
+    public void testSimpleCreate() {
+        SurfaceConfig sc = new SurfaceConfig();
+    }
+
+    public void testSetColor() {
+        SurfaceConfig sc = new SurfaceConfig();
+        try {
+            sc.setColor(-1, 8);
+            fail("should throw RSIllegalArgumentException.");
+        } catch (RSIllegalArgumentException e) {
+        }
+        sc = new SurfaceConfig();
+        try {
+            sc.setColor(9, 8);
+            fail("should throw RSIllegalArgumentException.");
+        } catch (RSIllegalArgumentException e) {
+        }
+        sc = new SurfaceConfig();
+        try {
+            sc.setColor(5, -1);
+            fail("should throw RSIllegalArgumentException.");
+        } catch (RSIllegalArgumentException e) {
+        }
+        sc = new SurfaceConfig();
+        sc.setColor(5, 8);
+        sc = new SurfaceConfig();
+        sc.setColor(8, 8);
+    }
+
+    public void testSetAlpha() {
+        SurfaceConfig sc = new SurfaceConfig();
+        try {
+            sc.setAlpha(-1, 8);
+            fail("should throw RSIllegalArgumentException.");
+        } catch (RSIllegalArgumentException e) {
+        }
+        sc = new SurfaceConfig();
+        try {
+            sc.setAlpha(9, 8);
+            fail("should throw RSIllegalArgumentException.");
+        } catch (RSIllegalArgumentException e) {
+        }
+        sc = new SurfaceConfig();
+        try {
+            sc.setAlpha(0, -1);
+            fail("should throw RSIllegalArgumentException.");
+        } catch (RSIllegalArgumentException e) {
+        }
+        sc = new SurfaceConfig();
+        sc.setAlpha(0, 8);
+        sc = new SurfaceConfig();
+        sc.setAlpha(8, 8);
+    }
+
+    public void testSetDepth() {
+        SurfaceConfig sc = new SurfaceConfig();
+        try {
+            sc.setDepth(-1, 8);
+            fail("should throw RSIllegalArgumentException.");
+        } catch (RSIllegalArgumentException e) {
+        }
+        sc = new SurfaceConfig();
+        try {
+            sc.setDepth(45, 8);
+            fail("should throw RSIllegalArgumentException.");
+        } catch (RSIllegalArgumentException e) {
+        }
+        sc = new SurfaceConfig();
+        try {
+            sc.setDepth(0, -1);
+            fail("should throw RSIllegalArgumentException.");
+        } catch (RSIllegalArgumentException e) {
+        }
+        sc = new SurfaceConfig();
+        sc.setDepth(0, 16);
+        sc = new SurfaceConfig();
+        sc.setDepth(16, 24);
+        sc = new SurfaceConfig();
+        sc.setDepth(24, 24);
+    }
+
+    public void testSetSamples() {
+        SurfaceConfig sc = new SurfaceConfig();
+        try {
+            sc.setSamples(-1, 8, 1.0f);
+            fail("should throw RSIllegalArgumentException.");
+        } catch (RSIllegalArgumentException e) {
+        }
+        sc = new SurfaceConfig();
+        try {
+            sc.setSamples(45, 8, 1.0f);
+            fail("should throw RSIllegalArgumentException.");
+        } catch (RSIllegalArgumentException e) {
+        }
+        sc = new SurfaceConfig();
+        try {
+            sc.setSamples(1, -1, 1.0f);
+            fail("should throw RSIllegalArgumentException.");
+        } catch (RSIllegalArgumentException e) {
+        }
+        sc = new SurfaceConfig();
+        try {
+            sc.setSamples(1, 1, -1.0f);
+            fail("should throw RSIllegalArgumentException.");
+        } catch (RSIllegalArgumentException e) {
+        }
+        sc = new SurfaceConfig();
+        try {
+            sc.setSamples(1, 1, 10.0f);
+            fail("should throw RSIllegalArgumentException.");
+        } catch (RSIllegalArgumentException e) {
+        }
+        sc = new SurfaceConfig();
+        sc.setSamples(1, 4, 1.0f);
+        sc = new SurfaceConfig();
+        sc.setSamples(4, 32, 1.0f);
+        sc = new SurfaceConfig();
+        sc.setSamples(4, 64, 0.5f);
+    }
+
+    public void testCopyConstructor() {
+        SurfaceConfig sc = new SurfaceConfig();
+        sc.setAlpha(1, 7);
+        sc.setColor(5, 8);
+        sc.setDepth(0, 16);
+        sc.setSamples(1, 4, 0.71f);
+        SurfaceConfig sc2 = new SurfaceConfig(sc);
+    }
+
+}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/TypeTest.java b/tests/tests/renderscript/src/android/renderscript/cts/TypeTest.java
new file mode 100644
index 0000000..928abaf
--- /dev/null
+++ b/tests/tests/renderscript/src/android/renderscript/cts/TypeTest.java
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) 2011 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.renderscript.cts;
+
+import android.renderscript.Element;
+import android.renderscript.Type;
+
+public class TypeTest extends RSBaseCompute {
+
+    void testBuilderSizes(Type.Builder b, int min, int max) {
+        for (int x = min; x < max; x ++) {
+            for (int y = min; y < max; y ++) {
+                b.setX(x).setY(y);
+                b.create();
+            }
+        }
+    }
+
+    void testTypeBuilderHelper(Element e) {
+        Type.Builder b = new Type.Builder(mRS, e);
+        for (int mips = 0; mips <= 1; mips ++) {
+            boolean useMips = (mips == 1);
+
+            for (int faces = 0; faces <= 1; faces++) {
+                boolean useFaces = (faces == 1);
+
+                b.setMipmaps(useMips);
+                b.setFaces(useFaces);
+                testBuilderSizes(b, 1, 8);
+            }
+        }
+    }
+
+    public void testTypeBuilder() {
+        testTypeBuilderHelper(Element.A_8(mRS));
+        testTypeBuilderHelper(Element.RGB_565(mRS));
+        testTypeBuilderHelper(Element.RGB_888(mRS));
+        testTypeBuilderHelper(Element.RGBA_8888(mRS));
+        testTypeBuilderHelper(Element.F32(mRS));
+        testTypeBuilderHelper(Element.F32_2(mRS));
+        testTypeBuilderHelper(Element.F32_3(mRS));
+        testTypeBuilderHelper(Element.F32_4(mRS));
+        testTypeBuilderHelper(Element.BOOLEAN(mRS));
+        testTypeBuilderHelper(Element.F64(mRS));
+        testTypeBuilderHelper(Element.I8(mRS));
+        testTypeBuilderHelper(Element.I16(mRS));
+        testTypeBuilderHelper(Element.I32(mRS));
+        testTypeBuilderHelper(Element.I64(mRS));
+        testTypeBuilderHelper(Element.U8(mRS));
+        testTypeBuilderHelper(Element.U8_4(mRS));
+        testTypeBuilderHelper(Element.U16(mRS));
+        testTypeBuilderHelper(Element.U32(mRS));
+        testTypeBuilderHelper(Element.U64(mRS));
+        testTypeBuilderHelper(Element.MATRIX_2X2(mRS));
+        testTypeBuilderHelper(Element.MATRIX_3X3(mRS));
+        testTypeBuilderHelper(Element.MATRIX_4X4(mRS));
+        testTypeBuilderHelper(Element.MESH(mRS));
+        testTypeBuilderHelper(Element.PROGRAM_FRAGMENT(mRS));
+        testTypeBuilderHelper(Element.PROGRAM_RASTER(mRS));
+        testTypeBuilderHelper(Element.PROGRAM_STORE(mRS));
+        testTypeBuilderHelper(Element.PROGRAM_VERTEX(mRS));
+        testTypeBuilderHelper(Element.ALLOCATION(mRS));
+        testTypeBuilderHelper(Element.SAMPLER(mRS));
+        testTypeBuilderHelper(Element.SCRIPT(mRS));
+        testTypeBuilderHelper(Element.TYPE(mRS));
+
+        // Add some complex and struct types to test here
+    }
+
+    public void testGetCount() {
+        Type.Builder b = new Type.Builder(mRS, Element.F32(mRS));
+        for (int faces = 0; faces <= 1; faces++) {
+            boolean useFaces = faces == 1;
+            int faceMultiplier = useFaces ? 6 : 1;
+            for (int x = 1; x < 8; x ++) {
+                for (int y = 1; y < 8; y ++) {
+                    b.setFaces(useFaces);
+                    b.setX(x).setY(y);
+                    Type t = b.create();
+                    assertTrue(t.getCount() == x * y * faceMultiplier);
+                }
+            }
+        }
+
+        // Test mipmaps
+        b.setFaces(false);
+        b.setMipmaps(true);
+        Type t = b.setX(8).setY(1).create();
+        int expectedCount = 8 + 4 + 2 + 1;
+        assertTrue(t.getCount() == expectedCount);
+
+        t = b.setX(8).setY(8).create();
+        expectedCount = 8*8 + 4*4 + 2*2 + 1;
+        assertTrue(t.getCount() == expectedCount);
+
+        t = b.setX(8).setY(4).create();
+        expectedCount = 8*4 + 4*2 + 2*1 + 1;
+        assertTrue(t.getCount() == expectedCount);
+
+        t = b.setX(4).setY(8).create();
+        assertTrue(t.getCount() == expectedCount);
+
+        t = b.setX(7).setY(1).create();
+        expectedCount = 7 + 3 + 1;
+        assertTrue(t.getCount() == expectedCount);
+
+        t = b.setX(7).setY(3).create();
+        expectedCount = 7*3 + 3*1 + 1;
+        assertTrue(t.getCount() == expectedCount);
+    }
+
+    public void testGetElement() {
+        Type.Builder b = new Type.Builder(mRS, Element.F32(mRS));
+        b.setX(1);
+        assertTrue(b.create().getElement() == Element.F32(mRS));
+    }
+
+    public void testGetX() {
+        Type.Builder b = new Type.Builder(mRS, Element.F32(mRS));
+        b.setX(3);
+        assertTrue(b.create().getX() == 3);
+    }
+
+    public void testGetY() {
+        Type.Builder b = new Type.Builder(mRS, Element.F32(mRS));
+        b.setX(3).setY(4);
+        Type t = b.create();
+        assertTrue(t.getX() == 3);
+        assertTrue(t.getY() == 4);
+    }
+
+    public void testGetZ() {
+        Type.Builder b = new Type.Builder(mRS, Element.F32(mRS));
+        b.setX(3).setY(4);
+        assertTrue(b.create().getZ() == 0);
+    }
+
+    public void testHasFaces() {
+        Type.Builder b = new Type.Builder(mRS, Element.F32(mRS));
+        b.setX(4).setY(4).setFaces(true);
+        assertTrue(b.create().hasFaces());
+        b.setFaces(false);
+        assertFalse(b.create().hasFaces());
+    }
+
+    public void testGetMipmaps() {
+        Type.Builder b = new Type.Builder(mRS, Element.F32(mRS));
+        b.setX(4).setY(4).setMipmaps(true);
+        assertTrue(b.create().hasMipmaps());
+        b.setMipmaps(false);
+        assertFalse(b.create().hasMipmaps());
+    }
+
+    public void testTypeCubemapFace() {
+        assertEquals(Type.CubemapFace.NEGATIVE_X, Type.CubemapFace.valueOf("NEGATIVE_X"));
+        assertEquals(Type.CubemapFace.NEGATIVE_Y, Type.CubemapFace.valueOf("NEGATIVE_Y"));
+        assertEquals(Type.CubemapFace.NEGATIVE_Z, Type.CubemapFace.valueOf("NEGATIVE_Z"));
+        assertEquals(Type.CubemapFace.POSITVE_X, Type.CubemapFace.valueOf("POSITVE_X"));
+        assertEquals(Type.CubemapFace.POSITVE_Y, Type.CubemapFace.valueOf("POSITVE_Y"));
+        assertEquals(Type.CubemapFace.POSITVE_Z, Type.CubemapFace.valueOf("POSITVE_Z"));
+        // Make sure no new enums are added
+        assertEquals(6, Type.CubemapFace.values().length);
+    }
+}
+
+
diff --git a/tests/tests/text/src/android/text/format/cts/DateFormatTest.java b/tests/tests/text/src/android/text/format/cts/DateFormatTest.java
index 37b337f..f24117e 100644
--- a/tests/tests/text/src/android/text/format/cts/DateFormatTest.java
+++ b/tests/tests/text/src/android/text/format/cts/DateFormatTest.java
@@ -32,6 +32,7 @@
 import java.util.Date;
 import java.util.GregorianCalendar;
 import java.util.Locale;
+import java.util.TimeZone;
 
 @TestTargetClass(DateFormat.class)
 public class DateFormatTest extends AndroidTestCase {
@@ -174,4 +175,29 @@
         actual = DateFormat.format(format, formatDate.getTime());
         assertEquals(expectedString, actual.toString());
     }
+
+    @TestTargetNew(level = TestLevel.ADDITIONAL)
+    public void test2038() {
+        Calendar calendar = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
+
+        calendar.setTimeInMillis(((long) Integer.MIN_VALUE + Integer.MIN_VALUE) * 1000L);
+        assertEquals("Sun Nov 24 17:31:44 GMT+00:00 1833",
+                DateFormat.format("EEE MMM dd kk:mm:ss zzz yyyy", calendar));
+
+        calendar.setTimeInMillis(Integer.MIN_VALUE * 1000L);
+        assertEquals("Fri Dec 13 20:45:52 GMT+00:00 1901",
+                DateFormat.format("EEE MMM dd kk:mm:ss zzz yyyy", calendar));
+
+        calendar.setTimeInMillis(0L);
+        assertEquals("Thu Jan 01 00:00:00 GMT+00:00 1970",
+                DateFormat.format("EEE MMM dd kk:mm:ss zzz yyyy", calendar));
+
+        calendar.setTimeInMillis(Integer.MAX_VALUE * 1000L);
+        assertEquals("Tue Jan 19 03:14:07 GMT+00:00 2038",
+                DateFormat.format("EEE MMM dd kk:mm:ss zzz yyyy", calendar));
+
+        calendar.setTimeInMillis((2L + Integer.MAX_VALUE + Integer.MAX_VALUE) * 1000L);
+        assertEquals("Sun Feb 07 06:28:16 GMT+00:00 2106",
+                DateFormat.format("EEE MMM dd kk:mm:ss zzz yyyy", calendar));
+    }
 }
diff --git a/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java b/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java
index 6d034b9..9e773cb 100644
--- a/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java
+++ b/tests/tests/text/src/android/text/format/cts/DateUtilsTest.java
@@ -16,17 +16,17 @@
 
 package android.text.format.cts;
 
+import android.content.Context;
+import android.test.AndroidTestCase;
+import android.text.format.DateUtils;
+import dalvik.annotation.KnownFailure;
 import dalvik.annotation.TestLevel;
 import dalvik.annotation.TestTargetClass;
 import dalvik.annotation.TestTargetNew;
 import dalvik.annotation.TestTargets;
-
-import android.content.Context;
-import android.test.AndroidTestCase;
-import android.text.format.DateUtils;
-
 import java.util.Calendar;
 import java.util.Date;
+import java.util.Formatter;
 import java.util.Locale;
 
 @TestTargetClass(DateUtils.class)
@@ -302,4 +302,32 @@
         assertTrue(DateUtils.isToday(mBaseTime));
         assertFalse(DateUtils.isToday(mBaseTime - DAY_DURATION));
     }
+
+    /**
+     * DateUtils is broken beyond Integer.MAX_VALUE seconds of 1970.
+     * http://code.google.com/p/android/issues/detail?id=13050
+     */
+    @TestTargetNew(level = TestLevel.ADDITIONAL)
+    @KnownFailure("http://b/2519073")
+    public void test2038() {
+        assertEquals("00:00, Thursday, January 1, 1970", formatFull(0L));
+
+        // these tests all fail in Honeycomb
+        assertEquals("17:31, Sunday, November 24, 1833",
+                formatFull(((long) Integer.MIN_VALUE + Integer.MIN_VALUE) * 1000L));
+        assertEquals("20:45, Friday, December 13, 1901", formatFull(Integer.MIN_VALUE * 1000L));
+        assertEquals("03:14, Tuesday, January 19, 2038", formatFull(Integer.MAX_VALUE * 1000L));
+        assertEquals("06:28, Sunday, February 7, 2106",
+                formatFull((2L + Integer.MAX_VALUE + Integer.MAX_VALUE) * 1000L));
+    }
+
+    private String formatFull(long millis) {
+        Formatter formatter = new Formatter();
+        int flags = DateUtils.FORMAT_SHOW_DATE
+                | DateUtils.FORMAT_SHOW_WEEKDAY
+                | DateUtils.FORMAT_SHOW_TIME
+                | DateUtils.FORMAT_24HOUR;
+        DateUtils.formatDateRange(null, formatter, millis, millis, flags, "UTC");
+        return formatter.toString();
+    }
 }
diff --git a/tests/tests/text/src/android/text/method/cts/PasswordTransformationMethodTest.java b/tests/tests/text/src/android/text/method/cts/PasswordTransformationMethodTest.java
index b751b32..6dde08d 100755
--- a/tests/tests/text/src/android/text/method/cts/PasswordTransformationMethodTest.java
+++ b/tests/tests/text/src/android/text/method/cts/PasswordTransformationMethodTest.java
@@ -147,8 +147,7 @@
 
         mMethod.reset();
         // 12-key support
-        KeyCharacterMap keymap
-                = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);
+        KeyCharacterMap keymap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);
         if (keymap.getKeyboardType() == KeyCharacterMap.NUMERIC) {
             // "HELLO" in case of 12-key(NUMERIC) keyboard
             sendKeys("6*4 6*3 7*5 DPAD_RIGHT 7*5 7*6 DPAD_RIGHT");
diff --git a/tests/tests/text/src/android/text/method/cts/TextKeyListenerTest.java b/tests/tests/text/src/android/text/method/cts/TextKeyListenerTest.java
index 1d239f7..932e5c0 100644
--- a/tests/tests/text/src/android/text/method/cts/TextKeyListenerTest.java
+++ b/tests/tests/text/src/android/text/method/cts/TextKeyListenerTest.java
@@ -244,11 +244,6 @@
         }
     }
 
-    private int getKeyboardType() {
-        KeyCharacterMap kmap = KeyCharacterMap.load(KeyCharacterMap.BUILT_IN_KEYBOARD);
-        return kmap.getKeyboardType();
-    }
-
     /**
      * Check point:
      * 1. press KEYCODE_4 once. if it's ALPHA key board, text will be "4", if it's
@@ -274,7 +269,6 @@
     public void testPressKey() {
         final TextKeyListener textKeyListener
                 = TextKeyListener.getInstance(false, Capitalize.NONE);
-        int keyType = getKeyboardType();
 
         mActivity.runOnUiThread(new Runnable() {
             public void run() {
@@ -290,7 +284,9 @@
         sendKeys(KeyEvent.KEYCODE_4);
         waitForListenerTimeout();
         String text = mTextView.getText().toString();
-        if (KeyCharacterMap.ALPHA == keyType) {
+        int keyType = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD).getKeyboardType();
+        if (KeyCharacterMap.ALPHA == keyType
+                || KeyCharacterMap.FULL == keyType) {
             assertEquals("4", text);
         } else if (KeyCharacterMap.NUMERIC == keyType) {
             assertEquals("g", text);
diff --git a/tests/tests/view/src/android/view/cts/ViewTest.java b/tests/tests/view/src/android/view/cts/ViewTest.java
index 6b5c0a1..c5f0104 100644
--- a/tests/tests/view/src/android/view/cts/ViewTest.java
+++ b/tests/tests/view/src/android/view/cts/ViewTest.java
@@ -39,6 +39,7 @@
 import android.graphics.drawable.StateListDrawable;
 import android.os.Parcelable;
 import android.os.SystemClock;
+import android.provider.Settings;
 import android.test.ActivityInstrumentationTestCase2;
 import android.test.TouchUtils;
 import android.test.UiThreadTest;
@@ -2436,12 +2437,12 @@
 
         View mockView = mActivity.findViewById(R.id.mock_view);
         mockView.getLocationOnScreen(location);
-        assertEquals(0, location[0]);
+        assertEquals(layoutLocation[0], location[0]);
         assertEquals(layoutLocation[1], location[1]);
 
         View scrollView = mActivity.findViewById(R.id.scroll_view);
         scrollView.getLocationOnScreen(location);
-        assertEquals(0, location[0]);
+        assertEquals(layoutLocation[0], location[0]);
         assertEquals(layoutLocation[1] + mockView.getHeight(), location[1]);
 
         try {
@@ -4377,6 +4378,9 @@
         )
     })
     public void testHapticFeedback() {
+        // Expect true to be returned for a haptic feedback only if haptics are enabled.
+        boolean expectedHapticsReturnValue = Settings.System.getInt(mActivity.getContentResolver(),
+                Settings.System.HAPTIC_FEEDBACK_ENABLED, 0) != 0;
         final MockView view = (MockView) mActivity.findViewById(R.id.mock_view);
         final int LONG_PRESS = HapticFeedbackConstants.LONG_PRESS;
         final int FLAG_IGNORE_VIEW_SETTING = HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING;
@@ -4387,11 +4391,12 @@
         assertFalse(view.isHapticFeedbackEnabled());
         assertFalse(view.performHapticFeedback(LONG_PRESS));
         assertFalse(view.performHapticFeedback(LONG_PRESS, FLAG_IGNORE_GLOBAL_SETTING));
-        assertTrue(view.performHapticFeedback(LONG_PRESS, ALWAYS));
+        assertEquals(expectedHapticsReturnValue, view.performHapticFeedback(LONG_PRESS, ALWAYS));
 
         view.setHapticFeedbackEnabled(true);
         assertTrue(view.isHapticFeedbackEnabled());
-        assertTrue(view.performHapticFeedback(LONG_PRESS, FLAG_IGNORE_GLOBAL_SETTING));
+        assertEquals(expectedHapticsReturnValue, view.performHapticFeedback(
+                LONG_PRESS, FLAG_IGNORE_GLOBAL_SETTING));
     }
 
     @TestTargets({
diff --git a/tests/tests/view/src/android/view/cts/View_UsingViewsTest.java b/tests/tests/view/src/android/view/cts/View_UsingViewsTest.java
index 7bdcfd2..3bc500c 100644
--- a/tests/tests/view/src/android/view/cts/View_UsingViewsTest.java
+++ b/tests/tests/view/src/android/view/cts/View_UsingViewsTest.java
@@ -469,6 +469,8 @@
     })
     @UiThreadTest
     public void testSetFocus() throws Throwable {
+        boolean focusWasOnEditText = mEditText.hasFocus();
+
         MockOnFocusChangeListener editListener = new MockOnFocusChangeListener();
         MockOnFocusChangeListener okListener = new MockOnFocusChangeListener();
         MockOnFocusChangeListener cancelListener = new MockOnFocusChangeListener();
@@ -491,7 +493,7 @@
         assertFalse(mSymbolTextView.hasFocus());
         assertFalse(mWarningTextView.hasFocus());
 
-        assertTrue(editListener.hasFocus());
+        assertTrue(editListener.hasFocus() || focusWasOnEditText);
         assertFalse(okListener.hasFocus());
         assertFalse(cancelListener.hasFocus());
         assertFalse(symbolListener.hasFocus());
diff --git a/tests/tests/view/src/android/view/cts/WindowTest.java b/tests/tests/view/src/android/view/cts/WindowTest.java
index f7cdbac..a3e0237 100755
--- a/tests/tests/view/src/android/view/cts/WindowTest.java
+++ b/tests/tests/view/src/android/view/cts/WindowTest.java
@@ -381,7 +381,8 @@
         int screenWidth = dm.widthPixels;
         int screenHeight = dm.heightPixels;
         assertEquals(screenWidth, decor.getWidth());
-        assertTrue(screenHeight > decor.getHeight());
+        assertTrue("Screen height: " + screenHeight + " Decor view height: " + decor.getHeight(),
+                screenHeight >= decor.getHeight());
         assertSame(mWindow.getContext(), decor.getContext());
     }
 
@@ -1122,6 +1123,10 @@
             return true;
         }
 
+        public boolean superDispatchGenericMotionEvent(MotionEvent event) {
+            return true;
+        }
+
         public View getDecorView() {
             return null;
         }
@@ -1200,6 +1205,10 @@
             return true;
         }
 
+        public boolean dispatchGenericMotionEvent(MotionEvent event) {
+            return true;
+        }
+
         public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
             return true;
         }
diff --git a/tests/tests/view/src/android/view/inputmethod/cts/BaseInputConnectionTest.java b/tests/tests/view/src/android/view/inputmethod/cts/BaseInputConnectionTest.java
index 415b308..2cf6b58 100755
--- a/tests/tests/view/src/android/view/inputmethod/cts/BaseInputConnectionTest.java
+++ b/tests/tests/view/src/android/view/inputmethod/cts/BaseInputConnectionTest.java
@@ -349,8 +349,7 @@
         });
 
         // 12-key support
-        KeyCharacterMap keymap
-                = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);
+        KeyCharacterMap keymap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);
         if (keymap.getKeyboardType() == KeyCharacterMap.NUMERIC) {
             // 'Q' in case of 12-key(NUMERIC) keyboard
             mConnection.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_7));
diff --git a/tests/tests/webkit/src/android/webkit/cts/CookieSyncManagerTest.java b/tests/tests/webkit/src/android/webkit/cts/CookieSyncManagerTest.java
index ef4d0dc..3b7d340 100644
--- a/tests/tests/webkit/src/android/webkit/cts/CookieSyncManagerTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/CookieSyncManagerTest.java
@@ -62,6 +62,7 @@
         assertSame(csm1, csm2);
 
         final CookieManager cookieManager = CookieManager.getInstance();
+        cookieManager.setAcceptFileSchemeCookies(true);
 
         // Remove all cookies from the database.
         cookieManager.removeAllCookie();
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java b/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
index 69093d2..639f795 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
@@ -244,7 +244,6 @@
             args = {boolean.class}
         )
     })
-    @ToBeFixed(explanation = "Implementation does not work as expected.")
     public void testAccessBlockNetworkImage() throws Exception {
         String url = TestHtmlConstants.EMBEDDED_IMG_URL;
         final String ext = MimeTypeMap.getFileExtensionFromUrl(url);
@@ -260,13 +259,11 @@
             }
         }.run();
 
-        /* ToBeFixed: Uncomment after fixing the framework
         mWebView.clearCache(true);
         mSettings.setBlockNetworkImage(true);
         assertTrue(mSettings.getBlockNetworkImage());
-        loadUrl(url);
+        loadAssetUrl(url);
         assertTrue(mWebServer.getLastRequestUrl().endsWith(ext));
-        */
     }
 
     @TestTargets({
@@ -1018,7 +1015,7 @@
         loadUrl(url);
         new DelayedCheck(10000) {
             protected boolean check() {
-                return mWebView.getTitle().equals("Done");
+                return mWebView.getTitle() != null && mWebView.getTitle().equals("Done");
             }
         }.run();
 
@@ -1026,7 +1023,7 @@
         loadUrl(url);
         new DelayedCheck(10000) {
             protected boolean check() {
-                return mWebView.getTitle().equals("Done");
+                return mWebView.getTitle() != null && mWebView.getTitle().equals("Done");
             }
         }.run();
     }
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
index 335ab4e..94fe857 100755
--- a/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebViewTest.java
@@ -32,12 +32,14 @@
 import android.graphics.Picture;
 import android.graphics.Rect;
 import android.graphics.Bitmap.Config;
+import android.net.Uri;
 import android.net.http.SslCertificate;
 import android.net.http.SslError;
 import android.os.Bundle;
 import android.os.Handler;
 import android.os.Looper;
 import android.os.Message;
+import android.os.SystemClock;
 import android.test.ActivityInstrumentationTestCase2;
 import android.test.UiThreadTest;
 import android.util.AttributeSet;
@@ -603,12 +605,12 @@
                     "</head><body onload=\"updateTitle();\"></body></html>";
 
             mWebView.addJavascriptInterface(obj, name);
-            mWebView.loadData(setTitleToPropertyTypeHtml, "text/html", "UTF-8");
+            mWebView.loadData(Uri.encode(setTitleToPropertyTypeHtml), "text/html", "UTF-8");
             waitForLoadComplete(mWebView, TEST_TIMEOUT);
             assertEquals("object", mWebView.getTitle());
 
             mWebView.removeJavascriptInterface(name);
-            mWebView.loadData(setTitleToPropertyTypeHtml, "text/html", "UTF-8");
+            mWebView.loadData(Uri.encode(setTitleToPropertyTypeHtml), "text/html", "UTF-8");
             waitForLoadComplete(mWebView, TEST_TIMEOUT);
             assertEquals("undefined", mWebView.getTitle());
         }
@@ -1404,8 +1406,9 @@
         handler.reset();
         int[] location = new int[2];
         mWebView.getLocationOnScreen(location);
+        long time = SystemClock.uptimeMillis();
         getInstrumentation().sendPointerSync(
-                MotionEvent.obtain(0, 0, MotionEvent.ACTION_DOWN,
+                MotionEvent.obtain(time, time, MotionEvent.ACTION_DOWN,
                         location[0] + imgWidth / 2,
                         location[1] + imgHeight / 2, 0));
         mWebView.requestImageRef(msg);
diff --git a/tests/tests/widget/src/android/widget/cts/AutoCompleteTextViewTest.java b/tests/tests/widget/src/android/widget/cts/AutoCompleteTextViewTest.java
index 0f17552..76bf39b 100755
--- a/tests/tests/widget/src/android/widget/cts/AutoCompleteTextViewTest.java
+++ b/tests/tests/widget/src/android/widget/cts/AutoCompleteTextViewTest.java
@@ -97,8 +97,7 @@
                 .findViewById(R.id.autocompletetv_edit);
         mAdapter = new ArrayAdapter<String>(mActivity,
                 android.R.layout.simple_dropdown_item_1line, WORDS);
-        KeyCharacterMap keymap
-                = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);
+        KeyCharacterMap keymap = KeyCharacterMap.load(KeyCharacterMap.VIRTUAL_KEYBOARD);
         if (keymap.getKeyboardType() == KeyCharacterMap.NUMERIC) {
             mNumeric = true;
         }
@@ -513,6 +512,7 @@
         } else {
             testString = "tes";
         }
+
         // Test the filter if the input string is not long enough to threshold
         runTestOnUiThread(new Runnable() {
             public void run() {
diff --git a/tools/dx-tests/Android.mk b/tools/dx-tests/Android.mk
index 9bdef58..d249cea 100644
--- a/tools/dx-tests/Android.mk
+++ b/tools/dx-tests/Android.mk
@@ -38,7 +38,7 @@
 	@echo "Copy: $(PRIVATE_MODULE) ($@)"
 	$(copy-file-to-new-target)
 	$(hide) chmod 755 $@
-	@$(PRIVATE_CURRENT_MODULE_SCRIPT) "$(PRIVATE_BASE)" "$(HOST_JAVAC)" "$(PRIVATE_INTERMEDIATES)" "$(HOST_OUT_JAVA_LIBRARIES)/dx.jar:$(HOST_OUT_JAVA_LIBRARIES)/cfassembler.jar" "$(HOST_OUT)"
+	$(hide) PATH=$(HOST_OUT_EXECUTABLES):$$PATH $(PRIVATE_CURRENT_MODULE_SCRIPT) "$(PRIVATE_BASE)" "$(HOST_JAVAC)" "$(PRIVATE_INTERMEDIATES)" "$(HOST_OUT_JAVA_LIBRARIES)/dx.jar:$(HOST_OUT_JAVA_LIBRARIES)/cfassembler.jar" "$(HOST_OUT)"
 
 # cfassembler host module
 #============================================================
diff --git a/tools/host/src/com/android/cts/Version.java b/tools/host/src/com/android/cts/Version.java
index 022ac2b..e2280d6 100644
--- a/tools/host/src/com/android/cts/Version.java
+++ b/tools/host/src/com/android/cts/Version.java
@@ -18,7 +18,7 @@
 
 public class Version {
     // The CTS version string
-    private static final String version = "3.0_r4";
+    private static final String version = "3.1_r5";
 
     private Version() {
         // no instances allowed
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java b/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java
index 6bcab73..1c90d83 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/result/CtsXmlResultReporter.java
@@ -25,6 +25,7 @@
 import com.android.tradefed.build.IFolderBuildInfo;
 import com.android.tradefed.config.Option;
 import com.android.tradefed.result.CollectingTestListener;
+import com.android.tradefed.result.InputStreamSource;
 import com.android.tradefed.result.LogDataType;
 import com.android.tradefed.result.TestResult;
 import com.android.tradefed.result.TestRunResult;
@@ -116,7 +117,7 @@
      * {@inheritDoc}
      */
     @Override
-    public void testLog(String dataName, LogDataType dataType, InputStream dataStream) {
+    public void testLog(String dataName, LogDataType dataType, InputStreamSource dataStream) {
         // save as zip file in report dir
         // TODO: ensure uniqueness of file name
         // TODO: use dataType.getFileExt() when its made public
@@ -124,7 +125,7 @@
         // TODO: consider compressing large files
         File logFile = new File(mReportDir, fileName);
         try {
-            FileUtil.writeToFile(dataStream, logFile);
+            FileUtil.writeToFile(dataStream.createInputStream(), logFile);
         } catch (IOException e) {
             Log.e(LOG_TAG, String.format("Failed to write log %s", logFile.getAbsolutePath()));
         }
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
index 6ed55d3..2834793 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/CtsTest.java
@@ -32,6 +32,7 @@
 import com.android.tradefed.testtype.IRemoteTest;
 import com.android.tradefed.testtype.IResumableTest;
 import com.android.tradefed.testtype.IShardableTest;
+import com.android.tradefed.testtype.InstrumentationTest;
 import com.android.tradefed.util.xml.AbstractXmlParser.ParseException;
 
 import java.io.BufferedInputStream;
@@ -248,6 +249,12 @@
             if (test instanceof IDeviceTest) {
                 ((IDeviceTest)test).setDevice(getDevice());
             }
+            // Increment the timeout for collecting the tests.
+            // TODO: move this to testPackage.createTest() instead and only increase timeout when
+            // tests number is large.
+            if (test instanceof InstrumentationTest) {
+                ((InstrumentationTest)test).setCollectsTestsShellTimeout(10*60*1000);
+            }
             ResultFilter filter = new ResultFilter(listener, testPair.getKnownTests());
             test.run(filter);
             mRemainingTests.remove(0);