1// This file is automatically generated from
2// frameworks/rs/tests/java_api/RSUnitTests/RSUnitTests.py
3/*
4 * Copyright (C) 2017 The Android Open Source Project
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 *      http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19package com.android.rs.unittest;
20
21import android.content.Context;
22import android.support.v8.renderscript.Allocation;
23import android.support.v8.renderscript.Element;
24import android.support.v8.renderscript.RenderScript;
25import android.support.v8.renderscript.Script;
26import android.support.v8.renderscript.Type;
27
28public class UT_foreach_bounds extends UnitTest {
29    private Allocation A;
30
31    public UT_foreach_bounds(Context ctx) {
32        super("ForEach (bounds)", ctx);
33    }
34
35    private void initializeGlobals(RenderScript RS, ScriptC_foreach_bounds s) {
36        Type.Builder typeBuilder = new Type.Builder(RS, Element.I32(RS));
37        int X = 5;
38        int Y = 7;
39        final int xStart = 2;
40        final int xEnd = 5;
41        final int yStart = 3;
42        final int yEnd = 6;
43        s.set_dimX(X);
44        s.set_dimY(Y);
45        typeBuilder.setX(X).setY(Y);
46        A = Allocation.createTyped(RS, typeBuilder.create());
47        s.set_aRaw(A);
48        s.set_s(s);
49        s.set_ain(A);
50        s.set_aout(A);
51        s.set_xStart(xStart);
52        s.set_xEnd(xEnd);
53        s.set_yStart(yStart);
54        s.set_yEnd(yEnd);
55        s.forEach_zero(A);
56
57        Script.LaunchOptions sc = new Script.LaunchOptions();
58        sc.setX(xStart, xEnd).setY(yStart, yEnd);
59        s.forEach_root(A, sc);
60
61        return;
62    }
63
64    public void run() {
65        RenderScript pRS = createRenderScript(true);
66        ScriptC_foreach_bounds s = new ScriptC_foreach_bounds(pRS);
67        initializeGlobals(pRS, s);
68        s.invoke_verify_root();
69        s.invoke_foreach_bounds_test();
70        pRS.finish();
71        A.getType().destroy();
72        A.destroy();
73        s.destroy();
74        pRS.destroy();
75    }
76}
77