diff options
author | Stephen Hines <srhines@google.com> | 2012-04-20 14:26:06 -0700 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2012-05-01 00:29:52 -0700 |
commit | adeb809201fcb77ba2b76a814ae4cdc9dacb326b (patch) | |
tree | 2b19e82372eb7c279c0cc19f9e40df9e2d33bc73 /tests/RenderScriptTests | |
parent | 9da1b5d0301e8d13be8c96cbd12dcda04fcf7118 (diff) | |
download | frameworks_base-adeb809201fcb77ba2b76a814ae4cdc9dacb326b.zip frameworks_base-adeb809201fcb77ba2b76a814ae4cdc9dacb326b.tar.gz frameworks_base-adeb809201fcb77ba2b76a814ae4cdc9dacb326b.tar.bz2 |
Start passing element/dim information along with FieldPacker.
BUG=6009244
Change-Id: I3c82c8b40c899b875831f53cf0ad82ea36c1a043
Diffstat (limited to 'tests/RenderScriptTests')
3 files changed, 74 insertions, 0 deletions
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java index e3d5c60..d2e1527 100644 --- a/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java +++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java @@ -68,6 +68,7 @@ public class RSTestCore { unitTests.add(new UT_constant(this, mRes, mCtx)); unitTests.add(new UT_vector(this, mRes, mCtx)); unitTests.add(new UT_array_init(this, mRes, mCtx)); + unitTests.add(new UT_array_alloc(this, mRes, mCtx)); unitTests.add(new UT_convert(this, mRes, mCtx)); unitTests.add(new UT_rsdebug(this, mRes, mCtx)); unitTests.add(new UT_rstime(this, mRes, mCtx)); diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_array_alloc.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_array_alloc.java new file mode 100644 index 0000000..befe865 --- /dev/null +++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_array_alloc.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 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 com.android.rs.test; + +import android.content.Context; +import android.content.res.Resources; +import android.renderscript.*; + +public class UT_array_alloc extends UnitTest { + private Resources mRes; + + protected UT_array_alloc(RSTestCore rstc, Resources res, Context ctx) { + super(rstc, "Array Allocation", ctx); + mRes = res; + } + + public void run() { + RenderScript pRS = RenderScript.create(mCtx); + ScriptC_array_alloc s = new ScriptC_array_alloc(pRS, mRes, R.raw.array_alloc); + pRS.setMessageHandler(mRsMessage); + + int dimX = s.get_dimX(); + Allocation[] Arr = new Allocation[dimX]; + Type.Builder typeBuilder = new Type.Builder(pRS, Element.I32(pRS)); + Type T = typeBuilder.setX(1).create(); + for (int i = 0; i < dimX; i++) { + Allocation A = Allocation.createTyped(pRS, T); + Arr[i] = A; + } + s.set_a(Arr); + + s.invoke_array_alloc_test(); + pRS.finish(); + waitForMessage(); + pRS.destroy(); + passTest(); + } +} diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/array_alloc.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/array_alloc.rs new file mode 100644 index 0000000..74ffdb1 --- /dev/null +++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/array_alloc.rs @@ -0,0 +1,21 @@ +#include "shared.rsh" + +const int dimX = 20; +rs_allocation a[dimX]; + +void array_alloc_test() { + bool failed = false; + + for (int i = 0; i < dimX; i++) { + rsDebug("i: ", i); + _RS_ASSERT(rsAllocationGetDimX(a[i]) == 1); + } + + if (failed) { + rsSendToClientBlocking(RS_MSG_TEST_FAILED); + } + else { + rsSendToClientBlocking(RS_MSG_TEST_PASSED); + } +} + |