diff options
author | Stephen Hines <srhines@google.com> | 2012-02-27 18:06:51 -0800 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2012-02-27 18:06:51 -0800 |
commit | 47e432e37cb9d2eb1c08111e8228fa7551c7c49a (patch) | |
tree | 0be86ee04f2cb9de76729efe220a03578dda93f6 /tests | |
parent | f69d204d2db04686e73829540d3184bf6ca67195 (diff) | |
download | frameworks_base-47e432e37cb9d2eb1c08111e8228fa7551c7c49a.zip frameworks_base-47e432e37cb9d2eb1c08111e8228fa7551c7c49a.tar.gz frameworks_base-47e432e37cb9d2eb1c08111e8228fa7551c7c49a.tar.bz2 |
Add test for signed/unsigned char bug (conversion).
BUG=6080056
Change-Id: I7980ff3e4a23ff8ba007ff0372ec855b7272630d
Diffstat (limited to 'tests')
3 files changed, 78 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 6f56223..22e1bff 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_convert(this, mRes, mCtx)); unitTests.add(new UT_rsdebug(this, mRes, mCtx)); unitTests.add(new UT_rstime(this, mRes, mCtx)); unitTests.add(new UT_rstypes(this, mRes, mCtx)); diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_convert.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_convert.java new file mode 100644 index 0000000..4fc6c55 --- /dev/null +++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_convert.java @@ -0,0 +1,40 @@ +/* + * 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_convert extends UnitTest { + private Resources mRes; + + protected UT_convert(RSTestCore rstc, Resources res, Context ctx) { + super(rstc, "Convert", ctx); + mRes = res; + } + + public void run() { + RenderScript pRS = RenderScript.create(mCtx); + ScriptC_convert s = new ScriptC_convert(pRS, mRes, R.raw.convert); + pRS.setMessageHandler(mRsMessage); + s.invoke_convert_test(); + pRS.finish(); + waitForMessage(); + pRS.destroy(); + } +} diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/convert.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/convert.rs new file mode 100644 index 0000000..e314f2b --- /dev/null +++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/convert.rs @@ -0,0 +1,37 @@ +#include "shared.rsh" + +float4 f4 = { 2.0f, 4.0f, 6.0f, 8.0f }; + +char4 i8_4 = { -1, -2, -3, 4 }; + +static bool test_convert() { + bool failed = false; + + f4 = convert_float4(i8_4); + _RS_ASSERT(f4.x == -1.0f); + _RS_ASSERT(f4.y == -2.0f); + _RS_ASSERT(f4.z == -3.0f); + _RS_ASSERT(f4.w == 4.0f); + + if (failed) { + rsDebug("test_convert FAILED", 0); + } + else { + rsDebug("test_convert PASSED", 0); + } + + return failed; +} + +void convert_test() { + bool failed = false; + failed |= test_convert(); + + if (failed) { + rsSendToClientBlocking(RS_MSG_TEST_FAILED); + } + else { + rsSendToClientBlocking(RS_MSG_TEST_PASSED); + } +} + |