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 "avqueue_info.h"
19 #include "avsession_log.h"
20
21 using namespace testing::ext;
22
23 namespace OHOS {
24 namespace AVSession {
25 class AVQueueInfoTest : public testing::Test {
26 public:
27 static void SetUpTestCase();
28 static void TearDownTestCase();
29 void SetUp() override;
30 void TearDown() override;
31 };
32
SetUpTestCase()33 void AVQueueInfoTest::SetUpTestCase()
34 {}
35
TearDownTestCase()36 void AVQueueInfoTest::TearDownTestCase()
37 {}
38
SetUp()39 void AVQueueInfoTest::SetUp()
40 {}
41
TearDown()42 void AVQueueInfoTest::TearDown()
43 {}
44
45 /**
46 * @tc.name: Marshalling001
47 * @tc.desc: test Marshalling
48 * @tc.type: FUNC
49 * @tc.require:
50 */
51 HWTEST_F(AVQueueInfoTest, Marshalling001, TestSize.Level0)
52 {
53 AVQueueInfo avqueueInfo;
54 avqueueInfo.SetAVQueueName("xiaoqiang");
55 EXPECT_EQ(avqueueInfo.GetAVQueueName(), "xiaoqiang");
56 avqueueInfo.SetAVQueueId("aaa");
57 EXPECT_EQ(avqueueInfo.GetAVQueueId(), "aaa");
58 avqueueInfo.SetAVQueueImageUri("bbb");
59 EXPECT_EQ(avqueueInfo.GetAVQueueImageUri(), "bbb");
60 Parcel parcel;
61 bool result = avqueueInfo.Marshalling(parcel);
62 EXPECT_EQ(result, true);
63 }
64
65 /**
66 * @tc.name: Unmarshalling001
67 * @tc.desc: test Unmarshalling
68 * @tc.type: FUNC
69 * @tc.require:
70 */
71 HWTEST_F(AVQueueInfoTest, Unmarshalling001, TestSize.Level0)
72 {
73 AVQueueInfo avqueueInfo;
74 avqueueInfo.SetAVQueueName("xiaoqiang");
75 EXPECT_EQ(avqueueInfo.GetAVQueueName(), "xiaoqiang");
76 avqueueInfo.SetAVQueueId("aaa");
77 EXPECT_EQ(avqueueInfo.GetAVQueueId(), "aaa");
78 avqueueInfo.SetAVQueueImageUri("bbb");
79 EXPECT_EQ(avqueueInfo.GetAVQueueImageUri(), "bbb");
80 Parcel parcel;
81 avqueueInfo.Marshalling(parcel);
82 bool result = avqueueInfo.Unmarshalling(parcel);
83 EXPECT_EQ(result, false);
84 }
85
86 /**
87 * @tc.name: Unmarshalling002
88 * @tc.desc: test Unmarshalling
89 * @tc.type: FUNC
90 * @tc.require:
91 */
92 HWTEST_F(AVQueueInfoTest, Unmarshalling002, TestSize.Level0)
93 {
94 AVQueueInfo avqueueInfo;
95 avqueueInfo.SetBundleName("xiaoming");
96 EXPECT_EQ(avqueueInfo.GetBundleName(), "xiaoming");
97 avqueueInfo.SetAVQueueId("aaa");
98 EXPECT_EQ(avqueueInfo.GetAVQueueId(), "aaa");
99 avqueueInfo.SetAVQueueImageUri("bbb");
100 EXPECT_EQ(avqueueInfo.GetAVQueueImageUri(), "bbb");
101 Parcel parcel;
102 avqueueInfo.Marshalling(parcel);
103 bool result = avqueueInfo.Unmarshalling(parcel);
104 EXPECT_EQ(result, false);
105 }
106
107 /**
108 * @tc.name: Unmarshalling003
109 * @tc.desc: test Unmarshalling
110 * @tc.type: FUNC
111 * @tc.require:
112 */
113 HWTEST_F(AVQueueInfoTest, Unmarshalling003, TestSize.Level0)
114 {
115 AVQueueInfo avqueueInfo;
116 avqueueInfo.SetBundleName("xiaoming");
117 EXPECT_EQ(avqueueInfo.GetBundleName(), "xiaoming");
118 avqueueInfo.SetAVQueueName("xiaoqiang");
119 EXPECT_EQ(avqueueInfo.GetAVQueueName(), "xiaoqiang");
120 avqueueInfo.SetAVQueueImageUri("bbb");
121 EXPECT_EQ(avqueueInfo.GetAVQueueImageUri(), "bbb");
122 Parcel parcel;
123 avqueueInfo.Marshalling(parcel);
124 bool result = avqueueInfo.Unmarshalling(parcel);
125 EXPECT_EQ(result, false);
126 }
127
128 /**
129 * @tc.name: Unmarshalling004
130 * @tc.desc: test Unmarshalling
131 * @tc.type: FUNC
132 * @tc.require:
133 */
134 HWTEST_F(AVQueueInfoTest, Unmarshalling004, TestSize.Level0)
135 {
136 AVQueueInfo avqueueInfo;
137 avqueueInfo.SetBundleName("xiaoming");
138 EXPECT_EQ(avqueueInfo.GetBundleName(), "xiaoming");
139 avqueueInfo.SetAVQueueName("xiaoqiang");
140 EXPECT_EQ(avqueueInfo.GetAVQueueName(), "xiaoqiang");
141 avqueueInfo.SetAVQueueId("aaa");
142 EXPECT_EQ(avqueueInfo.GetAVQueueId(), "aaa");
143 Parcel parcel;
144 bool result = avqueueInfo.Unmarshalling(parcel);
145 EXPECT_EQ(result, false);
146 }
147
148 /**
149 * @tc.name: Unmarshalling005
150 * @tc.desc: test Unmarshalling
151 * @tc.type: FUNC
152 * @tc.require:
153 */
154 HWTEST_F(AVQueueInfoTest, Unmarshalling005, TestSize.Level0)
155 {
156 AVQueueInfo avqueueInfo;
157 avqueueInfo.SetBundleName("xiaoming");
158 EXPECT_EQ(avqueueInfo.GetBundleName(), "xiaoming");
159 avqueueInfo.SetAVQueueName("xiaoqiang");
160 EXPECT_EQ(avqueueInfo.GetAVQueueName(), "xiaoqiang");
161 avqueueInfo.SetAVQueueId("aaa");
162 EXPECT_EQ(avqueueInfo.GetAVQueueId(), "aaa");
163 avqueueInfo.SetAVQueueImageUri("bbb");
164 EXPECT_EQ(avqueueInfo.GetAVQueueImageUri(), "bbb");
165 Parcel parcel;
166 avqueueInfo.Marshalling(parcel);
167 std::shared_ptr<AVSessionPixelMap> avQueueImage = std::make_shared<AVSessionPixelMap>();
168 avqueueInfo.SetAVQueueImage(avQueueImage);
169 bool result = avqueueInfo.Unmarshalling(parcel);
170 EXPECT_EQ(result, false);
171 }
172
173 } // namespace AVSession
174 } // namespace OHOS