1 /*
2 * Copyright (c) 2021 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 <cstdint>
17 #include <cstdio>
18 #include <cstdlib>
19 #include <string>
20 #include <unistd.h>
21 #include <fcntl.h>
22 #include <gtest/gtest.h>
23 #include "hdf_log.h"
24 #include "display_test.h"
25
26 using namespace testing::ext;
27
28 class HdiDisplayTest : public testing::Test {
29 public:
30 static void SetUpTestCase();
31 static void TearDownTestCase();
32 };
33
SetUpTestCase()34 void HdiDisplayTest::SetUpTestCase()
35 {
36 int32_t ret;
37 ret = DisplayInit();
38 if (ret != DISPLAY_SUCCESS) {
39 HDF_LOGE("%s: DisplayInit fail", __func__);
40 ASSERT_TRUE(0);
41 }
42 // sleep 1s to wait hdmi open
43 sleep(1);
44 }
45
TearDownTestCase()46 void HdiDisplayTest::TearDownTestCase()
47 {
48 int32_t ret;
49
50 ret = DisplayUninit();
51 if (ret != DISPLAY_SUCCESS) {
52 HDF_LOGE("%s: DisplayUninit fail", __func__);
53 ASSERT_TRUE(0);
54 }
55 }
56
57 /**
58 * @tc.name: InitDisplayTest001
59 * @tc.desc: open layer test
60 * @tc.type: FUNC
61 * @tc.require: AR000F868K
62 */
63 HWTEST_F(HdiDisplayTest, SUB_Driver_Display_Small_0100, TestSize.Level1)
64 {
65 int32_t ret;
66
67 ret = InitDisplayTest();
68 if (ret != DISPLAY_SUCCESS) {
69 HDF_LOGE("%s: InitDisplayTest fail", __func__);
70 ASSERT_TRUE(0);
71 }
72 EXPECT_EQ(0, ret);
73 }
74
75 /**
76 * @tc.name: GetDisplayInfoTest001
77 * @tc.desc: get display info test
78 * @tc.type: FUNC
79 * @tc.require: AR000F868O
80 */
81
82 HWTEST_F(HdiDisplayTest, SUB_Driver_Display_Small_0200, TestSize.Level1)
83 {
84 int32_t ret;
85
86 ret = GetDisplayInfoTest();
87 if (ret != DISPLAY_SUCCESS) {
88 HDF_LOGE("%s: GetDisplayInfoTest fail", __func__);
89 ASSERT_TRUE(0);
90 }
91 EXPECT_EQ(0, ret);
92 }
93
94 /**
95 * @tc.name: CreateLayer001
96 * @tc.desc: open layer test
97 * @tc.type: FUNC
98 * @tc.require: AR000F868K, AR000F868O
99 */
100 HWTEST_F(HdiDisplayTest, SUB_Driver_Display_Small_0300, TestSize.Level1)
101 {
102 int32_t ret;
103
104 ret = CreateLayerTest();
105 if (ret != DISPLAY_SUCCESS) {
106 HDF_LOGE("%s: CreateLayerTest fail", __func__);
107 ASSERT_TRUE(0);
108 }
109 EXPECT_EQ(0, ret);
110 }
111
112 /**
113 * @tc.name: SetLayerVisibleTest001
114 * @tc.desc: set layer visible test
115 * @tc.type: FUNC
116 * @tc.require: AR000F868L
117 */
118 HWTEST_F(HdiDisplayTest, SUB_Driver_Display_Small_0400, TestSize.Level1)
119 {
120 int32_t ret;
121
122 ret = SetLayerVisibleTest();
123 if (ret != DISPLAY_SUCCESS) {
124 HDF_LOGE("%s: SetLayerVisibleTest fail", __func__);
125 ASSERT_TRUE(0);
126 }
127 EXPECT_EQ(0, ret);
128 }
129
130 /**
131 * @tc.name: SetLayerDirtyRegionTest001
132 * @tc.desc: set layer dirty region test
133 * @tc.type: FUNC
134 * @tc.require: AR000F868L
135 */
136 HWTEST_F(HdiDisplayTest, SUB_Driver_Display_Small_0500, TestSize.Level1)
137 {
138 int32_t ret;
139
140 ret = SetLayerDirtyRegionTest();
141 if (ret != DISPLAY_SUCCESS) {
142 HDF_LOGE("%s: SetLayerDirtyRegionTest fail", __func__);
143 ASSERT_TRUE(0);
144 }
145 EXPECT_EQ(0, ret);
146 }
147
148 /**
149 * @tc.name: GetLayerBufferTest001
150 * @tc.desc: get layer buffer to draw test.
151 * @tc.type: FUNC
152 * @tc.require: AR000F868N
153 */
154 HWTEST_F(HdiDisplayTest, SUB_Driver_Display_Small_0600, TestSize.Level1)
155 {
156 int32_t ret;
157
158 ret = GetLayerBufferTest();
159 if (ret != DISPLAY_SUCCESS) {
160 HDF_LOGE("%s: GetLayerBufferTest fail", __func__);
161 ASSERT_TRUE(0);
162 }
163 EXPECT_EQ(0, ret);
164 }
165
166 /**
167 * @tc.name: FlushCrossLineTest001
168 * @tc.desc: flush cross line test
169 * @tc.type: FUNC
170 * @tc.require: AR000F868M
171 */
172 HWTEST_F(HdiDisplayTest, SUB_Driver_Display_Small_0700, TestSize.Level1)
173 {
174 int32_t ret;
175
176 ret = FlushTest();
177 if (ret != DISPLAY_SUCCESS) {
178 HDF_LOGE("%s: FlushCrossLineTest fail", __func__);
179 ASSERT_TRUE(0);
180 }
181 // sleep 2 to see the frame
182 sleep(IMG_KEEP_TIME);
183 EXPECT_EQ(0, ret);
184 }
185
186 /**
187 * @tc.name: InitGfxTest001
188 * @tc.desc: init gfx test
189 * @tc.type: FUNC
190 * @tc.require: AR000F868N
191 */
192 HWTEST_F(HdiDisplayTest, SUB_Driver_Display_Small_0800, TestSize.Level1)
193 {
194 int32_t ret;
195 ret = InitGfxTest();
196 if (ret != DISPLAY_SUCCESS) {
197 HDF_LOGE("%s: InitGfxTest fail", __func__);
198 ASSERT_TRUE(0);
199 }
200 EXPECT_EQ(0, ret);
201 }
202
203 /**
204 * @tc.name: BlitTest001
205 * @tc.desc: Gfx blit test
206 * @tc.type: FUNC
207 * @tc.require: AR000F868M
208 */
209 HWTEST_F(HdiDisplayTest, SUB_Driver_Display_Small_0900, TestSize.Level1)
210 {
211 int32_t ret;
212 ret = BlitTest();
213 if (ret != DISPLAY_SUCCESS) {
214 HDF_LOGE("%s: BlitTest fail", __func__);
215 ASSERT_TRUE(0);
216 }
217 EXPECT_EQ(0, ret);
218 }
219
220 /**
221 * @tc.name: FlushPictureTest001
222 * @tc.desc: flush bpm picture test
223 * @tc.type: FUNC
224 * @tc.require: AR000F868M
225 */
226 HWTEST_F(HdiDisplayTest, SUB_Driver_Display_Small_1000, TestSize.Level1)
227 {
228 int32_t ret;
229
230 ret = FlushTest();
231 if (ret != DISPLAY_SUCCESS) {
232 HDF_LOGE("%s: FlushPictureTest failed", __func__);
233 ASSERT_TRUE(0);
234 }
235 // sleep 2 to see the frame
236 sleep(IMG_KEEP_TIME);
237 EXPECT_EQ(0, ret);
238 }
239
240 /**
241 * @tc.name: FillRectTest001
242 * @tc.desc: fill rect test
243 * @tc.type: FUNC
244 * @tc.require: AR000F868L
245 */
246 HWTEST_F(HdiDisplayTest, SUB_Driver_Display_Small_1100, TestSize.Level1)
247 {
248 int32_t ret;
249
250 ret = FillRectTest();
251 if (ret != DISPLAY_SUCCESS) {
252 HDF_LOGE("%s: FillRectTest failed", __func__);
253 ASSERT_TRUE(0);
254 }
255 EXPECT_EQ(0, ret);
256 }
257
258 /**
259 * @tc.name: FlushRectTest001
260 * @tc.desc: flush rect picture test
261 * @tc.type: FUNC
262 * @tc.require: AR000F868N
263 */
264 HWTEST_F(HdiDisplayTest, SUB_Driver_Display_Small_1200, TestSize.Level1)
265 {
266 int32_t ret;
267
268 ret = FlushTest();
269 if (ret != DISPLAY_SUCCESS) {
270 HDF_LOGE("%s: FlushRectTest failed", __func__);
271 ASSERT_TRUE(0);
272 }
273 // sleep 2 to see the frame
274 sleep(IMG_KEEP_TIME);
275 EXPECT_EQ(0, ret);
276 }
277
278 /**
279 * @tc.name: DeinitGfxTest001
280 * @tc.desc: deinit gfx test
281 * @tc.type: FUNC
282 * @tc.require: AR000F868K
283 */
284 HWTEST_F(HdiDisplayTest, SUB_Driver_Display_Small_1300, TestSize.Level1)
285 {
286 int32_t ret;
287
288 ret = DeinitGfxTest();
289 if (ret != DISPLAY_SUCCESS) {
290 HDF_LOGE("%s: DeinitGfxTest failed", __func__);
291 ASSERT_TRUE(0);
292 }
293 EXPECT_EQ(0, ret);
294 }
295
296 /**
297 * @tc.name: CloseLayerTest001
298 * @tc.desc: close layer test
299 * @tc.type: FUNC
300 * @tc.require: AR000F868K
301 */
302 HWTEST_F(HdiDisplayTest, SUB_Driver_Display_Small_1400, TestSize.Level1)
303 {
304 int32_t ret;
305
306 ret = CloseLayerTest();
307 if (ret != DISPLAY_SUCCESS) {
308 HDF_LOGE("%s: CloseLayerTest failed", __func__);
309 ASSERT_TRUE(0);
310 }
311 EXPECT_EQ(0, ret);
312 }
313
314 /**
315 * @tc.name: DeinitDisplayTest001
316 * @tc.desc: deinit display test
317 * @tc.type: FUNC
318 * @tc.require: SR000F868J, AR000F868O
319 */
320 HWTEST_F(HdiDisplayTest, SUB_Driver_Display_Small_1500, TestSize.Level1)
321 {
322 int32_t ret;
323
324 ret = DeinitDisplayTest();
325 if (ret != DISPLAY_SUCCESS) {
326 HDF_LOGE("%s: DeinitDisplayTest failed", __func__);
327 ASSERT_TRUE(0);
328 }
329 EXPECT_EQ(0, ret);
330 }
331
332 /**
333 * @tc.name: AllocMemTest001
334 * @tc.desc: alloc memory test
335 * @tc.type: FUNC
336 * @tc.require: SR000F868J, AR000F868L
337 */
338 HWTEST_F(HdiDisplayTest, SUB_Driver_Display_Small_1600, TestSize.Level1)
339 {
340 int32_t ret;
341 ret = AllocMemTest1();
342 if (ret != DISPLAY_SUCCESS) {
343 HDF_LOGE("%s: AllocMemTest1 failed", __func__);
344 ASSERT_TRUE(0);
345 }
346 EXPECT_EQ(0, ret);
347 }
348
349 /**
350 * @tc.name: MmapCacheTest001
351 * @tc.desc: map cache memory test
352 * @tc.type: FUNC
353 * @tc.require: SR000F868J, AR000F868L
354 */
355 HWTEST_F(HdiDisplayTest, SUB_Driver_Display_Small_1700, TestSize.Level1)
356 {
357 int32_t ret;
358
359 ret = MmapCacheTest();
360 if (ret != DISPLAY_SUCCESS) {
361 HDF_LOGE("%s: MmapCacheTest01 failed", __func__);
362 ASSERT_TRUE(0);
363 }
364 EXPECT_EQ(0, ret);
365 }
366
367 /**
368 * @tc.name: FlushMCacheTest001
369 * @tc.desc: flush cache to memory test
370 * @tc.type: FUNC
371 * @tc.require: SR000F868J, AR000F868N
372 */
373 HWTEST_F(HdiDisplayTest, SUB_Driver_Display_Small_1800, TestSize.Level1)
374 {
375 int32_t ret;
376
377 ret = FlushMCacheTest();
378 if (ret != DISPLAY_SUCCESS) {
379 HDF_LOGE("%s: FlushMCacheTest01 failed", __func__);
380 ASSERT_TRUE(0);
381 }
382 EXPECT_EQ(0, ret);
383 }
384
385 /**
386 * @tc.name: FreeMemTest001
387 * @tc.desc: free memory test
388 * @tc.type: FUNC
389 * @tc.require: SR000F868J, AR000F868N
390 */
391 HWTEST_F(HdiDisplayTest, SUB_Driver_Display_Small_1900, TestSize.Level1)
392 {
393 int32_t ret;
394
395 ret = FreeMemTest();
396 if (ret != DISPLAY_SUCCESS) {
397 HDF_LOGE("%s: FreeMemTest01 failed", __func__);
398 ASSERT_TRUE(0);
399 }
400 EXPECT_EQ(0, ret);
401 }
402
403 /**
404 * @tc.name: AllocMemTest002
405 * @tc.desc: alloc memory test
406 * @tc.type: FUNC
407 * @tc.require: SR000F868J, AR000F868N
408 */
409 HWTEST_F(HdiDisplayTest, SUB_Driver_Display_Small_2000, TestSize.Level1)
410 {
411 int32_t ret;
412
413 ret = AllocMemTest2();
414 if (ret != DISPLAY_SUCCESS) {
415 HDF_LOGE("%s: AllocMemTest2 failed", __func__);
416 ASSERT_TRUE(0);
417 }
418 EXPECT_EQ(0, ret);
419 }
420
421 /**
422 * @tc.name: MmapCacheTest002
423 * @tc.desc: map cache memory test
424 * @tc.type: FUNC
425 * @tc.require: SR000F868J, AR000F868L
426 */
427 HWTEST_F(HdiDisplayTest, SUB_Driver_Display_Small_2100, TestSize.Level1)
428 {
429 int32_t ret;
430
431 ret = MmapCacheTest();
432 if (ret != DISPLAY_SUCCESS) {
433 HDF_LOGE("%s: MmapCacheTest02 failed", __func__);
434 ASSERT_TRUE(0);
435 }
436 EXPECT_EQ(0, ret);
437 }
438
439 /**
440 * @tc.name: FlushMCacheTest002
441 * @tc.desc: flush cache to memory test
442 * @tc.type: FUNC
443 * @tc.require: SR000F868J, AR000F868N
444 */
445 HWTEST_F(HdiDisplayTest, SUB_Driver_Display_Small_2200, TestSize.Level1)
446 {
447 int32_t ret;
448
449 ret = FlushMCacheTest();
450 if (ret != DISPLAY_SUCCESS) {
451 HDF_LOGE("%s: FlushMCacheTest02 failed", __func__);
452 ASSERT_TRUE(0);
453 }
454 EXPECT_EQ(0, ret);
455 }
456
457 /**
458 * @tc.name: FreeMemTest002
459 * @tc.desc: free memory test
460 * @tc.type: FUNC
461 * @tc.require: SR000F868J, AR000F868N
462 */
463 HWTEST_F(HdiDisplayTest, SUB_Driver_Display_Small_2300, TestSize.Level1)
464 {
465 int32_t ret;
466
467 ret = FreeMemTest();
468 if (ret != DISPLAY_SUCCESS) {
469 HDF_LOGE("%s: FreeMemTest02 failed", __func__);
470 ASSERT_TRUE(0);
471 }
472 EXPECT_EQ(0, ret);
473 }
474