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_VTS_HELPER_H
18 #define DRM_VTS_HELPER_H
19
20 #include <hidl/GtestPrinter.h>
21 #include <hidl/HidlSupport.h>
22
23 #include <array>
24 #include <chrono>
25 #include <iostream>
26 #include <map>
27 #include <memory>
28 #include <string>
29 #include <utility>
30 #include <vector>
31
32 namespace drm_vts {
33
34 using ::android::hardware::hidl_array;
35
36 struct DrmHalTestParam {
37 const std::string instance_;
38 const hidl_array<uint8_t, 16> scheme_{};
DrmHalTestParamDrmHalTestParam39 DrmHalTestParam(const std::string& instance) : instance_(instance) {}
DrmHalTestParamDrmHalTestParam40 DrmHalTestParam(const std::string& instance, const hidl_array<uint8_t, 16>& scheme)
41 : instance_(instance), scheme_(scheme) {}
42 };
43
44 inline std::ostream& operator<<(std::ostream& stream, const DrmHalTestParam& val) {
45 stream << val.instance_ << ", " << android::hardware::toString(val.scheme_);
46 return stream;
47 }
48
PrintParamInstanceToString(const testing::TestParamInfo<DrmHalTestParam> & info)49 inline std::string PrintParamInstanceToString(
50 const testing::TestParamInfo<DrmHalTestParam>& info) {
51 // test names need to be unique -> index prefix
52 std::string name = std::to_string(info.index) + "/" + info.param.instance_;
53 return android::hardware::Sanitize(name);
54 };
55
56 } // namespace drm_vts
57
58 #endif // DRM_VTS_HELPER_H
59