Merge "Add test for "public final static"-reflected constant fields."

This commit is contained in:
Stephen Hines
2012-02-01 14:01:35 -08:00
committed by Android (Google) Code Review
6 changed files with 98 additions and 6 deletions

View File

@@ -65,6 +65,7 @@ public class RSTestCore {
unitTests = new ArrayList<UnitTest>();
unitTests.add(new UT_primitives(this, mRes, mCtx));
unitTests.add(new UT_constant(this, mRes, mCtx));
unitTests.add(new UT_vector(this, mRes, mCtx));
unitTests.add(new UT_rsdebug(this, mRes, mCtx));
unitTests.add(new UT_rstime(this, mRes, mCtx));
@@ -93,7 +94,7 @@ public class RSTestCore {
for (int i = 0; i < uta.length; i++) {
ScriptField_ListAllocs_s.Item listElem = new ScriptField_ListAllocs_s.Item();
listElem.text = Allocation.createFromString(mRS, uta[i].name, Allocation.USAGE_SCRIPT);
listElem.result = uta[i].result;
listElem.result = uta[i].getResult();
mListAllocs.set(listElem, i, false);
uta[i].setItem(listElem);
}

View File

@@ -0,0 +1,57 @@
/*
* 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_constant extends UnitTest {
private Resources mRes;
protected UT_constant(RSTestCore rstc, Resources res, Context ctx) {
super(rstc, "Const", ctx);
mRes = res;
}
private void Assert(boolean b) {
if (!b) {
failTest();
}
}
public void run() {
Assert(ScriptC_constant.const_floatTest == 1.99f);
Assert(ScriptC_constant.const_doubleTest == 2.05);
Assert(ScriptC_constant.const_charTest == -8);
Assert(ScriptC_constant.const_shortTest == -16);
Assert(ScriptC_constant.const_intTest == -32);
Assert(ScriptC_constant.const_longTest == 17179869184l);
Assert(ScriptC_constant.const_longlongTest == 68719476736l);
Assert(ScriptC_constant.const_ucharTest == 8);
Assert(ScriptC_constant.const_ushortTest == 16);
Assert(ScriptC_constant.const_uintTest == 32);
Assert(ScriptC_constant.const_ulongTest == 4611686018427387904L);
Assert(ScriptC_constant.const_int64_tTest == -17179869184l);
Assert(ScriptC_constant.const_uint64_tTest == 117179869184l);
Assert(ScriptC_constant.const_boolTest == true);
passTest();
}
}

View File

@@ -92,8 +92,7 @@ public class UT_primitives extends UnitTest {
ScriptC_primitives s = new ScriptC_primitives(pRS, mRes, R.raw.primitives);
pRS.setMessageHandler(mRsMessage);
if (!initializeGlobals(s)) {
// initializeGlobals failed
result = -1;
failTest();
} else {
s.invoke_primitives_test(0, 0);
pRS.finish();

View File

@@ -307,7 +307,7 @@ public class UT_vector extends UnitTest {
ScriptC_vector s = new ScriptC_vector(pRS, mRes, R.raw.vector);
pRS.setMessageHandler(mRsMessage);
if (!initializeGlobals(s)) {
result = -1;
failTest();
} else {
s.invoke_vector_test();
pRS.finish();

View File

@@ -21,7 +21,7 @@ import android.renderscript.RenderScript.RSMessageHandler;
public class UnitTest extends Thread {
public String name;
public int result;
private int result;
private ScriptField_ListAllocs_s.Item mItem;
private RSTestCore mRSTC;
private boolean msgHandled;
@@ -63,7 +63,7 @@ public class UnitTest extends Thread {
}
}
protected void updateUI() {
private void updateUI() {
if (mItem != null) {
mItem.result = result;
msgHandled = true;
@@ -104,6 +104,22 @@ public class UnitTest extends Thread {
}
}
public int getResult() {
return result;
}
public void failTest() {
result = -1;
updateUI();
}
public void passTest() {
if (result != -1) {
result = 1;
}
updateUI();
}
public void setItem(ScriptField_ListAllocs_s.Item item) {
mItem = item;
}

View File

@@ -0,0 +1,19 @@
#include "shared.rsh"
const float floatTest = 1.99f;
const double doubleTest = 2.05;
const char charTest = -8;
const short shortTest = -16;
const int intTest = -32;
const long longTest = 17179869184l; // 1 << 34
const long long longlongTest = 68719476736l; // 1 << 36
const uchar ucharTest = 8;
const ushort ushortTest = 16;
const uint uintTest = 32;
const ulong ulongTest = 4611686018427387904L;
const int64_t int64_tTest = -17179869184l; // - 1 << 34
const uint64_t uint64_tTest = 117179869184l;
const bool boolTest = true;