• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <gtest/gtest.h>
17 #include <parameter.h>
18 #include <parameters.h>
19 
20 #include "screen_session_manager/include/screen_edid_parse.h"
21 
22 using namespace testing;
23 using namespace testing::ext;
24 
25 namespace OHOS {
26 namespace Rosen {
27 namespace {
28 constexpr uint32_t SLEEP_TIME_IN_US = 100000; // 100ms
29 }
30 class ScreenEdidTest : public testing::Test {
31 public:
32     static void SetUpTestCase();
33     static void TearDownTestCase();
34     void SetUp() override;
35     void TearDown() override;
36 };
37 
38 
SetUpTestCase()39 void ScreenEdidTest::SetUpTestCase()
40 {
41 }
42 
TearDownTestCase()43 void ScreenEdidTest::TearDownTestCase()
44 {
45 }
46 
SetUp()47 void ScreenEdidTest::SetUp()
48 {
49 }
50 
TearDown()51 void ScreenEdidTest::TearDown()
52 {
53     usleep(SLEEP_TIME_IN_US);
54 }
55 
56 namespace {
57 /**
58  * @tc.name: LoadEdidPlugin01
59  * @tc.desc: LoadEdidPlugin01 test
60  * @tc.type: FUNC
61  */
62 HWTEST_F(ScreenEdidTest, LoadEdidPlugin01, Function | SmallTest | Level3)
63 {
64     bool result = LoadEdidPlugin();
65     ASSERT_TRUE(result);
66     // second enter another branch
67     result = LoadEdidPlugin();
68     ASSERT_TRUE(result);
69     UnloadEdidPlugin();
70 }
71 
72 /**
73  * @tc.name: GetEdid01
74  * @tc.desc: GetEdid01 test
75  * @tc.type: FUNC
76  */
77 HWTEST_F(ScreenEdidTest, GetEdid01, Function | SmallTest | Level3)
78 {
79     ScreenId screenId = 1;
80     BaseEdid edid;
81     ASSERT_FALSE(GetEdid(screenId, edid));
82 }
83 
84 /**
85  * @tc.name: GetEdidCheckCode01
86  * @tc.desc: GetEdidCheckCode01 test
87  * @tc.type: FUNC
88  */
89 HWTEST_F(ScreenEdidTest, GetEdidCheckCode01, Function | SmallTest | Level3)
90 {
91     std::vector<uint8_t> edidData = {1, 2, 3, 4, 5};
92     int32_t result = GetEdidCheckCode(edidData);
93     int32_t invalid_code = -1;
94     ASSERT_EQ(result, invalid_code);
95 }
96 
97 /**
98  * @tc.name: GetEdidCheckCode02
99  * @tc.desc: GetEdidCheckCode02 test
100  * @tc.type: FUNC
101  */
102  HWTEST_F(ScreenEdidTest, GetEdidCheckCode02, Function | SmallTest | Level3)
103  {
104     std::vector<uint8_t> edidData(20, 0);
105     for (uint32_t i = 0; i < edidData.size(); i++) {
106         edidData[i] = i + 1;
107     }
108     int32_t result = GetEdidCheckCode(edidData);
109     int32_t expected = 135;
110     ASSERT_EQ(result, expected);
111 }
112 }
113 }
114 }