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 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 <gtest/gtest.h>
17 #include "avsession_log.h"
18 #include "avsession_errors.h"
19 #include "timer.h"
20
21 #define private public
22 #define protected public
23 #include "params_config_operator.h"
24 #undef protected
25 #undef private
26
27 using namespace OHOS;
28 using namespace OHOS::AVSession;
29
30 class ParamsConfigOperatorTest : public testing::Test {
31 public:
32 static void SetUpTestCase(void);
33 static void TearDownTestCase(void);
34 void SetUp();
35 void TearDown();
36 };
37
SetUpTestCase()38 void ParamsConfigOperatorTest::SetUpTestCase()
39 {
40 }
41
TearDownTestCase()42 void ParamsConfigOperatorTest::TearDownTestCase()
43 {
44 }
45
SetUp()46 void ParamsConfigOperatorTest::SetUp()
47 {
48 }
49
TearDown()50 void ParamsConfigOperatorTest::TearDown()
51 {
52 }
53
54 /**
55 * @tc.name: InitConfig001
56 * @tc.desc: Test InitConfig
57 * @tc.type: FUNC
58 */
59 static HWTEST_F(ParamsConfigOperatorTest, InitConfig001, testing::ext::TestSize.Level1)
60 {
61 SLOGI("InitConfig001 begin!");
62 auto paramsConfigOperator = ParamsConfigOperator::GetInstance();
63 paramsConfigOperator.InitConfig();
64 SLOGI("InitConfig001 end!");
65 }
66
67 /**
68 * @tc.name: GetValueIntByKey001
69 * @tc.desc: Test GetValueIntByKey
70 * @tc.type: FUNC
71 */
72 static HWTEST_F(ParamsConfigOperatorTest, GetValueIntByKey001, testing::ext::TestSize.Level1)
73 {
74 SLOGI("GetValueIntByKey001 begin!");
75 auto paramsConfigOperator = ParamsConfigOperator::GetInstance();
76 int32_t *value = nullptr;
77 int32_t ret = paramsConfigOperator.GetValueIntByKey("test1", value);
78 EXPECT_EQ(ret, AVSESSION_ERROR);
79 SLOGI("GetValueIntByKey001 end!");
80 }
81
82 /**
83 * @tc.name: GetValueIntByKey002
84 * @tc.desc: Test GetValueIntByKey
85 * @tc.type: FUNC
86 */
87 static HWTEST_F(ParamsConfigOperatorTest, GetValueIntByKey002, testing::ext::TestSize.Level1)
88 {
89 SLOGI("GetValueIntByKey002 begin!");
90 auto paramsConfigOperator = ParamsConfigOperator::GetInstance();
91 int32_t *value = nullptr;
92 paramsConfigOperator.configStringParams["test2"] = "test2";
93 int32_t ret = paramsConfigOperator.GetValueIntByKey("test2", value);
94 EXPECT_EQ(ret, AVSESSION_ERROR);
95 SLOGI("GetValueIntByKey002 end!");
96 }
97