summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/apps/lc-compliance/meson.build1
-rw-r--r--src/apps/lc-compliance/tests/configure_test.cpp52
2 files changed, 53 insertions, 0 deletions
diff --git a/src/apps/lc-compliance/meson.build b/src/apps/lc-compliance/meson.build
index c927dd12..c53b2603 100644
--- a/src/apps/lc-compliance/meson.build
+++ b/src/apps/lc-compliance/meson.build
@@ -15,6 +15,7 @@ lc_compliance_sources = files([
'helpers/capture.cpp',
'main.cpp',
'tests/capture_test.cpp',
+ 'tests/configure_test.cpp',
'tests/controls_test.cpp'
])
diff --git a/src/apps/lc-compliance/tests/configure_test.cpp b/src/apps/lc-compliance/tests/configure_test.cpp
new file mode 100644
index 00000000..2ac605f7
--- /dev/null
+++ b/src/apps/lc-compliance/tests/configure_test.cpp
@@ -0,0 +1,52 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2023, Ideas On Board Oy
+ *
+ * configure_test.cpp - Camera configuration tests
+ */
+
+#include <gtest/gtest.h>
+
+#include "environment.h"
+
+using namespace libcamera;
+
+class ConfigureTest : public testing::Test
+{
+protected:
+ void SetUp() override;
+ void TearDown() override;
+
+ std::shared_ptr<Camera> camera_;
+};
+
+void ConfigureTest::SetUp()
+{
+ Environment *env = Environment::get();
+
+ camera_ = env->cm()->get(env->cameraId());
+
+ ASSERT_EQ(camera_->acquire(), 0);
+}
+
+void ConfigureTest::TearDown()
+{
+ if (!camera_)
+ return;
+
+ camera_->release();
+ camera_.reset();
+}
+
+/* Test that an empty config doesn't get accepted by the camera. */
+TEST_F(ConfigureTest, EmptyConfig)
+{
+ auto emptyConfig = camera_->generateConfiguration({});
+ ASSERT_EQ(emptyConfig->size(), 0);
+
+ CameraConfiguration::Status status = emptyConfig->validate();
+ ASSERT_EQ(status, CameraConfiguration::Invalid);
+
+ int ret = camera_->configure(emptyConfig.get());
+ ASSERT_EQ(ret, -EINVAL);
+}