summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/controls/control_info.cpp25
-rw-r--r--test/controls/control_list.cpp66
2 files changed, 42 insertions, 49 deletions
diff --git a/test/controls/control_info.cpp b/test/controls/control_info.cpp
index 2aba568a..dbc43df8 100644
--- a/test/controls/control_info.cpp
+++ b/test/controls/control_info.cpp
@@ -7,6 +7,7 @@
#include <iostream>
+#include <libcamera/control_ids.h>
#include <libcamera/controls.h>
#include "test.h"
@@ -23,17 +24,17 @@ protected:
* Test information retrieval from a control with no minimum
* and maximum.
*/
- ControlInfo info(Brightness);
+ ControlInfo brightness(controls::Brightness);
- if (info.id() != Brightness ||
- info.type() != ControlTypeInteger32 ||
- info.name() != std::string("Brightness")) {
+ if (brightness.id() != controls::Brightness ||
+ brightness.id().type() != ControlTypeInteger32 ||
+ brightness.id().name() != std::string("Brightness")) {
cout << "Invalid control identification for Brightness" << endl;
return TestFail;
}
- if (info.min().get<int32_t>() != 0 ||
- info.max().get<int32_t>() != 0) {
+ if (brightness.min().get<int32_t>() != 0 ||
+ brightness.max().get<int32_t>() != 0) {
cout << "Invalid control range for Brightness" << endl;
return TestFail;
}
@@ -42,17 +43,17 @@ protected:
* Test information retrieval from a control with a minimum and
* a maximum value.
*/
- info = ControlInfo(Contrast, 10, 200);
+ ControlInfo contrast(controls::Contrast, 10, 200);
- if (info.id() != Contrast ||
- info.type() != ControlTypeInteger32 ||
- info.name() != std::string("Contrast")) {
+ if (contrast.id() != controls::Contrast ||
+ contrast.id().type() != ControlTypeInteger32 ||
+ contrast.id().name() != std::string("Contrast")) {
cout << "Invalid control identification for Contrast" << endl;
return TestFail;
}
- if (info.min().get<int32_t>() != 10 ||
- info.max().get<int32_t>() != 200) {
+ if (contrast.min().get<int32_t>() != 10 ||
+ contrast.max().get<int32_t>() != 200) {
cout << "Invalid control range for Contrast" << endl;
return TestFail;
}
diff --git a/test/controls/control_list.cpp b/test/controls/control_list.cpp
index 5215840b..05369681 100644
--- a/test/controls/control_list.cpp
+++ b/test/controls/control_list.cpp
@@ -9,6 +9,7 @@
#include <libcamera/camera.h>
#include <libcamera/camera_manager.h>
+#include <libcamera/control_ids.h>
#include <libcamera/controls.h>
#include "test.h"
@@ -52,7 +53,7 @@ protected:
return TestFail;
}
- if (list.contains(Brightness)) {
+ if (list.contains(controls::Brightness)) {
cout << "List should not contain Brightness control" << endl;
return TestFail;
}
@@ -70,7 +71,7 @@ protected:
* Set a control, and verify that the list now contains it, and
* nothing else.
*/
- list[Brightness] = 255;
+ list.set(controls::Brightness, 255);
if (list.empty()) {
cout << "List should not be empty" << endl;
@@ -82,7 +83,7 @@ protected:
return TestFail;
}
- if (!list.contains(Brightness)) {
+ if (!list.contains(controls::Brightness)) {
cout << "List should contain Brightness control" << endl;
return TestFail;
}
@@ -96,54 +97,45 @@ protected:
return TestFail;
}
- if (list[Brightness].get<int32_t>() != 255) {
+ if (list.get(controls::Brightness) != 255) {
cout << "Incorrest Brightness control value" << endl;
return TestFail;
}
- if (list.contains(Contrast)) {
+ if (list.contains(controls::Contrast)) {
cout << "List should not contain Contract control" << endl;
return TestFail;
}
- /*
- * Set a second control through ControlInfo and retrieve it
- * through both controlId and ControlInfo.
- */
- const ControlInfoMap &controls = camera_->controls();
- const ControlInfo *brightness = &controls.find(Brightness)->second;
- const ControlInfo *contrast = &controls.find(Contrast)->second;
-
- list[brightness] = 64;
- list[contrast] = 128;
+ /* Update the first control and set a second one. */
+ list.set(controls::Brightness, 64);
+ list.set(controls::Contrast, 128);
- if (!list.contains(Contrast) || !list.contains(contrast)) {
+ if (!list.contains(controls::Contrast) ||
+ !list.contains(controls::Contrast)) {
cout << "List should contain Contrast control" << endl;
return TestFail;
}
- /*
- * Test control value retrieval and update through ControlInfo.
- */
- if (list[brightness].get<int32_t>() != 64 ||
- list[contrast].get<int32_t>() != 128) {
+ if (list.get(controls::Brightness) != 64 ||
+ list.get(controls::Contrast) != 128) {
cout << "Failed to retrieve control value" << endl;
return TestFail;
}
- list[brightness] = 10;
- list[contrast] = 20;
+ /*
+ * Update both controls and verify that the container doesn't
+ * grow.
+ */
+ list.set(controls::Brightness, 10);
+ list.set(controls::Contrast, 20);
- if (list[brightness].get<int32_t>() != 10 ||
- list[contrast].get<int32_t>() != 20) {
+ if (list.get(controls::Brightness) != 10 ||
+ list.get(controls::Contrast) != 20) {
cout << "Failed to update control value" << endl;
return TestFail;
}
- /*
- * Assert that the container has not grown with the control
- * updated.
- */
if (list.size() != 2) {
cout << "List should contain two elements" << endl;
return TestFail;
@@ -157,8 +149,8 @@ protected:
*/
ControlList newList(camera_.get());
- newList[Brightness] = 128;
- newList[Saturation] = 255;
+ newList.set(controls::Brightness, 128);
+ newList.set(controls::Saturation, 255);
newList.update(list);
list.clear();
@@ -178,16 +170,16 @@ protected:
return TestFail;
}
- if (!newList.contains(Brightness) ||
- !newList.contains(Contrast) ||
- !newList.contains(Saturation)) {
+ if (!newList.contains(controls::Brightness) ||
+ !newList.contains(controls::Contrast) ||
+ !newList.contains(controls::Saturation)) {
cout << "New list contains incorrect items" << endl;
return TestFail;
}
- if (newList[Brightness].get<int32_t>() != 10 ||
- newList[Contrast].get<int32_t>() != 20 ||
- newList[Saturation].get<int32_t>() != 255) {
+ if (newList.get(controls::Brightness) != 10 ||
+ newList.get(controls::Contrast) != 20 ||
+ newList.get(controls::Saturation) != 255) {
cout << "New list contains incorrect values" << endl;
return TestFail;
}