summaryrefslogtreecommitdiff
path: root/test/controls/control_list.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/controls/control_list.cpp')
-rw-r--r--test/controls/control_list.cpp137
1 files changed, 117 insertions, 20 deletions
diff --git a/test/controls/control_list.cpp b/test/controls/control_list.cpp
index 5374c6f9..e27325c3 100644
--- a/test/controls/control_list.cpp
+++ b/test/controls/control_list.cpp
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * control_list.cpp - ControlList tests
+ * ControlList tests
*/
#include <iostream>
@@ -12,7 +12,7 @@
#include <libcamera/control_ids.h>
#include <libcamera/controls.h>
-#include "camera_controls.h"
+#include "libcamera/internal/camera_controls.h"
#include "camera_test.h"
#include "test.h"
@@ -24,7 +24,7 @@ class ControlListTest : public CameraTest, public Test
{
public:
ControlListTest()
- : CameraTest("VIMC Sensor B")
+ : CameraTest("platform/vimc.0 Sensor B")
{
}
@@ -50,7 +50,7 @@ protected:
return TestFail;
}
- if (list.contains(controls::Brightness)) {
+ if (list.get(controls::Brightness)) {
cout << "List should not contain Brightness control" << endl;
return TestFail;
}
@@ -68,7 +68,7 @@ protected:
* Set a control, and verify that the list now contains it, and
* nothing else.
*/
- list.set(controls::Brightness, 255);
+ list.set(controls::Brightness, -0.5f);
if (list.empty()) {
cout << "List should not be empty" << endl;
@@ -80,7 +80,7 @@ protected:
return TestFail;
}
- if (!list.contains(controls::Brightness)) {
+ if (!list.get(controls::Brightness)) {
cout << "List should contain Brightness control" << endl;
return TestFail;
}
@@ -94,28 +94,29 @@ protected:
return TestFail;
}
- if (list.get(controls::Brightness) != 255) {
+ if (list.get(controls::Brightness) != -0.5f) {
cout << "Incorrest Brightness control value" << endl;
return TestFail;
}
- if (list.contains(controls::Contrast)) {
+ if (list.get(controls::Contrast)) {
cout << "List should not contain Contract control" << endl;
return TestFail;
}
/* Update the first control and set a second one. */
- list.set(controls::Brightness, 64);
- list.set(controls::Contrast, 128);
+ list.set(controls::Brightness, 0.0f);
+ list.set(controls::Contrast, 1.5f);
- if (!list.contains(controls::Contrast) ||
- !list.contains(controls::Contrast)) {
- cout << "List should contain Contrast control" << endl;
+ if (!list.get(controls::Brightness) ||
+ !list.get(controls::Contrast)) {
+ cout << "List should contain Brightness and Contrast controls"
+ << endl;
return TestFail;
}
- if (list.get(controls::Brightness) != 64 ||
- list.get(controls::Contrast) != 128) {
+ if (list.get(controls::Brightness) != 0.0f ||
+ list.get(controls::Contrast) != 1.5f) {
cout << "Failed to retrieve control value" << endl;
return TestFail;
}
@@ -124,11 +125,11 @@ protected:
* Update both controls and verify that the container doesn't
* grow.
*/
- list.set(controls::Brightness, 10);
- list.set(controls::Contrast, 20);
+ list.set(controls::Brightness, 0.5f);
+ list.set(controls::Contrast, 1.1f);
- if (list.get(controls::Brightness) != 10 ||
- list.get(controls::Contrast) != 20) {
+ if (list.get(controls::Brightness) != 0.5f ||
+ list.get(controls::Contrast) != 1.1f) {
cout << "Failed to update control value" << endl;
return TestFail;
}
@@ -144,11 +145,107 @@ protected:
*/
list.set(controls::AwbEnable, true);
- if (list.contains(controls::AwbEnable)) {
+ if (list.get(controls::AwbEnable)) {
cout << "List shouldn't contain AwbEnable control" << endl;
return TestFail;
}
+ /*
+ * Create a new list with a new control and merge it with the
+ * existing one, verifying that the existing controls
+ * values don't get overwritten.
+ */
+ ControlList mergeList(controls::controls, &validator);
+ mergeList.set(controls::Brightness, 0.7f);
+ mergeList.set(controls::Saturation, 0.4f);
+
+ mergeList.merge(list);
+ if (mergeList.size() != 3) {
+ cout << "Merged list should contain three elements" << endl;
+ return TestFail;
+ }
+
+ if (list.size() != 2) {
+ cout << "The list to merge should contain two elements"
+ << endl;
+ return TestFail;
+ }
+
+ if (!mergeList.get(controls::Brightness) ||
+ !mergeList.get(controls::Contrast) ||
+ !mergeList.get(controls::Saturation)) {
+ cout << "Merged list does not contain all controls" << endl;
+ return TestFail;
+ }
+
+ if (mergeList.get(controls::Brightness) != 0.7f) {
+ cout << "Brightness control value changed after merging lists"
+ << endl;
+ return TestFail;
+ }
+
+ if (mergeList.get(controls::Contrast) != 1.1f) {
+ cout << "Contrast control value changed after merging lists"
+ << endl;
+ return TestFail;
+ }
+
+ if (mergeList.get(controls::Saturation) != 0.4f) {
+ cout << "Saturation control value changed after merging lists"
+ << endl;
+ return TestFail;
+ }
+
+ /*
+ * Create two lists with overlapping controls. Merge them with
+ * overwriteExisting = true, verifying that the existing control
+ * values *get* overwritten.
+ */
+ mergeList.clear();
+ mergeList.set(controls::Brightness, 0.7f);
+ mergeList.set(controls::Saturation, 0.4f);
+
+ list.clear();
+ list.set(controls::Brightness, 0.5f);
+ list.set(controls::Contrast, 1.1f);
+
+ mergeList.merge(list, ControlList::MergePolicy::OverwriteExisting);
+ if (mergeList.size() != 3) {
+ cout << "Merged list should contain three elements" << endl;
+ return TestFail;
+ }
+
+ if (list.size() != 2) {
+ cout << "The list to merge should contain two elements"
+ << endl;
+ return TestFail;
+ }
+
+ if (!mergeList.get(controls::Brightness) ||
+ !mergeList.get(controls::Contrast) ||
+ !mergeList.get(controls::Saturation)) {
+ cout << "Merged list does not contain all controls" << endl;
+ return TestFail;
+ }
+
+ if (mergeList.get(controls::Brightness) != 0.5f) {
+ cout << "Brightness control value did not change after merging lists"
+ << endl;
+ return TestFail;
+ }
+
+ if (mergeList.get(controls::Contrast) != 1.1f) {
+ cout << "Contrast control value changed after merging lists"
+ << endl;
+ return TestFail;
+ }
+
+ if (mergeList.get(controls::Saturation) != 0.4f) {
+ cout << "Saturation control value changed after merging lists"
+ << endl;
+ return TestFail;
+ }
+
return TestPass;
}
};