1 /*
2  * Copyright (c) 2023 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 "display_manager_lite.h"
18 #include "mock_display_manager_adapter_lite.h"
19 #include "singleton_mocker.h"
20 
21 using namespace testing;
22 using namespace testing::ext;
23 
24 namespace OHOS {
25 namespace Rosen {
26 using Mocker = SingletonMocker<DisplayManagerAdapterLite, MockDisplayManagerAdapterLite>;
27 class DisplayTestLite : 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 DisplayTestLite::SetUpTestCase()
36 {
37 }
38 
TearDownTestCase()39 void DisplayTestLite::TearDownTestCase()
40 {
41 }
42 
SetUp()43 void DisplayTestLite::SetUp()
44 {
45 }
46 
TearDown()47 void DisplayTestLite::TearDown()
48 {
49 }
50 
51 namespace {
52 /**
53  * @tc.name: UpdateDisplayInfo01
54  * @tc.desc: UpdateDisplayInfo with nullptr
55  * @tc.type: FUNC
56  * @tc.require: issueI5K0JP
57  */
58 HWTEST_F(DisplayTestLite, UpdateDisplayInfo01, Function | SmallTest | Level1)
59 {
60     sptr<DisplayInfo> displayInfo = nullptr;
61     sptr<DisplayLite> display = new DisplayLite("", displayInfo);
62     display->UpdateDisplayInfo(displayInfo);
63     ASSERT_EQ(displayInfo, nullptr);
64 }
65 
66 /**
67  * @tc.name: UpdateDisplayInfopImpl_
68  * @tc.desc: UpdateDisplayInfo with nullptr
69  * @tc.type: FUNC
70  * @tc.require: issueI5K0JP
71  */
72 HWTEST_F(DisplayTestLite, UpdateDisplayInfopImpl_, Function | SmallTest | Level1)
73 {
74     GTEST_LOG_(INFO) << "DisplayLite::UpdateDisplayInfo start";
75     sptr<DisplayInfo> displayInfo = new DisplayInfo();
76     sptr<DisplayLite> display = new DisplayLite("", displayInfo);
77     display->UpdateDisplayInfo(displayInfo);
78     ASSERT_NE(displayInfo, nullptr);
79     GTEST_LOG_(INFO) << "DisplayLite::UpdateDisplayInfo end";
80 }
81 
82 /**
83  * @tc.name: UpdateDisplayInfo03
84  * @tc.desc: UpdateDisplayInfo with nullptr
85  * @tc.type: FUNC
86  * @tc.require: issueI5K0JP
87  */
88 HWTEST_F(DisplayTestLite, UpdateDisplayInfo03, Function | SmallTest | Level1)
89 {
90     GTEST_LOG_(INFO) << "DisplayLite::UpdateDisplayInfo start";
91     sptr<DisplayInfo> displayInfo = nullptr;
92     sptr<DisplayLite> display = new DisplayLite("", displayInfo);
93     display->UpdateDisplayInfo();
94     ASSERT_EQ(displayInfo, nullptr);
95     GTEST_LOG_(INFO) << "DisplayLite::UpdateDisplayInfo end";
96 }
97 
98 /**
99  * @tc.name: GetId01
100  * @tc.desc: UpdateDisplayInfo with nullptr
101  * @tc.type: FUNC
102  * @tc.require: issueI5K0JP
103  */
104 HWTEST_F(DisplayTestLite, GetId01, Function | SmallTest | Level1)
105 {
106     GTEST_LOG_(INFO) << "DisplayLite::GetId start";
107     sptr<DisplayInfo> displayInfo = nullptr;
108     sptr<DisplayLite> display = new DisplayLite("", displayInfo);
109     uint64_t id;
110     id = display->GetId();
111     ASSERT_EQ(id, 0);
112     GTEST_LOG_(INFO) << "DisplayLite::GetId end";
113 }
114 
115 /**
116  * @tc.name: GetId02
117  * @tc.desc: UpdateDisplayInfo with nullptr
118  * @tc.type: FUNC
119  * @tc.require: issueI5K0JP
120  */
121 HWTEST_F(DisplayTestLite, GetId02, Function | SmallTest | Level1)
122 {
123     GTEST_LOG_(INFO) << "DisplayLite::GetId start";
124     sptr<DisplayInfo> displayInfo = new DisplayInfo();
125     sptr<DisplayLite> display = new DisplayLite("", displayInfo);
126     uint64_t id;
127     id = display->GetId();
128     ASSERT_NE(id, 0);
129     GTEST_LOG_(INFO) << "DisplayLite::GetId end";
130 }
131 
132 /**
133  * @tc.name: GetDisplayInfo01
134  * @tc.desc: UpdateDisplayInfo with nullptr
135  * @tc.type: FUNC
136  * @tc.require: issueI5K0JP
137  */
138 HWTEST_F(DisplayTestLite, GetDisplayInfo01, Function | SmallTest | Level1)
139 {
140     GTEST_LOG_(INFO) << "DisplayLite::GetId start";
141     sptr<DisplayInfo> displayInfo = nullptr;
142     sptr<DisplayLite> display = new DisplayLite("", displayInfo);;
143     displayInfo = display->GetDisplayInfo();
144     ASSERT_NE(displayInfo, nullptr);
145     GTEST_LOG_(INFO) << "DisplayLite::GetId end";
146 }
147 
148 /**
149  * @tc.name: GetDisplayInfo02
150  * @tc.desc: UpdateDisplayInfo with nullptr
151  * @tc.type: FUNC
152  * @tc.require: issueI5K0JP
153  */
154 HWTEST_F(DisplayTestLite, GetDisplayInfo02, Function | SmallTest | Level1)
155 {
156     GTEST_LOG_(INFO) << "DisplayLite::GetId start";
157     sptr<DisplayInfo> displayInfo = new DisplayInfo();
158     sptr<DisplayLite> display = new DisplayLite("", displayInfo);;
159     displayInfo = display->GetDisplayInfo();
160     ASSERT_NE(displayInfo, nullptr);
161     GTEST_LOG_(INFO) << "DisplayLite::GetId end";
162 }
163 
164 /**
165  * @tc.name: GetWidth01
166  * @tc.desc: UpdateDisplayInfo with nullptr
167  * @tc.type: FUNC
168  * @tc.require: issueI5K0JP
169  */
170 HWTEST_F(DisplayTestLite, GetWidth01, Function | SmallTest | Level1)
171 {
172     GTEST_LOG_(INFO) << "DisplayLite::GetWidth start";
173     sptr<DisplayInfo> displayInfo = nullptr;
174     sptr<DisplayLite> display = new DisplayLite("", displayInfo);
175     int32_t width;
176     width = display->GetWidth();
177     ASSERT_NE(width, 0);
178     GTEST_LOG_(INFO) << "DisplayLite::GetWidth end";
179 }
180 
181 /**
182  * @tc.name: GetWidth02
183  * @tc.desc: UpdateDisplayInfo with nullptr
184  * @tc.type: FUNC
185  * @tc.require: issueI5K0JP
186  */
187 HWTEST_F(DisplayTestLite, GetWidth02, Function | SmallTest | Level1)
188 {
189     GTEST_LOG_(INFO) << "DisplayLite::GetWidth start";
190     sptr<DisplayInfo> displayInfo = new DisplayInfo();
191     sptr<DisplayLite> display = new DisplayLite("", displayInfo);
192     int32_t width;
193     width = display->GetWidth();
194     ASSERT_EQ(width, 0);
195     GTEST_LOG_(INFO) << "DisplayLite::GetWidth end";
196 }
197 
198 /**
199  * @tc.name: GetHeight01
200  * @tc.desc: UpdateDisplayInfo with nullptr
201  * @tc.type: FUNC
202  * @tc.require: issueI5K0JP
203  */
204 HWTEST_F(DisplayTestLite, GetHeight01, Function | SmallTest | Level1)
205 {
206     GTEST_LOG_(INFO) << "DisplayLite::GetWidth start";
207     sptr<DisplayInfo> displayInfo = nullptr;
208     sptr<DisplayLite> display = new DisplayLite("", displayInfo);
209     int32_t Height;
210     Height = display->GetWidth();
211     ASSERT_NE(Height, 0);
212     GTEST_LOG_(INFO) << "DisplayLite::GetWidth end";
213 }
214 
215 /**
216  * @tc.name: GetHeight02
217  * @tc.desc: UpdateDisplayInfo with nullptr
218  * @tc.type: FUNC
219  * @tc.require: issueI5K0JP
220  */
221 HWTEST_F(DisplayTestLite, GetHeight02, Function | SmallTest | Level1)
222 {
223     GTEST_LOG_(INFO) << "DisplayLite::GetWidth start";
224     sptr<DisplayInfo> displayInfo = new DisplayInfo();
225     sptr<DisplayLite> display = new DisplayLite("", displayInfo);
226     int32_t Height;
227     Height = display->GetWidth();
228     ASSERT_EQ(Height, 0);
229     GTEST_LOG_(INFO) << "DisplayLite::GetWidth end";
230 }
231 
232 /**
233  * @tc.name: GetCutoutInfo
234  * @tc.desc: UpdateDisplayInfo with nullptr
235  * @tc.type: FUNC
236  * @tc.require: issueI5K0JP
237  */
238 HWTEST_F(DisplayTestLite, GetCutoutInfo, Function | SmallTest | Level1)
239 {
240     GTEST_LOG_(INFO) << "DisplayLite::GetCutoutInfo start";
241     sptr<DisplayInfo> displayInfo = new DisplayInfo();
242     sptr<DisplayLite> display = new DisplayLite("", displayInfo);
243     sptr<CutoutInfo> info = display->GetCutoutInfo();
244     ASSERT_EQ(info, nullptr);
245     GTEST_LOG_(INFO) << "DisplayLite::GetCutoutInfo end";
246 }
247 
248 /**
249  * @tc.name: GetRotation
250  * @tc.desc: UpdateDisplayInfo with nullptr
251  * @tc.type: FUNC
252  * @tc.require: issueI5K0JP
253  */
254 HWTEST_F(DisplayTestLite, GetRotation, Function | SmallTest | Level1)
255 {
256     GTEST_LOG_(INFO) << "DisplayLite::GetRotation start";
257     sptr<DisplayInfo> displayInfo = nullptr;
258     sptr<DisplayLite> display = new DisplayLite("", displayInfo);
259     Rotation res = display->GetRotation();
260     ASSERT_EQ(res, Rotation::ROTATION_0);
261     GTEST_LOG_(INFO) << "DisplayLite::GetRotation end";
262 }
263 }
264 } // namespace Rosen
265 } // namespace OHOS