From e28ebd6f91fe1d63ca1d09fbbfdb06a3204544ff Mon Sep 17 00:00:00 2001 From: Jeongmo Yang Date: Tue, 14 Sep 2021 16:37:18 +0900 Subject: [PATCH] haltests: Update - Remove hard coded fps setting. - Set supported values from device info before set format. [Version] 0.0.15 [Issue Type] Update Change-Id: I9901fa7fdd0ed5de6b039df5286fb3196f4e32d9 Signed-off-by: Jeongmo Yang --- packaging/hal-api-camera.spec | 2 +- tests/camera_hal_test.cpp | 62 +++++++++++++++++++++++++++-------- 2 files changed, 49 insertions(+), 15 deletions(-) diff --git a/packaging/hal-api-camera.spec b/packaging/hal-api-camera.spec index 1379101..ce30bf0 100644 --- a/packaging/hal-api-camera.spec +++ b/packaging/hal-api-camera.spec @@ -4,7 +4,7 @@ ### main package ######### Name: %{name} Summary: %{name} interface -Version: 0.0.14 +Version: 0.0.15 Release: 0 Group: Development/Libraries License: Apache-2.0 diff --git a/tests/camera_hal_test.cpp b/tests/camera_hal_test.cpp index 12e386d..6cd9f62 100644 --- a/tests/camera_hal_test.cpp +++ b/tests/camera_hal_test.cpp @@ -214,31 +214,35 @@ class CameraHalTest : public testing::Test int GetSupportedFormat(int index) { + camera_device_info_s *d = NULL; + if (g_device_info_list.count < 1) { cout << "no available camera device" << endl; return CAMERA_ERROR_DEVICE_NOT_SUPPORTED; } + d = &g_device_info_list.device_info[index]; + /* set preview format */ - g_preview_format.stream_format = g_device_info_list.device_info[index].format_list.formats[0]; - g_preview_format.stream_resolution.width = g_device_info_list.device_info[index].preview_list.resolutions[0].width; - g_preview_format.stream_resolution.height = g_device_info_list.device_info[index].preview_list.resolutions[0].height; - g_preview_format.stream_fps = 15; + g_preview_format.stream_format = d->format_list.formats[0]; + g_preview_format.stream_resolution.width = d->preview_list.resolutions[0].width; + g_preview_format.stream_resolution.height = d->preview_list.resolutions[0].height; + g_preview_format.stream_fps = d->preview_fps_list[0].fps[0]; g_preview_format.stream_rotation = CAMERA_ROTATION_0; - g_preview_format.capture_format = g_device_info_list.device_info[index].format_list.formats[0]; - g_preview_format.capture_resolution.width = g_device_info_list.device_info[index].capture_list.resolutions[0].width; - g_preview_format.capture_resolution.height = g_device_info_list.device_info[index].capture_list.resolutions[0].height; + g_preview_format.capture_format = d->format_list.formats[0]; + g_preview_format.capture_resolution.width = d->capture_list.resolutions[0].width; + g_preview_format.capture_resolution.height = d->capture_list.resolutions[0].height; g_preview_format.capture_quality = 95; /* set video format */ - g_video_format.stream_format = g_device_info_list.device_info[index].format_list.formats[0]; - g_video_format.stream_resolution.width = g_device_info_list.device_info[index].video_list.resolutions[0].width; - g_video_format.stream_resolution.height = g_device_info_list.device_info[index].video_list.resolutions[0].height; - g_video_format.stream_fps = 15; + g_video_format.stream_format = d->format_list.formats[0]; + g_video_format.stream_resolution.width = d->video_list.resolutions[0].width; + g_video_format.stream_resolution.height = d->video_list.resolutions[0].height; + g_video_format.stream_fps = d->video_fps_list[0].fps[0];; g_video_format.stream_rotation = CAMERA_ROTATION_0; - g_video_format.capture_format = g_device_info_list.device_info[index].format_list.formats[0]; - g_video_format.capture_resolution.width = g_device_info_list.device_info[index].capture_list.resolutions[0].width; - g_video_format.capture_resolution.height = g_device_info_list.device_info[index].capture_list.resolutions[0].height; + g_video_format.capture_format = d->format_list.formats[0]; + g_video_format.capture_resolution.width = d->capture_list.resolutions[0].width; + g_video_format.capture_resolution.height = d->capture_list.resolutions[0].height; g_video_format.capture_quality = 95; return CAMERA_ERROR_NONE; @@ -453,6 +457,8 @@ TEST_F(CameraHalTest, SetPreviewStreamFormatP) ret = hal_camera_open_device(g_hal_handle, g_device_info_list.device_info[0].index); ASSERT_EQ(ret, CAMERA_ERROR_NONE); + GetSupportedFormat(0); + ret = hal_camera_set_preview_stream_format(g_hal_handle, &g_preview_format); EXPECT_EQ(ret, CAMERA_ERROR_NONE); @@ -513,6 +519,8 @@ TEST_F(CameraHalTest, GetPreviewStreamFormatP) ret = hal_camera_open_device(g_hal_handle, g_device_info_list.device_info[0].index); ASSERT_EQ(ret, CAMERA_ERROR_NONE); + GetSupportedFormat(0); + ret = hal_camera_set_preview_stream_format(g_hal_handle, &g_preview_format); EXPECT_EQ(ret, CAMERA_ERROR_NONE); @@ -627,6 +635,8 @@ TEST_F(CameraHalTest, StartPreviewN) ret = hal_camera_open_device(g_hal_handle, g_device_info_list.device_info[0].index); ASSERT_EQ(ret, CAMERA_ERROR_NONE); + GetSupportedFormat(0); + ret = hal_camera_set_preview_stream_format(g_hal_handle, &g_preview_format); EXPECT_EQ(ret, CAMERA_ERROR_NONE); @@ -659,6 +669,8 @@ TEST_F(CameraHalTest, StopPreviewP) ret = hal_camera_open_device(g_hal_handle, g_device_info_list.device_info[0].index); ASSERT_EQ(ret, CAMERA_ERROR_NONE); + GetSupportedFormat(0); + ret = hal_camera_set_preview_stream_format(g_hal_handle, &g_preview_format); EXPECT_EQ(ret, CAMERA_ERROR_NONE); @@ -694,6 +706,8 @@ TEST_F(CameraHalTest, StartCaptureP) ret = hal_camera_open_device(g_hal_handle, g_device_info_list.device_info[0].index); ASSERT_EQ(ret, CAMERA_ERROR_NONE); + GetSupportedFormat(0); + ret = hal_camera_set_preview_stream_format(g_hal_handle, &g_preview_format); EXPECT_EQ(ret, CAMERA_ERROR_NONE); @@ -744,6 +758,8 @@ TEST_F(CameraHalTest, StartCaptureN) ret = hal_camera_open_device(g_hal_handle, g_device_info_list.device_info[0].index); ASSERT_EQ(ret, CAMERA_ERROR_NONE); + GetSupportedFormat(0); + ret = hal_camera_set_preview_stream_format(g_hal_handle, &g_preview_format); EXPECT_EQ(ret, CAMERA_ERROR_NONE); @@ -780,6 +796,8 @@ TEST_F(CameraHalTest, StopCaptureP) ret = hal_camera_open_device(g_hal_handle, g_device_info_list.device_info[0].index); ASSERT_EQ(ret, CAMERA_ERROR_NONE); + GetSupportedFormat(0); + ret = hal_camera_set_preview_stream_format(g_hal_handle, &g_preview_format); EXPECT_EQ(ret, CAMERA_ERROR_NONE); @@ -961,6 +979,8 @@ TEST_F(CameraHalTest, StartRecordP) ret = hal_camera_open_device(g_hal_handle, g_device_info_list.device_info[0].index); ASSERT_EQ(ret, CAMERA_ERROR_NONE); + GetSupportedFormat(0); + ret = hal_camera_set_preview_stream_format(g_hal_handle, &g_preview_format); EXPECT_EQ(ret, CAMERA_ERROR_NONE); @@ -1014,6 +1034,8 @@ TEST_F(CameraHalTest, StartRecordN) ret = hal_camera_open_device(g_hal_handle, g_device_info_list.device_info[0].index); ASSERT_EQ(ret, CAMERA_ERROR_NONE); + GetSupportedFormat(0); + ret = hal_camera_set_preview_stream_format(g_hal_handle, &g_preview_format); EXPECT_EQ(ret, CAMERA_ERROR_NONE); @@ -1058,6 +1080,8 @@ TEST_F(CameraHalTest, StopRecordP) ret = hal_camera_open_device(g_hal_handle, g_device_info_list.device_info[0].index); ASSERT_EQ(ret, CAMERA_ERROR_NONE); + GetSupportedFormat(0); + ret = hal_camera_set_preview_stream_format(g_hal_handle, &g_preview_format); EXPECT_EQ(ret, CAMERA_ERROR_NONE); @@ -1244,6 +1268,8 @@ TEST_F(CameraHalTest, StartAutoFocusP) ret = hal_camera_add_message_callback(g_hal_handle, _MessageCb, nullptr, &cb_id); EXPECT_EQ(ret, CAMERA_ERROR_NONE); + GetSupportedFormat(0); + ret = hal_camera_set_preview_stream_format(g_hal_handle, &g_preview_format); EXPECT_EQ(ret, CAMERA_ERROR_NONE); @@ -1299,6 +1325,8 @@ TEST_F(CameraHalTest, StopAutoFocusP) ret = hal_camera_add_message_callback(g_hal_handle, _MessageCb, nullptr, &cb_id); EXPECT_EQ(ret, CAMERA_ERROR_NONE); + GetSupportedFormat(0); + ret = hal_camera_set_preview_stream_format(g_hal_handle, &g_preview_format); EXPECT_EQ(ret, CAMERA_ERROR_NONE); @@ -1344,6 +1372,8 @@ TEST_F(CameraHalTest, ReleasePreviewBufferP) ret = hal_camera_open_device(g_hal_handle, g_device_info_list.device_info[0].index); ASSERT_EQ(ret, CAMERA_ERROR_NONE); + GetSupportedFormat(0); + ret = hal_camera_set_preview_stream_format(g_hal_handle, &g_preview_format); EXPECT_EQ(ret, CAMERA_ERROR_NONE); @@ -1384,6 +1414,8 @@ TEST_F(CameraHalTest, ReleaseVideoBufferP) ret = hal_camera_open_device(g_hal_handle, g_device_info_list.device_info[0].index); ASSERT_EQ(ret, CAMERA_ERROR_NONE); + GetSupportedFormat(0); + ret = hal_camera_set_preview_stream_format(g_hal_handle, &g_preview_format); EXPECT_EQ(ret, CAMERA_ERROR_NONE); @@ -1437,6 +1469,8 @@ TEST_F(CameraHalTest, SetUnsetExtraPreviewCallbackP) ret = hal_camera_open_device(g_hal_handle, g_device_info_list.device_info[0].index); ASSERT_EQ(ret, CAMERA_ERROR_NONE); + GetSupportedFormat(0); + ret = hal_camera_set_preview_stream_format(g_hal_handle, &g_preview_format); EXPECT_EQ(ret, CAMERA_ERROR_NONE); -- 2.34.1