lc-compliance: Add Environment singleton

Add a singleton Environment class in order to make the camera available
inside all tests. This is needed for the Googletest refactor, otherwise
the tests, which are statically declared, won't be able to access the
camera.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Nícolas F. R. A. Prado
2021-07-02 09:21:12 -03:00
committed by Jacopo Mondi
parent 034e0e81a2
commit e5c51e1fcf
3 changed files with 52 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Copyright (C) 2021, Collabora Ltd.
*
* environment.cpp - Common environment for tests
*/
#include "environment.h"
Environment *Environment::get()
{
static Environment instance;
return &instance;
}
void Environment::setup(CameraManager *cm, std::string cameraId)
{
cm_ = cm;
cameraId_ = cameraId;
}

View File

@@ -0,0 +1,31 @@
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Copyright (C) 2021, Collabora Ltd.
*
* environment.h - Common environment for tests
*/
#ifndef __LC_COMPLIANCE_ENVIRONMENT_H__
#define __LC_COMPLIANCE_ENVIRONMENT_H__
#include <libcamera/libcamera.h>
using namespace libcamera;
class Environment
{
public:
static Environment *get();
void setup(CameraManager *cm, std::string cameraId);
const std::string &cameraId() const { return cameraId_; }
CameraManager *cm() const { return cm_; }
private:
Environment() = default;
std::string cameraId_;
CameraManager *cm_;
};
#endif /* __LC_COMPLIANCE_ENVIRONMENT_H__ */

View File

@@ -12,6 +12,7 @@ lc_compliance_enabled = true
lc_compliance_sources = files([
'../cam/event_loop.cpp',
'../cam/options.cpp',
'environment.cpp',
'main.cpp',
'results.cpp',
'simple_capture.cpp',