2 * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "gtests_libmm_camcorder.h"
22 using ::testing::InitGoogleTest;
23 using ::testing::Test;
24 using ::testing::TestCase;
28 MMHandleType g_cam_handle;
30 GDBusConnection *g_dbus_connection;
35 static int _message_callback(int id, void *param, void *user_param)
37 MMMessageParamType *m = (MMMessageParamType *)param;
39 cout << "[ENTER]" << endl;
42 case MM_MESSAGE_CAMCORDER_STATE_CHANGED:
43 cout << "[STATE CHANGED] " << m->state.previous << " -> " << m->state.current << endl;
45 case MM_MESSAGE_CAMCORDER_CAPTURED:
46 cout << "[CAPTURED MESSAGE] SEND SIGNAL" << endl;
47 g_mutex_lock(&g_lock);
48 g_cond_signal(&g_capture_cond);
49 g_mutex_unlock(&g_lock);
51 case MM_MESSAGE_CAMCORDER_FOCUS_CHANGED:
52 cout << "[FOCUS CHANGED] SEND SIGNAL" << endl;
53 g_mutex_lock(&g_lock);
54 g_cond_signal(&g_focus_cond);
55 g_mutex_unlock(&g_lock);
61 cout << "[LEAVE]" << endl;
66 static gboolean _get_video_recording_settings(int *video_encoder, int *audio_encoder, int *file_format)
73 MMCamAttrsInfo info_a_enc;
74 MMCamAttrsInfo info_fmt;
76 if (!video_encoder || !audio_encoder || !file_format) {
77 cout << "NULL pointer" << endl;
81 /* get supported audio encoder list */
82 mm_camcorder_get_attribute_info(g_cam_handle, MMCAM_AUDIO_ENCODER, &info_a_enc);
84 /* get supported file format list */
85 mm_camcorder_get_attribute_info(g_cam_handle, MMCAM_FILE_FORMAT, &info_fmt);
87 /* compatibility check */
88 tmp_v_enc = MM_VIDEO_CODEC_MPEG4;
90 for (i = 0 ; i < info_fmt.int_array.count ; i++) {
91 tmp_fmt = info_fmt.int_array.array[i];
92 if (mm_camcorder_check_codec_fileformat_compatibility(MMCAM_VIDEO_ENCODER, tmp_v_enc, tmp_fmt) == MM_ERROR_NONE) {
93 for (j = 0 ; info_a_enc.int_array.count ; j++) {
94 tmp_a_enc = info_a_enc.int_array.array[j];
95 if (mm_camcorder_check_codec_fileformat_compatibility(MMCAM_AUDIO_ENCODER, tmp_a_enc, tmp_fmt) == MM_ERROR_NONE) {
96 cout << "[VIDEO RECORDING SETTING FOUND]" << endl;
98 *video_encoder = tmp_v_enc;
99 *audio_encoder = tmp_a_enc;
100 *file_format = tmp_fmt;
108 cout << "[VIDEO RECORDING SETTING FAILED]" << endl;
113 static gboolean _get_audio_recording_settings(int *audio_encoder, int *file_format)
118 MMCamAttrsInfo info_a_enc;
119 MMCamAttrsInfo info_fmt;
121 if (!audio_encoder || !file_format) {
122 cout << "NULL pointer" << endl;
126 /* get supported audio encoder list */
127 mm_camcorder_get_attribute_info(g_cam_handle, MMCAM_AUDIO_ENCODER, &info_a_enc);
129 /* get supported file format list */
130 mm_camcorder_get_attribute_info(g_cam_handle, MMCAM_FILE_FORMAT, &info_fmt);
132 /* compatibility check */
133 tmp_a_enc = info_a_enc.int_array.array[0];
135 for (i = 0 ; i < info_fmt.int_array.count ; i++) {
136 tmp_fmt = info_fmt.int_array.array[i];
137 if (mm_camcorder_check_codec_fileformat_compatibility(MMCAM_AUDIO_ENCODER, tmp_a_enc, tmp_fmt) == MM_ERROR_NONE) {
138 cout << "[AUDIO RECORDING SETTING FOUND]" << endl;
140 *audio_encoder = tmp_a_enc;
141 *file_format = tmp_fmt;
147 cout << "[VIDEO RECORDING SETTING FAILED]" << endl;
152 static gboolean _video_stream_callback(MMCamcorderVideoStreamDataType *stream, void *user_param)
154 cout << "[VIDEO_STREAM_CALLBACK]" << endl;
158 static gboolean _audio_stream_callback(MMCamcorderAudioStreamDataType *stream, void *user_param)
160 cout << "[AUDIO_STREAM_CALLBACK]" << endl;
164 static gboolean _muxed_stream_callback(MMCamcorderMuxedStreamDataType *stream, void *user_param)
166 cout << "[MUXED_STREAM_CALLBACK]" << endl;
173 static gboolean _video_capture_callback(MMCamcorderCaptureDataType *frame, MMCamcorderCaptureDataType *thumbnail, void *user_data)
175 cout << "[CAPTURE_CALLBACK]" << endl;
179 static int _start_preview(MMHandleType handle)
181 int ret = MM_ERROR_NONE;
183 ret = mm_camcorder_realize(handle);
184 if (ret != MM_ERROR_NONE) {
185 cout << "[REALIZE failed]" << endl;
189 ret = mm_camcorder_start(handle);
190 if (ret != MM_ERROR_NONE) {
191 cout << "[START failed]" << endl;
192 mm_camcorder_unrealize(handle);
198 static void _stop_preview(MMHandleType handle)
200 mm_camcorder_stop(handle);
201 mm_camcorder_unrealize(handle);
205 class MMCamcorderTest : public ::testing::Test {
208 cout << "[SetUp]" << endl;
210 if (g_dbus_connection) {
211 g_object_unref(g_dbus_connection);
212 g_dbus_connection = NULL;
215 g_dbus_connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
218 mm_camcorder_destroy(g_cam_handle);
222 g_info.videodev_type = MM_VIDEO_DEVICE_CAMERA0;
224 g_ret = mm_camcorder_create(&g_cam_handle, &g_info);
226 cout << "handle " << g_cam_handle << ", dbus connection " << g_dbus_connection << endl;
228 /* set gdbus connection */
229 if (g_cam_handle && g_dbus_connection) {
230 mm_camcorder_set_attributes(g_cam_handle, NULL,
231 MMCAM_GDBUS_CONNECTION, g_dbus_connection, 4,
235 /* set message callback */
236 if (mm_camcorder_set_message_callback(g_cam_handle, _message_callback, g_cam_handle) != MM_ERROR_NONE)
237 cout << "[FAILED] set message callback" << endl;
243 cout << "[TearDown]" << endl << endl;
246 mm_camcorder_destroy(g_cam_handle);
250 if (g_dbus_connection) {
251 g_object_unref(g_dbus_connection);
252 g_dbus_connection = NULL;
259 TEST_F(MMCamcorderTest, CreateP)
261 EXPECT_EQ(g_ret, MM_ERROR_NONE);
264 TEST_F(MMCamcorderTest, CreateN)
266 int ret = mm_camcorder_create(NULL, NULL);
268 EXPECT_EQ(ret, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
271 TEST_F(MMCamcorderTest, DestroyP)
273 int ret = MM_ERROR_NONE;
275 ret = mm_camcorder_destroy(g_cam_handle);
276 ASSERT_EQ(ret, MM_ERROR_NONE);
281 TEST_F(MMCamcorderTest, DestroyN)
283 int ret = MM_ERROR_NONE;
285 ret = mm_camcorder_destroy(NULL);
286 EXPECT_EQ(ret, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
289 TEST_F(MMCamcorderTest, RealizeP)
291 int ret = MM_ERROR_NONE;
293 ret = mm_camcorder_realize(g_cam_handle);
295 ASSERT_EQ(ret, MM_ERROR_NONE);
297 mm_camcorder_unrealize(g_cam_handle);
300 TEST_F(MMCamcorderTest, RealizeN)
302 int ret = MM_ERROR_NONE;
304 ret = mm_camcorder_realize(NULL);
306 EXPECT_EQ(ret, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
309 TEST_F(MMCamcorderTest, UnrealizeP)
311 int ret = MM_ERROR_NONE;
313 ret = mm_camcorder_realize(g_cam_handle);
315 ASSERT_EQ(ret, MM_ERROR_NONE);
317 ret = mm_camcorder_unrealize(g_cam_handle);
318 EXPECT_EQ(ret, MM_ERROR_NONE);
321 TEST_F(MMCamcorderTest, UnrealizeN)
323 int ret = MM_ERROR_NONE;
325 ret = mm_camcorder_realize(g_cam_handle);
327 ASSERT_EQ(ret, MM_ERROR_NONE);
329 ret = mm_camcorder_unrealize(NULL);
330 EXPECT_EQ(ret, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
332 mm_camcorder_unrealize(g_cam_handle);
335 TEST_F(MMCamcorderTest, StartP)
337 int ret = MM_ERROR_NONE;
339 ret = mm_camcorder_realize(g_cam_handle);
340 ASSERT_EQ(ret, MM_ERROR_NONE);
342 ret = mm_camcorder_start(g_cam_handle);
343 EXPECT_EQ(ret, MM_ERROR_NONE);
345 mm_camcorder_stop(g_cam_handle);
346 mm_camcorder_unrealize(g_cam_handle);
349 TEST_F(MMCamcorderTest, StartN)
351 int ret = MM_ERROR_NONE;
353 ret = mm_camcorder_realize(g_cam_handle);
354 ASSERT_EQ(ret, MM_ERROR_NONE);
356 ret = mm_camcorder_start(NULL);
357 EXPECT_EQ(ret, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
359 mm_camcorder_unrealize(g_cam_handle);
362 TEST_F(MMCamcorderTest, StopP)
364 int ret = MM_ERROR_NONE;
366 ret = mm_camcorder_realize(g_cam_handle);
367 ret |= mm_camcorder_start(g_cam_handle);
368 EXPECT_EQ(ret, MM_ERROR_NONE);
370 if (ret == MM_ERROR_NONE) {
371 ret = mm_camcorder_stop(g_cam_handle);
372 EXPECT_EQ(ret, MM_ERROR_NONE);
375 mm_camcorder_unrealize(g_cam_handle);
378 TEST_F(MMCamcorderTest, StopN)
380 int ret = MM_ERROR_NONE;
382 ret = mm_camcorder_realize(g_cam_handle);
383 ret |= mm_camcorder_start(g_cam_handle);
384 EXPECT_EQ(ret, MM_ERROR_NONE);
386 if (ret == MM_ERROR_NONE) {
387 ret = mm_camcorder_stop(NULL);
388 EXPECT_EQ(ret, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
391 mm_camcorder_stop(g_cam_handle);
392 mm_camcorder_unrealize(g_cam_handle);
395 TEST_F(MMCamcorderTest, CaptureStartP)
397 int ret = MM_ERROR_NONE;
398 gboolean ret_wait = FALSE;
401 ASSERT_EQ(_start_preview(g_cam_handle), MM_ERROR_NONE);
403 g_mutex_lock(&g_lock);
405 if (mm_camcorder_set_video_capture_callback(g_cam_handle, _video_capture_callback, g_cam_handle) != MM_ERROR_NONE)
406 cout << "[FAILED] set video capture callback" << endl;
408 ret = mm_camcorder_capture_start(g_cam_handle);
409 EXPECT_EQ(ret, MM_ERROR_NONE);
411 if (ret == MM_ERROR_NONE) {
412 end_time = g_get_monotonic_time() + 3 * G_TIME_SPAN_SECOND;
414 ret_wait = g_cond_wait_until(&g_capture_cond, &g_lock, end_time);
416 EXPECT_EQ(ret_wait, TRUE);
418 mm_camcorder_capture_stop(g_cam_handle);
421 g_mutex_unlock(&g_lock);
423 _stop_preview(g_cam_handle);
426 TEST_F(MMCamcorderTest, CaptureStartN1)
428 int ret = MM_ERROR_NONE;
430 ASSERT_EQ(_start_preview(g_cam_handle), MM_ERROR_NONE);
432 ret = mm_camcorder_capture_start(NULL);
433 EXPECT_EQ(ret, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
435 _stop_preview(g_cam_handle);
438 TEST_F(MMCamcorderTest, CaptureStartN2)
440 int ret = MM_ERROR_NONE;
442 ret = mm_camcorder_realize(g_cam_handle);
443 ASSERT_EQ(ret, MM_ERROR_NONE);
445 ret = mm_camcorder_capture_start(g_cam_handle);
446 EXPECT_EQ(ret, MM_ERROR_CAMCORDER_INVALID_STATE);
448 mm_camcorder_unrealize(g_cam_handle);
451 TEST_F(MMCamcorderTest, CaptureStopP)
453 int ret = MM_ERROR_NONE;
454 gboolean ret_wait = FALSE;
457 ASSERT_EQ(_start_preview(g_cam_handle), MM_ERROR_NONE);
459 g_mutex_lock(&g_lock);
461 if (mm_camcorder_set_video_capture_callback(g_cam_handle, _video_capture_callback, g_cam_handle) != MM_ERROR_NONE)
462 cout << "[FAILED] set video capture callback" << endl;
464 ret = mm_camcorder_capture_start(g_cam_handle);
465 EXPECT_EQ(ret, MM_ERROR_NONE);
467 if (ret == MM_ERROR_NONE) {
468 end_time = g_get_monotonic_time() + 3 * G_TIME_SPAN_SECOND;
470 ret_wait = g_cond_wait_until(&g_capture_cond, &g_lock, end_time);
472 EXPECT_EQ(ret_wait, TRUE);
474 ret = mm_camcorder_capture_stop(g_cam_handle);
475 EXPECT_EQ(ret, MM_ERROR_NONE);
478 g_mutex_unlock(&g_lock);
480 _stop_preview(g_cam_handle);
483 TEST_F(MMCamcorderTest, SetMessageCallbackP)
485 int ret = MM_ERROR_NONE;
487 ret = mm_camcorder_set_message_callback(g_cam_handle, _message_callback, g_cam_handle);
488 EXPECT_EQ(ret, MM_ERROR_NONE);
491 TEST_F(MMCamcorderTest, SetMessageCallbackN)
493 int ret = MM_ERROR_NONE;
495 ret = mm_camcorder_set_message_callback(NULL, _message_callback, g_cam_handle);
496 EXPECT_EQ(ret, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
499 TEST_F(MMCamcorderTest, SetVideoStreamCallbackP)
501 int ret = MM_ERROR_NONE;
503 ret = mm_camcorder_set_video_stream_callback(g_cam_handle, _video_stream_callback, g_cam_handle);
504 EXPECT_EQ(ret, MM_ERROR_NONE);
507 TEST_F(MMCamcorderTest, SetVideoStreamCallbackN)
509 int ret = MM_ERROR_NONE;
511 ret = mm_camcorder_set_video_stream_callback(NULL, _video_stream_callback, g_cam_handle);
512 EXPECT_EQ(ret, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
515 TEST_F(MMCamcorderTest, SetAudioStreamCallbackP)
517 int ret = MM_ERROR_NONE;
519 ret = mm_camcorder_set_audio_stream_callback(g_cam_handle, _audio_stream_callback, g_cam_handle);
520 EXPECT_EQ(ret, MM_ERROR_NONE);
523 TEST_F(MMCamcorderTest, SetAudioStreamCallbackN)
525 int ret = MM_ERROR_NONE;
527 ret = mm_camcorder_set_audio_stream_callback(NULL, _audio_stream_callback, g_cam_handle);
528 EXPECT_EQ(ret, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
531 TEST_F(MMCamcorderTest, SetVideoCaptureCallbackP)
533 int ret = MM_ERROR_NONE;
535 ret = mm_camcorder_set_video_capture_callback(g_cam_handle, _video_capture_callback, g_cam_handle);
536 EXPECT_EQ(ret, MM_ERROR_NONE);
539 TEST_F(MMCamcorderTest, SetVideoCaptureCallbackN)
541 int ret = MM_ERROR_NONE;
543 ret = mm_camcorder_set_video_capture_callback(NULL, _video_capture_callback, g_cam_handle);
544 EXPECT_EQ(ret, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
547 TEST_F(MMCamcorderTest, SetMuxedStreamCallbackP)
549 int ret = MM_ERROR_NONE;
551 ret = mm_camcorder_set_muxed_stream_callback(g_cam_handle, _muxed_stream_callback, g_cam_handle);
552 EXPECT_EQ(ret, MM_ERROR_NONE);
555 TEST_F(MMCamcorderTest, SetMuxedStreamCallbackN)
557 int ret = MM_ERROR_NONE;
559 ret = mm_camcorder_set_muxed_stream_callback(NULL, _muxed_stream_callback, g_cam_handle);
560 EXPECT_EQ(ret, MM_ERROR_CAMCORDER_INVALID_ARGUMENT);
563 TEST_F(MMCamcorderTest, RecordP)
565 int ret = MM_ERROR_NONE;
566 int video_encoder = 0;
567 int audio_encoder = 0;
569 gboolean ret_settings = FALSE;
571 ASSERT_EQ(_start_preview(g_cam_handle), MM_ERROR_NONE);
575 if (mm_camcorder_set_muxed_stream_callback(g_cam_handle, _muxed_stream_callback, g_cam_handle) != MM_ERROR_NONE)
576 cout << "[FAILED] set muxed stream callback" << endl;
578 ret_settings = _get_video_recording_settings(&video_encoder, &audio_encoder, &file_format);
579 EXPECT_EQ(ret_settings, TRUE);
581 ret = mm_camcorder_set_attributes(g_cam_handle, NULL,
582 MMCAM_VIDEO_ENCODER, video_encoder,
583 MMCAM_AUDIO_ENCODER, audio_encoder,
584 MMCAM_FILE_FORMAT, file_format,
586 EXPECT_EQ(ret, MM_ERROR_NONE);
588 ret = mm_camcorder_record(g_cam_handle);
589 EXPECT_EQ(ret, MM_ERROR_NONE);
591 if (ret == MM_ERROR_NONE) {
594 EXPECT_EQ(g_frame_count > 30, TRUE);
596 mm_camcorder_cancel(g_cam_handle);
599 _stop_preview(g_cam_handle);
602 TEST_F(MMCamcorderTest, CommitP)
604 int ret = MM_ERROR_NONE;
605 int video_encoder = 0;
606 int audio_encoder = 0;
608 gboolean ret_settings = FALSE;
610 ASSERT_EQ(_start_preview(g_cam_handle), MM_ERROR_NONE);
612 if (mm_camcorder_set_muxed_stream_callback(g_cam_handle, _muxed_stream_callback, g_cam_handle) != MM_ERROR_NONE)
613 cout << "[FAILED] set muxed stream callback" << endl;
615 ret_settings = _get_video_recording_settings(&video_encoder, &audio_encoder, &file_format);
616 EXPECT_EQ(ret_settings, TRUE);
618 ret = mm_camcorder_set_attributes(g_cam_handle, NULL,
619 MMCAM_VIDEO_ENCODER, video_encoder,
620 MMCAM_AUDIO_ENCODER, audio_encoder,
621 MMCAM_FILE_FORMAT, file_format,
623 EXPECT_EQ(ret, MM_ERROR_NONE);
625 ret = mm_camcorder_record(g_cam_handle);
626 EXPECT_EQ(ret, MM_ERROR_NONE);
628 if (ret == MM_ERROR_NONE) {
630 ret = mm_camcorder_commit(g_cam_handle);
631 EXPECT_EQ(ret, MM_ERROR_NONE);
634 _stop_preview(g_cam_handle);
637 TEST_F(MMCamcorderTest, CancelP)
639 int ret = MM_ERROR_NONE;
640 int video_encoder = 0;
641 int audio_encoder = 0;
643 gboolean ret_settings = FALSE;
645 ASSERT_EQ(_start_preview(g_cam_handle), MM_ERROR_NONE);
647 if (mm_camcorder_set_muxed_stream_callback(g_cam_handle, _muxed_stream_callback, g_cam_handle) != MM_ERROR_NONE)
648 cout << "[FAILED] set muxed stream callback" << endl;
650 ret_settings = _get_video_recording_settings(&video_encoder, &audio_encoder, &file_format);
651 EXPECT_EQ(ret_settings, TRUE);
653 ret = mm_camcorder_set_attributes(g_cam_handle, NULL,
654 MMCAM_VIDEO_ENCODER, video_encoder,
655 MMCAM_AUDIO_ENCODER, audio_encoder,
656 MMCAM_FILE_FORMAT, file_format,
658 EXPECT_EQ(ret, MM_ERROR_NONE);
660 ret = mm_camcorder_record(g_cam_handle);
661 EXPECT_EQ(ret, MM_ERROR_NONE);
663 if (ret == MM_ERROR_NONE) {
664 ret = mm_camcorder_cancel(g_cam_handle);
665 EXPECT_EQ(ret, MM_ERROR_NONE);
668 _stop_preview(g_cam_handle);
671 TEST_F(MMCamcorderTest, PauseP)
673 int ret = MM_ERROR_NONE;
674 int video_encoder = 0;
675 int audio_encoder = 0;
677 gboolean ret_settings = FALSE;
679 ASSERT_EQ(_start_preview(g_cam_handle), MM_ERROR_NONE);
681 if (mm_camcorder_set_muxed_stream_callback(g_cam_handle, _muxed_stream_callback, g_cam_handle) != MM_ERROR_NONE)
682 cout << "[FAILED] set muxed stream callback" << endl;
684 ret_settings = _get_video_recording_settings(&video_encoder, &audio_encoder, &file_format);
685 EXPECT_EQ(ret_settings, TRUE);
687 ret = mm_camcorder_set_attributes(g_cam_handle, NULL,
688 MMCAM_VIDEO_ENCODER, video_encoder,
689 MMCAM_AUDIO_ENCODER, audio_encoder,
690 MMCAM_FILE_FORMAT, file_format,
692 EXPECT_EQ(ret, MM_ERROR_NONE);
694 ret = mm_camcorder_record(g_cam_handle);
695 EXPECT_EQ(ret, MM_ERROR_NONE);
697 if (ret == MM_ERROR_NONE) {
700 ret = mm_camcorder_pause(g_cam_handle);
701 EXPECT_EQ(ret, MM_ERROR_NONE);
703 mm_camcorder_cancel(g_cam_handle);
706 _stop_preview(g_cam_handle);
709 TEST_F(MMCamcorderTest, GetStateP)
711 int ret = MM_ERROR_NONE;
712 MMCamcorderStateType state = MM_CAMCORDER_STATE_NONE;
714 ret = mm_camcorder_get_state(g_cam_handle, &state);
715 ASSERT_EQ(ret, MM_ERROR_NONE);
718 TEST_F(MMCamcorderTest, GetState2P)
720 int ret = MM_ERROR_NONE;
721 MMCamcorderStateType state = MM_CAMCORDER_STATE_NONE;
722 MMCamcorderStateType old_state = MM_CAMCORDER_STATE_NONE;
724 ret = mm_camcorder_get_state2(g_cam_handle, &state, &old_state);
725 ASSERT_EQ(ret, MM_ERROR_NONE);
728 TEST_F(MMCamcorderTest, GetAttributesP)
730 int ret = MM_ERROR_NONE;
731 int device_count = 0;
732 int audio_device = 0;
734 ret = mm_camcorder_get_attributes(g_cam_handle, NULL,
735 MMCAM_CAMERA_DEVICE_COUNT, &device_count,
736 MMCAM_AUDIO_DEVICE, &audio_device,
738 ASSERT_EQ(ret, MM_ERROR_NONE);
741 TEST_F(MMCamcorderTest, SetAttributesP)
743 int ret = MM_ERROR_NONE;
744 int audio_encoder = 0;
746 gboolean ret_settings = FALSE;
748 ret_settings = _get_audio_recording_settings(&audio_encoder, &file_format);
749 ASSERT_EQ(ret_settings, TRUE);
751 ret = mm_camcorder_set_attributes(g_cam_handle, NULL,
752 MMCAM_MODE, MM_CAMCORDER_MODE_AUDIO,
753 MMCAM_AUDIO_ENCODER, audio_encoder,
754 MMCAM_FILE_FORMAT, file_format,
756 ASSERT_EQ(ret, MM_ERROR_NONE);
759 TEST_F(MMCamcorderTest, GetAttributeInfoP)
761 int ret = MM_ERROR_NONE;
764 ret = mm_camcorder_get_attribute_info(g_cam_handle, MMCAM_MODE, &info);
765 ASSERT_EQ(ret, MM_ERROR_NONE);
768 TEST_F(MMCamcorderTest, GetFPSListByResolutionP)
770 int ret = MM_ERROR_NONE;
773 MMCamAttrsInfo fps_info;
775 ret = mm_camcorder_get_attributes(g_cam_handle, NULL,
776 MMCAM_CAMERA_WIDTH, &width,
777 MMCAM_CAMERA_HEIGHT, &height,
779 ASSERT_EQ(ret, MM_ERROR_NONE);
781 ret = mm_camcorder_get_fps_list_by_resolution(g_cam_handle, width, height, &fps_info);
782 ASSERT_EQ(ret, MM_ERROR_NONE);
785 TEST_F(MMCamcorderTest, InitFocsingP)
787 ASSERT_EQ(_start_preview(g_cam_handle), MM_ERROR_NONE);
789 EXPECT_EQ(mm_camcorder_init_focusing(g_cam_handle), MM_ERROR_NONE);
791 _stop_preview(g_cam_handle);
794 TEST_F(MMCamcorderTest, StartFocusingP)
798 ASSERT_EQ(_start_preview(g_cam_handle), MM_ERROR_NONE);
800 g_mutex_lock(&g_lock);
802 EXPECT_EQ(mm_camcorder_start_focusing(g_cam_handle), MM_ERROR_NONE);
804 end_time = g_get_monotonic_time() + 3 * G_TIME_SPAN_SECOND;
806 EXPECT_EQ(g_cond_wait_until(&g_focus_cond, &g_lock, end_time), TRUE);
808 g_mutex_unlock(&g_lock);
810 _stop_preview(g_cam_handle);
813 TEST_F(MMCamcorderTest, StopFocusingP)
815 ASSERT_EQ(_start_preview(g_cam_handle), MM_ERROR_NONE);
817 EXPECT_EQ(mm_camcorder_start_focusing(g_cam_handle), MM_ERROR_NONE);
818 EXPECT_EQ(mm_camcorder_stop_focusing(g_cam_handle), MM_ERROR_NONE);
820 _stop_preview(g_cam_handle);
824 int main(int argc, char **argv)
826 InitGoogleTest(&argc, argv);
828 return RUN_ALL_TESTS();