Merge "Fix cts test due to API changes." into lmp-dev
diff --git a/CtsTestCaseList.mk b/CtsTestCaseList.mk
index 615e955..cba171f 100644
--- a/CtsTestCaseList.mk
+++ b/CtsTestCaseList.mk
@@ -107,7 +107,6 @@
CtsPrintTestCases \
CtsProviderTestCases \
CtsRenderscriptTestCases \
- CtsRenderscriptGraphicsTestCases \
CtsRsCppTestCases \
CtsSaxTestCases \
CtsSecurityTestCases \
diff --git a/apps/CtsVerifier/AndroidManifest.xml b/apps/CtsVerifier/AndroidManifest.xml
index da93a59..5186ce3 100644
--- a/apps/CtsVerifier/AndroidManifest.xml
+++ b/apps/CtsVerifier/AndroidManifest.xml
@@ -732,7 +732,8 @@
android:value="android.hardware.sensor.accelerometer" />
</activity>
- <activity android:name=".sensors.SensorSynchronizationTestActivity"
+ <!-- TODO: enable test when a more reliable way to identify time synchronization is available -->
+ <!--activity android:name=".sensors.SensorSynchronizationTestActivity"
android:label="@string/snsr_synch_test"
android:screenOrientation="nosensor">
<intent-filter>
@@ -742,7 +743,7 @@
<meta-data android:name="test_category" android:value="@string/test_category_sensors" />
<meta-data android:name="test_required_features"
android:value="android.hardware.sensor.gyroscope" />
- </activity>
+ </activity-->
<activity android:name=".location.LocationModeOffTestActivity"
android:label="@string/location_mode_off_test">
diff --git a/apps/CtsVerifier/res/layout/snsr_rotvec.xml b/apps/CtsVerifier/res/layout/snsr_rotvec.xml
index 6f54f01..1a896db 100644
--- a/apps/CtsVerifier/res/layout/snsr_rotvec.xml
+++ b/apps/CtsVerifier/res/layout/snsr_rotvec.xml
@@ -13,68 +13,31 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<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:id="@+id/log_text"
- android:gravity="bottom"
- android:layout_alignParentTop="true"
- android:layout_height="wrap_content"
+ android:layout_height="0dp"
android:layout_width="wrap_content"
- android:maxLines="27"
+ android:layout_weight="1"
android:paddingBottom="5dip"
android:paddingLeft="10dip"
android:paddingRight="10dip"
android:paddingTop="5dip"
- android:scrollbars="vertical"
- />
-
- <Button android:id="@+id/next_button"
- android:layout_alignParentBottom="true"
- android:layout_centerInParent="true"
- android:layout_height="wrap_content"
- android:layout_marginBottom="20dip"
- android:layout_width="120dip"
- android:text="@string/next_button_text"
- android:textSize="24dip"
- />
+ android:scrollbars="vertical" />
<android.opengl.GLSurfaceView android:id="@+id/gl_surface_view"
- android:layout_above="@+id/next_button"
- android:layout_below="@+id/log_text"
- android:layout_marginBottom="5dip"
android:layout_width="match_parent"
- android:layout_height="wrap_content" />
+ android:layout_height="0dp"
+ android:layout_weight="2" />
- <TextView android:id="@+id/sensor_value"
- android:background="@drawable/gray_bubble"
- android:drawablePadding="10dip"
- android:layout_above="@+id/next_button"
- android:layout_centerInParent="true"
- android:layout_width="wrap_content"
+ <Button android:id="@+id/next_button"
+ android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"
- android:layout_marginBottom="10dip"
- android:paddingLeft="10dip"
- android:paddingRight="10dip"
- android:paddingTop="5dip"
- android:paddingBottom="5dip"
- android:textSize="28dip"
- />
-
- <TextView android:id="@+id/progress"
- android:background="@drawable/gray_bubble"
- android:layout_below="@+id/log_text"
- android:layout_centerInParent="true"
android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="10dip"
- android:paddingLeft="10dip"
- android:paddingRight="10dip"
- android:paddingTop="5dip"
- android:paddingBottom="5dip"
- android:textSize="28dip"
- />
+ android:layout_weight="0"
+ android:text="@string/next_button_text" />
-
-</RelativeLayout>
\ No newline at end of file
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/layout/snsr_semi_auto_test.xml b/apps/CtsVerifier/res/layout/snsr_semi_auto_test.xml
index 92039f0..c816021 100644
--- a/apps/CtsVerifier/res/layout/snsr_semi_auto_test.xml
+++ b/apps/CtsVerifier/res/layout/snsr_semi_auto_test.xml
@@ -13,15 +13,16 @@
See the License for the specific language governing permissions and
limitations under the License.
-->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+<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:id="@+id/log_text"
- android:gravity="bottom"
- android:layout_height="wrap_content"
+ android:layout_height="0dp"
android:layout_width="wrap_content"
- android:maxLines="27"
+ android:layout_weight="1"
+ android:layout_gravity="bottom"
android:paddingBottom="5dip"
android:paddingLeft="10dip"
android:paddingRight="10dip"
@@ -30,13 +31,11 @@
/>
<Button android:id="@+id/next_button"
- android:layout_alignParentBottom="true"
- android:layout_centerInParent="true"
+ android:layout_gravity="center_horizontal"
android:layout_height="wrap_content"
- android:layout_marginBottom="20dip"
- android:layout_width="120dip"
+ android:layout_width="wrap_content"
+ android:paddingBottom="5dip"
android:text="@string/next_button_text"
- android:textSize="24dip"
/>
-</RelativeLayout>
+</LinearLayout>
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index e42cf48..2a61323 100644
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -442,6 +442,7 @@
<string name="snsr_airplane_mode_request">You will be redirected to set \'Airplane Mode\' ON.</string>
<string name="snsr_screen_off_timeout">Screen Off Timeout set to: %1$d seconds.</string>
<string name="snsr_screen_off_request">You will be redirected to set \'Display Sleep\' to %1$d seconds.</string>
+ <string name="snsr_movement_expected">Movement was expected during the test. Found=%1$b.</string>
<!-- Accelerometer -->
<string name="snsr_accel_test">Accelerometer Test</string>
@@ -491,6 +492,9 @@
<!-- Sensor Value Accuracy -->
<string name="snsr_val_acc_test">Sensor Value Accuracy Tests</string>
<string name="snsr_rot_vec_test">Rotation Vector Accuracy Test</string>
+ <string name="snsr_event_length">Sensor(%3$s). Event values expected to have size=%1$d. Found=%2$d</string>
+ <string name="snsr_event_value">Sensor(%3$s). Event value[0] expected to be of value=%1$f. Found=%2$f</string>
+ <string name="snsr_event_time">Sensor(%3$s). Event timestamp expected to be at=%1$d. Found=%2$d. Delta=%3$d. Threshold=%4$d.</string>
<!-- Sensor Batching -->
<string name="snsr_batch_test">Sensor Batching Tests</string>
@@ -500,9 +504,31 @@
<!-- Step Counter and Detector -->
<string name="snsr_step_counter_test">Step Counter and Detector Tests</string>
+ <string name="snsr_step_counter_test_walking">Once the test begins, you will need to walk, and tap on the screen with each step you take.</string>
+ <string name="snsr_step_counter_test_still">Once the test begins, you will need to hold the device still in your hand.</string>
+ <string name="snsr_step_counter_test_waving">Once the test begins, you will need to wave the device in your hand throughout the test.</string>
+ <string name="snsr_step_counter_expected_steps">At least %1$d steps are expected to be reported. Reported=%2$d.</string>
+ <string name="snsr_step_counter_detected_reported">Steps reported by user=%1$d. Steps counted=%2$d. Delta=%3$d. Tolerance=%4$d.</string>
+ <string name="snsr_step_detector_detected_reported">Steps reported by user=%1$d. Steps detected=%2$d. Delta=%3$d. Tolerance=%4$d.</string>
+ <string name="snsr_step_counter_event_changed">Step counter expected to increase monotonically, with a delta > 0. Found=%1$d. Timestamp=%2$d.</string>
+ <string name="snsr_step_reported">%1$d | User reported step.</string>
+ <string name="snsr_step_counter_event">%1$d | Step Counter event. count=%2$d.</string>
+ <string name="snsr_step_detector_event">%1$d | Step Detector event.</string>
<!-- Significant Motion -->
<string name="snsr_significant_motion_test">Significant Motion Tests</string>
+ <string name="snsr_significant_motion_event_arrival">Event expected to trigger. Current: %1$s</string>
+ <string name="snsr_significant_motion_event_type">Event expected to be of type=%1$d. Found=%2$d</string>
+ <string name="snsr_significant_motion_event_unexpected">Event not expected to trigger. Current: %1$s.</string>
+ <string name="snsr_significant_motion_disable_info">Significant Motion is expected to disable itself after it triggers once.</string>
+ <string name="snsr_significant_motion_test_trigger">Once you begin the test, you will need to walk for Significant Motion to be detected.</string>
+ <string name="snsr_significant_motion_test_cancel">Once you begin the test, you will need to walk to ensure Significant Motion is not reported after trigger canceled.</string>
+ <string name="snsr_significant_motion_test_vibration">Leave the device in a level surface. Once you begin the test, the device will vibrate to ensure that Significant Motion is not triggered.</string>
+ <string name="snsr_significant_motion_test_in_hand">Once you begin the test, hold the device in your hand while you perform natural hand movements.</string>
+ <string name="snsr_significant_motion_test_sitting">Once you begin the test, keep the device in your pocket and move naturally while sitting in a chair.</string>
+ <string name="snsr_significant_motion_test_deactivation">Once you begin the test, you will need to walk to ensure Significant Motion triggers only once.</string>
+ <string name="snsr_significant_motion_registration">Expected to be able to register for TriggerSensor. Found=%b.</string>
+ <string name="snsr_significant_motion_cancelation">Expected to be able to cancel TriggerSensor. Found=%b.</string>
<!-- Strings for Sample Test Activities -->
<string name="share_button_text">Share</string>
@@ -1061,14 +1087,12 @@
<!-- Strings for RotationVectorTest and GameRotationVectorTest -->
<string name="rotation_vector_test">Rotation Vector Accuracy Test</string>
- <string name="game_rotation_vector_test">Game Rotation Vector Accuracy Test</string>
- <string name="rotation_vector_test_info">
- This test verifies that mobile device can detect its orientation in space quickly and repeatably.\n\n
- Instructions:\n
- \n
- 1. Place the mobile device in a reference position and note the arrow orientation.\n
- 2. Move, shake, and rotate the device for about 30 seconds.\n
- 3. Place the mobile device back to the reference position.\n
- 4. Pass if it returns to the original arrow orientation within one second.\n
- </string>
+ <string name="snsr_rotation_vector_set_reference">
+ Place the mobile device in a reference position. Note: to provide an accurate reference,
+ align the device along one edge of a notebook laying on a table.</string>
+ <string name="snsr_rotation_vector_reference_set">Reference position set.</string>
+ <string name="snsr_rotation_vector_move_info">Move, shake, and rotate the device.</string>
+ <string name="snsr_rotation_vector_set_final">Place the device back to the reference position.</string>
+ <string name="snsr_rotation_vector_verification">Angular deviation [%1$4.1f %2$4.1f %3$4.1f]. Current: %4$f deg. Max tolerated: %5$f.</string>
+
</resources>
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/BaseSensorTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/BaseSensorTestActivity.java
index 7953f25..b3f7085 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/BaseSensorTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/BaseSensorTestActivity.java
@@ -19,14 +19,18 @@
import com.android.cts.verifier.R;
import com.android.cts.verifier.TestResult;
+import junit.framework.Assert;
+
import android.app.Activity;
import android.content.ContentResolver;
+import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.hardware.cts.helpers.SensorNotSupportedException;
import android.media.MediaPlayer;
import android.os.Build;
import android.os.Bundle;
+import android.os.Vibrator;
import android.provider.Settings;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
@@ -63,6 +67,7 @@
protected final String LOG_TAG = "TestRunner";
protected final Class mTestClass;
+ private final int mLayoutId;
private final Semaphore mSemaphore = new Semaphore(0);
@@ -76,13 +81,18 @@
private volatile int mTestFailedCounter;
protected BaseSensorTestActivity(Class testClass) {
+ this(testClass, R.layout.snsr_semi_auto_test);
+ }
+
+ protected BaseSensorTestActivity(Class testClass, int layoutId) {
mTestClass = testClass;
+ mLayoutId = layoutId;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.snsr_semi_auto_test);
+ setContentView(mLayoutId);
mLogView = (TextView) this.findViewById(R.id.log_text);
mNextView = this.findViewById(R.id.next_button);
@@ -278,6 +288,16 @@
}
}
+ protected void vibrate(int timeInMs) {
+ Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
+ vibrator.vibrate(timeInMs);
+ }
+
+ protected void vibrate(long[] pattern) {
+ Vibrator vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
+ vibrator.vibrate(pattern, -1);
+ }
+
private List<Method> findTestMethods() {
ArrayList<Method> testMethods = new ArrayList<Method>();
for (Method method : mTestClass.getDeclaredMethods()) {
@@ -293,7 +313,7 @@
private SensorTestDetails executeTest(Method testMethod) {
SensorTestDetails testDetails = new SensorTestDetails();
- testDetails.name = String.format("%s.%s", getTestClassName(), testMethod.getName());
+ testDetails.name = String.format("%s#%s", getTestClassName(), testMethod.getName());
try {
appendText(getString(R.string.snsr_executing_test, testDetails.name));
@@ -424,6 +444,25 @@
}
}
+ // TODO: move to sensor assertions
+ protected String assertTimestampSynchronization(
+ long eventTimestamp,
+ long receivedTimestamp,
+ long deltaThreshold,
+ String sensorName) {
+ long timestampDelta = Math.abs(eventTimestamp - receivedTimestamp);
+ String timestampMessage = getString(
+ R.string.snsr_event_time,
+ receivedTimestamp,
+ eventTimestamp,
+ timestampDelta,
+ deltaThreshold,
+ sensorName);
+ Assert.assertTrue(timestampMessage, timestampDelta < deltaThreshold);
+ return timestampMessage;
+
+ }
+
private void launchAndWaitForSubactivity(String action) throws InterruptedException {
launchAndWaitForSubactivity(new Intent(action));
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/RotationVectorTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/RotationVectorTestActivity.java
index 1d6fe46..9ffce01 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/RotationVectorTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/RotationVectorTestActivity.java
@@ -16,95 +16,174 @@
package com.android.cts.verifier.sensors;
-import java.util.concurrent.CountDownLatch;
+import com.android.cts.verifier.R;
import junit.framework.Assert;
-import android.annotation.TargetApi;
+
import android.content.Context;
-import android.graphics.Color;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
+import android.hardware.cts.helpers.SensorNotSupportedException;
import android.opengl.GLSurfaceView;
-import android.os.Build;
import android.os.Bundle;
+import android.util.Log;
import android.view.View;
-import android.widget.TextView;
-import com.android.cts.verifier.R;
+import java.util.concurrent.TimeUnit;
/**
- * This test verifies that mobile device can detect it's orientation in space
- * and after device movement in space it correctly detects original (reference)
- * position. All three rotation vectors are tested: ROTATION_VECTOR,
- * GEOMAGNETIC_ROTATION_VECTOR, and GAME_ROTATION_VECTOR.
+ * This test verifies that mobile device can detect it's orientation in space and after device
+ * movement in space it correctly detects original (reference) position.
+ * All three rotation vectors are tested:
+ * - ROTATION_VECTOR,
+ * - GEOMAGNETIC_ROTATION_VECTOR,
+ * - GAME_ROTATION_VECTOR.
*/
-@TargetApi(Build.VERSION_CODES.KITKAT)
-public class RotationVectorTestActivity extends BaseSensorSemiAutomatedTestActivity implements
- SensorEventListener {
- private final int[] MAX_RV_DEVIATION_DEG = {
- 10, 10, 40
- };
- private GLSurfaceView mGLSurfaceView = null;
- private SensorManager mSensorManager = null;
- private SensorEventListener mListener;
- private TextView mInitialView, mFinalView;
- private float[] mVecFinal;
- private float[][] mVec, mVecInitial;
- private float[][] mAngChange;
+public class RotationVectorTestActivity
+ extends BaseSensorTestActivity
+ implements SensorEventListener {
+ public RotationVectorTestActivity() {
+ super(RotationVectorTestActivity.class, R.layout.snsr_rotvec);
+ }
- private CountDownLatch mFinalPositionSet;
+ private GLSurfaceView mGLSurfaceView;
+ private SensorManager mSensorManager;
+ private SensorEventListener mListener;
+
+ /**
+ * Defines the thresholds for each rotation vector in degrees.
+ */
+ private static final double[] MAX_DEVIATION_DEGREES = {
+ 10.0, // ROTATION_VECTOR
+ 10.0, // GEOMAGNETIC ROTATION_VECTOR
+ 40.0, // GAME_ROTATION_VECTOR
+ };
+
+ private static final int MAX_SENSORS_AVAILABLE = 3;
+ private static final int ROTATION_VECTOR_INDEX = 0;
+ private static final int GEOMAGNETIC_ROTATION_VECTOR_INDEX = 1;
+ private static final int GAME_ROTATION_VECTOR_INDEX = 2;
+
+ private float[][] mLastEvent = new float[3][5];
+ private final float[][] mReference = new float[3][16];
+ private final float[][] mAngularChange = new float[3][3];
+ private final Sensor[] mSensor = new Sensor[3];
+
+ /**
+ * The activity setup collects all the required data for test cases.
+ * This approach allows to test all sensors at once.
+ */
+ @Override
+ protected void activitySetUp() throws InterruptedException {
+ if (mSensor[ROTATION_VECTOR_INDEX] == null
+ && mSensor[GEOMAGNETIC_ROTATION_VECTOR_INDEX] == null
+ && mSensor[GAME_ROTATION_VECTOR_INDEX] == null) {
+ // if none of the sensors is supported, skip the test by throwing an exception
+ throw new IllegalStateException("Rotation vectors are not supported.");
+ }
+
+ // TODO: take reference value automatically when device is 'still'
+ appendText(R.string.snsr_rotation_vector_set_reference);
+ waitForUser();
+
+ clearText();
+ for (int i = 0; i < MAX_SENSORS_AVAILABLE; ++i) {
+ SensorManager.getRotationMatrixFromVector(mReference[i], mLastEvent[i].clone());
+ }
+
+ // TODO: check the user actually moved the device during the test
+ appendText(R.string.snsr_rotation_vector_reference_set);
+ appendText(R.string.snsr_rotation_vector_move_info);
+ appendText(R.string.snsr_test_play_sound);
+ Thread.sleep(TimeUnit.SECONDS.toMillis(30));
+ playSound();
+
+ // TODO: take final value automatically when device becomes 'still' at the end
+ clearText();
+ appendText(R.string.snsr_rotation_vector_set_final);
+ waitForUser();
+
+ clearText();
+ runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ mGLSurfaceView.setVisibility(View.GONE);
+ }
+ });
+
+ float[] finalVector = new float[16];
+ for (int i = 0; i < MAX_SENSORS_AVAILABLE; ++i) {
+ SensorManager.getRotationMatrixFromVector(finalVector, mLastEvent[i].clone());
+ SensorManager.getAngleChange(mAngularChange[i], mReference[i], finalVector);
+ }
+ }
+
+ /**
+ * Verifies that a given 'Rotation Vector' sensor does not drift over time.
+ * The test takes in consideration a reference measurement, and a final measurement. It then
+ * calculates its angular change.
+ */
+ private String verifyVector(int sensorIndex, int sensorType)
+ throws Throwable {
+ Sensor sensor = mSensor[sensorIndex];
+ if (sensor == null) {
+ throw new SensorNotSupportedException(sensorType);
+ }
+
+ float[] angularChange = mAngularChange[sensorIndex];
+ double maxDeviationDegrees = MAX_DEVIATION_DEGREES[sensorIndex];
+ double maxComponentDegrees = findMaxComponentDegrees(angularChange);
+ String message = getString(
+ R.string.snsr_rotation_vector_verification,
+ Math.toDegrees(angularChange[0]),
+ Math.toDegrees(angularChange[1]),
+ Math.toDegrees(angularChange[2]),
+ maxComponentDegrees,
+ maxDeviationDegrees);
+
+ Assert.assertEquals(message, 0, maxComponentDegrees, maxDeviationDegrees);
+ return message;
+ }
+
+ /**
+ * Test cases.
+ */
+ public String testRotationVector() throws Throwable {
+ return verifyVector(ROTATION_VECTOR_INDEX, Sensor.TYPE_ROTATION_VECTOR);
+ }
+
+ public String testGeomagneticRotationVector() throws Throwable {
+ return verifyVector(
+ GEOMAGNETIC_ROTATION_VECTOR_INDEX,
+ Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR);
+ }
+
+ public String testGameRotationVector() throws Throwable {
+ return verifyVector(GAME_ROTATION_VECTOR_INDEX, Sensor.TYPE_GAME_ROTATION_VECTOR);
+ }
@Override
protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- setContentView(R.layout.snsr_rotvec);
- setInitialFinalTextClickListeners();
-
+ // set up sensors first, so activitySetUp has the state in place
mSensorManager = (SensorManager) getApplicationContext().getSystemService(
Context.SENSOR_SERVICE);
- GLArrowSensorTestRenderer renderer = new GLArrowSensorTestRenderer(this,
- Sensor.TYPE_ROTATION_VECTOR);
+ mSensor[ROTATION_VECTOR_INDEX] =
+ mSensorManager.getDefaultSensor(Sensor.TYPE_ROTATION_VECTOR);
+ mSensor[GEOMAGNETIC_ROTATION_VECTOR_INDEX] =
+ mSensorManager.getDefaultSensor(Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR);
+ mSensor[GAME_ROTATION_VECTOR_INDEX] =
+ mSensorManager.getDefaultSensor(Sensor.TYPE_GAME_ROTATION_VECTOR);
+
+ super.onCreate(savedInstanceState);
+
+ GLArrowSensorTestRenderer renderer =
+ new GLArrowSensorTestRenderer(this, Sensor.TYPE_ROTATION_VECTOR);
mListener = renderer;
mGLSurfaceView = (GLSurfaceView) findViewById(R.id.gl_surface_view);
mGLSurfaceView.setRenderer(renderer);
- mVecInitial = new float[3][16];
- mVecFinal = new float[16];
- mVec = new float[3][5];
- mAngChange = new float[3][3];
- }
-
- void setInitialFinalTextClickListeners() {
- mInitialView = (TextView) findViewById(R.id.progress);
- mInitialView.setText("Click to set reference");
- mInitialView.setOnClickListener(new View.OnClickListener() {
- public void onClick(View view) {
- mInitialView.setText("Reference position set");
- for (int i = 0; i < 3; i++) {
- SensorManager.getRotationMatrixFromVector(mVecInitial[i], mVec[i].clone());
- }
- }
- });
- mFinalView = (TextView) findViewById(R.id.sensor_value);
- mFinalView.setText("Click to set final result");
- mFinalView.setOnClickListener(new View.OnClickListener() {
- public void onClick(View view) {
- mFinalView.setText("RV, Geo, and Game:");
- for (int i = 0; i < 3; i++) {
- SensorManager.getRotationMatrixFromVector(mVecFinal, mVec[i].clone());
- SensorManager.getAngleChange(mAngChange[i], mVecInitial[i], mVecFinal);
- mFinalView.append(String.format("\n%4.1f %4.1f %4.1f deg",
- Math.toDegrees(mAngChange[i][0]),
- Math.toDegrees(mAngChange[i][1]),
- Math.toDegrees(mAngChange[i][2])));
- }
- mFinalPositionSet.countDown();
- }
- });
-
}
@Override
@@ -119,28 +198,34 @@
protected void onResume() {
super.onResume();
mGLSurfaceView.onResume();
+
// listener for rendering
- mSensorManager.registerListener(mListener, mSensorManager.getDefaultSensor(
- Sensor.TYPE_ROTATION_VECTOR), SensorManager.SENSOR_DELAY_GAME);
- // listener for testing
- mSensorManager.registerListener(this, mSensorManager.getDefaultSensor(
- Sensor.TYPE_ROTATION_VECTOR), SensorManager.SENSOR_DELAY_GAME);
- mSensorManager.registerListener(this, mSensorManager.getDefaultSensor(
- Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR), SensorManager.SENSOR_DELAY_GAME);
- mSensorManager.registerListener(this, mSensorManager.getDefaultSensor(
- Sensor.TYPE_GAME_ROTATION_VECTOR), SensorManager.SENSOR_DELAY_GAME);
+ boolean renderListenerRegistered = false;
+ for (int i = 0; (!renderListenerRegistered && i < MAX_SENSORS_AVAILABLE); ++i) {
+ Sensor sensor = mSensor[i];
+ if (sensor != null) {
+ renderListenerRegistered = mSensorManager
+ .registerListener(mListener, sensor, SensorManager.SENSOR_DELAY_GAME);
+ Log.v(LOG_TAG, "Renderer using sensor: " + sensor.getName());
+ }
+ }
+
+ // listeners for testing
+ for (int i = 0; i < MAX_SENSORS_AVAILABLE; ++i) {
+ mSensorManager.registerListener(this, mSensor[i], SensorManager.SENSOR_DELAY_GAME);
+ }
}
@Override
public void onSensorChanged(SensorEvent event) {
if (event.sensor.getType() == Sensor.TYPE_ROTATION_VECTOR) {
- mVec[0] = event.values.clone();
+ mLastEvent[ROTATION_VECTOR_INDEX] = event.values.clone();
}
if (event.sensor.getType() == Sensor.TYPE_GEOMAGNETIC_ROTATION_VECTOR) {
- mVec[1] = event.values.clone();
+ mLastEvent[GEOMAGNETIC_ROTATION_VECTOR_INDEX] = event.values.clone();
}
if (event.sensor.getType() == Sensor.TYPE_GAME_ROTATION_VECTOR) {
- mVec[2] = event.values.clone();
+ mLastEvent[GAME_ROTATION_VECTOR_INDEX] = event.values.clone();
}
}
@@ -148,36 +233,7 @@
public void onAccuracyChanged(Sensor sensor, int accuracy) {
}
- @Override
- protected void onRun() throws Throwable {
- mFinalPositionSet = new CountDownLatch(1);
-
- appendText("INSTRUCTIONS:\n"
- + "Place device still and click to set reference position.\n"
- + "Move for 30 seconds then return to reference position.\n"
- + "Click to set final position.");
- mFinalPositionSet.await();
- clearText();
- // TODO: check the user actually moved the device during the test, and
- // stillness check at start and end of the test
- Assert.assertEquals(String.format(
- "ROTATION_VECTOR Angular deviation more than %d degrees",
- MAX_RV_DEVIATION_DEG[0]), 0, findMaxComponentDegrees(mAngChange[0]),
- MAX_RV_DEVIATION_DEG[0]);
- appendText("ROTATION_VECTOR passed", Color.GREEN);
- Assert.assertEquals(String.format(
- "GEOMAGNETIC_ROTATION_VECTOR Angular deviation more than %d degrees",
- MAX_RV_DEVIATION_DEG[1]), 0, findMaxComponentDegrees(mAngChange[1]),
- MAX_RV_DEVIATION_DEG[1]);
- appendText("GEOMAGNETIC_ROTATION_VECTOR passed", Color.GREEN);
- Assert.assertEquals(String.format(
- "GAME_ROTATION_VECTOR Angular deviation more than %d degrees",
- MAX_RV_DEVIATION_DEG[2]), 0, findMaxComponentDegrees(mAngChange[2]),
- MAX_RV_DEVIATION_DEG[2]);
- appendText("GAME_ROTATION_VECTOR passed", Color.GREEN);
- }
-
- double findMaxComponentDegrees(float[] vec) {
+ private static double findMaxComponentDegrees(float[] vec) {
float maxComponent = 0;
for (int i = 0; i < vec.length; i++) {
float absComp = Math.abs(vec[i]);
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/SignificantMotionTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/SignificantMotionTestActivity.java
index 9258ba6..d7bf976 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/SignificantMotionTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/SignificantMotionTestActivity.java
@@ -16,120 +16,113 @@
package com.android.cts.verifier.sensors;
+import com.android.cts.verifier.R;
+
import junit.framework.Assert;
-import android.annotation.TargetApi;
-import android.app.Activity;
+
import android.content.Context;
-import android.graphics.Color;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.hardware.TriggerEvent;
import android.hardware.TriggerEventListener;
-import android.media.AudioManager;
-import android.media.ToneGenerator;
-import android.os.Build;
import android.os.Bundle;
-import android.os.Vibrator;
+import android.os.SystemClock;
-@TargetApi(Build.VERSION_CODES.KITKAT)
-class TriggerListener extends TriggerEventListener {
- // how much difference between system time and event time considered to be
- // acceptable [msec]
- private final long MAX_ACCEPTABLE_EVENT_TIME_DELAY_MILLIS = 500;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
- // state used for internal recording of the event detection
- private boolean mEventDetected = false;
-
- public void onTrigger(TriggerEvent event) {
- final long NANOS_PER_MS = 1000000L;
-
- Assert.assertEquals("values should be of length 1 for significant motion event", 1,
- event.values.length);
- Assert.assertEquals("values[0] should be 1.0 for significant motion event", 1.0f,
- event.values[0]);
-
- // Check that timestamp is within MAX_ACCEPTABLE_EVENT_TIME_DELAY_MILLIS
- // It might take time to determine Significant Motion, but then that
- // event should be reported to the host in a timely fashion.
- long timeReportedMillis = event.timestamp / NANOS_PER_MS;
- long timeActualMillis = System.currentTimeMillis();
- Assert.assertEquals("Incorrect time reported in the event",
- timeReportedMillis, timeActualMillis, MAX_ACCEPTABLE_EVENT_TIME_DELAY_MILLIS);
-
- // Verify event type is truly Significant Motion
- Assert.assertEquals("Triggered event type is not Significant Motion",
- event.sensor.getType(), Sensor.TYPE_SIGNIFICANT_MOTION);
-
- // Event detected flag should be false if indeed only one event per
- // request
- Assert.assertFalse("Significant Motion sensor did not automatically "
- + "disable itself from subsequent detection", mEventDetected);
-
- // audible cue to indicate Significant Motion occurred
- beep();
- mEventDetected = true;
+/**
+ * Test cases for Significant Motion sensor.
+ * They use walking motion to change the location and trigger Significant Motion.
+ */
+public class SignificantMotionTestActivity extends BaseSensorTestActivity {
+ public SignificantMotionTestActivity() {
+ super(SignificantMotionTestActivity.class);
}
- public boolean wasEventTriggered() {
- return mEventDetected;
- }
+ // acceptable time difference between event time and system time
+ private static final long MAX_ACCEPTABLE_EVENT_TIME_DELAY_NANOS =
+ TimeUnit.MILLISECONDS.toNanos(500);
- public void reset() {
- mEventDetected = false;
- }
+ // time for the test to wait for a trigger
+ private static final int TRIGGER_MAX_DELAY_SECONDS = 30;
+ private static final int VIBRATE_DURATION_MILLIS = 10000;
- private void beep() {
- final ToneGenerator tg = new ToneGenerator(
- AudioManager.STREAM_NOTIFICATION, 100);
- tg.startTone(ToneGenerator.TONE_PROP_BEEP);
- }
-}
-
-@TargetApi(Build.VERSION_CODES.KITKAT)
-public class SignificantMotionTestActivity extends BaseSensorSemiAutomatedTestActivity {
- // minimum time for test to consider valid [msec]
- private final int MIN_TEST_TIME_MILLIS = 20000;
- private final int VIBRATE_DURATION_MILLIS = 10000;
+ private static final int EVENT_VALUES_LENGTH = 1;
+ private static final float EXPECTED_EVENT_VALUE = 1.0f;
private SensorManager mSensorManager;
private Sensor mSensorSignificantMotion;
- private final TriggerListener mTriggeredListener = new TriggerListener();
- private long mTestStartTimestamp;
- private static int sNumPassedTests = 0;
- @Override
- protected void onRun() throws Throwable {
- switch (sNumPassedTests) {
- // avoid re-running passed tests, so purposely want fallthroughs here
- case 0:
- // use walking to change location and trigger significant motion
- runTest("walk 15 steps for significant motion to be detected", true, false, false);
- case 1:
- runTest("walk another 15 steps to ensure significant motion "
- + "is not reported after trigger cancelled", false, true, false);
- case 2:
- // use vibrator to ensure significant motion is not triggered
- runTest("leave the device on a level surface", false, false, true);
- case 3:
- // use natural motion that does not change location to ensure
- // significant motion is not triggered
- runTest("hold the device in hand while performing natural "
- + "hand movements", false, false, false);
- case 4:
- runTest("keep the device in pocket and move naturally while "
- + "sitting in a chair", false, false, false);
- default:
- break;
- }
+ /**
+ * Test cases.
+ */
+ public String testTrigger() throws Throwable {
+ return runTest(
+ R.string.snsr_significant_motion_test_trigger,
+ true /* isMotionExpected */,
+ false /* cancelEventNotification */,
+ false /* vibrate */);
}
- private void vibrateDevice(int timeInMs) {
- Vibrator vibrator = (Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE);
- vibrator.vibrate(timeInMs);
+ public String testNotTriggerAfterCancell() throws Throwable {
+ return runTest(
+ R.string.snsr_significant_motion_test_cancel,
+ false /* isMotionExpected */,
+ true /* cancelEventNotification */,
+ false /* vibrate */);
}
/**
- * @param instructions Instruction to be shown to testers
+ * Verifies that Significant Motion is not trigger by the vibrator motion.
+ */
+ public String testVibratorDoesNotTrigger() throws Throwable {
+ return runTest(
+ R.string.snsr_significant_motion_test_vibration,
+ false /* isMotionExpected */,
+ false /* cancelEventNotification */,
+ true /* vibrate */);
+ }
+
+ /**
+ * Verifies that the natural motion of keeping the device in hand does not change the location.
+ * It ensures that Significant Motion will not trigger in that scenario.
+ */
+ public String testInHandDoesNotTrigger() throws Throwable {
+ return runTest(
+ R.string.snsr_significant_motion_test_in_hand,
+ false /* isMotionExpected */,
+ false /* cancelEventNotification */,
+ false /* vibrate */);
+ }
+
+ public String testSittingDoesNotTrigger() throws Throwable {
+ return runTest(
+ R.string.snsr_significant_motion_test_sitting,
+ false /* isMotionExpected */,
+ false /* cancelEventNotification */,
+ false /* vibrate */);
+ }
+
+ public String testTriggerDeactivation() throws Throwable {
+ appendText(R.string.snsr_significant_motion_test_deactivation);
+ waitForUser();
+
+ TriggerVerifier verifier = new TriggerVerifier();
+ mSensorManager.requestTriggerSensor(verifier, mSensorSignificantMotion);
+ appendText(R.string.snsr_test_play_sound);
+
+ // wait for the first event to trigger
+ verifier.verifyEventTriggered();
+
+ // wait for a second event not to trigger
+ String result = verifier.verifyEventNotTriggered();
+ playSound();
+ return result;
+ }
+
+ /**
+ * @param instructionsResId Instruction to be shown to testers
* @param isMotionExpected Should the device detect significant motion event
* for this test?
* @param cancelEventNotification If TRUE, motion notifications will be
@@ -137,57 +130,40 @@
* @param vibrate If TRUE, vibration will be concurrent with the test
* @throws Throwable
*/
- private void runTest(String instructions, final boolean isMotionExpected,
- final boolean cancelEventNotification, final boolean vibrate) throws Throwable {
-
- appendText("Click 'Next' and " + instructions);
+ private String runTest(
+ int instructionsResId,
+ boolean isMotionExpected,
+ boolean cancelEventNotification,
+ boolean vibrate) throws Throwable {
+ appendText(instructionsResId);
waitForUser();
if (vibrate) {
- vibrateDevice(VIBRATE_DURATION_MILLIS);
+ vibrate(VIBRATE_DURATION_MILLIS);
}
- mTestStartTimestamp = System.currentTimeMillis();
- startMeasurements(cancelEventNotification);
-
- long testTime = System.currentTimeMillis() - mTestStartTimestamp;
-
- while (!mTriggeredListener.wasEventTriggered()
- && testTime < MIN_TEST_TIME_MILLIS) {
- int timeWaitSec = Math
- .round((MIN_TEST_TIME_MILLIS - testTime) / 1000);
- clearText();
- appendText("Current test: " + instructions);
- appendText(
- String.format("%d seconds for the test to complete", timeWaitSec),
- Color.GRAY);
-
- Thread.sleep(1000);
- testTime = System.currentTimeMillis() - mTestStartTimestamp;
+ TriggerVerifier verifier = new TriggerVerifier();
+ Assert.assertTrue(
+ getString(R.string.snsr_significant_motion_registration),
+ mSensorManager.requestTriggerSensor(verifier, mSensorSignificantMotion));
+ if (cancelEventNotification) {
+ Assert.assertTrue(
+ getString(R.string.snsr_significant_motion_cancelation),
+ mSensorManager.cancelTriggerSensor(verifier, mSensorSignificantMotion));
}
- clearText();
- appendText("Current test: " + instructions);
- playSound();
- verifyMeasurements(isMotionExpected);
- sNumPassedTests++;
- }
+ appendText(R.string.snsr_test_play_sound);
- private void startMeasurements(boolean isCancelTriggerRequested) throws Throwable {
- mTriggeredListener.reset();
-
- mSensorManager.requestTriggerSensor(mTriggeredListener, mSensorSignificantMotion);
-
- if (isCancelTriggerRequested) {
- mSensorManager.cancelTriggerSensor(mTriggeredListener, mSensorSignificantMotion);
+ String result;
+ try {
+ if (isMotionExpected) {
+ result = verifier.verifyEventTriggered();
+ } else {
+ result = verifier.verifyEventNotTriggered();
+ }
+ } finally {
+ mSensorManager.cancelTriggerSensor(verifier, mSensorSignificantMotion);
}
- }
-
- private void verifyMeasurements(boolean isMotionExpected) throws Throwable {
- Assert.assertEquals("Significant motion event expected/detected mismatch: "
- + isMotionExpected + " / " + mTriggeredListener.wasEventTriggered(),
- isMotionExpected, mTriggeredListener.wasEventTriggered());
- appendText("Significant motion event " + isMotionExpected + " as expected", Color.GRAY);
- logSuccess();
+ return result;
}
@Override
@@ -196,29 +172,95 @@
mSensorManager = (SensorManager) getApplicationContext()
.getSystemService(Context.SENSOR_SERVICE);
-
mSensorSignificantMotion = mSensorManager
.getDefaultSensor(Sensor.TYPE_SIGNIFICANT_MOTION);
}
- @Override
- protected void onResume() {
- super.onResume();
+ /**
+ * Helper Trigger listener for testing.
+ * It cannot be reused.
+ */
+ private class TriggerVerifier extends TriggerEventListener {
+ private volatile CountDownLatch mCountDownLatch;
+ private volatile TriggerEventRegistry mEventRegistry;
- if (mSensorManager != null && mSensorSignificantMotion != null) {
- mSensorManager.requestTriggerSensor(mTriggeredListener,
- mSensorSignificantMotion);
+ // TODO: refactor out if needed
+ private class TriggerEventRegistry {
+ public final TriggerEvent triggerEvent;
+ public final long realtimeTimestampNanos;
+
+ public TriggerEventRegistry(TriggerEvent event, long realtimeTimestampNanos) {
+ this.triggerEvent = event;
+ this.realtimeTimestampNanos = realtimeTimestampNanos;
+ }
}
- }
- @Override
- protected void onPause() {
- super.onPause();
+ public void onTrigger(TriggerEvent event) {
+ long elapsedRealtimeNanos = SystemClock.elapsedRealtimeNanos();
+ mEventRegistry = new TriggerEventRegistry(event, elapsedRealtimeNanos);
+ mCountDownLatch.countDown();
+ }
- if (mSensorManager != null && mSensorSignificantMotion != null) {
- mSensorManager.cancelTriggerSensor(mTriggeredListener,
- mSensorSignificantMotion);
+ public String verifyEventTriggered() throws Throwable {
+ TriggerEventRegistry registry = awaitForEvent();
+
+ // verify an event arrived, and it is indeed a Significant Motion event
+ TriggerEvent event = registry.triggerEvent;
+ String eventArrivalMessage =
+ getString(R.string.snsr_significant_motion_event_arrival, event);
+ Assert.assertNotNull(eventArrivalMessage, event);
+
+ int eventType = event.sensor.getType();
+ String eventTypeMessage = getString(
+ R.string.snsr_significant_motion_event_type,
+ Sensor.TYPE_SIGNIFICANT_MOTION,
+ eventType);
+ Assert.assertEquals(eventTypeMessage, Sensor.TYPE_SIGNIFICANT_MOTION, eventType);
+
+ String sensorName = event.sensor.getName();
+ int valuesLength = event.values.length;
+ String valuesLengthMessage = getString(
+ R.string.snsr_event_length,
+ EVENT_VALUES_LENGTH,
+ valuesLength,
+ sensorName);
+ Assert.assertEquals(valuesLengthMessage, EVENT_VALUES_LENGTH, valuesLength);
+
+ float value = event.values[0];
+ String valuesMessage = getString(
+ R.string.snsr_event_value,
+ EXPECTED_EVENT_VALUE,
+ value,
+ sensorName);
+ Assert.assertEquals(valuesMessage, EXPECTED_EVENT_VALUE, value);
+
+ return assertTimestampSynchronization(
+ event.timestamp,
+ registry.realtimeTimestampNanos,
+ MAX_ACCEPTABLE_EVENT_TIME_DELAY_NANOS,
+ sensorName);
+ }
+
+ public String verifyEventNotTriggered() throws Throwable {
+ TriggerEventRegistry registry = awaitForEvent();
+
+ TriggerEvent event = registry.triggerEvent;
+ String eventMessage =
+ getString(R.string.snsr_significant_motion_event_unexpected, event);
+ Assert.assertNull(eventMessage, event);
+ return eventMessage;
+ }
+
+ private TriggerEventRegistry awaitForEvent() throws InterruptedException {
+ mCountDownLatch = new CountDownLatch(1);
+ mCountDownLatch.await(TRIGGER_MAX_DELAY_SECONDS, TimeUnit.SECONDS);
+
+ TriggerEventRegistry registry = mEventRegistry;
+ mEventRegistry = null;
+
+ playSound();
+ return registry != null ? registry : new TriggerEventRegistry(null, 0);
}
}
}
diff --git a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/StepCounterTestActivity.java b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/StepCounterTestActivity.java
index 0dfe341..fd1f057 100644
--- a/apps/CtsVerifier/src/com/android/cts/verifier/sensors/StepCounterTestActivity.java
+++ b/apps/CtsVerifier/src/com/android/cts/verifier/sensors/StepCounterTestActivity.java
@@ -16,346 +16,296 @@
package com.android.cts.verifier.sensors;
-import java.util.ArrayList;
-import java.util.List;
+import com.android.cts.verifier.R;
import junit.framework.Assert;
-import android.annotation.TargetApi;
+
import android.content.Context;
-import android.graphics.Color;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
-import android.hardware.cts.helpers.SensorCtsHelper;
-import android.media.AudioManager;
-import android.media.ToneGenerator;
-import android.os.Build;
+import android.hardware.cts.helpers.MovementDetectorHelper;
+import android.hardware.cts.helpers.TestSensorEvent;
import android.os.SystemClock;
-import android.os.Vibrator;
import android.view.View;
import android.view.View.OnClickListener;
-import com.android.cts.verifier.R;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
-@TargetApi(Build.VERSION_CODES.KITKAT)
-public class StepCounterTestActivity extends BaseSensorSemiAutomatedTestActivity
- implements SensorEventListener {
+public class StepCounterTestActivity extends BaseSensorTestActivity implements SensorEventListener {
+ public StepCounterTestActivity() {
+ super(StepCounterTestActivity.class);
+ }
+
+ private static final int TEST_DURATION_SECONDS = 20;
+ private static final long TIMESTAMP_SYNCHRONIZATION_THRESHOLD_NANOS =
+ TimeUnit.MILLISECONDS.toNanos(500);
+
+ private static final int MIN_NUM_STEPS_PER_TEST = 10;
+ private static final int MAX_STEP_DISCREPANCY = 5;
+ private static final long MAX_TOLERANCE_STEP_TIME_NANOS = TimeUnit.SECONDS.toNanos(10);
+
+ private static final long[] VIBRATE_PATTERN = {
+ 1000L, 500L, 1000L, 750L, 1000L, 500L, 1000L, 750L, 1000L, 1000L, 500L, 1000L,
+ 750L, 1000L, 500L, 1000L };
private SensorManager mSensorManager;
private Sensor mSensorStepCounter;
private Sensor mSensorStepDetector;
+ private MovementDetectorHelper mMovementDetectorHelper;
- private int mStepsReported = 0; // number of steps as reported by user
- private int mInitialStepCount = 0; // step counter at the start of test
- private int mStepsDetected = 0; // number of steps during the test
+ private volatile boolean mMoveDetected;
- private List<Long> mTimestampsUserReported = new ArrayList<Long>();
- private List<Long> mTimestampsStepCounter = new ArrayList<Long>();
- private List<Long> mTimestampsStepDetector = new ArrayList<Long>();
+ private final List<Long> mTimestampsUserReported = new ArrayList<Long>();
+ private final List<TestSensorEvent> mStepCounterEvents = new ArrayList<TestSensorEvent>();
+ private final List<TestSensorEvent> mStepDetectorEvents = new ArrayList<TestSensorEvent>();
- private final int MIN_TEST_TIME_MILLIS = 20000; // 20 sec
- private final double NANOSECONDS_IN_SEC = 1e9;
- private final int MIN_NUM_STEPS_PER_TEST = 10;
- private final int MAX_STEP_DISCREPANCY = 4;
- private final int MAX_TOLERANCE_STEP_TIME_LATENCY_SECONDS = 8;
-
- private boolean mCheckForMotion = false;
-
- private Sensor mSensorAcceleration;
- private boolean mMoveDetected = false;
- private static int sNumPassedTests = 0;
+ private volatile boolean mCheckForMotion;
@Override
- protected void onRun() throws Throwable {
- View screen = (View) findViewById(R.id.log_text).getParent();
- Assert.assertNotNull(screen);
- screen.setOnClickListener(mClickListener);
+ protected void activitySetUp() {
+ mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
+ mSensorStepCounter = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER);
+ mSensorStepDetector = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_DETECTOR);
- switch (sNumPassedTests) {
- // avoid re-running passed tests, so purposely want fallthroughs here
- case 0:
- runTest("walk at least " + MIN_NUM_STEPS_PER_TEST
- + " steps and tap on the screen with each step",
- MIN_NUM_STEPS_PER_TEST, MAX_STEP_DISCREPANCY, false, false);
- case 1:
- runTest("hold device still in hand", 0, MAX_STEP_DISCREPANCY, true, true);
- case 2:
- runTest("wave device in hand throughout test", 0, MAX_STEP_DISCREPANCY, false,
- true);
- default:
- break;
- }
+ View screen = findViewById(R.id.log_text);
+ screen.setOnClickListener(new OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ long elapsedTime = SystemClock.elapsedRealtimeNanos();
+ if (mCheckForMotion) {
+ playSound();
+ mTimestampsUserReported.add(SystemClock.elapsedRealtimeNanos());
+ appendText(getString(R.string.snsr_step_reported, elapsedTime));
+ }
+ }
+ });
}
- private OnClickListener mClickListener = new OnClickListener() {
- public void onClick(View v) {
- if (!mCheckForMotion) {
- SensorCtsHelper.beep(ToneGenerator.TONE_PROP_BEEP);
- mTimestampsUserReported.add(SystemClock.elapsedRealtimeNanos());
- mStepsReported = mTimestampsUserReported.size();
- }
- }
- };
+ public String testWalking() throws Throwable {
+ return runTest(
+ R.string.snsr_step_counter_test_walking,
+ MIN_NUM_STEPS_PER_TEST,
+ false /* vibrate */);
+ }
+
+ public String testStill() throws Throwable {
+ return runTest(
+ R.string.snsr_step_counter_test_still,
+ 0 /* expectedSteps */,
+ true /* vibrate */);
+ }
+
+ public String testWaving() throws Throwable {
+ return runTest(
+ R.string.snsr_step_counter_test_waving,
+ 0 /* expectedSteps */,
+ false /* vibrate */);
+ }
/**
- * @param instructions Instruction to be shown to testers
+ * @param instructionsResId Resource ID containing instruction to be shown to testers
* @param expectedSteps Number of steps expected in this test
- * @param tolerance Number of steps the count can be off by and still pass
* @param vibrate If TRUE, vibration will be concurrent with the test
- * @param onlyWarn If TRUE, only warn the user if the test fails. This
- * option will be removed on a future release of CTS. TODO:
- * remove this option
- * @throws Throwable
*/
- static long[] sVibratePattern = {
- 1000L, 500L, 1000L, 750L, 1000L, 500L, 1000L, 750L, 1000L, 1000L, 500L, 1000L,
- 750L, 1000L, 500L, 1000L
- };
- private void runTest(String instructions, int expectedSteps, int tolerance, boolean vibrate,
- boolean onlyWarn)
+ private String runTest(int instructionsResId, int expectedSteps, boolean vibrate)
throws Throwable {
-
mTimestampsUserReported.clear();
- mTimestampsStepCounter.clear();
- mTimestampsStepDetector.clear();
+ mStepCounterEvents.clear();
+ mStepDetectorEvents.clear();
mMoveDetected = false;
- mCheckForMotion = true;
+ mCheckForMotion = false;
- appendText("Click 'Next' and " + instructions);
+ appendText(instructionsResId);
waitForUser();
- mInitialStepCount = 0;
- mStepsDetected = 0;
- mStepsReported = 0;
+ mCheckForMotion = (expectedSteps > 0);
if (vibrate) {
- vibrate(sVibratePattern);
+ vibrate(VIBRATE_PATTERN);
}
-
- mCheckForMotion = (expectedSteps == 0);
startMeasurements();
+ appendText(R.string.snsr_test_play_sound);
- long testStartTime = System.currentTimeMillis();
- long testTime = 0;
-
- while (testTime < MIN_TEST_TIME_MILLIS) {
- int timeWaitSec = Math.round((MIN_TEST_TIME_MILLIS - testTime) / 1000);
- clearText();
- appendText("Current test: " + instructions);
- appendText(String.format("%d seconds left, %d steps detected, %d reported",
- timeWaitSec, mStepsDetected, mStepsReported), Color.GRAY);
- Thread.sleep(1000);
- testTime = System.currentTimeMillis() - testStartTime;
- }
- clearText();
- appendText("Current test: " + instructions);
- verifyMeasurements(expectedSteps, tolerance, onlyWarn);
- appendText(mERNWarning + "\n" + mSCWarning, Color.YELLOW);
+ Thread.sleep(TimeUnit.SECONDS.toMillis(TEST_DURATION_SECONDS));
mCheckForMotion = false;
- sNumPassedTests++;
- mERNWarning = "";
- mSCWarning = "";
+ playSound();
+
+ return verifyMeasurements(expectedSteps);
}
private void startMeasurements() throws Throwable {
- mSensorStepCounter = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_COUNTER);
if (mSensorStepCounter != null) {
mSensorManager.registerListener(this, mSensorStepCounter,
SensorManager.SENSOR_DELAY_NORMAL);
- } else {
- appendText("Failed test, step counter sensor was not found", Color.RED);
- Assert.fail("Step counter sensor was not found");
}
- mSensorStepDetector = mSensorManager.getDefaultSensor(Sensor.TYPE_STEP_DETECTOR);
if (mSensorStepDetector != null) {
mSensorManager.registerListener(this, mSensorStepDetector,
SensorManager.SENSOR_DELAY_NORMAL);
- } else {
- appendText("Failed test, step detector sensor was not found", Color.RED);
- Assert.fail("Step detector sensor was not found");
}
- mSensorAcceleration = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
- if (mSensorAcceleration != null && mCheckForMotion) {
- mSensorManager.registerListener(this, mSensorAcceleration,
- SensorManager.SENSOR_DELAY_NORMAL);
+ mMovementDetectorHelper = new MovementDetectorHelper(getApplicationContext()) {
+ @Override
+ protected void onMovementDetected() {
+ mMoveDetected = true;
+ }
+ };
+ mMovementDetectorHelper.start();
+ }
+
+ private String verifyMeasurements(int stepsExpected) throws Throwable {
+ mSensorManager.unregisterListener(this);
+ mMovementDetectorHelper.stop();
+
+ if (mCheckForMotion) {
+ Assert.assertTrue(
+ getString(R.string.snsr_movement_expected, mMoveDetected),
+ mMoveDetected);
+ }
+
+ final int userReportedSteps = mTimestampsUserReported.size();
+ String stepsReportedMessage = getString(
+ R.string.snsr_step_counter_expected_steps,
+ stepsExpected,
+ userReportedSteps);
+ Assert.assertFalse(stepsReportedMessage, userReportedSteps < stepsExpected);
+
+ // TODO: split test cases for step detector and counter
+ verifyStepDetectorMeasurements();
+ verifyStepCounterMeasurements();
+ return null;
+ }
+
+ private void verifyStepCounterMeasurements() {
+ final int userReportedSteps = mTimestampsUserReported.size();
+
+ int totalStepsCounted = 0;
+ int initialStepCount = -1;
+ for (TestSensorEvent counterEvent : mStepCounterEvents) {
+ String sensorName = counterEvent.sensor.getName();
+ float[] values = counterEvent.values;
+
+ final int expectedLength = 1;
+ int valuesLength = values.length;
+ String eventLengthMessage = getString(
+ R.string.snsr_event_length,
+ expectedLength,
+ valuesLength,
+ sensorName);
+ Assert.assertEquals(eventLengthMessage, expectedLength, valuesLength);
+
+ int stepValue = (int) values[0];
+ if (initialStepCount == -1) {
+ initialStepCount = stepValue;
+ } else {
+ int stepsCounted = stepValue - initialStepCount;
+ int countDelta = stepsCounted - totalStepsCounted;
+
+ String eventTriggered = getString(
+ R.string.snsr_step_counter_event_changed,
+ countDelta,
+ counterEvent.timestamp);
+ Assert.assertTrue(eventTriggered, countDelta > 0);
+
+ long systemTimestamp = counterEvent.receivedTimestamp;
+ long timestamp = counterEvent.timestamp;
+ long timestampDelta = Math.abs(timestamp - systemTimestamp);
+ String eventTimestampMessage = getString(
+ R.string.snsr_event_time,
+ systemTimestamp,
+ timestamp,
+ timestampDelta,
+ TIMESTAMP_SYNCHRONIZATION_THRESHOLD_NANOS,
+ sensorName);
+ Assert.assertTrue(
+ eventTimestampMessage,
+ timestampDelta < TIMESTAMP_SYNCHRONIZATION_THRESHOLD_NANOS);
+
+ totalStepsCounted = stepsCounted;
+ }
+ }
+
+ int stepsCountedDelta = Math.abs(totalStepsCounted - userReportedSteps);
+ String stepsDeltaMessage = getString(
+ R.string.snsr_step_counter_detected_reported,
+ userReportedSteps,
+ totalStepsCounted,
+ stepsCountedDelta,
+ MAX_STEP_DISCREPANCY);
+ Assert.assertFalse(stepsDeltaMessage, stepsCountedDelta > MAX_STEP_DISCREPANCY);
+
+ int stepCounterLength = mStepCounterEvents.size();
+ for (int i = 0; i < userReportedSteps && i < stepCounterLength; ++i) {
+ long userReportedTimestamp = mTimestampsUserReported.get(i);
+ TestSensorEvent counterEvent = mStepCounterEvents.get(i);
+
+ assertTimestampSynchronization(
+ counterEvent.timestamp,
+ userReportedTimestamp,
+ MAX_TOLERANCE_STEP_TIME_NANOS,
+ counterEvent.sensor.getName());
}
}
- private void verifyMeasurements(int stepsExpected, int tolerance, boolean onlyWarn)
- throws Throwable {
- if (mSensorManager != null) {
- mSensorManager.unregisterListener(this);
+ private void verifyStepDetectorMeasurements() {
+ final int userReportedSteps = mTimestampsUserReported.size();
+
+ int stepsDetected = mStepDetectorEvents.size();
+ int stepsDetectedDelta = Math.abs(stepsDetected - userReportedSteps);
+ String stepsDetectedMessage = getString(
+ R.string.snsr_step_detector_detected_reported,
+ userReportedSteps,
+ stepsDetected,
+ stepsDetectedDelta,
+ MAX_STEP_DISCREPANCY);
+ Assert.assertFalse(stepsDetectedMessage, stepsDetectedDelta > MAX_STEP_DISCREPANCY);
+
+ for (TestSensorEvent detectorEvent : mStepDetectorEvents) {
+ String sensorName = detectorEvent.sensor.getName();
+ float[] values = detectorEvent.values;
+
+ final int expectedLength = 1;
+ int valuesLength = values.length;
+ String eventLengthMessage = getString(
+ R.string.snsr_event_length,
+ expectedLength,
+ valuesLength,
+ sensorName);
+ Assert.assertEquals(eventLengthMessage, expectedLength, valuesLength);
+
+ final float expectedValue = 1.0f;
+ float value0 = values[0];
+ String eventValueMessage =
+ getString(R.string.snsr_event_value, expectedValue, value0, sensorName);
+ Assert.assertEquals(eventValueMessage, expectedValue, value0);
}
- Assert.assertFalse(String.format("You need to report at least %d steps", stepsExpected),
- mStepsReported < stepsExpected);
- double maxStepReportTime = compareTimestamps();
- Assert.assertTrue(String.format("Step report time %f longer than %d seconds",
- maxStepReportTime, MAX_TOLERANCE_STEP_TIME_LATENCY_SECONDS),
- maxStepReportTime < MAX_TOLERANCE_STEP_TIME_LATENCY_SECONDS);
-
- if (mCheckForMotion && !mMoveDetected) {
- String message = "Movement is needed during this test";
-
- warnOrAssert(onlyWarn, message);
- }
-
- if (Math.abs(mStepsDetected - mStepsReported) > tolerance) {
- String message = String.format("Step count test: "
- + "detected %d steps but %d were expected (to within %d steps)",
- mStepsDetected, mStepsReported, tolerance);
- warnOrAssert(onlyWarn, message);
- }
-
- appendText("PASS step count test", Color.GREEN);
-
- if (Math.abs(mTimestampsStepDetector.size() - mStepsReported) > tolerance) {
- String message = String.format("Step detector test: "
- + "detected %d steps but %d were expected (to within %d steps)",
- mTimestampsStepDetector.size(), mStepsReported, tolerance);
- warnOrAssert(onlyWarn, message);
- }
-
- appendText("PASS step detection test", Color.GREEN);
-
- logSuccess();
+ // TODO: verify correlation of events with steps from user
}
+ @Override
public final void onAccuracyChanged(Sensor sensor, int accuracy) {
}
- private void warnOrAssert(boolean onlyWarn, String message) throws Throwable {
- if (onlyWarn) {
- appendText("WARNING: " + message, Color.YELLOW);
- } else {
- Assert.fail("FAILED " + message);
- }
- }
-
- String mERNWarning = "";
- String mSCWarning = "";
-
- public long checkTimestamp(long eventTimestamp) {
- long timestamp = SystemClock.elapsedRealtimeNanos();
- if (Math.abs(timestamp - eventTimestamp) > MIN_TEST_TIME_MILLIS * 1e6) {
- // elapsedRealtimeNanos will lead to test failure, warn for now
- mERNWarning = "WARNING: elapsedRealtimeNanos is significantly different than "
- + " sensor event timestamps. This should be rectified.";
- } else {
- timestamp = eventTimestamp;
- }
- return timestamp;
- }
-
- public void onStepCounterChanged(SensorEvent event) throws Throwable {
- int steps = (int) event.values[0] - mInitialStepCount;
-
- if (mInitialStepCount == 0) { // set the initial number of steps
- mInitialStepCount = steps;
- } else if (steps > 0) {
- mTimestampsStepCounter.add(checkTimestamp(event.timestamp));
- Assert.assertTrue(String.format("Step counter did not increase monotonically: "
- + "%d changed to %d", mStepsDetected, steps), steps >= mStepsDetected);
- mStepsDetected = steps;
- } else {
- Assert.fail("Step Counter change called when no steps reported");
- }
- }
-
- public void onStepDetectorChanged(SensorEvent event) throws Throwable {
- Assert.assertEquals("Incorrect value[0] in step detector event", event.values[0], 1.0f);
- mTimestampsStepDetector.add(checkTimestamp(event.timestamp));
- }
-
public final void onSensorChanged(SensorEvent event) {
+ long elapsedRealtimeNanos = SystemClock.elapsedRealtimeNanos();
int type = event.sensor.getType();
- try {
- if (type == Sensor.TYPE_STEP_COUNTER) {
- onStepCounterChanged(event);
- } else if (type == Sensor.TYPE_STEP_DETECTOR) {
- onStepDetectorChanged(event);
- } else if (type == Sensor.TYPE_ACCELEROMETER) {
- mMoveDetected = SensorCtsHelper.checkMovementDetection(event);
- } else {
- Assert.fail("Sensor type " + type + " called when not registered for by this test");
- }
- } catch (Throwable ae) {
- mSCWarning = ae.getMessage();
- }
- }
+ if (type == Sensor.TYPE_STEP_COUNTER) {
+ mStepCounterEvents.add(new TestSensorEvent(event, elapsedRealtimeNanos));
+ String counterMessage = getString(
+ R.string.snsr_step_counter_event,
+ elapsedRealtimeNanos,
+ (int) event.values[0]);
+ appendText(counterMessage);
+ } else if (type == Sensor.TYPE_STEP_DETECTOR) {
+ mStepDetectorEvents.add(new TestSensorEvent(event, elapsedRealtimeNanos));
+ appendText(getString(R.string.snsr_step_detector_event, elapsedRealtimeNanos));
- protected double compareTimestamps() {
- double timeDeltaInSec;
- double maxTimeDeltaInSec = 0;
- StringBuilder reportLine = new StringBuilder();
- reportLine.append("Reported Step: Step Detector / Counter Latency (sec)\n");
- for (int eventCounter = 0; eventCounter < mStepsReported; eventCounter++) {
- reportLine.append((eventCounter + 1) + ": ");
-
- if (eventCounter < mTimestampsStepDetector.size()) {
- timeDeltaInSec = (mTimestampsStepDetector.get(eventCounter)
- - mTimestampsUserReported.get(eventCounter)) / NANOSECONDS_IN_SEC;
- maxTimeDeltaInSec = Math.max(maxTimeDeltaInSec, Math.abs(timeDeltaInSec));
- reportLine.append(String.format("%.2f", timeDeltaInSec));
- } else {
- reportLine.append("--");
- }
-
- reportLine.append(" / ");
- if (eventCounter < mTimestampsStepCounter.size()) {
- timeDeltaInSec = (mTimestampsStepCounter.get(eventCounter)
- - mTimestampsUserReported.get(eventCounter)) / NANOSECONDS_IN_SEC;
- maxTimeDeltaInSec = Math.max(maxTimeDeltaInSec, Math.abs(timeDeltaInSec));
- reportLine.append(String.format("%.2f", timeDeltaInSec));
- } else {
- reportLine.append("--");
- }
- reportLine.append("\n");
}
- appendText(reportLine.toString(), Color.GRAY);
-
- return maxTimeDeltaInSec;
- }
-
- protected void vibrate(long[] pattern) {
- Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
- if(v==null) {
- appendText("Cannot access vibrator for this test...continuing anyway", Color.YELLOW);
- } else {
- v.vibrate(pattern, -1);
- }
- }
-
- @Override
- protected void onResume() {
- super.onResume();
- if (mSensorManager == null) {
- mSensorManager = (SensorManager) getApplicationContext()
- .getSystemService(Context.SENSOR_SERVICE);
- }
-
- if (mSensorStepCounter != null) {
- mSensorManager.registerListener(this, mSensorStepCounter,
- SensorManager.SENSOR_DELAY_NORMAL);
- }
- if (mSensorStepDetector != null) {
- mSensorManager.registerListener(this, mSensorStepDetector,
- SensorManager.SENSOR_DELAY_NORMAL);
- }
- if (mSensorAcceleration != null && mCheckForMotion) {
- mSensorManager.registerListener(this, mSensorAcceleration,
- SensorManager.SENSOR_DELAY_NORMAL);
- }
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- if (mSensorManager != null) {
- mSensorManager.unregisterListener(this);
- }
+ // TODO: with delayed assertions check events of other types are tracked
}
}
diff --git a/suite/cts/deviceTests/videoperf/src/com/android/cts/videoperf/VideoEncoderDecoderTest.java b/suite/cts/deviceTests/videoperf/src/com/android/cts/videoperf/VideoEncoderDecoderTest.java
index 397b0c6..fe28a96 100644
--- a/suite/cts/deviceTests/videoperf/src/com/android/cts/videoperf/VideoEncoderDecoderTest.java
+++ b/suite/cts/deviceTests/videoperf/src/com/android/cts/videoperf/VideoEncoderDecoderTest.java
@@ -68,6 +68,7 @@
private int mBufferHeight;
private int mVideoWidth;
private int mVideoHeight;
+ private int mFrameRate;
private Vector<ByteBuffer> mEncodedOutputBuffer;
// check this many pixels per each decoded frame
@@ -155,6 +156,7 @@
infoEnc.mSupportSemiPlanar ? CodecCapabilities.COLOR_FormatYUV420SemiPlanar :
CodecCapabilities.COLOR_FormatYUV420Planar);
format.setInteger(MediaFormat.KEY_FRAME_RATE, infoEnc.mFps);
+ mFrameRate = infoEnc.mFps;
format.setInteger(MediaFormat.KEY_I_FRAME_INTERVAL, KEY_I_FRAME_INTERVAL);
double encodingTime = runEncoder(VIDEO_AVC, format, TOTAL_FRAMES);
// re-initialize format for decoder
@@ -312,8 +314,9 @@
}
}
int size = mVideoHeight * mVideoWidth * 3 /2;
+ long ptsUsec = computePresentationTime(frameCount);
- codec.queueInputBuffer(index, 0 /* offset */, size, 0 /* timeUs */, flags);
+ codec.queueInputBuffer(index, 0 /* offset */, size, ptsUsec /* timeUs */, flags);
if (VERBOSE && (frameCount == 0)) {
printByteArray("Y ", mYBuffer.array(), 0, 20);
printByteArray("UV ", mUVBuffer.array(), 0, 20);
@@ -602,4 +605,11 @@
builder.deleteCharAt(builder.length() - 1);
Log.i(TAG, builder.toString());
}
+
+ /**
+ * Generates the presentation time for frame N, in microseconds.
+ */
+ private long computePresentationTime(int frameIndex) {
+ return 132 + frameIndex * 1000000L / mFrameRate;
+ }
}
diff --git a/tests/src/android/rsg/cts/graphics_runner.rs b/tests/src/android/rsg/cts/graphics_runner.rs
deleted file mode 100644
index 18e1f76..0000000
--- a/tests/src/android/rsg/cts/graphics_runner.rs
+++ /dev/null
@@ -1,45 +0,0 @@
-// 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(void) {
- rsDebug("Running script", 0);
- return 0;
-}
diff --git a/tests/src/android/rsg/cts/shared.rsh b/tests/src/android/rsg/cts/shared.rsh
deleted file mode 100644
index f33b708..0000000
--- a/tests/src/android/rsg/cts/shared.rsh
+++ /dev/null
@@ -1,27 +0,0 @@
-#pragma version(1)
-#pragma rs java_package_name(android.renderscriptgraphics.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/rsg/cts/structs.rsh b/tests/src/android/rsg/cts/structs.rsh
deleted file mode 100755
index e7d2efd..0000000
--- a/tests/src/android/rsg/cts/structs.rsh
+++ /dev/null
@@ -1,56 +0,0 @@
-// 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/src/android/rsg/cts/stub_activity.rs b/tests/src/android/rsg/cts/stub_activity.rs
deleted file mode 100644
index f5efce6..0000000
--- a/tests/src/android/rsg/cts/stub_activity.rs
+++ /dev/null
@@ -1,35 +0,0 @@
-// 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.
-
-#pragma version(1)
-
-// Tell which java package name the reflected files should belong to
-#pragma rs java_package_name(android.renderscriptgraphics.cts)
-
-// Built-in header with graphics API's
-#include "rs_graphics.rsh"
-
-int root(void) {
-
- // Clear the background color
- rsgClearColor(0.0f, 0.0f, 0.0f, 0.0f);
- // Tell the runtime what the font color should be
- rsgFontColor(1.0f, 1.0f, 1.0f, 1.0f);
- // Introuduce ourselves to the world
- rsgDrawText("Hello World!", 50, 50);
-
- // Return value tells RS roughly how often to redraw
- // in this case 20 ms
- return 20;
-}
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureResultTest.java b/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureResultTest.java
index 93e5038..ed75deb 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureResultTest.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/CaptureResultTest.java
@@ -21,11 +21,9 @@
import android.hardware.camera2.CameraCaptureSession;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraDevice;
-import android.hardware.camera2.CameraMetadata;
import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.CaptureResult;
import android.hardware.camera2.TotalCaptureResult;
-import android.hardware.camera2.cts.helpers.CameraSessionUtils;
import android.media.Image;
import android.media.ImageReader;
import android.os.SystemClock;
@@ -41,7 +39,12 @@
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
public class CaptureResultTest extends Camera2AndroidTestCase {
private static final String TAG = "CaptureResultTest";
@@ -129,6 +132,106 @@
}
/**
+ * Check partial results conform to its specification.
+ * <p>
+ * The test is skipped if partial result is not supported on device. </p>
+ * <p>Test summary:<ul>
+ * <li>1. Number of partial results is less than or equal to
+ * {@link CameraCharacteristics#REQUEST_PARTIAL_RESULT_COUNT}.
+ * <li>2. Each key appeared in partial results must be unique across all partial results.
+ * <li>3. All keys appeared in partial results must be present in TotalCaptureResult
+ * <li>4. Also test onCaptureComplete callback always happen after onCaptureStart or
+ * onCaptureProgressed callbacks.
+ * </ul></p>
+ */
+ public void testPartialResult() throws Exception {
+ final int NUM_FRAMES_TESTED = 30;
+ final int WAIT_FOR_RESULT_TIMOUT_MS = 2000;
+ for (String id : mCameraIds) {
+ try {
+ openDevice(id);
+
+ // Skip the test if partial result is not supported
+ int partialResultCount = mStaticInfo.getPartialResultCount();
+ if (partialResultCount == 1) {
+ continue;
+ }
+
+ // Create image reader and surface.
+ Size size = mOrderedPreviewSizes.get(0);
+ createDefaultImageReader(size, ImageFormat.YUV_420_888, MAX_NUM_IMAGES,
+ new ImageDropperListener());
+
+ // Configure output streams.
+ List<Surface> outputSurfaces = new ArrayList<Surface>(1);
+ outputSurfaces.add(mReaderSurface);
+ createSession(outputSurfaces);
+
+ CaptureRequest.Builder requestBuilder =
+ mCamera.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW);
+ assertNotNull("Failed to create capture request", requestBuilder);
+ requestBuilder.addTarget(mReaderSurface);
+ TotalAndPartialResultListener listener =
+ new TotalAndPartialResultListener();
+
+ // Start capture
+ for (Integer frame = 0; frame < NUM_FRAMES_TESTED; frame++) {
+ // Set a different tag for each request so the listener can group
+ // partial results by each request
+ requestBuilder.setTag(frame);
+ startCapture(
+ requestBuilder.build(), /*repeating*/false,
+ listener, mHandler);
+ }
+
+ // Verify capture results
+ for (int frame = 0; frame < NUM_FRAMES_TESTED; frame++) {
+ Pair<TotalCaptureResult, List<CaptureResult>> resultPair =
+ listener.getCaptureResultPairs(WAIT_FOR_RESULT_TIMOUT_MS);
+ if (resultPair.second == null) {
+ // HAL only sends total result is legal
+ continue;
+ }
+ mCollector.expectLessOrEqual("Too many partial results",
+ partialResultCount, resultPair.second.size());
+ Set<CaptureResult.Key<?>> appearedPartialKeys =
+ new HashSet<CaptureResult.Key<?>>();
+ for (CaptureResult partialResult : resultPair.second) {
+ List<CaptureResult.Key<?>> partialKeys = partialResult.getKeys();
+ mCollector.expectValuesUnique("Partial result keys: ", partialKeys);
+ for (CaptureResult.Key<?> key : partialKeys) {
+ mCollector.expectTrue(
+ String.format("Key %s appears in multiple partial results",
+ key.getName()),
+ !appearedPartialKeys.contains(key));
+ }
+ appearedPartialKeys.addAll(partialKeys);
+ }
+ List<CaptureResult.Key<?>> totalResultKeys = resultPair.first.getKeys();
+ mCollector.expectTrue(
+ "TotalCaptureResult should be a super set of partial capture results",
+ totalResultKeys.containsAll(appearedPartialKeys));
+ }
+
+ int errorCode = listener.getErrorCode();
+ if ((errorCode & TotalAndPartialResultListener.ERROR_DUPLICATED_REQUEST) != 0) {
+ mCollector.addMessage("Listener received multiple onCaptureComplete" +
+ " callback for the same request");
+ }
+ if ((errorCode & TotalAndPartialResultListener.ERROR_WRONG_CALLBACK_ORDER) != 0) {
+ mCollector.addMessage("Listener received onCaptureStart or" +
+ " onCaptureProgressed after onCaptureComplete");
+ }
+
+ stopCapture(/*fast*/false);
+ } finally {
+ closeDevice(id);
+ closeDefaultImageReader();
+ }
+ }
+ }
+
+ /**
* Check that the timestamps passed in the results, buffers, and capture callbacks match for
* a single request, and increase monotonically
*/
@@ -394,6 +497,96 @@
}
/**
+ * A capture listener implementation for collecting both partial and total results.
+ *
+ * <p> This is not a full-blown class and has some implicit assumptions. The class groups
+ * capture results by capture request, so the user must guarantee each request this listener
+ * is listening is unique. This class is not thread safe, so don't attach an instance object
+ * with multiple handlers.</p>
+ * */
+ private static class TotalAndPartialResultListener
+ extends CameraCaptureSession.CaptureListener {
+ static final int ERROR_DUPLICATED_REQUEST = 1 << 0;
+ static final int ERROR_WRONG_CALLBACK_ORDER = 1 << 1;
+
+ private final LinkedBlockingQueue<Pair<TotalCaptureResult, List<CaptureResult>> > mQueue =
+ new LinkedBlockingQueue<>();
+ private HashMap<CaptureRequest, List<CaptureResult>> mPartialResultsMap =
+ new HashMap<CaptureRequest, List<CaptureResult>>();
+ private HashSet<CaptureRequest> completedRequests = new HashSet<>();
+ private int errorCode = 0;
+
+ @Override
+ public void onCaptureStarted(
+ CameraCaptureSession session, CaptureRequest request, long timestamp)
+ {
+ checkCallbackOrder(request);
+ createMapEntryIfNecessary(request);
+ }
+
+ @Override
+ public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request,
+ TotalCaptureResult result) {
+ try {
+ List<CaptureResult> partialResultsList = mPartialResultsMap.get(request);
+ if (partialResultsList == null) {
+ Log.w(TAG, "onCaptureCompleted: unknown request");
+ }
+ mQueue.put(new Pair<TotalCaptureResult, List<CaptureResult>>(
+ result, partialResultsList));
+ mPartialResultsMap.remove(request);
+ boolean newEntryAdded = completedRequests.add(request);
+ if (!newEntryAdded) {
+ Integer frame = (Integer) request.getTag();
+ Log.e(TAG, "Frame " + frame + "ERROR_DUPLICATED_REQUEST");
+ errorCode |= ERROR_DUPLICATED_REQUEST;
+ }
+ } catch (InterruptedException e) {
+ throw new UnsupportedOperationException(
+ "Can't handle InterruptedException in onCaptureCompleted");
+ }
+ }
+
+ @Override
+ public void onCaptureProgressed(CameraCaptureSession session, CaptureRequest request,
+ CaptureResult partialResult) {
+ createMapEntryIfNecessary(request);
+ List<CaptureResult> partialResultsList = mPartialResultsMap.get(request);
+ partialResultsList.add(partialResult);
+ }
+
+ private void createMapEntryIfNecessary(CaptureRequest request) {
+ if (!mPartialResultsMap.containsKey(request)) {
+ // create a new entry in the map
+ mPartialResultsMap.put(request, new ArrayList<CaptureResult>());
+ }
+ }
+
+ private void checkCallbackOrder(CaptureRequest request) {
+ if (completedRequests.contains(request)) {
+ Integer frame = (Integer) request.getTag();
+ Log.e(TAG, "Frame " + frame + "ERROR_WRONG_CALLBACK_ORDER");
+ errorCode |= ERROR_WRONG_CALLBACK_ORDER;
+ }
+ }
+
+ public Pair<TotalCaptureResult, List<CaptureResult>> getCaptureResultPairs(long timeout) {
+ try {
+ Pair<TotalCaptureResult, List<CaptureResult>> result =
+ mQueue.poll(timeout, TimeUnit.MILLISECONDS);
+ assertNotNull("Wait for a capture result timed out in " + timeout + "ms", result);
+ return result;
+ } catch (InterruptedException e) {
+ throw new UnsupportedOperationException("Unhandled interrupted exception", e);
+ }
+ }
+
+ public int getErrorCode() {
+ return errorCode;
+ }
+ }
+
+ /**
* TODO: Use CameraCharacteristics.getAvailableCaptureResultKeys() once we can filter out
* @hide keys.
*
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/helpers/CameraErrorCollector.java b/tests/tests/hardware/src/android/hardware/camera2/cts/helpers/CameraErrorCollector.java
index 9073ec5..700abb0 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/helpers/CameraErrorCollector.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/helpers/CameraErrorCollector.java
@@ -215,6 +215,34 @@
}
/**
+ * Check that the {@code actual} value is less than the {@code expected} value.
+ *
+ * @param msg Message to be logged when check fails.
+ * @param expected The expected value to check that the actual value is less than.
+ * @param actual Actual value to check.
+ * @return {@code true} if {@code actual} is less than {@code expected}.
+ */
+ public <T extends Comparable<? super T>> boolean expectLess(String msg, T expected,
+ T actual) {
+ return expectTrue(String.format("%s: (expected = %s was not greater than actual = %s) ",
+ msg, expected, actual), actual.compareTo(expected) < 0);
+ }
+
+ /**
+ * Check that the {@code actual} value is less than or equal to the {@code expected} value.
+ *
+ * @param msg Message to be logged when check fails.
+ * @param expected The expected value to check that the actual value is less than or equal to.
+ * @param actual Actual value to check.
+ * @return {@code true} if {@code actual} is less than or equal to {@code expected}.
+ */
+ public <T extends Comparable<? super T>> boolean expectLessOrEqual(String msg, T expected,
+ T actual) {
+ return expectTrue(String.format("%s: (expected = %s was not greater than actual = %s) ",
+ msg, expected, actual), actual.compareTo(expected) <= 0);
+ }
+
+ /**
* Check if the two float values are equal with given error tolerance.
*
* @param msg Message to be logged when check fails.
@@ -645,6 +673,6 @@
*/
public <T> void expectValuesUnique(String msg, List<T> list) {
Set<T> sizeSet = new HashSet<T>(list);
- expectTrue(msg + " each size must be distinct", sizeSet.size() == list.size());
+ expectTrue(msg + " each element must be distinct", sizeSet.size() == list.size());
}
}
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/helpers/StaticMetadata.java b/tests/tests/hardware/src/android/hardware/camera2/cts/helpers/StaticMetadata.java
index d2d3248..4a51221 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/helpers/StaticMetadata.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/helpers/StaticMetadata.java
@@ -251,6 +251,21 @@
}
/**
+ * Get the maximum number of partial result a request can expect
+ *
+ * @return 1 if partial result is not supported.
+ * a integer value larger than 1 if partial result is supported.
+ */
+ public int getPartialResultCount() {
+ Integer value = mCharacteristics.get(CameraCharacteristics.REQUEST_PARTIAL_RESULT_COUNT);
+ if (value == null) {
+ // Optional key. Default value is 1 if key is missing.
+ return 1;
+ }
+ return value;
+ }
+
+ /**
* Get the exposure time value and clamp to the range if needed.
*
* @param exposure Input exposure time value to check.
diff --git a/tests/tests/hardware/src/android/hardware/camera2/cts/testcases/Camera2AndroidTestCase.java b/tests/tests/hardware/src/android/hardware/camera2/cts/testcases/Camera2AndroidTestCase.java
index 56f0dba..ed75d6c 100644
--- a/tests/tests/hardware/src/android/hardware/camera2/cts/testcases/Camera2AndroidTestCase.java
+++ b/tests/tests/hardware/src/android/hardware/camera2/cts/testcases/Camera2AndroidTestCase.java
@@ -156,6 +156,8 @@
waitForState(BlockingSessionListener.SESSION_READY, CAMERA_IDLE_TIMEOUT_MS);
} else {
mCameraSession.close();
+ mCameraSessionListener.getStateWaiter().
+ waitForState(BlockingSessionListener.SESSION_CLOSED, CAMERA_IDLE_TIMEOUT_MS);
}
}
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/MovementDetectorHelper.java b/tests/tests/hardware/src/android/hardware/cts/helpers/MovementDetectorHelper.java
new file mode 100644
index 0000000..0eb1141
--- /dev/null
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/MovementDetectorHelper.java
@@ -0,0 +1,110 @@
+/*
+ * 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 android.hardware.cts.helpers;
+
+import junit.framework.Assert;
+
+import android.content.Context;
+import android.hardware.Sensor;
+import android.hardware.SensorEvent;
+import android.hardware.SensorEventListener;
+import android.hardware.SensorManager;
+
+/**
+ * Helper class that provides a way to identify if movement has been detected in the device.
+ *
+ * Notes:
+ * Alpha is calculated as:
+ * t / ( t + dT)
+ * Where
+ * t - low-pass filter's time-constant
+ * dT - event delivery rate
+ */
+public abstract class MovementDetectorHelper implements SensorEventListener {
+ private static final float MOVEMENT_DETECTION_ACCELERATION_THRESHOLD = 4.0f;
+ private static final float ALPHA = 0.8f;
+
+ private final float[] mGravity = {0.0f, 0.0f, 0.0f};
+
+ private final SensorManager mSensorManager;
+ private final Sensor mAccelerometer;
+
+ private boolean mInitialized;
+
+ public MovementDetectorHelper(Context context) {
+ mSensorManager = (SensorManager) context.getSystemService(Context.SENSOR_SERVICE);
+ Assert.assertNotNull("SensorManager", mSensorManager);
+
+ mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
+ if (mAccelerometer == null) {
+ throw new SensorNotSupportedException(Sensor.TYPE_ACCELEROMETER);
+ }
+ }
+
+ public synchronized void start() {
+ if (mInitialized) {
+ return;
+ }
+
+ mInitialized = mSensorManager
+ .registerListener(this, mAccelerometer,SensorManager.SENSOR_DELAY_NORMAL);
+ Assert.assertTrue(mInitialized);
+ }
+
+ public synchronized void stop() {
+ if (!mInitialized) {
+ return;
+ }
+
+ mSensorManager.unregisterListener(this);
+ mInitialized = false;
+ }
+
+ protected abstract void onMovementDetected();
+
+ @Override
+ public void onAccuracyChanged(Sensor sensor, int accuracy) {}
+
+ @Override
+ public void onSensorChanged(SensorEvent event) {
+ float[] linearAcceleration = {0.0f, 0.0f, 0.0f};
+
+ if (mGravity[0] == 0f && mGravity[2] == 0f) {
+ mGravity[0] = event.values[0];
+ mGravity[1] = event.values[1];
+ mGravity[2] = event.values[2];
+ } else {
+ // Isolate the force of gravity with the low-pass filter.
+ mGravity[0] = ALPHA * mGravity[0] + (1 - ALPHA) * event.values[0];
+ mGravity[1] = ALPHA * mGravity[1] + (1 - ALPHA) * event.values[1];
+ mGravity[2] = ALPHA * mGravity[2] + (1 - ALPHA) * event.values[2];
+ }
+
+ // Remove the gravity contribution with the high-pass filter.
+ linearAcceleration[0] = event.values[0] - mGravity[0];
+ linearAcceleration[1] = event.values[1] - mGravity[1];
+ linearAcceleration[2] = event.values[2] - mGravity[2];
+
+ float totalAcceleration = Math.abs(linearAcceleration[0])
+ + Math.abs(linearAcceleration[1])
+ + Math.abs(linearAcceleration[2]);
+
+ if (totalAcceleration > MOVEMENT_DETECTION_ACCELERATION_THRESHOLD) {
+ onMovementDetected();
+ }
+ }
+}
diff --git a/tests/tests/hardware/src/android/hardware/cts/helpers/SensorCtsHelper.java b/tests/tests/hardware/src/android/hardware/cts/helpers/SensorCtsHelper.java
index 9613b29..b3f9fec 100644
--- a/tests/tests/hardware/src/android/hardware/cts/helpers/SensorCtsHelper.java
+++ b/tests/tests/hardware/src/android/hardware/cts/helpers/SensorCtsHelper.java
@@ -17,10 +17,7 @@
import android.content.Context;
import android.hardware.Sensor;
-import android.hardware.SensorEvent;
import android.hardware.SensorManager;
-import android.media.AudioManager;
-import android.media.ToneGenerator;
import java.util.ArrayList;
import java.util.Collection;
@@ -34,7 +31,7 @@
//TODO: Refactor this class and SensorTestInformation into several more well defined helper classes
public class SensorCtsHelper {
- private static long NANOS_PER_MILLI = 1000000;
+ private static final long NANOS_PER_MILLI = 1000000;
/**
* Private constructor for static class.
@@ -251,45 +248,4 @@
}
return sensorManager;
}
-
- public static void beep(int tone) {
- ToneGenerator mToneGenerator = new ToneGenerator(AudioManager.STREAM_NOTIFICATION, 100);
- mToneGenerator.startTone(tone);
- }
-
- private final static float mAccelerationThresholdForMoveDetection = 4.0f;
- private static float[] mGravity = {0.0f, 0.0f, 0.0f};
- public static boolean checkMovementDetection(SensorEvent event) {
- // Alpha is calculated as t / (t + dT),
- // where t is the low-pass filter's time-constant and
- // dT is the event delivery rate.
- boolean mMoveDetected = false;
- final float alpha = 0.8f;
- float[] linear_acceleration = {0.0f, 0.0f, 0.0f};
-
- if (mGravity[0] == 0f && mGravity[2] == 0f) {
- mGravity[0] = event.values[0];
- mGravity[1] = event.values[1];
- mGravity[2] = event.values[2];
- } else {
- // Isolate the force of gravity with the low-pass filter.
- mGravity[0] = alpha * mGravity[0] + (1 - alpha) * event.values[0];
- mGravity[1] = alpha * mGravity[1] + (1 - alpha) * event.values[1];
- mGravity[2] = alpha * mGravity[2] + (1 - alpha) * event.values[2];
- }
-
- // Remove the gravity contribution with the high-pass filter.
- linear_acceleration[0] = event.values[0] - mGravity[0];
- linear_acceleration[1] = event.values[1] - mGravity[1];
- linear_acceleration[2] = event.values[2] - mGravity[2];
-
- float totalAcceleration = Math.abs(linear_acceleration[0])
- + Math.abs(linear_acceleration[1])
- + Math.abs(linear_acceleration[2]);
-
- if (totalAcceleration > mAccelerationThresholdForMoveDetection) {
- mMoveDetected = true;
- }
- return mMoveDetected;
- }
}
diff --git a/tests/tests/media/src/android/media/cts/Vp8CodecTestBase.java b/tests/tests/media/src/android/media/cts/Vp8CodecTestBase.java
index 54e2ca9..27c3b61 100644
--- a/tests/tests/media/src/android/media/cts/Vp8CodecTestBase.java
+++ b/tests/tests/media/src/android/media/cts/Vp8CodecTestBase.java
@@ -53,7 +53,7 @@
public class Vp8CodecTestBase extends AndroidTestCase {
protected static final String TAG = "VP8CodecTestBase";
- private static final String VP8_MIME = "video/x-vnd.on2.vp8";
+ protected static final String VP8_MIME = "video/x-vnd.on2.vp8";
private static final String VPX_SW_DECODER_NAME = "OMX.google.vp8.decoder";
private static final String VPX_SW_ENCODER_NAME = "OMX.google.vp8.encoder";
private static final String OMX_SW_CODEC_PREFIX = "OMX.google";
@@ -93,6 +93,29 @@
}
/**
+ * Returns the first codec capable of encoding the specified MIME type, or null if no
+ * match was found.
+ */
+ protected static MediaCodecInfo selectCodec(String mimeType) {
+ int numCodecs = MediaCodecList.getCodecCount();
+ for (int i = 0; i < numCodecs; i++) {
+ MediaCodecInfo codecInfo = MediaCodecList.getCodecInfoAt(i);
+
+ if (!codecInfo.isEncoder()) {
+ continue;
+ }
+
+ String[] types = codecInfo.getSupportedTypes();
+ for (int j = 0; j < types.length; j++) {
+ if (types[j].equalsIgnoreCase(mimeType)) {
+ return codecInfo;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
* VP8 codec properties generated by getVp8CodecProperties() function.
*/
private class CodecProperties {
diff --git a/tests/tests/media/src/android/media/cts/Vp8EncoderTest.java b/tests/tests/media/src/android/media/cts/Vp8EncoderTest.java
index c4fe4bb..10ad8cb 100644
--- a/tests/tests/media/src/android/media/cts/Vp8EncoderTest.java
+++ b/tests/tests/media/src/android/media/cts/Vp8EncoderTest.java
@@ -17,6 +17,7 @@
package android.media.cts;
import android.media.MediaCodec;
+import android.media.MediaCodecInfo;
import android.util.Log;
import com.android.cts.media.R;
@@ -79,6 +80,12 @@
* Also checks the average bitrate is within MAX_BITRATE_VARIATION of the target value.
*/
public void testBasic() throws Exception {
+ MediaCodecInfo codecInfo = selectCodec(VP8_MIME);
+ if (codecInfo == null) {
+ Log.w(TAG, "Codec " + VP8_MIME + " not supported. Return from testBasic.");
+ return;
+ }
+
int encodeSeconds = 9;
for (int targetBitrate : TEST_BITRATES_SET) {
@@ -112,6 +119,12 @@
* does not change much for two different ways of the encoder call.
*/
public void testAsyncEncoding() throws Exception {
+ MediaCodecInfo codecInfo = selectCodec(VP8_MIME);
+ if (codecInfo == null) {
+ Log.w(TAG, "Codec " + VP8_MIME + " not supported. Return from testAsyncEncoding.");
+ return;
+ }
+
int encodeSeconds = 9;
// First test the encoder running in a looper thread with buffer callbacks enabled.
@@ -173,6 +186,12 @@
* The test does not verify the output stream.
*/
public void testSyncFrame() throws Exception {
+ MediaCodecInfo codecInfo = selectCodec(VP8_MIME);
+ if (codecInfo == null) {
+ Log.w(TAG, "Codec " + VP8_MIME + " not supported. Return from testSyncFrame.");
+ return;
+ }
+
int encodeSeconds = 9;
EncoderOutputStreamParameters params = getDefaultEncodingParameters(
@@ -216,7 +235,13 @@
* Run the the encoder for 12 seconds. Request changes to the
* bitrate after 6 seconds and ensure the encoder responds.
*/
- public void testDynamicBitrateChange() throws Exception {
+ public void testDynamicBitrateChange() throws Exception {
+ MediaCodecInfo codecInfo = selectCodec(VP8_MIME);
+ if (codecInfo == null) {
+ Log.w(TAG, "Codec " + VP8_MIME + " not supported. Return from testDynamicBitrateChange.");
+ return;
+ }
+
int encodeSeconds = 12; // Encoding sequence duration in seconds.
int[] bitrateTargetValues = { 400000, 800000 }; // List of bitrates to test.
@@ -280,6 +305,12 @@
* Also compares average and minimum PSNR of HW codec with PSNR values of reference SW codec.
*/
public void testEncoderQuality() throws Exception {
+ MediaCodecInfo codecInfo = selectCodec(VP8_MIME);
+ if (codecInfo == null) {
+ Log.w(TAG, "Codec " + VP8_MIME + " not supported. Return from testEncoderQuality.");
+ return;
+ }
+
int encodeSeconds = 9; // Encoding sequence duration in seconds for each bitrate.
double[] psnrPlatformCodecAverage = new double[TEST_BITRATES_SET.length];
double[] psnrPlatformCodecMin = new double[TEST_BITRATES_SET.length];
diff --git a/tests/tests/print/src/android/print/cts/PageRangeAdjustmentTest.java b/tests/tests/print/src/android/print/cts/PageRangeAdjustmentTest.java
index 8351d56..524c83d 100644
--- a/tests/tests/print/src/android/print/cts/PageRangeAdjustmentTest.java
+++ b/tests/tests/print/src/android/print/cts/PageRangeAdjustmentTest.java
@@ -604,12 +604,15 @@
"com.android.printspooler:id/range_options_spinner"));
pagesSpinner.click();
- UiObject rangeOption = getUiDevice().findObject(new UiSelector().text("Range"));
+ UiObject rangeOption = getUiDevice().findObject(new UiSelector().textContains("Range"));
rangeOption.click();
UiObject pagesEditText = getUiDevice().findObject(new UiSelector().resourceId(
"com.android.printspooler:id/page_range_edittext"));
pagesEditText.setText(pages);
+
+ // Hide the keyboard.
+ getUiDevice().pressBack();
}
private PrinterDiscoverySessionCallbacks createMockFirstPrinterDiscoverySessionCallbacks() {
diff --git a/tests/tests/print/src/android/print/cts/PrinterDiscoverySessionLifecycleTest.java b/tests/tests/print/src/android/print/cts/PrinterDiscoverySessionLifecycleTest.java
index e17dda5..7ec12c6 100644
--- a/tests/tests/print/src/android/print/cts/PrinterDiscoverySessionLifecycleTest.java
+++ b/tests/tests/print/src/android/print/cts/PrinterDiscoverySessionLifecycleTest.java
@@ -39,6 +39,7 @@
import android.printservice.PrintJob;
import android.printservice.PrinterDiscoverySession;
+import junit.framework.AssertionFailedError;
import org.mockito.InOrder;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
@@ -241,13 +242,18 @@
inOrder.verify(firstSessionCallbacks).onStopPrinterStateTracking(
firstPrinterId);
- // We print again which brings the print activity up but the old
- // print activity is not destroyed yet (just fine) which is the
- // printer discovery session is not destroyed and the second print
- // will join the ongoing session. Hence, instead of start printer
- // discovery we are getting a printer validation request.
+ // This is tricky. It is possible that the print activity was not
+ // destroyed (the platform delays destruction at convenient time as
+ // an optimization) and we get the same instance which means that
+ // the discovery session may not have been destroyed. We try the
+ // case with the activity being destroyed and if this fails the
+ // case with the activity brought to front.
priorityList.add(firstPrinterId);
- inOrder.verify(firstSessionCallbacks).onValidatePrinters(priorityList);
+ try {
+ inOrder.verify(firstSessionCallbacks).onStartPrinterDiscovery(priorityList);
+ } catch (AssertionFailedError error) {
+ inOrder.verify(firstSessionCallbacks).onValidatePrinters(priorityList);
+ }
// The system selects the highest ranked historical printer.
inOrder.verify(firstSessionCallbacks).onStartPrinterStateTracking(
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/AllocationCopy2DRangeTest.java b/tests/tests/renderscript/src/android/renderscript/cts/AllocationCopy2DRangeTest.java
index b032fd4..3ac9834 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/AllocationCopy2DRangeTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/AllocationCopy2DRangeTest.java
@@ -28,7 +28,7 @@
public void testAllocationCopy2DRange() {
ScriptC_allocationCopy2DRange mScript =
- new ScriptC_allocationCopy2DRange(mRS, mRes, R.raw.allocationcopy2drange);
+ new ScriptC_allocationCopy2DRange(mRS);
Random random = new Random(0x172d8ab9);
int width = random.nextInt(512);
int height = random.nextInt(512);
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/AllocationResize.java b/tests/tests/renderscript/src/android/renderscript/cts/AllocationResize.java
index 68d7274..52b33f4 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/AllocationResize.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/AllocationResize.java
@@ -34,7 +34,7 @@
}
public void testResize() {
- mScript = new ScriptC_allocation_resize(mRS, mRes, R.raw.allocation_resize);
+ mScript = new ScriptC_allocation_resize(mRS);
mIn = Allocation.createSized(mRS, Element.I32(mRS), INPUTSIZE/2);
mOut = Allocation.createSized(mRS, Element.I32(mRS), INPUTSIZE*2);
mIn.resize(INPUTSIZE);
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/AllocationTest.java b/tests/tests/renderscript/src/android/renderscript/cts/AllocationTest.java
index 51309c8..10d2673 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/AllocationTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/AllocationTest.java
@@ -736,7 +736,7 @@
Allocation largeArray = Allocation.createTyped(mRS, b.setX(48).create());
Allocation singleElement = Allocation.createTyped(mRS, b.setX(1).create());
- ScriptC_setelementat script = new ScriptC_setelementat(mRS, mRes, R.raw.setelementat);
+ ScriptC_setelementat script = new ScriptC_setelementat(mRS);
script.set_memset_toValue(1);
script.forEach_memset(singleElement);
@@ -761,7 +761,7 @@
Allocation singleElement = Allocation.createTyped(mRS, b.setX(1).create());
Allocation largeArray = Allocation.createTyped(mRS, b.setX(48).setY(16).create());
- ScriptC_setelementat script = new ScriptC_setelementat(mRS, mRes, R.raw.setelementat);
+ ScriptC_setelementat script = new ScriptC_setelementat(mRS);
script.set_memset_toValue(1);
script.forEach_memset(singleElement);
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/CompilerTest.java b/tests/tests/renderscript/src/android/renderscript/cts/CompilerTest.java
index 799479e..adad6d5 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/CompilerTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/CompilerTest.java
@@ -31,9 +31,7 @@
*/
public void testMissingLink() {
try {
- ScriptC_missing_link t = new ScriptC_missing_link(mRS,
- mRes,
- R.raw.missing_link);
+ ScriptC_missing_link t = new ScriptC_missing_link(mRS);
fail("should throw RSRuntimeException");
} catch (RSRuntimeException e) {
}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ComputeTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ComputeTest.java
index d320448..e080f42 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/ComputeTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ComputeTest.java
@@ -314,9 +314,7 @@
* Test primitive types.
*/
public void testPrimitives() {
- ScriptC_primitives t = new ScriptC_primitives(mRS,
- mRes,
- R.raw.primitives);
+ ScriptC_primitives t = new ScriptC_primitives(mRS);
assertTrue(initializeGlobals(t));
t.invoke_test();
@@ -381,9 +379,7 @@
* Test array initialization.
*/
public void testArrayInit() {
- ScriptC_array_init t = new ScriptC_array_init(mRS,
- mRes,
- R.raw.array_init);
+ ScriptC_array_init t = new ScriptC_array_init(mRS);
checkInit(t);
t.invoke_array_init_test();
@@ -672,7 +668,7 @@
}
public void testVector() {
- ScriptC_vector s = new ScriptC_vector(mRS, mRes, R.raw.vector);
+ ScriptC_vector s = new ScriptC_vector(mRS);
if (!initializeVector(s)) {
fail("Failed to init vector components");
} else {
@@ -693,7 +689,7 @@
public void testStructObject() {
ScriptC_struct_object s =
- new ScriptC_struct_object(mRS, mRes, R.raw.struct_object);
+ new ScriptC_struct_object(mRS);
if (!initializeStructObject(s)) {
fail("Failed to init structure with RS objects");
} else {
@@ -706,7 +702,7 @@
/*
public void testClamp() {
- ScriptC_clamp s = new ScriptC_clamp(mRS, mRes, R.raw.clamp);
+ ScriptC_clamp s = new ScriptC_clamp(mRS);
s.invoke_clamp_test();
mRS.finish();
waitForMessage();
@@ -715,7 +711,7 @@
public void testClampRelaxed() {
ScriptC_clamp_relaxed s =
- new ScriptC_clamp_relaxed(mRS, mRes, R.raw.clamp_relaxed);
+ new ScriptC_clamp_relaxed(mRS);
s.invoke_clamp_test();
mRS.finish();
waitForMessage();
@@ -727,9 +723,7 @@
* Test utility functions.
*/
public void testUtilityFunctions() {
- ScriptC_primitives t = new ScriptC_primitives(mRS,
- mRes,
- R.raw.utils);
+ ScriptC_utils t = new ScriptC_utils(mRS);
t.invoke_test();
waitForMessage();
checkForErrors();
@@ -761,9 +755,7 @@
* Test support for reflected forEach() as well as validation of parameters.
*/
public void testForEach() {
- ScriptC_negate s = new ScriptC_negate(mRS,
- mRes,
- R.raw.negate);
+ ScriptC_negate s = new ScriptC_negate(mRS);
int x = 7;
Type t = new Type.Builder(mRS, Element.I32(mRS)).setX(x).create();
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ForEachTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ForEachTest.java
index 8e82f1f..4100f6e 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/ForEachTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ForEachTest.java
@@ -61,7 +61,7 @@
Type t = new Type.Builder(mRS, Element.I8(mRS)).setX(x).create();
Allocation badOut = Allocation.createTyped(mRS, t);
- ScriptC_fe_all fe_all = new ScriptC_fe_all(mRS, mRes, R.raw.fe_all);
+ ScriptC_fe_all fe_all = new ScriptC_fe_all(mRS);
// I8
Allocation in = Allocation.createTyped(mRS, t);
@@ -461,7 +461,7 @@
public void testMultipleForEach() {
- ScriptC_foreach s = new ScriptC_foreach(mRS, mRes, R.raw.foreach);
+ ScriptC_foreach s = new ScriptC_foreach(mRS);
Type.Builder typeBuilder = new Type.Builder(mRS, Element.I32(mRS));
int X = 5;
@@ -482,7 +482,7 @@
}
public void testNoRoot() {
- ScriptC_noroot s = new ScriptC_noroot(mRS, mRes, R.raw.noroot);
+ ScriptC_noroot s = new ScriptC_noroot(mRS);
Type.Builder typeBuilder = new Type.Builder(mRS, Element.I32(mRS));
int X = 5;
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/GetAllocationTest.java b/tests/tests/renderscript/src/android/renderscript/cts/GetAllocationTest.java
index e447224..047ca93 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/GetAllocationTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/GetAllocationTest.java
@@ -31,7 +31,7 @@
tempArray[i] = random.nextInt();
}
ScriptC_get_allocation ms =
- new ScriptC_get_allocation(mRS, mRes, R.raw.get_allocation);
+ new ScriptC_get_allocation(mRS);
Allocation mTemp = Allocation.createSized(mRS, Element.I32(mRS), INPUTSIZE);
mTemp.copyFrom(tempArray);
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/GetElementAt.java b/tests/tests/renderscript/src/android/renderscript/cts/GetElementAt.java
index babc1ef..a37a46e 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/GetElementAt.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/GetElementAt.java
@@ -56,7 +56,7 @@
public void testX () {
setupArrays(INPUTSIZE);
- script_x = new ScriptC_get_element_at_x(mRS, mRes, R.raw.get_element_at_x);
+ script_x = new ScriptC_get_element_at_x(mRS);
gIn = Allocation.createSized(mRS, Element.U32(mRS), INPUTSIZE);
gIn.copyFrom(in);
mOut = Allocation.createTyped(mRS, gIn.getType());
@@ -73,7 +73,7 @@
public void testXY () {
setupArrays(INPUTSIZE*INPUTSIZE);
- script_xy = new ScriptC_get_element_at_x_y(mRS, mRes, R.raw.get_element_at_x_y);
+ script_xy = new ScriptC_get_element_at_x_y(mRS);
Type.Builder builder = new Type.Builder(mRS, Element.U32(mRS));
builder.setX(INPUTSIZE);
builder.setY(INPUTSIZE);
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/InitTest.java b/tests/tests/renderscript/src/android/renderscript/cts/InitTest.java
index 848c192..53fe05b 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/InitTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/InitTest.java
@@ -32,7 +32,7 @@
}
public void testInitTest() {
- script = new ScriptC_init_test(mRS, mRes, R.raw.init_test);
+ script = new ScriptC_init_test(mRS);
float[] ref = new float[INPUTSIZE];
float[] in = new float[INPUTSIZE];
float[] out = new float[INPUTSIZE];
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/Intrinsic3DLut.java b/tests/tests/renderscript/src/android/renderscript/cts/Intrinsic3DLut.java
index 830982f..87a03ad 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/Intrinsic3DLut.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/Intrinsic3DLut.java
@@ -105,5 +105,36 @@
checkError();
}
+ public void test1C() {
+ initCube();
+ makeBuffers(97, 97, Element.U8_4(mRS));
+
+ Script.LaunchOptions lo = makeClipper(11, 11, 87, 87);
+
+ mIntrinsic.forEach(mAllocSrc, mAllocDst, lo);
+ mScript.forEach_root(mAllocSrc, mAllocRef, lo);
+
+ mVerify.set_gAllowedIntError(1);
+ mVerify.invoke_verify(mAllocRef, mAllocDst, mAllocSrc);
+ mRS.finish();
+ checkError();
+ }
+
+ public void test2C() {
+ initCube();
+ makeBuffers(97, 97, Element.U8_4(mRS));
+ genCubeRand();
+
+ Script.LaunchOptions lo = makeClipper(11, 11, 87, 87);
+
+ mIntrinsic.forEach(mAllocSrc, mAllocDst, lo);
+ mScript.forEach_root(mAllocSrc, mAllocRef, lo);
+
+ mVerify.set_gAllowedIntError(2);
+ mVerify.invoke_verify(mAllocRef, mAllocDst, mAllocSrc);
+ mRS.finish();
+ checkError();
+ }
+
}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicBlur.java b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicBlur.java
index aa67012..076dcd4 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicBlur.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicBlur.java
@@ -30,7 +30,7 @@
- private void initTest(int w, int h, Element e) {
+ private void initTest(int w, int h, Element e, Script.LaunchOptions lo) {
makeBuffers(w, h, e);
Type.Builder tb = new Type.Builder(mRS, Element.F32_4(mRS));
@@ -55,7 +55,7 @@
copyInput();
mScript.forEach_horz(mScratchPixelsAllocation2);
mScript.forEach_vert(mScratchPixelsAllocation1);
- copyOutput();
+ copyOutput(lo);
}
private void copyInput() {
@@ -70,13 +70,13 @@
throw new IllegalArgumentException("bad type");
}
- private void copyOutput() {
+ private void copyOutput(Script.LaunchOptions lo) {
if (mAllocSrc.getType().getElement().isCompatible(Element.U8(mRS))) {
- mScript.forEach_convert1_fToU(mScratchPixelsAllocation1, mAllocRef);
+ mScript.forEach_convert1_fToU(mScratchPixelsAllocation1, mAllocRef, lo);
return;
}
if (mAllocSrc.getType().getElement().isCompatible(Element.U8_4(mRS))) {
- mScript.forEach_convert4_fToU(mScratchPixelsAllocation1, mAllocRef);
+ mScript.forEach_convert4_fToU(mScratchPixelsAllocation1, mAllocRef, lo);
return;
}
throw new IllegalArgumentException("bad type");
@@ -86,7 +86,7 @@
final int w = 97;
final int h = 97;
Element e = Element.U8(mRS);
- initTest(w, h, e);
+ initTest(w, h, e, null);
mIntrinsic.forEach(mAllocDst);
@@ -100,7 +100,7 @@
final int w = 97;
final int h = 97;
Element e = Element.U8_4(mRS);
- initTest(w, h, e);
+ initTest(w, h, e, null);
mIntrinsic.forEach(mAllocDst);
@@ -110,4 +110,36 @@
checkError();
}
+
+ public void testU8_1C() {
+ final int w = 97;
+ final int h = 97;
+ Element e = Element.U8(mRS);
+ Script.LaunchOptions lo = makeClipper(11, 11, w - 11, h - 11);
+
+ initTest(w, h, e, lo);
+ mIntrinsic.forEach(mAllocDst, lo);
+
+ mVerify.set_gAllowedIntError(1);
+ mVerify.invoke_verify(mAllocRef, mAllocDst, mAllocSrc);
+ mRS.finish();
+ checkError();
+ }
+
+ public void testU8_4C() {
+ final int w = 97;
+ final int h = 97;
+ Element e = Element.U8_4(mRS);
+ Script.LaunchOptions lo = makeClipper(11, 11, w - 11, h - 11);
+
+ initTest(w, h, e, lo);
+ mIntrinsic.forEach(mAllocDst, lo);
+
+ mVerify.set_gAllowedIntError(1);
+ mVerify.invoke_verify(mAllocRef, mAllocDst, mAllocSrc);
+ mRS.finish();
+ checkError();
+ }
+
+
}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicHistogram.java b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicHistogram.java
index e970291..94cc4ce 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicHistogram.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/IntrinsicHistogram.java
@@ -48,7 +48,7 @@
mAout = Allocation.createSized(mRS, e2, 256);
}
- private void testNorm(int inVSize, int outVSize, int w, int h) {
+ private void testNorm(int inVSize, int outVSize, int w, int h, boolean clip) {
createAllocations(inVSize, outVSize, w, h);
int invs2 = (inVSize != 3) ? inVSize : 4;
@@ -61,11 +61,27 @@
java.util.Random r = new java.util.Random();
r.nextBytes(i);
- for (int ct=0; ct < i.length; ct++) {
- int t = i[ct];
- if (t < 0) t = 256 + t;
- if ((ct % invs2) < outVSize) {
- ref[(t * outvs2) + (ct % invs2)] ++;
+ int x1 = 0, y1 = 0, x2 = w, y2 = h;
+ if (clip) {
+ x1 = 11;
+ y1 = 11;
+ x2 = w - 11;
+ y2 = h - 11;
+ }
+
+ for (int y = y1; y < y2; y++) {
+ for (int x = x1; x < x2; x++) {
+ int ct = (y * w + x) * invs2;
+
+ int v = 0;
+ for (int c = 0; c < inVSize; c++) {
+ int t = i[ct + c];
+ if (t < 0) t = 256 + t;
+
+ if (c < outVSize) {
+ ref[(t * outvs2) + c] ++;
+ }
+ }
}
}
@@ -73,7 +89,7 @@
ScriptIntrinsicHistogram hist =
ScriptIntrinsicHistogram.create(mRS, mAin.getType().getElement());
hist.setOutput(mAout);
- hist.forEach(mAin);
+ hist.forEach(mAin, makeClipper(x1, y1, x2, y2));
mAin.copyFrom(i);
mAout.copyTo(res);
@@ -83,42 +99,77 @@
}
public void test_norm_4_4() {
- testNorm(4, 4, 101, 101);
+ testNorm(4, 4, 101, 101, false);
}
public void test_norm_4_3() {
- testNorm(4, 3, 101, 101);
+ testNorm(4, 3, 101, 101, false);
}
public void test_norm_4_2() {
- testNorm(4, 2, 101, 101);
+ testNorm(4, 2, 101, 101, false);
}
public void test_norm_4_1() {
- testNorm(4, 1, 101, 101);
+ testNorm(4, 1, 101, 101, false);
}
public void test_norm_3_3() {
- testNorm(3, 3, 101, 101);
+ testNorm(3, 3, 101, 101, false);
}
public void test_norm_3_2() {
- testNorm(3, 2, 101, 101);
+ testNorm(3, 2, 101, 101, false);
}
public void test_norm_3_1() {
- testNorm(3, 1, 101, 101);
+ testNorm(3, 1, 101, 101, false);
}
public void test_norm_2_2() {
- testNorm(2, 2, 101, 101);
+ testNorm(2, 2, 101, 101, false);
}
public void test_norm_2_1() {
- testNorm(2, 1, 101, 101);
+ testNorm(2, 1, 101, 101, false);
}
public void test_norm_1_1() {
- testNorm(1, 1, 101, 101);
+ testNorm(1, 1, 101, 101, false);
+ }
+
+
+ public void test_norm_4_4C() {
+ testNorm(4, 4, 101, 101, true);
+ }
+ public void test_norm_4_3C() {
+ testNorm(4, 3, 101, 101, true);
+ }
+ public void test_norm_4_2C() {
+ testNorm(4, 2, 101, 101, true);
+ }
+ public void test_norm_4_1C() {
+ testNorm(4, 1, 101, 101, true);
+ }
+
+ public void test_norm_3_3C() {
+ testNorm(3, 3, 101, 101, true);
+ }
+ public void test_norm_3_2C() {
+ testNorm(3, 2, 101, 101, true);
+ }
+ public void test_norm_3_1C() {
+ testNorm(3, 1, 101, 101, true);
+ }
+
+ public void test_norm_2_2C() {
+ testNorm(2, 2, 101, 101, true);
+ }
+ public void test_norm_2_1C() {
+ testNorm(2, 1, 101, 101, true);
+ }
+
+ public void test_norm_1_1C() {
+ testNorm(1, 1, 101, 101, true);
}
- private void testDot(int inVSize, int w, int h) {
+ private void testDot(int inVSize, int w, int h, boolean clip) {
createAllocations(inVSize, 1, w, h);
int invs2 = (inVSize != 3) ? inVSize : 4;
@@ -136,14 +187,26 @@
doti[ct] = (int)((dotVals[ct] * 256.f) + 0.5f);
}
- for (int ct=0; ct < i.length; ct+=invs2) {
- int v = 0;
- for (int c = 0; c < inVSize; c++) {
- int t = i[ct + c];
- if (t < 0) t = 256 + t;
- v += doti[c] * t;
+ int x1 = 0, y1 = 0, x2 = w, y2 = h;
+ if (clip) {
+ x1 = 11;
+ y1 = 11;
+ x2 = w - 11;
+ y2 = h - 11;
+ }
+
+ for (int y = y1; y < y2; y++) {
+ for (int x = x1; x < x2; x++) {
+ int ct = (y * w + x) * invs2;
+
+ int v = 0;
+ for (int c = 0; c < inVSize; c++) {
+ int t = i[ct + c];
+ if (t < 0) t = 256 + t;
+ v += doti[c] * t;
+ }
+ ref[(v + 0x7f) >> 8] ++;
}
- ref[(v + 0x7f) >> 8] ++;
}
mAin.copyFrom(i);
@@ -151,7 +214,7 @@
ScriptIntrinsicHistogram.create(mRS, mAin.getType().getElement());
hist.setOutput(mAout);
hist.setDotCoefficients(dotVals[0], dotVals[1], dotVals[2], dotVals[3]);
- hist.forEach_Dot(mAin);
+ hist.forEach_Dot(mAin, makeClipper(x1, y1, x2, y2));
mAin.copyFrom(i);
mAout.copyTo(res);
@@ -161,16 +224,30 @@
}
public void test_dot_1() {
- testDot(1, 101, 101);
+ testDot(1, 101, 101, false);
}
public void test_dot_2() {
- testDot(2, 101, 101);
+ testDot(2, 101, 101, false);
}
public void test_dot_3() {
- testDot(3, 101, 101);
+ testDot(3, 101, 101, false);
}
public void test_dot_4() {
- testDot(4, 101, 101);
+ testDot(4, 101, 101, false);
+ }
+
+
+ public void test_dot_1C() {
+ testDot(1, 101, 101, true);
+ }
+ public void test_dot_2C() {
+ testDot(2, 101, 101, true);
+ }
+ public void test_dot_3C() {
+ testDot(3, 101, 101, true);
+ }
+ public void test_dot_4C() {
+ testDot(4, 101, 101, true);
}
}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/KernelTest.java b/tests/tests/renderscript/src/android/renderscript/cts/KernelTest.java
index dcfc0ba..0a8c8bd 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/KernelTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/KernelTest.java
@@ -461,7 +461,7 @@
public void testMultipleForEach() {
- ScriptC_foreach s = new ScriptC_foreach(mRS, mRes, R.raw.foreach);
+ ScriptC_foreach s = new ScriptC_foreach(mRS);
Type.Builder typeBuilder = new Type.Builder(mRS, Element.I32(mRS));
int X = 5;
@@ -482,7 +482,7 @@
}
public void testNoRoot() {
- ScriptC_noroot s = new ScriptC_noroot(mRS, mRes, R.raw.noroot);
+ ScriptC_noroot s = new ScriptC_noroot(mRS);
Type.Builder typeBuilder = new Type.Builder(mRS, Element.I32(mRS));
int X = 5;
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/RenderScriptTest.java b/tests/tests/renderscript/src/android/renderscript/cts/RenderScriptTest.java
index 9e61526..e31f3c6 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/RenderScriptTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/RenderScriptTest.java
@@ -29,8 +29,7 @@
*/
public void testRenderScript() {
RenderScript mRS = RenderScript.create(getContext());
- ScriptC_passthrough t = new ScriptC_passthrough(mRS,
- getContext().getResources(), R.raw.passthrough);
+ ScriptC_passthrough t = new ScriptC_passthrough(mRS);
t.invoke_passthrough(5);
mRS.destroy();
}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/RsUnpackColor8888Test.java b/tests/tests/renderscript/src/android/renderscript/cts/RsUnpackColor8888Test.java
index 3ebbee1..c32cc79 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/RsUnpackColor8888Test.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/RsUnpackColor8888Test.java
@@ -32,7 +32,7 @@
}
public void testRsUnpackColor8888RGB() {
- script = new ScriptC_rs_unpack_color_8888(mRS, mRes, R.raw.rs_unpack_color_8888);
+ script = new ScriptC_rs_unpack_color_8888(mRS);
Allocation mAllocationIn = Allocation.createSized(mRS, Element.U8_4(mRS), INPUTSIZE);
Allocation mAllocationOut = Allocation.createSized(mRS, Element.F32_4(mRS), INPUTSIZE);
byte[] inArray = new byte[INPUTSIZE * 4];
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/SampleTest.java b/tests/tests/renderscript/src/android/renderscript/cts/SampleTest.java
index 1729aeb..916fec3 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/SampleTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/SampleTest.java
@@ -74,7 +74,7 @@
mAlloc_RGBA_1D = createAlloc(b.setX(8).create());
mAlloc_RGBA_2D = createAlloc(b.setX(8).setY(8).create());
- mScript = new ScriptC_sample(mRS, mRes, R.raw.sample);
+ mScript = new ScriptC_sample(mRS);
mScript.set_gNearest(Sampler.CLAMP_NEAREST(mRS));
mScript.set_gLinear(Sampler.CLAMP_LINEAR(mRS));
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ScriptCTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ScriptCTest.java
deleted file mode 100644
index 7f4ba93..0000000
--- a/tests/tests/renderscript/src/android/renderscript/cts/ScriptCTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * 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.res.Resources;
-
-import android.renderscript.RenderScript;
-import android.renderscript.ScriptC;
-
-import com.android.cts.stub.R;
-
-public class ScriptCTest extends RSBaseCompute {
-
- class ScriptCHelper extends ScriptC {
- public ScriptCHelper(int id, RenderScript rs) {
- super(id, rs);
- }
-
- public ScriptCHelper(RenderScript rs,
- Resources resources,
- int resourceID) {
- super(rs, resources, resourceID);
- }
- }
-
- public void testScriptC() {
- // Test basic constructor
- ScriptCHelper h = new ScriptCHelper(0, mRS);
-
- // Test actual constructor
- h = new ScriptCHelper(mRS, mRes, R.raw.negate);
- }
-}
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/ScriptTest.java b/tests/tests/renderscript/src/android/renderscript/cts/ScriptTest.java
index 90b847a..ed73b6a 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/ScriptTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/ScriptTest.java
@@ -33,7 +33,7 @@
public class ScriptTest extends RSBaseCompute {
public void testScript() {
- Script S = new ScriptC_primitives(mRS, mRes, R.raw.primitives);
+ Script S = new ScriptC_primitives(mRS);
S.setTimeZone("America/New_York");
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/StructArrayTest.java b/tests/tests/renderscript/src/android/renderscript/cts/StructArrayTest.java
index 6003ca9..a851501 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/StructArrayTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/StructArrayTest.java
@@ -23,9 +23,7 @@
*/
public void testStructArrays() {
mRS.setErrorHandler(mRsError);
- ScriptC_struct_array pad = new ScriptC_struct_array(mRS,
- mRes,
- R.raw.struct_array);
+ ScriptC_struct_array pad = new ScriptC_struct_array(mRS);
ScriptField_ArrayMe S = new ScriptField_ArrayMe(mRS, 1);
int[] values = {0, 1, 2, 3, 4};
S.set_i(0, values, true);
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/StructPadTest.java b/tests/tests/renderscript/src/android/renderscript/cts/StructPadTest.java
index c56c086..4832202 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/StructPadTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/StructPadTest.java
@@ -25,9 +25,7 @@
*/
public void testStructPadding() {
mRS.setErrorHandler(mRsError);
- ScriptC_struct_pad pad = new ScriptC_struct_pad(mRS,
- mRes,
- R.raw.struct_pad);
+ ScriptC_struct_pad pad = new ScriptC_struct_pad(mRS);
ScriptField_PadMe S = new ScriptField_PadMe(mRS, 1);
Float4 F4 = new Float4(1.0f, 2.0f, 3.0f, 4.0f);
diff --git a/tests/tests/renderscript/src/android/renderscript/cts/VersionTest.java b/tests/tests/renderscript/src/android/renderscript/cts/VersionTest.java
index c3dbea9..70fca9b 100644
--- a/tests/tests/renderscript/src/android/renderscript/cts/VersionTest.java
+++ b/tests/tests/renderscript/src/android/renderscript/cts/VersionTest.java
@@ -90,9 +90,7 @@
public void testVersion_too_high() {
try {
ScriptC_set_target_api_too_high test_too_high =
- new ScriptC_set_target_api_too_high(mRS,
- mRes,
- R.raw.set_target_api_too_high);
+ new ScriptC_set_target_api_too_high(mRS);
fail("should throw RSRuntimeException");
} catch (RSRuntimeException e) {
}
diff --git a/tests/tests/rsg/Android.mk b/tests/tests/rsg/Android.mk
deleted file mode 100644
index c58a4b0..0000000
--- a/tests/tests/rsg/Android.mk
+++ /dev/null
@@ -1,36 +0,0 @@
-# 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 := CtsRenderscriptGraphicsTestCases
-
-# 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)
-
-LOCAL_STATIC_JAVA_LIBRARIES := ctstestrunner
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_INSTRUMENTATION_FOR := CtsTestStubs
-
-LOCAL_SDK_VERSION := 17
-
-include $(BUILD_CTS_PACKAGE)
diff --git a/tests/tests/rsg/AndroidManifest.xml b/tests/tests/rsg/AndroidManifest.xml
deleted file mode 100644
index 031cbc2..0000000
--- a/tests/tests/rsg/AndroidManifest.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?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.renderscriptgraphics">
-
- <uses-permission android:name="android.permission.DISABLE_KEYGUARD" />
- <application>
- <uses-library android:name="android.test.runner" />
- </application>
-
- <!-- This is a self-instrumenting test package. -->
- <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
- android:targetPackage="com.android.cts.stub"
- android:label="CTS tests of Renderscript Graphics component">
- <meta-data android:name="listener"
- android:value="com.android.cts.runner.CtsTestRunListener" />
- </instrumentation>
-
-</manifest>
-
diff --git a/tests/tests/rsg/src/android/renderscriptgraphics/cts/BaseObjTest.java b/tests/tests/rsg/src/android/renderscriptgraphics/cts/BaseObjTest.java
deleted file mode 100644
index 7773dda..0000000
--- a/tests/tests/rsg/src/android/renderscriptgraphics/cts/BaseObjTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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.renderscriptgraphics.cts;
-
-import android.renderscript.BaseObj;
-import android.renderscript.Font;
-import android.renderscript.Font.Style;
-import android.renderscript.RSIllegalArgumentException;
-
-public class BaseObjTest extends RSBaseGraphics {
-
- public void testBaseObj() {
- Style S = Font.Style.NORMAL;
- Font F = Font.create(mRS, mRes, "sans-serif", S, 8);
- assertTrue(F != null);
- BaseObj B = F;
- B.setName("sans-serif");
- try {
- B.setName("sans-serif");
- fail("set name twice for a BaseObj");
- } catch (RSIllegalArgumentException e) {
- }
- B.destroy();
-
- F = Font.create(mRS, mRes, "serif", S, 8);
- assertTrue(F != null);
- B = F;
- try {
- B.setName("");
- fail("set empty name for a BaseObj");
- } catch (RSIllegalArgumentException e) {
- }
- B.setName("serif");
- B.destroy();
-
- F = Font.create(mRS, mRes, "mono", S, 8);
- assertTrue(F != null);
- B = F;
- try {
- B.setName(null);
- fail("set name as null string reference for a BaseObj");
- } catch (RSIllegalArgumentException e) {
- }
- B.setName("mono");
- B.destroy();
- }
-}
-
diff --git a/tests/tests/rsg/src/android/renderscriptgraphics/cts/ContextCreationTest.java b/tests/tests/rsg/src/android/renderscriptgraphics/cts/ContextCreationTest.java
deleted file mode 100644
index 11b999c..0000000
--- a/tests/tests/rsg/src/android/renderscriptgraphics/cts/ContextCreationTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * 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.renderscriptgraphics.cts;
-
-import android.renderscript.*;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.UiThreadTest;
-import android.util.Log;
-
-/**
- * Tests for the RenderScriptGL class.
- */
-public class ContextCreationTest extends
- ActivityInstrumentationTestCase2<RenderscriptGLStubActivity> {
-
- private static final int NUM_RECREATE_ITERATIONS_WITHOUT_DELAY = 50;
-
- private static final int NUM_RECREATE_ITERATIONS_WITH_DELAY = 10;
-
- private static final int RECREATE_DELAY = 100;
-
- private static final boolean LOG_RECREATE = true;
-
- private static final String TAG = "ContextCreationTest";
-
- private RenderscriptGLStubActivity mActivity;
-
- public ContextCreationTest() {
- super(RenderscriptGLStubActivity.class);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mActivity = getActivity();
- }
-
- @Override
- protected void tearDown() throws Exception {
- mActivity.destroyAll();
- super.tearDown();
- }
-
- /**
- * Test repeated recreation of the renderscript context with a
- * delay in between to detect hangs in the graphics drivers
- */
- @UiThreadTest
- public void testCreationWithDelay() throws InterruptedException {
- for (int i = 0; i < NUM_RECREATE_ITERATIONS_WITH_DELAY; i++) {
- Thread.sleep(RECREATE_DELAY);
- if (LOG_RECREATE) {
- Log.w(TAG, "Recreate (w/ delay) step " + i + " - pause");
- }
- mActivity.recreateView();
- }
- }
-
- /**
- * Test repeated recreation of the renderscript context to
- * detect hangs in the graphics drivers
- */
- @UiThreadTest
- public void testCreationWithoutDelay() {
- for (int i = 0; i < NUM_RECREATE_ITERATIONS_WITHOUT_DELAY; i++) {
- if (LOG_RECREATE) {
- Log.w(TAG, "Recreate (no delay) step " + i);
- }
- mActivity.recreateView();
- }
- }
-
- /**
- * Test repeated recreation of the renderscript context with two
- * created at a time to detect hangs in the graphics drivers
- */
- @UiThreadTest
- public void testMultiviewCreationWithoutDelay() {
- for (int i = 0; i < NUM_RECREATE_ITERATIONS_WITHOUT_DELAY; i++) {
- if (LOG_RECREATE) {
- Log.w(TAG, "Recreate multiview (no delay) step " + i + " - pause");
- }
- mActivity.recreateMultiView();
- }
- }
-}
diff --git a/tests/tests/rsg/src/android/renderscriptgraphics/cts/FileA3DTest.java b/tests/tests/rsg/src/android/renderscriptgraphics/cts/FileA3DTest.java
deleted file mode 100644
index 510a3c5..0000000
--- a/tests/tests/rsg/src/android/renderscriptgraphics/cts/FileA3DTest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * 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.renderscriptgraphics.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/rsg/src/android/renderscriptgraphics/cts/FontTest.java b/tests/tests/rsg/src/android/renderscriptgraphics/cts/FontTest.java
deleted file mode 100644
index 43b9662..0000000
--- a/tests/tests/rsg/src/android/renderscriptgraphics/cts/FontTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * 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.renderscriptgraphics.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 = "Roboto-Regular.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/rsg/src/android/renderscriptgraphics/cts/MeshTest.java b/tests/tests/rsg/src/android/renderscriptgraphics/cts/MeshTest.java
deleted file mode 100644
index 9b7eb99..0000000
--- a/tests/tests/rsg/src/android/renderscriptgraphics/cts/MeshTest.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * 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.renderscriptgraphics.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/rsg/src/android/renderscriptgraphics/cts/ProgramFragmentFixedFunctionTest.java b/tests/tests/rsg/src/android/renderscriptgraphics/cts/ProgramFragmentFixedFunctionTest.java
deleted file mode 100644
index 29824d1..0000000
--- a/tests/tests/rsg/src/android/renderscriptgraphics/cts/ProgramFragmentFixedFunctionTest.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * 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.renderscriptgraphics.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/rsg/src/android/renderscriptgraphics/cts/ProgramFragmentTest.java b/tests/tests/rsg/src/android/renderscriptgraphics/cts/ProgramFragmentTest.java
deleted file mode 100644
index ef6ad18..0000000
--- a/tests/tests/rsg/src/android/renderscriptgraphics/cts/ProgramFragmentTest.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * 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.renderscriptgraphics.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/rsg/src/android/renderscriptgraphics/cts/ProgramRasterTest.java b/tests/tests/rsg/src/android/renderscriptgraphics/cts/ProgramRasterTest.java
deleted file mode 100644
index e752d39..0000000
--- a/tests/tests/rsg/src/android/renderscriptgraphics/cts/ProgramRasterTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.renderscriptgraphics.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/rsg/src/android/renderscriptgraphics/cts/ProgramStoreTest.java b/tests/tests/rsg/src/android/renderscriptgraphics/cts/ProgramStoreTest.java
deleted file mode 100644
index e42f6fe..0000000
--- a/tests/tests/rsg/src/android/renderscriptgraphics/cts/ProgramStoreTest.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * 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.renderscriptgraphics.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/rsg/src/android/renderscriptgraphics/cts/ProgramVertexFixedFunctionTest.java b/tests/tests/rsg/src/android/renderscriptgraphics/cts/ProgramVertexFixedFunctionTest.java
deleted file mode 100644
index a50a9d5..0000000
--- a/tests/tests/rsg/src/android/renderscriptgraphics/cts/ProgramVertexFixedFunctionTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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.renderscriptgraphics.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/rsg/src/android/renderscriptgraphics/cts/ProgramVertexTest.java b/tests/tests/rsg/src/android/renderscriptgraphics/cts/ProgramVertexTest.java
deleted file mode 100644
index 7f23bd0..0000000
--- a/tests/tests/rsg/src/android/renderscriptgraphics/cts/ProgramVertexTest.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * 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.renderscriptgraphics.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/rsg/src/android/renderscriptgraphics/cts/RSBase.java b/tests/tests/rsg/src/android/renderscriptgraphics/cts/RSBase.java
deleted file mode 100644
index 7729e1e..0000000
--- a/tests/tests/rsg/src/android/renderscriptgraphics/cts/RSBase.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2011-2012 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.renderscriptgraphics.cts;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.RenderScript.RSErrorHandler;
-import android.renderscript.RenderScript.RSMessageHandler;
-import android.renderscript.RSRuntimeException;
-import android.test.AndroidTestCase;
-import android.util.Log;
-
-/**
- * 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;
-
- private int result;
- private boolean msgHandled;
-
- private static final int RS_MSG_TEST_PASSED = 100;
- private 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();
- }
- }
-
- protected boolean FoundError = false;
- protected RSErrorHandler mRsError = new RSErrorHandler() {
- public void run() {
- FoundError = true;
- Log.e("RenderscriptCTS", mErrorMessage);
- throw new RSRuntimeException("Received error " + mErrorNum +
- " message " + mErrorMessage);
- }
- };
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- result = 0;
- msgHandled = false;
- mCtx = getContext();
- mRes = mCtx.getResources();
- }
-
- /**
- * Verify that we didn't fail on the control or script side of things.
- */
- protected void checkForErrors() {
- assertFalse(FoundError);
- assertTrue(result != RS_MSG_TEST_FAILED);
- }
-}
diff --git a/tests/tests/rsg/src/android/renderscriptgraphics/cts/RSBaseGraphics.java b/tests/tests/rsg/src/android/renderscriptgraphics/cts/RSBaseGraphics.java
deleted file mode 100644
index 65ba926..0000000
--- a/tests/tests/rsg/src/android/renderscriptgraphics/cts/RSBaseGraphics.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * 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.renderscriptgraphics.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/rsg/src/android/renderscriptgraphics/cts/RSSurfaceViewTest.java b/tests/tests/rsg/src/android/renderscriptgraphics/cts/RSSurfaceViewTest.java
deleted file mode 100644
index 4d46d8d..0000000
--- a/tests/tests/rsg/src/android/renderscriptgraphics/cts/RSSurfaceViewTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * 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.renderscriptgraphics.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/rsg/src/android/renderscriptgraphics/cts/RenderscriptGLStubActivity.java b/tests/tests/rsg/src/android/renderscriptgraphics/cts/RenderscriptGLStubActivity.java
deleted file mode 100644
index bddde03..0000000
--- a/tests/tests/rsg/src/android/renderscriptgraphics/cts/RenderscriptGLStubActivity.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * 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.renderscriptgraphics.cts;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.content.Context;
-import android.content.res.Resources;
-import android.renderscript.*;
-
-import com.android.cts.stub.R;
-
-// Renderscript activity
-public class RenderscriptGLStubActivity extends Activity {
- class StubActivityRS {
- private Resources mRes;
- private RenderScriptGL mRS;
-
- private ScriptC mScript;
-
- public StubActivityRS() {
- }
-
- // This provides us with the renderscript context and resources that
- // allow us to create the script that does rendering
- public void init(RenderScriptGL rs, Resources res) {
- mRS = rs;
- mRes = res;
- initRS();
- }
-
- private void initRS() {
- mScript = new ScriptC_stub_activity(mRS, mRes, R.raw.stub_activity);
- mRS.bindRootScript(mScript);
- }
- }
-
- class HelloWorldView extends RSSurfaceView {
- // Renderscipt context
- private RenderScriptGL mRS;
- // Script that does the rendering
- private StubActivityRS mRender;
-
- public HelloWorldView(Context context) {
- super(context);
- ensureRenderScript();
- }
-
- private void ensureRenderScript() {
- if (mRS == null) {
- // Initialize renderscript with desired surface characteristics.
- // In this case, just use the defaults
- RenderScriptGL.SurfaceConfig sc = new RenderScriptGL.SurfaceConfig();
- mRS = createRenderScriptGL(sc);
- // Create an instance of the script that does the rendering
- mRender = new StubActivityRS();
- mRender.init(mRS, getResources());
- }
- }
-
- @Override
- protected void onAttachedToWindow() {
- super.onAttachedToWindow();
- ensureRenderScript();
- }
-
- @Override
- protected void onDetachedFromWindow() {
- // Handle the system event and clean up
- mRender = null;
- if (mRS != null) {
- mRS = null;
- destroyRenderScriptGL();
- }
- }
-
- public void forceDestroy() {
- onDetachedFromWindow();
- }
- }
-
- // Custom view to use with RenderScript
- private HelloWorldView mView;
- private HelloWorldView mView2;
-
- @Override
- public void onCreate(Bundle icicle) {
- super.onCreate(icicle);
-
- // Create our view and set it as the content of our Activity
- mView = new HelloWorldView(this);
- setContentView(mView);
- }
-
- public void recreateView() {
- HelloWorldView oldView = mView;
- mView = new HelloWorldView(this);
- setContentView(mView);
- oldView.forceDestroy();
- }
-
- public void destroyAll() {
- if (mView != null) {
- mView.forceDestroy();
- }
- if (mView2 != null) {
- mView2.forceDestroy();
- }
- }
-
- public void recreateMultiView() {
- HelloWorldView oldView = mView;
- mView = new HelloWorldView(this);
- mView2 = new HelloWorldView(this);
- setContentView(mView);
- setContentView(mView2);
- oldView.forceDestroy();
- }
-
- @Override
- protected void onResume() {
- // Ideally an app should implement onResume() and onPause()
- // to take appropriate action when the activity loses focus
- super.onResume();
- mView.resume();
- }
-
- @Override
- protected void onPause() {
- // Ideally an app should implement onResume() and onPause()
- // to take appropriate action when the activity loses focus
- super.onPause();
- mView.pause();
- }
-
-}
-
diff --git a/tests/tests/rsg/src/android/renderscriptgraphics/cts/SurfaceConfigTest.java b/tests/tests/rsg/src/android/renderscriptgraphics/cts/SurfaceConfigTest.java
deleted file mode 100644
index a402e8a..0000000
--- a/tests/tests/rsg/src/android/renderscriptgraphics/cts/SurfaceConfigTest.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * 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.renderscriptgraphics.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/security/src/android/security/cts/KernelSettingsTest.java b/tests/tests/security/src/android/security/cts/KernelSettingsTest.java
index fc76027..f3163be 100644
--- a/tests/tests/security/src/android/security/cts/KernelSettingsTest.java
+++ b/tests/tests/security/src/android/security/cts/KernelSettingsTest.java
@@ -75,23 +75,6 @@
}
/**
- * dmesg shows the contents of the kernel log buffer. This log buffer
- * stores sensitive information, such as kernel addresses, which
- * could be used to perform attacks against the kernel. In addition,
- * inappropriate data, such as keystrokes and touch events,
- * are occasionally logged to dmesg. This setting prevents user
- * space programs from accessing the kernel settings buffer,
- * and should not be changed.
- */
- public void testDmesgRestrict() throws IOException {
- try {
- assertEquals("1", getFile("/proc/sys/kernel/dmesg_restrict"));
- } catch (FileNotFoundException e) {
- // Odd. The file doesn't exist... Assume we're ok.
- }
- }
-
- /**
* setuid programs should not be dumpable.
*/
public void testSetuidDumpable() throws IOException {
diff --git a/tests/tests/view/src/android/view/inputmethod/cts/InputConnectionWrapperTest.java b/tests/tests/view/src/android/view/inputmethod/cts/InputConnectionWrapperTest.java
index 8cc6919..6d89a64 100644
--- a/tests/tests/view/src/android/view/inputmethod/cts/InputConnectionWrapperTest.java
+++ b/tests/tests/view/src/android/view/inputmethod/cts/InputConnectionWrapperTest.java
@@ -23,7 +23,6 @@
import android.view.KeyEvent;
import android.view.inputmethod.CompletionInfo;
import android.view.inputmethod.CorrectionInfo;
-import android.view.inputmethod.CursorAnchorInfoRequest;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.ExtractedText;
import android.view.inputmethod.ExtractedTextRequest;
@@ -85,10 +84,9 @@
assertTrue(inputConnection.isGetSelectedTextCalled);
wrapper.setComposingRegion(0, 3);
assertTrue(inputConnection.isSetComposingRegionCalled);
- wrapper.requestCursorAnchorInfo(new CursorAnchorInfoRequest(
- CursorAnchorInfoRequest.TYPE_CURSOR_ANCHOR_INFO,
- CursorAnchorInfoRequest.FLAG_CURSOR_ANCHOR_INFO_MONITOR));
- assertTrue(inputConnection.isRequestCursorAnchorInfoCalled);
+ wrapper.requestUpdateCursorAnchorInfo(
+ InputConnection.REQUEST_UPDATE_CURSOR_ANCHOR_INFO_IMMEDIATE);
+ assertTrue(inputConnection.isRequestUpdateCursorAnchorInfoCalled);
}
private class MockInputConnection implements InputConnection {
@@ -113,7 +111,7 @@
public boolean isSetComposingTextCalled;
public boolean isSetComposingRegionCalled;
public boolean isSetSelectionCalled;
- public boolean isRequestCursorAnchorInfoCalled;
+ public boolean isRequestUpdateCursorAnchorInfoCalled;
public boolean beginBatchEdit() {
isBeginBatchEditCalled = true;
@@ -220,9 +218,9 @@
return false;
}
- public int requestCursorAnchorInfo(CursorAnchorInfoRequest request) {
- isRequestCursorAnchorInfoCalled = true;
- return CursorAnchorInfoRequest.RESULT_NOT_HANDLED;
+ public boolean requestUpdateCursorAnchorInfo(int cursorUpdateMode) {
+ isRequestUpdateCursorAnchorInfoCalled = true;
+ return false;
}
}
}
diff --git a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/InstrumentationApkTest.java b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/InstrumentationApkTest.java
index eab7925..4195dda 100644
--- a/tools/tradefed-host/src/com/android/cts/tradefed/testtype/InstrumentationApkTest.java
+++ b/tools/tradefed-host/src/com/android/cts/tradefed/testtype/InstrumentationApkTest.java
@@ -93,7 +93,7 @@
String[] options = {};
String forceAbi = getForceAbi();
if (forceAbi != null) {
- String abi = AbiFormatter.getDefaultAbi(mTestDevice, mForceAbi);
+ String abi = AbiFormatter.getDefaultAbi(mTestDevice, forceAbi);
if (abi != null) {
options = new String[]{String.format("--abi %s ", abi)};
}