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 "base64_utils.h"
17 #include "dash_segment_downloader.h"
18 #include "gtest/gtest.h"
19 #include <iostream>
20 #include "mpd_parser/dash_adpt_set_manager.h"
21 #include "mpd_parser/dash_mpd_parser.h"
22 #include "mpd_parser/dash_mpd_manager.h"
23 #include "mpd_parser/dash_period_manager.h"
24 #include "mpd_parser/dash_seg_tmline_node.h"
25 #include "mpd_parser/i_dash_mpd_node.h"
26
27 using namespace std;
28 using namespace testing::ext;
29
30 namespace OHOS {
31 namespace Media {
32 namespace Plugins {
33 namespace HttpPlugin {
34 class DashMpdNodeParserUnitTest : public testing::Test {
35 public:
SetUpTestCase(void)36 static void SetUpTestCase(void) {}
TearDownTestCase(void)37 static void TearDownTestCase(void) {}
SetUp(void)38 void SetUp(void) {}
39 void TearDown(void);
40 private:
41 IDashMpdNode* node_ {nullptr};
42 std::shared_ptr<XmlParser> parser_;
43 std::shared_ptr<XmlElement> element_;
44 };
45
TearDown()46 void DashMpdNodeParserUnitTest::TearDown()
47 {
48 IDashMpdNode::DestroyNode(node_);
49 }
50 /**
51 * @tc.name : Test CreateNode API
52 * @tc.number: CreateNode_001
53 * @tc.desc : Test nodeName == "mock"
54 */
55 HWTEST_F(DashMpdNodeParserUnitTest, CreateNode_001, TestSize.Level1)
56 {
57 node_ = IDashMpdNode::CreateNode("mock");
58 ASSERT_EQ(nullptr, node_);
59 }
60
61 /**
62 * @tc.name : Test DashSegTmlineNode API
63 * @tc.number: DashSegTmlineNode_001
64 * @tc.desc : Test GetAttr interface
65 */
66 HWTEST_F(DashMpdNodeParserUnitTest, DashSegTmlineNode_001, TestSize.Level1)
67 {
68 node_ = IDashMpdNode::CreateNode("SegmentTimeline");
69 ASSERT_NE(nullptr, node_);
70 node_->ParseNode(parser_, element_);
71 parser_ = std::make_shared<XmlParser>();
72 ASSERT_NE(nullptr, parser_);
73 node_->ParseNode(parser_, element_);
74 std::string attr;
75 node_->GetAttr("mock", attr);
76 ASSERT_EQ("", attr);
77 DashSegTmlineNode* segNode = reinterpret_cast<DashSegTmlineNode*>(node_);
78 ASSERT_NE(nullptr, segNode);
79 segNode->segTmlineAttr_[0].val_ = "mockData";
80 node_->GetAttr("t", attr);
81 ASSERT_EQ("mockData", attr);
82 }
83 }
84 }
85 }
86 }