#include "hardware/hardware.h"
#include "hardware/camera2.h"
+#include <common/CameraModule.h>
#include <device2/Camera2Device.h>
#include <device3/Camera3Device.h>
void SetUp() {
TEST_EXTENSION_FORKING_SET_UP;
+ camera_module_t *rawModule;
ASSERT_LE(0, hw_get_module(CAMERA_HARDWARE_MODULE_ID,
- (const hw_module_t **)&mModule)) << "Could not load camera module";
- ASSERT_NE((void*)0, mModule);
+ (const hw_module_t **)&rawModule)) << "Could not load camera module";
+ ASSERT_NE((void*)0, rawModule);
+ mModule = new CameraModule(rawModule);
- mNumberOfCameras = mModule->get_number_of_cameras();
+ mNumberOfCameras = mModule->getNumberOfCameras();
ASSERT_LE(0, mNumberOfCameras);
ASSERT_LE(
- CAMERA_MODULE_API_VERSION_2_0, mModule->common.module_api_version)
+ CAMERA_MODULE_API_VERSION_2_0, mModule->getRawModule()->module_api_version)
<< "Wrong module API version";
/* For using this fixture in other tests only */
void TearDown() {
TEST_EXTENSION_FORKING_TEAR_DOWN;
+ delete mModule;
TearDownMixin();
/* important: device must be destructed before closing module,
mDevice.clear();
if (!TEST_EXTENSION_FORKING_ENABLED) {
- ASSERT_EQ(0, HWModuleHelpers::closeModule(&mModule->common))
+ ASSERT_EQ(0, HWModuleHelpers::closeModule(mModule->getRawModule()))
<< "Failed to close camera HAL module";
}
}
void CreateCamera(int cameraID, /*out*/ sp<CameraDeviceBase> *device) {
struct camera_info info;
- ASSERT_EQ(OK, mModule->get_camera_info(cameraID, &info));
+ ASSERT_EQ(OK, mModule->getCameraInfo(cameraID, &info));
ASSERT_GE((int)info.device_version, CAMERA_DEVICE_API_VERSION_2_0) <<
"Device version too old for camera " << cameraID << ". Version: " <<
int getDeviceVersion(int cameraId, status_t* status = NULL) {
camera_info info;
status_t res;
- res = mModule->get_camera_info(cameraId, &info);
+ res = mModule->getCameraInfo(cameraId, &info);
if (status != NULL) *status = res;
return info.device_version;
protected:
int mNumberOfCameras;
- camera_module_t *mModule;
+ CameraModule *mModule;
sp<CameraDeviceBase> mDevice;
private:
for (unsigned i = 0; i < sizeof(idx)/sizeof(idx[0]); ++i) {
String8 deviceName = String8::format("%d", idx[i]);
- status_t res =
- mModule->common.methods->open(
- &mModule->common,
- deviceName,
- &device);
+ status_t res = mModule->open(deviceName, &device);
EXPECT_NE(OK, res);
EXPECT_EQ(-ENODEV, res)
<< "Incorrect error code when trying to open camera with invalid id "
for (int i = 0; i < mNumberOfCameras; ++i) {
struct camera_info info;
- ASSERT_EQ(OK, mModule->get_camera_info(i, &info));
+ ASSERT_EQ(OK, mModule->getCameraInfo(i, &info));
}
}
int idx[] = { -1, mNumberOfCameras, mNumberOfCameras + 1 };
for (unsigned i = 0; i < sizeof(idx)/sizeof(idx[0]); ++i) {
struct camera_info info;
- EXPECT_NE(OK, mModule->get_camera_info(idx[i], &info));
- EXPECT_EQ(-ENODEV, mModule->get_camera_info(idx[i], &info))
+ EXPECT_NE(OK, mModule->getCameraInfo(idx[i], &info));
+ EXPECT_EQ(-ENODEV, mModule->getCameraInfo(idx[i], &info))
<< "Incorrect error code for get_camera_info idx= "
<< idx[i];
}