Home | History | Annotate | Download | only in cts
      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 
     17 package android.renderscript.cts;
     18 
     19 import android.renderscript.BaseObj;
     20 import android.renderscript.Element;
     21 import android.renderscript.RSIllegalArgumentException;
     22 import android.renderscript.Type;
     23 
     24 public class BaseObjTest extends RSBaseCompute {
     25 
     26     public void testBaseObj() {
     27         Element E = Element.I32(mRS);
     28         Type.Builder TB = new Type.Builder(mRS, E);
     29         Type T = TB.setX(1).create();
     30         assertTrue(T != null);
     31         BaseObj B = T;
     32         B.setName("int32_t");
     33         try {
     34             B.setName("int32_t");
     35             fail("set name twice for a BaseObj");
     36         } catch (RSIllegalArgumentException e) {
     37         }
     38         T.destroy();
     39 
     40         T = TB.setX(2).create();
     41         assertTrue(T != null);
     42         B = T;
     43         try {
     44             B.setName("");
     45             fail("set empty name for a BaseObj");
     46         } catch (RSIllegalArgumentException e) {
     47         }
     48 
     49         try {
     50             B.setName(null);
     51             fail("set name as null string reference for a BaseObj");
     52         } catch (RSIllegalArgumentException e) {
     53         }
     54         B.setName("int32_t");
     55 
     56         assertTrue(B.getName().compareTo("int32_t") == 0);
     57         B.destroy();
     58     }
     59 }
     60 
     61