Home | History | Annotate | Download | only in cts
      1 /*
      2  * Copyright (C) 2011-2012 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.Float4;
     20 
     21 public class StructPadTest extends RSBaseCompute {
     22     /**
     23      * Test for appropriate alignment/padding of structures.
     24      */
     25     public void testStructPadding() {
     26         mRS.setErrorHandler(mRsError);
     27         ScriptC_struct_pad pad = new ScriptC_struct_pad(mRS);
     28         ScriptField_PadMe S = new ScriptField_PadMe(mRS, 1);
     29         Float4 F4 = new Float4(1.0f, 2.0f, 3.0f, 4.0f);
     30 
     31         S.set_i(0, 7, true);
     32         S.set_f4(0, F4, true);
     33         S.set_j(0, 9, true);
     34 
     35         ScriptField_PadMe.Item I = new ScriptField_PadMe.Item();
     36         I.i = S.get_i(0);
     37         I.f4 = S.get_f4(0);
     38         I.j = S.get_j(0);
     39 
     40         S.set(new ScriptField_PadMe.Item(), 0, true);
     41 
     42         pad.set_s(I);
     43         pad.invoke_verify();
     44         waitForMessage();
     45 
     46         pad.destroy();
     47 
     48         checkForErrors();
     49     }
     50 }
     51