• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file expect 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 #ifndef CODEC_SERVER_COVERAGE_UNIT_TEST
16 #define CODEC_SERVER_COVERAGE_UNIT_TEST
17 
18 #include "gtest/gtest.h"
19 #include "av_common.h"
20 #include "codecbase.h"
21 #include "codec_server.h"
22 
23 namespace OHOS {
24 namespace MediaAVCodec {
25 constexpr uint32_t DEFAULT_WIDTH = 4096;
26 constexpr uint32_t DEFAULT_HEIGHT = 4096;
27 class CodecServerUnitTest : public testing::Test {
28 public:
SetUpTestCase(void)29     static void SetUpTestCase(void){};
TearDownTestCase(void)30     static void TearDownTestCase(void){};
31     void SetUp(void);
32     void TearDown(void);
33 
34     void CreateCodecByMime();
35     void CreateFCodecByName();
36     void CreateFCodecByMime();
37     void CreateHCodecByName();
38     void CreateHCodecByMime();
39     std::shared_ptr<CodecBaseMock> codecBaseMock_ = nullptr;
40     std::shared_ptr<CodecServer> server_ = nullptr;
41 private:
42     Format validFormat_;
43 };
44 
45 class CodecParamCheckerTest : public testing::Test {
46 public:
SetUpTestCase(void)47     static void SetUpTestCase(void){};
TearDownTestCase(void)48     static void TearDownTestCase(void){};
SetUp(void)49     void SetUp(void){};
TearDown(void)50     void TearDown(void){};
51 };
52 
SetUp(void)53 inline void CodecServerUnitTest::SetUp(void)
54 {
55     codecBaseMock_ = std::make_shared<CodecBaseMock>();
56     CodecBase::RegisterMock(codecBaseMock_);
57 
58     server_ = std::static_pointer_cast<CodecServer>(CodecServer::Create());
59     EXPECT_NE(server_, nullptr);
60 
61     validFormat_.PutIntValue(Tag::VIDEO_WIDTH, DEFAULT_WIDTH);
62     validFormat_.PutIntValue(Tag::VIDEO_HEIGHT, DEFAULT_HEIGHT);
63     validFormat_.PutIntValue(Tag::VIDEO_PIXEL_FORMAT, static_cast<int32_t>(VideoPixelFormat::YUVI420));
64 }
65 
TearDown(void)66 inline void CodecServerUnitTest::TearDown(void)
67 {
68     server_->Release();
69     server_ = nullptr;
70     codecBaseMock_ = nullptr;
71     validFormat_ = Format();
72 }
73 } // name space MediaAVCodec
74 } // namespace OHOS
75 #endif // CODEC_SERVER_COVERAGE_UNIT_TEST