• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
18 #include "avsession_log.h"
19 #include "media_info_holder.h"
20 
21 using namespace testing::ext;
22 
23 namespace OHOS {
24 namespace AVSession {
25 
26 static constexpr int32_t TEST_NUM = 2000;
27 class MediaInfoHolderTest : public testing::Test {
28 public:
29     static void SetUpTestCase();
30     static void TearDownTestCase();
31     void SetUp() override;
32     void TearDown() override;
33 };
34 
SetUpTestCase()35 void MediaInfoHolderTest::SetUpTestCase()
36 {}
37 
TearDownTestCase()38 void MediaInfoHolderTest::TearDownTestCase()
39 {}
40 
SetUp()41 void MediaInfoHolderTest::SetUp()
42 {}
43 
TearDown()44 void MediaInfoHolderTest::TearDown()
45 {}
46 
47 /**
48 * @tc.name: SetAVCallState001
49 * @tc.desc: test SetAVCallState
50 * @tc.type: FUNC
51 * @tc.require:
52 */
53 HWTEST_F(MediaInfoHolderTest, SetAVCallState001, TestSize.Level0)
54 {
55     MediaInfoHolder mediaInfoHolder;
56     Parcel parcel;
57     parcel.SetDataSize(0);
58     parcel.GetDataCapacity();
59     mediaInfoHolder.SetCurrentIndex(1);
60     AVQueueItem avQueueItem;
61     std::vector<AVQueueItem> playInfos = {avQueueItem};
62     mediaInfoHolder.SetPlayInfos(playInfos);
63     ASSERT_TRUE(mediaInfoHolder.Marshalling(parcel));
64     MediaInfoHolder *result = mediaInfoHolder.Unmarshalling(parcel);
65     EXPECT_NE(result, nullptr);
66 }
67 
68 /**
69 * @tc.name: SetAVCallState002
70 * @tc.desc: test SetAVCallState
71 * @tc.type: FUNC
72 * @tc.require:
73 */
74 HWTEST_F(MediaInfoHolderTest, SetAVCallState002, TestSize.Level0)
75 {
76     MediaInfoHolder mediaInfoHolder;
77     Parcel parcel;
78     mediaInfoHolder.SetCurrentIndex(1);
79     std::vector<AVQueueItem> playInfos;
80 
81     for (int32_t i = 0; i < TEST_NUM; ++i) {
82         AVQueueItem avQueueItem;
83         playInfos.push_back(avQueueItem);
84     }
85     mediaInfoHolder.SetPlayInfos(playInfos);
86     EXPECT_TRUE(mediaInfoHolder.Marshalling(parcel));
87     MediaInfoHolder *result = mediaInfoHolder.Unmarshalling(parcel);
88     EXPECT_EQ(result, nullptr);
89 }
90 
91 } // namespace AVSession
92 } // namespace OHOS