UT_unsigned.java revision 648a1c137663ef7207684d0d7009dd5518942111
1/*
2 * Copyright (C) 2013 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.rs.test_compatlegacy;
18
19import android.content.Context;
20import android.content.res.Resources;
21import android.support.v8.renderscript.*;
22
23public class UT_unsigned extends UnitTest {
24    private Resources mRes;
25
26    protected UT_unsigned(RSTestCore rstc, Resources res, Context ctx) {
27        super(rstc, "Unsigned", ctx);
28        mRes = res;
29    }
30
31    private boolean initializeGlobals(ScriptC_unsigned s) {
32        short pUC = s.get_uc();
33        if (pUC != 5) {
34            return false;
35        }
36        s.set_uc((short)129);
37
38        long pUI = s.get_ui();
39        if (pUI != 37) {
40            return false;
41        }
42        s.set_ui(0x7fffffff);
43
44        return true;
45    }
46
47    public void run() {
48        RenderScript pRS = RenderScript.create(mCtx);
49        ScriptC_unsigned s = new ScriptC_unsigned(pRS);
50        pRS.setMessageHandler(mRsMessage);
51        if (!initializeGlobals(s)) {
52            failTest();
53        } else {
54            s.invoke_unsigned_test();
55            pRS.finish();
56            waitForMessage();
57        }
58        pRS.destroy();
59    }
60}
61