diff options
author | Eino-Ville Talvala <etalvala@google.com> | 2013-06-25 18:12:19 -0700 |
---|---|---|
committer | Eino-Ville Talvala <etalvala@google.com> | 2013-06-27 18:02:24 -0700 |
commit | 4c543a1456cd34a94e2c3a09879aa65ed8cd2f3a (patch) | |
tree | 15bf4a8edf1aecdf2bf59b3f88c5ba3e07a923b6 /tests/camera2/CameraModuleFixture.h | |
parent | 1a70c0fd39eed070c2c28fc0731fa689d15931c4 (diff) | |
download | hardware_libhardware-4c543a1456cd34a94e2c3a09879aa65ed8cd2f3a.zip hardware_libhardware-4c543a1456cd34a94e2c3a09879aa65ed8cd2f3a.tar.gz hardware_libhardware-4c543a1456cd34a94e2c3a09879aa65ed8cd2f3a.tar.bz2 |
Enable native HAL tests to work for camera3 devices
Change-Id: Ie11270cc8cf301ec94795b595f0517ee3bad2817
Diffstat (limited to 'tests/camera2/CameraModuleFixture.h')
-rw-r--r-- | tests/camera2/CameraModuleFixture.h | 51 |
1 files changed, 43 insertions, 8 deletions
diff --git a/tests/camera2/CameraModuleFixture.h b/tests/camera2/CameraModuleFixture.h index 01e1ad0..ef4a9a5 100644 --- a/tests/camera2/CameraModuleFixture.h +++ b/tests/camera2/CameraModuleFixture.h @@ -23,6 +23,7 @@ #include "hardware/camera2.h" #include "Camera2Device.h" +#include "Camera3Device.h" #include "camera2_utils.h" #include "TestExtensions.h" @@ -82,6 +83,42 @@ struct CameraModuleFixture { } } + void CreateCamera(int cameraID, /*out*/ sp<CameraDeviceBase> *device) { + struct camera_info info; + ASSERT_EQ(OK, mModule->get_camera_info(cameraID, &info)); + + ASSERT_GE((int)info.device_version, CAMERA_DEVICE_API_VERSION_2_0) << + "Device version too old for camera " << cameraID << ". Version: " << + info.device_version; + switch(info.device_version) { + case CAMERA_DEVICE_API_VERSION_2_0: + case CAMERA_DEVICE_API_VERSION_2_1: + *device = new Camera2Device(cameraID); + break; + case CAMERA_DEVICE_API_VERSION_3_0: + *device = new Camera3Device(cameraID); + break; + default: + device->clear(); + FAIL() << "Device version unknown for camera " << cameraID << ". Version: " << + info.device_version; + } + + } + + int getDeviceVersion() { + return getDeviceVersion(mCameraID); + } + + int getDeviceVersion(int cameraId, status_t* status = NULL) { + camera_info info; + status_t res; + res = mModule->get_camera_info(cameraId, &info); + if (status != NULL) *status = res; + + return info.device_version; + } + private: void SetUpMixin() { @@ -90,14 +127,12 @@ private: EXPECT_LE(0, mCameraID); EXPECT_LT(mCameraID, mNumberOfCameras); - /* HALBUG (Exynos5); crashes if trying to initialize - before calling get_camera_info */ - if (InfoQuirk) { - struct camera_info info; - ASSERT_EQ(OK, mModule->get_camera_info(mCameraID, &info)); - } + /* HALBUG (Exynos5); crashes if we skip calling get_camera_info + before initializing. Need info anyway now. */ + + CreateCamera(mCameraID, &mDevice); - mDevice = new Camera2Device(mCameraID); + ASSERT_TRUE(mDevice != NULL) << "Failed to open device " << mCameraID; ASSERT_EQ(OK, mDevice->initialize(mModule)) << "Failed to initialize device " << mCameraID; } @@ -110,7 +145,7 @@ private: protected: int mNumberOfCameras; camera_module_t *mModule; - sp<Camera2Device> mDevice; + sp<CameraDeviceBase> mDevice; private: int mCameraID; |