diff --git a/window_scene/test/unittest/event_distribution/scene_input_manager_test.cpp b/window_scene/test/unittest/event_distribution/scene_input_manager_test.cpp index 2a52e8e5189581de8c794aea15131779e01eaddf..1cf3c53dd0ceb8cfa2f13737133f249ea0773f53 100644 --- a/window_scene/test/unittest/event_distribution/scene_input_manager_test.cpp +++ b/window_scene/test/unittest/event_distribution/scene_input_manager_test.cpp @@ -28,7 +28,7 @@ namespace { void MyLogCallback(const LogType type, const LogLevel level, const unsigned int domain, const char* tag, const char* msg) { - logMsg = msg; + logMsg += msg; } } @@ -250,17 +250,19 @@ HWTEST_F(SceneInputManagerTest, CheckNeedUpdate7, TestSize.Level1) */ HWTEST_F(SceneInputManagerTest, UpdateSecSurfaceInfo, TestSize.Level1) { - int ret = 0; + logMsg.clear(); + LOG_SetCallback(MyLogCallback); std::map> emptyMap; auto oldDirty = SceneInputManager::GetInstance().sceneSessionDirty_; ASSERT_NE(oldDirty, nullptr); SceneInputManager::GetInstance().sceneSessionDirty_ = nullptr; SceneInputManager::GetInstance().UpdateSecSurfaceInfo(emptyMap); - ASSERT_EQ(ret, 0); + EXPECT_TRUE(logMsg.find("sceneSessionDirty_ is nullptr") != std::string::npos); + logMsg.clear(); SceneInputManager::GetInstance().sceneSessionDirty_ = oldDirty; SceneInputManager::GetInstance().UpdateSecSurfaceInfo(emptyMap); - ASSERT_EQ(ret, 0); + EXPECT_FALSE(logMsg.find("sceneSessionDirty_ is nullptr") != std::string::npos); } /** @@ -323,12 +325,15 @@ HWTEST_F(SceneInputManagerTest, UpdateDisplayAndWindowInfo, TestSize.Level1) */ HWTEST_F(SceneInputManagerTest, FlushEmptyInfoToMMI, TestSize.Level1) { - int ret = 0; + logMsg.clear(); + LOG_SetCallback(MyLogCallback); auto preEventHandler = SceneInputManager::GetInstance().eventHandler_; SceneInputManager::GetInstance().eventHandler_ = nullptr; SceneInputManager::GetInstance().FlushEmptyInfoToMMI(); SceneInputManager::GetInstance().eventHandler_ = preEventHandler; - ASSERT_EQ(ret, 0); + SceneInputManager::GetInstance().FlushEmptyInfoToMMI(); + usleep(WAIT_SYNC_IN_NS); + EXPECT_TRUE(logMsg.find("userId") != std::string::npos); } /** @@ -373,7 +378,8 @@ HWTEST_F(SceneInputManagerTest, GetConstrainedModalExtWindowInfo, TestSize.Level HWTEST_F(SceneInputManagerTest, FlushDisplayInfoToMMI, TestSize.Level0) { GTEST_LOG_(INFO) << "SceneInputManagerTest: FlushDisplayInfoToMMI start"; - int ret = 0; + logMsg.clear(); + LOG_SetCallback(MyLogCallback); // sceneSessionDirty_ = nullptr std::vector windowInfoList; std::vector> pixelMapList; @@ -381,11 +387,17 @@ HWTEST_F(SceneInputManagerTest, FlushDisplayInfoToMMI, TestSize.Level0) auto oldDirty = SceneInputManager::GetInstance().sceneSessionDirty_; SceneInputManager::GetInstance().sceneSessionDirty_ = nullptr; SceneInputManager::GetInstance().FlushDisplayInfoToMMI(std::move(windowInfoList), std::move(pixelMapList)); + usleep(WAIT_SYNC_IN_NS); + EXPECT_TRUE(logMsg.find("sceneSessionDirty_ is nullptr") != std::string::npos); + logMsg.clear(); SceneInputManager::GetInstance().sceneSessionDirty_ = oldDirty; // NotNeedUpdate SceneInputManager::GetInstance().FlushDisplayInfoToMMI(std::move(windowInfoList), std::move(pixelMapList), true); SceneInputManager::GetInstance().FlushDisplayInfoToMMI(std::move(windowInfoList), std::move(pixelMapList)); + usleep(WAIT_SYNC_IN_NS); + EXPECT_TRUE(logMsg.find("sceneSessionDirty_ is nullptr") != std::string::npos); + logMsg.clear(); auto preEventHandler = SceneInputManager::GetInstance().eventHandler_; SceneInputManager::GetInstance().eventHandler_ = nullptr; @@ -396,7 +408,6 @@ HWTEST_F(SceneInputManagerTest, FlushDisplayInfoToMMI, TestSize.Level0) WindowInfoListZeroTest(ssm_); MaxWindowInfoTest(ssm_); - ASSERT_EQ(ret, 0); GTEST_LOG_(INFO) << "SceneInputManagerTest: FlushDisplayInfoToMMI end"; } diff --git a/window_scene/test/unittest/event_distribution/scene_session_dirty_manager_test2.cpp b/window_scene/test/unittest/event_distribution/scene_session_dirty_manager_test2.cpp index 4b7557aabf19e2fc38bbf80b45414c9b066fd6b0..503315491889f20a6776e78b86b6ad5b18b89b0a 100644 --- a/window_scene/test/unittest/event_distribution/scene_session_dirty_manager_test2.cpp +++ b/window_scene/test/unittest/event_distribution/scene_session_dirty_manager_test2.cpp @@ -165,11 +165,7 @@ HWTEST_F(SceneSessionDirtyManagerTest2, GetWindowInfoWithNotSystemTouchable, Tes sptr::MakeSptr(config, ScreenSessionReason::CREATE_SESSION_FOR_CLIENT); ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(screenId, screenSession)); manager_->UpdateWindowFlags(screenId, sceneSessionMainWindow, windowInfo); - bool windowFlagResult = false; - if (windowInfo.flags == 1) { - windowFlagResult = true; - } - ASSERT_EQ(windowFlagResult, true); + ASSERT_EQ(windowInfo.flags, 1); } /** @@ -206,11 +202,7 @@ HWTEST_F(SceneSessionDirtyManagerTest2, GetWindowInfoWithNotIsTouchEnable, TestS ScreenSessionManagerClient::GetInstance().screenSessionMap_.clear(); ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(screenId, screenSession)); manager_->UpdateWindowFlags(screenId, sceneSessionMainWindow, windowInfo); - bool windowFlagResult = false; - if (windowInfo.flags == MMI::WindowInfo::FLAG_BIT_UNTOUCHABLE) { - windowFlagResult = true; - } - ASSERT_EQ(windowFlagResult, true); + ASSERT_EQ(windowInfo.flags, MMI::WindowInfo::FLAG_BIT_UNTOUCHABLE); } /** @@ -246,11 +238,7 @@ HWTEST_F(SceneSessionDirtyManagerTest2, GetWindowInfoWithNotIsForceTouchEnable, screenSession->touchEnabled_.store(true); ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(screenId, screenSession)); manager_->UpdateWindowFlags(screenId, sceneSessionMainWindow, windowInfo); - bool windowFlagResult = false; - if (windowInfo.flags == 1) { - windowFlagResult = true; - } - ASSERT_EQ(windowFlagResult, true); + ASSERT_EQ(windowInfo.flags, 1); } /** @@ -284,11 +272,7 @@ HWTEST_F(SceneSessionDirtyManagerTest2, GetWindowInfoWithNotForegroundInteractiv sptr::MakeSptr(config, ScreenSessionReason::CREATE_SESSION_FOR_CLIENT); ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(screenId, screenSession)); manager_->UpdateWindowFlags(screenId, sceneSessionMainWindow, windowInfo); - bool windowFlagResult = false; - if (windowInfo.flags == 1) { - windowFlagResult = true; - } - ASSERT_EQ(windowFlagResult, true); + ASSERT_EQ(windowInfo.flags, 1); } /** @@ -322,11 +306,7 @@ HWTEST_F(SceneSessionDirtyManagerTest2, GetWindowInfoWithNotPropertyTouchable, T sptr::MakeSptr(config, ScreenSessionReason::CREATE_SESSION_FOR_CLIENT); ScreenSessionManagerClient::GetInstance().screenSessionMap_.insert(std::make_pair(screenId, screenSession)); manager_->UpdateWindowFlags(screenId, sceneSessionMainWindow, windowInfo); - bool windowFlagResult = false; - if (windowInfo.flags == 1) { - windowFlagResult = true; - } - ASSERT_EQ(windowFlagResult, true); + ASSERT_EQ(windowInfo.flags, 1); } /** diff --git a/window_scene/test/unittest/ui_extension/extension_session_test.cpp b/window_scene/test/unittest/ui_extension/extension_session_test.cpp index 731d24f633a8ba3291f8d9bddac4b2bd6ffe6808..22ac1df141d5d11dd914b41ea794165d9a14e985 100644 --- a/window_scene/test/unittest/ui_extension/extension_session_test.cpp +++ b/window_scene/test/unittest/ui_extension/extension_session_test.cpp @@ -532,7 +532,7 @@ HWTEST_F(ExtensionSessionTest, TransferKeyEventForConsumed01, TestSize.Level0) auto keyEvent = MMI::KeyEvent::Create(); ASSERT_NE(keyEvent, nullptr); bool isConsumed = false; - bool isTimeout = false; + bool isTimeout = true; bool isPreImeEvent = false; WSError result = extensionSession_->TransferKeyEventForConsumed(keyEvent, isConsumed, isTimeout, isPreImeEvent); ASSERT_EQ(result, WSError::WS_OK);