summaryrefslogtreecommitdiff
path: root/test/controls
diff options
context:
space:
mode:
Diffstat (limited to 'test/controls')
-rw-r--r--test/controls/control_info.cpp2
-rw-r--r--test/controls/control_info_map.cpp2
-rw-r--r--test/controls/control_list.cpp52
-rw-r--r--test/controls/control_value.cpp82
4 files changed, 134 insertions, 4 deletions
diff --git a/test/controls/control_info.cpp b/test/controls/control_info.cpp
index 1176a502..e1bb43f0 100644
--- a/test/controls/control_info.cpp
+++ b/test/controls/control_info.cpp
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * control_info.cpp - ControlInfo tests
+ * ControlInfo tests
*/
#include <iostream>
diff --git a/test/controls/control_info_map.cpp b/test/controls/control_info_map.cpp
index 29b33515..b0be14b5 100644
--- a/test/controls/control_info_map.cpp
+++ b/test/controls/control_info_map.cpp
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * control_info.cpp - ControlInfoMap tests
+ * ControlInfoMap tests
*/
#include <iostream>
diff --git a/test/controls/control_list.cpp b/test/controls/control_list.cpp
index c03f230e..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>
@@ -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;
}
};
diff --git a/test/controls/control_value.cpp b/test/controls/control_value.cpp
index ad8e05d0..5084fd0c 100644
--- a/test/controls/control_value.cpp
+++ b/test/controls/control_value.cpp
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * control_value.cpp - ControlValue tests
+ * ControlValue tests
*/
#include <algorithm>
@@ -110,6 +110,86 @@ protected:
}
/*
+ * Unsigned Integer16 type.
+ */
+ value.set(static_cast<uint16_t>(42));
+ if (value.isNone() || value.isArray() ||
+ value.type() != ControlTypeUnsigned16) {
+ cerr << "Control type mismatch after setting to uint16_t" << endl;
+ return TestFail;
+ }
+
+ if (value.get<uint16_t>() != 42) {
+ cerr << "Control value mismatch after setting to uint16_t" << endl;
+ return TestFail;
+ }
+
+ if (value.toString() != "42") {
+ cerr << "Control string mismatch after setting to uint16_t" << endl;
+ return TestFail;
+ }
+
+ std::array<uint16_t, 4> uint16s{ 3, 14, 15, 9 };
+ value.set(Span<uint16_t>(uint16s));
+ if (value.isNone() || !value.isArray() ||
+ value.type() != ControlTypeUnsigned16) {
+ cerr << "Control type mismatch after setting to uint16_t array" << endl;
+ return TestFail;
+ }
+
+ Span<const uint16_t> uint16sResult = value.get<Span<const uint16_t>>();
+ if (uint16s.size() != uint16sResult.size() ||
+ !std::equal(uint16s.begin(), uint16s.end(), uint16sResult.begin())) {
+ cerr << "Control value mismatch after setting to uint16_t array" << endl;
+ return TestFail;
+ }
+
+ if (value.toString() != "[ 3, 14, 15, 9 ]") {
+ cerr << "Control string mismatch after setting to uint16_t array" << endl;
+ return TestFail;
+ }
+
+ /*
+ * Unsigned Integer32 type.
+ */
+ value.set(static_cast<uint32_t>(42));
+ if (value.isNone() || value.isArray() ||
+ value.type() != ControlTypeUnsigned32) {
+ cerr << "Control type mismatch after setting to uint32_t" << endl;
+ return TestFail;
+ }
+
+ if (value.get<uint32_t>() != 42) {
+ cerr << "Control value mismatch after setting to uint32_t" << endl;
+ return TestFail;
+ }
+
+ if (value.toString() != "42") {
+ cerr << "Control string mismatch after setting to uint32_t" << endl;
+ return TestFail;
+ }
+
+ std::array<uint32_t, 4> uint32s{ 3, 14, 15, 9 };
+ value.set(Span<uint32_t>(uint32s));
+ if (value.isNone() || !value.isArray() ||
+ value.type() != ControlTypeUnsigned32) {
+ cerr << "Control type mismatch after setting to uint32_t array" << endl;
+ return TestFail;
+ }
+
+ Span<const uint32_t> uint32sResult = value.get<Span<const uint32_t>>();
+ if (uint32s.size() != uint32sResult.size() ||
+ !std::equal(uint32s.begin(), uint32s.end(), uint32sResult.begin())) {
+ cerr << "Control value mismatch after setting to uint32_t array" << endl;
+ return TestFail;
+ }
+
+ if (value.toString() != "[ 3, 14, 15, 9 ]") {
+ cerr << "Control string mismatch after setting to uint32_t array" << endl;
+ return TestFail;
+ }
+
+ /*
* Integer32 type.
*/
value.set(0x42000000);