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
16 #include <gtest/gtest.h>
17 #include "ability_context_impl.h"
18 #include "display_info.h"
19 #include "mock_session.h"
20 #include "mock_uicontent.h"
21 #include "mock_window.h"
22 #include "parameters.h"
23 #include "scene_board_judgement.h"
24 #include "window_session_impl.h"
25 #include "wm_common.h"
26
27 using namespace testing;
28 using namespace testing::ext;
29
30 namespace OHOS {
31 namespace Rosen {
32 class WindowSessionImplTest3 : public testing::Test {
33 public:
34 static void SetUpTestCase();
35 static void TearDownTestCase();
36 void SetUp() override;
37 void TearDown() override;
38 sptr<WindowSessionImpl> window_;
39 };
40
SetUpTestCase()41 void WindowSessionImplTest3::SetUpTestCase() {}
42
TearDownTestCase()43 void WindowSessionImplTest3::TearDownTestCase() {}
44
SetUp()45 void WindowSessionImplTest3::SetUp() {}
46
TearDown()47 void WindowSessionImplTest3::TearDown()
48 {
49 if (window_ != nullptr) {
50 window_->Destroy();
51 }
52 }
53
54 namespace {
GetTestWindowImpl(const std::string & name)55 sptr<WindowSessionImpl> GetTestWindowImpl(const std::string& name)
56 {
57 sptr<WindowOption> option = new (std::nothrow) WindowOption();
58 if (option == nullptr) {
59 return nullptr;
60 }
61 option->SetWindowName(name);
62 sptr<WindowSessionImpl> window = new (std::nothrow) WindowSessionImpl(option);
63 if (window == nullptr) {
64 return nullptr;
65 }
66 SessionInfo sessionInfo = { name, name, name };
67 sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
68 if (session == nullptr) {
69 return nullptr;
70 }
71 window->hostSession_ = session;
72 return window;
73 }
74
75 /**
76 * @tc.name: SetInputEventConsumer
77 * @tc.desc: SetInputEventConsumer01
78 * @tc.type: FUNC
79 */
80 HWTEST_F(WindowSessionImplTest3, SetInputEventConsumer01, Function | SmallTest | Level2)
81 {
82 GTEST_LOG_(INFO) << "WindowSessionImplTest3: SetInputEventConsumer01 start";
83 window_ = GetTestWindowImpl("SetInputEventConsumer01");
84 ASSERT_NE(window_, nullptr);
85 window_->inputEventConsumer_ = nullptr;
86 std::shared_ptr<IInputEventConsumer> inputEventConsumer = std::make_shared<MockInputEventConsumer>();
87 window_->SetInputEventConsumer(inputEventConsumer);
88 ASSERT_NE(window_->inputEventConsumer_, nullptr);
89 GTEST_LOG_(INFO) << "WindowSessionImplTest3: SetInputEventConsumer01 end";
90 }
91
92 /**
93 * @tc.name: SetContinueState
94 * @tc.desc: SetContinueState test
95 * @tc.type: FUNC
96 */
97 HWTEST_F(WindowSessionImplTest3, SetContinueState, Function | SmallTest | Level2)
98 {
99 GTEST_LOG_(INFO) << "WindowSessionImplTest3: SetContinueState start";
100 window_ = GetTestWindowImpl("SetContinueState");
101 ASSERT_NE(window_, nullptr);
102 WMError ret = window_->SetContinueState(static_cast<int32_t>(ContinueState::CONTINUESTATE_INACTIVE));
103 ASSERT_EQ(ret, WMError::WM_OK);
104 ret = window_->SetContinueState(-100);
105 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_PARAM);
106 ret = window_->SetContinueState(3);
107 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_PARAM);
108 GTEST_LOG_(INFO) << "WindowSessionImplTest3: SetContinueState end";
109 }
110
111 /**
112 * @tc.name: GetListeners
113 * @tc.desc: GetListeners01 IDisplayMoveListener
114 * @tc.type: FUNC
115 */
116 HWTEST_F(WindowSessionImplTest3, GetListeners01, Function | SmallTest | Level2)
117 {
118 GTEST_LOG_(INFO) << "WindowSessionImplTest3: GetListeners01 start";
119 window_ = GetTestWindowImpl("GetListeners01");
120 ASSERT_NE(window_, nullptr);
121 window_->displayMoveListeners_.clear();
122 window_->NotifyDisplayMove(0, 100);
123 ASSERT_TRUE(window_->displayMoveListeners_[window_->GetPersistentId()].empty());
124
125 sptr<IDisplayMoveListener> displayMoveListener = new (std::nothrow) MockIDisplayMoveListener();
126 ASSERT_EQ(window_->RegisterDisplayMoveListener(displayMoveListener), WMError::WM_OK);
127 window_->NotifyDisplayMove(0, 100);
128 ASSERT_FALSE(window_->displayMoveListeners_[window_->GetPersistentId()].empty());
129 GTEST_LOG_(INFO) << "WindowSessionImplTest3: GetListeners01 end";
130 }
131
132 /**
133 * @tc.name: RegisterWindowNoInteractionListener
134 * @tc.desc: RegisterWindowNoInteractionListener01
135 * @tc.type: FUNC
136 */
137 HWTEST_F(WindowSessionImplTest3, RegisterWindowNoInteractionListener01, Function | SmallTest | Level2)
138 {
139 GTEST_LOG_(INFO) << "WindowSessionImplTest3: RegisterWindowNoInteractionListener01 start";
140 window_ = GetTestWindowImpl("RegisterWindowNoInteractionListener01");
141 ASSERT_NE(window_, nullptr);
142 ASSERT_EQ(window_->RegisterWindowNoInteractionListener(nullptr), WMError::WM_ERROR_NULLPTR);
143 ASSERT_EQ(window_->UnregisterWindowNoInteractionListener(nullptr), WMError::WM_ERROR_NULLPTR);
144
145 sptr<IWindowNoInteractionListener> windowNoInteractionListenerSptr =
146 new (std::nothrow) MockIWindowNoInteractionListener();
147 ASSERT_EQ(window_->RegisterWindowNoInteractionListener(windowNoInteractionListenerSptr), WMError::WM_OK);
148 ASSERT_EQ(window_->UnregisterWindowNoInteractionListener(windowNoInteractionListenerSptr), WMError::WM_OK);
149 GTEST_LOG_(INFO) << "WindowSessionImplTest3: RegisterWindowNoInteractionListener01 end";
150 }
151
152 /**
153 * @tc.name: SetForceSplitEnable
154 * @tc.desc: SetForceSplitEnable
155 * @tc.type: FUNC
156 */
157 HWTEST_F(WindowSessionImplTest3, SetForceSplitEnable, Function | SmallTest | Level2)
158 {
159 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetForceSplitEnable start";
160 window_ = GetTestWindowImpl("SetForceSplitEnable");
161 ASSERT_NE(window_, nullptr);
162
163 bool isForceSplit = false;
164 std::string homePage = "MainPage";
165 int32_t res = 0;
166 window_->SetForceSplitEnable(isForceSplit, homePage);
167 ASSERT_EQ(res, 0);
168
169 isForceSplit = true;
170 window_->SetForceSplitEnable(isForceSplit, homePage);
171 ASSERT_EQ(res, 0);
172 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetForceSplitEnable end";
173 }
174
175 /**
176 * @tc.name: GetAppForceLandscapeConfig01
177 * @tc.desc: GetAppForceLandscapeConfig
178 * @tc.type: FUNC
179 */
180 HWTEST_F(WindowSessionImplTest3, GetAppForceLandscapeConfig01, Function | SmallTest | Level2)
181 {
182 GTEST_LOG_(INFO) << "WindowSessionImplTest: GetAppForceLandscapeConfig start";
183 window_ = GetTestWindowImpl("GetAppForceLandscapeConfig01");
184 ASSERT_NE(window_, nullptr);
185
186 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
187 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
188 window_->hostSession_ = session;
189 window_->property_->SetPersistentId(1);
190 window_->state_ = WindowState::STATE_CREATED;
191 AppForceLandscapeConfig config = {};
192 auto res = window_->GetAppForceLandscapeConfig(config);
193 if (SceneBoardJudgement::IsSceneBoardEnabled()) {
194 ASSERT_EQ(res, WMError::WM_OK);
195 ASSERT_EQ(config.mode_, 0);
196 ASSERT_EQ(config.homePage_, "");
197 }
198 GTEST_LOG_(INFO) << "WindowSessionImplTest: GetAppForceLandscapeConfig end";
199 }
200
201 /**
202 * @tc.name: GetAppForceLandscapeConfig02
203 * @tc.desc: GetAppForceLandscapeConfig
204 * @tc.type: FUNC
205 */
206 HWTEST_F(WindowSessionImplTest3, GetAppForceLandscapeConfig02, Function | SmallTest | Level2)
207 {
208 GTEST_LOG_(INFO) << "WindowSessionImplTest: GetAppForceLandscapeConfig start";
209 window_ = GetTestWindowImpl("GetAppForceLandscapeConfig");
210 ASSERT_NE(window_, nullptr);
211
212 AppForceLandscapeConfig config = {};
213 window_->hostSession_ = nullptr;
214 auto res = window_->GetAppForceLandscapeConfig(config);
215 if (SceneBoardJudgement::IsSceneBoardEnabled()) {
216 ASSERT_EQ(res, WMError::WM_ERROR_INVALID_WINDOW);
217 ASSERT_EQ(config.mode_, 0);
218 ASSERT_EQ(config.homePage_, "");
219 }
220 GTEST_LOG_(INFO) << "WindowSessionImplTest: GetAppForceLandscapeConfig end";
221 }
222
223 /**
224 * @tc.name: IsSceneBoardEnabled
225 * @tc.desc: IsSceneBoardEnabled
226 * @tc.type: FUNC
227 */
228 HWTEST_F(WindowSessionImplTest3, IsSceneBoardEnabled, TestSize.Level1)
229 {
230 GTEST_LOG_(INFO) << "WindowSessionImplTest: IsSceneBoardEnabled start";
231 window_ = GetTestWindowImpl("IsSceneBoardEnabled");
232 ASSERT_NE(window_, nullptr);
233
234 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
235 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
236 window_->hostSession_ = session;
237 window_->property_->SetPersistentId(1);
238 window_->state_ = WindowState::STATE_CREATED;
239 bool result = SceneBoardJudgement::IsSceneBoardEnabled();
240 ASSERT_EQ(result, window_->IsSceneBoardEnabled());
241 GTEST_LOG_(INFO) << "WindowSessionImplTest: IsSceneBoardEnabled end";
242 }
243
244 /**
245 * @tc.name: IsFocused
246 * @tc.desc: IsFocused
247 * @tc.type: FUNC
248 */
249 HWTEST_F(WindowSessionImplTest3, IsFocused, Function | SmallTest | Level2)
250 {
251 GTEST_LOG_(INFO) << "WindowSessionImplTest: IsFocused start";
252 window_ = GetTestWindowImpl("IsFocused");
253 ASSERT_NE(window_, nullptr);
254 window_->property_->SetPersistentId(INVALID_SESSION_ID);
255 auto ret = window_->IsFocused();
256 ASSERT_EQ(ret, false);
257
258 window_->property_->SetPersistentId(1);
259 window_->state_ = WindowState::STATE_CREATED;
260 window_->UpdateFocus(true);
261 ret = window_->IsFocused();
262 ASSERT_EQ(ret, true);
263 GTEST_LOG_(INFO) << "WindowSessionImplTest: IsFocused end";
264 }
265
266 /**
267 * @tc.name: IsNotifyInteractiveDuplicative
268 * @tc.desc: IsNotifyInteractiveDuplicative
269 * @tc.type: FUNC
270 */
271 HWTEST_F(WindowSessionImplTest3, IsNotifyInteractiveDuplicative, Function | SmallTest | Level2)
272 {
273 GTEST_LOG_(INFO) << "WindowSessionImplTest: IsNotifyInteractiveDuplicative start";
274 window_ = GetTestWindowImpl("IsNotifyInteractiveDuplicative");
275 ASSERT_NE(window_, nullptr);
276 window_->hasFirstNotifyInteractive_ = true;
277 window_->interactive_ = true;
278 window_->NotifyForegroundInteractiveStatus(true);
279 auto ret = window_->IsNotifyInteractiveDuplicative(true);
280 ASSERT_EQ(ret, true);
281 GTEST_LOG_(INFO) << "IsNotifyInteractiveDuplicative: IsNotifyInteractiveDuplicative end";
282 }
283
284 /**
285 * @tc.name: SetMainWindowTopmost
286 * @tc.desc: SetMainWindowTopmost
287 * @tc.type: FUNC
288 */
289 HWTEST_F(WindowSessionImplTest3, SetMainWindowTopmost, Function | SmallTest | Level2)
290 {
291 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetMainWindowTopmost start";
292 window_ = GetTestWindowImpl("SetMainWindowTopmost");
293 ASSERT_NE(window_, nullptr);
294 window_->property_->SetPersistentId(INVALID_SESSION_ID);
295 auto ret = window_->SetMainWindowTopmost(true);
296 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_WINDOW);
297 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetMainWindowTopmost end";
298 }
299
300 /**
301 * @tc.name: GetRequestedOrientation
302 * @tc.desc: GetRequestedOrientation
303 * @tc.type: FUNC
304 */
305 HWTEST_F(WindowSessionImplTest3, GetRequestedOrientation, Function | SmallTest | Level2)
306 {
307 GTEST_LOG_(INFO) << "WindowSessionImplTest: GetRequestedOrientation start";
308 window_ = GetTestWindowImpl("GetRequestedOrientation");
309 ASSERT_NE(window_, nullptr);
310 window_->property_->SetPersistentId(INVALID_SESSION_ID);
311 auto ret = window_->GetRequestedOrientation();
312 ASSERT_EQ(ret, Orientation::UNSPECIFIED);
313 GTEST_LOG_(INFO) << "WindowSessionImplTest: GetRequestedOrientation end";
314 }
315
316 /**
317 * @tc.name: SetDecorVisible
318 * @tc.desc: SetDecorVisible
319 * @tc.type: FUNC
320 */
321 HWTEST_F(WindowSessionImplTest3, SetDecorVisible, Function | SmallTest | Level2)
322 {
323 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetDecorVisible start";
324 window_ = GetTestWindowImpl("SetDecorVisible");
325 ASSERT_NE(window_, nullptr);
326 window_->property_->SetPersistentId(INVALID_SESSION_ID);
327 auto ret = window_->SetDecorVisible(true);
328 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_WINDOW);
329 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetDecorVisible end";
330 }
331
332 /**
333 * @tc.name: SetWindowModal
334 * @tc.desc: SetWindowModal
335 * @tc.type: FUNC
336 */
337 HWTEST_F(WindowSessionImplTest3, SetWindowModal, Function | SmallTest | Level2)
338 {
339 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetWindowModal start";
340 window_ = GetTestWindowImpl("SetWindowModal");
341 ASSERT_NE(window_, nullptr);
342 window_->property_->SetPersistentId(INVALID_SESSION_ID);
343 auto ret = window_->SetWindowModal(true);
344 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_WINDOW);
345 ret = window_->SetWindowModal(false);
346 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_WINDOW);
347
348 window_->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
349 window_->property_->SetPersistentId(1);
350 window_->state_ = WindowState::STATE_CREATED;
351 window_->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
352 ret = window_->SetWindowModal(true);
353 ASSERT_EQ(WMError::WM_OK, ret);
354 ret = window_->SetWindowModal(false);
355 ASSERT_EQ(WMError::WM_OK, ret);
356
357 window_->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
358 ret = window_->SetWindowModal(true);
359 ASSERT_EQ(WMError::WM_ERROR_INVALID_CALLING, ret);
360 ret = window_->SetWindowModal(false);
361 ASSERT_EQ(WMError::WM_ERROR_INVALID_CALLING, ret);
362
363 window_->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
364 ret = window_->SetWindowModal(true);
365 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_CALLING);
366 ret = window_->SetWindowModal(false);
367 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_CALLING);
368
369 window_->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
370 ret = window_->SetWindowModal(false);
371 ASSERT_EQ(ret, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
372 ret = window_->SetWindowModal(true);
373 ASSERT_EQ(ret, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
374 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetWindowModal end";
375 }
376
377 /**
378 * @tc.name: SetDecorButtonStyle
379 * @tc.desc: SetDecorButtonStyle
380 * @tc.type: FUNC
381 */
382 HWTEST_F(WindowSessionImplTest3, SetDecorButtonStyle, Function | SmallTest | Level2)
383 {
384 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetDecorButtonStyle start";
385 window_ = GetTestWindowImpl("SetDecorButtonStyle");
386 ASSERT_NE(window_, nullptr);
387 window_->property_->SetPersistentId(INVALID_SESSION_ID);
388 DecorButtonStyle decorButtonStyle;
389 auto ret = window_->SetDecorButtonStyle(decorButtonStyle);
390 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_WINDOW);
391 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetDecorButtonStyle end";
392 }
393
394 /**
395 * @tc.name: GetDecorButtonStyle
396 * @tc.desc: GetDecorButtonStyle
397 * @tc.type: FUNC
398 */
399 HWTEST_F(WindowSessionImplTest3, GetDecorButtonStyle, Function | SmallTest | Level2)
400 {
401 GTEST_LOG_(INFO) << "WindowSessionImplTest: GetDecorButtonStyle start";
402 window_ = GetTestWindowImpl("GetDecorButtonStyle");
403 ASSERT_NE(window_, nullptr);
404 window_->property_->SetPersistentId(INVALID_SESSION_ID);
405 DecorButtonStyle decorButtonStyle;
406 auto ret = window_->GetDecorButtonStyle(decorButtonStyle);
407 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_WINDOW);
408 GTEST_LOG_(INFO) << "WindowSessionImplTest: GetDecorButtonStyle end";
409 }
410
411 /**
412 * @tc.name: RegisterMainWindowCloseListeners
413 * @tc.desc: RegisterMainWindowCloseListeners
414 * @tc.type: FUNC
415 */
416 HWTEST_F(WindowSessionImplTest3, RegisterMainWindowCloseListeners, Function | SmallTest | Level2)
417 {
418 GTEST_LOG_(INFO) << "WindowSessionImplTest: RegisterMainWindowCloseListeners start";
419 window_ = GetTestWindowImpl("RegisterMainWindowCloseListeners");
420 ASSERT_NE(window_, nullptr);
421 window_->property_->SetPersistentId(INVALID_SESSION_ID);
422 sptr<IMainWindowCloseListener> listener = sptr<IMainWindowCloseListener>::MakeSptr();
423 ASSERT_NE(listener, nullptr);
424 auto ret = window_->RegisterMainWindowCloseListeners(listener);
425 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_WINDOW);
426
427 window_->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
428 window_->property_->SetPersistentId(1);
429 window_->state_ = WindowState::STATE_CREATED;
430 ret = window_->RegisterMainWindowCloseListeners(listener);
431 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_CALLING);
432
433 window_->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
434 window_->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
435 ret = window_->RegisterMainWindowCloseListeners(listener);
436 ASSERT_EQ(ret, WMError::WM_OK);
437
438 window_->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
439 ret = window_->RegisterMainWindowCloseListeners(listener);
440 ASSERT_EQ(ret, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
441 GTEST_LOG_(INFO) << "WindowSessionImplTest: RegisterMainWindowCloseListeners end";
442 }
443
444 /**
445 * @tc.name: UnregisterMainWindowCloseListeners
446 * @tc.desc: UnregisterMainWindowCloseListeners
447 * @tc.type: FUNC
448 */
449 HWTEST_F(WindowSessionImplTest3, UnregisterMainWindowCloseListeners, Function | SmallTest | Level2)
450 {
451 GTEST_LOG_(INFO) << "WindowSessionImplTest: UnregisterMainWindowCloseListeners start";
452 window_ = GetTestWindowImpl("UnregisterMainWindowCloseListeners");
453 ASSERT_NE(window_, nullptr);
454 window_->property_->SetPersistentId(INVALID_SESSION_ID);
455 sptr<IMainWindowCloseListener> listener = sptr<IMainWindowCloseListener>::MakeSptr();
456 ASSERT_NE(listener, nullptr);
457 auto ret = window_->UnregisterMainWindowCloseListeners(listener);
458 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_WINDOW);
459
460 window_->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
461 window_->property_->SetPersistentId(1);
462 window_->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
463 window_->state_ = WindowState::STATE_CREATED;
464 ret = window_->UnregisterMainWindowCloseListeners(listener);
465 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_CALLING);
466
467 window_->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
468 ret = window_->UnregisterMainWindowCloseListeners(listener);
469 ASSERT_EQ(ret, WMError::WM_OK);
470
471 window_->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
472 ret = window_->UnregisterMainWindowCloseListeners(listener);
473 ASSERT_EQ(ret, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
474 GTEST_LOG_(INFO) << "WindowSessionImplTest: UnregisterMainWindowCloseListeners end";
475 }
476
477 /**
478 * @tc.name: RegisterWindowWillCloseListeners
479 * @tc.desc: RegisterWindowWillCloseListeners
480 * @tc.type: FUNC
481 */
482 HWTEST_F(WindowSessionImplTest3, RegisterWindowWillCloseListeners, Function | SmallTest | Level2)
483 {
484 GTEST_LOG_(INFO) << "WindowSessionImplTest: RegisterWindowWillCloseListeners start";
485 window_ = GetTestWindowImpl("RegisterWindowWillCloseListeners");
486 ASSERT_NE(window_, nullptr);
487 window_->property_->SetPersistentId(INVALID_SESSION_ID);
488 sptr<IWindowWillCloseListener> listener = sptr<IWindowWillCloseListener>::MakeSptr();
489 auto ret = window_->RegisterWindowWillCloseListeners(listener);
490 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_WINDOW);
491
492 window_->property_->SetPersistentId(1);
493 window_->state_ = WindowState::STATE_CREATED;
494 window_->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
495 ret = window_->RegisterWindowWillCloseListeners(listener);
496 ASSERT_EQ(ret, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
497
498 window_->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
499 window_->property_->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
500 ret = window_->RegisterWindowWillCloseListeners(listener);
501 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_CALLING);
502
503 window_->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
504 ret = window_->RegisterWindowWillCloseListeners(listener);
505 ASSERT_EQ(ret, WMError::WM_OK);
506 GTEST_LOG_(INFO) << "WindowSessionImplTest: RegisterWindowWillCloseListeners end";
507 }
508
509 /**
510 * @tc.name: UnRegisterWindowWillCloseListeners
511 * @tc.desc: UnRegisterWindowWillCloseListeners
512 * @tc.type: FUNC
513 */
514 HWTEST_F(WindowSessionImplTest3, UnRegisterWindowWillCloseListeners, Function | SmallTest | Level2)
515 {
516 GTEST_LOG_(INFO) << "WindowSessionImplTest: UnRegisterWindowWillCloseListeners start";
517 window_ = GetTestWindowImpl("UnRegisterWindowWillCloseListeners");
518 ASSERT_NE(window_, nullptr);
519 window_->property_->SetPersistentId(INVALID_SESSION_ID);
520 sptr<IWindowWillCloseListener> listener = sptr<IWindowWillCloseListener>::MakeSptr();
521 auto ret = window_->UnRegisterWindowWillCloseListeners(listener);
522 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_WINDOW);
523
524 window_->property_->SetPersistentId(1);
525 window_->state_ = WindowState::STATE_CREATED;
526 window_->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
527 ret = window_->UnRegisterWindowWillCloseListeners(listener);
528 ASSERT_EQ(ret, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
529
530 window_->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
531 window_->property_->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
532 ret = window_->UnRegisterWindowWillCloseListeners(listener);
533 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_CALLING);
534
535 window_->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
536 ret = window_->UnRegisterWindowWillCloseListeners(listener);
537 ASSERT_EQ(ret, WMError::WM_OK);
538 GTEST_LOG_(INFO) << "WindowSessionImplTest: UnRegisterWindowWillCloseListeners end";
539 }
540
541 /**
542 * @tc.name: RegisterSwitchFreeMultiWindowListener
543 * @tc.desc: RegisterSwitchFreeMultiWindowListener
544 * @tc.type: FUNC
545 */
546 HWTEST_F(WindowSessionImplTest3, RegisterSwitchFreeMultiWindowListener, Function | SmallTest | Level2)
547 {
548 GTEST_LOG_(INFO) << "WindowSessionImplTest: RegisterSwitchFreeMultiWindowListener start";
549 window_ = GetTestWindowImpl("RegisterSwitchFreeMultiWindowListener");
550 ASSERT_NE(window_, nullptr);
551 sptr<ISwitchFreeMultiWindowListener> listener = sptr<ISwitchFreeMultiWindowListener>::MakeSptr();
552 ASSERT_NE(listener, nullptr);
553 window_->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
554 auto ret = window_->RegisterSwitchFreeMultiWindowListener(listener);
555 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_CALLING);
556 GTEST_LOG_(INFO) << "WindowSessionImplTest: RegisterSwitchFreeMultiWindowListener end";
557 }
558
559 /**
560 * @tc.name: UnregisterSwitchFreeMultiWindowListener
561 * @tc.desc: UnregisterSwitchFreeMultiWindowListener
562 * @tc.type: FUNC
563 */
564 HWTEST_F(WindowSessionImplTest3, UnregisterSwitchFreeMultiWindowListener, Function | SmallTest | Level2)
565 {
566 GTEST_LOG_(INFO) << "WindowSessionImplTest: UnregisterSwitchFreeMultiWindowListener start";
567 window_ = GetTestWindowImpl("UnregisterSwitchFreeMultiWindowListener");
568 ASSERT_NE(window_, nullptr);
569 sptr<ISwitchFreeMultiWindowListener> listener = sptr<ISwitchFreeMultiWindowListener>::MakeSptr();
570 ASSERT_NE(listener, nullptr);
571 window_->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
572 auto ret = window_->UnregisterSwitchFreeMultiWindowListener(listener);
573 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_CALLING);
574 window_->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
575 ret = window_->UnregisterSwitchFreeMultiWindowListener(listener);
576 ASSERT_EQ(ret, WMError::WM_OK);
577 GTEST_LOG_(INFO) << "WindowSessionImplTest: UnregisterSwitchFreeMultiWindowListener end";
578 }
579
580 /**
581 * @tc.name: SetSplitButtonVisible
582 * @tc.desc: SetSplitButtonVisible
583 * @tc.type: FUNC
584 */
585 HWTEST_F(WindowSessionImplTest3, SetSplitButtonVisible, Function | SmallTest | Level2)
586 {
587 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetSplitButtonVisible start";
588 window_ = GetTestWindowImpl("SetSplitButtonVisible");
589 ASSERT_NE(window_, nullptr);
590 auto ret = window_->SetSplitButtonVisible(true);
591 ASSERT_EQ(ret, WSError::WS_OK);
592 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetSplitButtonVisible end";
593 }
594
595 /**
596 * @tc.name: NotifyNoInteractionTimeout
597 * @tc.desc: NotifyNoInteractionTimeout
598 * @tc.type: FUNC
599 */
600 HWTEST_F(WindowSessionImplTest3, NotifyNoInteractionTimeout, Function | SmallTest | Level2)
601 {
602 GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyNoInteractionTimeout start";
603 window_ = GetTestWindowImpl("NotifyNoInteractionTimeout");
604 ASSERT_NE(window_, nullptr);
605 IWindowNoInteractionListenerSptr listener = nullptr;
606 auto ret = window_->NotifyNoInteractionTimeout(listener);
607 ASSERT_EQ(ret, WSError::WS_ERROR_NULLPTR);
608 GTEST_LOG_(INFO) << "WindowSessionImplTest: NotifyNoInteractionTimeout end";
609 }
610
611 /**
612 * @tc.name: IsVerticalOrientation
613 * @tc.desc: IsVerticalOrientation
614 * @tc.type: FUNC
615 */
616 HWTEST_F(WindowSessionImplTest3, IsVerticalOrientation, Function | SmallTest | Level2)
617 {
618 GTEST_LOG_(INFO) << "WindowSessionImplTest: IsVerticalOrientation start";
619 window_ = GetTestWindowImpl("IsVerticalOrientation");
620 ASSERT_NE(window_, nullptr);
621 Orientation orientation = Orientation::VERTICAL;
622 auto ret = window_->IsVerticalOrientation(orientation);
623 ASSERT_EQ(ret, true);
624 orientation = Orientation::REVERSE_VERTICAL;
625 ret = window_->IsVerticalOrientation(orientation);
626 ASSERT_EQ(ret, true);
627 orientation = Orientation::SENSOR_VERTICAL;
628 ret = window_->IsVerticalOrientation(orientation);
629 ASSERT_EQ(ret, true);
630 orientation = Orientation::AUTO_ROTATION_PORTRAIT_RESTRICTED;
631 ret = window_->IsVerticalOrientation(orientation);
632 ASSERT_EQ(ret, true);
633 orientation = Orientation::USER_ROTATION_PORTRAIT;
634 ret = window_->IsVerticalOrientation(orientation);
635 ASSERT_EQ(ret, true);
636 orientation = Orientation::USER_ROTATION_PORTRAIT_INVERTED;
637 ret = window_->IsVerticalOrientation(orientation);
638 ASSERT_EQ(ret, true);
639 orientation = Orientation::UNSPECIFIED;
640 ret = window_->IsVerticalOrientation(orientation);
641 ASSERT_EQ(ret, false);
642 GTEST_LOG_(INFO) << "WindowSessionImplTest: IsVerticalOrientation end";
643 }
644
645 /**
646 * @tc.name: MarkProcessed
647 * @tc.desc: MarkProcessed
648 * @tc.type: FUNC
649 */
650 HWTEST_F(WindowSessionImplTest3, MarkProcessed, Function | SmallTest | Level2)
651 {
652 GTEST_LOG_(INFO) << "WindowSessionImplTest: MarkProcessed start";
653 window_ = GetTestWindowImpl("MarkProcessed");
654 ASSERT_NE(window_, nullptr);
655 window_->property_->SetPersistentId(1);
656 window_->state_ = WindowState::STATE_CREATED;
657 auto ret = window_->MarkProcessed(1);
658 ASSERT_EQ(ret, WSError::WS_OK);
659 GTEST_LOG_(INFO) << "WindowSessionImplTest: MarkProcessed end";
660 }
661
662 /**
663 * @tc.name: UpdateRectForOtherReasonTask
664 * @tc.desc: UpdateRectForOtherReasonTask
665 * @tc.type: FUNC
666 */
667 HWTEST_F(WindowSessionImplTest3, UpdateRectForOtherReasonTask, Function | SmallTest | Level2)
668 {
669 GTEST_LOG_(INFO) << "WindowSessionImplTest: UpdateRectForOtherReasonTask start";
670 window_ = GetTestWindowImpl("UpdateRectForOtherReasonTask");
671 ASSERT_NE(window_, nullptr);
672 Rect wmRect = { 0, 0, 0, 0 };
673 Rect preRect = { 0, 0, 0, 0 };
674 WindowSizeChangeReason wmReason = WindowSizeChangeReason::UNDEFINED;
675 std::shared_ptr<RSTransaction> rsTransaction = nullptr;
676 window_->lastSizeChangeReason_ = WindowSizeChangeReason::UNDEFINED;
677 window_->postTaskDone_ = false;
678 window_->UpdateRectForOtherReasonTask(wmRect, preRect, wmReason, rsTransaction);
679 ASSERT_EQ(window_->postTaskDone_, true);
680 window_->UpdateRectForOtherReasonTask(wmRect, preRect, wmReason, rsTransaction);
681 window_->postTaskDone_ = false;
682 wmRect.posX_ = 1;
683 window_->UpdateRectForOtherReasonTask(wmRect, preRect, wmReason, rsTransaction);
684 ASSERT_EQ(window_->postTaskDone_, true);
685
686 window_->handler_ = nullptr;
687 window_->UpdateRectForOtherReason(wmRect, preRect, wmReason, rsTransaction);
688 GTEST_LOG_(INFO) << "WindowSessionImplTest: UpdateRectForOtherReasonTask end";
689 }
690
691 /**
692 * @tc.name: CopyUniqueDensityParameter
693 * @tc.desc: CopyUniqueDensityParameter
694 * @tc.type: FUNC
695 */
696 HWTEST_F(WindowSessionImplTest3, CopyUniqueDensityParameter, Function | SmallTest | Level2)
697 {
698 GTEST_LOG_(INFO) << "WindowSessionImplTest: CopyUniqueDensityParameter start";
699 window_ = GetTestWindowImpl("CopyUniqueDensityParameter");
700 ASSERT_NE(window_, nullptr);
701 sptr<WindowSessionImpl> parentWindow = GetTestWindowImpl("CopyUniqueDensityParameter01");
702 ASSERT_NE(parentWindow, nullptr);
703 window_->useUniqueDensity_ = false;
704 window_->virtualPixelRatio_ = 1.0f;
705 parentWindow->useUniqueDensity_ = true;
706 parentWindow->virtualPixelRatio_ = 1.0f;
707 window_->CopyUniqueDensityParameter(parentWindow);
708 ASSERT_EQ(window_->useUniqueDensity_, true);
709 parentWindow = nullptr;
710 window_->CopyUniqueDensityParameter(parentWindow);
711 GTEST_LOG_(INFO) << "WindowSessionImplTest: CopyUniqueDensityParameter end";
712 }
713
714 /**
715 * @tc.name: SetRaiseByClickEnabled
716 * @tc.desc: SetRaiseByClickEnabled
717 * @tc.type: FUNC
718 */
719 HWTEST_F(WindowSessionImplTest3, SetRaiseByClickEnabled, Function | SmallTest | Level2)
720 {
721 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetRaiseByClickEnabled start";
722 window_ = GetTestWindowImpl("SetRaiseByClickEnabled");
723 ASSERT_NE(window_, nullptr);
724 window_->property_->parentPersistentId_ = 2;
725 window_->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
726 window_->state_ = WindowState::STATE_SHOWN;
727 window_->property_->SetPersistentId(1);
728 auto ret = window_->SetRaiseByClickEnabled(true);
729 ASSERT_EQ(ret, WMError::WM_OK);
730 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetRaiseByClickEnabled end";
731 }
732
733 /**
734 * @tc.name: SetSubWindowModal
735 * @tc.desc: SetSubWindowModal
736 * @tc.type: FUNC
737 */
738 HWTEST_F(WindowSessionImplTest3, SetSubWindowModal, Function | SmallTest | Level2)
739 {
740 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetSubWindowModal start";
741 window_ = GetTestWindowImpl("SetSubWindowModal");
742 ASSERT_NE(window_, nullptr);
743 window_->property_->SetPersistentId(1);
744 window_->state_ = WindowState::STATE_CREATED;
745 window_->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
746 ModalityType modalityType = ModalityType::APPLICATION_MODALITY;
747 window_->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
748 window_->windowSystemConfig_.freeMultiWindowEnable_ = false;
749 window_->windowSystemConfig_.freeMultiWindowSupport_ = false;
750 auto ret = window_->SetSubWindowModal(true, modalityType);
751 ASSERT_EQ(ret, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
752
753 window_->vsyncStation_ = nullptr;
754 window_->ClearVsyncStation();
755 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetSubWindowModal end";
756 }
757
758 /**
759 * @tc.name: UpdateFrameLayoutCallbackIfNeeded
760 * @tc.desc: UpdateFrameLayoutCallbackIfNeeded
761 * @tc.type: FUNC
762 */
763 HWTEST_F(WindowSessionImplTest3, UpdateFrameLayoutCallbackIfNeeded, Function | SmallTest | Level2)
764 {
765 GTEST_LOG_(INFO) << "WindowSessionImplTest: UpdateFrameLayoutCallbackIfNeeded start";
766 window_ = GetTestWindowImpl("UpdateFrameLayoutCallbackIfNeeded");
767 ASSERT_NE(window_, nullptr);
768 window_->enableFrameLayoutFinishCb_ = false;
769 WindowSizeChangeReason wmReason = WindowSizeChangeReason::FULL_TO_SPLIT;
770 window_->UpdateFrameLayoutCallbackIfNeeded(wmReason);
771 ASSERT_EQ(window_->enableFrameLayoutFinishCb_, true);
772
773 window_->enableFrameLayoutFinishCb_ = false;
774 wmReason = WindowSizeChangeReason::SPLIT_TO_FULL;
775 window_->UpdateFrameLayoutCallbackIfNeeded(wmReason);
776 ASSERT_EQ(window_->enableFrameLayoutFinishCb_, true);
777
778 window_->enableFrameLayoutFinishCb_ = false;
779 wmReason = WindowSizeChangeReason::FULL_TO_FLOATING;
780 window_->UpdateFrameLayoutCallbackIfNeeded(wmReason);
781 ASSERT_EQ(window_->enableFrameLayoutFinishCb_, true);
782
783 window_->enableFrameLayoutFinishCb_ = false;
784 wmReason = WindowSizeChangeReason::FLOATING_TO_FULL;
785 window_->UpdateFrameLayoutCallbackIfNeeded(wmReason);
786 ASSERT_EQ(window_->enableFrameLayoutFinishCb_, true);
787
788 window_->enableFrameLayoutFinishCb_ = false;
789 wmReason = WindowSizeChangeReason::DRAG_END;
790 window_->windowSystemConfig_.freeMultiWindowEnable_ = true;
791 window_->windowSystemConfig_.freeMultiWindowSupport_ = true;
792 window_->UpdateFrameLayoutCallbackIfNeeded(wmReason);
793 ASSERT_EQ(window_->enableFrameLayoutFinishCb_, true);
794
795 window_->windowSystemConfig_.freeMultiWindowSupport_ = false;
796 window_->UpdateFrameLayoutCallbackIfNeeded(wmReason);
797 GTEST_LOG_(INFO) << "WindowSessionImplTest: UpdateFrameLayoutCallbackIfNeeded end";
798 }
799
800 /**
801 * @tc.name: SetRequestedOrientation
802 * @tc.desc: SetRequestedOrientation
803 * @tc.type: FUNC
804 */
805 HWTEST_F(WindowSessionImplTest3, SetRequestedOrientation, Function | SmallTest | Level2)
806 {
807 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetRequestedOrientation start";
808 window_ = GetTestWindowImpl("SetRequestedOrientation");
809 ASSERT_NE(window_, nullptr);
810 window_->property_->SetPersistentId(1);
811 window_->state_ = WindowState::STATE_CREATED;
812 Orientation orientation = Orientation::VERTICAL;
813 window_->property_->requestedOrientation_ = Orientation::VERTICAL;
814 window_->SetRequestedOrientation(orientation);
815 orientation = Orientation::USER_ROTATION_PORTRAIT;
816 window_->SetRequestedOrientation(orientation);
817 auto ret = window_->GetRequestedOrientation();
818 ASSERT_EQ(ret, orientation);
819 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetRequestedOrientation end";
820 }
821
822 /**
823 * @tc.name: SetTargetAPIVersion
824 * @tc.desc: SetTargetAPIVersion
825 * @tc.type: FUNC
826 */
827 HWTEST_F(WindowSessionImplTest3, SetTargetAPIVersion, Function | SmallTest | Level2)
828 {
829 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetTargetAPIVersion start";
830 window_ = GetTestWindowImpl("SetAPPWindowIcon");
831 ASSERT_NE(window_, nullptr);
832 uint32_t version = 14;
833 window_->SetTargetAPIVersion(version);
834 EXPECT_EQ(version, window_->GetTargetAPIVersion());
835 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetTargetAPIVersion end";
836 }
837
838 /**
839 * @tc.name: SetAPPWindowIcon
840 * @tc.desc: SetAPPWindowIcon
841 * @tc.type: FUNC
842 */
843 HWTEST_F(WindowSessionImplTest3, GetTargetAPIVersion, Function | SmallTest | Level2)
844 {
845 GTEST_LOG_(INFO) << "WindowSessionImplTest: GetTargetAPIVersion start";
846 window_ = GetTestWindowImpl("GetTargetAPIVersion");
847 ASSERT_NE(window_, nullptr);
848 EXPECT_EQ(0, window_->GetTargetAPIVersion());
849 GTEST_LOG_(INFO) << "WindowSessionImplTest: GetTargetAPIVersion end";
850 }
851
852 /**
853 * @tc.name: SetAPPWindowIcon
854 * @tc.desc: SetAPPWindowIcon
855 * @tc.type: FUNC
856 */
857 HWTEST_F(WindowSessionImplTest3, SetAPPWindowIcon, Function | SmallTest | Level2)
858 {
859 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetAPPWindowIcon start";
860 window_ = GetTestWindowImpl("SetAPPWindowIcon");
861 ASSERT_NE(window_, nullptr);
862 window_->uiContent_ = nullptr;
863 std::shared_ptr<Media::PixelMap> icon = std::make_shared<Media::PixelMap>();
864 ASSERT_NE(icon, nullptr);
865 auto ret = window_->SetAPPWindowIcon(icon);
866 ASSERT_EQ(ret, WMError::WM_ERROR_NULLPTR);
867 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetAPPWindowIcon end";
868 }
869
870 /**
871 * @tc.name: SetBackgroundColor
872 * @tc.desc: SetBackgroundColor
873 * @tc.type: FUNC
874 */
875 HWTEST_F(WindowSessionImplTest3, SetBackgroundColor, Function | SmallTest | Level2)
876 {
877 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetBackgroundColor start";
878 window_ = GetTestWindowImpl("SetBackgroundColor");
879 ASSERT_NE(window_, nullptr);
880 window_->property_->SetPersistentId(1);
881 window_->state_ = WindowState::STATE_CREATED;
882 std::string color = "";
883 auto ret = window_->SetBackgroundColor(color);
884 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_PARAM);
885
886 color = "#FF0000";
887 ret = window_->SetBackgroundColor(color);
888 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_OPERATION);
889 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetBackgroundColor end";
890 }
891
892 /**
893 * @tc.name: Find
894 * @tc.desc: Find
895 * @tc.type: FUNC
896 */
897 HWTEST_F(WindowSessionImplTest3, Find, Function | SmallTest | Level2)
898 {
899 GTEST_LOG_(INFO) << "WindowSessionImplTest: Find start";
900 window_ = GetTestWindowImpl("Find");
901 ASSERT_NE(window_, nullptr);
902 window_->windowSessionMap_.clear();
903 std::string name = "Find";
904 sptr<WindowSessionImpl> window1 = GetTestWindowImpl("Find1");
905 ASSERT_NE(window1, nullptr);
906 window_->windowSessionMap_.insert(std::make_pair(name, std::make_pair(1, window1)));
907 auto ret = window_->Find(name);
908 ASSERT_NE(ret, nullptr);
909 GTEST_LOG_(INFO) << "WindowSessionImplTest: Find end";
910 }
911
912 /**
913 * @tc.name: RegisterWindowTitleButtonRectChangeListener
914 * @tc.desc: RegisterWindowTitleButtonRectChangeListener
915 * @tc.type: FUNC
916 */
917 HWTEST_F(WindowSessionImplTest3, RegisterWindowTitleButtonRectChangeListener, Function | SmallTest | Level2)
918 {
919 GTEST_LOG_(INFO) << "WindowSessionImplTest: RegisterWindowTitleButtonRectChangeListener start";
920 window_ = GetTestWindowImpl("RegisterWindowTitleButtonRectChangeListener");
921 ASSERT_NE(window_, nullptr);
922 window_->property_->SetPersistentId(1);
923 window_->state_ = WindowState::STATE_SHOWN;
924 window_->interactive_ = true;
925 window_->hasFirstNotifyInteractive_ = true;
926 window_->NotifyForegroundInteractiveStatus(true);
927
928 sptr<IWindowTitleButtonRectChangedListener> listener = nullptr;
929 auto ret = window_->RegisterWindowTitleButtonRectChangeListener(listener);
930 ASSERT_EQ(ret, WMError::WM_ERROR_NULLPTR);
931 GTEST_LOG_(INFO) << "WindowSessionImplTest: RegisterWindowTitleButtonRectChangeListener end";
932 }
933
934 /**
935 * @tc.name: GetUIContentWithId
936 * @tc.desc: GetUIContentWithId
937 * @tc.type: FUNC
938 */
939 HWTEST_F(WindowSessionImplTest3, GetUIContentWithId, Function | SmallTest | Level2)
940 {
941 GTEST_LOG_(INFO) << "WindowSessionImplTest: GetUIContentWithId start";
942 window_ = GetTestWindowImpl("GetUIContentWithId");
943 ASSERT_NE(window_, nullptr);
944 window_->windowSessionMap_.clear();
945 std::string name = "GetUIContentWithId";
946 sptr<WindowSessionImpl> window1 = GetTestWindowImpl("GetUIContentWithId1");
947 ASSERT_NE(window1, nullptr);
948 window_->windowSessionMap_.insert(std::make_pair(name, std::make_pair(1, window1)));
949 auto ret = window_->GetUIContentWithId(1);
950 ASSERT_EQ(ret, nullptr);
951 GTEST_LOG_(INFO) << "WindowSessionImplTest: GetUIContentWithId end";
952 }
953
954 /**
955 * @tc.name: UnregisterWindowRectChangeListener
956 * @tc.desc: UnregisterWindowRectChangeListener
957 * @tc.type: FUNC
958 */
959 HWTEST_F(WindowSessionImplTest3, UnregisterWindowRectChangeListener, Function | SmallTest | Level2)
960 {
961 GTEST_LOG_(INFO) << "WindowSessionImplTest: UnregisterWindowRectChangeListener start";
962 window_ = GetTestWindowImpl("UnregisterWindowRectChangeListener");
963 ASSERT_NE(window_, nullptr);
964 window_->property_->SetPersistentId(1);
965 window_->state_ = WindowState::STATE_SHOWN;
966 window_->windowRectChangeListeners_.clear();
967 sptr<IWindowRectChangeListener> listener = nullptr;
968 auto ret = window_->UnregisterWindowRectChangeListener(listener);
969 ASSERT_EQ(ret, WMError::WM_ERROR_NULLPTR);
970 GTEST_LOG_(INFO) << "WindowSessionImplTest: UnregisterWindowRectChangeListener end";
971 }
972
973 /**
974 * @tc.name: IsFloatingWindowAppType
975 * @tc.desc: IsFloatingWindowAppType
976 * @tc.type: FUNC
977 */
978 HWTEST_F(WindowSessionImplTest3, IsFloatingWindowAppType, Function | SmallTest | Level2)
979 {
980 GTEST_LOG_(INFO) << "WindowSessionImplTest: IsFloatingWindowAppType start";
981 window_ = GetTestWindowImpl("IsFloatingWindowAppType");
982 ASSERT_NE(window_, nullptr);
983 window_->property_->SetPersistentId(1);
984 window_->property_->isFloatingWindowAppType_ = true;
985 window_->state_ = WindowState::STATE_CREATED;
986 auto ret = window_->IsFloatingWindowAppType();
987 ASSERT_EQ(ret, true);
988 GTEST_LOG_(INFO) << "WindowSessionImplTest: IsFloatingWindowAppType end";
989 }
990
991 /**
992 * @tc.name: GetCompatibleModeInPc
993 * @tc.desc: GetCompatibleModeInPc
994 * @tc.type: FUNC
995 */
996 HWTEST_F(WindowSessionImplTest3, GetCompatibleModeInPc, Function | SmallTest | Level2)
997 {
998 GTEST_LOG_(INFO) << "WindowSessionImplTest3: GetCompatibleModeInPc start";
999 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1000 option->SetWindowName("GetCompatibleModeInPc");
1001 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1002 bool enable = true;
1003 window->property_->SetCompatibleModeInPc(enable);
1004 EXPECT_EQ(true, window->GetCompatibleModeInPc());
1005 GTEST_LOG_(INFO) << "WindowSessionImplTest3: GetCompatibleModeInPc end";
1006 }
1007
1008 /**
1009 * @tc.name: SetWindowContainerColor
1010 * @tc.desc: SetWindowContainerColor
1011 * @tc.type: FUNC
1012 */
1013 HWTEST_F(WindowSessionImplTest3, SetWindowContainerColor, Function | SmallTest | Level2)
1014 {
1015 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetWindowContainerColor start";
1016 window_ = GetTestWindowImpl("SetWindowContainerColor");
1017 ASSERT_NE(window_, nullptr);
1018 window_->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1019 window_->windowSystemConfig_.freeMultiWindowSupport_ = true;
1020 window_->windowSystemConfig_.isSystemDecorEnable_ = true;
1021 window_->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
1022 std::string activeColor = "";
1023 std::string inactiveColor = "";
1024 auto ret = window_->SetWindowContainerColor(activeColor, inactiveColor);
1025 ASSERT_NE(ret, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
1026 GTEST_LOG_(INFO) << "WindowSessionImplTest: SetWindowContainerColor end";
1027 }
1028
1029 /**
1030 * @tc.name: SetAvoidAreaOption
1031 * @tc.desc: SetAvoidAreaOption
1032 * @tc.type: FUNC
1033 */
1034 HWTEST_F(WindowSessionImplTest3, SetAvoidAreaOption, Function | SmallTest | Level2)
1035 {
1036 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1037 option->SetWindowName("SetAvoidAreaOption");
1038 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1039 window->property_->SetPersistentId(1);
1040 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1041 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1042
1043 window->hostSession_ = session;
1044 window->state_ = WindowState::STATE_CREATED;
1045 WMError res = window->SetAvoidAreaOption(3);
1046 ASSERT_EQ(res, WMError::WM_OK);
1047 }
1048
1049 /**
1050 * @tc.name: GetAvoidAreaOption
1051 * @tc.desc: GetAvoidAreaOption
1052 * @tc.type: FUNC
1053 */
1054 HWTEST_F(WindowSessionImplTest3, GetAvoidAreaOption, Function | SmallTest | Level2)
1055 {
1056 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1057 option->SetWindowName("GetAvoidAreaOption");
1058 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1059 window->property_->SetPersistentId(1);
1060 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1061 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1062
1063 window->hostSession_ = session;
1064 window->state_ = WindowState::STATE_CREATED;
1065 uint32_t avoidAreaOption = 0;
1066 WMError res = window->GetAvoidAreaOption(avoidAreaOption);
1067 ASSERT_EQ(res, WMError::WM_OK);
1068 }
1069
1070 /**
1071 * @tc.name: SetWatchGestureConsumed
1072 * @tc.desc: SetWatchGestureConsumed test
1073 * @tc.type: FUNC
1074 */
1075 HWTEST_F(WindowSessionImplTest3, SetWatchGestureConsumed, Function | SmallTest | Level2)
1076 {
1077 window_ = GetTestWindowImpl("SetWatchGestureConsumed");
1078 ASSERT_NE(window_, nullptr);
1079 bool isWatchGestureConsumed = false;
1080 window_->SetWatchGestureConsumed(isWatchGestureConsumed);
1081 ASSERT_EQ(window_->GetWatchGestureConsumed(), false);
1082 }
1083
1084 /**
1085 * @tc.name: NotifyConsumeResultToFloatWindow
1086 * @tc.desc: NotifyConsumeResultToFloatWindow test
1087 * @tc.type: FUNC
1088 */
1089 HWTEST_F(WindowSessionImplTest3, NotifyConsumeResultToFloatWindow, Function | SmallTest | Level2)
1090 {
1091 window_ = GetTestWindowImpl("NotifyConsumeResultToFloatWindow");
1092 ASSERT_NE(window_, nullptr);
1093 std::shared_ptr<MMI::KeyEvent> keyEvent = MMI::KeyEvent::Create();
1094 keyEvent->SetKeyCode(MMI::KeyEvent::KEYCODE_TAB);
1095 keyEvent->SetKeyAction(MMI::KeyEvent::KEY_ACTION_DOWN);
1096 window_->SetWatchGestureConsumed(false);
1097 bool isConsumed = false;
1098 window_->NotifyConsumeResultToFloatWindow(keyEvent, isConsumed);
1099 ASSERT_EQ(window_->GetWatchGestureConsumed(), false);
1100 }
1101
1102 /**
1103 * @tc.name: IsSystemWindow
1104 * @tc.desc: IsSystemWindow
1105 * @tc.type: FUNC
1106 */
1107 HWTEST_F(WindowSessionImplTest3, IsSystemWindow, Function | SmallTest | Level2)
1108 {
1109 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1110 option->SetWindowName("IsSystemWindow");
1111 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1112 window->property_->SetPersistentId(1);
1113 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1114 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1115
1116 window->hostSession_ = session;
1117 window->state_ = WindowState::STATE_CREATED;
1118 window->property_->SetWindowType(WindowType::WINDOW_TYPE_SYSTEM_FLOAT);
1119 bool res = window->IsSystemWindow();
1120 ASSERT_EQ(res, true);
1121 }
1122
1123 /**
1124 * @tc.name: IsAppWindow
1125 * @tc.desc: IsAppWindow
1126 * @tc.type: FUNC
1127 */
1128 HWTEST_F(WindowSessionImplTest3, IsAppWindow, Function | SmallTest | Level2)
1129 {
1130 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1131 option->SetWindowName("IsAppWindow");
1132 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1133 window->property_->SetPersistentId(1);
1134 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1135 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1136
1137 window->hostSession_ = session;
1138 window->state_ = WindowState::STATE_CREATED;
1139 window->property_->SetWindowType(WindowType::APP_WINDOW_BASE);
1140 bool res = window->IsAppWindow();
1141 ASSERT_EQ(res, true);
1142 }
1143
1144 /**
1145 * @tc.name: SetMouseEventFilter
1146 * @tc.desc: SetMouseEventFilter
1147 * @tc.type: FUNC
1148 */
1149 HWTEST_F(WindowSessionImplTest3, SetMouseEventFilter, Function | SmallTest | Level2)
1150 {
1151 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1152 option->SetWindowName("SetMouseEventFilter");
1153 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1154 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1155 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1156 ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1157 window->hostSession_ = session;
1158 window->property_->SetPersistentId(1);
__anondd0f83570202(const OHOS::MMI::PointerEvent& event) 1159 WMError res = window->SetMouseEventFilter([](const OHOS::MMI::PointerEvent& event) {
1160 return true;
1161 });
1162 ASSERT_EQ(res, WMError::WM_OK);
1163 }
1164
1165 /**
1166 * @tc.name: ClearMouseEventFilter
1167 * @tc.desc: ClearMouseEventFilter
1168 * @tc.type: FUNC
1169 */
1170 HWTEST_F(WindowSessionImplTest3, ClearMouseEventFilter, Function | SmallTest | Level2)
1171 {
1172 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1173 option->SetWindowName("ClearMouseEventFilter");
1174 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1175 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1176 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1177 ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1178 window->hostSession_ = session;
1179 window->property_->SetPersistentId(1);
1180 WMError res = window->ClearMouseEventFilter();
1181 ASSERT_EQ(res, WMError::WM_OK);
1182 }
1183
1184 /**
1185 * @tc.name: SetTouchEventFilter
1186 * @tc.desc: SetTouchEventFilter
1187 * @tc.type: FUNC
1188 */
1189 HWTEST_F(WindowSessionImplTest3, SetTouchEventFilter, Function | SmallTest | Level2)
1190 {
1191 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1192 option->SetWindowName("SetTouchEventFilter");
1193 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1194 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1195 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1196 ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1197 window->hostSession_ = session;
1198 window->property_->SetPersistentId(1);
__anondd0f83570302(const OHOS::MMI::PointerEvent& event) 1199 WMError res = window->SetTouchEventFilter([](const OHOS::MMI::PointerEvent& event) {
1200 return true;
1201 });
1202 ASSERT_EQ(res, WMError::WM_OK);
1203 }
1204
1205 /**
1206 * @tc.name: ClearTouchEventFilter
1207 * @tc.desc: ClearTouchEventFilter
1208 * @tc.type: FUNC
1209 */
1210 HWTEST_F(WindowSessionImplTest3, ClearTouchEventFilter, Function | SmallTest | Level2)
1211 {
1212 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1213 option->SetWindowName("ClearTouchEventFilter");
1214 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1215 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1216 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1217 ASSERT_EQ(WMError::WM_OK, window->Create(nullptr, session));
1218 window->hostSession_ = session;
1219 window->property_->SetPersistentId(1);
1220 WMError res = window->ClearTouchEventFilter();
1221 ASSERT_EQ(res, WMError::WM_OK);
1222 }
1223
1224 /**
1225 * @tc.name: FilterPointerEvent
1226 * @tc.desc: FilterPointerEvent
1227 * @tc.type: FUNC
1228 */
1229 HWTEST_F(WindowSessionImplTest3, FilterPointerEvent, Function | SmallTest | Level2)
1230 {
1231 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1232 option->SetWindowName("FilterPointerEvent");
1233 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1234
1235 std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
1236 pointerEvent->SetSourceType(OHOS::MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1237 window->touchEventFilter_ = nullptr;
1238 auto ret = window->FilterPointerEvent(pointerEvent);
1239 ASSERT_EQ(false, ret);
1240
__anondd0f83570402(const MMI::PointerEvent&) 1241 window->touchEventFilter_ = [](const MMI::PointerEvent&) { return true; };
1242 window->FilterPointerEvent(pointerEvent);
1243 }
1244
1245 /**
1246 * @tc.name: FilterPointerEvent01
1247 * @tc.desc: FilterPointerEvent
1248 * @tc.type: FUNC
1249 */
1250 HWTEST_F(WindowSessionImplTest3, FilterPointerEvent01, Function | SmallTest | Level2)
1251 {
1252 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1253 option->SetWindowName("FilterPointerEvent01");
1254 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1255
1256 std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
1257 pointerEvent->SetSourceType(OHOS::MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
1258 pointerEvent->SetPointerAction(OHOS::MMI::PointerEvent::POINTER_ACTION_BUTTON_DOWN);
1259 window->mouseEventFilter_ = nullptr;
1260 auto ret = window->FilterPointerEvent(pointerEvent);
1261 ASSERT_EQ(false, ret);
1262
__anondd0f83570502(const MMI::PointerEvent&) 1263 window->mouseEventFilter_ = [](const MMI::PointerEvent&) { return true; };
1264 window->FilterPointerEvent(pointerEvent);
1265 }
1266
1267 /**
1268 * @tc.name: NotifyPointerEvent
1269 * @tc.desc: NotifyPointerEvent
1270 * @tc.type: FUNC
1271 */
1272 HWTEST_F(WindowSessionImplTest3, NotifyPointerEvent, Function | SmallTest | Level2)
1273 {
1274 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1275 option->SetWindowName("NotifyPointerEvent");
1276 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1277 std::shared_ptr<MMI::PointerEvent> pointerEvent = nullptr;
1278 window->NotifyPointerEvent(pointerEvent);
1279
1280 pointerEvent = MMI::PointerEvent::Create();
1281 window->inputEventConsumer_ = std::make_shared<MockInputEventConsumer>();
1282 pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_UNKNOWN);
1283 ASSERT_EQ(pointerEvent->GetPointerAction(), MMI::PointerEvent::POINTER_ACTION_UNKNOWN);
1284 window->NotifyPointerEvent(pointerEvent);
1285
1286 pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_MOVE);
1287 window->NotifyPointerEvent(pointerEvent);
1288
1289 window->inputEventConsumer_ = nullptr;
1290 window->NotifyPointerEvent(pointerEvent);
1291 }
1292
1293 /**
1294 * @tc.name: SetWindowContainerColor01
1295 * @tc.desc: SetWindowContainerColor01
1296 * @tc.type: FUNC
1297 */
1298 HWTEST_F(WindowSessionImplTest3, SetWindowContainerColor01, Function | SmallTest | Level2)
1299 {
1300 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1301 option->SetWindowName("SetWindowContainerColor01");
1302 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1303
1304 std::string activeColor = "";
1305 std::string inactiveColor = "";
1306 window->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
1307 auto ret = window->SetWindowContainerColor(activeColor, inactiveColor);
1308 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_CALLING);
1309
1310 window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
1311 window->property_->SetIsPcAppInPad(true);
1312 window->property_->isDecorEnable_ = true;
1313 window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
1314 ret = window->SetWindowContainerColor(activeColor, inactiveColor);
1315 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_WINDOW);
1316 }
1317
1318 /**
1319 * @tc.name: SetAvoidAreaOption01
1320 * @tc.desc: SetAvoidAreaOption
1321 * @tc.type: FUNC
1322 */
1323 HWTEST_F(WindowSessionImplTest3, SetAvoidAreaOption01, Function | SmallTest | Level2)
1324 {
1325 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1326 option->SetWindowName("SetAvoidAreaOption01");
1327 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1328
1329 window->state_ = WindowState::STATE_DESTROYED;
1330 auto ret = window->SetAvoidAreaOption(0);
1331 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_WINDOW);
1332 }
1333
1334 /**
1335 * @tc.name: GetAvoidAreaOption01
1336 * @tc.desc: GetAvoidAreaOption
1337 * @tc.type: FUNC
1338 */
1339 HWTEST_F(WindowSessionImplTest3, GetAvoidAreaOption01, Function | SmallTest | Level2)
1340 {
1341 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1342 option->SetWindowName("GetAvoidAreaOption01");
1343 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1344
1345 window->state_ = WindowState::STATE_DESTROYED;
1346 uint32_t avoidAreaOption = 1;
1347 auto ret = window->SetAvoidAreaOption(avoidAreaOption);
1348 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_WINDOW);
1349 }
1350
1351 /**
1352 * @tc.name: SetWindowDelayRaiseEnabled
1353 * @tc.desc: SetWindowDelayRaiseEnabled
1354 * @tc.type: FUNC
1355 */
1356 HWTEST_F(WindowSessionImplTest3, SetWindowDelayRaiseEnabled, Function | SmallTest | Level2)
1357 {
1358 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1359 option->SetWindowName("SetWindowDelayRaiseEnabled");
1360 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1361
1362 window->state_ = WindowState::STATE_DESTROYED;
1363 auto ret = window->SetWindowDelayRaiseEnabled(true);
1364 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_WINDOW);
1365
1366 window->state_ = WindowState::STATE_CREATED;
1367 window->property_->persistentId_ = ROTATE_ANIMATION_DURATION;
1368 SessionInfo info;
1369 window->hostSession_ = sptr<SessionMocker>::MakeSptr(info);
1370 window->windowSystemConfig_.windowUIType_ = WindowUIType::PHONE_WINDOW;
1371 window->windowSystemConfig_.freeMultiWindowSupport_ = true;
1372 ret = window->SetWindowDelayRaiseEnabled(true);
1373 ASSERT_EQ(ret, WMError::WM_ERROR_DEVICE_NOT_SUPPORT);
1374
1375 window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
1376 ret = window->SetWindowDelayRaiseEnabled(true);
1377 ASSERT_EQ(ret, WMError::WM_OK);
1378 }
1379
1380 /**
1381 * @tc.name: NotifyWatchFocusActiveChange
1382 * @tc.desc: NotifyWatchFocusActiveChange
1383 * @tc.type: FUNC
1384 */
1385 HWTEST_F(WindowSessionImplTest3, NotifyWatchFocusActiveChange, Function | SmallTest | Level2)
1386 {
1387 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1388 option->SetWindowName("NotifyWatchFocusActiveChange");
1389 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1390
1391 window->state_ = WindowState::STATE_DESTROYED;
1392 auto ret = window->NotifyWatchFocusActiveChange(true);
1393 ASSERT_EQ(ret, WMError::WM_ERROR_INVALID_WINDOW);
1394
1395 window->state_ = WindowState::STATE_CREATED;
1396 SessionInfo info;
1397 window->hostSession_ = sptr<SessionMocker>::MakeSptr(info);
1398 window->property_->persistentId_ = ROTATE_ANIMATION_DURATION;
1399 ret = window->SetWindowDelayRaiseEnabled(true);
1400 }
1401
1402 /**
1403 * @tc.name: UpdateSubWindowLevel
1404 * @tc.desc: UpdateSubWindowLevel
1405 * @tc.type: FUNC
1406 */
1407 HWTEST_F(WindowSessionImplTest3, UpdateSubWindowLevel, Function | SmallTest | Level2)
1408 {
1409 sptr<WindowOption> option = sptr<WindowOption>::MakeSptr();
1410 option->SetWindowName("UpdateSubWindowLevel");
1411 sptr<WindowSessionImpl> window = sptr<WindowSessionImpl>::MakeSptr(option);
1412 SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
1413 sptr<SessionMocker> session = sptr<SessionMocker>::MakeSptr(sessionInfo);
1414 window->hostSession_ = session;
1415 window->property_->SetPersistentId(1);
1416 window->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
1417
1418 sptr<WindowOption> subWindowOption = sptr<WindowOption>::MakeSptr();
1419 subWindowOption->SetWindowName("UpdateSubWindowLevel_subWindow");
1420 sptr<WindowSessionImpl> subWindow = sptr<WindowSessionImpl>::MakeSptr(subWindowOption);
1421 subWindow->property_->SetPersistentId(2);
1422 subWindow->property_->SetParentPersistentId(1);
1423 subWindow->hostSession_ = session;
1424 subWindow->windowSystemConfig_.windowUIType_ = WindowUIType::PC_WINDOW;
1425 subWindow->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
1426 WindowSessionImpl::subWindowSessionMap_.insert(std::pair<int32_t,
1427 std::vector<sptr<WindowSessionImpl>>>(1, { subWindow }));
1428
1429 int subWindowLevel = 5;
1430 window->UpdateSubWindowLevel(subWindowLevel);
1431 auto res = subWindow->property_->GetSubWindowLevel();
1432 EXPECT_EQ(res, 0);
1433 EXPECT_EQ(WMError::WM_OK, subWindow->Destroy(true));
1434 EXPECT_EQ(WMError::WM_OK, window->Destroy(true));
1435 }
1436 } // namespace
1437 } // namespace Rosen
1438 } // namespace OHOS