• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 #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     EXPECT_EQ(nullptr, ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty, 0));
42 }
43 
44 /**
45  * @tc.name: CreateWindow_002
46  * @tc.desc: Verify the CreateWindow function.
47  * @tc.type: FUNC
48  * @tc.require: Issue Number
49  */
50 HWTEST_F(ScreenClientWindowAdapterTest, CreateWindow_002, TestSize.Level1)
51 {
52     std::shared_ptr<WindowProperty> windowProperty = std::make_shared<WindowProperty>();
53     int32_t windowId = 0;
54     sptr<Surface> actualSurface = ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty, windowId);
55     EXPECT_NE(nullptr, actualSurface);
56     int32_t ret = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId);
57     EXPECT_EQ(DH_SUCCESS, ret);
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(ScreenClientWindowAdapterTest, ShowWindow_001, TestSize.Level1)
67 {
68     int32_t ret = ScreenClientWindowAdapter::GetInstance().ShowWindow(100);
69     EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_SHOW_WINDOW_ERROR, ret);
70 }
71 
72 /**
73  * @tc.name: ShowWindow_002
74  * @tc.desc: Verify the ShowWindow function.
75  * @tc.type: FUNC
76  * @tc.require: Issue Number
77  */
78 HWTEST_F(ScreenClientWindowAdapterTest, ShowWindow_002, TestSize.Level1)
79 {
80     std::shared_ptr<WindowProperty> windowProperty = std::make_shared<WindowProperty>();
81     int32_t windowId = 100;
82     ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty, windowId);
83     int32_t ret = ScreenClientWindowAdapter::GetInstance().ShowWindow(windowId);
84     EXPECT_EQ(DH_SUCCESS, ret);
85     ret = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId);
86     EXPECT_EQ(DH_SUCCESS, ret);
87 }
88 
89 /**
90  * @tc.name: ShowWindow_003
91  * @tc.desc: Verify the ShowWindow function.
92  * @tc.type: FUNC
93  * @tc.require: Issue Number
94  */
95 HWTEST_F(ScreenClientWindowAdapterTest, ShowWindow_003, TestSize.Level1)
96 {
97     int32_t windowId = 0;
98     ScreenClientWindowAdapter::GetInstance().windowIdMap_.emplace(windowId, nullptr);
99     int32_t ret = ScreenClientWindowAdapter::GetInstance().ShowWindow(windowId);
100     EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_SHOW_WINDOW_ERROR, ret);
101     ret = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId);
102     EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, ret);
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(ScreenClientWindowAdapterTest, HideWindow_001, TestSize.Level1)
111 {
112     int32_t ret = ScreenClientWindowAdapter::GetInstance().HideWindow(0);
113     EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_HIDE_WINDOW_ERROR, ret);
114 }
115 
116 /**
117  * @tc.name: HideWindow_001
118  * @tc.desc: Verify the HideWindow function.
119  * @tc.type: FUNC
120  * @tc.require: Issue Number
121  */
122 HWTEST_F(ScreenClientWindowAdapterTest, HideWindow_002, TestSize.Level1)
123 {
124     std::shared_ptr<WindowProperty> windowProperty = std::make_shared<WindowProperty>();
125     int32_t windowId = 0;
126     ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty, windowId);
127     int32_t ret = ScreenClientWindowAdapter::GetInstance().HideWindow(windowId);
128     EXPECT_EQ(DH_SUCCESS, ret);
129     ret = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId);
130     EXPECT_EQ(DH_SUCCESS, ret);
131 }
132 
133 /**
134  * @tc.name: HideWindow_003
135  * @tc.desc: Verify the HideWindow function.
136  * @tc.type: FUNC
137  * @tc.require: Issue Number
138  */
139 HWTEST_F(ScreenClientWindowAdapterTest, HideWindow_003, TestSize.Level1)
140 {
141     int32_t windowId = 0;
142     ScreenClientWindowAdapter::GetInstance().windowIdMap_.emplace(windowId, nullptr);
143     int32_t ret = ScreenClientWindowAdapter::GetInstance().HideWindow(windowId);
144     EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_HIDE_WINDOW_ERROR, ret);
145     ret = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId);
146     EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, ret);
147 }
148 
149 /**
150  * @tc.name: MoveWindow_001
151  * @tc.desc: Verify the MoveWindow function.
152  * @tc.type: FUNC
153  * @tc.require: Issue Number
154  */
155 HWTEST_F(ScreenClientWindowAdapterTest, MoveWindow_001, TestSize.Level1)
156 {
157     int32_t ret = ScreenClientWindowAdapter::GetInstance().MoveWindow(0, 0, 0);
158     EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_MOVE_WINDOW_ERROR, ret);
159 }
160 
161 /**
162  * @tc.name: MoveWindow_002
163  * @tc.desc: Verify the MoveWindow function.
164  * @tc.type: FUNC
165  * @tc.require: Issue Number
166  */
167 HWTEST_F(ScreenClientWindowAdapterTest, MoveWindow_002, TestSize.Level1)
168 {
169     std::shared_ptr<WindowProperty> windowProperty = std::make_shared<WindowProperty>();
170     int32_t windowId = 0;
171     ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty, windowId);
172     int32_t ret = ScreenClientWindowAdapter::GetInstance().MoveWindow(windowId, 0, 0);
173     EXPECT_EQ(DH_SUCCESS, ret);
174     ret = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId);
175     EXPECT_EQ(DH_SUCCESS, ret);
176 }
177 
178 /**
179  * @tc.name: MoveWindow_003
180  * @tc.desc: Verify the MoveWindow function.
181  * @tc.type: FUNC
182  * @tc.require: Issue Number
183  */
184 HWTEST_F(ScreenClientWindowAdapterTest, MoveWindow_003, TestSize.Level1)
185 {
186     int32_t windowId = 0;
187     ScreenClientWindowAdapter::GetInstance().windowIdMap_.emplace(windowId, nullptr);
188     int32_t ret = ScreenClientWindowAdapter::GetInstance().MoveWindow(windowId, 0, 0);
189     EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_MOVE_WINDOW_ERROR, ret);
190     ret = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId);
191     EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, ret);
192 }
193 
194 /**
195  * @tc.name: RemoveWindow_001
196  * @tc.desc: Verify the RemoveWindow function.
197  * @tc.type: FUNC
198  * @tc.require: Issue Number
199  */
200 HWTEST_F(ScreenClientWindowAdapterTest, RemoveWindow_001, TestSize.Level1)
201 {
202     int32_t ret = ScreenClientWindowAdapter::GetInstance().RemoveWindow(0);
203     EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, ret);
204 }
205 
206 /**
207  * @tc.name: RemoveWindow_002
208  * @tc.desc: Verify the RemoveWindow function.
209  * @tc.type: FUNC
210  * @tc.require: Issue Number
211  */
212 HWTEST_F(ScreenClientWindowAdapterTest, RemoveWindow_002, TestSize.Level1)
213 {
214     std::shared_ptr<WindowProperty> windowProperty = std::make_shared<WindowProperty>();
215     int32_t windowId = 0;
216     ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty, windowId);
217     int32_t ret = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId);
218     EXPECT_EQ(DH_SUCCESS, ret);
219 }
220 
221 /**
222  * @tc.name: RemoveWindow_003
223  * @tc.desc: Verify the RemoveWindow function.
224  * @tc.type: FUNC
225  * @tc.require: Issue Number
226  */
227 HWTEST_F(ScreenClientWindowAdapterTest, RemoveWindow_003, TestSize.Level1)
228 {
229     int32_t windowId = 0;
230     ScreenClientWindowAdapter::GetInstance().windowIdMap_.emplace(windowId, nullptr);
231     int32_t ret = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId);
232     EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, ret);
233 }
234 
235 /**
236  * @tc.name: DestroyAllWindow_001
237  * @tc.desc: Verify the DestroyAllWindow function.
238  * @tc.type: FUNC
239  * @tc.require: Issue Number
240  */
241 HWTEST_F(ScreenClientWindowAdapterTest, DestroyAllWindow_001, TestSize.Level1)
242 {
243     ScreenClientWindowAdapter::GetInstance().windowIdMap_.emplace(0, nullptr);
244     int32_t ret = ScreenClientWindowAdapter::GetInstance().DestroyAllWindow();
245     EXPECT_EQ(DH_SUCCESS, ret);
246 }
247 } // DistributedHardware
248 } // OHOS