diff options
author | Stephen Hines <srhines@google.com> | 2012-01-31 15:16:56 -0800 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2012-01-31 15:27:08 -0800 |
commit | b1ea64edb0a8bcf23cfe04ec5f51f6ed867d9c74 (patch) | |
tree | 03acf945f821fded86c122815f28a874faf89ea0 /tests | |
parent | e372593cfb973c8f8bdc46858dece9fcae9e178c (diff) | |
download | frameworks_base-b1ea64edb0a8bcf23cfe04ec5f51f6ed867d9c74.zip frameworks_base-b1ea64edb0a8bcf23cfe04ec5f51f6ed867d9c74.tar.gz frameworks_base-b1ea64edb0a8bcf23cfe04ec5f51f6ed867d9c74.tar.bz2 |
Test RS struct writing/reading.
BUG=5569561
Note that this only tests the issue described in the bug. It does not actually
produce an error on any recent version of RS.
Change-Id: I0194b13cb3f4ff01ce95d966e8e2dd74119a3946
Diffstat (limited to 'tests')
3 files changed, 93 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 5ab2c58..451d537 100644 --- a/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java +++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java @@ -73,6 +73,7 @@ public class RSTestCore { unitTests.add(new UT_refcount(this, mRes, mCtx)); unitTests.add(new UT_foreach(this, mRes, mCtx)); unitTests.add(new UT_atomic(this, mRes, mCtx)); + unitTests.add(new UT_struct(this, mRes, mCtx)); unitTests.add(new UT_math(this, mRes, mCtx)); unitTests.add(new UT_fp_mad(this, mRes, mCtx)); /* diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_struct.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_struct.java new file mode 100644 index 0000000..2a55686 --- /dev/null +++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_struct.java @@ -0,0 +1,55 @@ +/* + * 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_struct extends UnitTest { + private Resources mRes; + + protected UT_struct(RSTestCore rstc, Resources res, Context ctx) { + super(rstc, "Struct", ctx); + mRes = res; + } + + public void run() { + RenderScript pRS = RenderScript.create(mCtx); + ScriptC_struct s = new ScriptC_struct(pRS, mRes, R.raw.struct); + pRS.setMessageHandler(mRsMessage); + + ScriptField_Point2 p = new ScriptField_Point2(pRS, 1); + ScriptField_Point2.Item i = new ScriptField_Point2.Item(); + int val = 100; + i.x = val; + i.y = val; + p.set(i, 0, true); + s.bind_point2(p); + s.invoke_struct_test(val); + pRS.finish(); + waitForMessage(); + + val = 200; + p.set_x(0, val, true); + p.set_y(0, val, true); + s.invoke_struct_test(val); + pRS.finish(); + waitForMessage(); + pRS.destroy(); + } +} diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/struct.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/struct.rs new file mode 100644 index 0000000..1cd728e --- /dev/null +++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/struct.rs @@ -0,0 +1,37 @@ +#include "shared.rsh" + +typedef struct Point2 { + int x; + int y; +} Point_2; +Point_2 *point2; + +static bool test_Point_2(int expected) { + bool failed = false; + + rsDebug("Point: ", point2[0].x, point2[0].y); + _RS_ASSERT(point2[0].x == expected); + _RS_ASSERT(point2[0].y == expected); + + if (failed) { + rsDebug("test_Point_2 FAILED", 0); + } + else { + rsDebug("test_Point_2 PASSED", 0); + } + + return failed; +} + +void struct_test(int expected) { + bool failed = false; + failed |= test_Point_2(expected); + + if (failed) { + rsSendToClientBlocking(RS_MSG_TEST_FAILED); + } + else { + rsSendToClientBlocking(RS_MSG_TEST_PASSED); + } +} + |