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 <regex>
18 #include <pointer_event.h>
19 #include <ui/rs_surface_node.h>
20
21 #include "key_event.h"
22 #include "mock/mock_session_stage.h"
23 #include "mock/mock_window_event_channel.h"
24 #include "mock/mock_pattern_detach_callback.h"
25 #include "session/host/include/extension_session.h"
26 #include "session/host/include/move_drag_controller.h"
27 #include "session/host/include/scene_session.h"
28 #include "session/host/include/session.h"
29 #include "session_manager/include/scene_session_manager.h"
30 #include "session_info.h"
31 #include "wm_common.h"
32 #include "window_manager_hilog.h"
33
34 using namespace testing;
35 using namespace testing::ext;
36
37 namespace OHOS {
38 namespace Rosen {
39 namespace {
40 const std::string UNDEFINED = "undefined";
41 }
42
43 class WindowSessionTest3 : public testing::Test {
44 public:
45 static void SetUpTestCase();
46 static void TearDownTestCase();
47 void SetUp() override;
48 void TearDown() override;
49
50 int32_t GetTaskCount();
51 sptr<SceneSessionManager> ssm_;
52
53 private:
54 RSSurfaceNode::SharedPtr CreateRSSurfaceNode();
55 sptr<Session> session_ = nullptr;
56 static constexpr uint32_t WAIT_SYNC_IN_NS = 500000;
57 };
58
SetUpTestCase()59 void WindowSessionTest3::SetUpTestCase()
60 {
61 }
62
TearDownTestCase()63 void WindowSessionTest3::TearDownTestCase()
64 {
65 }
66
SetUp()67 void WindowSessionTest3::SetUp()
68 {
69 SessionInfo info;
70 info.abilityName_ = "testSession1";
71 info.moduleName_ = "testSession2";
72 info.bundleName_ = "testSession3";
73 session_ = sptr<Session>::MakeSptr(info);
74 EXPECT_NE(nullptr, session_);
75 session_->surfaceNode_ = CreateRSSurfaceNode();
76 ssm_ = sptr<SceneSessionManager>::MakeSptr();
77 session_->SetEventHandler(ssm_->taskScheduler_->GetEventHandler(), ssm_->eventHandler_);
78 auto isScreenLockedCallback = [this]() {
79 return ssm_->IsScreenLocked();
80 };
81 session_->RegisterIsScreenLockedCallback(isScreenLockedCallback);
82 }
83
TearDown()84 void WindowSessionTest3::TearDown()
85 {
86 session_ = nullptr;
87 usleep(WAIT_SYNC_IN_NS);
88 }
89
CreateRSSurfaceNode()90 RSSurfaceNode::SharedPtr WindowSessionTest3::CreateRSSurfaceNode()
91 {
92 struct RSSurfaceNodeConfig rsSurfaceNodeConfig;
93 rsSurfaceNodeConfig.SurfaceNodeName = "WindowSessionTest3SurfaceNode";
94 auto surfaceNode = RSSurfaceNode::Create(rsSurfaceNodeConfig);
95 if (surfaceNode == nullptr) {
96 GTEST_LOG_(INFO) << "WindowSessionTest3::CreateRSSurfaceNode surfaceNode is nullptr";
97 }
98 return surfaceNode;
99 }
100
GetTaskCount()101 int32_t WindowSessionTest3::GetTaskCount()
102 {
103 std::string dumpInfo = session_->handler_->GetEventRunner()->GetEventQueue()->DumpCurrentQueueSize();
104 std::regex pattern("\\d+");
105 std::smatch matches;
106 int32_t taskNum = 0;
107 while (std::regex_search(dumpInfo, matches, pattern)) {
108 taskNum += std::stoi(matches.str());
109 dumpInfo = matches.suffix();
110 }
111 return taskNum;
112 }
113
114 namespace {
115 /**
116 * @tc.name: NotifyContextTransparent
117 * @tc.desc: NotifyContextTransparent Test
118 * @tc.type: FUNC
119 */
120 HWTEST_F(WindowSessionTest3, NotifyContextTransparent, Function | SmallTest | Level2)
121 {
122 ASSERT_NE(session_, nullptr);
123 NotifyContextTransparentFunc contextTransparentFunc = session_->contextTransparentFunc_;
124 if (contextTransparentFunc == nullptr) {
125 contextTransparentFunc = {};
126 }
127 session_->contextTransparentFunc_ = nullptr;
128 session_->NotifyContextTransparent();
129
130 session_->SetContextTransparentFunc(contextTransparentFunc);
131 session_->NotifyContextTransparent();
132 session_->SetPendingSessionToBackgroundForDelegatorListener(nullptr);
133 EXPECT_EQ(WSError::WS_OK, session_->PendingSessionToBackgroundForDelegator(true));
134 }
135
136 /**
137 * @tc.name: SetFocusable04
138 * @tc.desc: SetFocusable Test
139 * @tc.type: FUNC
140 */
141 HWTEST_F(WindowSessionTest3, SetFocusable04, Function | SmallTest | Level2)
142 {
143 ASSERT_NE(session_, nullptr);
144 session_->property_ = nullptr;
145 auto result = session_->SetFocusable(false);
146 ASSERT_EQ(result, WSError::WS_ERROR_NULLPTR);
147
148 session_->isFocused_ = true;
149 session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
150 EXPECT_NE(session_->property_, nullptr);
151 session_->property_->SetFocusable(false);
152
153 result = session_->SetFocusable(false);
154 EXPECT_EQ(result, WSError::WS_OK);
155 }
156
157 /**
158 * @tc.name: SetFocusableOnShow
159 * @tc.desc: SetFocusableOnShow Test
160 * @tc.type: FUNC
161 */
162 HWTEST_F(WindowSessionTest3, SetFocusableOnShow, Function | SmallTest | Level2)
163 {
164 ASSERT_NE(session_, nullptr);
165 ASSERT_EQ(session_->IsFocusableOnShow(), true);
166 bool focusableOnShow = false;
167 session_->SetFocusableOnShow(focusableOnShow);
168 usleep(10000); // sleep 10ms
169 ASSERT_EQ(session_->IsFocusableOnShow(), focusableOnShow);
170 }
171
172 /**
173 * @tc.name: SetTouchable03
174 * @tc.desc: IsSessionValid() and touchable return true
175 * @tc.type: FUNC
176 */
177 HWTEST_F(WindowSessionTest3, SetTouchable03, Function | SmallTest | Level2)
178 {
179 ASSERT_NE(session_, nullptr);
180 session_->SetSessionState(SessionState::STATE_FOREGROUND);
181 session_->sessionInfo_.isSystem_ = false;
182 EXPECT_EQ(WSError::WS_OK, session_->SetTouchable(true));
183 }
184
185 /**
186 * @tc.name: GetTouchable02
187 * @tc.desc: GetTouchable Test
188 * @tc.type: FUNC
189 */
190 HWTEST_F(WindowSessionTest3, GetTouchable02, Function | SmallTest | Level2)
191 {
192 ASSERT_NE(session_, nullptr);
193 session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
194 ASSERT_NE(session_->property_, nullptr);
195 EXPECT_EQ(true, session_->GetTouchable());
196
197 session_->property_ = nullptr;
198 EXPECT_EQ(true, session_->GetTouchable());
199 }
200
201 /**
202 * @tc.name: UpdateDensity02
203 * @tc.desc: UpdateDensity Test
204 * @tc.type: FUNC
205 */
206 HWTEST_F(WindowSessionTest3, UpdateDensity02, Function | SmallTest | Level2)
207 {
208 ASSERT_NE(session_, nullptr);
209 session_->SetSessionState(SessionState::STATE_FOREGROUND);
210 sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
211 EXPECT_NE(nullptr, mockSessionStage);
212 session_->sessionStage_ = mockSessionStage;
213 auto result = session_->UpdateDensity();
214 EXPECT_EQ(result, WSError::WS_OK);
215 }
216
217 /**
218 * @tc.name: UpdateOrientation
219 * @tc.desc: UpdateOrientation Test
220 * @tc.type: FUNC
221 */
222 HWTEST_F(WindowSessionTest3, UpdateOrientation, Function | SmallTest | Level2)
223 {
224 ASSERT_NE(session_, nullptr);
225 session_->sessionInfo_.isSystem_ = true;
226 auto result = session_->UpdateOrientation();
227 EXPECT_EQ(result, WSError::WS_ERROR_INVALID_SESSION);
228
229 session_->sessionInfo_.isSystem_ = false;
230 session_->SetSessionState(SessionState::STATE_FOREGROUND);
231 result = session_->UpdateOrientation();
232 EXPECT_EQ(result, WSError::WS_ERROR_NULLPTR);
233
234 sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
235 EXPECT_NE(nullptr, mockSessionStage);
236 session_->sessionStage_ = mockSessionStage;
237 result = session_->UpdateOrientation();
238 EXPECT_EQ(result, WSError::WS_OK);
239 }
240
241 /**
242 * @tc.name: HandleDialogBackground
243 * @tc.desc: HandleDialogBackground Test
244 * @tc.type: FUNC
245 */
246 HWTEST_F(WindowSessionTest3, HandleDialogBackground, Function | SmallTest | Level2)
247 {
248 ASSERT_NE(session_, nullptr);
249 session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
250 ASSERT_NE(session_->property_, nullptr);
251 session_->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
252 session_->HandleDialogBackground();
253
254 session_->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
255 sptr<Session> session01 = nullptr;
256
257 SessionInfo info;
258 info.abilityName_ = "testSession1";
259 info.moduleName_ = "testSession2";
260 info.bundleName_ = "testSession3";
261 sptr<Session> session02 = sptr<Session>::MakeSptr(info);
262 sptr<Session> session03 = sptr<Session>::MakeSptr(info);
263 EXPECT_NE(session02, nullptr);
264 EXPECT_NE(session03, nullptr);
265
266 sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
267 EXPECT_NE(nullptr, mockSessionStage);
268 session02->sessionStage_ = mockSessionStage;
269 session03->sessionStage_ = nullptr;
270
271 session_->dialogVec_.push_back(session01);
272 session_->dialogVec_.push_back(session02);
273 session_->dialogVec_.push_back(session03);
274 session_->HandleDialogBackground();
275 session_->SetPendingSessionToBackgroundForDelegatorListener(nullptr);
276 EXPECT_EQ(WSError::WS_OK, session_->PendingSessionToBackgroundForDelegator(true));
277 }
278
279 /**
280 * @tc.name: HandleDialogForeground
281 * @tc.desc: HandleDialogForeground Test
282 * @tc.type: FUNC
283 */
284 HWTEST_F(WindowSessionTest3, HandleDialogForeground, Function | SmallTest | Level2)
285 {
286 ASSERT_NE(session_, nullptr);
287 session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
288 ASSERT_NE(session_->property_, nullptr);
289 session_->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
290 session_->HandleDialogForeground();
291
292 session_->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
293 sptr<Session> session01 = nullptr;
294
295 SessionInfo info;
296 info.abilityName_ = "testSession1";
297 info.moduleName_ = "testSession2";
298 info.bundleName_ = "testSession3";
299 sptr<Session> session02 = sptr<Session>::MakeSptr(info);
300 sptr<Session> session03 = sptr<Session>::MakeSptr(info);
301 EXPECT_NE(session02, nullptr);
302 EXPECT_NE(session03, nullptr);
303
304 sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
305 EXPECT_NE(nullptr, mockSessionStage);
306 session02->sessionStage_ = mockSessionStage;
307 session03->sessionStage_ = nullptr;
308
309 session_->dialogVec_.push_back(session01);
310 session_->dialogVec_.push_back(session02);
311 session_->dialogVec_.push_back(session03);
312 session_->HandleDialogForeground();
313 session_->SetPendingSessionToBackgroundForDelegatorListener(nullptr);
314 EXPECT_EQ(WSError::WS_OK, session_->PendingSessionToBackgroundForDelegator(true));
315 }
316
317 /**
318 * @tc.name: SetActive
319 * @tc.desc: SetActive Test
320 * @tc.type: FUNC
321 */
322 HWTEST_F(WindowSessionTest3, SetActive, Function | SmallTest | Level2)
323 {
324 ASSERT_NE(session_, nullptr);
325 session_->SetSessionState(SessionState::STATE_CONNECT);
326 auto result = session_->SetActive(false);
327 EXPECT_EQ(result, WSError::WS_DO_NOTHING);
328 }
329
330 /**
331 * @tc.name: SetActive02
332 * @tc.desc: SetActive Test
333 * @tc.type: FUNC
334 */
335 HWTEST_F(WindowSessionTest3, SetActive02, Function | SmallTest | Level2)
336 {
337 ASSERT_NE(session_, nullptr);
338 session_->SetSessionState(SessionState::STATE_FOREGROUND);
339 sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
340 EXPECT_NE(nullptr, mockSessionStage);
341 session_->sessionStage_ = mockSessionStage;
342 auto result = session_->SetActive(true);
343 EXPECT_EQ(result, WSError::WS_OK);
344 }
345
346 /**
347 * @tc.name: SetActive03
348 * @tc.desc: SetActive Test
349 * @tc.type: FUNC
350 */
351 HWTEST_F(WindowSessionTest3, SetActive03, Function | SmallTest | Level2)
352 {
353 ASSERT_NE(session_, nullptr);
354 sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
355 EXPECT_NE(nullptr, mockSessionStage);
356 session_->sessionStage_ = mockSessionStage;
357
358 session_->SetSessionState(SessionState::STATE_CONNECT);
359 auto result = session_->SetActive(true);
360 EXPECT_EQ(result, WSError::WS_OK);
361
362 session_->isActive_ = true;
363 result = session_->SetActive(false);
364 EXPECT_EQ(result, WSError::WS_OK);
365
366 session_->SetSessionState(SessionState::STATE_ACTIVE);
367 session_->isActive_ = true;
368 result = session_->SetActive(false);
369 EXPECT_EQ(result, WSError::WS_OK);
370 }
371
372 /**
373 * @tc.name: IsTopDialog02
374 * @tc.desc: IsTopDialog Test
375 * @tc.type: FUNC
376 */
377 HWTEST_F(WindowSessionTest3, IsTopDialog02, Function | SmallTest | Level2)
378 {
379 ASSERT_NE(session_, nullptr);
380 session_->SetParentSession(nullptr);
381 EXPECT_EQ(false, session_->IsTopDialog());
382
383 SessionInfo info;
384 info.abilityName_ = "testSession1";
385 info.moduleName_ = "testSession2";
386 info.bundleName_ = "testSession3";
387 sptr<Session> parentSession = sptr<Session>::MakeSptr(info);
388 ASSERT_NE(parentSession, nullptr);
389 parentSession->dialogVec_.clear();
390 session_->SetParentSession(parentSession);
391 auto result = session_->IsTopDialog();
392 EXPECT_EQ(result, true);
393 }
394
395 /**
396 * @tc.name: IsTopDialog03
397 * @tc.desc: IsTopDialog Test
398 * @tc.type: FUNC
399 */
400 HWTEST_F(WindowSessionTest3, IsTopDialog03, Function | SmallTest | Level2)
401 {
402 ASSERT_NE(session_, nullptr);
403 session_->dialogVec_.clear();
404 SessionInfo info;
405 info.abilityName_ = "testSession1";
406 info.moduleName_ = "testSession2";
407 info.bundleName_ = "testSession3";
408 sptr<Session> dialogSession1 = sptr<Session>::MakeSptr(info);
409 sptr<Session> dialogSession2 = sptr<Session>::MakeSptr(info);
410 ASSERT_NE(dialogSession1, nullptr);
411 ASSERT_NE(dialogSession2, nullptr);
412 dialogSession1->SetParentSession(session_);
413 dialogSession2->SetParentSession(session_);
414 session_->dialogVec_.push_back(dialogSession1);
415 session_->dialogVec_.push_back(dialogSession2);
416 dialogSession1->SetSessionState(SessionState::STATE_INACTIVE);
417 dialogSession2->SetSessionState(SessionState::STATE_INACTIVE);
418 EXPECT_EQ(false, dialogSession1->IsTopDialog());
419 }
420
421 /**
422 * @tc.name: PresentFocusIfPointDown
423 * @tc.desc: PresentFocusIfPointDown Test
424 * @tc.type: FUNC
425 */
426 HWTEST_F(WindowSessionTest3, PresentFocusIfPointDown, Function | SmallTest | Level2)
427 {
428 ASSERT_NE(session_, nullptr);
429 session_->isFocused_ = true;
430 session_->PresentFocusIfPointDown();
431
432 session_->isFocused_ = false;
433 session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
434 EXPECT_NE(session_->property_, nullptr);
435 session_->property_->SetFocusable(false);
436 session_->PresentFocusIfPointDown();
437 session_->SetPendingSessionToBackgroundForDelegatorListener(nullptr);
438 EXPECT_EQ(WSError::WS_OK, session_->PendingSessionToBackgroundForDelegator(true));
439 }
440
441 /**
442 * @tc.name: HandlePointDownDialog
443 * @tc.desc: HandlePointDownDialog Test
444 * @tc.type: FUNC
445 */
446 HWTEST_F(WindowSessionTest3, HandlePointDownDialog, Function | SmallTest | Level2)
447 {
448 ASSERT_NE(session_, nullptr);
449 SessionInfo info;
450 info.abilityName_ = "testSession1";
451 info.moduleName_ = "testSession2";
452 info.bundleName_ = "testSession3";
453 sptr<Session> dialogSession1 = sptr<Session>::MakeSptr(info);
454 sptr<Session> dialogSession2 = sptr<Session>::MakeSptr(info);
455 sptr<Session> dialogSession3 = sptr<Session>::MakeSptr(info);
456 sptr<Session> dialogSession4 = nullptr;
457 ASSERT_NE(dialogSession1, nullptr);
458 ASSERT_NE(dialogSession2, nullptr);
459 ASSERT_NE(dialogSession3, nullptr);
460 dialogSession1->SetSessionState(SessionState::STATE_FOREGROUND);
461 dialogSession2->SetSessionState(SessionState::STATE_ACTIVE);
462 dialogSession2->SetSessionState(SessionState::STATE_INACTIVE);
463 session_->dialogVec_.push_back(dialogSession1);
464 session_->dialogVec_.push_back(dialogSession2);
465 session_->dialogVec_.push_back(dialogSession3);
466 session_->dialogVec_.push_back(dialogSession4);
467 session_->HandlePointDownDialog();
468 session_->SetPendingSessionToBackgroundForDelegatorListener(nullptr);
469 EXPECT_EQ(WSError::WS_OK, session_->PendingSessionToBackgroundForDelegator(true));
470 }
471
472 /**
473 * @tc.name: HandleSubWindowClick01
474 * @tc.desc: parentSession and property is nullptr
475 * @tc.type: FUNC
476 */
477 HWTEST_F(WindowSessionTest3, HandleSubWindowClick01, Function | SmallTest | Level2)
478 {
479 ASSERT_NE(session_, nullptr);
480 auto result = session_->HandleSubWindowClick(MMI::PointerEvent::POINTER_ACTION_DOWN);
481 EXPECT_EQ(result, WSError::WS_OK);
482 }
483
484 /**
485 * @tc.name: HandleSubWindowClick03
486 * @tc.desc: parentSession->dialogVec_ is nullptr
487 * @tc.type: FUNC
488 */
489 HWTEST_F(WindowSessionTest3, HandleSubWindowClick03, Function | SmallTest | Level2)
490 {
491 ASSERT_NE(session_, nullptr);
492 SessionInfo info;
493 info.abilityName_ = "testSession1";
494 info.moduleName_ = "testSession2";
495 info.bundleName_ = "testSession3";
496 sptr<Session> dialogSession = sptr<Session>::MakeSptr(info);
497 ASSERT_NE(dialogSession, nullptr);
498 session_->SetParentSession(dialogSession);
499
500 session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
501 ASSERT_NE(session_->property_, nullptr);
502
503 auto result = session_->HandleSubWindowClick(MMI::PointerEvent::POINTER_ACTION_DOWN);
504 EXPECT_EQ(result, WSError::WS_OK);
505
506 result = session_->HandleSubWindowClick(MMI::PointerEvent::POINTER_ACTION_MOVE);
507 EXPECT_EQ(result, WSError::WS_OK);
508 }
509
510 /**
511 * @tc.name: TransferPointerEvent06
512 * @tc.desc: TransferPointerEvent Test
513 * @tc.type: FUNC
514 */
515 HWTEST_F(WindowSessionTest3, TransferPointerEvent06, Function | SmallTest | Level2)
516 {
517 ASSERT_NE(session_, nullptr);
518 session_->SetSessionState(SessionState::STATE_CONNECT);
519 std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
520 ASSERT_NE(pointerEvent, nullptr);
521
522 SessionInfo info;
523 info.abilityName_ = "testSession1";
524 info.moduleName_ = "testSession2";
525 info.bundleName_ = "testSession3";
526 sptr<Session> dialogSession = sptr<Session>::MakeSptr(info);
527 ASSERT_NE(dialogSession, nullptr);
528 dialogSession->SetSessionState(SessionState::STATE_ACTIVE);
529 session_->dialogVec_.push_back(dialogSession);
530 pointerEvent->pointerAction_ = MMI::PointerEvent::POINTER_ACTION_DOWN;
531
532 auto result = session_->TransferPointerEvent(pointerEvent);
533 EXPECT_EQ(result, WSError::WS_ERROR_INVALID_PERMISSION);
534 }
535
536 /**
537 * @tc.name: TransferPointerEvent07
538 * @tc.desc: TransferPointerEvent Test
539 * @tc.type: FUNC
540 */
541 HWTEST_F(WindowSessionTest3, TransferPointerEvent07, Function | SmallTest | Level2)
542 {
543 ASSERT_NE(session_, nullptr);
544 session_->SetSessionState(SessionState::STATE_CONNECT);
545 std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
546 ASSERT_NE(pointerEvent, nullptr);
547 session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
548 ASSERT_NE(session_->property_, nullptr);
549 session_->property_->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
550 auto result = session_->TransferPointerEvent(pointerEvent);
551 EXPECT_EQ(result, WSError::WS_ERROR_NULLPTR);
552 }
553
554 /**
555 * @tc.name: TransferPointerEvent08
556 * @tc.desc: TransferPointerEvent Test
557 * @tc.type: FUNC
558 */
559 HWTEST_F(WindowSessionTest3, TransferPointerEvent08, Function | SmallTest | Level2)
560 {
561 ASSERT_NE(session_, nullptr);
562 session_->SetSessionState(SessionState::STATE_CONNECT);
563 std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
564 ASSERT_NE(pointerEvent, nullptr);
565
566 session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
567 ASSERT_NE(session_->property_, nullptr);
568
569 session_->property_->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
570 SessionInfo info;
571 info.abilityName_ = "testSession1";
572 info.moduleName_ = "testSession2";
573 info.bundleName_ = "testSession3";
574 sptr<Session> dialogSession = sptr<Session>::MakeSptr(info);
575 ASSERT_NE(dialogSession, nullptr);
576
577 session_->SetParentSession(dialogSession);
578 auto result = session_->TransferPointerEvent(pointerEvent);
579 EXPECT_EQ(result, WSError::WS_ERROR_NULLPTR);
580 }
581
582 /**
583 * @tc.name: TransferPointerEvent09
584 * @tc.desc: TransferPointerEvent Test
585 * @tc.type: FUNC
586 */
587 HWTEST_F(WindowSessionTest3, TransferPointerEvent09, Function | SmallTest | Level2)
588 {
589 ASSERT_NE(session_, nullptr);
590 session_->SetSessionState(SessionState::STATE_FOREGROUND);
591 std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
592 ASSERT_NE(pointerEvent, nullptr);
593
594 session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
595 ASSERT_NE(session_->property_, nullptr);
596
597 session_->property_->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
598 SessionInfo info;
599 info.abilityName_ = "testSession1";
600 info.moduleName_ = "testSession2";
601 info.bundleName_ = "testSession3";
602 sptr<Session> dialogSession = sptr<Session>::MakeSptr(info);
603 ASSERT_NE(dialogSession, nullptr);
604
605 session_->SetParentSession(dialogSession);
606 dialogSession->dialogVec_.push_back(session_);
607 pointerEvent->pointerAction_ = MMI::PointerEvent::POINTER_ACTION_MOVE;
608 auto result = session_->TransferPointerEvent(pointerEvent);
609 EXPECT_EQ(result, WSError::WS_ERROR_NULLPTR);
610 }
611
612 /**
613 * @tc.name: TransferPointerEvent10
614 * @tc.desc: TransferPointerEvent Test
615 * @tc.type: FUNC
616 */
617 HWTEST_F(WindowSessionTest3, TransferPointerEvent10, Function | SmallTest | Level2)
618 {
619 ASSERT_NE(session_, nullptr);
620 session_->SetSessionState(SessionState::STATE_FOREGROUND);
621 std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
622 ASSERT_NE(pointerEvent, nullptr);
623 pointerEvent->pointerAction_ = MMI::PointerEvent::POINTER_ACTION_DOWN;
624
625 session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
626 ASSERT_NE(session_->property_, nullptr);
627 session_->property_->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
628
629 SessionInfo info;
630 info.abilityName_ = "testSession1";
631 info.moduleName_ = "testSession2";
632 info.bundleName_ = "testSession3";
633 sptr<Session> dialogSession = sptr<Session>::MakeSptr(info);
634 sptr<Session> dialogSession2 = sptr<Session>::MakeSptr(info);
635 sptr<Session> dialogSession3 = sptr<Session>::MakeSptr(info);
636 ASSERT_NE(dialogSession, nullptr);
637 ASSERT_NE(dialogSession2, nullptr);
638 ASSERT_NE(dialogSession3, nullptr);
639 dialogSession2->SetSessionState(SessionState::STATE_FOREGROUND);
640 dialogSession3->SetSessionState(SessionState::STATE_ACTIVE);
641 dialogSession2->persistentId_ = 9;
642 session_->SetParentSession(dialogSession);
643 dialogSession->dialogVec_.push_back(dialogSession2);
644 dialogSession->dialogVec_.push_back(dialogSession3);
645 auto result = session_->TransferPointerEvent(pointerEvent);
646 EXPECT_EQ(result, WSError::WS_ERROR_NULLPTR);
647 }
648
649 /**
650 * @tc.name: TransferPointerEvent11
651 * @tc.desc: TransferPointerEvent Test
652 * @tc.type: FUNC
653 */
654 HWTEST_F(WindowSessionTest3, TransferPointerEvent11, Function | SmallTest | Level2)
655 {
656 ASSERT_NE(session_, nullptr);
657 session_->SetSessionState(SessionState::STATE_FOREGROUND);
658 std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
659 ASSERT_NE(pointerEvent, nullptr);
660
661 session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
662 ASSERT_NE(session_->property_, nullptr);
663 session_->property_->SetWindowType(WindowType::APP_WINDOW_BASE);
664
665 session_->windowEventChannel_ = nullptr;
666 auto result = session_->TransferPointerEvent(pointerEvent);
667 EXPECT_EQ(result, WSError::WS_ERROR_NULLPTR);
668 }
669
670 /**
671 * @tc.name: TransferFocusStateEvent03
672 * @tc.desc: TransferFocusStateEvent Test
673 * @tc.type: FUNC
674 */
675 HWTEST_F(WindowSessionTest3, TransferFocusStateEvent03, Function | SmallTest | Level2)
676 {
677 ASSERT_NE(session_, nullptr);
678 session_->windowEventChannel_ = nullptr;
679 session_->sessionInfo_.isSystem_ = true;
680 EXPECT_EQ(session_->TransferFocusStateEvent(true), WSError::WS_ERROR_NULLPTR);
681 }
682
683 /**
684 * @tc.name: Snapshot
685 * @tc.desc: Snapshot Test
686 * @tc.type: FUNC
687 */
688 HWTEST_F(WindowSessionTest3, Snapshot, Function | SmallTest | Level2)
689 {
690 ASSERT_NE(session_, nullptr);
691 int32_t persistentId = 1424;
692 std::string bundleName = "testBundleName";
693 session_->scenePersistence_ = sptr<ScenePersistence>::MakeSptr(bundleName, persistentId);
694 ASSERT_NE(session_->scenePersistence_, nullptr);
695 struct RSSurfaceNodeConfig config;
696 session_->surfaceNode_ = RSSurfaceNode::Create(config);
697 ASSERT_NE(session_->surfaceNode_, nullptr);
698 EXPECT_EQ(nullptr, session_->Snapshot(false, 0.0f));
699
700 session_->bufferAvailable_ = true;
701 EXPECT_EQ(nullptr, session_->Snapshot(false, 0.0f));
702
703 session_->surfaceNode_->bufferAvailable_ = true;
704 EXPECT_EQ(nullptr, session_->Snapshot(false, 0.0f));
705
706 session_->surfaceNode_ = nullptr;
707 EXPECT_EQ(nullptr, session_->Snapshot(false, 0.0f));
708 }
709
710 /**
711 * @tc.name: SetBufferAvailableChangeListener
712 * @tc.desc: SetBufferAvailableChangeListener Test
713 * @tc.type: FUNC
714 */
715 HWTEST_F(WindowSessionTest3, SetBufferAvailableChangeListener, Function | SmallTest | Level2)
716 {
717 ASSERT_NE(session_, nullptr);
718 session_->SetSessionState(SessionState::STATE_CONNECT);
719 session_->SetSessionStateChangeNotifyManagerListener(nullptr);
720
721 session_->bufferAvailable_ = true;
722 session_->SetBufferAvailableChangeListener(nullptr);
723
724 int resultValue = 0;
__anond30b60280402(const bool isAvailable) 725 NotifyBufferAvailableChangeFunc func = [&resultValue](const bool isAvailable) {
726 resultValue = 1;
727 };
728 session_->SetBufferAvailableChangeListener(func);
729 EXPECT_EQ(resultValue, 1);
730 }
731
732 /**
733 * @tc.name: NotifySessionFocusableChange
734 * @tc.desc: NotifySessionFocusableChange Test
735 * @tc.type: FUNC
736 */
737 HWTEST_F(WindowSessionTest3, NotifySessionFocusableChange, Function | SmallTest | Level2)
738 {
739 ASSERT_NE(session_, nullptr);
740 int resultValue = 0;
__anond30b60280502(const bool isFocusable) 741 NotifySessionFocusableChangeFunc func = [&resultValue](const bool isFocusable) {
742 resultValue = 1;
743 };
744 session_->SetSessionFocusableChangeListener(func);
745 session_->NotifySessionFocusableChange(true);
746
747 session_->sessionFocusableChangeFunc_ = nullptr;
748 session_->NotifySessionFocusableChange(true);
749 EXPECT_EQ(resultValue, 1);
750 }
751
752 /**
753 * @tc.name: GetStateFromManager
754 * @tc.desc: GetStateFromManager Test
755 * @tc.type: FUNC
756 */
757 HWTEST_F(WindowSessionTest3, GetStateFromManager, Function | SmallTest | Level2)
758 {
759 ManagerState key = ManagerState{0};
__anond30b60280602(const ManagerState key) 760 GetStateFromManagerFunc func = [](const ManagerState key) {
761 return true;
762 };
763 session_->getStateFromManagerFunc_ = func;
764 session_->GetStateFromManager(key);
765
766 session_->getStateFromManagerFunc_ = nullptr;
767 ASSERT_EQ(false, session_->GetStateFromManager(key));
768
769 // 覆盖default分支
770 key = ManagerState{-1};
771 ASSERT_EQ(false, session_->GetStateFromManager(key));
772 }
773
774 /**
775 * @tc.name: NotifyUIRequestFocus
776 * @tc.desc: NotifyUIRequestFocus Test
777 * @tc.type: FUNC
778 */
779 HWTEST_F(WindowSessionTest3, NotifyUIRequestFocus, Function | SmallTest | Level2)
780 {
__anond30b60280702() 781 session_->requestFocusFunc_ = []() {};
782 session_->NotifyUIRequestFocus();
783
784 ASSERT_NE(session_, nullptr);
785 }
786
787 /**
788 * @tc.name: SetCompatibleModeInPc
789 * @tc.desc: SetCompatibleModeInPc Test
790 * @tc.type: FUNC
791 */
792 HWTEST_F(WindowSessionTest3, SetCompatibleModeInPc, Function | SmallTest | Level2)
793 {
794 session_->property_ = nullptr;
795 auto enable = true;
796 auto isSupportDragInPcCompatibleMode = true;
797 ASSERT_EQ(WSError::WS_ERROR_NULLPTR, session_->SetCompatibleModeInPc(enable, isSupportDragInPcCompatibleMode));
798
799 session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
800 ASSERT_EQ(WSError::WS_OK, session_->SetCompatibleModeInPc(enable, isSupportDragInPcCompatibleMode));
801
802 enable = false;
803 ASSERT_EQ(WSError::WS_OK, session_->SetCompatibleModeInPc(enable, isSupportDragInPcCompatibleMode));
804 }
805
806 /**
807 * @tc.name: NotifySessionTouchableChange
808 * @tc.desc: NotifySessionTouchableChange Test
809 * @tc.type: FUNC
810 */
811 HWTEST_F(WindowSessionTest3, NotifySessionTouchableChange, Function | SmallTest | Level2)
812 {
813 ASSERT_NE(session_, nullptr);
814 int resultValue = 0;
__anond30b60280802(const bool touchable) 815 NotifySessionTouchableChangeFunc func = [&resultValue](const bool touchable) {
816 resultValue = 1;
817 };
818 session_->SetSessionTouchableChangeListener(func);
819 session_->NotifySessionTouchableChange(true);
820 EXPECT_EQ(resultValue, 1);
821 }
822
823 /**
824 * @tc.name: NotifyClick
825 * @tc.desc: NotifyClick Test
826 * @tc.type: FUNC
827 */
828 HWTEST_F(WindowSessionTest3, NotifyClick, Function | SmallTest | Level2)
829 {
830 ASSERT_NE(session_, nullptr);
831 int resultValue = 0;
__anond30b60280902() 832 NotifyClickFunc func = [&resultValue]() {
833 resultValue = 1;
834 };
835 session_->SetClickListener(func);
836 session_->NotifyClick();
837 EXPECT_EQ(resultValue, 1);
838 }
839
840 /**
841 * @tc.name: NotifyRequestFocusStatusNotifyManager
842 * @tc.desc: NotifyRequestFocusStatusNotifyManager Test
843 * @tc.type: FUNC
844 */
845 HWTEST_F(WindowSessionTest3, NotifyRequestFocusStatusNotifyManager, Function | SmallTest | Level2)
846 {
847 ASSERT_NE(session_, nullptr);
848 int resultValue = 0;
849 NotifyRequestFocusStatusNotifyManagerFunc func = [&resultValue](int32_t persistentId,
__anond30b60280a02(int32_t persistentId, const bool isFocused, const bool byForeground, FocusChangeReason reason) 850 const bool isFocused, const bool byForeground, FocusChangeReason reason) {
851 resultValue = 1;
852 };
853 session_->SetRequestFocusStatusNotifyManagerListener(func);
854 FocusChangeReason reason = FocusChangeReason::SCB_SESSION_REQUEST;
855 session_->NotifyRequestFocusStatusNotifyManager(true, false, reason);
856 EXPECT_EQ(resultValue, 1);
857 }
858
859 /**
860 * @tc.name: PresentFoucusIfNeed
861 * @tc.desc: PresentFoucusIfNeed Test
862 * @tc.type: FUNC
863 */
864 HWTEST_F(WindowSessionTest3, PresentFoucusIfNeed, Function | SmallTest | Level2)
865 {
866 ASSERT_NE(session_, nullptr);
867 int32_t pointerAction = MMI::PointerEvent::POINTER_ACTION_DOWN;
868 session_->PresentFoucusIfNeed(pointerAction);
869 pointerAction = MMI::PointerEvent::POINTER_ACTION_BUTTON_DOWN;
870 session_->PresentFoucusIfNeed(pointerAction);
871 session_->property_->focusable_ = false;
872 session_->PresentFoucusIfNeed(pointerAction);
873 session_->isFocused_ = true;
874 session_->PresentFoucusIfNeed(pointerAction);
875 EXPECT_EQ(true, session_->CheckPointerEventDispatch(nullptr));
876 }
877
878 /**
879 * @tc.name: UpdateFocus03
880 * @tc.desc: UpdateFocus Test
881 * @tc.type: FUNC
882 */
883 HWTEST_F(WindowSessionTest3, UpdateFocus03, Function | SmallTest | Level2)
884 {
885 ASSERT_NE(session_, nullptr);
886 session_->isFocused_ = true;
887 EXPECT_EQ(WSError::WS_OK, session_->UpdateFocus(false));
888 }
889
890 /**
891 * @tc.name: NotifyFocusStatus
892 * @tc.desc: NotifyFocusStatus Test
893 * @tc.type: FUNC
894 */
895 HWTEST_F(WindowSessionTest3, NotifyFocusStatus, Function | SmallTest | Level2)
896 {
897 ASSERT_NE(session_, nullptr);
898 session_->state_ = SessionState::STATE_CONNECT;
899 sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
900 EXPECT_NE(nullptr, mockSessionStage);
901 session_->sessionStage_ = mockSessionStage;
902 EXPECT_EQ(WSError::WS_OK, session_->NotifyFocusStatus(true));
903 }
904
905 /**
906 * @tc.name: RequestFocus
907 * @tc.desc: RequestFocus Test
908 * @tc.type: FUNC
909 */
910 HWTEST_F(WindowSessionTest3, RequestFocus, Function | SmallTest | Level2)
911 {
912 ASSERT_NE(session_, nullptr);
913 session_->state_ = SessionState::STATE_FOREGROUND;
914 session_->sessionInfo_.isSystem_ = false;
915 EXPECT_EQ(WSError::WS_OK, session_->RequestFocus(true));
916 EXPECT_EQ(WSError::WS_OK, session_->RequestFocus(false));
917 }
918
919 /**
920 * @tc.name: UpdateWindowMode
921 * @tc.desc: UpdateWindowMode Test
922 * @tc.type: FUNC
923 */
924 HWTEST_F(WindowSessionTest3, UpdateWindowMode, Function | SmallTest | Level2)
925 {
926 ASSERT_NE(session_, nullptr);
927 sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
928 EXPECT_NE(nullptr, mockSessionStage);
929 session_->sessionStage_ = mockSessionStage;
930
931 session_->state_ = SessionState::STATE_END;
932 auto result = session_->UpdateWindowMode(WindowMode::WINDOW_MODE_UNDEFINED);
933 EXPECT_EQ(result, WSError::WS_ERROR_INVALID_SESSION);
934
935 session_->state_ = SessionState::STATE_DISCONNECT;
936 result = session_->UpdateWindowMode(WindowMode::WINDOW_MODE_UNDEFINED);
937 EXPECT_EQ(session_->property_->windowMode_, WindowMode::WINDOW_MODE_UNDEFINED);
938 EXPECT_EQ(session_->property_->isNeedUpdateWindowMode_, true);
939 EXPECT_EQ(result, WSError::WS_OK);
940
941 session_->state_ = SessionState::STATE_CONNECT;
942 result = session_->UpdateWindowMode(WindowMode::WINDOW_MODE_SPLIT_SECONDARY);
943 EXPECT_EQ(session_->property_->windowMode_, WindowMode::WINDOW_MODE_SPLIT_SECONDARY);
944 EXPECT_EQ(session_->property_->maximizeMode_, MaximizeMode::MODE_RECOVER);
945 EXPECT_EQ(result, WSError::WS_OK);
946
947 session_->state_ = SessionState::STATE_CONNECT;
948 result = session_->UpdateWindowMode(WindowMode::WINDOW_MODE_SPLIT_PRIMARY);
949 EXPECT_EQ(result, WSError::WS_OK);
950
951 session_->state_ = SessionState::STATE_CONNECT;
952 result = session_->UpdateWindowMode(WindowMode::WINDOW_MODE_UNDEFINED);
953 EXPECT_EQ(result, WSError::WS_OK);
954 }
955
956 /**
957 * @tc.name: RectSizeCheckProcess
958 * @tc.desc: RectSizeCheckProcess Test
959 * @tc.type: FUNC
960 */
961 HWTEST_F(WindowSessionTest3, RectSizeCheckProcess, Function | SmallTest | Level2)
962 {
963 ASSERT_NE(session_, nullptr);
964 session_->RectSizeCheckProcess(1, 0, 2, 0, 0);
965 session_->RectSizeCheckProcess(1, 0, 1, 0, 0);
966 session_->RectSizeCheckProcess(0, 1, 0, 2, 0);
967 session_->RectSizeCheckProcess(0, 1, 0, 0, 0);
968 EXPECT_EQ(true, session_->CheckPointerEventDispatch(nullptr));
969 }
970
971 /**
972 * @tc.name: RectCheckProcess
973 * @tc.desc: RectCheckProcess Test
974 * @tc.type: FUNC
975 */
976 HWTEST_F(WindowSessionTest3, RectCheckProcess, Function | SmallTest | Level2)
977 {
978 ASSERT_NE(session_, nullptr);
979 session_->isVisible_ = true;
980 session_->property_ = nullptr;
981 session_->RectCheckProcess();
982
983 session_->state_ = SessionState::STATE_FOREGROUND;
984 session_->property_ = nullptr;
985 session_->RectCheckProcess();
986 EXPECT_EQ(true, session_->CheckPointerEventDispatch(nullptr));
987 }
988
989 /**
990 * @tc.name: SetAcquireRotateAnimationConfigFunc
991 * @tc.desc: SetAcquireRotateAnimationConfigFunc Test
992 * @tc.type: FUNC
993 */
994 HWTEST_F(WindowSessionTest3, SetAcquireRotateAnimationConfigFunc, Function | SmallTest | Level2)
995 {
996 ASSERT_NE(session_, nullptr);
997 session_->SetAcquireRotateAnimationConfigFunc(nullptr);
998 ASSERT_EQ(session_->acquireRotateAnimationConfigFunc_, nullptr);
999 int32_t duration = session_->GetRotateAnimationDuration();
1000 ASSERT_EQ(duration, ROTATE_ANIMATION_DURATION);
1001
__anond30b60280b02(RotateAnimationConfig& config) 1002 AcquireRotateAnimationConfigFunc func = [](RotateAnimationConfig& config) {
1003 config.duration_ = 800;
1004 };
1005 session_->SetAcquireRotateAnimationConfigFunc(func);
1006 ASSERT_NE(session_->acquireRotateAnimationConfigFunc_, nullptr);
1007 duration = session_->GetRotateAnimationDuration();
1008 ASSERT_EQ(duration, 800);
1009 }
1010
1011 /**
1012 * @tc.name: SetIsPcAppInPad
1013 * @tc.desc: SetIsPcAppInPad Test
1014 * @tc.type: FUNC
1015 */
1016 HWTEST_F(WindowSessionTest3, SetIsPcAppInPad, Function | SmallTest | Level2)
1017 {
1018 ASSERT_NE(session_, nullptr);
1019 bool isPcAppInPad = false;
1020 session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
1021 auto result = session_->SetIsPcAppInPad(isPcAppInPad);
1022 EXPECT_EQ(result, WSError::WS_OK);
1023
1024 session_->property_ = nullptr;
1025 EXPECT_EQ(WSError::WS_ERROR_NULLPTR, session_->SetIsPcAppInPad(isPcAppInPad));
1026 }
1027
1028 /**
1029 * @tc.name: SetBufferAvailable
1030 * @tc.desc: SetBufferAvailable Test
1031 * @tc.type: FUNC
1032 */
1033 HWTEST_F(WindowSessionTest3, SetBufferAvailable, Function | SmallTest | Level2)
1034 {
1035 int resultValue = 0;
__anond30b60280c02(const bool isAvailable) 1036 NotifyBufferAvailableChangeFunc func = [&resultValue](const bool isAvailable) {
1037 resultValue = 1;
1038 };
1039 session_->SetBufferAvailableChangeListener(func);
1040 session_->SetBufferAvailable(true);
1041 ASSERT_EQ(session_->bufferAvailable_, true);
1042 }
1043
1044 /**
1045 * @tc.name: NotifySessionInfoChange
1046 * @tc.desc: NotifySessionInfoChange Test
1047 * @tc.type: FUNC
1048 */
1049 HWTEST_F(WindowSessionTest3, NotifySessionInfoChange, Function | SmallTest | Level2)
1050 {
1051 int resultValue = 0;
__anond30b60280d02(const bool isAvailable) 1052 NotifyBufferAvailableChangeFunc func = [&resultValue](const bool isAvailable) {
1053 resultValue = 1;
1054 };
1055 session_->SetSessionInfoChangeNotifyManagerListener(func);
1056 session_->NotifySessionInfoChange();
1057 ASSERT_EQ(resultValue, 1);
1058 }
1059
1060 /**
1061 * @tc.name: RectSizeCheckProcess01
1062 * @tc.desc: RectSizeCheckProcess Test
1063 * @tc.type: FUNC
1064 */
1065 HWTEST_F(WindowSessionTest3, RectSizeCheckProcess01, Function | SmallTest | Level2)
1066 {
1067 session_->SetSessionProperty(nullptr);
1068 session_->RectSizeCheckProcess(1, 1, 2, 2, 0);
1069 ASSERT_EQ(session_->property_, nullptr);
1070 }
1071
1072 /**
1073 * @tc.name: SetCompatibleModeEnableInPad
1074 * @tc.desc: SetCompatibleModeEnableInPad Test
1075 * @tc.type: FUNC
1076 */
1077 HWTEST_F(WindowSessionTest3, SetCompatibleModeEnableInPad, Function | SmallTest | Level2)
1078 {
1079 ASSERT_NE(session_, nullptr);
1080 session_->state_ = SessionState::STATE_FOREGROUND;
1081 sptr<SessionStageMocker> mockSessionStage = sptr<SessionStageMocker>::MakeSptr();
1082 EXPECT_NE(nullptr, mockSessionStage);
1083 session_->sessionStage_ = mockSessionStage;
1084 session_->property_ = nullptr;
1085 bool enable = true;
1086 ASSERT_EQ(WSError::WS_ERROR_NULLPTR, session_->SetCompatibleModeEnableInPad(enable));
1087
1088 session_->property_ = sptr<WindowSessionProperty>::MakeSptr();
1089 ASSERT_EQ(WSError::WS_OK, session_->SetCompatibleModeEnableInPad(enable));
1090
1091 enable = false;
1092 ASSERT_EQ(WSError::WS_OK, session_->SetCompatibleModeEnableInPad(enable));
1093 }
1094
1095 /**
1096 * @tc.name: SetStartingBeforeVisible
1097 * @tc.desc: test SetStartingBeforeVisible
1098 * @tc.type: FUNC
1099 */
1100 HWTEST_F(WindowSessionTest3, SetStartingBeforeVisible, Function | SmallTest | Level2)
1101 {
1102 ASSERT_NE(session_, nullptr);
1103 session_->SetStartingBeforeVisible(true);
1104 ASSERT_EQ(true, session_->isStartingBeforeVisible_);
1105 ASSERT_EQ(true, session_->GetStartingBeforeVisible());
1106
1107 session_->SetStartingBeforeVisible(false);
1108 ASSERT_EQ(false, session_->isStartingBeforeVisible_);
1109 ASSERT_EQ(false, session_->GetStartingBeforeVisible());
1110 }
1111
1112 /**
1113 * @tc.name: SetFreezeImmediately
1114 * @tc.desc: SetFreezeImmediately Test
1115 * @tc.type: FUNC
1116 */
1117 HWTEST_F(WindowSessionTest3, SetFreezeImmediately, Function | SmallTest | Level2)
1118 {
1119 ASSERT_NE(session_, nullptr);
1120 struct RSSurfaceNodeConfig config;
1121 session_->surfaceNode_ = RSSurfaceNode::Create(config);
1122 ASSERT_NE(session_->surfaceNode_, nullptr);
1123 ASSERT_EQ(nullptr, session_->SetFreezeImmediately(1.0f, false));
1124 session_->surfaceNode_->bufferAvailable_ = true;
1125 ASSERT_EQ(nullptr, session_->SetFreezeImmediately(1.0f, false));
1126 ASSERT_EQ(nullptr, session_->SetFreezeImmediately(1.0f, true));
1127 session_->surfaceNode_ = nullptr;
1128 ASSERT_EQ(nullptr, session_->SetFreezeImmediately(1.0f, false));
1129 }
1130 }
1131 } // namespace Rosen
1132 } // namespace OHOS