• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "dash_mpd_node_unittest.h"
17 
18 namespace OHOS {
19 namespace Media {
20 namespace Plugins {
21 namespace HttpPlugin {
22 using namespace std;
23 using namespace testing;
24 using namespace testing::ext;
25 static const int32_t NUM_0 = 0;
26 static const int32_t NUM_1 = 1;
27 
SetUpTestCase(void)28 void DashMpdNodeUnitTest::SetUpTestCase(void) {}
29 
TearDownTestCase(void)30 void DashMpdNodeUnitTest::TearDownTestCase(void) {}
31 
SetUp(void)32 void DashMpdNodeUnitTest::SetUp(void)
33 {
34     dashMpdNode_ = std::make_shared<DashMpdNode>();
35 }
36 
TearDown(void)37 void DashMpdNodeUnitTest::TearDown(void)
38 {
39     dashMpdNode_ = nullptr;
40 }
41 
42 /**
43  * @tc.name  : Test GetAttr(string, uint32_t)
44  * @tc.number: GetAttr_001
45  * @tc.desc  : Test mpdAttr_[index].val_.length() > 0
46  */
47 HWTEST_F(DashMpdNodeUnitTest, GetAttr_001, TestSize.Level0)
48 {
49     ASSERT_NE(dashMpdNode_, nullptr);
50     std::string attrName = "id";
51     uint32_t uiAttrVal;
52     dashMpdNode_->mpdAttr_[NUM_0].val_ = "1";
53     dashMpdNode_->GetAttr(attrName, uiAttrVal);
54     EXPECT_EQ(uiAttrVal, NUM_1);
55 }
56 
57 /**
58  * @tc.name  : Test GetAttr(string, int32_t)
59  * @tc.number: GetAttr_002
60  * @tc.desc  : Test mpdAttr_[index].val_.length() > 0
61  */
62 HWTEST_F(DashMpdNodeUnitTest, GetAttr_002, TestSize.Level0)
63 {
64     ASSERT_NE(dashMpdNode_, nullptr);
65     std::string attrName = "id";
66     int32_t iAttrVal;
67     dashMpdNode_->mpdAttr_[NUM_0].val_ = "1";
68     dashMpdNode_->GetAttr(attrName, iAttrVal);
69     EXPECT_EQ(iAttrVal, NUM_1);
70 }
71 
72 /**
73  * @tc.name  : Test GetAttr(string, uint64_t)
74  * @tc.number: GetAttr_003
75  * @tc.desc  : Test mpdAttr_[index].val_.length() > 0
76  */
77 HWTEST_F(DashMpdNodeUnitTest, GetAttr_003, TestSize.Level0)
78 {
79     ASSERT_NE(dashMpdNode_, nullptr);
80     std::string attrName = "id";
81     uint64_t ullAttrVal;
82     dashMpdNode_->mpdAttr_[NUM_0].val_ = "1";
83     dashMpdNode_->GetAttr(attrName, ullAttrVal);
84     EXPECT_EQ(ullAttrVal, NUM_1);
85 }
86 
87 /**
88  * @tc.name  : Test GetAttr(string, double)
89  * @tc.number: GetAttr_004
90  * @tc.desc  : Test mpdAttr_[index].val_.length() > 0
91  */
92 HWTEST_F(DashMpdNodeUnitTest, GetAttr_004, TestSize.Level0)
93 {
94     ASSERT_NE(dashMpdNode_, nullptr);
95     std::string attrName = "id";
96     double dAttrVal;
97     dashMpdNode_->mpdAttr_[NUM_0].val_ = "1";
98     dashMpdNode_->GetAttr(attrName, dAttrVal);
99     EXPECT_EQ(dAttrVal, NUM_1);
100 }
101 
102 } // namespace HttpPluginLite
103 } // namespace Plugin
104 } // namespace Media
105 } // namespace OHOS