summaryrefslogtreecommitdiff
path: root/test/controls
diff options
context:
space:
mode:
authorStefan Klug <stefan.klug@ideasonboard.com>2024-03-07 11:27:38 +0100
committerStefan Klug <stefan.klug@ideasonboard.com>2024-03-12 17:04:28 +0100
commitd54abd32affdb7d7458cd2a0889a7afe6a5a5d33 (patch)
tree1df71fcee4f7383ae75898ce408ca492c05b5347 /test/controls
parent2e2ba223f3a249f1c04fe88c2709ca6e7d42c242 (diff)
libcamera: controls: Add policy parameter to ControlList::merge()
This is useful in many cases although not included in the stl. Note: This is an ABI incompatible change. Reviewed-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Diffstat (limited to 'test/controls')
-rw-r--r--test/controls/control_list.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/test/controls/control_list.cpp b/test/controls/control_list.cpp
index c03f230e..bb35aab7 100644
--- a/test/controls/control_list.cpp
+++ b/test/controls/control_list.cpp
@@ -196,6 +196,56 @@ protected:
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;
}
};