Merge changes from topic "parameterized-vts-tests"
am: a3c1ad15b2

Change-Id: Id03c8749461bb4df9a53c2508a2b6e1f1bd60665
diff --git a/Android.bp b/Android.bp
index dbc9fa2..c0058ef 100644
--- a/Android.bp
+++ b/Android.bp
@@ -30,6 +30,11 @@
     ],
 }
 
+cc_library_headers {
+    name: "libhidl_gtest_helpers",
+    export_include_dirs: ["gtest_helpers"],
+}
+
 cc_test {
     name: "libhidl_test",
     defaults: ["libhidl-defaults"],
diff --git a/gtest_helpers/hidl/GtestPrinter.h b/gtest_helpers/hidl/GtestPrinter.h
new file mode 100644
index 0000000..c9f5dd3
--- /dev/null
+++ b/gtest_helpers/hidl/GtestPrinter.h
@@ -0,0 +1,36 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+
+namespace android {
+namespace hardware {
+
+static inline std::string PrintInstanceNameToString(
+        const testing::TestParamInfo<std::string>& info) {
+    // test names need to be unique -> index prefix
+    std::string name = std::to_string(info.index) + "/" + info.param;
+
+    for (size_t i = 0; i < name.size(); i++) {
+        // gtest test names must only contain alphanumeric characters
+        if (!std::isalnum(name[i])) name[i] = '_';
+    }
+
+    return name;
+}
+
+}  // namespace hardware
+}  // namespace android