1 /*
2 * Copyright (c) 2025 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 <iostream>
17 #include <algorithm>
18 #include "dash_seg_template_node_unittest.h"
19
20 namespace OHOS {
21 namespace Media {
22 namespace Plugins {
23 namespace HttpPlugin {
24 using namespace testing;
25 using namespace testing::ext;
26 const static int32_t RET_TEST = 123;
27 const static int32_t NUM_TEST = 0;
SetUpTestCase(void)28 void DashSegTemplateNodeUnittest::SetUpTestCase(void) {}
TearDownTestCase(void)29 void DashSegTemplateNodeUnittest::TearDownTestCase(void) {}
SetUp(void)30 void DashSegTemplateNodeUnittest::SetUp(void)
31 {
32 dashPtr_ = std::make_shared<DashSegTemplateNode>();
33 }
TearDown(void)34 void DashSegTemplateNodeUnittest::TearDown(void)
35 {
36 dashPtr_ = nullptr;
37 }
38
39 /**
40 * @tc.name : Test GetAttr(_, uint32_t)
41 * @tc.number: GetAttr_001
42 * @tc.desc : Test segTemplateAttr_[index].val_.length() > 0
43 */
44 HWTEST_F(DashSegTemplateNodeUnittest, GetAttr_001, TestSize.Level0)
45 {
46 ASSERT_NE(dashPtr_, nullptr);
47 std::string attrName = "media";
48 uint32_t uiAttrVal = 0;
49 dashPtr_->segTemplateAttr_[NUM_TEST].val_ = std::to_string(RET_TEST);
50 dashPtr_->GetAttr(attrName, uiAttrVal);
51 EXPECT_EQ(uiAttrVal, RET_TEST);
52 }
53
54 /**
55 * @tc.name : Test GetAttr(_, int32_t)
56 * @tc.number: GetAttr_002
57 * @tc.desc : Test segTemplateAttr_[index].val_.length() > 0
58 */
59 HWTEST_F(DashSegTemplateNodeUnittest, GetAttr_002, TestSize.Level0)
60 {
61 ASSERT_NE(dashPtr_, nullptr);
62 std::string attrName = "media";
63 int32_t uiAttrVal = 0;
64 dashPtr_->segTemplateAttr_[NUM_TEST].val_ = std::to_string(RET_TEST);
65 dashPtr_->GetAttr(attrName, uiAttrVal);
66 EXPECT_EQ(uiAttrVal, RET_TEST);
67 }
68
69 /**
70 * @tc.name : Test GetAttr(_, uint64_t)
71 * @tc.number: GetAttr_003
72 * @tc.desc : Test segTemplateAttr_[index].val_.length() > 0
73 */
74 HWTEST_F(DashSegTemplateNodeUnittest, GetAttr_003, TestSize.Level0)
75 {
76 ASSERT_NE(dashPtr_, nullptr);
77 std::string attrName = "media";
78 uint64_t uiAttrVal = 0;
79 dashPtr_->segTemplateAttr_[NUM_TEST].val_ = std::to_string(RET_TEST);
80 dashPtr_->GetAttr(attrName, uiAttrVal);
81 EXPECT_EQ(uiAttrVal, RET_TEST);
82 }
83
84 /**
85 * @tc.name : Test GetAttr(_, double)
86 * @tc.number: GetAttr_004
87 * @tc.desc : Test segTemplateAttr_[index].val_.length() > 0
88 */
89 HWTEST_F(DashSegTemplateNodeUnittest, GetAttr_004, TestSize.Level0)
90 {
91 ASSERT_NE(dashPtr_, nullptr);
92 std::string attrName = "media";
93 double uiAttrVal = 0;
94 dashPtr_->segTemplateAttr_[NUM_TEST].val_ = std::to_string(RET_TEST);
95 dashPtr_->GetAttr(attrName, uiAttrVal);
96 EXPECT_EQ(uiAttrVal, RET_TEST);
97 }
98 }
99 }
100 }
101 }