[libcamera-devel] [PATCH v8 17/17] lc-compliance: Add test to ensure MinimumRequests is valid
Paul Elder
paul.elder at ideasonboard.com
Thu Dec 1 12:32:00 CET 2022
On Tue, Aug 24, 2021 at 04:56:36PM -0300, NĂcolas F. R. A. Prado wrote:
> 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 at collabora.com>
Reviewed-by: Paul Elder <paul.elder at ideasonboard.com>
>
> ---
>
> Changes in v8:
> - Moved RequiredProperties test to property_test.cpp
> - Moved CameraTests to new test_base.{cpp,h} files
>
> Changes in v7:
> - New
>
> src/lc-compliance/meson.build | 1 +
> src/lc-compliance/property_test.cpp | 24 ++++++++++++++++++++++++
> src/lc-compliance/test_base.cpp | 10 ++++++++++
> src/lc-compliance/test_base.h | 7 +++++++
> 4 files changed, 42 insertions(+)
> create mode 100644 src/lc-compliance/property_test.cpp
>
> diff --git a/src/lc-compliance/meson.build b/src/lc-compliance/meson.build
> index db593a6ec201..0c7e750b8264 100644
> --- a/src/lc-compliance/meson.build
> +++ b/src/lc-compliance/meson.build
> @@ -16,6 +16,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/lc-compliance/property_test.cpp b/src/lc-compliance/property_test.cpp
> new file mode 100644
> index 000000000000..6a0951b2ce53
> --- /dev/null
> +++ b/src/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/lc-compliance/test_base.cpp b/src/lc-compliance/test_base.cpp
> index c9957b9efd36..a5e64c8b8144 100644
> --- a/src/lc-compliance/test_base.cpp
> +++ b/src/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/lc-compliance/test_base.h b/src/lc-compliance/test_base.h
> index 52347749ab10..8125e1c60af7 100644
> --- a/src/lc-compliance/test_base.h
> +++ b/src/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__ */
> --
> 2.33.0
>
More information about the libcamera-devel
mailing list