Camera: modify test per framework interface change

Wrap camera_module_t by CameraModule to follow
framework interface change.

Change-Id: Ief423a1571cf06c7ef80b98b403a33969baf95f6
This commit is contained in:
Yin-Chia Yeh 2015-02-02 16:20:46 -08:00
parent a40a7cebcd
commit 7eb3d91b87
4 changed files with 18 additions and 18 deletions

View file

@ -22,6 +22,7 @@
#include "hardware/hardware.h"
#include "hardware/camera2.h"
#include <common/CameraModule.h>
#include <device2/Camera2Device.h>
#include <device3/Camera3Device.h>
@ -54,15 +55,17 @@ struct CameraModuleFixture {
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 */
@ -72,6 +75,7 @@ struct CameraModuleFixture {
void TearDown() {
TEST_EXTENSION_FORKING_TEAR_DOWN;
delete mModule;
TearDownMixin();
/* important: device must be destructed before closing module,
@ -79,14 +83,14 @@ struct CameraModuleFixture {
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: " <<
@ -116,7 +120,7 @@ struct CameraModuleFixture {
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;
@ -147,7 +151,7 @@ private:
protected:
int mNumberOfCameras;
camera_module_t *mModule;
CameraModule *mModule;
sp<CameraDeviceBase> mDevice;
private:

View file

@ -93,11 +93,7 @@ TEST_F(CameraModuleTest, LoadModuleBadIndices) {
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 "
@ -111,7 +107,7 @@ TEST_F(CameraModuleTest, GetCameraInfo) {
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));
}
}
@ -123,8 +119,8 @@ TEST_F(CameraModuleTest, GetCameraInfoBadIndices) {
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];
}

View file

@ -580,7 +580,7 @@ void FrameWaiter::onFrameAvailable(const BufferItem& /* item */) {
mCondition.signal();
}
int HWModuleHelpers::closeModule(hw_module_t* module) {
int HWModuleHelpers::closeModule(const hw_module_t* module) {
int status;
if (!module) {

View file

@ -240,7 +240,7 @@ class FrameWaiter : public CpuConsumer::FrameAvailableListener {
struct HWModuleHelpers {
/* attempt to unload the library with dlclose */
static int closeModule(hw_module_t* module);
static int closeModule(const hw_module_t* module);
};
}