Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c97992b4 authored by Stephen Hines's avatar Stephen Hines Committed by Android (Google) Code Review
Browse files

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

parents ff35de85 071abd1a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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);
        }
+57 −0
Original line number Diff line number Diff line
/*
 * 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();
    }
}
+1 −2
Original line number Diff line number Diff line
@@ -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();
+1 −1
Original line number Diff line number Diff line
@@ -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();
+18 −2
Original line number Diff line number Diff line
@@ -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;
    }
Loading