[libcamera-devel] [PATCH v10 16/19] lc-compliance: Move role to string conversion to its own function
Paul Elder
paul.elder at ideasonboard.com
Wed Dec 28 23:30:00 CET 2022
From: Nícolas F. R. A. Prado <nfraprado at collabora.com>
The functions that generate the test name based on the parameters need
to convert a StreamRole to a string. Move this to a separate function to
avoid redundancy.
Signed-off-by: Nícolas F. R. A. Prado <nfraprado at collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder at ideasonboard.com>
Signed-off-by: Paul Elder <paul.elder at ideasonboard.com>
---
Changes in v8:
- Made roleToString()'s map const and changed usage from [] operator to at()
Changes in v5:
- New
---
src/apps/lc-compliance/capture_test.cpp | 25 ++++++++++++++-----------
1 file changed, 14 insertions(+), 11 deletions(-)
diff --git a/src/apps/lc-compliance/capture_test.cpp b/src/apps/lc-compliance/capture_test.cpp
index 2b82443a..d62f7692 100644
--- a/src/apps/lc-compliance/capture_test.cpp
+++ b/src/apps/lc-compliance/capture_test.cpp
@@ -23,6 +23,18 @@ const std::vector<StreamRole> ROLES = {
StreamRole::Viewfinder
};
+static const std::string &roleToString(const StreamRole &role)
+{
+ static const std::map<StreamRole, std::string> rolesMap = {
+ { StreamRole::Raw, "Raw" },
+ { StreamRole::StillCapture, "StillCapture" },
+ { StreamRole::VideoRecording, "VideoRecording" },
+ { StreamRole::Viewfinder, "Viewfinder" }
+ };
+
+ return rolesMap.at(role);
+}
+
class SingleStream : public testing::TestWithParam<std::tuple<StreamRole, int>>, public CameraHolder
{
public:
@@ -49,17 +61,8 @@ void SingleStream::TearDown()
std::string SingleStream::nameParameters(const testing::TestParamInfo<SingleStream::ParamType> &info)
{
- std::map<StreamRole, std::string> rolesMap = {
- { StreamRole::Raw, "Raw" },
- { StreamRole::StillCapture, "StillCapture" },
- { StreamRole::VideoRecording, "VideoRecording" },
- { StreamRole::Viewfinder, "Viewfinder" }
- };
-
- std::string roleName = rolesMap[std::get<0>(info.param)];
- std::string numRequestsName = std::to_string(std::get<1>(info.param));
-
- return roleName + "_" + numRequestsName;
+ return roleToString(std::get<0>(info.param)) + "_" +
+ std::to_string(std::get<1>(info.param));
}
/*
--
2.35.1
More information about the libcamera-devel
mailing list