diff --git a/test/unittest/recorder_test/capi/src/recorder_unit_test.cpp b/test/unittest/recorder_test/capi/src/recorder_unit_test.cpp index 62077fe86e086702d764ff8a78136ae3a19dbf50..d5df74e1328e236da0987ed2c7da94414471f4c5 100644 --- a/test/unittest/recorder_test/capi/src/recorder_unit_test.cpp +++ b/test/unittest/recorder_test/capi/src/recorder_unit_test.cpp @@ -99,6 +99,20 @@ static HapPolicyParams hapPolicy = { .resDeviceID = { "local" }, .grantStatus = { PermissionState::PERMISSION_GRANTED }, .grantFlags = { 1 } + }, + { + .permissionName = "ohos.permission.GET_BUNDLE_INFO", + .isGeneral = true, + .resDeviceID = { "local" }, + .grantStatus = { PermissionState::PERMISSION_GRANTED }, + .grantFlags = { 1 } + }, + { + .permissionName = "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED", + .isGeneral = true, + .resDeviceID = { "local" }, + .grantStatus = { PermissionState::PERMISSION_GRANTED }, + .grantFlags = { 1 } } } }; @@ -603,6 +617,55 @@ HWTEST_F(NativeRecorderUnitTest, Recorder_Prepare_007, TestSize.Level2) MEDIA_LOGI("NativeRecorderUnitTest Recorder_Prepare_007 out."); } +/** + * @tc.name: Recorder_Prepare_008 + * @tc.desc: Test recorder preparation process success situation + * @tc.type: FUNC + */ +HWTEST_F(NativeRecorderUnitTest, Recorder_Prepare_008, TestSize.Level2) +{ + MEDIA_LOGI("NativeRecorderUnitTest Recorder_Prepare_008 in."); + + OH_AVRecorder_Config config = config_; + config.url = strdup(""); + config.metadata.genre = strdup(""); + config.metadata.videoOrientation = nullptr; + config.metadata.customInfo.key = strdup("abc"); + config.metadata.customInfo.value = strdup("123"); + config.profile.audioBitrate = 96000; + config.profile.audioChannels = 2; + config.profile.audioCodec = OH_AVRecorder_CodecMimeType::AVRECORDER_AUDIO_AAC; + config.profile.audioSampleRate = 48000; + config.profile.fileFormat = OH_AVRecorder_ContainerFormatType::AVRECORDER_CFT_MPEG_4; + config.profile.videoBitrate = 2000000; + config.profile.videoCodec = OH_AVRecorder_CodecMimeType::AVRECORDER_VIDEO_AVC; + config.profile.videoFrameWidth = 1280; + config.profile.videoFrameHeight = 720; + config.profile.videoFrameRate = 30; + config.profile.isHdr = false; + config.profile.enableTemporalScale = false; + config.audioSourceType = OH_AVRecorder_AudioSourceType::AVRECORDER_MIC; + config.videoSourceType = OH_AVRecorder_VideoSourceType::AVRECORDER_SURFACE_YUV; + config.fileGenerationMode = OH_AVRecorder_FileGenerationMode::AVRECORDER_AUTO_CREATE_CAMERA_SCENE; + + int32_t ret = AV_ERR_OK; + ret = OH_AVRecorder_Prepare(recorder_, &config); + + #ifdef SUPPORT_RECORDER_CREATE_FILE + EXPECT_EQ(ret, AV_ERR_OK); + #else + EXPECT_EQ(ret, AV_ERR_INVALID_VAL); + #endif + + free(config.url); + free(config.metadata.genre); + free(config.metadata.videoOrientation); + free(config.metadata.customInfo.key); + free(config.metadata.customInfo.value); + + MEDIA_LOGI("NativeRecorderUnitTest Recorder_Prepare_008 out."); +} + /** * @tc.name: Recorder_Prepare_009 * @tc.desc: Test recorder preparation process success situation 2 @@ -950,6 +1013,97 @@ HWTEST_F(NativeRecorderUnitTest, Recorder_UpdateRotation_002, TestSize.Level2) MEDIA_LOGI("NativeRecorderUnitTest Recorder_UpdateRotation_002 out."); } +/** + * @tc.name: Recorder_UpdateRotation_003 + * @tc.desc: Test recorder UpdateRotation process 003 + * @tc.type: FUNC + */ +HWTEST_F(NativeRecorderUnitTest, Recorder_UpdateRotation_003, TestSize.Level2) +{ + MEDIA_LOGI("NativeRecorderUnitTest Recorder_UpdateRotation_003 in."); + + OH_AVRecorder_Config config = config_; + config.url = strdup(""); + config.metadata.genre = strdup(""); + config.metadata.videoOrientation = strdup("0"); + config.metadata.customInfo.key = strdup(""); + config.metadata.customInfo.value = strdup(""); + config.fileGenerationMode = OH_AVRecorder_FileGenerationMode::AVRECORDER_AUTO_CREATE_CAMERA_SCENE; + + int32_t rotation = 90; + + int32_t ret = AV_ERR_OK; + + ret = OH_AVRecorder_Prepare(recorder_, &config); + #ifdef SUPPORT_RECORDER_CREATE_FILE + EXPECT_EQ(ret, AV_ERR_OK); + #else + EXPECT_EQ(ret, AV_ERR_INVALID_VAL); + #endif + ret = OH_AVRecorder_UpdateRotation(recorder_, rotation); + EXPECT_EQ(ret, AV_ERR_OK); + + + free(config.url); + free(config.metadata.genre); + free(config.metadata.videoOrientation); + free(config.metadata.customInfo.key); + free(config.metadata.customInfo.value); + + MEDIA_LOGI("NativeRecorderUnitTest Recorder_UpdateRotation_003 out."); +} + +/** + * @tc.name: Recorder_UpdateRotation_004 + * @tc.desc: Test recorder UpdateRotation process 004 + * @tc.type: FUNC + */ +HWTEST_F(NativeRecorderUnitTest, Recorder_UpdateRotation_004, TestSize.Level2) +{ + MEDIA_LOGI("NativeRecorderUnitTest Recorder_UpdateRotation_004 in."); + + OH_AVRecorder_Config config = config_; + config.url = strdup(""); + config.metadata.genre = strdup(""); + config.metadata.videoOrientation = strdup("0"); + config.metadata.customInfo.key = strdup(""); + config.metadata.customInfo.value = strdup(""); + config.fileGenerationMode = OH_AVRecorder_FileGenerationMode::AVRECORDER_AUTO_CREATE_CAMERA_SCENE; + + int32_t ret = AV_ERR_OK; + + ret = OH_AVRecorder_Prepare(recorder_, &config); + #ifdef SUPPORT_RECORDER_CREATE_FILE + EXPECT_EQ(ret, AV_ERR_OK); + #else + EXPECT_EQ(ret, AV_ERR_INVALID_VAL); + #endif + + int32_t rotation = 0; + ret = OH_AVRecorder_UpdateRotation(recorder_, rotation); + EXPECT_EQ(ret, AV_ERR_OK); + + rotation = 90; + ret = OH_AVRecorder_UpdateRotation(recorder_, rotation); + EXPECT_EQ(ret, AV_ERR_OK); + + rotation = 180; + ret = OH_AVRecorder_UpdateRotation(recorder_, rotation); + EXPECT_EQ(ret, AV_ERR_OK); + + rotation = 270; + ret = OH_AVRecorder_UpdateRotation(recorder_, rotation); + EXPECT_EQ(ret, AV_ERR_OK); + + free(config.url); + free(config.metadata.genre); + free(config.metadata.videoOrientation); + free(config.metadata.customInfo.key); + free(config.metadata.customInfo.value); + + MEDIA_LOGI("NativeRecorderUnitTest Recorder_UpdateRotation_004 out."); +} + /** * @tc.name: Recorder_Start_001 * @tc.desc: Test recorder start process 001