1 /*
2 * Copyright (c) 2023-2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <memory>
17 #include <string>
18 #include "gtest/gtest.h"
19 #include "plugin/plugins/ffmpeg_adapter/video_encoder/video_ffmpeg_encoder_plugin.h"
20
21 namespace OHOS {
22 namespace Media {
23 namespace Test {
24 using namespace OHOS::Media::Plugin;
25 using namespace testing::ext;
26
27 class TestFFmpegVideoEncoder : public ::testing::Test {
28 public:
29 std::shared_ptr<Ffmpeg::VideoFfmpegEncoderPlugin> videoFfmpegEncoderPlugin;
30 void SetUp() override
31 {
32 videoFfmpegEncoderPlugin = std::make_shared<Ffmpeg::VideoFfmpegEncoderPlugin>("test");
33 }
34
35 void TearDown() override
36 {
37 }
38 };
39
HWTEST_F(TestFFmpegVideoEncoder, test_init, TestSize.Level1)40 HWTEST_F(TestFFmpegVideoEncoder, test_init, TestSize.Level1)
41 {
42 auto status = videoFfmpegEncoderPlugin->Init();
43 EXPECT_EQ(Status::ERROR_UNSUPPORTED_FORMAT, status);
44 }
45
HWTEST_F(TestFFmpegVideoEncoder, test_prepare, TestSize.Level1)46 HWTEST_F(TestFFmpegVideoEncoder, test_prepare, TestSize.Level1)
47 {
48 auto status = videoFfmpegEncoderPlugin->Prepare();
49 EXPECT_EQ(Status::ERROR_WRONG_STATE, status);
50 }
51
HWTEST_F(TestFFmpegVideoEncoder, test_reset, TestSize.Level1)52 HWTEST_F(TestFFmpegVideoEncoder, test_reset, TestSize.Level1)
53 {
54 auto status = videoFfmpegEncoderPlugin->Reset();
55 EXPECT_EQ(Status::OK, status);
56 }
57
HWTEST_F(TestFFmpegVideoEncoder, test_start, TestSize.Level1)58 HWTEST_F(TestFFmpegVideoEncoder, test_start, TestSize.Level1)
59 {
60 auto status = videoFfmpegEncoderPlugin->Start();
61 EXPECT_EQ(Status::ERROR_WRONG_STATE, status);
62 }
63
HWTEST_F(TestFFmpegVideoEncoder, test_set_get_parameter, TestSize.Level1)64 HWTEST_F(TestFFmpegVideoEncoder, test_set_get_parameter, TestSize.Level1)
65 {
66 Tag tag = Tag::SECTION_VIDEO_UNIVERSAL_START;
67 ValueType value = 2;
68 auto status = videoFfmpegEncoderPlugin->GetParameter(tag, value);
69 EXPECT_EQ(Status::ERROR_WRONG_STATE, status);
70 status = videoFfmpegEncoderPlugin->SetParameter(tag, value);
71 EXPECT_EQ(Status::OK, status);
72 status = videoFfmpegEncoderPlugin->GetParameter(tag, value);
73 EXPECT_EQ(Status::OK, status);
74 }
75
HWTEST_F(TestFFmpegVideoEncoder, test_deinit_status, TestSize.Level1)76 HWTEST_F(TestFFmpegVideoEncoder, test_deinit_status, TestSize.Level1)
77 {
78 auto status = videoFfmpegEncoderPlugin->Deinit();
79 EXPECT_EQ(Status::OK, status);
80 }
81 } // namespace Test
82 } // namespace Media
83 } // namespace OHOS
84