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 #include <gtest/gtest.h>
18 #include <hidl/HidlSupport.h>
19 #include <hidl/ServiceManagement.h>
20 
21 #include <algorithm>
22 #include <iterator>
23 #include <set>
24 #include <string>
25 #include <utility>
26 #include <vector>
27 
28 #include "android/hardware/drm/1.1/vts/drm_hal_clearkey_test.h"
29 
30 using android::hardware::drm::V1_1::ICryptoFactory;
31 using android::hardware::drm::V1_1::IDrmFactory;
32 using android::hardware::drm::V1_1::vts::DrmHalClearkeyTest;
33 using android::hardware::drm::V1_1::vts::kClearKeyUUID;
34 
__anonc810a9050102null35 static const std::vector<DrmHalTestParam> kAllInstances = [] {
36     std::vector<std::string> drmInstances =
37             android::hardware::getAllHalInstanceNames(IDrmFactory::descriptor);
38     std::vector<std::string> cryptoInstances =
39             android::hardware::getAllHalInstanceNames(ICryptoFactory::descriptor);
40     std::set<std::string> allInstances;
41     allInstances.insert(drmInstances.begin(), drmInstances.end());
42     allInstances.insert(cryptoInstances.begin(), cryptoInstances.end());
43 
44     std::vector<DrmHalTestParam> allInstancesWithClearKeyUuid;
45     std::transform(allInstances.begin(), allInstances.end(),
46             std::back_inserter(allInstancesWithClearKeyUuid),
47             [](std::string s) { return DrmHalTestParam(s, kClearKeyUUID); });
48     return allInstancesWithClearKeyUuid;
49 }();
50 
51 GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(DrmHalClearkeyTest);
52 INSTANTIATE_TEST_SUITE_P(PerInstance, DrmHalClearkeyTest, testing::ValuesIn(kAllInstances),
53                          PrintParamInstanceToString);
54