diff options
author | Igor Murashkin <iam@google.com> | 2012-12-18 14:08:27 -0800 |
---|---|---|
committer | Igor Murashkin <iam@google.com> | 2012-12-20 16:39:38 -0800 |
commit | 0a7a430a81b97b09f42b56ab85de24d0ca711520 (patch) | |
tree | 2e96a1e335f6b57bdb120d0ad8449ad019b08d26 /tests/camera2 | |
parent | 981c903c31db2ded5f299c653c779e4ca150f834 (diff) | |
download | hardware_libhardware-0a7a430a81b97b09f42b56ab85de24d0ca711520.zip hardware_libhardware-0a7a430a81b97b09f42b56ab85de24d0ca711520.tar.gz hardware_libhardware-0a7a430a81b97b09f42b56ab85de24d0ca711520.tar.bz2 |
Camera2: Tests: Ignore V1 device initialization failures.
This allows CameraModuleTests.LoadModule and GetCameraInfo to pass.
Change-Id: Id6e38afc6d9c5d45933d3117c7895775a30ee679
Diffstat (limited to 'tests/camera2')
-rw-r--r-- | tests/camera2/CameraModuleTests.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/tests/camera2/CameraModuleTests.cpp b/tests/camera2/CameraModuleTests.cpp index b5b88fc..cf34f04 100644 --- a/tests/camera2/CameraModuleTests.cpp +++ b/tests/camera2/CameraModuleTests.cpp @@ -42,6 +42,28 @@ public: ~CameraModuleTest() { CameraModuleFixture::TearDown(); } + + status_t initializeDevice(int cameraId) { + + // ignore HAL1s. count as test pass + if (!isDeviceVersionHal2(cameraId)) { + return OK; + } + + return mDevice->initialize(mModule); + } + + int getDeviceVersion(int cameraId) { + camera_info info; + status_t res = mModule->get_camera_info(cameraId, &info); + EXPECT_EQ(OK, res); + + return info.device_version; + } + + bool isDeviceVersionHal2(int cameraId) { + return getDeviceVersion(cameraId) >= CAMERA_DEVICE_API_VERSION_2_0; + } }; TEST_F(CameraModuleTest, LoadModule) { @@ -50,7 +72,8 @@ TEST_F(CameraModuleTest, LoadModule) { for (int i = 0; i < mNumberOfCameras; ++i) { mDevice = new Camera2Device(i); - ASSERT_EQ(OK, mDevice->initialize(mModule)) + + ASSERT_EQ(OK, initializeDevice(i)) << "Failed to initialize device " << i; mDevice.clear(); } @@ -65,7 +88,7 @@ TEST_F(CameraModuleTest, LoadModuleBadIndices) { for (unsigned i = 0; i < sizeof(idx)/sizeof(idx[0]); ++i) { mDevice = new Camera2Device(idx[i]); - status_t deviceInitializeCode = mDevice->initialize(mModule); + status_t deviceInitializeCode = initializeDevice(idx[i]); EXPECT_NE(OK, deviceInitializeCode); EXPECT_EQ(-ENODEV, deviceInitializeCode) << "Incorrect error code when trying to initialize invalid index " |