Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright (C) 2011 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.RenderScript;
     20 import android.test.AndroidTestCase;
     21 
     22 public class RenderScriptTest extends AndroidTestCase {
     23 
     24     /**
     25      * Simple test for Renderscript that executes a passthrough function
     26      * from cts/tests/src/android/renderscript/cts/passthrough.rs.
     27      */
     28     public void testRenderScript() {
     29         RenderScript mRS = RenderScript.create(getContext());
     30         ScriptC_passthrough t = new ScriptC_passthrough(mRS);
     31         t.invoke_passthrough(5);
     32         mRS.finish();
     33         t.destroy();
     34         mRS.destroy();
     35     }
     36 
     37     /**
     38      * Excercise all API calls in the basic RenderScript class.
     39      */
     40     public void testAPI() {
     41         try {
     42             RenderScript mRS = RenderScript.create(null);
     43             fail("should throw NullPointerException.");
     44         } catch (NullPointerException e) {
     45         }
     46 
     47         RenderScript mRS = RenderScript.create(getContext());
     48         mRS.contextDump();
     49         mRS.finish();
     50         assertEquals(mRS.getApplicationContext(),
     51                      getContext().getApplicationContext());
     52         RenderScript.RSErrorHandler mEH = mRS.getErrorHandler();
     53         RenderScript.RSMessageHandler mMH = mRS.getMessageHandler();
     54         mRS.setErrorHandler(mEH);
     55         mRS.setMessageHandler(mMH);
     56         mRS.setPriority(RenderScript.Priority.LOW);
     57         mRS.setPriority(RenderScript.Priority.NORMAL);
     58         mRS.destroy();
     59     }
     60 
     61     /**
     62      * Verify Priority enum properties.
     63      */
     64     public void testPriority() {
     65         assertEquals(RenderScript.Priority.LOW,
     66             RenderScript.Priority.valueOf("LOW"));
     67         assertEquals(RenderScript.Priority.NORMAL,
     68             RenderScript.Priority.valueOf("NORMAL"));
     69         assertEquals(2, RenderScript.Priority.values().length);
     70     }
     71 
     72     /**
     73      * Create a base RSMessageHandler object and run() it.
     74      * Note that most developers will subclass RSMessageHandler and use
     75      * their own non-empty implementation.
     76      */
     77     public void testRSMessageHandler() {
     78         RenderScript.RSMessageHandler mMH = new RenderScript.RSMessageHandler();
     79         mMH.run();
     80     }
     81 
     82     /**
     83      * Create a base RSErrorHandler object and run() it.
     84      * Note that most developers will subclass RSErrorHandler and use
     85      * their own non-empty implementation.
     86      */
     87     public void testRSErrorHandler() {
     88         RenderScript.RSErrorHandler mEH = new RenderScript.RSErrorHandler();
     89         mEH.run();
     90     }
     91 }
     92