1 /*
2 * Copyright (c) 2024 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 #include <filesystem>
16 #include <fstream>
17 #include <gtest/gtest.h>
18
19 #include "ability_context_impl.h"
20 #include "accessibility_event_info.h"
21 #include "color_parser.h"
22 #include "mock_session.h"
23 #include "window_helper.h"
24 #include "window_session_impl.h"
25 #include "wm_common.h"
26 #include "mock_uicontent.h"
27 #include "mock_window.h"
28 #include "parameters.h"
29 #include "scene_board_judgement.h"
30
31 using namespace testing;
32 using namespace testing::ext;
33
34 namespace OHOS {
35 namespace Rosen {
36 class WindowSessionImplTest4 : public testing::Test {
37 public:
38 static void SetUpTestCase();
39 static void TearDownTestCase();
40 void SetUp() override;
41 void TearDown() override;
42
43 std::shared_ptr<AbilityRuntime::AbilityContext> abilityContext_;
44 private:
45 static constexpr uint32_t WAIT_SYNC_IN_NS = 50000;
46 };
47
SetUpTestCase()48 void WindowSessionImplTest4::SetUpTestCase()
49 {
50 }
51
TearDownTestCase()52 void WindowSessionImplTest4::TearDownTestCase()
53 {
54 }
55
SetUp()56 void WindowSessionImplTest4::SetUp()
57 {
58 abilityContext_ = std::make_shared<AbilityRuntime::AbilityContextImpl>();
59 }
60
TearDown()61 void WindowSessionImplTest4::TearDown()
62 {
63 usleep(WAIT_SYNC_IN_NS);
64 abilityContext_ = nullptr;
65 }
66
67 namespace {
68 /**
69 * @tc.name: GetRequestWindowStatetest01
70 * @tc.desc: GetRequestWindowState
71 * @tc.type: FUNC
72 */
73 HWTEST_F(WindowSessionImplTest4, GetRequestWindowState, Function | SmallTest | Level2)
74 {
75 GTEST_LOG_(INFO) << "WindowSessionImplTest4: GetRequestWindowStatetest01 start";
76 sptr<WindowOption> option = new WindowOption();
77 ASSERT_NE(option, nullptr);
78 option->SetWindowName("GetRequestWindowState");
79 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
80 ASSERT_NE(window, nullptr);
81 auto ret = window->GetRequestWindowState();
82 ASSERT_EQ(ret, WindowState::STATE_INITIAL);
83 GTEST_LOG_(INFO) << "WindowSessionImplTest4: GetRequestWindowStatetest01 end";
84 }
85
86 /**
87 * @tc.name: GetFocusabletest01
88 * @tc.desc: GetFocusable
89 * @tc.type: FUNC
90 */
91 HWTEST_F(WindowSessionImplTest4, GetFocusable, Function | SmallTest | Level2)
92 {
93 GTEST_LOG_(INFO) << "WindowSessionImplTest4: GetFocusabletest01 start";
94 sptr<WindowOption> option = new WindowOption();
95 ASSERT_NE(option, nullptr);
96 option->SetWindowName("GetFocusable");
97 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
98 ASSERT_NE(window, nullptr);
99 bool ret = window->GetFocusable();
100 ASSERT_EQ(ret, true);
101 GTEST_LOG_(INFO) << "WindowSessionImplTest4: GetFocusabletest01 end";
102 }
103
104
105 /**
106 * @tc.name: TransferAccessibilityEvent
107 * @tc.desc: TransferAccessibilityEvent
108 * @tc.type: FUNC
109 */
110 HWTEST_F(WindowSessionImplTest4, TransferAccessibilityEvent, Function | SmallTest | Level2)
111 {
112 GTEST_LOG_(INFO) << "WindowSessionImplTest4: TransferAccessibilityEvent start";
113 sptr<WindowOption> option = new WindowOption();
114 ASSERT_NE(option, nullptr);
115 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
116 ASSERT_NE(window, nullptr);
117 Accessibility::AccessibilityEventInfo info;
118 int64_t uiExtensionIdLevel = 0;
119 ASSERT_EQ(WMError::WM_OK, window->TransferAccessibilityEvent(info, uiExtensionIdLevel));
120 GTEST_LOG_(INFO) << "WindowSessionImplTest4: TransferAccessibilityEvent end";
121 }
122
123 /**
124 * @tc.name: SetSingleFrameComposerEnabled01
125 * @tc.desc: SetSingleFrameComposerEnabled and check the retCode
126 * @tc.type: FUNC
127 */
128 HWTEST_F(WindowSessionImplTest4, SetSingleFrameComposerEnabled01, Function | SmallTest | Level2)
129 {
130 sptr<WindowOption> option = new WindowOption();
131 option->SetWindowName("SetSingleFrameComposerEnabled01");
132 sptr<WindowSessionImpl> window = new(std::nothrow) WindowSessionImpl(option);
133 ASSERT_NE(nullptr, window);
134 WMError retCode = window->SetSingleFrameComposerEnabled(false);
135 ASSERT_EQ(retCode, WMError::WM_ERROR_INVALID_WINDOW);
136 window->property_->SetPersistentId(1);
137 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
138 sptr<SessionMocker> session = new(std::nothrow) SessionMocker(sessionInfo);
139 ASSERT_NE(nullptr, session);
140 window->hostSession_ = session;
141 window->state_ = WindowState::STATE_CREATED;
142 retCode = window->SetSingleFrameComposerEnabled(false);
143 ASSERT_EQ(retCode, WMError::WM_OK);
144
145 window->surfaceNode_ = nullptr;
146 retCode = window->SetSingleFrameComposerEnabled(false);
147 ASSERT_EQ(retCode, WMError::WM_ERROR_INVALID_WINDOW);
148 }
149
150 /**
151 * @tc.name: SetTopmost
152 * @tc.desc: SetTopmost
153 * @tc.type: FUNC
154 */
155 HWTEST_F(WindowSessionImplTest4, SetTopmost, Function | SmallTest | Level2)
156 {
157 sptr<WindowOption> option = new WindowOption();
158 option->SetWindowName("SetTopmost");
159 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
160 ASSERT_NE(nullptr, window);
161 window->windowSystemConfig_.uiType_ = "phone";
162 WMError res = window->SetTopmost(true);
163 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, res);
164 window->windowSystemConfig_.uiType_ = "pc";
165 res = window->SetTopmost(true);
166 ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, res);
167
168 window->property_->SetPersistentId(1);
169 SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"};
170 sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
171 ASSERT_NE(nullptr, session);
172 window->hostSession_ = session;
173 window->state_ = WindowState::STATE_CREATED;
174 res = window->SetTopmost(true);
175 ASSERT_EQ(WMError::WM_OK, res);
176 }
177
178 /**
179 * @tc.name: IsTopmost
180 * @tc.desc: IsTopmost
181 * @tc.type: FUNC
182 */
183 HWTEST_F(WindowSessionImplTest4, IsTopmost, Function | SmallTest | Level2)
184 {
185 sptr<WindowOption> option = new WindowOption();
186 option->SetWindowName("IsTopmost");
187 sptr<WindowSessionImpl> window = new WindowSessionImpl(option);
188 ASSERT_NE(window, nullptr);
189 bool res = window->IsTopmost();
190 ASSERT_FALSE(res);
191 }
192
193 /**
194 * @tc.name: SetMainWindowTopmost
195 * @tc.desc: SetMainWindowTopmost
196 * @tc.type: FUNC
197 */
198 HWTEST_F(WindowSessionImplTest4, SetMainWindowTopmost, Function | SmallTest | Level2)
199 {
200 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
201 option->SetWindowName("SetMainWindowTopmost");
202 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
203 window->property_->SetPersistentId(1);
204 SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"};
205 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
206 window->hostSession_ = session;
207 window->state_ = WindowState::STATE_CREATED;
208 window->windowSystemConfig_.uiType_ = UI_TYPE_PC;
209 window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
210 WMError res = window->SetMainWindowTopmost(true);
211 ASSERT_EQ(WMError::WM_ERROR_DEVICE_NOT_SUPPORT, res);
212 }
213
214 /**
215 * @tc.name: IsMainWindowTopmost
216 * @tc.desc: IsMainWindowTopmost
217 * @tc.type: FUNC
218 */
219 HWTEST_F(WindowSessionImplTest4, IsMainWindowTopmost, Function | SmallTest | Level2)
220 {
221 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
222 option->SetWindowName("IsMainWindowTopmost");
223 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
224 bool res = window->IsMainWindowTopmost();
225 ASSERT_FALSE(res);
226 }
227
228 /**
229 * @tc.name: SetDecorVisible
230 * @tc.desc: SetDecorVisible and check the retCode
231 * @tc.type: FUNC
232 */
233 HWTEST_F(WindowSessionImplTest4, SetDecorVisible, Function | SmallTest | Level2)
234 {
235 GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetDecorVisibletest01 start";
236 sptr<WindowOption> option = new WindowOption();
237 ASSERT_NE(option, nullptr);
238 option->SetWindowName("SetDecorVisible");
239 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
240 ASSERT_NE(window, nullptr);
241 ASSERT_NE(window->property_, nullptr);
242 window->property_->SetPersistentId(1);
243 SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"};
244 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
245 ASSERT_NE(nullptr, session);
246 window->hostSession_ = session;
247
248 bool isVisible = true;
249 WMError res = window->SetDecorVisible(isVisible);
250 ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
251
252 window->uiContent_ = std::make_unique<Ace::UIContentMocker>();
253 res = window->SetDecorVisible(isVisible);
254 ASSERT_EQ(res, WMError::WM_OK);
255 GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetDecorVisibletest01 end";
256 }
257
258 /**
259 * @tc.name: SetWindowTitleMoveEnabled
260 * @tc.desc: SetWindowTitleMoveEnabled and check the retCode
261 * @tc.type: FUNC
262 */
263 HWTEST_F(WindowSessionImplTest4, SetWindowTitleMoveEnabled, Function | SmallTest | Level2)
264 {
265 GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetWindowTitleMoveEnabledtest01 start";
266 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
267 ASSERT_NE(option, nullptr);
268 option->SetWindowName("SetWindowTitleMoveEnabled");
269 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
270 ASSERT_NE(window, nullptr);
271 WMError res = window->SetWindowTitleMoveEnabled(true);
272 EXPECT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW);
273 window->property_->SetPersistentId(1);
274 SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"};
275 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
276 ASSERT_NE(nullptr, session);
277 window->hostSession_ = session;
278 window->windowSystemConfig_.uiType_ = "phone";
279 res = window->SetWindowTitleMoveEnabled(true);
280 EXPECT_EQ(res, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
281 window->windowSystemConfig_.uiType_ = "pc";
282 window->property_->SetWindowType(WindowType::WINDOW_TYPE_UI_EXTENSION);
283 res = window->SetWindowTitleMoveEnabled(true);
284 EXPECT_EQ(res, WMError::WM_ERROR_INVALID_CALLING);
285 window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
286 res = window->SetWindowTitleMoveEnabled(true);
287 EXPECT_EQ(res, WMError::WM_ERROR_NULLPTR);
288 window->uiContent_ = std::make_unique<Ace::UIContentMocker>();
289 res = window->SetWindowTitleMoveEnabled(true);
290 EXPECT_EQ(res, WMError::WM_OK);
291 res = window->SetWindowTitleMoveEnabled(false);
292 EXPECT_EQ(res, WMError::WM_OK);
293 GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetWindowTitleMoveEnabledtest01 end";
294 }
295
296 /**
297 * @tc.name: SetSubWindowModal
298 * @tc.desc: SetSubWindowModal and check the retCode
299 * @tc.type: FUNC
300 */
301 HWTEST_F(WindowSessionImplTest4, SetSubWindowModal, Function | SmallTest | Level2)
302 {
303 GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetSubWindowModaltest01 start";
304 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
305 ASSERT_NE(option, nullptr);
306 option->SetWindowName("SetSubWindowModal");
307 option->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
308 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
309 ASSERT_NE(window, nullptr);
310 window->property_->SetPersistentId(1);
311 SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"};
312 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
313 ASSERT_NE(nullptr, session);
314 window->hostSession_ = session;
315 WMError res = window->SetSubWindowModal(true);
316 ASSERT_EQ(res, WMError::WM_OK);
317 GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetSubWindowModaltest01 end";
318 }
319
320 /**
321 * @tc.name: SetSubWindowModal02
322 * @tc.desc: SetSubWindowModal and check the retCode
323 * @tc.type: FUNC
324 */
325 HWTEST_F(WindowSessionImplTest4, SetSubWindowModal02, Function | SmallTest | Level2)
326 {
327 GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetSubWindowModaltest02 start";
328 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
329 ASSERT_NE(option, nullptr);
330 option->SetWindowName("SetSubWindowModal02");
331 option->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
332 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
333 ASSERT_NE(window, nullptr);
334 window->property_->SetPersistentId(1);
335 SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"};
336 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
337 ASSERT_NE(nullptr, session);
338 window->hostSession_ = session;
339 window->windowSystemConfig_.uiType_ = "pc";
340 WMError res = window->SetSubWindowModal(true, ModalityType::WINDOW_MODALITY);
341 ASSERT_EQ(res, WMError::WM_OK);
342 res = window->SetSubWindowModal(true, ModalityType::APPLICATION_MODALITY);
343 ASSERT_EQ(res, WMError::WM_OK);
344 GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetSubWindowModaltest02 end";
345 }
346
347 /**
348 * @tc.name: SetWindowModal
349 * @tc.desc: SetWindowModal and check the retCode
350 * @tc.type: FUNC
351 */
352 HWTEST_F(WindowSessionImplTest4, SetWindowModal, Function | SmallTest | Level2)
353 {
354 GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetWindowModal start";
355 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
356 ASSERT_NE(option, nullptr);
357 option->SetWindowName("SetWindowModal");
358 option->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
359 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
360 ASSERT_NE(window, nullptr);
361 window->property_->SetPersistentId(1);
362 SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"};
363 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
364 ASSERT_NE(nullptr, session);
365 window->hostSession_ = session;
366 window->windowSystemConfig_.uiType_ = "pc";
367 WMError res = window->SetWindowModal(true);
368 ASSERT_EQ(res, WMError::WM_OK);
369 res = window->SetWindowModal(false);
370 ASSERT_EQ(res, WMError::WM_OK);
371 window->windowSystemConfig_.uiType_ = "phone";
372 res = window->SetWindowModal(true);
373 ASSERT_EQ(res, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
374 res = window->SetWindowModal(false);
375 ASSERT_EQ(res, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
376 GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetWindowModal end";
377 }
378
379 /**
380 * @tc.name: IsPcWindow
381 * @tc.desc: IsPcWindow
382 * @tc.type: FUNC
383 */
384 HWTEST_F(WindowSessionImplTest4, IsPcWindow, Function | SmallTest | Level2)
385 {
386 GTEST_LOG_(INFO) << "WindowSessionImplTest4: IsPcWindow start";
387 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
388 option->SetWindowName("IsPcWindow");
389 option->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
390 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
391 window->property_->SetPersistentId(1);
392 SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"};
393 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
394 window->hostSession_ = session;
395 window->windowSystemConfig_.uiType_ = UI_TYPE_PC;
396 ASSERT_EQ(true, window->IsPcWindow());
397 window->windowSystemConfig_.uiType_ = UI_TYPE_PHONE;
398 ASSERT_EQ(false, window->IsPcWindow());
399 GTEST_LOG_(INFO) << "WindowSessionImplTest4: IsPcWindow end";
400 }
401
402 /**
403 * @tc.name: IsPcOrPadFreeMultiWindowMode
404 * @tc.desc: IsPcOrPadFreeMultiWindowMode
405 * @tc.type: FUNC
406 */
407 HWTEST_F(WindowSessionImplTest4, IsPcOrPadFreeMultiWindowMode, Function | SmallTest | Level2)
408 {
409 GTEST_LOG_(INFO) << "WindowSessionImplTest4: IsPcOrPadFreeMultiWindowMode start";
410 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
411 ASSERT_NE(option, nullptr);
412 option->SetWindowName("IsPcOrPadFreeMultiWindowMode");
413 option->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
414 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
415 ASSERT_NE(window, nullptr);
416 window->property_->SetPersistentId(1);
417 SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"};
418 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
419 ASSERT_NE(nullptr, session);
420 window->hostSession_ = session;
421 window->windowSystemConfig_.uiType_ = "pc";
422 ASSERT_EQ(true, window->IsPcOrPadFreeMultiWindowMode());
423 window->windowSystemConfig_.uiType_ = "phone";
424 ASSERT_EQ(false, window->IsPcOrPadFreeMultiWindowMode());
425 GTEST_LOG_(INFO) << "WindowSessionImplTest4: IsPcOrPadFreeMultiWindowMode end";
426 }
427
428 /**
429 * @tc.name: GetDecorHeight
430 * @tc.desc: GetDecorHeight and check the retCode
431 * @tc.type: FUNC
432 */
433 HWTEST_F(WindowSessionImplTest4, GetDecorHeight, Function | SmallTest | Level2)
434 {
435 GTEST_LOG_(INFO) << "WindowSessionImplTest4: GetDecorHeighttest01 start";
436 sptr<WindowOption> option = new WindowOption();
437 ASSERT_NE(option, nullptr);
438 option->SetWindowName("GetDecorHeight");
439 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
440 ASSERT_NE(window, nullptr);
441 ASSERT_NE(window->property_, nullptr);
442 window->property_->SetPersistentId(1);
443 SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"};
444 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
445 ASSERT_NE(nullptr, session);
446 window->hostSession_ = session;
447 int32_t height = 0;
448 WMError res = window->GetDecorHeight(height);
449 ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
450 GTEST_LOG_(INFO) << "WindowSessionImplTest4: GetDecorHeighttest01 end";
451 }
452
453 /**
454 * @tc.name: GetTitleButtonArea
455 * @tc.desc: GetTitleButtonArea and check the retCode
456 * @tc.type: FUNC
457 */
458 HWTEST_F(WindowSessionImplTest4, GetTitleButtonArea, Function | SmallTest | Level2)
459 {
460 GTEST_LOG_(INFO) << "WindowSessionImplTest4: GetTitleButtonAreatest01 start";
461 sptr<WindowOption> option = new WindowOption();
462 ASSERT_NE(option, nullptr);
463 option->SetWindowName("GetTitleButtonArea");
464 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
465 ASSERT_NE(window, nullptr);
466 ASSERT_NE(window->property_, nullptr);
467 window->property_->SetPersistentId(1);
468 SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"};
469 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
470 ASSERT_NE(nullptr, session);
471 window->hostSession_ = session;
472 TitleButtonRect titleButtonRect;
473 WMError res = window->GetTitleButtonArea(titleButtonRect);
474 ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
475 GTEST_LOG_(INFO) << "WindowSessionImplTest4: GetDecorHeighttest01 end";
476 }
477
478 /**
479 * @tc.name: RegisterExtensionAvoidAreaChangeListener
480 * @tc.desc: RegisterExtensionAvoidAreaChangeListener Test
481 * @tc.type: FUNC
482 */
483 HWTEST_F(WindowSessionImplTest4, RegisterExtensionAvoidAreaChangeListener, Function | SmallTest | Level2)
484 {
485 GTEST_LOG_(INFO) << "WindowSessionImplTest4: RegisterExtensionAvoidAreaChangeListener start";
486 sptr<WindowOption> option = new WindowOption();
487 ASSERT_NE(option, nullptr);
488 option->SetWindowName("GetTitleButtonArea");
489 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
490 ASSERT_NE(window, nullptr);
491 sptr<IAvoidAreaChangedListener> listener = nullptr;
492 WMError res = window->RegisterExtensionAvoidAreaChangeListener(listener);
493 ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
494 GTEST_LOG_(INFO) << "WindowSessionImplTest4: RegisterExtensionAvoidAreaChangeListener end";
495 }
496
497 /**
498 * @tc.name: UnregisterExtensionAvoidAreaChangeListener
499 * @tc.desc: UnregisterExtensionAvoidAreaChangeListener Test
500 * @tc.type: FUNC
501 */
502 HWTEST_F(WindowSessionImplTest4, UnregisterExtensionAvoidAreaChangeListener, Function | SmallTest | Level2)
503 {
504 GTEST_LOG_(INFO) << "WindowSessionImplTest4: UnregisterExtensionAvoidAreaChangeListener start";
505 sptr<WindowOption> option = new WindowOption();
506 ASSERT_NE(option, nullptr);
507 option->SetWindowName("GetTitleButtonArea");
508 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
509 ASSERT_NE(window, nullptr);
510 sptr<IAvoidAreaChangedListener> listener = nullptr;
511 WMError res = window->UnregisterExtensionAvoidAreaChangeListener(listener);
512 ASSERT_EQ(res, WMError::WM_ERROR_NULLPTR);
513 GTEST_LOG_(INFO) << "WindowSessionImplTest4: UnregisterExtensionAvoidAreaChangeListener end";
514 }
515
516 /**
517 * @tc.name: SetPipActionEvent
518 * @tc.desc: SetPipActionEvent Test
519 * @tc.type: FUNC
520 */
521 HWTEST_F(WindowSessionImplTest4, SetPipActionEvent, Function | SmallTest | Level2)
522 {
523 GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetPipActionEvent start";
524 sptr<WindowOption> option = new WindowOption();
525 ASSERT_NE(option, nullptr);
526 option->SetWindowName("GetTitleButtonArea");
527 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
528 ASSERT_NE(window, nullptr);
529 ASSERT_EQ(nullptr, window->GetUIContentWithId(10000));
530 window->property_->SetPersistentId(1);
531
532 SessionInfo sessionInfo = { "CreateTestBundle", "TestGetUIContentWithId", "CreateTestAbility" };
533 sptr<SessionMocker> session = new(std::nothrow) SessionMocker(sessionInfo);
534 ASSERT_NE(nullptr, session);
535 ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
536 window->uiContent_ = std::make_unique<Ace::UIContentMocker>();
537 ASSERT_EQ(window->FindWindowById(1), nullptr);
538 ASSERT_EQ(nullptr, window->GetUIContentWithId(1));
539 ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
540 GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetPipActionEvent end";
541 }
542
543 /**
544 * @tc.name: SetPiPControlEvent
545 * @tc.desc: SetPiPControlEvent Test
546 * @tc.type: FUNC
547 */
548 HWTEST_F(WindowSessionImplTest4, SetPiPControlEvent, Function | SmallTest | Level2)
549 {
550 GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetPiPControlEvent start";
551 auto option = sptr<WindowOption>::MakeSptr();
552 ASSERT_NE(option, nullptr);
553 option->SetWindowName("GetTitleButtonArea");
554 auto window = sptr<WindowSessionImpl>::MakeSptr(option);
555 ASSERT_NE(window, nullptr);
556 auto controlType = WsPiPControlType::VIDEO_PLAY_PAUSE;
557 auto status = WsPiPControlStatus::PLAY;
558 WSError res = window->SetPiPControlEvent(controlType, status);
559 ASSERT_EQ(res, WSError::WS_OK);
560 GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetPiPControlEvent end";
561 }
562
563 /**
564 * @tc.name: SetAutoStartPiP
565 * @tc.desc: SetAutoStartPiP
566 * @tc.type: FUNC
567 */
568 HWTEST_F(WindowSessionImplTest4, SetAutoStartPiP, Function | SmallTest | Level2)
569 {
570 auto option = sptr<WindowOption>::MakeSptr();
571 ASSERT_NE(option, nullptr);
572 option->SetWindowName("SetAutoStartPiP");
573 auto window = sptr<WindowSessionImpl>::MakeSptr(option);
574 ASSERT_NE(window, nullptr);
575 window->property_->SetPersistentId(1);
576 SessionInfo sessionInfo = { "SetAutoStartPiP", "SetAutoStartPiP", "SetAutoStartPiP" };
577 auto session = sptr<SessionMocker>::MakeSptr(sessionInfo);
578 ASSERT_NE(nullptr, session);
579 window->hostSession_ = session;
580 bool isAutoStart = true;
581 uint32_t priority = 1;
582 window->SetAutoStartPiP(isAutoStart, priority);
583 window->hostSession_ = nullptr;
584 window->SetAutoStartPiP(isAutoStart, priority);
585 }
586
587 /**
588 * @tc.name: TestGetUIContentWithId
589 * @tc.desc: Get uicontent with id
590 * @tc.type: FUNC
591 */
592 HWTEST_F(WindowSessionImplTest4, TestGetUIContentWithId, Function | SmallTest | Level2)
593 {
594 GTEST_LOG_(INFO) << "WindowSessionImplTest4: TestGetUIContentWithId start";
595 sptr<WindowOption> option = new WindowOption();
596 ASSERT_NE(nullptr, option);
597 option->SetWindowName("TestGetUIContentWithId");
598 sptr<WindowSessionImpl> window = new WindowSessionImpl(option);
599 ASSERT_NE(nullptr, window);
600 ASSERT_EQ(nullptr, window->GetUIContentWithId(10000));
601 window->property_->SetPersistentId(1);
602
603 SessionInfo sessionInfo = { "CreateTestBundle", "TestGetUIContentWithId", "CreateTestAbility" };
604 sptr<SessionMocker> session = new(std::nothrow) SessionMocker(sessionInfo);
605 ASSERT_NE(nullptr, session);
606 ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
607 window->uiContent_ = std::make_unique<Ace::UIContentMocker>();
608 if (SceneBoardJudgement::IsSceneBoardEnabled()) {
609 ASSERT_NE(window->FindWindowById(1), nullptr);
610 ASSERT_EQ(nullptr, window->GetUIContentWithId(1));
611 ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
612 }
613 GTEST_LOG_(INFO) << "WindowSessionImplTest4: TestGetUIContentWithId end";
614 }
615
616 /**
617 * @tc.name: GetCallingWindowRect
618 * @tc.desc: GetCallingWindowRect Test
619 * @tc.type: FUNC
620 */
621 HWTEST_F(WindowSessionImplTest4, GetCallingWindowRect, Function | SmallTest | Level2)
622 {
623 sptr<WindowOption> option = new WindowOption();
624 option->SetWindowName("GetCallingWindowRect");
625 sptr<WindowSessionImpl> window = new(std::nothrow) WindowSessionImpl(option);
626 ASSERT_NE(nullptr, window);
627 Rect rect = {0, 0, 0, 0};
628 WMError retCode = window->GetCallingWindowRect(rect);
629 ASSERT_EQ(retCode, WMError::WM_ERROR_INVALID_WINDOW);
630 window->property_->SetPersistentId(1);
631 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
632 sptr<SessionMocker> session = new(std::nothrow) SessionMocker(sessionInfo);
633 ASSERT_NE(nullptr, session);
634 window->hostSession_ = session;
635 window->state_ = WindowState::STATE_CREATED;
636 window->GetCallingWindowRect(rect);
637 }
638
639 /**
640 * @tc.name: GetCallingWindowWindowStatus
641 * @tc.desc: GetCallingWindowWindowStatus Test
642 * @tc.type: FUNC
643 */
644 HWTEST_F(WindowSessionImplTest4, GetCallingWindowWindowStatus, Function | SmallTest | Level2)
645 {
646 sptr<WindowOption> option = new WindowOption();
647 option->SetWindowName("GetCallingWindowWindowStatus");
648 sptr<WindowSessionImpl> window = new(std::nothrow) WindowSessionImpl(option);
649 ASSERT_NE(nullptr, window);
650 WindowStatus windowStatus = WindowStatus::WINDOW_STATUS_UNDEFINED;
651 WMError retCode = window->GetCallingWindowWindowStatus(windowStatus);
652 ASSERT_EQ(retCode, WMError::WM_ERROR_INVALID_WINDOW);
653 window->property_->SetPersistentId(1);
654 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
655 sptr<SessionMocker> session = new(std::nothrow) SessionMocker(sessionInfo);
656 ASSERT_NE(nullptr, session);
657 window->hostSession_ = session;
658 window->state_ = WindowState::STATE_CREATED;
659 window->GetCallingWindowWindowStatus(windowStatus);
660 }
661
662 /**
663 * @tc.name: GetParentId
664 * @tc.desc: GetParentId Test
665 * @tc.type: FUNC
666 */
667 HWTEST_F(WindowSessionImplTest4, GetParentId, Function | SmallTest | Level2)
668 {
669 sptr<WindowOption> option = new WindowOption();
670 sptr<WindowSessionImpl> window = new WindowSessionImpl(option);
671 const int32_t res = window->GetParentId();
672 ASSERT_EQ(res, 0);
673 ASSERT_EQ(true, window->IsSupportWideGamut());
674 }
675
676 /**
677 * @tc.name: PreNotifyKeyEvent
678 * @tc.desc: PreNotifyKeyEvent Test
679 * @tc.type: FUNC
680 */
681 HWTEST_F(WindowSessionImplTest4, PreNotifyKeyEvent, Function | SmallTest | Level2)
682 {
683 sptr<WindowOption> option = new (std::nothrow) WindowOption();
684 ASSERT_NE(nullptr, option);
685 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
686 ASSERT_NE(nullptr, window);
687 std::shared_ptr<MMI::PointerEvent> pointerEvent;
688 window->ConsumePointerEvent(pointerEvent);
689
690 std::shared_ptr<MMI::KeyEvent> keyEvent = MMI::KeyEvent::Create();
691 window->ConsumeKeyEvent(keyEvent);
692 ASSERT_EQ(nullptr, window->GetUIContentSharedPtr());
693 ASSERT_EQ(false, window->PreNotifyKeyEvent(keyEvent));
694 ASSERT_EQ(false, window->NotifyOnKeyPreImeEvent(keyEvent));
695 window->uiContent_ = std::make_unique<Ace::UIContentMocker>();
696 ASSERT_NE(nullptr, window->GetUIContentSharedPtr());
697 ASSERT_EQ(false, window->PreNotifyKeyEvent(keyEvent));
698 ASSERT_EQ(false, window->NotifyOnKeyPreImeEvent(keyEvent));
699 }
700
701 /**
702 * @tc.name: UpdateRectForRotation
703 * @tc.desc: UpdateRectForRotation Test
704 * @tc.type: FUNC
705 */
706 HWTEST_F(WindowSessionImplTest4, UpdateRectForRotation, Function | SmallTest | Level2)
707 {
708 sptr<WindowOption> option = new WindowOption();
709 option->SetWindowName("WindowSessionCreateCheck");
710 sptr<WindowSessionImpl> window =
711 new (std::nothrow) WindowSessionImpl(option);
712 ASSERT_NE(window, nullptr);
713
714 Rect wmRect;
715 wmRect.posX_ = 0;
716 wmRect.posY_ = 0;
717 wmRect.height_ = 50;
718 wmRect.width_ = 50;
719
720 WSRect rect;
721 wmRect.posX_ = 0;
722 wmRect.posY_ = 0;
723 wmRect.height_ = 50;
724 wmRect.width_ = 50;
725
726 Rect preRect;
727 preRect.posX_ = 0;
728 preRect.posY_ = 0;
729 preRect.height_ = 200;
730 preRect.width_ = 200;
731
732 window->property_->SetWindowRect(preRect);
733 WindowSizeChangeReason wmReason = WindowSizeChangeReason{0};
734 std::shared_ptr<RSTransaction> rsTransaction;
735 SceneAnimationConfig config { .rsTransaction_ = rsTransaction };
736 window->UpdateRectForRotation(wmRect, preRect, wmReason, config);
737
738 SizeChangeReason reason = SizeChangeReason::UNDEFINED;
739 auto res = window->UpdateRect(rect, reason);
740 ASSERT_EQ(res, WSError::WS_OK);
741 }
742
743 /**
744 * @tc.name: SetTitleButtonVisible
745 * @tc.desc: SetTitleButtonVisible and GetTitleButtonVisible
746 * @tc.type: FUNC
747 */
748 HWTEST_F(WindowSessionImplTest4, SetTitleButtonVisible, Function | SmallTest | Level2)
749 {
750 sptr<WindowOption> option = new WindowOption();
751 sptr<WindowSessionImpl> window = new WindowSessionImpl(option);
752 ASSERT_NE(window, nullptr);
753 bool isMaximizeVisible = true;
754 bool isMinimizeVisible = true;
755 bool isSplitVisible = true;
756 bool isCloseVisible = true;
757 auto res = window->SetTitleButtonVisible(isMaximizeVisible, isMinimizeVisible,
758 isSplitVisible, isCloseVisible);
759
760 bool &hideMaximizeButton = isMaximizeVisible;
761 bool &hideMinimizeButton = isMinimizeVisible;
762 bool &hideSplitButton = isSplitVisible;
763 bool &hideCloseButton = isCloseVisible;
764 window->windowSystemConfig_.uiType_ = "pc";
765 window->GetTitleButtonVisible(hideMaximizeButton, hideMinimizeButton,
766 hideSplitButton, hideCloseButton);
767 ASSERT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW);
768 }
769
770 /**
771 * @tc.name: IsFocused
772 * @tc.desc: IsFocused
773 * @tc.type: FUNC
774 */
775 HWTEST_F(WindowSessionImplTest4, IsFocused, Function | SmallTest | Level2)
776 {
777 sptr<WindowOption> option = new WindowOption();
778 option->SetWindowName("WindowSessionCreateCheck");
779 sptr<WindowSessionImpl> window =
780 new (std::nothrow) WindowSessionImpl(option);
781 ASSERT_NE(window, nullptr);
782 bool res = window->IsFocused();
783 ASSERT_EQ(res, false);
784
785 ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->RequestFocus());
786
787 SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule",
788 "CreateTestAbility"};
789 sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
790 ASSERT_NE(nullptr, session);
791 ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
792 int32_t persistentId = window->GetPersistentId();
793 if (persistentId == INVALID_SESSION_ID) {
794 persistentId = 1;
795 window->property_->SetPersistentId(persistentId);
796 }
797 if (window->state_ == WindowState::STATE_DESTROYED) {
798 window->state_ = WindowState::STATE_SHOWN;
799 }
800 window->hostSession_ = session;
801 window->RequestFocus();
802 ASSERT_FALSE(window->IsWindowSessionInvalid());
803 ASSERT_EQ(persistentId, window->GetPersistentId());
804 ASSERT_EQ(WMError::WM_OK, window->Destroy());
805 }
806
807 /**
808 * @tc.name: GetAbcContent
809 * @tc.desc: GetAbcContent Test
810 * @tc.type: FUNC
811 */
812 HWTEST_F(WindowSessionImplTest4, GetAbcContent, Function | SmallTest | Level2)
813 {
814 sptr<WindowOption> option = new WindowOption();
815 ASSERT_NE(option, nullptr);
816 option->SetWindowName("GetAbcContent");
817 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
818 ASSERT_NE(window, nullptr);
819 std::string abcPath = "";
820 std::shared_ptr<std::vector<uint8_t>> res = window->GetAbcContent(abcPath);
821 std::filesystem::path abcFile{abcPath};
822 ASSERT_TRUE(abcFile.empty());
823 ASSERT_TRUE(!abcFile.is_absolute());
824 ASSERT_TRUE(!std::filesystem::exists(abcFile));
825 ASSERT_EQ(res, nullptr);
826
827 abcPath = "/abc";
828 res = window->GetAbcContent(abcPath);
829 std::filesystem::path abcFile2{abcPath};
830 ASSERT_FALSE(abcFile2.empty());
831 ASSERT_FALSE(!abcFile2.is_absolute());
832 ASSERT_TRUE(!std::filesystem::exists(abcFile2));
833 ASSERT_EQ(res, nullptr);
834
835 abcPath = "abc";
836 res = window->GetAbcContent(abcPath);
837 std::filesystem::path abcFile3{abcPath};
838 ASSERT_FALSE(abcFile3.empty());
839 ASSERT_TRUE(!abcFile3.is_absolute());
840 ASSERT_TRUE(!std::filesystem::exists(abcFile3));
841 ASSERT_EQ(res, nullptr);
842
843 abcPath = "/log";
844 res = window->GetAbcContent(abcPath);
845 std::filesystem::path abcFile4{abcPath};
846 ASSERT_FALSE(abcFile4.empty());
847 ASSERT_FALSE(!abcFile4.is_absolute());
848 if (SceneBoardJudgement::IsSceneBoardEnabled()) {
849 ASSERT_FALSE(!std::filesystem::exists(abcFile4));
850 ASSERT_NE(res, nullptr);
851 std::fstream file(abcFile, std::ios::in | std::ios::binary);
852 ASSERT_FALSE(file);
853 }
854 window->Destroy();
855 }
856
857 /**
858 * @tc.name: SetLandscapeMultiWindow
859 * @tc.desc: SetLandscapeMultiWindow and check the retCode
860 * @tc.type: FUNC
861 */
862 HWTEST_F(WindowSessionImplTest4, SetLandscapeMultiWindow, Function | SmallTest | Level2)
863 {
864 sptr<WindowOption> option = new WindowOption();
865 option->SetWindowName("SetLandscapeMultiWindow");
866 sptr<WindowSessionImpl> window = new(std::nothrow) WindowSessionImpl(option);
867 ASSERT_NE(nullptr, window);
868 WMError retCode = window->SetLandscapeMultiWindow(false);
869 ASSERT_EQ(retCode, WMError::WM_ERROR_INVALID_WINDOW);
870 window->property_->SetPersistentId(1);
871 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
872 sptr<SessionMocker> session = new(std::nothrow) SessionMocker(sessionInfo);
873 ASSERT_NE(nullptr, session);
874 window->hostSession_ = session;
875 window->state_ = WindowState::STATE_CREATED;
876 retCode = window->SetLandscapeMultiWindow(false);
877 ASSERT_EQ(retCode, WMError::WM_OK);
878 }
879
880 /**
881 * @tc.name: GetTouchable
882 * @tc.desc: GetTouchable
883 * @tc.type: FUNC
884 */
885 HWTEST_F(WindowSessionImplTest4, GetTouchable, Function | SmallTest | Level2)
886 {
887 sptr<WindowOption> option = new WindowOption();
888 ASSERT_NE(option, nullptr);
889 option->SetWindowName("GetTouchable");
890 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
891 ASSERT_NE(window, nullptr);
892 window->GetTouchable();
893 window->GetBrightness();
894 ASSERT_NE(window, nullptr);
895 }
896
897 /**
898 * @tc.name: Notify03
899 * @tc.desc: NotifyCloseExistPipWindow NotifyAfterResumed NotifyAfterPaused
900 * @tc.type: FUNC
901 */
902 HWTEST_F(WindowSessionImplTest4, Notify03, Function | SmallTest | Level2)
903 {
904 sptr<WindowOption> option = new WindowOption();
905 option->SetWindowName("Notify03");
906 sptr<WindowSessionImpl> window = new WindowSessionImpl(option);
907
908 SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule",
909 "CreateTestAbility"};
910 sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
911 ASSERT_NE(nullptr, session);
912 ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
913
914 window->NotifyAfterResumed();
915 window->NotifyAfterPaused();
916 WSError res = window->NotifyCloseExistPipWindow();
917 ASSERT_EQ(res, WSError::WS_OK);
918 AAFwk::WantParams wantParams;
919 WSError ret = window->NotifyTransferComponentData(wantParams);
920 ASSERT_EQ(ret, WSError::WS_OK);
921 ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
922 }
923
924 /**
925 * @tc.name: Filter
926 * @tc.desc: Filter
927 * @tc.type: FUNC
928 */
929 HWTEST_F(WindowSessionImplTest4, Filter, Function | SmallTest | Level2)
930 {
931 sptr<WindowOption> option = new WindowOption();
932 ASSERT_NE(option, nullptr);
933 option->SetWindowName("Filter");
934 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
935 ASSERT_NE(window, nullptr);
936 std::shared_ptr<MMI::KeyEvent> keyEvent = MMI::KeyEvent::Create();
937 window->FilterKeyEvent(keyEvent);
938 ASSERT_EQ(window->keyEventFilter_, nullptr);
__anon1d1e8d9a0202(MMI::KeyEvent& keyEvent) 939 window->SetKeyEventFilter([](MMI::KeyEvent& keyEvent) {
940 GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetKeyEventFilter";
941 return true;
942 });
943 ASSERT_NE(window->keyEventFilter_, nullptr);
944 window->FilterKeyEvent(keyEvent);
945 auto ret = window->ClearKeyEventFilter();
946 ASSERT_EQ(ret, WMError::WM_OK);
947 }
948
949 /**
950 * @tc.name: UpdateOrientation
951 * @tc.desc: UpdateOrientation
952 * @tc.type: FUNC
953 */
954 HWTEST_F(WindowSessionImplTest4, UpdateOrientation, Function | SmallTest | Level2)
955 {
956 sptr<WindowOption> option = new WindowOption();
957 ASSERT_NE(option, nullptr);
958 option->SetWindowName("UpdateOrientation");
959 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
960 ASSERT_NE(window, nullptr);
961 auto ret = window->UpdateOrientation();
962 ASSERT_EQ(WSError::WS_OK, ret);
963 }
964
965 /**
966 * @tc.name: SetTitleButtonVisible01
967 * @tc.desc: SetTitleButtonVisible
968 * @tc.type: FUNC
969 */
970 HWTEST_F(WindowSessionImplTest4, SetTitleButtonVisible01, Function | SmallTest | Level2)
971 {
972 GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetTitleButtonVisible01 start";
973 sptr<WindowOption> option = new (std::nothrow) WindowOption();
974 ASSERT_NE(option, nullptr);
975 option->SetWindowName("SetTitleButtonVisible");
976 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
977 ASSERT_NE(window, nullptr);
978 SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"};
979 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
980 ASSERT_NE(nullptr, session);
981 window->hostSession_ = session;
982 ASSERT_NE(window->property_, nullptr);
983 window->property_->SetPersistentId(1);
984 window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
985 WMError res = window->SetTitleButtonVisible(false, false, false, true);
986 ASSERT_EQ(res, WMError::WM_ERROR_INVALID_CALLING);
987 GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetTitleButtonVisible01 end";
988 }
989
990 /**
991 * @tc.name: SetTitleButtonVisible02
992 * @tc.desc: SetTitleButtonVisible
993 * @tc.type: FUNC
994 */
995 HWTEST_F(WindowSessionImplTest4, SetTitleButtonVisible02, Function | SmallTest | Level2)
996 {
997 GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetTitleButtonVisible02 start";
998 sptr<WindowOption> option = new (std::nothrow) WindowOption();
999 ASSERT_NE(option, nullptr);
1000 option->SetWindowName("SetTitleButtonVisible");
1001 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
1002 ASSERT_NE(window, nullptr);
1003 ASSERT_NE(window->property_, nullptr);
1004 window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1005 WMError res = window->SetTitleButtonVisible(false, false, false, true);
1006 ASSERT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW);
1007 GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetTitleButtonVisible02 end";
1008 }
1009
1010 /**
1011 * @tc.name: SetTitleButtonVisible03
1012 * @tc.desc: SetTitleButtonVisible
1013 * @tc.type: FUNC
1014 */
1015 HWTEST_F(WindowSessionImplTest4, SetTitleButtonVisible03, Function | SmallTest | Level2)
1016 {
1017 GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetTitleButtonVisible03 start";
1018 sptr option = new (std::nothrow) WindowOption();
1019 ASSERT_NE(option, nullptr);
1020 option->SetWindowName("SetTitleButtonVisible");
1021 sptr window = new (std::nothrow) WindowSessionImpl(option);
1022 ASSERT_NE(window, nullptr);
1023 ASSERT_NE(window->property_, nullptr);
1024 window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1025 window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1026 window->uiContent_ = std::make_unique<Ace::UIContentMocker>();
1027 window->windowSystemConfig_.freeMultiWindowSupport_ = true;
1028 window->windowSystemConfig_.isSystemDecorEnable_ = true;
1029 window->windowSystemConfig_.uiType_ = "phone";
1030 WMError res = window->SetTitleButtonVisible(false, false, false, true);
1031 ASSERT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW);
1032 window->windowSystemConfig_.uiType_ = "pc";
1033 res = window->SetTitleButtonVisible(false, false, false, true);
1034 ASSERT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW);
1035 GTEST_LOG_(INFO) << "WindowSessionImplTest4: SetTitleButtonVisible03 end";
1036 }
1037
1038 /**
1039 * @tc.name: GetTitleButtonVisible01
1040 * @tc.desc: GetTitleButtonVisible
1041 * @tc.type: FUNC
1042 */
1043 HWTEST_F(WindowSessionImplTest4, GetTitleButtonVisible01, Function | SmallTest | Level2)
1044 {
1045 sptr<WindowOption> option = new (std::nothrow) WindowOption();
1046 ASSERT_NE(option, nullptr);
1047 option->SetWindowName("GetTitleButtonVisible01");
1048 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
1049 ASSERT_NE(window, nullptr);
1050 ASSERT_NE(window->property_, nullptr);
1051 uint32_t windowModeSupportType = 1 | (1 << 1) | (1 << 2);
1052 window->property_->SetWindowModeSupportType(windowModeSupportType);
1053 window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1054 // show Maximize, Minimize, Split buttons.
1055 window->windowTitleVisibleFlags_ = { false, false, false, false };
1056 bool hideMaximizeButton = false;
1057 bool hideMinimizeButton = false;
1058 bool hideSplitButton = false;
1059 bool hideCloseButton = false;
1060 window->windowSystemConfig_.uiType_ = "pc";
1061 window->GetTitleButtonVisible(hideMaximizeButton, hideMinimizeButton, hideSplitButton,
1062 hideCloseButton);
1063 ASSERT_EQ(hideMaximizeButton, true);
1064 ASSERT_EQ(hideMinimizeButton, true);
1065 ASSERT_EQ(hideSplitButton, true);
1066 ASSERT_EQ(hideCloseButton, true);
1067 }
1068
1069 /**
1070 * @tc.name: UpdateRect03
1071 * @tc.desc: UpdateRect
1072 * @tc.type: FUNC
1073 */
1074 HWTEST_F(WindowSessionImplTest4, UpdateRect03, Function | SmallTest | Level2)
1075 {
1076 sptr<WindowOption> option = new WindowOption();
1077 option->SetWindowName("WindowSessionCreateCheck");
1078 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
1079 ASSERT_NE(window, nullptr);
1080
1081 WSRect rect;
1082 rect.posX_ = 0;
1083 rect.posY_ = 0;
1084 rect.height_ = 0;
1085 rect.width_ = 0;
1086
1087 Rect rectW; // GetRect().IsUninitializedRect is true
1088 rectW.posX_ = 0;
1089 rectW.posY_ = 0;
1090 rectW.height_ = 0; // rectW - rect > 50
1091 rectW.width_ = 0; // rectW - rect > 50
1092
1093 window->property_->SetWindowRect(rectW);
1094 SizeChangeReason reason = SizeChangeReason::UNDEFINED;
1095 WSError res = window->UpdateRect(rect, reason);
1096 ASSERT_EQ(res, WSError::WS_OK);
1097
1098 rect.height_ = 50;
1099 rect.width_ = 50;
1100 rectW.height_ = 50;
1101 rectW.width_ = 50;
1102 window->property_->SetWindowRect(rectW);
1103 res = window->UpdateRect(rect, reason);
1104 ASSERT_EQ(res, WSError::WS_OK);
1105 }
1106
1107 /**
1108 * @tc.name: GetTitleButtonVisible02
1109 * @tc.desc: GetTitleButtonVisible
1110 * @tc.type: FUNC
1111 */
1112 HWTEST_F(WindowSessionImplTest4, GetTitleButtonVisible02, Function | SmallTest | Level2)
1113 {
1114 sptr<WindowOption> option = new (std::nothrow) WindowOption();
1115 ASSERT_NE(option, nullptr);
1116 option->SetWindowName("GetTitleButtonVisible02");
1117 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
1118 ASSERT_NE(window, nullptr);
1119 ASSERT_NE(window->property_, nullptr);
1120 // only not support WINDOW_MODE_SUPPORT_SPLIT
1121 uint32_t windowModeSupportType = 1 | (1 << 1);
1122 window->property_->SetWindowModeSupportType(windowModeSupportType);
1123 window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1124 // show Maximize, Minimize, Split buttons.
1125 window->windowTitleVisibleFlags_ = { true, true, true, true };
1126 bool hideMaximizeButton = false;
1127 bool hideMinimizeButton = false;
1128 bool hideSplitButton = false;
1129 bool hideCloseButton = false;
1130 window->windowSystemConfig_.uiType_ = "pc";
1131 window->GetTitleButtonVisible(hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton);
1132 ASSERT_EQ(hideMaximizeButton, false);
1133 ASSERT_EQ(hideMinimizeButton, false);
1134 ASSERT_EQ(hideSplitButton, false);
1135 ASSERT_EQ(hideCloseButton, false);
1136 }
1137
1138 /**
1139 * @tc.name: GetTitleButtonVisible03
1140 * @tc.desc: GetTitleButtonVisible
1141 * @tc.type: FUNC
1142 */
1143 HWTEST_F(WindowSessionImplTest4, GetTitleButtonVisible03, Function | SmallTest | Level2)
1144 {
1145 sptr<WindowOption> option = new (std::nothrow) WindowOption();
1146 ASSERT_NE(option, nullptr);
1147 option->SetWindowName("GetTitleButtonVisible03");
1148 option->SetDisplayId(1);
1149 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
1150 ASSERT_NE(window, nullptr);
1151 ASSERT_NE(window->property_, nullptr);
1152 ASSERT_EQ(1, window->GetDisplayId());
1153 // only not support WINDOW_MODE_SUPPORT_SPLIT
1154 uint32_t windowModeSupportType = 1 | (1 << 1) | (1 << 2);
1155 window->property_->SetWindowModeSupportType(windowModeSupportType);
1156 window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1157 // show Maximize, Minimize, Split buttons.
1158 window->windowTitleVisibleFlags_ = { false, false, false, false };
1159 bool hideMaximizeButton = true;
1160 bool hideMinimizeButton = true;
1161 bool hideSplitButton = true;
1162 bool hideCloseButton = true;
1163 window->windowSystemConfig_.uiType_ = "phone";
1164 window->GetTitleButtonVisible(hideMaximizeButton, hideMinimizeButton, hideSplitButton, hideCloseButton);
1165 ASSERT_EQ(hideMaximizeButton, true);
1166 ASSERT_EQ(hideMinimizeButton, true);
1167 ASSERT_EQ(hideSplitButton, true);
1168 ASSERT_EQ(hideCloseButton, true);
1169 }
1170
1171 /**
1172 * @tc.name: SetUiDvsyncSwitch
1173 * @tc.desc: SetUiDvsyncSwitch
1174 * @tc.type: FUNC
1175 */
1176 HWTEST_F(WindowSessionImplTest4, SetUiDvsyncSwitch, Function | SmallTest | Level2)
1177 {
1178 sptr<WindowOption> option = new (std::nothrow) WindowOption();
1179 ASSERT_NE(option, nullptr);
1180 option->SetWindowName("SetUiDvsyncSwitch");
1181 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
1182 ASSERT_NE(window, nullptr);
1183 window->SetUiDvsyncSwitch(true);
1184 window->vsyncStation_ = nullptr;
1185 window->SetUiDvsyncSwitch(true);
1186 }
1187
1188 /**
1189 * @tc.name: GetVSyncPeriod
1190 * @tc.desc: GetVSyncPeriod
1191 * @tc.type: FUNC
1192 */
1193 HWTEST_F(WindowSessionImplTest4, GetVSyncPeriod, Function | SmallTest | Level2)
1194 {
1195 sptr<WindowOption> option = new (std::nothrow) WindowOption();
1196 ASSERT_NE(option, nullptr);
1197 option->SetWindowName("GetVSyncPeriod");
1198 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
1199 ASSERT_NE(window, nullptr);
1200 window->GetVSyncPeriod();
1201 window->vsyncStation_ = nullptr;
1202 window->GetVSyncPeriod();
1203 }
1204
1205 /**
1206 * @tc.name: UpdatePiPControlStatus01
1207 * @tc.desc: UpdatePiPControlStatus
1208 * @tc.type: FUNC
1209 */
1210 HWTEST_F(WindowSessionImplTest4, UpdatePiPControlStatus01, Function | SmallTest | Level2)
1211 {
1212 sptr<WindowOption> option = new (std::nothrow) WindowOption();
1213 ASSERT_NE(option, nullptr);
1214 option->SetWindowName("UpdatePiPControlStatus01");
1215 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
1216 ASSERT_NE(window, nullptr);
1217 ASSERT_NE(window->property_, nullptr);
1218 window->property_->SetPersistentId(1);
1219 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1220 sptr<SessionMocker> session = new(std::nothrow) SessionMocker(sessionInfo);
1221 ASSERT_NE(nullptr, session);
1222 window->hostSession_ = session;
1223 auto controlType = PiPControlType::VIDEO_PLAY_PAUSE;
1224 auto status = PiPControlStatus::ENABLED;
1225 window->UpdatePiPControlStatus(controlType, status);
1226 window->hostSession_ = nullptr;
1227 window->UpdatePiPControlStatus(controlType, status);
1228 }
1229
1230 /**
1231 * @tc.name: NotifyWindowVisibility01
1232 * @tc.desc: NotifyWindowVisibility
1233 * @tc.type: FUNC
1234 */
1235 HWTEST_F(WindowSessionImplTest4, NotifyWindowVisibility01, Function | SmallTest | Level2)
1236 {
1237 sptr<WindowOption> option = new (std::nothrow) WindowOption();
1238 ASSERT_NE(option, nullptr);
1239 option->SetWindowName("NotifyWindowVisibility01");
1240 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
1241 ASSERT_NE(window, nullptr);
1242 ASSERT_NE(window->property_, nullptr);
1243 window->property_->SetPersistentId(1);
1244 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1245 sptr<SessionMocker> session = new(std::nothrow) SessionMocker(sessionInfo);
1246 ASSERT_NE(nullptr, session);
1247 window->hostSession_ = session;
1248 window->NotifyWindowVisibility(false);
1249 sptr<IWindowVisibilityChangedListener> listener = new IWindowVisibilityChangedListener();
1250 window->RegisterWindowVisibilityChangeListener(listener);
1251 window->NotifyWindowVisibility(false);
1252 window->UnregisterWindowVisibilityChangeListener(listener);
1253 }
1254
1255 /**
1256 * @tc.name: NotifyMainWindowClose01
1257 * @tc.desc: NotifyMainWindowClose
1258 * @tc.type: FUNC
1259 */
1260 HWTEST_F(WindowSessionImplTest4, NotifyMainWindowClose01, Function | SmallTest | Level2)
1261 {
1262 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1263 ASSERT_NE(option, nullptr);
1264 option->SetWindowName("NotifyMainWindowClose01");
1265 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1266 ASSERT_NE(window, nullptr);
1267 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1268 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1269 ASSERT_NE(nullptr, session);
1270 window->hostSession_ = session;
1271 window->property_->SetPersistentId(1);
1272
1273 bool terminateCloseProcess = false;
1274 WMError res = window->NotifyMainWindowClose(terminateCloseProcess);
1275 EXPECT_EQ(terminateCloseProcess, false);
1276 EXPECT_EQ(res, WMError::WM_ERROR_NULLPTR);
1277 sptr<IMainWindowCloseListener> listener = sptr<IMainWindowCloseListener>::MakeSptr();
1278 window->RegisterMainWindowCloseListeners(listener);
1279 res = window->NotifyMainWindowClose(terminateCloseProcess);
1280 EXPECT_EQ(terminateCloseProcess, false);
1281 EXPECT_EQ(res, WMError::WM_ERROR_NULLPTR);
1282 window->UnregisterMainWindowCloseListeners(listener);
1283 }
1284
1285 /**
1286 * @tc.name: NotifyWindowWillClose
1287 * @tc.desc: NotifyWindowWillClose
1288 * @tc.type: FUNC
1289 */
1290 HWTEST_F(WindowSessionImplTest4, NotifyWindowWillClose, Function | SmallTest | Level2)
1291 {
1292 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1293 option->SetWindowName("NotifyWindowWillClose");
1294 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1295 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1296 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1297 window->hostSession_ = session;
1298 window->property_->SetPersistentId(1);
1299 WMError res = window->NotifyWindowWillClose(window);
1300 EXPECT_EQ(res, WMError::WM_ERROR_NULLPTR);
1301
1302 sptr<IWindowWillCloseListener> listener = sptr<MockIWindowWillCloseListener>::MakeSptr();
1303 window->windowSystemConfig_.uiType_ = UI_TYPE_PC;
1304 window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1305 res = window->RegisterWindowWillCloseListeners(listener);
1306 EXPECT_EQ(res, WMError::WM_OK);
1307 res = window->NotifyWindowWillClose(window);
1308 EXPECT_EQ(res, WMError::WM_OK);
1309 res = window->UnRegisterWindowWillCloseListeners(listener);
1310 EXPECT_EQ(res, WMError::WM_OK);
1311 res = window->NotifyWindowWillClose(window);
1312 EXPECT_EQ(res, WMError::WM_ERROR_NULLPTR);
1313 }
1314
1315 /**
1316 * @tc.name: UpdateVirtualPixelRatio
1317 * @tc.desc: test UpdateVirtualPixelRatio
1318 * @tc.type: FUNC
1319 */
1320 HWTEST_F(WindowSessionImplTest4, UpdateVirtualPixelRatio, Function | SmallTest | Level2)
1321 {
1322 GTEST_LOG_(INFO) << "WindowSessionImplTest4: UpdateVirtualPixelRatio start";
1323 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1324 option->SetWindowName("UpdateVirtualPixelRatio");
1325 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1326 window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1327 window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1328
1329 window->property_->SetDisplayId(-1);
1330 sptr<Display> display = nullptr;
1331 window->UpdateVirtualPixelRatio(display);
1332 ASSERT_EQ(window->virtualPixelRatio_, 1.0f);
1333
1334 window->property_->SetDisplayId(0);
1335 display = SingletonContainer::Get<DisplayManager>().GetDisplayById(window->property_->GetDisplayId());
1336 window->UpdateVirtualPixelRatio(display);
1337 ASSERT_NE(window->virtualPixelRatio_, 1.0f);
1338 GTEST_LOG_(INFO) << "WindowSessionImplTest4: UpdateVirtualPixelRatio end";
1339 }
1340
1341 /**
1342 * @tc.name: IsPcOrPadCapabilityEnabled
1343 * @tc.desc: IsPcOrPadCapabilityEnabled test
1344 * @tc.type: FUNC
1345 */
1346 HWTEST_F(WindowSessionImplTest4, IsPcOrPadCapabilityEnabled, Function | SmallTest | Level2)
1347 {
1348 GTEST_LOG_(INFO) << "WindowSessionImplTest4: IsPcOrPadCapabilityEnabled start";
1349 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1350 option->SetWindowName("IsPcOrPadCapabilityEnabled");
1351 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1352 ASSERT_NE(window->property_, nullptr);
1353 window->property_->SetPersistentId(1);
1354 window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1355 window->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
1356 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1357 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1358 ASSERT_NE(nullptr, session);
1359 window->hostSession_ = session;
1360
1361 window->windowSystemConfig_.uiType_ = "pc";
1362 EXPECT_EQ(true, window->IsPcOrPadCapabilityEnabled());
1363 window->windowSystemConfig_.uiType_ = "phone";
1364 EXPECT_EQ(false, window->IsPcOrPadCapabilityEnabled());
1365 window->windowSystemConfig_.uiType_ = "pad";
1366 EXPECT_EQ(false, window->IsPcOrPadCapabilityEnabled());
1367 window->property_->SetIsPcAppInPad(true);
1368 EXPECT_EQ(true, window->IsPcOrPadCapabilityEnabled());
1369 EXPECT_EQ(WMError::WM_OK, window->Destroy(true));
1370 GTEST_LOG_(INFO) << "WindowSessionImplTest4: IsPcOrPadCapabilityEnabled end";
1371 }
1372
1373 /**
1374 * @tc.name: DestroySubWindow
1375 * @tc.desc: DestroySubWindow test
1376 * @tc.type: FUNC
1377 */
1378 HWTEST_F(WindowSessionImplTest4, DestroySubWindow, Function | SmallTest | Level2)
1379 {
1380 GTEST_LOG_(INFO) << "WindowSessionImplTest4: DestroySubWindow start";
1381 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1382 ASSERT_NE(option, nullptr);
1383 option->SetWindowName("DestroySubWindow");
1384 option->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1385 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1386 ASSERT_NE(window->property_, nullptr);
1387 window->property_->SetPersistentId(1);
1388 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1389 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1390 ASSERT_NE(nullptr, session);
1391 window->hostSession_ = session;
1392 window->windowSystemConfig_.uiType_ = "pc";
1393
1394 sptr<WindowOption> subOption = sptr<WindowOption>::MakeSptr();
1395 ASSERT_NE(subOption, nullptr);
1396 subOption->SetWindowName("DestroySubWindow01");
1397 subOption->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1398 sptr<WindowSessionImpl> subWindow = sptr<WindowSessionImpl>::MakeSptr(subOption);
1399 ASSERT_NE(subWindow, nullptr);
1400 ASSERT_NE(subWindow->property_, nullptr);
1401 subWindow->property_->SetPersistentId(2);
1402 SessionInfo subSessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1403 sptr<SessionMocker> subSession = sptr<SessionMocker>::MakeSptr(subSessionInfo);
1404 ASSERT_NE(nullptr, subSession);
1405 subWindow->hostSession_ = subSession;
1406 subWindow->windowSystemConfig_.uiType_ = "pc";
1407 std::vector<sptr<WindowSessionImpl>> vec;
1408 WindowSessionImpl::subWindowSessionMap_.insert(std::pair<int32_t,
1409 std::vector<sptr<WindowSessionImpl>>>(1, vec));
1410 WindowSessionImpl::subWindowSessionMap_[1].push_back(subWindow);
1411 window->DestroySubWindow();
1412 EXPECT_EQ(WMError::WM_OK, window->Destroy(true));
1413 }
1414
1415 /**
1416 * @tc.name: UpdateSubWindowStateAndNotify01
1417 * @tc.desc: UpdateSubWindowStateAndNotify
1418 * @tc.type: FUNC
1419 */
1420 HWTEST_F(WindowSessionImplTest4, UpdateSubWindowStateAndNotify01, Function | SmallTest | Level2)
1421 {
1422 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1423 ASSERT_NE(option, nullptr);
1424 option->SetWindowName("UpdateSubWindowStateAndNotify01");
1425 option->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1426 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1427 ASSERT_NE(window->property_, nullptr);
1428 window->property_->SetPersistentId(1);
1429 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1430 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1431 ASSERT_NE(nullptr, session);
1432 window->hostSession_ = session;
1433 window->windowSystemConfig_.uiType_ = "pc";
1434
1435 sptr<WindowOption> subOption = sptr<WindowOption>::MakeSptr();
1436 ASSERT_NE(subOption, nullptr);
1437 subOption->SetWindowName("UpdateSubWindowStateAndNotify011");
1438 subOption->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1439 sptr<WindowSessionImpl> subWindow = sptr<WindowSessionImpl>::MakeSptr(subOption);
1440 ASSERT_NE(subWindow, nullptr);
1441 ASSERT_NE(subWindow->property_, nullptr);
1442 subWindow->property_->SetPersistentId(2);
1443 SessionInfo subSessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1444 sptr<SessionMocker> subSession = sptr<SessionMocker>::MakeSptr(subSessionInfo);
1445 ASSERT_NE(nullptr, subSession);
1446 subWindow->hostSession_ = subSession;
1447 subWindow->windowSystemConfig_.uiType_ = "pc";
1448 std::vector<sptr<WindowSessionImpl>> vec;
1449 WindowSessionImpl::subWindowSessionMap_.insert(std::pair<int32_t,
1450 std::vector<sptr<WindowSessionImpl>>>(1, vec));
1451 subWindow->UpdateSubWindowStateAndNotify(1, WindowState::STATE_HIDDEN);
1452 WindowSessionImpl::subWindowSessionMap_[1].push_back(subWindow);
1453 subWindow->state_ = WindowState::STATE_SHOWN;
1454 window->UpdateSubWindowStateAndNotify(1, WindowState::STATE_HIDDEN);
1455 window->state_ = WindowState::STATE_HIDDEN;
1456 window->UpdateSubWindowStateAndNotify(1, WindowState::STATE_HIDDEN);
1457 window->state_ = WindowState::STATE_SHOWN;
1458 window->UpdateSubWindowStateAndNotify(1, WindowState::STATE_SHOWN);
1459 window->state_ = WindowState::STATE_SHOWN;
1460 window->UpdateSubWindowStateAndNotify(1, WindowState::STATE_SHOWN);
1461 EXPECT_EQ(WMError::WM_OK, subWindow->Destroy(true));
1462 EXPECT_EQ(WMError::WM_OK, window->Destroy(true));
1463 }
1464
1465 /**
1466 * @tc.name: SetEnableDragBySystem
1467 * @tc.desc: test SetEnableDragBySystem
1468 * @tc.type: FUNC
1469 */
1470 HWTEST_F(WindowSessionImplTest4, SetEnableDragBySystem, Function | SmallTest | Level2)
1471 {
1472 GTEST_LOG_(INFO) << "WindowSessionImplTest4: GetSubWindow start";
1473 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1474 option->SetWindowName("GetSubWindow");
1475 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1476 ASSERT_NE(nullptr, window);
1477 window->property_->SetDragEnabled(true);
1478 window->SetEnableDragBySystem(false);
1479 ASSERT_FALSE(window->property_->GetDragEnabled());
1480 }
1481
1482 /**
1483 * @tc.name: ClearListenersById_windowWillCloseListeners
1484 * @tc.desc: ClearListenersById_windowWillCloseListeners
1485 * @tc.type: FUNC
1486 */
1487 HWTEST_F(WindowSessionImplTest4, ClearListenersById_windowWillCloseListeners, Function | SmallTest | Level2)
1488 {
1489 GTEST_LOG_(INFO) << "WindowSessionImplTest4: ClearListenersById_windowWillCloseListeners start";
1490 sptr<WindowOption> option_ = sptr<WindowOption>::MakeSptr();
1491 option_->SetWindowName("ClearListenersById_windowWillCloseListeners");
1492 sptr<WindowSessionImpl> window_ = sptr<WindowSessionImpl>::MakeSptr(option_);
1493 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1494 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1495 window_->hostSession_ = session;
1496 window_->property_->SetPersistentId(1);
1497 int persistentId = window_->GetPersistentId();
1498 window_->ClearListenersById(persistentId);
1499
1500 sptr<IWindowWillCloseListener> listener_ = sptr<MockIWindowWillCloseListener>::MakeSptr();
1501 window_->windowSystemConfig_.uiType_ = UI_TYPE_PC;
1502 ASSERT_EQ(WMError::WM_OK, window_->RegisterWindowWillCloseListeners(listener_));
1503 ASSERT_NE(window_->windowWillCloseListeners_.find(persistentId), window_->windowWillCloseListeners_.end());
1504
1505 window_->ClearListenersById(persistentId);
1506 ASSERT_EQ(window_->windowWillCloseListeners_.find(persistentId), window_->windowWillCloseListeners_.end());
1507
1508 GTEST_LOG_(INFO) << "WindowSessionImplTest4: ClearListenersById_windowWillCloseListeners end";
1509 }
1510
1511 /**
1512 * @tc.name: FlushLayoutSize
1513 * @tc.desc: FlushLayoutSize
1514 * @tc.type: FUNC
1515 */
1516 HWTEST_F(WindowSessionImplTest4, FlushLayoutSize, Function | SmallTest | Level2)
1517 {
1518 #undef private
1519 GTEST_LOG_(INFO) << "WindowSessionImplTest4: FlushLayoutSize start";
1520 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1521 option->SetWindowName("FlushLayoutSize");
1522 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1523 window->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1524 int32_t width = 1320;
1525 int32_t height = 2710;
1526 WSRect rect = { 0, 0, width, height };
1527 window->FlushLayoutSize(width, height);
1528
1529 window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1530 window->windowSizeChanged_ = true;
1531 window->FlushLayoutSize(width, height);
1532 ASSERT_EQ(window->windowSizeChanged_, false);
1533
1534 window->layoutRect_ = { 0, 0, 2710, 1320 };
1535 window->FlushLayoutSize(width, height);
1536 ASSERT_EQ(window->layoutRect_, rect);
1537
1538 window->enableFrameLayoutFinishCb_ = true;
1539 window->FlushLayoutSize(width, height);
1540 ASSERT_EQ(window->enableFrameLayoutFinishCb_, false);
1541
1542 GTEST_LOG_(INFO) << "WindowSessionImplTest4: FlushLayoutSize end";
1543 }
1544
1545 /**
1546 * @tc.name: RegisterDisplayIdChangeListener01
1547 * @tc.desc: RegisterDisplayIdChangeListener01
1548 * @tc.type: FUNC
1549 */
1550 HWTEST_F(WindowSessionImplTest4, RegisterDisplayIdChangeListener01, Function | SmallTest | Level2)
1551 {
1552 sptr<WindowOption> option = new WindowOption();
1553 ASSERT_NE(option, nullptr);
1554 option->SetWindowName("RegisterDisplayIdChangeListener01");
1555
1556 sptr<WindowSessionImpl> window = new WindowSessionImpl(option);
1557 ASSERT_NE(window, nullptr);
1558 sptr<IDisplayIdChangeListener> listener = nullptr;
1559 WMError ret = window->RegisterDisplayIdChangeListener(listener);
1560 ASSERT_EQ(ret, WMError::WM_ERROR_NULLPTR);
1561
1562 listener = sptr<IDisplayIdChangeListener>::MakeSptr();
1563 std::vector<sptr<IDisplayIdChangeListener>> holder;
1564 window->displayIdChangeListeners_[window->property_->GetPersistentId()] = holder;
1565 ret = window->RegisterDisplayIdChangeListener(listener);
1566 ASSERT_EQ(ret, WMError::WM_OK);
1567 holder = window->displayIdChangeListeners_[window->property_->GetPersistentId()];
1568 auto existsListener = std::find(holder.begin(), holder.end(), listener);
1569 ASSERT_NE(existsListener, holder.end());
1570
1571 ret = window->RegisterDisplayIdChangeListener(listener);
1572 ASSERT_EQ(ret, WMError::WM_OK);
1573 }
1574
1575 /**
1576 * @tc.name: UnregisterDisplayIdChangeListener01
1577 * @tc.desc: UnregisterDisplayIdChangeListener01
1578 * @tc.type: FUNC
1579 */
1580 HWTEST_F(WindowSessionImplTest4, UnregisterDisplayIdChangeListener01, Function | SmallTest | Level2)
1581 {
1582 sptr<WindowOption> option = new WindowOption();
1583 ASSERT_NE(option, nullptr);
1584 option->SetWindowName("UnregisterDisplayIdChangeListener01");
1585
1586 sptr<WindowSessionImpl> window = new WindowSessionImpl(option);
1587 ASSERT_NE(window, nullptr);
1588 sptr<IDisplayIdChangeListener> listener = nullptr;
1589 WMError ret = window->UnregisterDisplayIdChangeListener(listener);
1590 ASSERT_EQ(ret, WMError::WM_ERROR_NULLPTR);
1591
1592 listener = sptr<IDisplayIdChangeListener>::MakeSptr();
1593 std::vector<sptr<IDisplayIdChangeListener>> holder;
1594 window->displayIdChangeListeners_[window->property_->GetPersistentId()] = holder;
1595 window->UnregisterDisplayIdChangeListener(listener);
1596
1597 ret = window->UnregisterDisplayIdChangeListener(listener);
1598 ASSERT_EQ(ret, WMError::WM_OK);
1599
1600 holder = window->displayIdChangeListeners_[window->property_->GetPersistentId()];
1601 auto existsListener = std::find(holder.begin(), holder.end(), listener);
1602 ASSERT_EQ(existsListener, holder.end());
1603 }
1604
1605 /**
1606 * @tc.name: NotifyDisplayIdChange01
1607 * @tc.desc: NotifyDisplayIdChange01
1608 * @tc.type: FUNC
1609 */
1610 HWTEST_F(WindowSessionImplTest4, NotifyDisplayIdChange01, Function | SmallTest | Level2)
1611 {
1612 sptr<WindowOption> option = new WindowOption();
1613 ASSERT_NE(option, nullptr);
1614 option->SetWindowName("NotifyDisplayIdChange01");
1615
1616 sptr<WindowSessionImpl> window = new WindowSessionImpl(option);
1617 ASSERT_NE(window, nullptr);
1618
1619 SessionInfo sessioninfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"};
1620 sptr<SessionMocker> session = new SessionMocker(sessioninfo);
1621 ASSERT_NE(session, nullptr);
1622 ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1623 DisplayId displayId = 12;
1624 auto ret = window->NotifyDisplayIdChange(displayId);
1625 ASSERT_EQ(WSError::WS_OK, ret);
1626 ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
1627 }
1628
1629 /**
1630 * @tc.name: RegisterSystemDensityChangeListener01
1631 * @tc.desc: RegisterSystemDensityChangeListener01
1632 * @tc.type: FUNC
1633 */
1634 HWTEST_F(WindowSessionImplTest4, RegisterSystemDensityChangeListener01, Function | SmallTest | Level2)
1635 {
1636 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1637 ASSERT_NE(option, nullptr);
1638 option->SetWindowName("RegisterSystemDensityChangeListener01");
1639
1640 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1641 ASSERT_NE(window, nullptr);
1642 sptr<ISystemDensityChangeListener> listener = nullptr;
1643 WMError ret = window->RegisterSystemDensityChangeListener(listener);
1644 ASSERT_EQ(ret, WMError::WM_ERROR_NULLPTR);
1645
1646 listener = sptr<ISystemDensityChangeListener>::MakeSptr();
1647 std::vector<sptr<ISystemDensityChangeListener>> holder;
1648 window->systemDensityChangeListeners_[window->property_->GetPersistentId()] = holder;
1649 ret = window->RegisterSystemDensityChangeListener(listener);
1650 ASSERT_EQ(ret, WMError::WM_OK);
1651 holder = window->systemDensityChangeListeners_[window->property_->GetPersistentId()];
1652 auto existsListener = std::find(holder.begin(), holder.end(), listener);
1653 ASSERT_NE(existsListener, holder.end());
1654
1655 ret = window->RegisterSystemDensityChangeListener(listener);
1656 ASSERT_EQ(ret, WMError::WM_OK);
1657 holder = window->systemDensityChangeListeners_[window->property_->GetPersistentId()];
1658 ASSERT_EQ(holder.size(), 1);
1659 }
1660
1661 /**
1662 * @tc.name: UnregisterSystemDensityChangeListener01
1663 * @tc.desc: UnregisterSystemDensityChangeListener01
1664 * @tc.type: FUNC
1665 */
1666 HWTEST_F(WindowSessionImplTest4, UnregisterSystemDensityChangeListener01, Function | SmallTest | Level2)
1667 {
1668 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1669 ASSERT_NE(option, nullptr);
1670 option->SetWindowName("UnregisterSystemDensityChangeListener01");
1671
1672 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1673 ASSERT_NE(window, nullptr);
1674 sptr<ISystemDensityChangeListener> listener = nullptr;
1675 WMError ret = window->UnregisterSystemDensityChangeListener(listener);
1676 ASSERT_EQ(ret, WMError::WM_ERROR_NULLPTR);
1677
1678 listener = sptr<ISystemDensityChangeListener>::MakeSptr();
1679 std::vector<sptr<ISystemDensityChangeListener>> holder;
1680 window->systemDensityChangeListeners_[window->property_->GetPersistentId()] = holder;
1681 ret = window->UnregisterSystemDensityChangeListener(listener);
1682 ASSERT_EQ(ret, WMError::WM_OK);
1683
1684 holder = window->systemDensityChangeListeners_[window->property_->GetPersistentId()];
1685 auto existsListener = std::find(holder.begin(), holder.end(), listener);
1686 ASSERT_EQ(existsListener, holder.end());
1687 }
1688
1689 /**
1690 * @tc.name: NotifySystemDensityChange01
1691 * @tc.desc: NotifySystemDensityChange01
1692 * @tc.type: FUNC
1693 */
1694 HWTEST_F(WindowSessionImplTest4, NotifySystemDensityChange01, Function | SmallTest | Level2)
1695 {
1696 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1697 ASSERT_NE(option, nullptr);
1698 option->SetWindowName("NotifySystemDensityChange01");
1699
1700 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1701 ASSERT_NE(window, nullptr);
1702
1703 SessionInfo sessioninfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"};
1704 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessioninfo);
1705 ASSERT_NE(session, nullptr);
1706 ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1707
1708 float density = 1.5f;
1709 auto ret = window->NotifySystemDensityChange(density);
1710 ASSERT_EQ(WSError::WS_OK, ret);
1711 ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
1712 }
1713
1714 /**
1715 * @tc.name: GetIsMidScene
1716 * @tc.desc: GetIsMidScene
1717 * @tc.type: FUNC
1718 */
1719 HWTEST_F(WindowSessionImplTest4, GetIsMidScene, Function | SmallTest | Level2)
1720 {
1721 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1722 option->SetWindowName("GetIsMidScene");
1723
1724 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1725 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1726 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1727 ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1728
1729 bool isMidScene = false;
1730 auto ret = window->GetIsMidScene(isMidScene);
1731 ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, ret);
1732 ASSERT_EQ(false, isMidScene);
1733 ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
1734 }
1735
1736 /**
1737 * @tc.name: GetLayoutTransform
1738 * @tc.desc: GetLayoutTransform
1739 * @tc.type: FUNC
1740 */
1741 HWTEST_F(WindowSessionImplTest4, GetLayoutTransform, Function | SmallTest | Level2)
1742 {
1743 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1744 option->SetWindowName("GetLayoutTransform");
1745 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1746
1747 Transform transform;
1748 transform.scaleX_ = 1.0;
1749 transform.scaleY_ = 1.0;
1750 window->uiContent_ = std::make_unique<Ace::UIContentMocker>();
1751 window->NotifyTransformChange(transform);
1752 Transform layoutTransform = window->GetLayoutTransform();
1753 ASSERT_EQ(transform.scaleX_, layoutTransform.scaleX_);
1754 ASSERT_EQ(transform.scaleY_, layoutTransform.scaleY_);
1755 ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->Destroy());
1756 }
1757
1758 /**
1759 * @tc.name: SetExclusivelyHighlighted
1760 * @tc.desc: SetExclusivelyHighlighted
1761 * @tc.type: FUNC
1762 */
1763 HWTEST_F(WindowSessionImplTest4, SetExclusivelyHighlighted, Function | SmallTest | Level2)
1764 {
1765 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1766 option->SetWindowName("SetExclusivelyHighlighted");
1767 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1768 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1769 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1770 ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1771 window->hostSession_ = session;
1772 window->property_->SetPersistentId(INVALID_SESSION_ID);
1773 ASSERT_EQ(window->SetExclusivelyHighlighted(true), WMError::WM_ERROR_INVALID_WINDOW);
1774 window->property_->SetPersistentId(1);
1775 window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1776 ASSERT_EQ(window->SetExclusivelyHighlighted(true), WMError::WM_ERROR_INVALID_CALLING);
1777 window->property_->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
1778 ASSERT_EQ(window->SetExclusivelyHighlighted(true), WMError::WM_ERROR_INVALID_CALLING);
1779 window->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1780 window->property_->AddWindowFlag(WindowFlag::WINDOW_FLAG_IS_APPLICATION_MODAL);
1781 ASSERT_EQ(window->SetExclusivelyHighlighted(true), WMError::WM_ERROR_INVALID_CALLING);
1782 window->property_->flags_ = 0;
1783 ASSERT_EQ(window->SetExclusivelyHighlighted(true), WMError::WM_OK);
1784 ASSERT_EQ(window->SetExclusivelyHighlighted(false), WMError::WM_OK);
1785 }
1786
1787 /**
1788 * @tc.name: GetExclusivelyHighlighted
1789 * @tc.desc: GetExclusivelyHighlighted
1790 * @tc.type: FUNC
1791 */
1792 HWTEST_F(WindowSessionImplTest4, GetExclusivelyHighlighted, Function | SmallTest | Level2)
1793 {
1794 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1795 option->SetWindowName("GetExclusivelyHighlighted");
1796 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1797 ASSERT_EQ(window->GetExclusivelyHighlighted(), true);
1798 }
1799
1800 /**
1801 * @tc.name: NotifyHighlightChange
1802 * @tc.desc: NotifyHighlightChange
1803 * @tc.type: FUNC
1804 */
1805 HWTEST_F(WindowSessionImplTest4, NotifyHighlightChange, Function | SmallTest | Level2)
1806 {
1807 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1808 option->SetWindowName("NotifyHighlightChange01");
1809 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1810 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1811 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1812 window->hostSession_ = session;
1813 window->property_->SetPersistentId(1);
1814
1815 bool highlight = false;
1816 WSError res = window->NotifyHighlightChange(highlight);
1817 EXPECT_EQ(highlight, false);
1818 EXPECT_EQ(res, WSError::WS_OK);
1819 sptr<IWindowHighlightChangeListener> listener = sptr<IWindowHighlightChangeListener>::MakeSptr();
1820 window->RegisterWindowHighlightChangeListeners(listener);
1821 res = window->NotifyHighlightChange(highlight);
1822 EXPECT_EQ(highlight, false);
1823 EXPECT_EQ(res, WSError::WS_OK);
1824 window->UnregisterWindowHighlightChangeListeners(listener);
1825 }
1826
1827 /**
1828 * @tc.name: IsWindowHighlighted
1829 * @tc.desc: IsWindowHighlighted
1830 * @tc.type: FUNC
1831 */
1832 HWTEST_F(WindowSessionImplTest4, IsWindowHighlighted, Function | SmallTest | Level2)
1833 {
1834 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1835 option->SetWindowName("IsWindowHighlighted");
1836 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1837 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1838 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1839 ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1840 window->hostSession_ = session;
1841 window->property_->SetPersistentId(INVALID_SESSION_ID);
1842 bool isHighlighted = false;
1843 window->IsWindowHighlighted(isHighlighted);
1844 ASSERT_EQ(isHighlighted, false);
1845 window->property_->SetPersistentId(1);
1846 window->isHighlighted_ = true;
1847 window->IsWindowHighlighted(isHighlighted);
1848 ASSERT_EQ(isHighlighted, true);
1849 }
1850
1851 } // namespace
1852 } // namespace Rosen
1853 } // namespace OHOS
1854