1 /* 2 * Copyright (C) 2020 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 DRM_HAL_TEST_V1_3_H 18 #define DRM_HAL_TEST_V1_3_H 19 20 #include <android/hardware/drm/1.3/ICryptoFactory.h> 21 #include <android/hardware/drm/1.3/IDrmFactory.h> 22 #include <gtest/gtest.h> 23 #include <hidl/HidlSupport.h> 24 #include <hidl/ServiceManagement.h> 25 #include <log/log.h> 26 27 #include <algorithm> 28 #include <iterator> 29 #include <string> 30 #include <utility> 31 #include <vector> 32 33 #include "drm_hal_vendor_module_api.h" 34 #include "drm_vts_helper.h" 35 #include "vendor_modules.h" 36 #include "VtsHalHidlTargetCallbackBase.h" 37 38 namespace android { 39 namespace hardware { 40 namespace drm { 41 namespace V1_3 { 42 namespace vts { 43 44 using android::hardware::hidl_array; 45 using android::hardware::hidl_string; 46 47 using drm_vts::DrmHalTestParam; 48 49 using IDrmFactoryV1_3 = android::hardware::drm::V1_3::IDrmFactory; 50 using IDrmPluginV1_0 = android::hardware::drm::V1_0::IDrmPlugin; 51 using StatusV1_0 = android::hardware::drm::V1_0::Status; 52 53 class DrmHalTestV1_3 : public ::testing::TestWithParam<DrmHalTestParam> { 54 public: DrmHalTestV1_3()55 DrmHalTestV1_3() 56 : drmFactory_(IDrmFactoryV1_3::getService(GetParam().instance_)) {} 57 SetUp()58 virtual void SetUp() override { 59 ASSERT_NE(drmFactory_, nullptr); 60 61 // create plugin 62 hidl_string packageName("android.hardware.drm.V1_3.vts"); 63 auto res = drmFactory_->createPlugin( 64 GetParam().scheme_, packageName, 65 [&](StatusV1_0 status, const sp<IDrmPluginV1_0>& pluginV1_0) { 66 EXPECT_EQ(StatusV1_0::OK, status); 67 drmPlugin_ = pluginV1_0; 68 }); 69 EXPECT_TRUE(res.isOk()); 70 ASSERT_NE(drmPlugin_, nullptr); 71 } 72 TearDown()73 virtual void TearDown() override {} 74 75 protected: 76 sp<IDrmFactoryV1_3> drmFactory_; 77 sp<IDrmPluginV1_0> drmPlugin_; 78 }; 79 80 } // namespace vts 81 } // namespace V1_3 82 } // namespace drm 83 } // namespace hardware 84 } // namespace android 85 86 #endif // DRM_HAL_TEST_V1_3_H 87