Home | History | Annotate | Download | only in unittest
      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 
     19 package com.android.rs.unittest;
     20 
     21 import android.content.Context;
     22 import android.support.v8.renderscript.Byte2;
     23 import android.support.v8.renderscript.Byte3;
     24 import android.support.v8.renderscript.Byte4;
     25 import android.support.v8.renderscript.Double2;
     26 import android.support.v8.renderscript.Double3;
     27 import android.support.v8.renderscript.Double4;
     28 import android.support.v8.renderscript.Float2;
     29 import android.support.v8.renderscript.Float3;
     30 import android.support.v8.renderscript.Float4;
     31 import android.support.v8.renderscript.Int2;
     32 import android.support.v8.renderscript.Int3;
     33 import android.support.v8.renderscript.Int4;
     34 import android.support.v8.renderscript.Long2;
     35 import android.support.v8.renderscript.Long3;
     36 import android.support.v8.renderscript.Long4;
     37 import android.support.v8.renderscript.RenderScript;
     38 import android.support.v8.renderscript.Short2;
     39 import android.support.v8.renderscript.Short3;
     40 import android.support.v8.renderscript.Short4;
     41 
     42 public class UT_vector extends UnitTest {
     43 
     44     public UT_vector(Context ctx) {
     45         super("Vector", ctx);
     46     }
     47 
     48     private boolean initializeGlobals(ScriptC_vector s) {
     49         Float2 F2 = s.get_f2();
     50         if (F2.x != 1.0f || F2.y != 2.0f) {
     51             return false;
     52         }
     53         F2.x = 2.99f;
     54         F2.y = 3.99f;
     55         s.set_f2(F2);
     56 
     57         Float3 F3 = s.get_f3();
     58         if (F3.x != 1.0f || F3.y != 2.0f || F3.z != 3.0f) {
     59             return false;
     60         }
     61         F3.x = 2.99f;
     62         F3.y = 3.99f;
     63         F3.z = 4.99f;
     64         s.set_f3(F3);
     65 
     66         Float4 F4 = s.get_f4();
     67         if (F4.x != 1.0f || F4.y != 2.0f || F4.z != 3.0f || F4.w != 4.0f) {
     68             return false;
     69         }
     70         F4.x = 2.99f;
     71         F4.y = 3.99f;
     72         F4.z = 4.99f;
     73         F4.w = 5.99f;
     74         s.set_f4(F4);
     75 
     76         Double2 D2 = s.get_d2();
     77         if (D2.x != 1.0 || D2.y != 2.0) {
     78             return false;
     79         }
     80         D2.x = 2.99;
     81         D2.y = 3.99;
     82         s.set_d2(D2);
     83 
     84         Double3 D3 = s.get_d3();
     85         if (D3.x != 1.0 || D3.y != 2.0 || D3.z != 3.0) {
     86             return false;
     87         }
     88         D3.x = 2.99;
     89         D3.y = 3.99;
     90         D3.z = 4.99;
     91         s.set_d3(D3);
     92 
     93         Double4 D4 = s.get_d4();
     94         if (D4.x != 1.0 || D4.y != 2.0 || D4.z != 3.0 || D4.w != 4.0) {
     95             return false;
     96         }
     97         D4.x = 2.99;
     98         D4.y = 3.99;
     99         D4.z = 4.99;
    100         D4.w = 5.99;
    101         s.set_d4(D4);
    102 
    103         Byte2 B2 = s.get_i8_2();
    104         if (B2.x != 1 || B2.y != 2) {
    105             return false;
    106         }
    107         B2.x = 2;
    108         B2.y = 3;
    109         s.set_i8_2(B2);
    110 
    111         Byte3 B3 = s.get_i8_3();
    112         if (B3.x != 1 || B3.y != 2 || B3.z != 3) {
    113             return false;
    114         }
    115         B3.x = 2;
    116         B3.y = 3;
    117         B3.z = 4;
    118         s.set_i8_3(B3);
    119 
    120         Byte4 B4 = s.get_i8_4();
    121         if (B4.x != 1 || B4.y != 2 || B4.z != 3 || B4.w != 4) {
    122             return false;
    123         }
    124         B4.x = 2;
    125         B4.y = 3;
    126         B4.z = 4;
    127         B4.w = 5;
    128         s.set_i8_4(B4);
    129 
    130         Short2 S2 = s.get_u8_2();
    131         if (S2.x != 1 || S2.y != 2) {
    132             return false;
    133         }
    134         S2.x = 2;
    135         S2.y = 3;
    136         s.set_u8_2(S2);
    137 
    138         Short3 S3 = s.get_u8_3();
    139         if (S3.x != 1 || S3.y != 2 || S3.z != 3) {
    140             return false;
    141         }
    142         S3.x = 2;
    143         S3.y = 3;
    144         S3.z = 4;
    145         s.set_u8_3(S3);
    146 
    147         Short4 S4 = s.get_u8_4();
    148         if (S4.x != 1 || S4.y != 2 || S4.z != 3 || S4.w != 4) {
    149             return false;
    150         }
    151         S4.x = 2;
    152         S4.y = 3;
    153         S4.z = 4;
    154         S4.w = 5;
    155         s.set_u8_4(S4);
    156 
    157         S2 = s.get_i16_2();
    158         if (S2.x != 1 || S2.y != 2) {
    159             return false;
    160         }
    161         S2.x = 2;
    162         S2.y = 3;
    163         s.set_i16_2(S2);
    164 
    165         S3 = s.get_i16_3();
    166         if (S3.x != 1 || S3.y != 2 || S3.z != 3) {
    167             return false;
    168         }
    169         S3.x = 2;
    170         S3.y = 3;
    171         S3.z = 4;
    172         s.set_i16_3(S3);
    173 
    174         S4 = s.get_i16_4();
    175         if (S4.x != 1 || S4.y != 2 || S4.z != 3 || S4.w != 4) {
    176             return false;
    177         }
    178         S4.x = 2;
    179         S4.y = 3;
    180         S4.z = 4;
    181         S4.w = 5;
    182         s.set_i16_4(S4);
    183 
    184         Int2 I2 = s.get_u16_2();
    185         if (I2.x != 1 || I2.y != 2) {
    186             return false;
    187         }
    188         I2.x = 2;
    189         I2.y = 3;
    190         s.set_u16_2(I2);
    191 
    192         Int3 I3 = s.get_u16_3();
    193         if (I3.x != 1 || I3.y != 2 || I3.z != 3) {
    194             return false;
    195         }
    196         I3.x = 2;
    197         I3.y = 3;
    198         I3.z = 4;
    199         s.set_u16_3(I3);
    200 
    201         Int4 I4 = s.get_u16_4();
    202         if (I4.x != 1 || I4.y != 2 || I4.z != 3 || I4.w != 4) {
    203             return false;
    204         }
    205         I4.x = 2;
    206         I4.y = 3;
    207         I4.z = 4;
    208         I4.w = 5;
    209         s.set_u16_4(I4);
    210 
    211         I2 = s.get_i32_2();
    212         if (I2.x != 1 || I2.y != 2) {
    213             return false;
    214         }
    215         I2.x = 2;
    216         I2.y = 3;
    217         s.set_i32_2(I2);
    218 
    219         I3 = s.get_i32_3();
    220         if (I3.x != 1 || I3.y != 2 || I3.z != 3) {
    221             return false;
    222         }
    223         I3.x = 2;
    224         I3.y = 3;
    225         I3.z = 4;
    226         s.set_i32_3(I3);
    227 
    228         I4 = s.get_i32_4();
    229         if (I4.x != 1 || I4.y != 2 || I4.z != 3 || I4.w != 4) {
    230             return false;
    231         }
    232         I4.x = 2;
    233         I4.y = 3;
    234         I4.z = 4;
    235         I4.w = 5;
    236         s.set_i32_4(I4);
    237 
    238         Long2 L2 = s.get_u32_2();
    239         if (L2.x != 1 || L2.y != 2) {
    240             return false;
    241         }
    242         L2.x = 2;
    243         L2.y = 3;
    244         s.set_u32_2(L2);
    245 
    246         Long3 L3 = s.get_u32_3();
    247         if (L3.x != 1 || L3.y != 2 || L3.z != 3) {
    248             return false;
    249         }
    250         L3.x = 2;
    251         L3.y = 3;
    252         L3.z = 4;
    253         s.set_u32_3(L3);
    254 
    255         Long4 L4 = s.get_u32_4();
    256         if (L4.x != 1 || L4.y != 2 || L4.z != 3 || L4.w != 4) {
    257             return false;
    258         }
    259         L4.x = 2;
    260         L4.y = 3;
    261         L4.z = 4;
    262         L4.w = 5;
    263         s.set_u32_4(L4);
    264 
    265         L2 = s.get_i64_2();
    266         if (L2.x != 1 || L2.y != 2) {
    267             return false;
    268         }
    269         L2.x = 2;
    270         L2.y = 3;
    271         s.set_i64_2(L2);
    272 
    273         L3 = s.get_i64_3();
    274         if (L3.x != 1 || L3.y != 2 || L3.z != 3) {
    275             return false;
    276         }
    277         L3.x = 2;
    278         L3.y = 3;
    279         L3.z = 4;
    280         s.set_i64_3(L3);
    281 
    282         L4 = s.get_i64_4();
    283         if (L4.x != 1 || L4.y != 2 || L4.z != 3 || L4.w != 4) {
    284             return false;
    285         }
    286         L4.x = 2;
    287         L4.y = 3;
    288         L4.z = 4;
    289         L4.w = 5;
    290         s.set_i64_4(L4);
    291 
    292         L2 = s.get_u64_2();
    293         if (L2.x != 1 || L2.y != 2) {
    294             return false;
    295         }
    296         L2.x = 2;
    297         L2.y = 3;
    298         s.set_u64_2(L2);
    299 
    300         L3 = s.get_u64_3();
    301         if (L3.x != 1 || L3.y != 2 || L3.z != 3) {
    302             return false;
    303         }
    304         L3.x = 2;
    305         L3.y = 3;
    306         L3.z = 4;
    307         s.set_u64_3(L3);
    308 
    309         L4 = s.get_u64_4();
    310         if (L4.x != 1 || L4.y != 2 || L4.z != 3 || L4.w != 4) {
    311             return false;
    312         }
    313         L4.x = 2;
    314         L4.y = 3;
    315         L4.z = 4;
    316         L4.w = 5;
    317         s.set_u64_4(L4);
    318 
    319         return true;
    320     }
    321 
    322     public void run() {
    323         RenderScript pRS = createRenderScript(true);
    324         ScriptC_vector s = new ScriptC_vector(pRS);
    325         if (!initializeGlobals(s)) {
    326             failTest();
    327         } else {
    328             s.invoke_vector_test();
    329             pRS.finish();
    330         }
    331         s.destroy();
    332         pRS.destroy();
    333     }
    334 }
    335