1 /*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <gtest/gtest.h>
17 #include <regex>
18 #include <pointer_event.h>
19 #include <ui/rs_surface_node.h>
20
21 #include "mock/mock_session_stage.h"
22 #include "mock/mock_window_event_channel.h"
23 #include "mock/mock_pattern_detach_callback.h"
24 #include "session/host/include/extension_session.h"
25 #include "session/host/include/move_drag_controller.h"
26 #include "session/host/include/scene_session.h"
27 #include "session_manager/include/scene_session_manager.h"
28 #include "session/host/include/session.h"
29 #include "session_info.h"
30 #include "key_event.h"
31 #include "wm_common.h"
32 #include "window_event_channel_base.h"
33 #include "window_manager_hilog.h"
34
35 using namespace testing;
36 using namespace testing::ext;
37
38 namespace OHOS {
39 namespace Rosen {
40 namespace {
41 const std::string UNDEFINED = "undefined";
42 }
43
44 class WindowSessionTest : public testing::Test {
45 public:
46 static void SetUpTestCase();
47 static void TearDownTestCase();
48 void SetUp() override;
49 void TearDown() override;
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 class TLifecycleListener : public ILifecycleListener {
59 public:
~TLifecycleListener()60 virtual ~TLifecycleListener() {}
OnActivation()61 void OnActivation() override {}
OnConnect()62 void OnConnect() override {}
OnForeground()63 void OnForeground() override {}
OnBackground()64 void OnBackground() override {}
OnDisconnect()65 void OnDisconnect() override {}
OnExtensionDied()66 void OnExtensionDied() override {}
OnExtensionTimeout(int32_t errorCode)67 void OnExtensionTimeout(int32_t errorCode) override {}
OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo & info,int64_t uiExtensionIdLevel)68 void OnAccessibilityEvent(const Accessibility::AccessibilityEventInfo& info,
69 int64_t uiExtensionIdLevel) override {}
OnDrawingCompleted()70 void OnDrawingCompleted() override {}
OnAppRemoveStartingWindow()71 void OnAppRemoveStartingWindow() override {}
72 };
73 std::shared_ptr<TLifecycleListener> lifecycleListener_ = std::make_shared<TLifecycleListener>();
74
75 sptr<SessionStageMocker> mockSessionStage_ = nullptr;
76 sptr<WindowEventChannelMocker> mockEventChannel_ = nullptr;
77 };
78
SetUpTestCase()79 void WindowSessionTest::SetUpTestCase()
80 {
81 }
82
TearDownTestCase()83 void WindowSessionTest::TearDownTestCase()
84 {
85 }
86
SetUp()87 void WindowSessionTest::SetUp()
88 {
89 SessionInfo info;
90 info.abilityName_ = "testSession1";
91 info.moduleName_ = "testSession2";
92 info.bundleName_ = "testSession3";
93 session_ = new (std::nothrow) Session(info);
94 session_->surfaceNode_ = CreateRSSurfaceNode();
95 EXPECT_NE(nullptr, session_);
96 ssm_ = new SceneSessionManager();
97 session_->SetEventHandler(ssm_->taskScheduler_->GetEventHandler(), ssm_->eventHandler_);
98 auto isScreenLockedCallback = [this]() {
99 return ssm_->IsScreenLocked();
100 };
101 session_->RegisterIsScreenLockedCallback(isScreenLockedCallback);
102
103 mockSessionStage_ = new (std::nothrow) SessionStageMocker();
104 ASSERT_NE(mockSessionStage_, nullptr);
105
106 mockEventChannel_ = new (std::nothrow) WindowEventChannelMocker(mockSessionStage_);
107 ASSERT_NE(mockEventChannel_, nullptr);
108 }
109
TearDown()110 void WindowSessionTest::TearDown()
111 {
112 session_ = nullptr;
113 usleep(WAIT_SYNC_IN_NS);
114 }
115
CreateRSSurfaceNode()116 RSSurfaceNode::SharedPtr WindowSessionTest::CreateRSSurfaceNode()
117 {
118 struct RSSurfaceNodeConfig rsSurfaceNodeConfig;
119 rsSurfaceNodeConfig.SurfaceNodeName = "WindowSessionTestSurfaceNode";
120 auto surfaceNode = RSSurfaceNode::Create(rsSurfaceNodeConfig);
121 if (surfaceNode == nullptr) {
122 GTEST_LOG_(INFO) << "WindowSessionTest::CreateRSSurfaceNode surfaceNode is nullptr";
123 }
124 return surfaceNode;
125 }
126
GetTaskCount()127 int32_t WindowSessionTest::GetTaskCount()
128 {
129 std::string dumpInfo = session_->handler_->GetEventRunner()->GetEventQueue()->DumpCurrentQueueSize();
130 std::regex pattern("\\d+");
131 std::smatch matches;
132 int32_t taskNum = 0;
133 while (std::regex_search(dumpInfo, matches, pattern)) {
134 taskNum += std::stoi(matches.str());
135 dumpInfo = matches.suffix();
136 }
137 return taskNum;
138 }
139
140 namespace {
141 /**
142 * @tc.name: SetForceTouchable
143 * @tc.desc: SetForceTouchable
144 * @tc.type: FUNC
145 */
146 HWTEST_F(WindowSessionTest, SetForceTouchable, Function | SmallTest | Level2)
147 {
148 ASSERT_NE(session_, nullptr);
149 bool touchable = false;
150 session_->SetForceTouchable(touchable);
151 ASSERT_EQ(session_->forceTouchable_, touchable);
152 }
153
154 /**
155 * @tc.name: SetActive01
156 * @tc.desc: set session active
157 * @tc.type: FUNC
158 * @tc.require: #I6JLSI
159 */
160 HWTEST_F(WindowSessionTest, SetActive01, Function | SmallTest | Level2)
161 {
162 sptr<ISession> sessionToken = nullptr;
163 sptr<SessionStageMocker> mockSessionStage = new(std::nothrow) SessionStageMocker();
164 EXPECT_NE(nullptr, mockSessionStage);
165 EXPECT_CALL(*(mockSessionStage), SetActive(_)).WillOnce(Return(WSError::WS_OK));
166 EXPECT_CALL(*(mockSessionStage), UpdateRect(_, _, _, _)).Times(0).WillOnce(Return(WSError::WS_OK));
167 session_->sessionStage_ = mockSessionStage;
168 ASSERT_EQ(WSError::WS_ERROR_INVALID_SESSION, session_->SetActive(true));
169
170 sptr<WindowEventChannelMocker> mockEventChannel = new(std::nothrow) WindowEventChannelMocker(mockSessionStage);
171 EXPECT_NE(nullptr, mockEventChannel);
172 auto surfaceNode = CreateRSSurfaceNode();
173 SystemSessionConfig sessionConfig;
174 sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
175 ASSERT_NE(nullptr, property);
176 ASSERT_EQ(WSError::WS_OK, session_->Connect(mockSessionStage,
177 mockEventChannel, surfaceNode, sessionConfig, property));
178 ASSERT_EQ(WSError::WS_ERROR_INVALID_SESSION, session_->SetActive(true));
179 ASSERT_EQ(false, session_->isActive_);
180
181 session_->UpdateSessionState(SessionState::STATE_FOREGROUND);
182 ASSERT_EQ(WSError::WS_OK, session_->SetActive(true));
183 ASSERT_EQ(true, session_->isActive_);
184 }
185
186 /**
187 * @tc.name: SetCompatibleModeEnableInPad
188 * @tc.desc: SetCompatibleModeEnableInPad test
189 * @tc.type: FUNC
190 */
191 HWTEST_F(WindowSessionTest, SetCompatibleModeEnableInPad, Function | SmallTest | Level2)
192 {
193 sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
194 ASSERT_NE(nullptr, property);
195 bool enable = true;
196 property->SetCompatibleModeEnableInPad(enable);
197 ASSERT_EQ(property->GetCompatibleModeEnableInPad(), true);
198 }
199
200 /**
201 * @tc.name: UpdateRect01
202 * @tc.desc: update rect
203 * @tc.type: FUNC
204 * @tc.require: #I6JLSI
205 */
206 HWTEST_F(WindowSessionTest, UpdateRect01, Function | SmallTest | Level2)
207 {
208 sptr<ISession> sessionToken = nullptr;
209 sptr<SessionStageMocker> mockSessionStage = new(std::nothrow) SessionStageMocker();
210 EXPECT_NE(nullptr, mockSessionStage);
211 session_->sessionStage_ = mockSessionStage;
212 EXPECT_CALL(*(mockSessionStage), UpdateRect(_, _, _, _)).Times(AtLeast(1)).WillOnce(Return(WSError::WS_OK));
213
214 WSRect rect = {0, 0, 0, 0};
215 ASSERT_EQ(WSError::WS_ERROR_INVALID_SESSION, session_->UpdateRect(rect,
216 SizeChangeReason::UNDEFINED, "WindowSessionTest"));
217 sptr<WindowEventChannelMocker> mockEventChannel = new(std::nothrow) WindowEventChannelMocker(mockSessionStage);
218 EXPECT_NE(nullptr, mockEventChannel);
219 SystemSessionConfig sessionConfig;
220 sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
221 ASSERT_NE(nullptr, property);
222 ASSERT_EQ(WSError::WS_OK, session_->Connect(mockSessionStage,
223 mockEventChannel, nullptr, sessionConfig, property));
224
225 rect = {0, 0, 100, 100};
226 ASSERT_EQ(WSError::WS_ERROR_INVALID_SESSION, session_->UpdateRect(rect,
227 SizeChangeReason::UNDEFINED, "WindowSessionTest"));
228 ASSERT_EQ(rect, session_->winRect_);
229
230 session_->UpdateSessionState(SessionState::STATE_ACTIVE);
231 ASSERT_EQ(WSError::WS_OK, session_->UpdateRect(rect, SizeChangeReason::UNDEFINED, "WindowSessionTest"));
232
233 session_->sessionStage_ = nullptr;
234 ASSERT_EQ(WSError::WS_OK, session_->UpdateRect(rect, SizeChangeReason::UNDEFINED, "WindowSessionTest"));
235 }
236
237 /**
238 * @tc.name: IsSessionValid01
239 * @tc.desc: check func IsSessionValid
240 * @tc.type: FUNC
241 */
242 HWTEST_F(WindowSessionTest, IsSessionValid01, Function | SmallTest | Level2)
243 {
244 session_->state_ = SessionState::STATE_DISCONNECT;
245 ASSERT_FALSE(session_->IsSessionValid());
246 session_->state_ = SessionState::STATE_CONNECT;
247 ASSERT_TRUE(session_->IsSessionValid());
248 }
249
250 /**
251 * @tc.name: ConnectInner
252 * @tc.desc: ConnectInner
253 * @tc.type: FUNC
254 */
255 HWTEST_F(WindowSessionTest, ConnectInner, Function | SmallTest | Level2)
256 {
257 SystemSessionConfig sessionConfig;
258 session_->state_ = SessionState::STATE_CONNECT;
259 session_->isTerminating_ = false;
260 sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
261
262 property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
263 property->SetIsNeedUpdateWindowMode(true);
264 session_->SetScreenId(233);
265 session_->SetSessionProperty(property);
266 auto res = session_->ConnectInner(mockSessionStage_, mockEventChannel_,
267 nullptr, sessionConfig, property, nullptr, 1, 1, "");
268 ASSERT_EQ(res, WSError::WS_ERROR_INVALID_SESSION);
269
270 session_->isTerminating_ = true;
271 auto res2 = session_->ConnectInner(mockSessionStage_, mockEventChannel_,
272 nullptr, sessionConfig, property, nullptr, 1, 1, "");
273 ASSERT_EQ(res2, WSError::WS_OK);
274
275 property->SetWindowType(WindowType::APP_MAIN_WINDOW_END);
276 property->SetIsNeedUpdateWindowMode(true);
277 session_->SetScreenId(SCREEN_ID_INVALID);
278 session_->SetSessionProperty(property);
279 auto res3 = session_->ConnectInner(mockSessionStage_, mockEventChannel_,
280 nullptr, sessionConfig, property, nullptr, 1, 1, "");
281 ASSERT_EQ(res3, WSError::WS_OK);
282 }
283
284 /**
285 * @tc.name: RemoveLifeCycleTask
286 * @tc.desc: RemoveLifeCycleTask & PostLifeCycleTask
287 * @tc.type: FUNC
288 */
289 HWTEST_F(WindowSessionTest, LifeCycleTask, Function | SmallTest | Level2)
290 {
__anoncdc0beff0402() 291 auto task = []() {};
292 session_->PostLifeCycleTask(task, "task1", LifeCycleTaskType::START);
293 ASSERT_EQ(session_->lifeCycleTaskQueue_.size(), 1);
294
__anoncdc0beff0502() 295 auto task2 = []() {};
296 session_->PostLifeCycleTask(task2, "task2", LifeCycleTaskType::START);
297 ASSERT_EQ(session_->lifeCycleTaskQueue_.size(), 2);
298
299 LifeCycleTaskType taskType = LifeCycleTaskType{0};
300
301 session_->RemoveLifeCycleTask(taskType);
302 ASSERT_EQ(session_->lifeCycleTaskQueue_.size(), 1);
303
304 session_->RemoveLifeCycleTask(taskType);
305 ASSERT_EQ(session_->lifeCycleTaskQueue_.size(), 0);
306 }
307
308 /**
309 * @tc.name: SetSessionProperty01
310 * @tc.desc: SetSessionProperty
311 * @tc.type: FUNC
312 */
313 HWTEST_F(WindowSessionTest, SetSessionProperty01, Function | SmallTest | Level2)
314 {
315 ASSERT_EQ(session_->SetSessionProperty(nullptr), WSError::WS_OK);
316 }
317
318 /**
319 * @tc.name: SetSessionRect
320 * @tc.desc: check func SetSessionRect
321 * @tc.type: FUNC
322 */
323 HWTEST_F(WindowSessionTest, SetSessionRect, Function | SmallTest | Level2)
324 {
325 ASSERT_NE(session_, nullptr);
326 WSRect rect = { 0, 0, 320, 240}; // width: 320, height: 240
327 session_->SetSessionRect(rect);
328 ASSERT_EQ(rect, session_->winRect_);
329 }
330
331 /**
332 * @tc.name: GetSessionRect
333 * @tc.desc: check func GetSessionRect
334 * @tc.type: FUNC
335 */
336 HWTEST_F(WindowSessionTest, GetSessionRect, Function | SmallTest | Level2)
337 {
338 ASSERT_NE(session_, nullptr);
339 WSRect rect = { 0, 0, 320, 240}; // width: 320, height: 240
340 session_->SetSessionRect(rect);
341 ASSERT_EQ(rect, session_->GetSessionRect());
342 }
343
344 /**
345 * @tc.name: GetLayoutRect
346 * @tc.desc: check func GetLayoutRect
347 * @tc.type: FUNC
348 */
349 HWTEST_F(WindowSessionTest, GetLayoutRect, Function | SmallTest | Level2)
350 {
351 ASSERT_NE(session_, nullptr);
352 WSRect rect = { 0, 0, 320, 240 }; // width: 320, height: 240
353 session_->layoutRect_ = rect;
354 session_->lastLayoutRect_ = session_->layoutRect_;
355 ASSERT_EQ(rect, session_->GetLayoutRect());
356 ASSERT_EQ(rect, session_->GetLastLayoutRect());
357 }
358
359 /**
360 * @tc.name: CheckDialogOnForeground
361 * @tc.desc: check func CheckDialogOnForeground
362 * @tc.type: FUNC
363 */
364 HWTEST_F(WindowSessionTest, CheckDialogOnForeground, Function | SmallTest | Level2)
365 {
366 ASSERT_NE(session_, nullptr);
367 session_->dialogVec_.clear();
368 ASSERT_EQ(false, session_->CheckDialogOnForeground());
369 SessionInfo info;
370 info.abilityName_ = "dialogAbilityName";
371 info.moduleName_ = "dialogModuleName";
372 info.bundleName_ = "dialogBundleName";
373 sptr<Session> dialogSession = new (std::nothrow) Session(info);
374 ASSERT_NE(dialogSession, nullptr);
375 dialogSession->state_ = SessionState::STATE_INACTIVE;
376 session_->dialogVec_.push_back(dialogSession);
377 ASSERT_EQ(false, session_->CheckDialogOnForeground());
378 session_->dialogVec_.clear();
379 }
380
381 /**
382 * @tc.name: IsTopDialog
383 * @tc.desc: check func IsTopDialog
384 * @tc.type: FUNC
385 */
386 HWTEST_F(WindowSessionTest, IsTopDialog, Function | SmallTest | Level2)
387 {
388 ASSERT_NE(session_, nullptr);
389 session_->dialogVec_.clear();
390 SessionInfo info;
391 info.abilityName_ = "testSession1";
392 info.moduleName_ = "testSession2";
393 info.bundleName_ = "testSession3";
394
395 sptr<Session> dialogSession1 = new (std::nothrow) Session(info);
396 ASSERT_NE(dialogSession1, nullptr);
397 dialogSession1->persistentId_ = 33;
398 dialogSession1->SetParentSession(session_);
399 dialogSession1->state_ = SessionState::STATE_ACTIVE;
400 session_->dialogVec_.push_back(dialogSession1);
401
402 sptr<Session> dialogSession2 = new (std::nothrow) Session(info);
403 ASSERT_NE(dialogSession2, nullptr);
404 dialogSession2->persistentId_ = 34;
405 dialogSession2->SetParentSession(session_);
406 dialogSession2->state_ = SessionState::STATE_ACTIVE;
407 session_->dialogVec_.push_back(dialogSession2);
408
409 sptr<Session> dialogSession3 = new (std::nothrow) Session(info);
410 ASSERT_NE(dialogSession3, nullptr);
411 dialogSession3->persistentId_ = 35;
412 dialogSession3->SetParentSession(session_);
413 dialogSession3->state_ = SessionState::STATE_INACTIVE;
414 session_->dialogVec_.push_back(dialogSession3);
415
416 ASSERT_EQ(false, dialogSession3->IsTopDialog());
417 ASSERT_EQ(true, dialogSession2->IsTopDialog());
418 ASSERT_EQ(false, dialogSession1->IsTopDialog());
419 session_->dialogVec_.clear();
420 }
421
422 /**
423 * @tc.name: GetGlobalScaledRect
424 * @tc.desc: GetGlobalScaledRect
425 * @tc.type: FUNC
426 */
427 HWTEST_F(WindowSessionTest, GetGlobalScaledRect, Function | SmallTest | Level2)
428 {
429 SessionInfo info;
430 sptr<SceneSession> sceneSession = sptr<SceneSession>::MakeSptr(info, nullptr);
431 Rect globalScaledRect;
432 sceneSession->globalRect_ = {100, 100, 50, 40};
433 sceneSession->isScbCoreEnabled_ = true;
434 sceneSession->scaleX_ = 0.5f;
435 sceneSession->scaleY_ = 0.5f;
436 WMError ret = sceneSession->GetGlobalScaledRect(globalScaledRect);
437 ASSERT_EQ(WMError::WM_OK, ret);
438 ASSERT_EQ(100, globalScaledRect.posX_);
439 ASSERT_EQ(100, globalScaledRect.posY_);
440 ASSERT_EQ(25, globalScaledRect.width_);
441 ASSERT_EQ(20, globalScaledRect.height_);
442 }
443
444 /**
445 * @tc.name: RaiseToAppTop01
446 * @tc.desc: RaiseToAppTop
447 * @tc.type: FUNC
448 */
449 HWTEST_F(WindowSessionTest, RaiseToAppTop01, Function | SmallTest | Level2)
450 {
451 SessionInfo info;
452 info.abilityName_ = "testSession1";
453 info.bundleName_ = "testSession3";
454 sptr<SceneSession> scensession = new (std::nothrow) SceneSession(info, nullptr);
455 EXPECT_NE(scensession, nullptr);
456 auto result = scensession->RaiseToAppTop();
457 ASSERT_EQ(result, WSError::WS_OK);
458
459 sptr<SceneSession::SessionChangeCallback> scensessionchangeCallBack =
460 new (std::nothrow) SceneSession::SessionChangeCallback();
461 EXPECT_NE(scensessionchangeCallBack, nullptr);
462 scensession->RegisterSessionChangeCallback(scensessionchangeCallBack);
463 result = scensession->RaiseToAppTop();
464 ASSERT_EQ(result, WSError::WS_OK);
465
__anoncdc0beff0602() 466 NotifyRaiseToTopFunc onRaiseToTop_ = []() {};
467 scensessionchangeCallBack->onRaiseToTop_ = onRaiseToTop_;
468 result = scensession->RaiseToAppTop();
469 ASSERT_EQ(result, WSError::WS_OK);
470 }
471
472 /**
473 * @tc.name: UpdateSessionRect01
474 * @tc.desc: UpdateSessionRect
475 * @tc.type: FUNC
476 */
477 HWTEST_F(WindowSessionTest, UpdateSessionRect01, Function | SmallTest | Level2)
478 {
479 SessionInfo info;
480 info.abilityName_ = "testSession1";
481 info.bundleName_ = "testSession3";
482 sptr<SceneSession> scensession = new (std::nothrow) SceneSession(info, nullptr);
483 EXPECT_NE(scensession, nullptr);
484 WSRect rect = {0, 0, 320, 240}; // width: 320, height: 240
485 auto result = scensession->UpdateSessionRect(rect, SizeChangeReason::RESIZE);
486 ASSERT_EQ(result, WSError::WS_OK);
487
488 sptr<SceneSession::SessionChangeCallback> scensessionchangeCallBack =
489 new (std::nothrow) SceneSession::SessionChangeCallback();
490 EXPECT_NE(scensessionchangeCallBack, nullptr);
491 scensession->RegisterSessionChangeCallback(scensessionchangeCallBack);
492 result = scensession->UpdateSessionRect(rect, SizeChangeReason::RESIZE);
493 ASSERT_EQ(result, WSError::WS_OK);
494 }
495
496 /**
497 * @tc.name: OnSessionEvent01
498 * @tc.desc: OnSessionEvent
499 * @tc.type: FUNC
500 */
501 HWTEST_F(WindowSessionTest, OnSessionEvent01, Function | SmallTest | Level2)
502 {
503 SessionInfo info;
504 info.abilityName_ = "testSession1";
505 info.bundleName_ = "testSession3";
506 sptr<SceneSession> scensession = new (std::nothrow) SceneSession(info, nullptr);
507 EXPECT_NE(scensession, nullptr);
508 auto result = scensession->OnSessionEvent(SessionEvent::EVENT_MINIMIZE);
509 ASSERT_EQ(result, WSError::WS_OK);
510
511 sptr<SceneSession::SessionChangeCallback> scensessionchangeCallBack =
512 new (std::nothrow) SceneSession::SessionChangeCallback();
513 EXPECT_NE(scensessionchangeCallBack, nullptr);
514 scensession->RegisterSessionChangeCallback(scensessionchangeCallBack);
515 result = scensession->OnSessionEvent(SessionEvent::EVENT_MINIMIZE);
516 ASSERT_EQ(result, WSError::WS_OK);
517
518 int resultValue = 0;
519 NotifySessionEventFunc onSessionEvent_ = [&resultValue](int32_t eventId, SessionEventParam param)
__anoncdc0beff0702(int32_t eventId, SessionEventParam param) 520 { resultValue = 1; };
521 scensessionchangeCallBack->OnSessionEvent_ = onSessionEvent_;
522 result = scensession->OnSessionEvent(SessionEvent::EVENT_MINIMIZE);
523 ASSERT_EQ(result, WSError::WS_OK);
524 }
525
526 /**
527 * @tc.name: ConsumeMoveEvent01
528 * @tc.desc: ConsumeMoveEvent, abnormal scene
529 * @tc.type: FUNC
530 */
531 HWTEST_F(WindowSessionTest, ConsumeMoveEvent01, Function | SmallTest | Level2)
532 {
533 SessionInfo info;
534 info.abilityName_ = "testSession1";
535 info.bundleName_ = "testSession3";
536 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
537 sceneSession->moveDragController_ = new MoveDragController(1);
538 EXPECT_NE(sceneSession, nullptr);
539 ASSERT_TRUE(sceneSession->moveDragController_);
540 sceneSession->moveDragController_->InitMoveDragProperty();
541 WSRect originalRect = { 100, 100, 1000, 1000 };
542
543 std::shared_ptr<MMI::PointerEvent> pointerEvent = nullptr;
544 auto result = sceneSession->moveDragController_->ConsumeMoveEvent(pointerEvent, originalRect);
545 ASSERT_FALSE(result);
546
547 pointerEvent = MMI::PointerEvent::Create();
548 ASSERT_TRUE(pointerEvent);
549 pointerEvent->SetPointerId(1);
550 sceneSession->moveDragController_->moveDragProperty_.pointerId_ = 0;
551 result = sceneSession->moveDragController_->ConsumeMoveEvent(pointerEvent, originalRect);
552 ASSERT_FALSE(result);
553
554 pointerEvent->SetPointerId(0);
555 pointerEvent->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_MOUSE);
556 pointerEvent->SetButtonId(MMI::PointerEvent::MOUSE_BUTTON_RIGHT);
557 result = sceneSession->moveDragController_->ConsumeMoveEvent(pointerEvent, originalRect);
558 ASSERT_FALSE(result);
559 }
560
561 /**
562 * @tc.name: ConsumeMoveEvent02
563 * @tc.desc: ConsumeMoveEvent, normal secne
564 * @tc.type: FUNC
565 */
566 HWTEST_F(WindowSessionTest, ConsumeMoveEvent02, Function | SmallTest | Level2)
567 {
568 SessionInfo info;
569 info.abilityName_ = "testSession1";
570 info.bundleName_ = "testSession3";
571 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
572 EXPECT_NE(sceneSession, nullptr);
573 sceneSession->moveDragController_ = new MoveDragController(1);
574 ASSERT_TRUE(sceneSession->moveDragController_);
575 sceneSession->moveDragController_->InitMoveDragProperty();
576 WSRect originalRect = { 100, 100, 1000, 1000 };
577 sceneSession->moveDragController_->isStartMove_ = true;
578 std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
579 ASSERT_TRUE(pointerEvent);
580 pointerEvent->SetAgentWindowId(1);
581 pointerEvent->SetPointerId(0);
582 pointerEvent->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
583 MMI::PointerEvent::PointerItem pointerItem;
584 pointerItem.SetPointerId(0);
585 pointerEvent->AddPointerItem(pointerItem);
586
587 pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_MOVE);
588 pointerItem.SetDisplayX(115);
589 pointerItem.SetDisplayY(500);
590 pointerItem.SetWindowX(15);
591 pointerItem.SetWindowY(400);
592 auto result = sceneSession->moveDragController_->ConsumeMoveEvent(pointerEvent, originalRect);
593 ASSERT_EQ(result, true);
594
595 pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_MOVE);
596 pointerItem.SetDisplayX(145);
597 pointerItem.SetDisplayY(550);
598 result = sceneSession->moveDragController_->ConsumeMoveEvent(pointerEvent, originalRect);
599 ASSERT_EQ(result, true);
600
601 pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_MOVE);
602 pointerItem.SetDisplayX(175);
603 pointerItem.SetDisplayY(600);
604 result = sceneSession->moveDragController_->ConsumeMoveEvent(pointerEvent, originalRect);
605 ASSERT_EQ(result, true);
606
607 pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_UP);
608 pointerItem.SetDisplayX(205);
609 pointerItem.SetDisplayY(650);
610 result = sceneSession->moveDragController_->ConsumeMoveEvent(pointerEvent, originalRect);
611 ASSERT_EQ(result, false);
612 }
613
614 /**
615 * @tc.name: ConsumeDragEvent01
616 * @tc.desc: ConsumeDragEvent, abnormal scene
617 * @tc.type: FUNC
618 */
619 HWTEST_F(WindowSessionTest, ConsumeDragEvent01, Function | SmallTest | Level2)
620 {
621 SessionInfo info;
622 info.abilityName_ = "testSession1";
623 info.bundleName_ = "testSession3";
624 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
625 EXPECT_NE(sceneSession, nullptr);
626 sceneSession->moveDragController_ = new MoveDragController(1);
627 ASSERT_TRUE(sceneSession->moveDragController_);
628 sceneSession->moveDragController_->InitMoveDragProperty();
629 WSRect originalRect = { 100, 100, 1000, 1000 };
630 SystemSessionConfig sessionConfig;
631
632 std::shared_ptr<MMI::PointerEvent> pointerEvent = nullptr;
633 sptr<WindowSessionProperty> property = nullptr;
634 auto result = sceneSession->moveDragController_->ConsumeDragEvent(pointerEvent, originalRect, property,
635 sessionConfig);
636 ASSERT_EQ(result, false);
637
638 pointerEvent = MMI::PointerEvent::Create();
639 ASSERT_TRUE(pointerEvent);
640 pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_UP);
641 property = new WindowSessionProperty();
642 sceneSession->moveDragController_->isStartDrag_ = false;
643 result = sceneSession->moveDragController_->ConsumeDragEvent(pointerEvent, originalRect, property, sessionConfig);
644 ASSERT_EQ(result, false);
645
646 pointerEvent->SetPointerId(1);
647 sceneSession->moveDragController_->moveDragProperty_.pointerId_ = 0;
648 sceneSession->moveDragController_->isStartDrag_ = true;
649 result = sceneSession->moveDragController_->ConsumeDragEvent(pointerEvent, originalRect, property, sessionConfig);
650 ASSERT_EQ(result, false);
651
652 pointerEvent->SetPointerId(0);
653 result = sceneSession->moveDragController_->ConsumeDragEvent(pointerEvent, originalRect, property, sessionConfig);
654 ASSERT_EQ(result, false);
655 }
656
657 /**
658 * @tc.name: ConsumeDragEvent02
659 * @tc.desc: ConsumeDragEvent, normal scene
660 * @tc.type: FUNC
661 */
662 HWTEST_F(WindowSessionTest, ConsumeDragEvent02, Function | SmallTest | Level2)
663 {
664 SessionInfo info;
665 info.abilityName_ = "testSession1";
666 info.bundleName_ = "testSession3";
667 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
668 sceneSession->moveDragController_ = new MoveDragController(1);
669 ASSERT_TRUE(sceneSession->moveDragController_);
670 sceneSession->moveDragController_->InitMoveDragProperty();
671 WSRect originalRect = { 100, 100, 1000, 1000 };
672 sptr<WindowSessionProperty> property = new WindowSessionProperty();
673 property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
674 property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
675 SystemSessionConfig sessionConfig;
676 sessionConfig.isSystemDecorEnable_ = true;
677 sessionConfig.backgroundswitch = true;
678 sessionConfig.decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL;
679 std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
680 ASSERT_TRUE(pointerEvent);
681 pointerEvent->SetAgentWindowId(1);
682 pointerEvent->SetPointerId(0);
683 pointerEvent->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
684 sceneSession->moveDragController_->moveDragProperty_.pointerId_ = pointerEvent->GetPointerId();
685 sceneSession->moveDragController_->moveDragProperty_.pointerType_ = pointerEvent->GetSourceType();
686 MMI::PointerEvent::PointerItem pointerItem;
687 pointerItem.SetPointerId(0);
688 pointerEvent->AddPointerItem(pointerItem);
689
690 pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_DOWN);
691 pointerItem.SetDisplayX(100);
692 pointerItem.SetDisplayY(100);
693 pointerItem.SetWindowX(0);
694 pointerItem.SetWindowY(0);
695 auto result = sceneSession->moveDragController_->ConsumeDragEvent(pointerEvent, originalRect, property,
696 sessionConfig);
697 ASSERT_EQ(result, true);
698
699 sceneSession->moveDragController_->aspectRatio_ = 0.0f;
700 pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_MOVE);
701 pointerItem.SetDisplayX(150);
702 pointerItem.SetDisplayY(150);
703 result = sceneSession->moveDragController_->ConsumeDragEvent(pointerEvent, originalRect, property, sessionConfig);
704 ASSERT_EQ(result, true);
705
706 sceneSession->moveDragController_->aspectRatio_ = 1.0f;
707 pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_MOVE);
708 pointerItem.SetDisplayX(200);
709 pointerItem.SetDisplayY(200);
710 result = sceneSession->moveDragController_->ConsumeDragEvent(pointerEvent, originalRect, property, sessionConfig);
711 ASSERT_EQ(result, true);
712
713 pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_UP);
714 pointerItem.SetDisplayX(250);
715 pointerItem.SetDisplayY(250);
716 result = sceneSession->moveDragController_->ConsumeDragEvent(pointerEvent, originalRect, property, sessionConfig);
717 ASSERT_EQ(result, true);
718 }
719
720 /**
721 * @tc.name: ConsumeDragEvent03
722 * @tc.desc: ConsumeDragEvent, normal scene
723 * @tc.type: FUNC
724 */
725 HWTEST_F(WindowSessionTest, ConsumeDragEvent03, Function | SmallTest | Level2)
726 {
727 SessionInfo info;
728 info.abilityName_ = "testSession1";
729 info.bundleName_ = "testSession3";
730 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
731 EXPECT_NE(sceneSession, nullptr);
732 sceneSession->moveDragController_ = new MoveDragController(1);
733 ASSERT_TRUE(sceneSession->moveDragController_);
734 sceneSession->moveDragController_->InitMoveDragProperty();
735 WSRect originalRect = { 100, 100, 1000, 1000 };
736 sptr<WindowSessionProperty> property = new WindowSessionProperty();
737 property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
738 property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
739 SystemSessionConfig sessionConfig;
740 sessionConfig.isSystemDecorEnable_ = true;
741 sessionConfig.backgroundswitch = true;
742 sessionConfig.decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL;
743 std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
744 ASSERT_TRUE(pointerEvent);
745 pointerEvent->SetAgentWindowId(1);
746 pointerEvent->SetPointerId(0);
747 pointerEvent->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
748 pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_DOWN);
749 sceneSession->moveDragController_->moveDragProperty_.pointerId_ = pointerEvent->GetPointerId();
750 sceneSession->moveDragController_->moveDragProperty_.pointerType_ = pointerEvent->GetSourceType();
751 MMI::PointerEvent::PointerItem pointerItem;
752 pointerItem.SetPointerId(0);
753 pointerEvent->AddPointerItem(pointerItem);
754
755 // LEFT_TOP
756 pointerItem.SetWindowX(0);
757 pointerItem.SetWindowY(0);
758 auto result = sceneSession->moveDragController_->ConsumeDragEvent(pointerEvent, originalRect, property,
759 sessionConfig);
760 ASSERT_EQ(result, true);
761
762 // RIGHT_TOP
763 pointerItem.SetWindowX(1000);
764 pointerItem.SetWindowY(0);
765 result = sceneSession->moveDragController_->ConsumeDragEvent(pointerEvent, originalRect, property, sessionConfig);
766 ASSERT_EQ(result, true);
767
768 // RIGHT_BOTTOM
769 pointerItem.SetWindowX(1000);
770 pointerItem.SetWindowY(1000);
771 result = sceneSession->moveDragController_->ConsumeDragEvent(pointerEvent, originalRect, property, sessionConfig);
772 ASSERT_EQ(result, true);
773
774 // LEFT_BOTTOM
775 pointerItem.SetWindowX(0);
776 pointerItem.SetWindowY(1000);
777 result = sceneSession->moveDragController_->ConsumeDragEvent(pointerEvent, originalRect, property, sessionConfig);
778 ASSERT_EQ(result, true);
779 }
780
781 /**
782 * @tc.name: ConsumeDragEvent04
783 * @tc.desc: ConsumeDragEvent, normal scene
784 * @tc.type: FUNC
785 */
786 HWTEST_F(WindowSessionTest, ConsumeDragEvent04, Function | SmallTest | Level2)
787 {
788 SessionInfo info;
789 info.abilityName_ = "testSession1";
790 info.bundleName_ = "testSession3";
791 sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
792 EXPECT_NE(sceneSession, nullptr);
793 sceneSession->moveDragController_ = new MoveDragController(1);
794 ASSERT_TRUE(sceneSession->moveDragController_);
795 sceneSession->moveDragController_->InitMoveDragProperty();
796 WSRect originalRect = { 100, 100, 1000, 1000 };
797 sptr<WindowSessionProperty> property = new WindowSessionProperty();
798 property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
799 property->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
800 SystemSessionConfig sessionConfig;
801 sessionConfig.isSystemDecorEnable_ = true;
802 sessionConfig.backgroundswitch = true;
803 sessionConfig.decorWindowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_ALL;
804 std::shared_ptr<MMI::PointerEvent> pointerEvent = MMI::PointerEvent::Create();
805 ASSERT_TRUE(pointerEvent);
806 pointerEvent->SetAgentWindowId(1);
807 pointerEvent->SetPointerId(0);
808 pointerEvent->SetSourceType(MMI::PointerEvent::SOURCE_TYPE_TOUCHSCREEN);
809 pointerEvent->SetPointerAction(MMI::PointerEvent::POINTER_ACTION_DOWN);
810 sceneSession->moveDragController_->moveDragProperty_.pointerId_ = pointerEvent->GetPointerId();
811 sceneSession->moveDragController_->moveDragProperty_.pointerType_ = pointerEvent->GetSourceType();
812 MMI::PointerEvent::PointerItem pointerItem;
813 pointerItem.SetPointerId(0);
814 pointerEvent->AddPointerItem(pointerItem);
815
816 // LEFT
817 pointerItem.SetWindowX(0);
818 pointerItem.SetWindowY(500);
819 auto result = sceneSession->moveDragController_->ConsumeDragEvent(pointerEvent, originalRect, property,
820 sessionConfig);
821 ASSERT_EQ(result, true);
822
823 // TOP
824 pointerItem.SetWindowX(500);
825 pointerItem.SetWindowY(0);
826 result = sceneSession->moveDragController_->ConsumeDragEvent(pointerEvent, originalRect, property, sessionConfig);
827 ASSERT_EQ(result, true);
828
829 // RIGHT
830 pointerItem.SetWindowX(1000);
831 pointerItem.SetWindowY(500);
832 result = sceneSession->moveDragController_->ConsumeDragEvent(pointerEvent, originalRect, property, sessionConfig);
833 ASSERT_EQ(result, true);
834
835 // BOTTOM
836 pointerItem.SetWindowX(500);
837 pointerItem.SetWindowY(1000);
838 result = sceneSession->moveDragController_->ConsumeDragEvent(pointerEvent, originalRect, property, sessionConfig);
839 ASSERT_EQ(result, true);
840 }
841
842 /**
843 * @tc.name: GetWindowId01
844 * @tc.desc: GetWindowId, normal scene
845 * @tc.type: FUNC
846 */
847 HWTEST_F(WindowSessionTest, GetWindowId, Function | SmallTest | Level2)
848 {
849 ASSERT_NE(session_, nullptr);
850 ASSERT_EQ(0, session_->GetWindowId());
851 }
852
853 /**
854 * @tc.name: GetRSVisible01
855 * @tc.desc: GetRSVisible, normal scene
856 * @tc.type: FUNC
857 */
858 HWTEST_F(WindowSessionTest, GetRSVisible, Function | SmallTest | Level2)
859 {
860 ASSERT_NE(session_, nullptr);
861 ASSERT_EQ(WSError::WS_OK, session_->SetRSVisible(false));
862 session_->state_ = SessionState::STATE_CONNECT;
863 if (!session_->GetRSVisible()) {
864 ASSERT_EQ(false, session_->GetRSVisible());
865 }
866 }
867
868 /**
869 * @tc.name: SetFocusable01
870 * @tc.desc: SetFocusable, normal scene
871 * @tc.type: FUNC
872 */
873 HWTEST_F(WindowSessionTest, SetFocusable, Function | SmallTest | Level2)
874 {
875 ASSERT_NE(session_, nullptr);
876 session_->state_ = SessionState::STATE_DISCONNECT;
877 ASSERT_EQ(WSError::WS_OK, session_->SetFocusable(false));
878 }
879
880 /**
881 * @tc.name: GetSnapshot
882 * @tc.desc: GetSnapshot Test
883 * @tc.type: FUNC
884 */
885 HWTEST_F(WindowSessionTest, GetSnapshot, Function | SmallTest | Level2)
886 {
887 ASSERT_NE(session_, nullptr);
888 session_->state_ = SessionState::STATE_DISCONNECT;
889 std::shared_ptr<Media::PixelMap> snapshot = session_->Snapshot();
890 ASSERT_EQ(snapshot, session_->GetSnapshot());
891 }
892
893 /**
894 * @tc.name: NotifyExtensionDied
895 * @tc.desc: NotifyExtensionDied Test
896 * @tc.type: FUNC
897 */
898 HWTEST_F(WindowSessionTest, NotifyExtensionDied, Function | SmallTest | Level2)
899 {
900 ASSERT_NE(session_, nullptr);
901 session_->state_ = SessionState::STATE_DISCONNECT;
902 session_->NotifyExtensionDied();
903
904 ASSERT_EQ(WSError::WS_OK, session_->SetFocusable(false));
905 }
906
907 /**
908 * @tc.name: NotifyExtensionTimeout
909 * @tc.desc: NotifyExtensionTimeout Test
910 * @tc.type: FUNC
911 */
912 HWTEST_F(WindowSessionTest, NotifyExtensionTimeout, Function | SmallTest | Level2)
913 {
914 ASSERT_NE(session_, nullptr);
915 session_->state_ = SessionState::STATE_DISCONNECT;
916 session_->NotifyExtensionTimeout(3);
917
918 session_->RegisterLifecycleListener(lifecycleListener_);
919 session_->NotifyExtensionTimeout(3);
920 session_->UnregisterLifecycleListener(lifecycleListener_);
921
922 ASSERT_EQ(WSError::WS_OK, session_->SetFocusable(false));
923 }
924
925 /**
926 * @tc.name: SetAspectRatio
927 * @tc.desc: SetAspectRatio Test
928 * @tc.type: FUNC
929 */
930 HWTEST_F(WindowSessionTest, SetAspectRatio, Function | SmallTest | Level2)
931 {
932 ASSERT_NE(session_, nullptr);
933 session_->state_ = SessionState::STATE_DISCONNECT;
934 ASSERT_EQ(WSError::WS_OK, session_->SetAspectRatio(0.1f));
935 }
936
937 /**
938 * @tc.name: UpdateSessionTouchable
939 * @tc.desc: UpdateSessionTouchable Test
940 * @tc.type: FUNC
941 */
942 HWTEST_F(WindowSessionTest, UpdateSessionTouchable, Function | SmallTest | Level2)
943 {
944 ASSERT_NE(session_, nullptr);
945
946 session_->state_ = SessionState::STATE_DISCONNECT;
947 session_->UpdateSessionTouchable(false);
948
949 ASSERT_EQ(WSError::WS_OK, session_->SetFocusable(false));
950 }
951
952 /**
953 * @tc.name: SetFocusable02
954 * @tc.desc: others
955 * @tc.type: FUNC
956 */
957 HWTEST_F(WindowSessionTest, SetFocusable02, Function | SmallTest | Level2)
958 {
959 ASSERT_NE(session_, nullptr);
960
961 session_->state_ = SessionState::STATE_FOREGROUND;
962 session_->sessionInfo_.isSystem_ = false;
963
964 ASSERT_EQ(WSError::WS_OK, session_->SetFocusable(true));
965 }
966
967 /**
968 * @tc.name: GetFocusable01
969 * @tc.desc: property_ is not nullptr
970 * @tc.type: FUNC
971 */
972 HWTEST_F(WindowSessionTest, GetFocusable01, Function | SmallTest | Level2)
973 {
974 ASSERT_NE(session_, nullptr);
975 session_->property_ = new WindowSessionProperty();
976 ASSERT_EQ(true, session_->GetFocusable());
977 }
978
979 /**
980 * @tc.name: GetFocusable02
981 * @tc.desc: property_ is nullptr
982 * @tc.type: FUNC
983 */
984 HWTEST_F(WindowSessionTest, GetFocusable02, Function | SmallTest | Level2)
985 {
986 ASSERT_NE(session_, nullptr);
987 session_->property_ = nullptr;
988 ASSERT_EQ(true, session_->GetFocusable());
989 }
990
991 /**
992 * @tc.name: SetNeedNotify
993 * @tc.desc: SetNeedNotify Test
994 * @tc.type: FUNC
995 */
996 HWTEST_F(WindowSessionTest, SetNeedNotify, Function | SmallTest | Level2)
997 {
998 ASSERT_NE(session_, nullptr);
999 session_->state_ = SessionState::STATE_DISCONNECT;
1000 session_->SetNeedNotify(false);
1001
1002 ASSERT_EQ(WSError::WS_OK, session_->SetFocusable(false));
1003 }
1004
1005 /**
1006 * @tc.name: NeedNotify
1007 * @tc.desc: NeedNotify Test
1008 * @tc.type: FUNC
1009 */
1010 HWTEST_F(WindowSessionTest, NeedNotify, Function | SmallTest | Level2)
1011 {
1012 ASSERT_NE(session_, nullptr);
1013 session_->state_ = SessionState::STATE_DISCONNECT;
1014 session_->SetNeedNotify(true);
1015 ASSERT_EQ(true, session_->NeedNotify());
1016 }
1017
1018 /**
1019 * @tc.name: SetFocusedOnShow
1020 * @tc.desc: SetFocusedOnShow Test
1021 * @tc.type: FUNC
1022 */
1023 HWTEST_F(WindowSessionTest, SetFocusedOnShow, Function | SmallTest | Level2)
1024 {
1025 ASSERT_NE(session_, nullptr);
1026 session_->SetFocusedOnShow(false);
1027 auto focusedOnShow = session_->IsFocusedOnShow();
1028 ASSERT_EQ(focusedOnShow, false);
1029 session_->SetFocusedOnShow(true);
1030 focusedOnShow = session_->IsFocusedOnShow();
1031 ASSERT_EQ(focusedOnShow, true);
1032 }
1033
1034 /**
1035 * @tc.name: SetTouchable01
1036 * @tc.desc: IsSessionValid() return false
1037 * @tc.type: FUNC
1038 */
1039 HWTEST_F(WindowSessionTest, SetTouchable01, Function | SmallTest | Level2)
1040 {
1041 ASSERT_NE(session_, nullptr);
1042 session_->state_ = SessionState::STATE_DISCONNECT;
1043 session_->sessionInfo_.isSystem_ = true;
1044 ASSERT_EQ(WSError::WS_ERROR_INVALID_SESSION, session_->SetTouchable(false));
1045 }
1046
1047 /**
1048 * @tc.name: SetTouchable02
1049 * @tc.desc: IsSessionValid() return true
1050 * @tc.type: FUNC
1051 */
1052 HWTEST_F(WindowSessionTest, SetTouchable02, Function | SmallTest | Level2)
1053 {
1054 ASSERT_NE(session_, nullptr);
1055 session_->state_ = SessionState::STATE_FOREGROUND;
1056 session_->sessionInfo_.isSystem_ = false;
1057 ASSERT_EQ(WSError::WS_OK, session_->SetTouchable(false));
1058 }
1059
1060 /**
1061 * @tc.name: SetSessionInfoLockedState01
1062 * @tc.desc: IsSessionValid() return false
1063 * @tc.type: FUNC
1064 */
1065 HWTEST_F(WindowSessionTest, SetSessionInfoLockedState01, Function | SmallTest | Level2)
1066 {
1067 ASSERT_NE(session_, nullptr);
1068 session_->SetSessionInfoLockedState(false);
1069 ASSERT_EQ(false, session_->sessionInfo_.lockedState);
1070 }
1071
1072 /**
1073 * @tc.name: SetSessionInfoLockedState02
1074 * @tc.desc: IsSessionValid() return true
1075 * @tc.type: FUNC
1076 */
1077 HWTEST_F(WindowSessionTest, SetSessionInfoLockedState02, Function | SmallTest | Level2)
1078 {
1079 ASSERT_NE(session_, nullptr);
1080 session_->SetSessionInfoLockedState(true);
1081 ASSERT_EQ(true, session_->sessionInfo_.lockedState);
1082 }
1083
1084 /**
1085 * @tc.name: GetCallingPid
1086 * @tc.desc: GetCallingPid Test
1087 * @tc.type: FUNC
1088 */
1089 HWTEST_F(WindowSessionTest, GetCallingPid, Function | SmallTest | Level2)
1090 {
1091 ASSERT_NE(session_, nullptr);
1092 session_->SetCallingPid(111);
1093 ASSERT_EQ(111, session_->GetCallingPid());
1094 }
1095
1096 /**
1097 * @tc.name: GetCallingUid
1098 * @tc.desc: GetCallingUid Test
1099 * @tc.type: FUNC
1100 */
1101 HWTEST_F(WindowSessionTest, GetCallingUid, Function | SmallTest | Level2)
1102 {
1103 ASSERT_NE(session_, nullptr);
1104 session_->SetCallingUid(111);
1105 ASSERT_EQ(111, session_->GetCallingUid());
1106 }
1107
1108 /**
1109 * @tc.name: GetAbilityToken
1110 * @tc.desc: GetAbilityToken Test
1111 * @tc.type: FUNC
1112 */
1113 HWTEST_F(WindowSessionTest, GetAbilityToken, Function | SmallTest | Level2)
1114 {
1115 ASSERT_NE(session_, nullptr);
1116 session_->SetAbilityToken(nullptr);
1117 ASSERT_EQ(nullptr, session_->GetAbilityToken());
1118 }
1119
1120 /**
1121 * @tc.name: SetBrightness01
1122 * @tc.desc: property_ is nullptr
1123 * @tc.type: FUNC
1124 */
1125 HWTEST_F(WindowSessionTest, SetBrightness01, Function | SmallTest | Level2)
1126 {
1127 ASSERT_NE(session_, nullptr);
1128 session_->state_ = SessionState::STATE_DISCONNECT;
1129 session_->property_ = nullptr;
1130 ASSERT_EQ(WSError::WS_ERROR_NULLPTR, session_->SetBrightness(0.1f));
1131 }
1132
1133 /**
1134 * @tc.name: SetBrightness02
1135 * @tc.desc: property_ is not nullptr
1136 * @tc.type: FUNC
1137 */
1138 HWTEST_F(WindowSessionTest, SetBrightness02, Function | SmallTest | Level2)
1139 {
1140 ASSERT_NE(session_, nullptr);
1141 session_->state_ = SessionState::STATE_DISCONNECT;
1142 session_->property_ = new WindowSessionProperty();
1143 ASSERT_EQ(WSError::WS_OK, session_->SetBrightness(0.1f));
1144 }
1145
1146 /**
1147 * @tc.name: UpdateHotRect
1148 * @tc.desc: UpdateHotRect Test
1149 * @tc.type: FUNC
1150 */
1151 HWTEST_F(WindowSessionTest, UpdateHotRect, Function | SmallTest | Level2)
1152 {
1153 ASSERT_NE(session_, nullptr);
1154
1155 WSRect rect;
1156 rect.posX_ = 0;
1157 rect.posY_ = 0;
1158 rect.width_ = 0;
1159 rect.height_ = 0;
1160
1161 WSRectF newRect;
1162 const float outsideBorder = 4.0f * 1.5f;
1163 const size_t outsideBorderCount = 2;
1164 newRect.posX_ = rect.posX_ - outsideBorder;
1165 newRect.posY_ = rect.posY_ - outsideBorder;
1166 newRect.width_ = rect.width_ + outsideBorder * outsideBorderCount;
1167 newRect.height_ = rect.height_ + outsideBorder * outsideBorderCount;
1168
1169 ASSERT_EQ(newRect, session_->UpdateHotRect(rect));
1170 }
1171
1172 /**
1173 * @tc.name: SetTerminateSessionListener
1174 * @tc.desc: SetTerminateSessionListener Test
1175 * @tc.type: FUNC
1176 */
1177 HWTEST_F(WindowSessionTest, SetTerminateSessionListener, Function | SmallTest | Level2)
1178 {
1179 ASSERT_NE(session_, nullptr);
1180 session_->state_ = SessionState::STATE_DISCONNECT;
1181 session_->SetTerminateSessionListener(nullptr);
1182
1183 ASSERT_EQ(WSError::WS_OK, session_->SetFocusable(false));
1184 }
1185
1186 /**
1187 * @tc.name: SetTerminateSessionListenerTotal
1188 * @tc.desc: SetTerminateSessionListenerTotal Test
1189 * @tc.type: FUNC
1190 */
1191 HWTEST_F(WindowSessionTest, SetTerminateSessionListenerTotal, Function | SmallTest | Level2)
1192 {
1193 ASSERT_NE(session_, nullptr);
1194 session_->state_ = SessionState::STATE_DISCONNECT;
1195 session_->SetTerminateSessionListenerTotal(nullptr);
1196
1197 ASSERT_EQ(WSError::WS_OK, session_->SetFocusable(false));
1198 }
1199
1200 /**
1201 * @tc.name: SetSessionLabel
1202 * @tc.desc: SetSessionLabel Test
1203 * @tc.type: FUNC
1204 */
1205 HWTEST_F(WindowSessionTest, SetSessionLabel, Function | SmallTest | Level2)
1206 {
1207 ASSERT_NE(session_, nullptr);
1208 session_->state_ = SessionState::STATE_DISCONNECT;
__anoncdc0beff0802(const std::string& label) 1209 NofitySessionLabelUpdatedFunc func = [](const std::string& label) {};
1210 session_->updateSessionLabelFunc_ = func;
1211 ASSERT_EQ(WSError::WS_OK, session_->SetSessionLabel("SetSessionLabel Test"));
1212 }
1213
1214 /**
1215 * @tc.name: SetUpdateSessionLabelListener
1216 * @tc.desc: SetUpdateSessionLabelListener Test
1217 * @tc.type: FUNC
1218 */
1219 HWTEST_F(WindowSessionTest, SetUpdateSessionLabelListener, Function | SmallTest | Level2)
1220 {
1221 ASSERT_NE(session_, nullptr);
1222 session_->state_ = SessionState::STATE_DISCONNECT;
1223 NofitySessionLabelUpdatedFunc func = nullptr;
1224 session_->SetUpdateSessionLabelListener(func);
1225
1226 ASSERT_EQ(WSError::WS_OK, session_->SetFocusable(false));
1227 }
1228
1229 /**
1230 * @tc.name: SetPendingSessionToForegroundListener
1231 * @tc.desc: SetPendingSessionToForegroundListener Test
1232 * @tc.type: FUNC
1233 */
1234 HWTEST_F(WindowSessionTest, SetPendingSessionToForegroundListener, Function | SmallTest | Level2)
1235 {
1236 ASSERT_NE(session_, nullptr);
1237 session_->state_ = SessionState::STATE_DISCONNECT;
1238 session_->SetPendingSessionToForegroundListener(nullptr);
1239
1240 ASSERT_EQ(WSError::WS_OK, session_->SetFocusable(false));
1241 }
1242
1243 /**
1244 * @tc.name: NotifyScreenshot
1245 * @tc.desc: NotifyScreenshot Test
1246 * @tc.type: FUNC
1247 */
1248 HWTEST_F(WindowSessionTest, NotifyScreenshot, Function | SmallTest | Level2)
1249 {
1250 ASSERT_NE(session_, nullptr);
1251 session_->sessionStage_ = nullptr;
1252 session_->NotifyScreenshot();
1253
1254 session_->sessionStage_ = mockSessionStage_;
1255 session_->NotifyScreenshot();
1256
1257 session_->property_ = new WindowSessionProperty();
1258 ASSERT_EQ(WSError::WS_OK, session_->SetFocusable(false));
1259 }
1260
1261 /**
1262 * @tc.name: TransferBackPressedEventForConsumed02
1263 * @tc.desc: windowEventChannel_ is not nullptr
1264 * @tc.type: FUNC
1265 */
1266 HWTEST_F(WindowSessionTest, TransferBackPressedEventForConsumed02, Function | SmallTest | Level2)
1267 {
1268 ASSERT_NE(session_, nullptr);
1269
1270 session_->windowEventChannel_ = new TestWindowEventChannel();
1271
1272 bool isConsumed = false;
1273 ASSERT_EQ(WSError::WS_OK, session_->TransferBackPressedEventForConsumed(isConsumed));
1274 }
1275
1276 /**
1277 * @tc.name: GetUIContentRemoteObj
1278 * @tc.desc: GetUIContentRemoteObj Test
1279 * @tc.type: FUNC
1280 */
1281 HWTEST_F(WindowSessionTest, GetUIContentRemoteObj, Function | SmallTest | Level2)
1282 {
1283 ASSERT_NE(session_, nullptr);
1284 sptr<SessionStageMocker> mockSessionStage = new(std::nothrow) SessionStageMocker();
1285 ASSERT_NE(mockSessionStage, nullptr);
1286 EXPECT_CALL(*(mockSessionStage), GetUIContentRemoteObj(_)).WillRepeatedly(Return(WSError::WS_OK));
1287 session_->sessionStage_ = mockSessionStage;
1288 session_->state_ = SessionState::STATE_FOREGROUND;
1289 sptr<IRemoteObject> remoteObj;
1290 ASSERT_EQ(WSError::WS_OK, session_->GetUIContentRemoteObj(remoteObj));
1291
1292 session_->state_ = SessionState::STATE_BACKGROUND;
1293 ASSERT_EQ(WSError::WS_OK, session_->GetUIContentRemoteObj(remoteObj));
1294 Mock::VerifyAndClearExpectations(&mockSessionStage);
1295
1296 session_->sessionInfo_.isSystem_ = true;
1297 ASSERT_EQ(WSError::WS_ERROR_INVALID_SESSION, session_->GetUIContentRemoteObj(remoteObj));
1298 }
1299
1300 /**
1301 * @tc.name: TransferKeyEventForConsumed02
1302 * @tc.desc: windowEventChannel_ is not nullptr, keyEvent is nullptr
1303 * @tc.type: FUNC
1304 */
1305 HWTEST_F(WindowSessionTest, TransferKeyEventForConsumed02, Function | SmallTest | Level2)
1306 {
1307 ASSERT_NE(session_, nullptr);
1308
1309 session_->windowEventChannel_ = new TestWindowEventChannel();
1310
1311 std::shared_ptr<MMI::KeyEvent> keyEvent = nullptr;
1312 bool isConsumed = false;
1313 ASSERT_EQ(WSError::WS_ERROR_NULLPTR, session_->TransferKeyEventForConsumed(keyEvent, isConsumed));
1314 }
1315
1316 /**
1317 * @tc.name: TransferKeyEventForConsumed03
1318 * @tc.desc: windowEventChannel_ is not nullptr, keyEvent is not nullptr
1319 * @tc.type: FUNC
1320 */
1321 HWTEST_F(WindowSessionTest, TransferKeyEventForConsumed03, Function | SmallTest | Level2)
1322 {
1323 ASSERT_NE(session_, nullptr);
1324
1325 session_->windowEventChannel_ = new TestWindowEventChannel();
1326
1327 std::shared_ptr<MMI::KeyEvent> keyEvent = MMI::KeyEvent::Create();
1328 bool isConsumed = false;
1329 ASSERT_EQ(WSError::WS_OK, session_->TransferKeyEventForConsumed(keyEvent, isConsumed));
1330 }
1331
1332 /**
1333 * @tc.name: TransferFocusActiveEvent02
1334 * @tc.desc: windowEventChannel_ is not nullptr
1335 * @tc.type: FUNC
1336 */
1337 HWTEST_F(WindowSessionTest, TransferFocusActiveEvent02, Function | SmallTest | Level2)
1338 {
1339 ASSERT_NE(session_, nullptr);
1340
1341 session_->windowEventChannel_ = new TestWindowEventChannel();
1342
1343 ASSERT_EQ(WSError::WS_OK, session_->TransferFocusActiveEvent(false));
1344 }
1345
1346 /**
1347 * @tc.name: TransferFocusStateEvent02
1348 * @tc.desc: windowEventChannel_ is not nullptr
1349 * @tc.type: FUNC
1350 */
1351 HWTEST_F(WindowSessionTest, TransferFocusStateEvent02, Function | SmallTest | Level2)
1352 {
1353 ASSERT_NE(session_, nullptr);
1354
1355 session_->windowEventChannel_ = new TestWindowEventChannel();
1356
1357 ASSERT_EQ(WSError::WS_OK, session_->TransferFocusStateEvent(false));
1358 }
1359
1360 /**
1361 * @tc.name: SetCompatibleModeInPc
1362 * @tc.desc: SetCompatibleModeInPc test
1363 * @tc.type: FUNC
1364 */
1365 HWTEST_F(WindowSessionTest, SetCompatibleModeInPc, Function | SmallTest | Level2)
1366 {
1367 sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
1368 ASSERT_NE(nullptr, property);
1369 bool enable = true;
1370 bool isSupportDragInPcCompatibleMode = true;
1371 property->SetCompatibleModeInPc(enable);
1372 ASSERT_EQ(property->GetCompatibleModeInPc(), true);
1373 property->SetIsSupportDragInPcCompatibleMode(isSupportDragInPcCompatibleMode);;
1374 ASSERT_EQ(property->GetIsSupportDragInPcCompatibleMode(), true);
1375 }
1376
1377 /**
1378 * @tc.name: UpdateMaximizeMode
1379 * @tc.desc: UpdateMaximizeMode test
1380 * @tc.type: FUNC
1381 */
1382 HWTEST_F(WindowSessionTest, UpdateMaximizeMode, Function | SmallTest | Level2)
1383 {
1384 sptr<SessionStageMocker> mockSessionStage = new (std::nothrow) SessionStageMocker();
1385 EXPECT_NE(mockSessionStage, nullptr);
1386 session_->sessionStage_ = mockSessionStage;
1387
1388 session_->sessionInfo_.isSystem_ = false;
1389 session_->state_ = SessionState::STATE_ACTIVE;
1390 auto ret = session_->UpdateMaximizeMode(true);
1391 ASSERT_EQ(ret, WSError::WS_OK);
1392
1393 sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
1394 ASSERT_NE(property, nullptr);
1395 property->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
1396 session_->SetSessionProperty(property);
1397 ret = session_->UpdateMaximizeMode(false);
1398 ASSERT_EQ(ret, WSError::WS_OK);
1399
1400 session_->SetSessionProperty(nullptr);
1401 ret = session_->UpdateMaximizeMode(false);
1402 ASSERT_EQ(ret, WSError::WS_ERROR_NULLPTR);
1403 }
1404
1405 /**
1406 * @tc.name: UpdateTitleInTargetPos
1407 * @tc.desc: UpdateTitleInTargetPos test
1408 * @tc.type: FUNC
1409 */
1410 HWTEST_F(WindowSessionTest, UpdateTitleInTargetPos, Function | SmallTest | Level2)
1411 {
1412 sptr<SessionStageMocker> mockSessionStage = new (std::nothrow) SessionStageMocker();
1413 EXPECT_NE(mockSessionStage, nullptr);
1414 session_->sessionStage_ = mockSessionStage;
1415
1416 session_->sessionInfo_.isSystem_ = false;
1417 session_->state_ = SessionState::STATE_FOREGROUND;
1418 auto ret = session_->UpdateTitleInTargetPos(true, 20);
1419 ASSERT_NE(ret, WSError::WS_ERROR_INVALID_SESSION);
1420 }
1421
1422 /**
1423 * @tc.name: SwitchFreeMultiWindow
1424 * @tc.desc: SwitchFreeMultiWindow test
1425 * @tc.type: FUNC
1426 */
1427 HWTEST_F(WindowSessionTest, SwitchFreeMultiWindow, Function | SmallTest | Level2)
1428 {
1429 sptr<SessionStageMocker> mockSessionStage = new (std::nothrow) SessionStageMocker();
1430 EXPECT_NE(mockSessionStage, nullptr);
1431 session_->sessionStage_ = mockSessionStage;
1432
1433 session_->sessionInfo_.isSystem_ = false;
1434 session_->state_ = SessionState::STATE_FOREGROUND;
1435 auto ret = session_->SwitchFreeMultiWindow(true);
1436 ASSERT_NE(ret, WSError::WS_ERROR_INVALID_SESSION);
1437
1438 session_->sessionInfo_.isSystem_ = true;
1439 ret = session_->SwitchFreeMultiWindow(true);
1440 ASSERT_EQ(ret, WSError::WS_ERROR_INVALID_SESSION);
1441 }
1442
1443 /**
1444 * @tc.name: SetTouchHotAreas
1445 * @tc.desc: SetTouchHotAreas test
1446 * @tc.type: FUNC
1447 */
1448 HWTEST_F(WindowSessionTest, SetTouchHotAreas, Function | SmallTest | Level2)
1449 {
1450 session_->SetSessionProperty(nullptr);
1451 std::vector<Rect> touchHotAreas;
1452 session_->SetTouchHotAreas(touchHotAreas);
1453 ASSERT_EQ(session_->property_, nullptr);
1454
1455 session_->property_ = new WindowSessionProperty();
1456 touchHotAreas = session_->property_->touchHotAreas_;
1457 session_->property_->SetTouchHotAreas(touchHotAreas);
1458 ASSERT_EQ(touchHotAreas, session_->property_->touchHotAreas_);
1459 }
1460
1461 /**
1462 * @tc.name: NotifyOccupiedAreaChangeInfo
1463 * @tc.desc: NotifyOccupiedAreaChangeInfo test
1464 * @tc.type: FUNC
1465 */
1466 HWTEST_F(WindowSessionTest, NotifyOccupiedAreaChangeInfo, Function | SmallTest | Level2)
1467 {
1468 sptr<SessionStageMocker> mockSessionStage = new (std::nothrow) SessionStageMocker();
1469 EXPECT_NE(mockSessionStage, nullptr);
1470 session_->sessionStage_ = mockSessionStage;
1471 session_->NotifyOccupiedAreaChangeInfo(nullptr, nullptr);
1472 EXPECT_NE(session_->sessionStage_, nullptr);
1473 }
1474
1475 /**
1476 * @tc.name: ProcessBackEvent
1477 * @tc.desc: ProcessBackEvent test
1478 * @tc.type: FUNC
1479 */
1480 HWTEST_F(WindowSessionTest, ProcessBackEvent, Function | SmallTest | Level2)
1481 {
1482 sptr<SessionStageMocker> mockSessionStage = new (std::nothrow) SessionStageMocker();
1483 EXPECT_NE(mockSessionStage, nullptr);
1484 session_->sessionStage_ = mockSessionStage;
1485
1486 session_->sessionInfo_.isSystem_ = false;
1487 session_->state_ = SessionState::STATE_FOREGROUND;
1488 auto ret = session_->ProcessBackEvent();
1489 ASSERT_NE(ret, WSError::WS_ERROR_INVALID_SESSION);
1490 }
1491
1492 /**
1493 * @tc.name: ProcessBackGetAndSetSessionRequestRectEvent
1494 * @tc.desc: GetSessionRequestRectEvent, SetSessionRequestRectEvent test
1495 * @tc.type: FUNC
1496 */
1497 HWTEST_F(WindowSessionTest, GetAndSetSessionRequestRect, Function | SmallTest | Level2)
1498 {
1499 session_->SetSessionProperty(nullptr);
1500 session_->GetSessionRequestRect();
1501 ASSERT_EQ(session_->property_, nullptr);
1502
1503 WSRect rect = {0, 0, 0, 0};
1504 session_->SetSessionRequestRect(rect);
1505 ASSERT_EQ(session_->property_, nullptr);
1506 }
1507
1508 /**
1509 * @tc.name: SetSessionRect01
1510 * @tc.desc: SetSessionRect test
1511 * @tc.type: FUNC
1512 */
1513 HWTEST_F(WindowSessionTest, SetSessionRect01, Function | SmallTest | Level2)
1514 {
1515 WSRect rect = session_->GetSessionRect();
1516 session_->SetSessionRect(rect);
1517 ASSERT_EQ(rect, session_->winRect_);
1518 }
1519
1520 /**
1521 * @tc.name: SetExclusivelyHighlighted
1522 * @tc.desc: SetExclusivelyHighlighted Test
1523 * @tc.type: FUNC
1524 */
1525 HWTEST_F(WindowSessionTest, SetExclusivelyHighlighted, Function | SmallTest | Level2)
1526 {
1527 ASSERT_NE(session_, nullptr);
1528 session_->SetExclusivelyHighlighted(false);
1529 bool isExclusivelyHighlighted = session_->GetSessionProperty()->GetExclusivelyHighlighted();
1530 ASSERT_EQ(isExclusivelyHighlighted, false);
1531 session_->SetExclusivelyHighlighted(true);
1532 isExclusivelyHighlighted = session_->GetSessionProperty()->GetExclusivelyHighlighted();
1533 ASSERT_EQ(isExclusivelyHighlighted, true);
1534 }
1535
1536 /**
1537 * @tc.name: UpdateHighlightStatus
1538 * @tc.desc: UpdateHighlightStatus Test
1539 * @tc.type: FUNC
1540 */
1541 HWTEST_F(WindowSessionTest, UpdateHighlightStatus, Function | SmallTest | Level2)
1542 {
1543 ASSERT_NE(session_, nullptr);
1544 EXPECT_EQ(session_->UpdateHighlightStatus(false, false), WSError::WS_DO_NOTHING);
1545
1546 EXPECT_EQ(session_->UpdateHighlightStatus(true, false), WSError::WS_OK);
1547 session_->isHighlight_ = false;
1548 EXPECT_EQ(session_->UpdateHighlightStatus(true, true), WSError::WS_OK);
1549 }
1550
1551 /**
1552 * @tc.name: NotifyHighlightChange
1553 * @tc.desc: NotifyHighlightChange Test
1554 * @tc.type: FUNC
1555 */
1556 HWTEST_F(WindowSessionTest, NotifyHighlightChange, Function | SmallTest | Level2)
1557 {
1558 ASSERT_NE(session_, nullptr);
1559 session_->sessionInfo_.isSystem_ = true;
1560 EXPECT_EQ(session_->NotifyHighlightChange(true), WSError::WS_ERROR_INVALID_SESSION);
1561 session_->sessionInfo_.isSystem_ = false;
1562 EXPECT_EQ(session_->NotifyHighlightChange(true), WSError::WS_ERROR_NULLPTR);
1563 session_->sessionStage_ = mockSessionStage_;
1564 session_->state_ = SessionState::STATE_CONNECT;
1565 EXPECT_EQ(session_->NotifyHighlightChange(true), WSError::WS_OK);
1566 session_->sessionStage_ = nullptr;
1567 EXPECT_EQ(session_->NotifyHighlightChange(true), WSError::WS_ERROR_NULLPTR);
1568 }
1569 }
1570 } // namespace Rosen
1571 } // namespace OHOS
1572