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