[libcamera-devel,v10,16/19] lc-compliance: Move role to string conversion to its own function
diff mbox series

Message ID 20221228223003.2265712-17-paul.elder@ideasonboard.com
State New
Headers show
Series
  • lc-compliance: Add test to queue more requests than hardware depth
Related show

Commit Message

Paul Elder Dec. 28, 2022, 10:30 p.m. UTC
From: NĂ­colas F. R. A. Prado <nfraprado@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@collabora.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Paul Elder <paul.elder@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(-)

Patch
diff mbox series

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));
 }
 
 /*