[libcamera-devel,v3,10/13] test: v4l2_device: Test getControl() API

Message ID 20200424215304.558317-11-jacopo@jmondi.org
State Superseded
Headers show
Series
  • libcamera: Add CameraSensorInfo
Related show

Commit Message

Jacopo Mondi April 24, 2020, 9:53 p.m. UTC
Add a simple test for the newly added method.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 test/v4l2_videodevice/controls.cpp | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Patch

diff --git a/test/v4l2_videodevice/controls.cpp b/test/v4l2_videodevice/controls.cpp
index da9e0111e221..cf3d599c43ff 100644
--- a/test/v4l2_videodevice/controls.cpp
+++ b/test/v4l2_videodevice/controls.cpp
@@ -121,6 +121,22 @@  protected:
 			return TestFail;
 		}
 
+		/* Test the getControl() API. */
+		int32_t oldBrightness = ctrls.get(V4L2_CID_BRIGHTNESS).get<int32_t>();
+		int32_t newBrightness;
+		ret = capture_->getControl(V4L2_CID_BRIGHTNESS, &newBrightness);
+		if (ret) {
+			cerr << "Failed to read a single control" << endl;
+			return TestFail;
+		}
+
+		if (newBrightness != oldBrightness) {
+			cerr << "Wrong control value read from device: "
+			     << "got: " << newBrightness << " expected: "
+			     << oldBrightness << endl;
+			return TestFail;
+		}
+
 		return TestPass;
 	}
 };