1 /*
2  * Copyright (C) 2017 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 #ifndef VTS_HAL_RENDERSCRIPT_V1_0_TARGET_TESTS_H
18 #define VTS_HAL_RENDERSCRIPT_V1_0_TARGET_TESTS_H
19 
20 #define LOG_TAG "renderscript_hidl_hal_test"
21 #include <android-base/logging.h>
22 
23 #include <android/hardware/renderscript/1.0/IContext.h>
24 #include <android/hardware/renderscript/1.0/IDevice.h>
25 #include <android/hardware/renderscript/1.0/types.h>
26 
27 #include <VtsHalHidlTargetTestBase.h>
28 #include <VtsHalHidlTargetTestEnvBase.h>
29 #include <gtest/gtest.h>
30 
31 using ::android::hardware::renderscript::V1_0::Allocation;
32 using ::android::hardware::renderscript::V1_0::AllocationAdapter;
33 using ::android::hardware::renderscript::V1_0::AllocationCubemapFace;
34 using ::android::hardware::renderscript::V1_0::AllocationMipmapControl;
35 using ::android::hardware::renderscript::V1_0::AllocationUsageType;
36 using ::android::hardware::renderscript::V1_0::Closure;
37 using ::android::hardware::renderscript::V1_0::IContext;
38 using ::android::hardware::renderscript::V1_0::IDevice;
39 using ::android::hardware::renderscript::V1_0::ContextType;
40 using ::android::hardware::renderscript::V1_0::DataType;
41 using ::android::hardware::renderscript::V1_0::DataKind;
42 using ::android::hardware::renderscript::V1_0::Element;
43 using ::android::hardware::renderscript::V1_0::MessageToClientType;
44 using ::android::hardware::renderscript::V1_0::NativeWindow;
45 using ::android::hardware::renderscript::V1_0::ObjectBase;
46 using ::android::hardware::renderscript::V1_0::OpaqueHandle;
47 using ::android::hardware::renderscript::V1_0::Ptr;
48 using ::android::hardware::renderscript::V1_0::Sampler;
49 using ::android::hardware::renderscript::V1_0::SamplerValue;
50 using ::android::hardware::renderscript::V1_0::Script;
51 using ::android::hardware::renderscript::V1_0::ScriptFieldID;
52 using ::android::hardware::renderscript::V1_0::ScriptGroup;
53 using ::android::hardware::renderscript::V1_0::ScriptGroup2;
54 using ::android::hardware::renderscript::V1_0::ScriptIntrinsicID;
55 using ::android::hardware::renderscript::V1_0::ScriptInvokeID;
56 using ::android::hardware::renderscript::V1_0::ScriptKernelID;
57 using ::android::hardware::renderscript::V1_0::Size;
58 using ::android::hardware::renderscript::V1_0::ThreadPriorities;
59 using ::android::hardware::renderscript::V1_0::Type;
60 using ::android::hardware::renderscript::V1_0::YuvFormat;
61 using ::android::hardware::Return;
62 using ::android::hardware::Void;
63 using ::android::hardware::hidl_vec;
64 using ::android::hardware::hidl_string;
65 using ::android::sp;
66 
67 // bitcode slots
68 extern const int mExportVarIdx_var_int;
69 extern const int mExportVarIdx_var_long;
70 extern const int mExportVarIdx_var_float;
71 extern const int mExportVarIdx_var_double;
72 extern const int mExportVarIdx_var_allocation;
73 extern const int mExportVarIdx_var_uint32_t;
74 extern const int mExportVarIdx_var_point2;
75 extern const int mExportVarIdx_var_int_ptr;
76 // bitcode invoke slots
77 //extern const int mExportForEachIdx_root;
78 extern const int mExportForEachIdx_increment;
79 // bitcode reduce slots
80 extern const int mExportReduceIdx_summation;
81 // bitcode invoke slots
82 extern const int mExportFuncIdx_function;
83 extern const int mExportFuncIdx_functionV;
84 extern const int mExportFuncIdx_setBuffer;
85 extern const int mExportFuncIdx_setAllocation;
86 // bitcode
87 typedef signed char int8_t;
88 extern const int8_t bitCode[];
89 extern const int bitCodeLength;
90 
91 // The main test class for RENDERSCRIPT HIDL HAL.
92 class RenderscriptHidlTest : public ::testing::VtsHalHidlTargetTestBase {
93 public:
94     virtual void SetUp() override;
95     virtual void TearDown() override;
96 
97     sp<IContext>   context;
98 
99 private:
100     sp<IDevice>    device;
101 };
102 
103 // Test environment for RENDERSCRIPT HIDL HAL.
104 class RenderscriptHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
105    public:
106     // get the test environment singleton
Instance()107     static RenderscriptHidlEnvironment* Instance() {
108         static RenderscriptHidlEnvironment* instance = new RenderscriptHidlEnvironment;
109         return instance;
110     }
111 
registerTestServices()112     virtual void registerTestServices() override { registerTestService<IDevice>(); }
113 };
114 
115 #endif // VTS_HAL_RENDERSCRIPT_V1_0_TARGET_TESTS_H
116