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 "sidx_box_parser.h" 17 #include "gtest/gtest.h" 18 19 using namespace std; 20 using namespace testing::ext; 21 22 namespace OHOS { 23 namespace Media { 24 namespace Plugins { 25 namespace HttpPlugin { 26 const static int32_t VOLUME_TEST = 24; 27 const static int32_t INVALID_TEST = -1; 28 const static int32_t NUM_TEST = 0; 29 class SidxBoxParserUnitTest : public testing::Test { 30 public: SetUpTestCase(void)31 static void SetUpTestCase(void) {} TearDownTestCase(void)32 static void TearDownTestCase(void) {} SetUp(void)33 void SetUp(void) {} TearDown(void)34 void TearDown(void) {} 35 }; 36 37 /** 38 * @tc.name : Test BuildSubSegmentIndexes API 39 * @tc.number: BuildSubSegmentIndexes_001 40 * @tc.desc : Test version != 0 && (referenceCount * SIDX_REFERENCE_ITEM_SIZE + currPos) > streamSize 41 */ 42 HWTEST_F(SidxBoxParserUnitTest, BuildSubSegmentIndexes_001, TestSize.Level1) 43 { 44 char mockStr[24] {-1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}; 45 DashList<std::shared_ptr<SubSegmentIndex>> mockList; 46 uint32_t currPos {0}; 47 ASSERT_EQ(false, SidxBoxParser::BuildSubSegmentIndexes(mockStr, NUM_TEST, NUM_TEST, mockList, currPos)); 48 } 49 50 /** 51 * @tc.name : Test ParseSidxBox API 52 * @tc.number: ParseSidxBox_001 53 * @tc.desc : Test boxType != BEM_SIDX 54 */ 55 HWTEST_F(SidxBoxParserUnitTest, ParseSidxBox_001, TestSize.Level1) 56 { 57 char mockStr[24] {-1, -1, -1, -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1}; 58 DashList<std::shared_ptr<SubSegmentIndex>> mockList; 59 ASSERT_EQ(INVALID_TEST, SidxBoxParser::ParseSidxBox(mockStr, VOLUME_TEST, NUM_TEST, mockList)); 60 } 61 } 62 } 63 } 64 }