• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 #define private public
17 #include "screen_client_test.h"
18 #undef private
19 
20 using namespace testing::ext;
21 
22 namespace OHOS {
23 namespace DistributedHardware {
SetUpTestCase(void)24 void ScreenClientTest::SetUpTestCase(void) {}
25 
TearDownTestCase(void)26 void ScreenClientTest::TearDownTestCase(void) {}
27 
SetUp()28 void ScreenClientTest::SetUp() {}
29 
TearDown()30 void ScreenClientTest::TearDown() {}
31 
32 /**
33  * @tc.name: AddWindow_001
34  * @tc.desc: Verify the AddWindow function.
35  * @tc.type: FUNC
36  * @tc.require: Issue Number
37  */
38 HWTEST_F(ScreenClientTest, AddWindow_001, TestSize.Level1)
39 {
40     std::shared_ptr<WindowProperty> windowProperty = nullptr;
41     int32_t actual = ScreenClient::GetInstance().AddWindow(windowProperty);
42     EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_ADD_WINDOW_ERROR, actual);
43 }
44 
45 /**
46  * @tc.name: AddWindow_002
47  * @tc.desc: Verify the AddWindow function.
48  * @tc.type: FUNC
49  * @tc.require: Issue Number
50  */
51 HWTEST_F(ScreenClientTest, AddWindow_002, TestSize.Level1)
52 {
53     std::shared_ptr<WindowProperty> windowProperty = std::make_shared<WindowProperty>();
54     int32_t windowId = 0;
55     int32_t actual = ScreenClient::GetInstance().AddWindow(windowProperty);
56     EXPECT_EQ(windowId, actual);
57     ScreenClient::GetInstance().RemoveWindow(actual);
58 }
59 
60 /**
61  * @tc.name: ShowWindow_001
62  * @tc.desc: Verify the ShowWindow function.
63  * @tc.type: FUNC
64  * @tc.require: Issue Number
65  */
66 HWTEST_F(ScreenClientTest, ShowWindow_001, TestSize.Level1)
67 {
68     int32_t windowId = 0;
69     int32_t actual = ScreenClient::GetInstance().ShowWindow(windowId);
70     EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_SHOW_WINDOW_ERROR, actual);
71 }
72 
73 /**
74  * @tc.name: ShowWindow_002
75  * @tc.desc: Verify the ShowWindow function.
76  * @tc.type: FUNC
77  * @tc.require: Issue Number
78  */
79 HWTEST_F(ScreenClientTest, ShowWindow_002, TestSize.Level1)
80 {
81     std::shared_ptr<WindowProperty> windowProperty = std::make_shared<WindowProperty>();
82     int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty);
83     int32_t actual = ScreenClient::GetInstance().ShowWindow(windowId);
84     EXPECT_EQ(DH_SUCCESS, actual);
85     ScreenClient::GetInstance().RemoveWindow(windowId);
86 }
87 
88 /**
89  * @tc.name: ShowWindow_003
90  * @tc.desc: Verify the ShowWindow function.
91  * @tc.type: FUNC
92  * @tc.require: Issue Number
93  */
94 HWTEST_F(ScreenClientTest, ShowWindow_003, TestSize.Level1)
95 {
96     int32_t windowId = 100;
97     sptr<Surface> surface = nullptr;
98     ScreenClient::GetInstance().surfaceMap_.emplace(windowId, surface);
99     int32_t actual = ScreenClient::GetInstance().ShowWindow(windowId);
100     EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_SHOW_WINDOW_ERROR, actual);
101     ScreenClient::GetInstance().RemoveWindow(windowId);
102 }
103 
104 /**
105  * @tc.name: HideWindow_001
106  * @tc.desc: Verify the HideWindow function.
107  * @tc.type: FUNC
108  * @tc.require: Issue Number
109  */
110 HWTEST_F(ScreenClientTest, HideWindow_001, TestSize.Level1)
111 {
112     int32_t windowId = 0;
113     int32_t actual = ScreenClient::GetInstance().HideWindow(windowId);
114     EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_HIDE_WINDOW_ERROR, actual);
115 }
116 
117 /**
118  * @tc.name: HideWindow_002
119  * @tc.desc: Verify the HideWindow function.
120  * @tc.type: FUNC
121  * @tc.require: Issue Number
122  */
123 HWTEST_F(ScreenClientTest, HideWindow_002, TestSize.Level1)
124 {
125     std::shared_ptr<WindowProperty> windowProperty = std::make_shared<WindowProperty>();
126     int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty);
127     int32_t actual = ScreenClient::GetInstance().HideWindow(windowId);
128     EXPECT_EQ(DH_SUCCESS, actual);
129     ScreenClient::GetInstance().RemoveWindow(windowId);
130 }
131 
132 /**
133  * @tc.name: HideWindow_003
134  * @tc.desc: Verify the HideWindow function.
135  * @tc.type: FUNC
136  * @tc.require: Issue Number
137  */
138 HWTEST_F(ScreenClientTest, HideWindow_003, TestSize.Level1)
139 {
140     int32_t windowId = 0;
141     sptr<Surface> surface = nullptr;
142     ScreenClient::GetInstance().surfaceMap_.emplace(windowId, surface);
143     int32_t actual = ScreenClient::GetInstance().HideWindow(windowId);
144     EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_HIDE_WINDOW_ERROR, actual);
145     ScreenClient::GetInstance().RemoveWindow(windowId);
146 }
147 
148 /**
149  * @tc.name: MoveWindow_001
150  * @tc.desc: Verify the MoveWindow function.
151  * @tc.type: FUNC
152  * @tc.require: Issue Number
153  */
154 HWTEST_F(ScreenClientTest, MoveWindow_001, TestSize.Level1)
155 {
156     int32_t windowId = 0;
157     int32_t startX = 0;
158     int32_t startY = 0;
159     int32_t actual = ScreenClient::GetInstance().MoveWindow(windowId, startX, startY);
160     EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_MOVE_WINDOW_ERROR, actual);
161 }
162 
163 /**
164  * @tc.name: MoveWindow_002
165  * @tc.desc: Verify the MoveWindow function.
166  * @tc.type: FUNC
167  * @tc.require: Issue Number
168  */
169 HWTEST_F(ScreenClientTest, MoveWindow_002, TestSize.Level1)
170 {
171     std::shared_ptr<WindowProperty> windowProperty = std::make_shared<WindowProperty>();
172     int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty);
173     int32_t startX = 0;
174     int32_t startY = 0;
175     int32_t actual = ScreenClient::GetInstance().MoveWindow(windowId, startX, startY);
176     EXPECT_EQ(DH_SUCCESS, actual);
177     ScreenClient::GetInstance().RemoveWindow(windowId);
178 }
179 
180 /**
181  * @tc.name: MoveWindow_003
182  * @tc.desc: Verify the MoveWindow function.
183  * @tc.type: FUNC
184  * @tc.require: Issue Number
185  */
186 HWTEST_F(ScreenClientTest, MoveWindow_003, TestSize.Level1)
187 {
188     int32_t windowId = 0;
189     sptr<Surface> surface = nullptr;
190     ScreenClient::GetInstance().surfaceMap_.emplace(windowId, surface);
191     int32_t startX = 0;
192     int32_t startY = 0;
193     int32_t actual = ScreenClient::GetInstance().MoveWindow(windowId, startX, startY);
194     EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_MOVE_WINDOW_ERROR, actual);
195     ScreenClient::GetInstance().RemoveWindow(windowId);
196 }
197 
198 /**
199  * @tc.name: RemoveWindow_001
200  * @tc.desc: Verify the RemoveWindow function.
201  * @tc.type: FUNC
202  * @tc.require: Issue Number
203  */
204 HWTEST_F(ScreenClientTest, RemoveWindow_001, TestSize.Level1)
205 {
206     int32_t windowId = 0;
207     int32_t actual = ScreenClient::GetInstance().RemoveWindow(windowId);
208     EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, actual);
209 }
210 
211 /**
212  * @tc.name: RemoveWindow_002
213  * @tc.desc: Verify the RemoveWindow function.
214  * @tc.type: FUNC
215  * @tc.require: Issue Number
216  */
217 HWTEST_F(ScreenClientTest, RemoveWindow_002, TestSize.Level1)
218 {
219     std::shared_ptr<WindowProperty> windowProperty = std::make_shared<WindowProperty>();
220     int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty);
221     int32_t actual = ScreenClient::GetInstance().RemoveWindow(windowId);
222     EXPECT_EQ(DH_SUCCESS, actual);
223 }
224 
225 /**
226  * @tc.name: RemoveWindow_002
227  * @tc.desc: Verify the RemoveWindow function.
228  * @tc.type: FUNC
229  * @tc.require: Issue Number
230  */
231 HWTEST_F(ScreenClientTest, RemoveWindow_003, TestSize.Level1)
232 {
233     int32_t windowId = 0;
234     sptr<Surface> surface = nullptr;
235     ScreenClient::GetInstance().surfaceMap_.emplace(windowId, surface);
236     int32_t actual = ScreenClient::GetInstance().RemoveWindow(windowId);
237     EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, actual);
238     ScreenClient::GetInstance().RemoveWindow(windowId);
239 }
240 
241 /**
242  * @tc.name: GetSurface_001
243  * @tc.desc: Verify the GetSurface function.
244  * @tc.type: FUNC
245  * @tc.require: Issue Number
246  */
247 HWTEST_F(ScreenClientTest, GetSurface_001, TestSize.Level1)
248 {
249     int32_t windowId = 0;
250     sptr<Surface> actualSurface = ScreenClient::GetInstance().GetSurface(windowId);
251     EXPECT_EQ(nullptr, actualSurface);
252 }
253 
254 /**
255  * @tc.name: GetSurface_002
256  * @tc.desc: Verify the GetSurface function.
257  * @tc.type: FUNC
258  * @tc.require: Issue Number
259  */
260 HWTEST_F(ScreenClientTest, GetSurface_002, TestSize.Level1)
261 {
262     std::shared_ptr<WindowProperty> windowProperty = std::make_shared<WindowProperty>();
263     int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty);
264     sptr<Surface> actualSurface = ScreenClient::GetInstance().GetSurface(windowId);
265     EXPECT_NE(nullptr, actualSurface);
266     ScreenClient::GetInstance().RemoveWindow(windowId);
267 }
268 
269 /**
270  * @tc.name: DestroyAllWindow_001
271  * @tc.desc: Verify the DestroyAllWindow function.
272  * @tc.type: FUNC
273  * @tc.require: Issue Number
274  */
275 HWTEST_F(ScreenClientTest, DestroyAllWindow_001, TestSize.Level1)
276 {
277     std::shared_ptr<WindowProperty> windowProperty = std::make_shared<WindowProperty>();
278     ScreenClient::GetInstance().AddWindow(windowProperty);
279     int32_t actual = ScreenClient::GetInstance().DestroyAllWindow();
280     EXPECT_EQ(DH_SUCCESS, actual);
281 }
282 
283 } // DistributedHardware
284 } // OHOS