FileDocCategorySizeDatePackage
UT_element.javaAPI DocAndroid 5.1 API3607Thu Mar 12 22:22:54 GMT 2015com.android.rs.test_compat

UT_element

public class UT_element extends UnitTest

Fields Summary
private android.content.res.Resources
mRes
Element
simpleElem
Element
complexElem
final String[]
subElemNames
final int[]
subElemArraySizes
final int[]
subElemOffsets
Constructors Summary
protected UT_element(RSTestCore rstc, android.content.res.Resources res, android.content.Context ctx)


           
        super(rstc, "Element", ctx);
        mRes = res;
    
Methods Summary
private voidinitializeGlobals(RenderScript RS, ScriptC_element s)

        simpleElem = Element.F32_3(RS);
        complexElem = ScriptField_ComplexStruct.createElement(RS);
        s.set_simpleElem(simpleElem);
        s.set_complexElem(complexElem);

        ScriptField_ComplexStruct data = new ScriptField_ComplexStruct(RS, 1);
        s.bind_complexStruct(data);
    
public voidrun()

        RenderScript pRS = RenderScript.create(mCtx);
        testScriptSide(pRS);
        testJavaSide(pRS);
        passTest();
        pRS.destroy();
    
private voidtestJavaSide(RenderScript RS)


        int subElemCount = simpleElem.getSubElementCount();
        _RS_ASSERT("subElemCount == 0", subElemCount == 0);

        subElemCount = complexElem.getSubElementCount();
        _RS_ASSERT("subElemCount == 10", subElemCount == 10);
        _RS_ASSERT("complexElem.getSizeBytes() == ScriptField_ComplexStruct.Item.sizeof",
                   complexElem.getBytesSize() == ScriptField_ComplexStruct.Item.sizeof);

        for (int i = 0; i < subElemCount; i ++) {
            _RS_ASSERT("complexElem.getSubElement(i) != null",
                       complexElem.getSubElement(i) != null);
            _RS_ASSERT("complexElem.getSubElementName(i).equals(subElemNames[i])",
                       complexElem.getSubElementName(i).equals(subElemNames[i]));
            _RS_ASSERT("complexElem.getSubElementArraySize(i) == subElemArraySizes[i]",
                       complexElem.getSubElementArraySize(i) == subElemArraySizes[i]);
            _RS_ASSERT("complexElem.getSubElementOffsetBytes(i) == subElemOffsets[i]",
                       complexElem.getSubElementOffsetBytes(i) == subElemOffsets[i]);
        }
    
private voidtestScriptSide(RenderScript pRS)

        ScriptC_element s = new ScriptC_element(pRS);
        pRS.setMessageHandler(mRsMessage);
        initializeGlobals(pRS, s);
        s.invoke_element_test();
        pRS.finish();
        waitForMessage();