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; 18 19import android.content.Context; 20import android.content.res.Resources; 21import android.renderscript.*; 22 23public class UT_check_dims extends UnitTest { 24 private Resources mRes; 25 byte mFailedArr[]; 26 int mData[]; 27 Allocation mA; 28 static final int Pattern = 0xA5A5A5A5; 29 30 protected UT_check_dims(RSTestCore rstc, Resources res, Context ctx) { 31 super(rstc, "Check Dims", ctx); 32 mRes = res; 33 } 34 35 private void initializeGlobals(RenderScript RS, ScriptC_check_dims s) { 36 Type.Builder typeBuilder = new Type.Builder(RS, Element.U8(RS)); 37 typeBuilder.setX(1); 38 Allocation AFailed = Allocation.createTyped(RS, typeBuilder.create()); 39 s.set_aFailed(AFailed); 40 41 mFailedArr = new byte[1]; 42 mFailedArr[0] = 0; 43 AFailed.copyFrom(mFailedArr); 44 45 typeBuilder = new Type.Builder(RS, Element.I32(RS)); 46 int X = 5; 47 int Y = 7; 48 typeBuilder.setX(X).setY(Y); 49 mA = Allocation.createTyped(RS, typeBuilder.create()); 50 s.set_pattern(Pattern); 51 52 mData = new int[X*Y]; 53 for (int i = 0; i < X*Y; i++) { 54 mData[i] = Pattern; 55 } 56 mA.copyFrom(mData); 57 58 return; 59 } 60 61 public void run() { 62 RenderScript pRS = RenderScript.create(mCtx); 63 ScriptC_check_dims s = new ScriptC_check_dims(pRS); 64 pRS.setMessageHandler(mRsMessage); 65 initializeGlobals(pRS, s); 66 s.forEach_root(mA); 67 s.invoke_check_dims_test(); 68 pRS.finish(); 69 waitForMessage(); 70 pRS.destroy(); 71 } 72} 73