summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/camera/tizen-camera.h36
-rw-r--r--packaging/mm-hal-interface.spec2
-rw-r--r--testcase/camera/Makefile.am2
-rw-r--r--testcase/camera/camera_hal_tc.cpp805
-rw-r--r--testcase/camera/camera_haltests.cpp1408
5 files changed, 1428 insertions, 825 deletions
diff --git a/include/camera/tizen-camera.h b/include/camera/tizen-camera.h
index 3dbb38d..d631119 100644
--- a/include/camera/tizen-camera.h
+++ b/include/camera/tizen-camera.h
@@ -48,24 +48,24 @@ extern "C" {
* @since_tizen 3.0
*/
typedef enum camera_error {
- CAMERA_ERROR_NONE = 0x00000000,
- CAMERA_ERROR_INVALID_PARAMETER = 0x80002001,
- CAMERA_ERROR_INVALID_STATE = 0x80002002,
- CAMERA_ERROR_PERMISSION_DENIED = 0x80002003,
- CAMERA_ERROR_OUT_OF_MEMORY = 0x80002004,
- CAMERA_ERROR_DEVICE_OPEN = 0x80002005,
- CAMERA_ERROR_DEVICE_NOT_FOUND = 0x80002006,
- CAMERA_ERROR_DEVICE_UNAVAILABLE = 0x80002007,
- CAMERA_ERROR_DEVICE_NOT_SUPPORTED = 0x80002008,
- CAMERA_ERROR_DEVICE_READ = 0x80002009,
- CAMERA_ERROR_DEVICE_WRITE = 0x8000200a,
- CAMERA_ERROR_DEVICE_BUSY = 0x8000200b,
- CAMERA_ERROR_DEVICE_TIME_OUT = 0x8000200c,
- CAMERA_ERROR_DEVICE_ESD = 0x8000200d,
- CAMERA_ERROR_INTERNAL = 0x8000200e,
-
- CAMERA_ERROR_NOT_IMPLEMENTED = 0x80002ffe,
- CAMERA_ERROR_UNKNOWN = 0x80002fff
+ CAMERA_ERROR_NONE = 0,
+ CAMERA_ERROR_INVALID_PARAMETER = (int32_t)0x80002001,
+ CAMERA_ERROR_INVALID_STATE = (int32_t)0x80002002,
+ CAMERA_ERROR_PERMISSION_DENIED = (int32_t)0x80002003,
+ CAMERA_ERROR_OUT_OF_MEMORY = (int32_t)0x80002004,
+ CAMERA_ERROR_DEVICE_OPEN = (int32_t)0x80002005,
+ CAMERA_ERROR_DEVICE_NOT_FOUND = (int32_t)0x80002006,
+ CAMERA_ERROR_DEVICE_UNAVAILABLE = (int32_t)0x80002007,
+ CAMERA_ERROR_DEVICE_NOT_SUPPORTED = (int32_t)0x80002008,
+ CAMERA_ERROR_DEVICE_READ = (int32_t)0x80002009,
+ CAMERA_ERROR_DEVICE_WRITE = (int32_t)0x8000200a,
+ CAMERA_ERROR_DEVICE_BUSY = (int32_t)0x8000200b,
+ CAMERA_ERROR_DEVICE_TIME_OUT = (int32_t)0x8000200c,
+ CAMERA_ERROR_DEVICE_ESD = (int32_t)0x8000200d,
+ CAMERA_ERROR_INTERNAL = (int32_t)0x8000200e,
+
+ CAMERA_ERROR_NOT_IMPLEMENTED = (int32_t)0x80002ffe,
+ CAMERA_ERROR_UNKNOWN = (int32_t)0x80002fff
} camera_error_t;
/**
diff --git a/packaging/mm-hal-interface.spec b/packaging/mm-hal-interface.spec
index 4a2abf0..07d89bf 100644
--- a/packaging/mm-hal-interface.spec
+++ b/packaging/mm-hal-interface.spec
@@ -1,6 +1,6 @@
Name: mm-hal-interface
Summary: Multimedia HAL Interface
-Version: 0.0.8
+Version: 0.0.9
Release: 0
Group: Multimedia/Development
License: Apache-2.0
diff --git a/testcase/camera/Makefile.am b/testcase/camera/Makefile.am
index 8449971..5cf9565 100644
--- a/testcase/camera/Makefile.am
+++ b/testcase/camera/Makefile.am
@@ -2,7 +2,7 @@
bin_PROGRAMS = camera_haltests
camera_haltests_SOURCES = \
- camera_hal_tc.cpp
+ camera_haltests.cpp
camera_haltests_CPPFLAGS = \
$(GLIB_CFLAGS)\
diff --git a/testcase/camera/camera_hal_tc.cpp b/testcase/camera/camera_hal_tc.cpp
deleted file mode 100644
index 9e8eae9..0000000
--- a/testcase/camera/camera_hal_tc.cpp
+++ /dev/null
@@ -1,805 +0,0 @@
-/*
- * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Jeongmo Yang <jm80.yang@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <glib.h>
-#include <string.h>
-#include <gtest/gtest.h>
-#include <unistd.h>
-#include <iostream>
-#include <camera_hal_interface.h>
-#include <system_info.h>
-
-using namespace std;
-
-int ret;
-int preview_check;
-int capture_check;
-int video_check;
-camera_hal_interface *h;
-camera_device_info_list_t device_info_list;
-camera_format_t preview_format;
-camera_format_t video_format;
-GMutex msg_cb_lock;
-GCond msg_cb_cond;
-
-bool camera_supported;
-
-#define CAMERA_SUPPORT_CHECK \
- do {\
- if (!camera_supported) {\
- cout << "CAMERA NOT SUPPORTED" << endl;\
- EXPECT_EQ(ret, CAMERA_ERROR_DEVICE_NOT_SUPPORTED);\
- return;\
- }\
- } while (0)
-
-/*
- * callback
- */
-static int _PreviewCb(camera_buffer_t *buffer, camera_metadata_t *meta, void *user_data)
-{
- camera_hal_interface *hal_intf_handle = (camera_hal_interface *)user_data;
-
- if (!hal_intf_handle) {
- cout << "NULL handle" << endl;
- return false;
- }
-
- if (!buffer) {
- cout << "NULL buffer" << endl;
- return false;
- }
-
- cout << "preview buffer index [" << buffer->index << "]" << endl;
-
- preview_check = 1;
-
- camera_hal_interface_release_preview_buffer(hal_intf_handle, buffer->index);
-
- return true;
-}
-
-static int _CaptureCb(camera_buffer_t *main, camera_buffer_t *postview, camera_buffer_t *thumbnail, void *user_data)
-{
- if (!main) {
- cout << "NULL buffer" << endl;
- return false;
- }
-
- cout << "capture callback invoked" << endl;
-
- capture_check = 1;
-
- return true;
-}
-
-static int _VideoCb(camera_buffer_t *buffer, camera_metadata_t *meta, void *user_data)
-{
- camera_hal_interface *hal_intf_handle = (camera_hal_interface *)user_data;
-
- if (!hal_intf_handle) {
- cout << "NULL handle" << endl;
- return false;
- }
-
- if (!buffer) {
- cout << "NULL buffer" << endl;
- return false;
- }
-
- cout << "video buffer index [" << buffer->index << "]" << endl;
-
- video_check = 1;
-
- camera_hal_interface_release_video_buffer(hal_intf_handle, buffer->index);
-
- return true;
-}
-
-static int _MessageCb(camera_message_t *message, void *user_data)
-{
- if (!message) {
- cout << "NULL message" << endl;
- return false;
- }
-
- cout << "message - type " << message->type << endl;
-
- g_mutex_lock(&msg_cb_lock);
-
- switch (message->type) {
- case CAMERA_MESSAGE_TYPE_FOCUS_CHANGED:
- cout << "focus changed : " << message->focus_state << endl;
- if (message->focus_state == CAMERA_FOCUS_STATE_FOCUSED ||
- message->focus_state == CAMERA_FOCUS_STATE_FAILED) {
- g_cond_signal(&msg_cb_cond);
- }
- break;
- case CAMERA_MESSAGE_TYPE_CAPTURED:
- cout << "captured" << endl;
- g_cond_signal(&msg_cb_cond);
- break;
- case CAMERA_MESSAGE_TYPE_HDR_PROGRESS:
- cout << "HDR progress " << message->hdr_progress << endl;
- g_cond_signal(&msg_cb_cond);
- break;
- case CAMERA_MESSAGE_TYPE_ERROR:
- cout << "error " << message->error_code << endl;
- break;
- default:
- cout << "unknown message " << message->type << endl;
- break;
- }
-
- g_mutex_unlock(&msg_cb_lock);
-
- return true;
-}
-
-
-/*
- * main class
- */
-class CameraHalTest : public testing::Test
-{
- public:
- virtual void SetUp()
- {
- camera_supported = false;
-
- system_info_get_platform_bool("http://tizen.org/feature/camera", &camera_supported);
-
- ret = camera_hal_interface_init(&h);
- if (ret != CAMERA_ERROR_NONE) {
- cout << "camera hal init failed " << ret << endl;
- return;
- }
-
- ret = camera_hal_interface_get_device_info_list(h, &device_info_list);
- if (ret != CAMERA_ERROR_NONE) {
- cout << "get device list failed " << ret << endl;
- return;
- }
-
- ret = GetSupportedFormat(0);
-
- return;
- }
-
- virtual void TearDown()
- {
- if (h) {
- ret = camera_hal_interface_deinit(h);
- h = nullptr;
- }
-
- return;
- }
-
- int GetSupportedFormat(int index)
- {
- if (device_info_list.count < 1) {
- cout << "no available camera device" << endl;
- return CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
- }
-
- /* set preview format */
- preview_format.stream_format = device_info_list.device_info[index].format_list.formats[0];
- preview_format.stream_resolution.width = device_info_list.device_info[index].preview_list.resolutions[0].width;
- preview_format.stream_resolution.height = device_info_list.device_info[index].preview_list.resolutions[0].height;
- preview_format.stream_fps = 15;
- preview_format.stream_rotation = CAMERA_ROTATION_0;
- preview_format.capture_format = CAMERA_PIXEL_FORMAT_JPEG;
- preview_format.capture_resolution.width = device_info_list.device_info[index].capture_list.resolutions[0].width;
- preview_format.capture_resolution.height = device_info_list.device_info[index].capture_list.resolutions[0].height;
- preview_format.capture_quality = 95;
-
- /* set video format */
- video_format.stream_format = device_info_list.device_info[index].format_list.formats[0];
- video_format.stream_resolution.width = device_info_list.device_info[index].video_list.resolutions[0].width;
- video_format.stream_resolution.height = device_info_list.device_info[index].video_list.resolutions[0].height;
- video_format.stream_fps = 15;
- video_format.stream_rotation = CAMERA_ROTATION_0;
- video_format.capture_format = CAMERA_PIXEL_FORMAT_JPEG;
- video_format.capture_resolution.width = device_info_list.device_info[index].capture_list.resolutions[0].width;
- video_format.capture_resolution.height = device_info_list.device_info[index].capture_list.resolutions[0].height;
- video_format.capture_quality = 95;
-
- return CAMERA_ERROR_NONE;
- }
-};
-
-
-/*
- * testcase
- */
-TEST_F(CameraHalTest, InitP)
-{
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
-}
-
-TEST_F(CameraHalTest, DeinitP)
-{
- camera_hal_interface *hal_handle = nullptr;
-
- CAMERA_SUPPORT_CHECK;
-
- ret = camera_hal_interface_init(&hal_handle);
-
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
- EXPECT_NE(hal_handle, nullptr);
-
- if (hal_handle) {
- ret = camera_hal_interface_deinit(hal_handle);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
- hal_handle = nullptr;
- }
-}
-
-TEST_F(CameraHalTest, GetDeviceInfoListP)
-{
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-}
-
-TEST_F(CameraHalTest, GetDeviceInfoListN)
-{
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
-
- ret = camera_hal_interface_get_device_info_list(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_INVALID_PARAMETER);
-}
-
-TEST_F(CameraHalTest, OpenDeviceP)
-{
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- if (device_info_list.count > 0) {
- ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- if (ret == CAMERA_ERROR_NONE) {
- camera_hal_interface_close_device(h);
- }
- }
-}
-
-TEST_F(CameraHalTest, OpenDeviceN)
-{
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- if (device_info_list.count > 0) {
- ret = camera_hal_interface_open_device(NULL, device_info_list.device_info[device_info_list.count - 1].index + 1);
- EXPECT_NE(ret, CAMERA_ERROR_NONE);
-
- if (ret == CAMERA_ERROR_NONE) {
- camera_hal_interface_close_device(h);
- }
- }
-}
-
-TEST_F(CameraHalTest, CloseDeviceP)
-{
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- if (device_info_list.count > 0) {
- ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- if (ret == CAMERA_ERROR_NONE) {
- ret = camera_hal_interface_close_device(h);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
- }
- }
-}
-
-TEST_F(CameraHalTest, SetPreviewStreamFormatP)
-{
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_set_preview_stream_format(h, &preview_format);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- camera_hal_interface_close_device(h);
-}
-
-TEST_F(CameraHalTest, SetPreviewStreamFormatN)
-{
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_set_preview_stream_format(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_INVALID_PARAMETER);
-
- camera_hal_interface_close_device(h);
-}
-
-TEST_F(CameraHalTest, GetPreviewStreamFormatP)
-{
- camera_format_t get_format;
-
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_set_preview_stream_format(h, &preview_format);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- memset(&get_format, 0x0, sizeof(camera_format_t));
-
- ret = camera_hal_interface_get_preview_stream_format(h, &get_format);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = memcmp(&preview_format, &get_format, sizeof(camera_format_t));
- EXPECT_EQ(ret, 0);
-
- camera_hal_interface_close_device(h);
-}
-
-TEST_F(CameraHalTest, GetPreviewStreamFormatN)
-{
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_get_preview_stream_format(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_INVALID_PARAMETER);
-
- camera_hal_interface_close_device(h);
-}
-
-TEST_F(CameraHalTest, StartPreviewP)
-{
- unsigned int i = 0;
-
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- for (i = 0 ; i < device_info_list.count ; i++) {
- cout << "Device Index " << i << endl;
-
- ret = camera_hal_interface_open_device(h, device_info_list.device_info[i].index);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- GetSupportedFormat(i);
-
- ret = camera_hal_interface_set_preview_stream_format(h, &preview_format);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- preview_check = 0;
-
- ret = camera_hal_interface_start_preview(h, _PreviewCb, (void *)h);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- /* wait for preview frame */
- sleep(1);
-
- EXPECT_TRUE(preview_check);
-
- camera_hal_interface_stop_preview(h);
- camera_hal_interface_close_device(h);
- }
-}
-
-TEST_F(CameraHalTest, StartPreviewN)
-{
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_set_preview_stream_format(h, &preview_format);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_start_preview(h, nullptr, (void *)h);
- EXPECT_EQ(ret, CAMERA_ERROR_INVALID_PARAMETER);
-
- camera_hal_interface_close_device(h);
-}
-
-TEST_F(CameraHalTest, StopPreviewP)
-{
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_set_preview_stream_format(h, &preview_format);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_start_preview(h, _PreviewCb, (void *)h);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_stop_preview(h);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- camera_hal_interface_close_device(h);
-}
-
-TEST_F(CameraHalTest, StartCaptureP)
-{
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_set_preview_stream_format(h, &preview_format);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_start_preview(h, _PreviewCb, (void *)h);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- capture_check = 0;
-
- ret = camera_hal_interface_start_capture(h, _CaptureCb, NULL);
-
- if (ret != CAMERA_ERROR_DEVICE_NOT_SUPPORTED) {
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- /* wait for capture frame */
- sleep(1);
-
- EXPECT_TRUE(capture_check);
-
- camera_hal_interface_stop_capture(h);
- }
-
- camera_hal_interface_stop_preview(h);
- camera_hal_interface_close_device(h);
-}
-
-TEST_F(CameraHalTest, StartCaptureN)
-{
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_set_preview_stream_format(h, &preview_format);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_start_preview(h, _PreviewCb, (void *)h);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_start_capture(h, nullptr, NULL);
- EXPECT_EQ(ret, CAMERA_ERROR_INVALID_PARAMETER);
-
- camera_hal_interface_stop_preview(h);
- camera_hal_interface_close_device(h);
-}
-
-TEST_F(CameraHalTest, StartRecordP)
-{
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_set_preview_stream_format(h, &preview_format);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_start_preview(h, _PreviewCb, (void *)h);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_set_video_stream_format(h, &video_format);
-
- if (ret != CAMERA_ERROR_DEVICE_NOT_SUPPORTED) {
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- video_check = 0;
-
- ret = camera_hal_interface_start_record(h, _VideoCb, (void *)h);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- /* wait for video frame */
- sleep(1);
-
- EXPECT_TRUE(video_check);
-
- camera_hal_interface_stop_record(h);
- }
-
- camera_hal_interface_stop_preview(h);
- camera_hal_interface_close_device(h);
-}
-
-TEST_F(CameraHalTest, StartRecordN)
-{
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_set_preview_stream_format(h, &preview_format);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_start_preview(h, _PreviewCb, (void *)h);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_set_video_stream_format(h, &video_format);
-
- if (ret != CAMERA_ERROR_DEVICE_NOT_SUPPORTED) {
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_start_record(h, nullptr, (void *)h);
- EXPECT_EQ(ret, CAMERA_ERROR_INVALID_PARAMETER);
- }
-
- camera_hal_interface_stop_preview(h);
- camera_hal_interface_close_device(h);
-}
-
-TEST_F(CameraHalTest, SetVideoStreamFormatP)
-{
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_set_video_stream_format(h, &video_format);
- if (ret != CAMERA_ERROR_DEVICE_NOT_SUPPORTED) {
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
- }
-
- camera_hal_interface_close_device(h);
-}
-
-TEST_F(CameraHalTest, SetVideoStreamFormatN)
-{
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_set_video_stream_format(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_INVALID_PARAMETER);
-
- camera_hal_interface_close_device(h);
-}
-
-TEST_F(CameraHalTest, GetVideoStreamFormatP)
-{
- camera_format_t get_format;
-
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- memset(&get_format, 0x0, sizeof(camera_format_t));
-
- ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_set_video_stream_format(h, &video_format);
-
- if (ret != CAMERA_ERROR_DEVICE_NOT_SUPPORTED) {
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_get_video_stream_format(h, &get_format);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = memcmp(&video_format, &get_format, sizeof(camera_format_t));
- EXPECT_EQ(ret, 0);
- }
-
- camera_hal_interface_close_device(h);
-}
-
-TEST_F(CameraHalTest, GetVideoStreamFormatN)
-{
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_get_video_stream_format(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_INVALID_PARAMETER);
-
- camera_hal_interface_close_device(h);
-}
-
-TEST_F(CameraHalTest, AddMessageCallbackP)
-{
- uint32_t cb_id = 0;
-
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_add_message_callback(h, _MessageCb, nullptr, &cb_id);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- if (ret == CAMERA_ERROR_NONE) {
- camera_hal_interface_remove_message_callback(h, cb_id);
- }
-
- camera_hal_interface_close_device(h);
-}
-
-TEST_F(CameraHalTest, AddMessageCallbackN1)
-{
- uint32_t cb_id = 0;
-
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_add_message_callback(h, nullptr, nullptr, &cb_id);
- EXPECT_EQ(ret, CAMERA_ERROR_INVALID_PARAMETER);
-
- camera_hal_interface_close_device(h);
-}
-
-TEST_F(CameraHalTest, AddMessageCallbackN2)
-{
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_add_message_callback(h, _MessageCb, nullptr, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_INVALID_PARAMETER);
-
- camera_hal_interface_close_device(h);
-}
-
-TEST_F(CameraHalTest, RemoveMessageCallbackP)
-{
- uint32_t cb_id = 0;
-
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_add_message_callback(h, _MessageCb, nullptr, &cb_id);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- if (ret == CAMERA_ERROR_NONE) {
- ret = camera_hal_interface_remove_message_callback(h, cb_id);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
- }
-
- camera_hal_interface_close_device(h);
-}
-
-TEST_F(CameraHalTest, StartAutoFocusP)
-{
- uint32_t cb_id = 0;
- gint64 end_time = 0;
-
- CAMERA_SUPPORT_CHECK;
-
- EXPECT_NE(h, nullptr);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_add_message_callback(h, _MessageCb, nullptr, &cb_id);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_set_preview_stream_format(h, &preview_format);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- ret = camera_hal_interface_start_preview(h, _PreviewCb, (void *)h);
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- g_mutex_lock(&msg_cb_lock);
-
- ret = camera_hal_interface_start_auto_focus(h);
-
- if (ret != CAMERA_ERROR_DEVICE_NOT_SUPPORTED) {
- EXPECT_EQ(ret, CAMERA_ERROR_NONE);
-
- /* wait a message and check result */
- end_time = g_get_monotonic_time() + G_TIME_SPAN_SECOND * 5;
- EXPECT_EQ(g_cond_wait_until(&msg_cb_cond, &msg_cb_lock, end_time), true);
- }
-
- g_mutex_unlock(&msg_cb_lock);
-
- camera_hal_interface_stop_preview(h);
- camera_hal_interface_remove_message_callback(h, cb_id);
- camera_hal_interface_close_device(h);
-}
-
-int main(int argc, char **argv)
-{
- testing::InitGoogleTest(&argc, argv);
-
- return RUN_ALL_TESTS();
-}
diff --git a/testcase/camera/camera_haltests.cpp b/testcase/camera/camera_haltests.cpp
new file mode 100644
index 0000000..59da896
--- /dev/null
+++ b/testcase/camera/camera_haltests.cpp
@@ -0,0 +1,1408 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Jeongmo Yang <jm80.yang@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+#include <string.h>
+#include <gtest/gtest.h>
+#include <unistd.h>
+#include <iostream>
+#include <camera_hal_interface.h>
+#include <system_info.h>
+
+using namespace std;
+
+int ret;
+int preview_check;
+int capture_check;
+int video_check;
+int ret_release_preview_buffer;
+int ret_release_video_buffer;
+camera_hal_interface *h;
+camera_device_info_list_t device_info_list;
+camera_format_t preview_format;
+camera_format_t video_format;
+GMutex msg_cb_lock;
+GCond msg_cb_cond;
+
+bool camera_supported;
+
+#define CAMERA_SUPPORT_CHECK \
+ do {\
+ if (!camera_supported) {\
+ cout << "CAMERA NOT SUPPORTED" << endl;\
+ EXPECT_EQ(ret, CAMERA_ERROR_DEVICE_NOT_SUPPORTED);\
+ return;\
+ }\
+ } while (0)
+
+/*
+ * callback
+ */
+static int _PreviewCb(camera_buffer_t *buffer, camera_metadata_t *meta, void *user_data)
+{
+ camera_hal_interface *hal_intf_handle = (camera_hal_interface *)user_data;
+
+ if (!hal_intf_handle) {
+ cout << "NULL handle" << endl;
+ return false;
+ }
+
+ if (!buffer) {
+ cout << "NULL buffer" << endl;
+ return false;
+ }
+
+ preview_check = 1;
+
+ ret_release_preview_buffer = camera_hal_interface_release_preview_buffer(hal_intf_handle, buffer->index);
+
+ cout << "preview buffer index [" << buffer->index << "], ret " << ret_release_preview_buffer << endl;
+
+ return true;
+}
+
+static int _CaptureCb(camera_buffer_t *main, camera_buffer_t *postview, camera_buffer_t *thumbnail, void *user_data)
+{
+ if (!main) {
+ cout << "NULL buffer" << endl;
+ return false;
+ }
+
+ cout << "capture callback invoked" << endl;
+
+ capture_check = 1;
+
+ return true;
+}
+
+static int _VideoCb(camera_buffer_t *buffer, camera_metadata_t *meta, void *user_data)
+{
+ camera_hal_interface *hal_intf_handle = (camera_hal_interface *)user_data;
+
+ if (!hal_intf_handle) {
+ cout << "NULL handle" << endl;
+ return false;
+ }
+
+ if (!buffer) {
+ cout << "NULL buffer" << endl;
+ return false;
+ }
+
+ video_check = 1;
+
+ ret_release_video_buffer = camera_hal_interface_release_video_buffer(hal_intf_handle, buffer->index);
+
+ cout << "video buffer index [" << buffer->index << "], ret " << ret_release_video_buffer << endl;
+
+ return true;
+}
+
+static int _MessageCb(camera_message_t *message, void *user_data)
+{
+ if (!message) {
+ cout << "NULL message" << endl;
+ return false;
+ }
+
+ cout << "message - type " << message->type << endl;
+
+ g_mutex_lock(&msg_cb_lock);
+
+ switch (message->type) {
+ case CAMERA_MESSAGE_TYPE_FOCUS_CHANGED:
+ cout << "focus changed : " << message->focus_state << endl;
+ if (message->focus_state == CAMERA_FOCUS_STATE_FOCUSED ||
+ message->focus_state == CAMERA_FOCUS_STATE_FAILED) {
+ g_cond_signal(&msg_cb_cond);
+ }
+ break;
+ case CAMERA_MESSAGE_TYPE_CAPTURED:
+ cout << "captured" << endl;
+ g_cond_signal(&msg_cb_cond);
+ break;
+ case CAMERA_MESSAGE_TYPE_HDR_PROGRESS:
+ cout << "HDR progress " << message->hdr_progress << endl;
+ g_cond_signal(&msg_cb_cond);
+ break;
+ case CAMERA_MESSAGE_TYPE_ERROR:
+ cout << "error " << message->error_code << endl;
+ break;
+ default:
+ cout << "unknown message " << message->type << endl;
+ break;
+ }
+
+ g_mutex_unlock(&msg_cb_lock);
+
+ return true;
+}
+
+
+/*
+ * main class
+ */
+class CameraHalTest : public testing::Test
+{
+ public:
+ virtual void SetUp()
+ {
+ camera_supported = false;
+
+ system_info_get_platform_bool("http://tizen.org/feature/camera", &camera_supported);
+
+ ret = camera_hal_interface_init(&h);
+ if (ret != CAMERA_ERROR_NONE) {
+ cout << "camera hal init failed " << ret << endl;
+ return;
+ }
+
+ ret = camera_hal_interface_get_device_info_list(h, &device_info_list);
+ if (ret != CAMERA_ERROR_NONE) {
+ cout << "get device list failed " << ret << endl;
+ return;
+ }
+
+ ret = GetSupportedFormat(0);
+
+ return;
+ }
+
+ virtual void TearDown()
+ {
+ if (h) {
+ ret = camera_hal_interface_deinit(h);
+ h = nullptr;
+ }
+
+ return;
+ }
+
+ int GetSupportedFormat(int index)
+ {
+ if (device_info_list.count < 1) {
+ cout << "no available camera device" << endl;
+ return CAMERA_ERROR_DEVICE_NOT_SUPPORTED;
+ }
+
+ /* set preview format */
+ preview_format.stream_format = device_info_list.device_info[index].format_list.formats[0];
+ preview_format.stream_resolution.width = device_info_list.device_info[index].preview_list.resolutions[0].width;
+ preview_format.stream_resolution.height = device_info_list.device_info[index].preview_list.resolutions[0].height;
+ preview_format.stream_fps = 15;
+ preview_format.stream_rotation = CAMERA_ROTATION_0;
+ preview_format.capture_format = CAMERA_PIXEL_FORMAT_JPEG;
+ preview_format.capture_resolution.width = device_info_list.device_info[index].capture_list.resolutions[0].width;
+ preview_format.capture_resolution.height = device_info_list.device_info[index].capture_list.resolutions[0].height;
+ preview_format.capture_quality = 95;
+
+ /* set video format */
+ video_format.stream_format = device_info_list.device_info[index].format_list.formats[0];
+ video_format.stream_resolution.width = device_info_list.device_info[index].video_list.resolutions[0].width;
+ video_format.stream_resolution.height = device_info_list.device_info[index].video_list.resolutions[0].height;
+ video_format.stream_fps = 15;
+ video_format.stream_rotation = CAMERA_ROTATION_0;
+ video_format.capture_format = CAMERA_PIXEL_FORMAT_JPEG;
+ video_format.capture_resolution.width = device_info_list.device_info[index].capture_list.resolutions[0].width;
+ video_format.capture_resolution.height = device_info_list.device_info[index].capture_list.resolutions[0].height;
+ video_format.capture_quality = 95;
+
+ return CAMERA_ERROR_NONE;
+ }
+};
+
+
+/**
+ * @testcase InitP
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Positive, Initialize camera HAL handle
+ * @apicovered camera_init
+ * @passcase when camera_init returns CAMERA_ERROR_NONE and the handle "h" is not a NULL pointer
+ * @failcase when handle "h" is a NULL pointer
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, InitP)
+{
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+}
+
+/**
+ * @testcase DeinitP
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Positive, Deinitialize camera HAL handle
+ * @apicovered camera_init, camera_deinit
+ * @passcase when camera_deinit returns CAMERA_ERROR_NONE
+ * @failcase when camera_deinit does not return CAMERA_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, DeinitP)
+{
+ camera_hal_interface *hal_handle = nullptr;
+
+ CAMERA_SUPPORT_CHECK;
+
+ ret = camera_hal_interface_init(&hal_handle);
+
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+ EXPECT_NE(hal_handle, nullptr);
+
+ if (hal_handle) {
+ ret = camera_hal_interface_deinit(hal_handle);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+ hal_handle = nullptr;
+ }
+}
+
+/**
+ * @testcase GetDeviceInfoListP
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Positive, Get the list of device information
+ * @apicovered camera_get_device_info_list
+ * @passcase when camera_get_device_info_list returns CAMERA_ERROR_NONE
+ * @failcase when camera_get_device_info_list does not return CAMERA_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, GetDeviceInfoListP)
+{
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+}
+
+/**
+ * @testcase GetDeviceInfoListN
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Negative, Get the list of device information
+ * @apicovered camera_get_device_info_list
+ * @passcase when camera_get_device_info_list returns CAMERA_ERROR_INVALID_PARAMETER
+ * @failcase when camera_get_device_info_list does not return CAMERA_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, GetDeviceInfoListN)
+{
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+
+ ret = camera_hal_interface_get_device_info_list(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_INVALID_PARAMETER);
+}
+
+/**
+ * @testcase OpenDeviceP
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Positive, Open camera device
+ * @apicovered camera_open_device
+ * @passcase when camera_open_device returns CAMERA_ERROR_NONE
+ * @failcase when camera_open_device does not return CAMERA_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, OpenDeviceP)
+{
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ if (device_info_list.count > 0) {
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ camera_hal_interface_close_device(h);
+ }
+ }
+}
+
+/**
+ * @testcase OpenDeviceN
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Negative, Open camera device
+ * @apicovered camera_open_device
+ * @passcase when camera_open_device does not return CAMERA_ERROR_NONE
+ * @failcase when camera_open_device returns CAMERA_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, OpenDeviceN)
+{
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ if (device_info_list.count > 0) {
+ ret = camera_hal_interface_open_device(NULL, device_info_list.device_info[device_info_list.count - 1].index + 1);
+ EXPECT_NE(ret, CAMERA_ERROR_NONE);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ camera_hal_interface_close_device(h);
+ }
+ }
+}
+
+/**
+ * @testcase CloseDeviceP
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Positive, Close camera device
+ * @apicovered camera_open_device, camera_close_device
+ * @passcase when camera_close_device returns CAMERA_ERROR_NONE
+ * @failcase when camera_close_device does not return CAMERA_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, CloseDeviceP)
+{
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ if (device_info_list.count > 0) {
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ ret = camera_hal_interface_close_device(h);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+ }
+ }
+}
+
+/**
+ * @testcase SetPreviewStreamFormatP
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Positive, Set the stream format for preview in camera
+ * @apicovered camera_open_device, camera_set_preview_stream_format
+ * @passcase when camera_set_preview_stream_format returns CAMERA_ERROR_NONE
+ * @failcase when camera_set_preview_stream_format does not return CAMERA_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, SetPreviewStreamFormatP)
+{
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_set_preview_stream_format(h, &preview_format);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ camera_hal_interface_close_device(h);
+}
+
+/**
+ * @testcase SetPreviewStreamFormatN
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Negative, Set the stream format for preview in camera
+ * @apicovered camera_open_device, camera_set_preview_stream_format
+ * @passcase when camera_set_preview_stream_format returns CAMERA_ERROR_INVALID_PARAMETER
+ * @failcase when camera_set_preview_stream_format does not return CAMERA_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, SetPreviewStreamFormatN)
+{
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_set_preview_stream_format(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_INVALID_PARAMETER);
+
+ camera_hal_interface_close_device(h);
+}
+
+/**
+ * @testcase GetPreviewStreamFormatP
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Positive, Get the stream format for preview in camera
+ * @apicovered camera_open_device, camera_set_preview_stream_format, camera_get_preview_stream_format
+ * @passcase when camera_get_preview_stream_format returns CAMERA_ERROR_NONE and result is same with previous set format
+ * @failcase when camera_get_preview_stream_format does not return CAMERA_ERROR_NONE or result is different with previous set format
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, GetPreviewStreamFormatP)
+{
+ camera_format_t get_format;
+
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_set_preview_stream_format(h, &preview_format);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ memset(&get_format, 0x0, sizeof(camera_format_t));
+
+ ret = camera_hal_interface_get_preview_stream_format(h, &get_format);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = memcmp(&preview_format, &get_format, sizeof(camera_format_t));
+ EXPECT_EQ(ret, 0);
+
+ camera_hal_interface_close_device(h);
+}
+
+/**
+ * @testcase GetPreviewStreamFormatN
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Negative, Get the stream format for preview in camera
+ * @apicovered camera_open_device, camera_get_preview_stream_format
+ * @passcase when camera_get_preview_stream_format returns CAMERA_ERROR_INVALID_PARAMETER
+ * @failcase when camera_get_preview_stream_format does not return CAMERA_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, GetPreviewStreamFormatN)
+{
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_get_preview_stream_format(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_INVALID_PARAMETER);
+
+ camera_hal_interface_close_device(h);
+}
+
+/**
+ * @testcase StartPreviewP
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Positive, Start the preview stream in camera
+ * @apicovered camera_open_device, camera_set_preview_stream_format, camera_start_preview
+ * @passcase when camera_start_preview returns CAMERA_ERROR_NONE
+ * @failcase when camera_start_preview does not return CAMERA_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, StartPreviewP)
+{
+ unsigned int i = 0;
+
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ for (i = 0 ; i < device_info_list.count ; i++) {
+ cout << "Device Index " << i << endl;
+
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[i].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ GetSupportedFormat(i);
+
+ ret = camera_hal_interface_set_preview_stream_format(h, &preview_format);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ preview_check = 0;
+
+ ret = camera_hal_interface_start_preview(h, _PreviewCb, (void *)h);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ /* wait for preview frame */
+ sleep(1);
+
+ EXPECT_TRUE(preview_check);
+
+ camera_hal_interface_stop_preview(h);
+ camera_hal_interface_close_device(h);
+ }
+}
+
+/**
+ * @testcase StartPreviewN
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Negative, Start the preview stream in camera
+ * @apicovered camera_open_device, camera_set_preview_stream_format, camera_start_preview
+ * @passcase when camera_start_preview returns CAMERA_ERROR_INVALID_PARAMETER
+ * @failcase when camera_start_preview does not return CAMERA_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, StartPreviewN)
+{
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_set_preview_stream_format(h, &preview_format);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_start_preview(h, nullptr, (void *)h);
+ EXPECT_EQ(ret, CAMERA_ERROR_INVALID_PARAMETER);
+
+ camera_hal_interface_close_device(h);
+}
+
+/**
+ * @testcase StopPreviewP
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Positive, Stop the preview stream in camera
+ * @apicovered camera_open_device, camera_set_preview_stream_format, camera_start_preview, camera_stop_preview
+ * @passcase when camera_stop_preview returns CAMERA_ERROR_NONE
+ * @failcase when camera_stop_preview does not return CAMERA_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, StopPreviewP)
+{
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_set_preview_stream_format(h, &preview_format);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_start_preview(h, _PreviewCb, (void *)h);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_stop_preview(h);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ camera_hal_interface_close_device(h);
+}
+
+/**
+ * @testcase StartCaptureP
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Positive, Start the image capture in camera
+ * @apicovered camera_open_device, camera_set_preview_stream_format, camera_start_preview, camera_start_capture
+ * @passcase when camera_start_capture returns CAMERA_ERROR_NONE
+ * @failcase when camera_start_capture does not return CAMERA_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, StartCaptureP)
+{
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_set_preview_stream_format(h, &preview_format);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_start_preview(h, _PreviewCb, (void *)h);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ capture_check = 0;
+
+ ret = camera_hal_interface_start_capture(h, _CaptureCb, NULL);
+
+ if (ret != CAMERA_ERROR_DEVICE_NOT_SUPPORTED) {
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ /* wait for capture frame */
+ sleep(1);
+
+ EXPECT_TRUE(capture_check);
+
+ camera_hal_interface_stop_capture(h);
+ } else {
+ cout << "NOT SUPPORTED : CAPTURE" << endl;
+ }
+
+ camera_hal_interface_stop_preview(h);
+ camera_hal_interface_close_device(h);
+}
+
+/**
+ * @testcase StartCaptureN
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Negative, Start the image capture in camera
+ * @apicovered camera_open_device, camera_set_preview_stream_format, camera_start_preview, camera_start_capture
+ * @passcase when camera_start_capture returns CAMERA_ERROR_INVALID_PARAMETER
+ * @failcase when camera_start_capture does not return CAMERA_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, StartCaptureN)
+{
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_set_preview_stream_format(h, &preview_format);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_start_preview(h, _PreviewCb, (void *)h);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_start_capture(h, nullptr, NULL);
+ EXPECT_EQ(ret, CAMERA_ERROR_INVALID_PARAMETER);
+
+ camera_hal_interface_stop_preview(h);
+ camera_hal_interface_close_device(h);
+}
+
+/**
+ * @testcase StopCaptureP
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Positive, Stop the image capture in camera
+ * @apicovered camera_open_device, camera_set_preview_stream_format, camera_start_preview, camera_start_capture, camera_stop_capture
+ * @passcase when camera_stop_capture returns CAMERA_ERROR_NONE
+ * @failcase when camera_stop_capture does not return CAMERA_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, StopCaptureP)
+{
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_set_preview_stream_format(h, &preview_format);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_start_preview(h, _PreviewCb, (void *)h);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_start_capture(h, _CaptureCb, NULL);
+
+ if (ret != CAMERA_ERROR_DEVICE_NOT_SUPPORTED) {
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ /* wait for capture frame */
+ sleep(1);
+
+ ret = camera_hal_interface_stop_capture(h);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+ } else {
+ cout << "NOT SUPPORTED : CAPTURE" << endl;
+ }
+
+ camera_hal_interface_stop_preview(h);
+ camera_hal_interface_close_device(h);
+}
+
+/**
+ * @testcase SetVideoStreamFormatP
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Positive, Set the stream format for video in camera
+ * @apicovered camera_open_device, camera_set_video_stream_format
+ * @passcase when camera_set_video_stream_format returns CAMERA_ERROR_NONE
+ * @failcase when camera_set_video_stream_format does not return CAMERA_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, SetVideoStreamFormatP)
+{
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_set_video_stream_format(h, &video_format);
+ if (ret != CAMERA_ERROR_DEVICE_NOT_SUPPORTED) {
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+ } else {
+ cout << "NOT SUPPORTED : VIDEO STREAM" << endl;
+ }
+
+ camera_hal_interface_close_device(h);
+}
+
+/**
+ * @testcase SetVideoStreamFormatN
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Negative, Set the stream format for video in camera
+ * @apicovered camera_open_device, camera_set_video_stream_format
+ * @passcase when camera_set_video_stream_format returns CAMERA_ERROR_INVALID_PARAMETER
+ * @failcase when camera_set_video_stream_format does not return CAMERA_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, SetVideoStreamFormatN)
+{
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_set_video_stream_format(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_INVALID_PARAMETER);
+
+ camera_hal_interface_close_device(h);
+}
+
+/**
+ * @testcase GetVideoStreamFormatP
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Positive, Get the stream format for video in camera
+ * @apicovered camera_open_device, camera_set_video_stream_format, camera_get_video_stream_format
+ * @passcase when camera_get_video_stream_format returns CAMERA_ERROR_NONE and result is same with previous set format
+ * @failcase when camera_get_video_stream_format does not return CAMERA_ERROR_NONE or result is different with previous set format
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, GetVideoStreamFormatP)
+{
+ camera_format_t get_format;
+
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ memset(&get_format, 0x0, sizeof(camera_format_t));
+
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_set_video_stream_format(h, &video_format);
+
+ if (ret != CAMERA_ERROR_DEVICE_NOT_SUPPORTED) {
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_get_video_stream_format(h, &get_format);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = memcmp(&video_format, &get_format, sizeof(camera_format_t));
+ EXPECT_EQ(ret, 0);
+ } else {
+ cout << "NOT SUPPORTED : VIDEO STREAM" << endl;
+ }
+
+ camera_hal_interface_close_device(h);
+}
+
+/**
+ * @testcase GetVideoStreamFormatN
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Negative, Get the stream format for video in camera
+ * @apicovered camera_open_device, camera_get_video_stream_format
+ * @passcase when camera_get_video_stream_format returns CAMERA_ERROR_INVALID_PARAMETER
+ * @failcase when camera_get_video_stream_format does not return CAMERA_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, GetVideoStreamFormatN)
+{
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_get_video_stream_format(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_INVALID_PARAMETER);
+
+ camera_hal_interface_close_device(h);
+}
+
+/**
+ * @testcase StartRecordP
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Positive, Start the record to get video frames
+ * @apicovered camera_open_device, camera_set_preview_stream_format, camera_start_preview, camera_set_video_stream_format, camera_start_record
+ * @passcase when camera_start_record returns CAMERA_ERROR_NONE
+ * @failcase when camera_start_record does not return CAMERA_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, StartRecordP)
+{
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_set_preview_stream_format(h, &preview_format);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_start_preview(h, _PreviewCb, (void *)h);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_set_video_stream_format(h, &video_format);
+
+ if (ret != CAMERA_ERROR_DEVICE_NOT_SUPPORTED) {
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ video_check = 0;
+
+ ret = camera_hal_interface_start_record(h, _VideoCb, (void *)h);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ /* wait for video frame */
+ sleep(1);
+
+ EXPECT_TRUE(video_check);
+
+ camera_hal_interface_stop_record(h);
+ } else {
+ cout << "NOT SUPPORTED : VIDEO STREAM" << endl;
+ }
+
+ camera_hal_interface_stop_preview(h);
+ camera_hal_interface_close_device(h);
+}
+
+/**
+ * @testcase StartRecordN
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Negative, Start the record to get video frames
+ * @apicovered camera_open_device, camera_set_preview_stream_format, camera_start_preview, camera_set_video_stream_format, camera_start_record
+ * @passcase when camera_start_record returns CAMERA_ERROR_INVALID_PARAMETER
+ * @failcase when camera_start_record does not return CAMERA_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, StartRecordN)
+{
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_set_preview_stream_format(h, &preview_format);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_start_preview(h, _PreviewCb, (void *)h);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_set_video_stream_format(h, &video_format);
+
+ if (ret != CAMERA_ERROR_DEVICE_NOT_SUPPORTED) {
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_start_record(h, nullptr, (void *)h);
+ EXPECT_EQ(ret, CAMERA_ERROR_INVALID_PARAMETER);
+ } else {
+ cout << "NOT SUPPORTED : VIDEO STREAM" << endl;
+ }
+
+ camera_hal_interface_stop_preview(h);
+ camera_hal_interface_close_device(h);
+}
+
+/**
+ * @testcase StopRecordP
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Positive, Stop the record
+ * @apicovered camera_open_device, camera_set_preview_stream_format, camera_start_preview, camera_set_video_stream_format, camera_start_record, camera_stop_record
+ * @passcase when camera_stop_record returns CAMERA_ERROR_NONE
+ * @failcase when camera_stop_record does not return CAMERA_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, StopRecordP)
+{
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_set_preview_stream_format(h, &preview_format);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_start_preview(h, _PreviewCb, (void *)h);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_set_video_stream_format(h, &video_format);
+
+ if (ret != CAMERA_ERROR_DEVICE_NOT_SUPPORTED) {
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_start_record(h, _VideoCb, (void *)h);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ /* wait for video frame */
+ sleep(1);
+
+ ret = camera_hal_interface_stop_record(h);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+ } else {
+ cout << "NOT SUPPORTED : VIDEO STREAM" << endl;
+ }
+
+ camera_hal_interface_stop_preview(h);
+ camera_hal_interface_close_device(h);
+}
+
+/**
+ * @testcase AddMessageCallbackP
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Positive, Add message callback to receive message from camera HAL
+ * @apicovered camera_open_device, camera_add_message_callback
+ * @passcase when camera_add_message_callback returns CAMERA_ERROR_NONE
+ * @failcase when camera_add_message_callback does not return CAMERA_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, AddMessageCallbackP)
+{
+ uint32_t cb_id = 0;
+
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_add_message_callback(h, _MessageCb, nullptr, &cb_id);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ camera_hal_interface_remove_message_callback(h, cb_id);
+ }
+
+ camera_hal_interface_close_device(h);
+}
+
+/**
+ * @testcase AddMessageCallbackN1
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Negative, Add message callback to receive message from camera HAL
+ * @apicovered camera_open_device, camera_add_message_callback
+ * @passcase when camera_add_message_callback returns CAMERA_ERROR_INVALID_PARAMETER
+ * @failcase when camera_add_message_callback does not return CAMERA_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, AddMessageCallbackN1)
+{
+ uint32_t cb_id = 0;
+
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_add_message_callback(h, nullptr, nullptr, &cb_id);
+ EXPECT_EQ(ret, CAMERA_ERROR_INVALID_PARAMETER);
+
+ camera_hal_interface_close_device(h);
+}
+
+/**
+ * @testcase AddMessageCallbackN2
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Negative, Add message callback to receive message from camera HAL
+ * @apicovered camera_open_device, camera_add_message_callback
+ * @passcase when camera_add_message_callback returns CAMERA_ERROR_INVALID_PARAMETER
+ * @failcase when camera_add_message_callback does not return CAMERA_ERROR_INVALID_PARAMETER
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, AddMessageCallbackN2)
+{
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_add_message_callback(h, _MessageCb, nullptr, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_INVALID_PARAMETER);
+
+ camera_hal_interface_close_device(h);
+}
+
+/**
+ * @testcase RemoveMessageCallbackP
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Positive, Remove message callback
+ * @apicovered camera_open_device, camera_add_message_callback, camera_remove_message_callback
+ * @passcase when camera_remove_message_callback returns CAMERA_ERROR_NONE
+ * @failcase when camera_remove_message_callback does not return CAMERA_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, RemoveMessageCallbackP)
+{
+ uint32_t cb_id = 0;
+
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_add_message_callback(h, _MessageCb, nullptr, &cb_id);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ if (ret == CAMERA_ERROR_NONE) {
+ ret = camera_hal_interface_remove_message_callback(h, cb_id);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+ }
+
+ camera_hal_interface_close_device(h);
+}
+
+/**
+ * @testcase StartAutoFocusP
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Positive, Start auto focus
+ * @apicovered camera_open_device, camera_add_message_callback, camera_set_preview_stream_format, camera_start_preview, camera_start_auto_focus
+ * @passcase when camera_start_auto_focus return CAMERA_ERROR_NONE and focus message is come in time
+ * @failcase when camera_start_auto_focus does not return CAMERA_ERROR_NONE or focus message is not come in time
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, StartAutoFocusP)
+{
+ uint32_t cb_id = 0;
+ gint64 end_time = 0;
+
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_add_message_callback(h, _MessageCb, nullptr, &cb_id);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_set_preview_stream_format(h, &preview_format);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_start_preview(h, _PreviewCb, (void *)h);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ g_mutex_lock(&msg_cb_lock);
+
+ ret = camera_hal_interface_start_auto_focus(h);
+
+ if (ret != CAMERA_ERROR_DEVICE_NOT_SUPPORTED) {
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ /* wait a message and check result */
+ end_time = g_get_monotonic_time() + G_TIME_SPAN_SECOND * 3;
+ EXPECT_EQ(g_cond_wait_until(&msg_cb_cond, &msg_cb_lock, end_time), true);
+ } else {
+ cout << "NOT SUPPORTED : AUTO FOCUS" << endl;
+ }
+
+ g_mutex_unlock(&msg_cb_lock);
+
+ camera_hal_interface_stop_preview(h);
+ camera_hal_interface_remove_message_callback(h, cb_id);
+ camera_hal_interface_close_device(h);
+}
+
+/**
+ * @testcase StopAutoFocusP
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Positive, Stop auto focus
+ * @apicovered camera_open_device, camera_add_message_callback, camera_set_preview_stream_format, camera_start_preview, camera_start_auto_focus, camera_stop_auto_focus
+ * @passcase when camera_hal_interface_stop_auto_focus returns CAMERA_ERROR_NONE
+ * @failcase when camera_hal_interface_stop_auto_focus does not return CAMERA_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, StopAutoFocusP)
+{
+ uint32_t cb_id = 0;
+
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_add_message_callback(h, _MessageCb, nullptr, &cb_id);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_set_preview_stream_format(h, &preview_format);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_start_preview(h, _PreviewCb, (void *)h);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_start_auto_focus(h);
+
+ if (ret != CAMERA_ERROR_DEVICE_NOT_SUPPORTED) {
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_stop_auto_focus(h);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+ } else {
+ cout << "NOT SUPPORTED : AUTO FOCUS" << endl;
+ }
+
+ camera_hal_interface_stop_preview(h);
+ camera_hal_interface_remove_message_callback(h, cb_id);
+ camera_hal_interface_close_device(h);
+}
+
+/**
+ * @testcase ReleasePreviewBufferP
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Positive, Release preview buffer to get new frame in it
+ * @apicovered camera_open_device, camera_set_preview_stream_format, camera_start_preview, camera_release_preview_buffer
+ * @passcase when camera_release_preview_buffer returns CAMERA_ERROR_NONE
+ * @failcase when camera_release_preview_buffer does not return CAMERA_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, ReleasePreviewBufferP)
+{
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_set_preview_stream_format(h, &preview_format);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret_release_preview_buffer = CAMERA_ERROR_INTERNAL;
+
+ ret = camera_hal_interface_start_preview(h, _PreviewCb, (void *)h);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ /* wait for preview frame */
+ sleep(1);
+
+ EXPECT_EQ(ret_release_preview_buffer, CAMERA_ERROR_NONE);
+
+ camera_hal_interface_stop_preview(h);
+ camera_hal_interface_close_device(h);
+}
+
+/**
+ * @testcase ReleaseVideoBufferP
+ * @sizen_tizen 4.0
+ * @author SR(jm80.yang)
+ * @reviewer SR(haesu.gwon)
+ * @type auto
+ * @description Positive, Release video buffer to get new frame in it
+ * @apicovered camera_open_device, camera_set_preview_stream_format, camera_start_preview, camera_set_video_stream_format, camera_start_record, camera_release_video_buffer
+ * @passcase when camera_release_video_buffer returns CAMERA_ERROR_NONE
+ * @failcase when camera_release_video_buffer does not return CAMERA_ERROR_NONE
+ * @precondition None
+ * @postcondition None
+ */
+TEST_F(CameraHalTest, ReleaseVideoBufferP)
+{
+ CAMERA_SUPPORT_CHECK;
+
+ EXPECT_NE(h, nullptr);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_open_device(h, device_info_list.device_info[0].index);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_set_preview_stream_format(h, &preview_format);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_start_preview(h, _PreviewCb, (void *)h);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret = camera_hal_interface_set_video_stream_format(h, &video_format);
+
+ if (ret != CAMERA_ERROR_DEVICE_NOT_SUPPORTED) {
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ ret_release_video_buffer = CAMERA_ERROR_INTERNAL;
+
+ ret = camera_hal_interface_start_record(h, _VideoCb, (void *)h);
+ EXPECT_EQ(ret, CAMERA_ERROR_NONE);
+
+ /* wait for video frame */
+ sleep(1);
+
+ EXPECT_EQ(ret_release_video_buffer, CAMERA_ERROR_NONE);
+
+ camera_hal_interface_stop_record(h);
+ } else {
+ cout << "NOT SUPPORTED : VIDEO STREAM" << endl;
+ }
+
+ camera_hal_interface_stop_preview(h);
+ camera_hal_interface_close_device(h);
+}
+
+
+int main(int argc, char **argv)
+{
+ testing::InitGoogleTest(&argc, argv);
+
+ return RUN_ALL_TESTS();
+}