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_compat;
18
19import android.content.Context;
20import android.content.res.Resources;
21import android.support.v8.renderscript.*;
22
23public class UT_apitest extends UnitTest {
24    private Resources mRes;
25
26    protected UT_apitest(RSTestCore rstc, Resources res, Context ctx) {
27        super(rstc, "API Test", ctx);
28        mRes = res;
29    }
30
31    public void run() {
32        RenderScript pRS = RenderScript.create(mCtx);
33        ScriptC_apitest s = new ScriptC_apitest(pRS);
34        pRS.setMessageHandler(mRsMessage);
35        Element elem = Element.I8(pRS);
36        Type.Builder typeBuilder = new Type.Builder(pRS, elem);
37
38        int x = 5;
39        int y = 7;
40        int z = 0;  // Don't actually setZ()
41        s.set_x(x);
42        s.set_y(y);
43        s.set_z(z);
44        typeBuilder.setX(x).setY(y);
45        Type type = typeBuilder.create();
46        Allocation alloc = Allocation.createTyped(pRS, type);
47        Allocation allocDst = Allocation.createTyped(pRS, type);
48        Sampler sampler = Sampler.CLAMP_NEAREST(pRS);
49        s.set_elemNonNull(elem);
50        s.set_typeNonNull(type);
51        s.set_allocNonNull(alloc);
52        s.set_allocDst(allocDst);
53        s.set_samplerNonNull(sampler);
54        s.set_scriptNonNull(s);
55        s.bind_allocPtr(alloc);
56
57        s.invoke_api_test();
58        pRS.finish();
59        waitForMessage();
60        pRS.destroy();
61    }
62}
63