Message ID | 20221216122939.256534-19-paul.elder@ideasonboard.com |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Hi On 12/16/22 5:59 PM, Paul Elder via libcamera-devel wrote: > From: Nícolas F. R. A. Prado <nfraprado@collabora.com> > > Add a test in lc-compliance to check that the MinimumRequests property > is set and valid, that is, greater than 0. > > Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com> > Reviewed-by: Paul Elder <paul.elder@ideasonboard.com> > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> > > --- > Changes in v9: > - rebased > > Changes in v8: > - Moved RequiredProperties test to property_test.cpp > - Moved CameraTests to new test_base.{cpp,h} files > > Changes in v7: > - New > --- > src/apps/lc-compliance/meson.build | 1 + > src/apps/lc-compliance/property_test.cpp | 24 ++++++++++++++++++++++++ > src/apps/lc-compliance/test_base.cpp | 10 ++++++++++ > src/apps/lc-compliance/test_base.h | 7 +++++++ > 4 files changed, 42 insertions(+) > create mode 100644 src/apps/lc-compliance/property_test.cpp > > diff --git a/src/apps/lc-compliance/meson.build b/src/apps/lc-compliance/meson.build > index fae290bb..a10a3cc2 100644 > --- a/src/apps/lc-compliance/meson.build > +++ b/src/apps/lc-compliance/meson.build > @@ -14,6 +14,7 @@ lc_compliance_sources = files([ > 'capture_test.cpp', > 'environment.cpp', > 'main.cpp', > + 'property_test.cpp', > 'simple_capture.cpp', > 'test_base.cpp', > ]) > diff --git a/src/apps/lc-compliance/property_test.cpp b/src/apps/lc-compliance/property_test.cpp > new file mode 100644 > index 00000000..6a0951b2 > --- /dev/null > +++ b/src/apps/lc-compliance/property_test.cpp > @@ -0,0 +1,24 @@ > +/* SPDX-License-Identifier: GPL-2.0-or-later */ > +/* > + * Copyright (C) 2021, Collabora Ltd. > + * > + * property_test.cpp - Test camera properties > + */ > + > +#include <libcamera/libcamera.h> > + > +#include <gtest/gtest.h> > + > +#include "test_base.h" > + > +using namespace libcamera; > + > +TEST_F(CameraTests, RequiredProperties) > +{ > + const ControlList &properties = camera_->properties(); > + > + using namespace properties; > + > + EXPECT_GT(properties.get(MinimumRequests), 0) > + << "Camera should have a positive value for MinimumRequests property"; > +} > diff --git a/src/apps/lc-compliance/test_base.cpp b/src/apps/lc-compliance/test_base.cpp > index c9957b9e..a5e64c8b 100644 > --- a/src/apps/lc-compliance/test_base.cpp > +++ b/src/apps/lc-compliance/test_base.cpp > @@ -26,3 +26,13 @@ void CameraHolder::releaseCamera() > camera_->release(); > camera_.reset(); > } > + > +void CameraTests::SetUp() > +{ > + acquireCamera(); > +} > + > +void CameraTests::TearDown() > +{ > + releaseCamera(); > +} > diff --git a/src/apps/lc-compliance/test_base.h b/src/apps/lc-compliance/test_base.h > index 52347749..8125e1c6 100644 > --- a/src/apps/lc-compliance/test_base.h > +++ b/src/apps/lc-compliance/test_base.h > @@ -21,4 +21,11 @@ protected: > std::shared_ptr<libcamera::Camera> camera_; > }; > > +class CameraTests : public ::testing::Test, public CameraHolder > +{ > +protected: > + void SetUp() override; > + void TearDown() override; > +}; > + > #endif /* __LC_COMPLIANCE_TEST_BASE_H__ */
diff --git a/src/apps/lc-compliance/meson.build b/src/apps/lc-compliance/meson.build index fae290bb..a10a3cc2 100644 --- a/src/apps/lc-compliance/meson.build +++ b/src/apps/lc-compliance/meson.build @@ -14,6 +14,7 @@ lc_compliance_sources = files([ 'capture_test.cpp', 'environment.cpp', 'main.cpp', + 'property_test.cpp', 'simple_capture.cpp', 'test_base.cpp', ]) diff --git a/src/apps/lc-compliance/property_test.cpp b/src/apps/lc-compliance/property_test.cpp new file mode 100644 index 00000000..6a0951b2 --- /dev/null +++ b/src/apps/lc-compliance/property_test.cpp @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2021, Collabora Ltd. + * + * property_test.cpp - Test camera properties + */ + +#include <libcamera/libcamera.h> + +#include <gtest/gtest.h> + +#include "test_base.h" + +using namespace libcamera; + +TEST_F(CameraTests, RequiredProperties) +{ + const ControlList &properties = camera_->properties(); + + using namespace properties; + + EXPECT_GT(properties.get(MinimumRequests), 0) + << "Camera should have a positive value for MinimumRequests property"; +} diff --git a/src/apps/lc-compliance/test_base.cpp b/src/apps/lc-compliance/test_base.cpp index c9957b9e..a5e64c8b 100644 --- a/src/apps/lc-compliance/test_base.cpp +++ b/src/apps/lc-compliance/test_base.cpp @@ -26,3 +26,13 @@ void CameraHolder::releaseCamera() camera_->release(); camera_.reset(); } + +void CameraTests::SetUp() +{ + acquireCamera(); +} + +void CameraTests::TearDown() +{ + releaseCamera(); +} diff --git a/src/apps/lc-compliance/test_base.h b/src/apps/lc-compliance/test_base.h index 52347749..8125e1c6 100644 --- a/src/apps/lc-compliance/test_base.h +++ b/src/apps/lc-compliance/test_base.h @@ -21,4 +21,11 @@ protected: std::shared_ptr<libcamera::Camera> camera_; }; +class CameraTests : public ::testing::Test, public CameraHolder +{ +protected: + void SetUp() override; + void TearDown() override; +}; + #endif /* __LC_COMPLIANCE_TEST_BASE_H__ */