BasicRenderScript sample, initial check in
Now sample template compatible, in KLP-DEV branch.
Change-Id: Id3f31f9d56a908098aa9a76bef6f944416bff6fe
diff --git a/renderScript/BasicRenderScript/BasicRenderScriptSample/.gitignore b/renderScript/BasicRenderScript/BasicRenderScriptSample/.gitignore
new file mode 100644
index 0000000..6eb878d
--- /dev/null
+++ b/renderScript/BasicRenderScript/BasicRenderScriptSample/.gitignore
@@ -0,0 +1,16 @@
+# Copyright 2013 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.
+src/template/
+src/common/
+build.gradle
diff --git a/renderScript/BasicRenderScript/BasicRenderScriptSample/AndroidManifest.xml b/renderScript/BasicRenderScript/BasicRenderScriptSample/AndroidManifest.xml
new file mode 100644
index 0000000..1e35dc3
--- /dev/null
+++ b/renderScript/BasicRenderScript/BasicRenderScriptSample/AndroidManifest.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.android.basicrenderscript"
+ android:versionCode="1"
+ android:versionName="1.0" >
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="19" />
+
+ <application
+ android:allowBackup="true"
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:theme="@style/AppTheme" >
+ <activity
+ android:name="com.example.android.basicrenderscript.MainActivity"
+ android:configChanges="orientation|keyboardHidden|screenSize"
+ android:label="@string/app_name"
+ android:theme="@style/FullscreenTheme" >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+</manifest>
diff --git a/renderScript/BasicRenderScript/BasicRenderScriptSample/build.gradle b/renderScript/BasicRenderScript/BasicRenderScriptSample/build.gradle
new file mode 100644
index 0000000..a9df66d
--- /dev/null
+++ b/renderScript/BasicRenderScript/BasicRenderScriptSample/build.gradle
@@ -0,0 +1,67 @@
+
+
+
+buildscript {
+ repositories {
+ mavenCentral()
+ }
+
+ dependencies {
+ classpath 'com.android.tools.build:gradle:0.8.+'
+ }
+}
+
+apply plugin: 'android'
+
+dependencies {
+ // Add the support lib that is appropriate for SDK 8
+ compile "com.android.support:support-v4:19.0.+"
+ compile "com.android.support:gridlayout-v7:19.0.+"
+ compile files('renderscript-v8.jar')
+}
+
+// The sample build uses multiple directories to
+// keep boilerplate and common code separate from
+// the main sample code.
+List<String> dirs = [
+ 'main', // main sample code; look here for the interesting stuff.
+ 'common', // components that are reused by multiple samples
+ 'template'] // boilerplate code that is generated by the sample template process
+
+android {
+ compileSdkVersion 19
+ buildToolsVersion "19.0.1"
+
+ sourceSets {
+ main {
+ dirs.each { dir ->
+ java.srcDirs "src/${dir}/java"
+ res.srcDirs "src/${dir}/res"
+ }
+ }
+ instrumentTest.setRoot('tests')
+ instrumentTest.java.srcDirs = ['tests/src']
+
+ defaultConfig {
+
+ renderscriptTargetApi 18
+ renderscriptSupportMode true
+
+ }
+ }
+}
+// BEGIN_EXCLUDE
+// Tasks below this line will be hidden from release output
+
+task preflight (dependsOn: parent.preflight) {
+ project.afterEvaluate {
+ // Inject a preflight task into each variant so we have a place to hook tasks
+ // that need to run before any of the android build tasks.
+ //
+ android.applicationVariants.each { variant ->
+ tasks.getByPath("prepare${variant.name.capitalize()}Dependencies").dependsOn preflight
+ }
+ }
+}
+
+// END_EXCLUDE
diff --git a/renderScript/BasicRenderScript/BasicRenderScriptSample/project.properties b/renderScript/BasicRenderScript/BasicRenderScriptSample/project.properties
new file mode 100644
index 0000000..aa550f1
--- /dev/null
+++ b/renderScript/BasicRenderScript/BasicRenderScriptSample/project.properties
@@ -0,0 +1,15 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-19
+renderscript.support.mode=true
\ No newline at end of file
diff --git a/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/AndroidManifest.xml b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..e1e2dfc
--- /dev/null
+++ b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/AndroidManifest.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?><!--
+ Copyright 2014 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.example.android.basicrenderscript"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="19" />
+
+ <application
+ android:allowBackup="true"
+ android:label="@string/app_name"
+ android:icon="@drawable/ic_launcher"
+ android:theme="@style/AppTheme">
+
+ <activity
+ android:name=".MainActivity"
+ android:label="@string/app_name"
+ android:theme="@style/FullscreenTheme">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ </application>
+
+
+</manifest>
diff --git a/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/java/com/example/android/basicrenderscript/MainActivity.java b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/java/com/example/android/basicrenderscript/MainActivity.java
new file mode 100644
index 0000000..ed6d5ad
--- /dev/null
+++ b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/java/com/example/android/basicrenderscript/MainActivity.java
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2014 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.example.android.basicrenderscript;
+
+import android.app.Activity;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.os.AsyncTask;
+import android.os.Bundle;
+import android.widget.ImageView;
+import android.widget.SeekBar;
+import android.widget.SeekBar.OnSeekBarChangeListener;
+import android.support.v8.renderscript.*;
+
+public class MainActivity extends Activity {
+ /* Number of bitmaps that is used for renderScript thread and UI thread synchronization.
+ Ideally, this can be reduced to 2, however in some devices, 2 buffers still showing tierings on UI.
+ Investigating a root cause.
+ */
+ private final int NUM_BITMAPS = 3;
+ private int mCurrentBitmap = 0;
+ private Bitmap mBitmapIn;
+ private Bitmap[] mBitmapsOut;
+ private ImageView mImageView;
+
+ private RenderScript mRS;
+ private Allocation mInAllocation;
+ private Allocation[] mOutAllocations;
+ private ScriptC_saturation mScript;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.main_layout);
+
+ /*
+ * Initialize UI
+ */
+ mBitmapIn = loadBitmap(R.drawable.data);
+ mBitmapsOut = new Bitmap[NUM_BITMAPS];
+ for (int i = 0; i < NUM_BITMAPS; ++i) {
+ mBitmapsOut[i] = Bitmap.createBitmap(mBitmapIn.getWidth(),
+ mBitmapIn.getHeight(), mBitmapIn.getConfig());
+ }
+
+ mImageView = (ImageView) findViewById(R.id.imageView);
+ mImageView.setImageBitmap(mBitmapsOut[mCurrentBitmap]);
+ mCurrentBitmap += (mCurrentBitmap + 1) % NUM_BITMAPS;
+
+ SeekBar seekbar = (SeekBar) findViewById(R.id.seekBar1);
+ seekbar.setProgress(50);
+ seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
+ public void onProgressChanged(SeekBar seekBar, int progress,
+ boolean fromUser) {
+ float max = 2.0f;
+ float min = 0.0f;
+ float f = (float) ((max - min) * (progress / 100.0) + min);
+ updateImage(f);
+ }
+
+ @Override
+ public void onStartTrackingTouch(SeekBar seekBar) {
+ }
+
+ @Override
+ public void onStopTrackingTouch(SeekBar seekBar) {
+ }
+ });
+
+ /*
+ * Create renderScript
+ */
+ createScript();
+
+ /*
+ * Invoke renderScript kernel and update imageView
+ */
+ updateImage(1.0f);
+ }
+
+ /*
+ * Initialize RenderScript
+ * In the sample, it creates RenderScript kernel that performs saturation manipulation.
+ */
+ private void createScript() {
+ //Initialize RS
+ mRS = RenderScript.create(this);
+
+ //Allocate buffers
+ mInAllocation = Allocation.createFromBitmap(mRS, mBitmapIn);
+ mOutAllocations = new Allocation[NUM_BITMAPS];
+ for (int i = 0; i < NUM_BITMAPS; ++i) {
+ mOutAllocations[i] = Allocation.createFromBitmap(mRS, mBitmapsOut[i]);
+ }
+
+ //Load script
+ mScript = new ScriptC_saturation(mRS);
+ }
+
+ /*
+ * In the AsyncTask, it invokes RenderScript intrinsics to do a filtering.
+ * After the filtering is done, an operation blocks at Allication.copyTo() in AsyncTask thread.
+ * Once all operation is finished at onPostExecute() in UI thread, it can invalidate and update ImageView UI.
+ */
+ private class RenderScriptTask extends AsyncTask<Float, Integer, Integer> {
+ Boolean issued = false;
+
+ protected Integer doInBackground(Float... values) {
+ int index = -1;
+ if (isCancelled() == false) {
+ issued = true;
+ index = mCurrentBitmap;
+
+ /*
+ * Set global variable in RS
+ */
+ mScript.set_saturationValue(values[0]);
+
+ /*
+ * Invoke saturation filter kernel
+ */
+ mScript.forEach_saturation(mInAllocation, mOutAllocations[index]);
+
+ /*
+ * Copy to bitmap and invalidate image view
+ */
+ mOutAllocations[index].copyTo(mBitmapsOut[index]);
+ mCurrentBitmap = (mCurrentBitmap + 1) % NUM_BITMAPS;
+ }
+ return index;
+ }
+
+ void updateView(Integer result) {
+ if (result != -1) {
+ // Request UI update
+ mImageView.setImageBitmap(mBitmapsOut[result]);
+ mImageView.invalidate();
+ }
+ }
+
+ protected void onPostExecute(Integer result) {
+ updateView(result);
+ }
+
+ protected void onCancelled(Integer result) {
+ if (issued) {
+ updateView(result);
+ }
+ }
+ }
+
+ RenderScriptTask currentTask = null;
+
+ /*
+ Invoke AsynchTask and cancel previous task.
+ When AsyncTasks are piled up (typically in slow device with heavy kernel),
+ Only the latest (and already started) task invokes RenderScript operation.
+ */
+ private void updateImage(final float f) {
+ if (currentTask != null)
+ currentTask.cancel(false);
+ currentTask = new RenderScriptTask();
+ currentTask.execute(f);
+ }
+
+ /*
+ Helper to load Bitmap from resource
+ */
+ private Bitmap loadBitmap(int resource) {
+ final BitmapFactory.Options options = new BitmapFactory.Options();
+ options.inPreferredConfig = Bitmap.Config.ARGB_8888;
+ return BitmapFactory.decodeResource(getResources(), resource, options);
+ }
+
+}
diff --git a/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/drawable-hdpi/ic_launcher.png b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/drawable-hdpi/ic_launcher.png
new file mode 100755
index 0000000..75b3c97
--- /dev/null
+++ b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/drawable-mdpi/ic_launcher.png b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/drawable-mdpi/ic_launcher.png
new file mode 100755
index 0000000..4ccd98e
--- /dev/null
+++ b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/drawable-nodpi/data.jpg b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/drawable-nodpi/data.jpg
new file mode 100644
index 0000000..81a87b1
--- /dev/null
+++ b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/drawable-nodpi/data.jpg
Binary files differ
diff --git a/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/drawable-xhdpi/ic_launcher.png b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/drawable-xhdpi/ic_launcher.png
new file mode 100755
index 0000000..7c5aeed
--- /dev/null
+++ b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/drawable-xxhdpi/ic_launcher.png b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/drawable-xxhdpi/ic_launcher.png
new file mode 100755
index 0000000..3c45f51
--- /dev/null
+++ b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/layout/main_layout.xml b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/layout/main_layout.xml
new file mode 100644
index 0000000..69695f0
--- /dev/null
+++ b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/layout/main_layout.xml
@@ -0,0 +1,22 @@
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:background="#0099cc"
+ tools:context=".MainActivity">
+
+ <ImageView
+ android:id="@+id/imageView"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:scaleType="fitCenter"
+ android:src="@drawable/data" />
+
+ <SeekBar
+ android:id="@+id/seekBar1"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_gravity="bottom"
+ android:layout_marginBottom="16dp" />
+
+</FrameLayout>
diff --git a/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/values-v11/styles.xml b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/values-v11/styles.xml
new file mode 100644
index 0000000..f3a90c6
--- /dev/null
+++ b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/values-v11/styles.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+ <!--
+ Base application theme for API 11+. This theme completely replaces
+ AppBaseTheme from res/values/styles.xml on API 11+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light">
+ <!-- API 11 theme customizations can go here. -->
+ </style>
+
+ <style name="FullscreenTheme" parent="android:Theme.Holo">
+ <item name="android:actionBarStyle">@style/FullscreenActionBarStyle</item>
+ <item name="android:windowActionBarOverlay">true</item>
+ <item name="android:windowBackground">@null</item>
+ <item name="buttonBarStyle">?android:attr/buttonBarStyle</item>
+ <item name="buttonBarButtonStyle">?android:attr/buttonBarButtonStyle</item>
+ </style>
+
+ <style name="FullscreenActionBarStyle" parent="android:Widget.Holo.ActionBar">
+ <item name="android:background">@color/black_overlay</item>
+ </style>
+
+</resources>
diff --git a/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/values-v14/styles.xml b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/values-v14/styles.xml
new file mode 100644
index 0000000..a91fd03
--- /dev/null
+++ b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/values-v14/styles.xml
@@ -0,0 +1,12 @@
+<resources>
+
+ <!--
+ Base application theme for API 14+. This theme completely replaces
+ AppBaseTheme from BOTH res/values/styles.xml and
+ res/values-v11/styles.xml on API 14+ devices.
+ -->
+ <style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
+ <!-- API 14 theme customizations can go here. -->
+ </style>
+
+</resources>
diff --git a/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/values/attrs.xml b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/values/attrs.xml
new file mode 100644
index 0000000..e67df0a
--- /dev/null
+++ b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/values/attrs.xml
@@ -0,0 +1,14 @@
+<resources>
+
+ <!--
+ Declare custom theme attributes that allow changing which styles are
+ used for button bars depending on the API level.
+ ?android:attr/buttonBarStyle is new as of API 11 so this is
+ necessary to support previous API levels.
+ -->
+ <declare-styleable name="ButtonBarContainerTheme">
+ <attr name="buttonBarStyle" format="reference" />
+ <attr name="buttonBarButtonStyle" format="reference" />
+ </declare-styleable>
+
+</resources>
diff --git a/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/values/colors.xml b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/values/colors.xml
new file mode 100644
index 0000000..327c060
--- /dev/null
+++ b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/values/colors.xml
@@ -0,0 +1,5 @@
+<resources>
+
+ <color name="black_overlay">#66000000</color>
+
+</resources>
diff --git a/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/values/styles.xml b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/values/styles.xml
new file mode 100644
index 0000000..49299b9
--- /dev/null
+++ b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/res/values/styles.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<resources>
+
+
+ <style name="FullscreenTheme" parent="android:Theme.NoTitleBar">
+ <item name="android:windowContentOverlay">@null</item>
+ <item name="android:windowBackground">@null</item>
+ <item name="buttonBarStyle">@style/ButtonBar</item>
+ <item name="buttonBarButtonStyle">@style/ButtonBarButton</item>
+ </style>
+
+ <style name="ButtonBar">
+ <item name="android:paddingLeft">2dp</item>
+ <item name="android:paddingTop">5dp</item>
+ <item name="android:paddingRight">2dp</item>
+ <item name="android:paddingBottom">0dp</item>
+ <item name="android:background">@android:drawable/bottom_bar</item>
+ </style>
+
+ <style name="ButtonBarButton" />
+
+</resources>
diff --git a/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/rs/saturation.rs b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/rs/saturation.rs
new file mode 100644
index 0000000..cf043d1
--- /dev/null
+++ b/renderScript/BasicRenderScript/BasicRenderScriptSample/src/main/rs/saturation.rs
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2014 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.
+ */
+
+#pragma version(1)
+#pragma rs java_package_name(com.example.android.basicrenderscript)
+#pragma rs_fp_relaxed
+
+const static float3 gMonoMult = {0.299f, 0.587f, 0.114f};
+
+float saturationValue = 0.f;
+
+/*
+RenderScript kernel that performs saturation manipulation.
+*/
+uchar4 __attribute__((kernel)) saturation(uchar4 in)
+{
+ float4 f4 = rsUnpackColor8888(in);
+ float3 result = dot(f4.rgb, gMonoMult);
+ result = mix( result, f4.rgb, saturationValue );
+
+ return rsPackColorTo8888(result);
+}
+
diff --git a/renderScript/BasicRenderScript/BasicRenderScriptSample/tests/AndroidManifest.xml b/renderScript/BasicRenderScript/BasicRenderScriptSample/tests/AndroidManifest.xml
new file mode 100644
index 0000000..02a8db3
--- /dev/null
+++ b/renderScript/BasicRenderScript/BasicRenderScriptSample/tests/AndroidManifest.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2013 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 name must be unique so suffix with "tests" so package loader doesn't ignore us -->
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.example.android.basicrenderscript.tests"
+ android:versionCode="1"
+ android:versionName="1.0">
+
+ <uses-sdk
+ android:minSdkVersion="8"
+ android:targetSdkVersion="19" />
+
+ <!-- We add an application tag here just so that we can indicate that
+ this package needs to link against the android.test library,
+ which is needed when building test cases. -->
+ <application>
+ <uses-library android:name="android.test.runner" />
+ </application>
+
+ <!--
+ Specifies the instrumentation test runner used to run the tests.
+ -->
+ <instrumentation
+ android:name="android.test.InstrumentationTestRunner"
+ android:targetPackage="com.example.android.basicrenderscript"
+ android:label="Tests for com.example.android.basicrenderscript" />
+
+</manifest>
\ No newline at end of file
diff --git a/renderScript/BasicRenderScript/BasicRenderScriptSample/tests/src/com/example/android/basicrenderscript/tests/SampleTests.java b/renderScript/BasicRenderScript/BasicRenderScriptSample/tests/src/com/example/android/basicrenderscript/tests/SampleTests.java
new file mode 100644
index 0000000..b361507
--- /dev/null
+++ b/renderScript/BasicRenderScript/BasicRenderScriptSample/tests/src/com/example/android/basicrenderscript/tests/SampleTests.java
@@ -0,0 +1,79 @@
+/*
+* Copyright 2013 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.
+*/
+
+
+
+/*
+* Copyright (C) 2013 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.example.android.basicrenderscript.tests;
+
+import com.example.android.basicrenderscript.*;
+
+import android.test.ActivityInstrumentationTestCase2;
+
+/**
+* Tests for BasicRenderScript sample.
+*/
+public class SampleTests extends ActivityInstrumentationTestCase2<MainActivity> {
+
+ private MainActivity mTestActivity;
+ private BasicRenderScriptFragment mTestFragment;
+
+ public SampleTests() {
+ super(MainActivity.class);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // Starts the activity under test using the default Intent with:
+ // action = {@link Intent#ACTION_MAIN}
+ // flags = {@link Intent#FLAG_ACTIVITY_NEW_TASK}
+ // All other fields are null or empty.
+ mTestActivity = getActivity();
+ mTestFragment = (BasicRenderScriptFragment)
+ mTestActivity.getSupportFragmentManager().getFragments().get(1);
+ }
+
+ /**
+ * Test if the test fixture has been set up correctly.
+ */
+ public void testPreconditions() {
+ //Try to add a message to add context to your assertions. These messages will be shown if
+ //a tests fails and make it easy to understand why a test failed
+ assertNotNull("mTestActivity is null", mTestActivity);
+ assertNotNull("mTestFragment is null", mTestFragment);
+ }
+
+ /**
+ * Add more tests below.
+ */
+
+}
\ No newline at end of file