summaryrefslogtreecommitdiff
path: root/test/camera-sensor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/camera-sensor.cpp')
-rw-r--r--test/camera-sensor.cpp46
1 files changed, 31 insertions, 15 deletions
diff --git a/test/camera-sensor.cpp b/test/camera-sensor.cpp
index 27c190fe..869c7889 100644
--- a/test/camera-sensor.cpp
+++ b/test/camera-sensor.cpp
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * camera-sensor.cpp - Camera sensor tests
+ * Camera sensor tests
*/
#include <algorithm>
@@ -10,11 +10,13 @@
#include <linux/media-bus-format.h>
-#include "camera_sensor.h"
-#include "device_enumerator.h"
-#include "media_device.h"
-#include "utils.h"
-#include "v4l2_subdevice.h"
+#include <libcamera/base/utils.h>
+
+#include "libcamera/internal/camera_lens.h"
+#include "libcamera/internal/camera_sensor.h"
+#include "libcamera/internal/device_enumerator.h"
+#include "libcamera/internal/media_device.h"
+#include "libcamera/internal/v4l2_subdevice.h"
#include "test.h"
@@ -50,17 +52,27 @@ protected:
return TestFail;
}
- sensor_ = new CameraSensor(entity);
- if (sensor_->init() < 0) {
+ sensor_ = CameraSensorFactoryBase::create(entity);
+ if (!sensor_) {
cerr << "Unable to initialise camera sensor" << endl;
return TestFail;
}
+ lens_ = sensor_->focusLens();
+ if (lens_)
+ cout << "Found lens controller" << endl;
+
return TestPass;
}
int run()
{
+ if (sensor_->model() != "Sensor A") {
+ cerr << "Incorrect sensor model '" << sensor_->model()
+ << "'" << endl;
+ return TestFail;
+ }
+
const std::vector<unsigned int> &codes = sensor_->mbusCodes();
auto iter = std::find(codes.begin(), codes.end(),
MEDIA_BUS_FMT_ARGB8888_1X32);
@@ -69,7 +81,7 @@ protected:
return TestFail;
}
- const std::vector<Size> &sizes = sensor_->sizes();
+ const std::vector<Size> &sizes = sensor_->sizes(*iter);
auto iter2 = std::find(sizes.begin(), sizes.end(),
Size(4096, 2160));
if (iter2 == sizes.end()) {
@@ -79,8 +91,7 @@ protected:
const Size &resolution = sensor_->resolution();
if (resolution != Size(4096, 2160)) {
- cerr << "Incorrect sensor resolution "
- << resolution.toString() << endl;
+ cerr << "Incorrect sensor resolution " << resolution << endl;
return TestFail;
}
@@ -89,11 +100,16 @@ protected:
MEDIA_BUS_FMT_SBGGR10_1X10,
MEDIA_BUS_FMT_BGR888_1X24 },
Size(1024, 768));
- if (format.mbus_code != MEDIA_BUS_FMT_SBGGR10_1X10 ||
+ if (format.code != MEDIA_BUS_FMT_SBGGR10_1X10 ||
format.size != Size(4096, 2160)) {
cerr << "Failed to get a suitable format, expected 4096x2160-0x"
<< utils::hex(MEDIA_BUS_FMT_SBGGR10_1X10)
- << ", got " << format.toString() << endl;
+ << ", got " << format << endl;
+ return TestFail;
+ }
+
+ if (lens_ && lens_->setFocusPosition(10)) {
+ cerr << "Failed to set lens focus position" << endl;
return TestFail;
}
@@ -102,13 +118,13 @@ protected:
void cleanup()
{
- delete sensor_;
}
private:
std::unique_ptr<DeviceEnumerator> enumerator_;
std::shared_ptr<MediaDevice> media_;
- CameraSensor *sensor_;
+ std::unique_ptr<CameraSensor> sensor_;
+ CameraLens *lens_;
};
TEST_REGISTER(CameraSensorTest)