diff --git a/window_scene/test/unittest/anomaly_detection_test.cpp b/window_scene/test/unittest/anomaly_detection_test.cpp index b7063000c2ef8c60229abd81ce5592a2f719cb23..681dc33cb234ea4ae4a61954070a339a93b4c069 100644 --- a/window_scene/test/unittest/anomaly_detection_test.cpp +++ b/window_scene/test/unittest/anomaly_detection_test.cpp @@ -20,13 +20,21 @@ #include "session/host/include/session.h" #include "session/host/include/scene_session.h" #include "common/include/window_session_property.h" - +#include "window_manager_hilog.h" using namespace testing; using namespace testing::ext; namespace OHOS { namespace Rosen { +namespace { + std::string g_errLog; + void MyLogCallback(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, + const char *msg) + { + g_errLog = msg; + } +} class AnomalyDetectionTest : public testing::Test { public: static void SetUpTestCase(); @@ -288,9 +296,10 @@ void WallPaperTest(sptr ssm_) HWTEST_F(AnomalyDetectionTest, SceneZOrderCheckProcess, TestSize.Level1) { GTEST_LOG_(INFO) << "AnomalyDetectionTest: SceneZOrderCheckProcess start"; - int ret = 0; + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); AnomalyDetection::SceneZOrderCheckProcess(); - + EXPECT_FALSE(g_errLog.find("ZOrderCheck err, zorder 0") != std::string::npos); SessionVisibleTest(ssm_); ZeroOrderTest(ssm_); EQOrderTest(ssm_); @@ -299,7 +308,7 @@ HWTEST_F(AnomalyDetectionTest, SceneZOrderCheckProcess, TestSize.Level1) KeyGUARDTest(ssm_); IsShowWhenLockedTest(ssm_); WallPaperTest(ssm_); - ASSERT_EQ(ret, 0); + LOG_SetCallback(nullptr); GTEST_LOG_(INFO) << "AnomalyDetectionTest: SceneZOrderCheckProcess end"; } diff --git a/window_scene/test/unittest/main_session_test.cpp b/window_scene/test/unittest/main_session_test.cpp index e7f7711a6c61d31a982ad52101f6ef6918aa4fdf..0a5fc0f9be0f991fbae379aa79143d79c4d2cb14 100644 --- a/window_scene/test/unittest/main_session_test.cpp +++ b/window_scene/test/unittest/main_session_test.cpp @@ -32,6 +32,14 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { +namespace { + std::string g_errLog; + void MyLogCallback(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, + const char *msg) + { + g_errLog = msg; + } +} class MainSessionTest : public testing::Test { public: static void SetUpTestCase(); @@ -398,9 +406,11 @@ HWTEST_F(MainSessionTest, NotifyClientToUpdateInteractive, TestSize.Level1) */ HWTEST_F(MainSessionTest, SetExitSplitOnBackground, TestSize.Level1) { - bool isExitSplitOnBackground = true; + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); mainSession_->SetExitSplitOnBackground(isExitSplitOnBackground); - ASSERT_EQ(true, isExitSplitOnBackground); + EXPECT_TRUE(g_errLog.find("[NAPI]") != std::string::npos); + LOG_SetCallback(nullptr); } /** @@ -892,7 +902,6 @@ HWTEST_F(MainSessionTest, NotifySubAndDialogFollowRectChange01, TestSize.Level1) WSRect rect; subSession->isFollowParentLayout_ = false; mainSession->NotifySubAndDialogFollowRectChange(rect, false, false); - ASSERT_EQ(false, isCall); subSession->isFollowParentLayout_ = true; sptr callBack = sptr::MakeSptr(); diff --git a/window_scene/test/unittest/scb_system_session_test.cpp b/window_scene/test/unittest/scb_system_session_test.cpp index 13d787515bd0f580f13db4905f52b57ba9a86ae3..f04ad5aba0dc34ccf184a926641210943bf32e9c 100644 --- a/window_scene/test/unittest/scb_system_session_test.cpp +++ b/window_scene/test/unittest/scb_system_session_test.cpp @@ -27,6 +27,14 @@ using namespace testing::ext; namespace OHOS { namespace Rosen { +namespace { + std::string g_errLog; + void MyLogCallback(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, + const char *msg) + { + g_errLog = msg; + } +} class SCBSystemSessionTest : public testing::Test { public: static void SetUpTestCase(); @@ -237,13 +245,16 @@ HWTEST_F(SCBSystemSessionTest, PresentFocusIfPointDown02, TestSize.Level1) */ HWTEST_F(SCBSystemSessionTest, PresentFocusIfNeed, TestSize.Level1) { + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); int32_t pointerAction = 8; scbSystemSession_->PresentFocusIfNeed(pointerAction, 0); - ASSERT_EQ(pointerAction, 8); + EXPECT_FALSE(g_errLog.find("OnClick down, id:") != std::string::npos); pointerAction = 100; scbSystemSession_->PresentFocusIfNeed(pointerAction, 0); - ASSERT_EQ(pointerAction, 100); + EXPECT_FALSE(g_errLog.find("OnClick down, id:") != std::string::npos); + LOG_SetCallback(nullptr); } /** diff --git a/window_scene/test/unittest/scene_session_manager_test10.cpp b/window_scene/test/unittest/scene_session_manager_test10.cpp index 8ddd07a2e567d0fc9d505fba6973d35ea7ddfa57..33fa652103b72b02dcef64ec48a26f0ffe827998 100644 --- a/window_scene/test/unittest/scene_session_manager_test10.cpp +++ b/window_scene/test/unittest/scene_session_manager_test10.cpp @@ -595,7 +595,6 @@ HWTEST_F(SceneSessionManagerTest10, ChangeWindowRectYInVirtualDisplay, TestSize. DisplayId displayId = 0; int32_t y = 100; ssm_->ChangeWindowRectYInVirtualDisplay(displayId, y); - EXPECT_EQ(displayId, 0); EXPECT_EQ(y, 100); displayId = 999; ssm_->ChangeWindowRectYInVirtualDisplay(displayId, y); diff --git a/window_scene/test/unittest/scene_session_manager_test12.cpp b/window_scene/test/unittest/scene_session_manager_test12.cpp index 3b50f371fae0c5306005f3ca3a85d4a6e361dc8c..5f753fc3ad9556b315f7791b7a27e52eb987fc09 100644 --- a/window_scene/test/unittest/scene_session_manager_test12.cpp +++ b/window_scene/test/unittest/scene_session_manager_test12.cpp @@ -40,12 +40,21 @@ #include "session_manager/include/zidl/session_router_stack_listener_stub.h" #include "ui_effect_manager.h" #include "ui_effect_controller_client_proxy.h" +#include "window_manager_hilog.h" using namespace testing; using namespace testing::ext; namespace OHOS { namespace Rosen { +namespace { + std::string g_errLog; + void MyLogCallback(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, + const char *msg) + { + g_errLog = msg; + } +} class KeyboardTestData; class SceneSessionManagerTest12 : public testing::Test { public: @@ -1675,7 +1684,6 @@ HWTEST_F(SceneSessionManagerTest12, HasFloatingWindowForeground01, TestSize.Leve bool hasFloatWindowForeground = false; WMError result = ssm_->HasFloatingWindowForeground(nullptr, hasFloatWindowForeground); EXPECT_EQ(result, WMError::WM_ERROR_NULLPTR); - EXPECT_EQ(hasFloatWindowForeground, false); } /** @@ -1708,7 +1716,7 @@ HWTEST_F(SceneSessionManagerTest12, HasFloatingWindowForeground02, TestSize.Leve sceneSession->SetSessionState(SessionState::STATE_ACTIVE); ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); - bool hasFloatWindowForeground = false; + bool hasFloatWindowForeground = true; sptr token2 = sptr::MakeSptr(); WMError result = ssm_->HasFloatingWindowForeground(token2, hasFloatWindowForeground); EXPECT_EQ(result, WMError::WM_OK); @@ -1790,12 +1798,12 @@ HWTEST_F(SceneSessionManagerTest12, HasFloatingWindowForeground04, TestSize.Leve ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 }); ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 }); - bool hasFloatWindowForeground = false; + bool hasFloatWindowForeground = true; WMError result = ssm_->HasFloatingWindowForeground(token1, hasFloatWindowForeground); EXPECT_EQ(result, WMError::WM_OK); EXPECT_EQ(hasFloatWindowForeground, false); - hasFloatWindowForeground = false; + hasFloatWindowForeground = true; result = ssm_->HasFloatingWindowForeground(token2, hasFloatWindowForeground); EXPECT_EQ(result, WMError::WM_OK); EXPECT_EQ(hasFloatWindowForeground, false); @@ -1821,7 +1829,7 @@ HWTEST_F(SceneSessionManagerTest12, HasFloatingWindowForeground05, TestSize.Leve ssm_->sceneSessionMap_.insert({ sceneSession->GetPersistentId(), sceneSession }); - bool hasFloatWindowForeground = false; + bool hasFloatWindowForeground = true; WMError result = ssm_->HasFloatingWindowForeground(token, hasFloatWindowForeground); EXPECT_EQ(result, WMError::WM_OK); EXPECT_EQ(hasFloatWindowForeground, false); @@ -1859,7 +1867,7 @@ HWTEST_F(SceneSessionManagerTest12, HasFloatingWindowForeground06, TestSize.Leve ssm_->sceneSessionMap_.insert({ sceneSession1->GetPersistentId(), sceneSession1 }); ssm_->sceneSessionMap_.insert({ sceneSession2->GetPersistentId(), sceneSession2 }); - bool hasFloatWindowForeground = false; + bool hasFloatWindowForeground = true; WMError result = ssm_->HasFloatingWindowForeground(token2, hasFloatWindowForeground); EXPECT_EQ(result, WMError::WM_OK); EXPECT_EQ(hasFloatWindowForeground, false); @@ -3011,7 +3019,7 @@ HWTEST_F(SceneSessionManagerTest12, GetPiPSettingSwitchStatus, Function | SmallT ssm_->SetPiPSettingSwitchStatus(false); ret = ssm_->GetPiPSettingSwitchStatus(switchStatus); - EXPECT_EQ(switchStatus, false); + EXPECT_NE(switchStatus, true); EXPECT_EQ(ret, WMError::WM_OK); } @@ -3064,7 +3072,6 @@ HWTEST_F(SceneSessionManagerTest12, IsFocusWindowParent, Function | SmallTest | sceneSession->SetAbilityToken(nullptr); EXPECT_EQ(WSError::WS_OK, ssm_->IsFocusWindowParent(token, isParent)); - EXPECT_EQ(false, isParent); } } // namespace } // namespace Rosen diff --git a/window_scene/test/unittest/scene_session_test.cpp b/window_scene/test/unittest/scene_session_test.cpp index b030f899e8a6ffa178afa81ecd9dd964c8e8a151..60d495bd4d805de7d574df0b78b47d83f6619255 100644 --- a/window_scene/test/unittest/scene_session_test.cpp +++ b/window_scene/test/unittest/scene_session_test.cpp @@ -201,9 +201,6 @@ HWTEST_F(SceneSessionTest, SetZOrder01, TestSize.Level1) sceneSession->SetZOrder(zOrder); usleep(WAIT_ASYNC_US); ASSERT_EQ(zOrder, sceneSession->zOrder_); - sceneSession->SetZOrder(zOrder); - usleep(WAIT_ASYNC_US); - ASSERT_EQ(zOrder, sceneSession->zOrder_); } /** @@ -1173,9 +1170,7 @@ HWTEST_F(SceneSessionTest, GetCutoutAvoidArea, TestSize.Level1) EXPECT_NE(sceneSession, nullptr); WSRect overlapRect = { 0, 0, 0, 0 }; AvoidArea avoidArea; - int ret = 1; sceneSession->GetCutoutAvoidArea(overlapRect, avoidArea); - ASSERT_EQ(ret, 1); } /** @@ -1273,9 +1268,8 @@ HWTEST_F(SceneSessionTest, OnShowWhenLocked, TestSize.Level1) sptr sceneSession; sceneSession = sptr::MakeSptr(info, specificCallback_); EXPECT_NE(sceneSession, nullptr); - int ret = 0; - sceneSession->OnShowWhenLocked(false); - ASSERT_EQ(ret, 0); + auto res = sceneSession->OnShowWhenLocked(false); + ASSERT_EQ(res, WSError::WS_OK); } /** @@ -1492,7 +1486,6 @@ HWTEST_F(SceneSessionTest, CalculateAvoidAreaRect, TestSize.Level1) sptr sceneSession; sceneSession = sptr::MakeSptr(info, specificCallback_); EXPECT_NE(sceneSession, nullptr); - int ret = 0; WSRect overlapRect = { 0, 0, 0, 0 }; WSRect avoidRect = { 0, 0, 0, 0 }; AvoidArea avoidArea; @@ -1500,7 +1493,6 @@ HWTEST_F(SceneSessionTest, CalculateAvoidAreaRect, TestSize.Level1) WSRect overlapRect_ = { 1, 1, 1, 1 }; WSRect avoidRect_ = { 1, 1, 1, 1 }; sceneSession->CalculateAvoidAreaRect(overlapRect_, avoidRect_, avoidArea); - ASSERT_EQ(ret, 0); } /** @@ -1590,7 +1582,6 @@ HWTEST_F(SceneSessionTest, UpdateCameraWindowStatus, TestSize.Level1) sptr sysSession; sysSession = sptr::MakeSptr(info, specificCallback_); EXPECT_NE(sysSession, nullptr); - int ret = 1; specificCallback_->onCameraFloatSessionChange_ = [](uint32_t accessTokenId, bool isShowing) {}; specificCallback_->onCameraSessionChange_ = [](uint32_t accessTokenId, bool isShowing) {}; @@ -1611,7 +1602,6 @@ HWTEST_F(SceneSessionTest, UpdateCameraWindowStatus, TestSize.Level1) sysSession->SetPiPTemplateInfo(pipType); sysSession->property_ = property; sysSession->UpdateCameraWindowStatus(false); - ASSERT_EQ(ret, 1); } /** @@ -1664,7 +1654,6 @@ HWTEST_F(SceneSessionTest, NotifyPropertyWhenConnect, TestSize.Level1) sptr sceneSession; sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); - int ret = 1; std::string key = info.bundleName_ + info.moduleName_ + info.abilityName_; sceneSession = sptr::MakeSptr(info, specificCallback_); sceneSession->NotifyPropertyWhenConnect(); @@ -1672,7 +1661,6 @@ HWTEST_F(SceneSessionTest, NotifyPropertyWhenConnect, TestSize.Level1) property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); sceneSession->property_ = property; sceneSession->NotifyPropertyWhenConnect(); - ASSERT_EQ(ret, 1); } /** diff --git a/window_scene/test/unittest/scene_session_test2.cpp b/window_scene/test/unittest/scene_session_test2.cpp index 4044cac88daf85a4b4e29dde253c65e76bdbd5d3..fa4d39a002cdb74f9500963877c2237854cb6b8b 100644 --- a/window_scene/test/unittest/scene_session_test2.cpp +++ b/window_scene/test/unittest/scene_session_test2.cpp @@ -169,14 +169,12 @@ HWTEST_F(SceneSessionTest2, NotifyPropertyWhenConnect1, TestSize.Level1) EXPECT_NE(specificCallback_, nullptr); sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); - int ret = 1; std::string key = info.bundleName_ + info.moduleName_ + info.abilityName_; sceneSession = sptr::MakeSptr(info, specificCallback_); sceneSession->NotifyPropertyWhenConnect(); sptr property = nullptr; sceneSession->NotifyPropertyWhenConnect(); - ASSERT_EQ(ret, 1); } /** @@ -506,11 +504,9 @@ HWTEST_F(SceneSessionTest2, SetScale, TestSize.Level1) sptr specificCallback_ = sptr::MakeSptr(); EXPECT_NE(specificCallback_, nullptr); - int resultValue = 0; sptr sceneSession = sptr::MakeSptr(info, nullptr); EXPECT_NE(sceneSession, nullptr); sceneSession->SetScale(1.0f, 1.0f, 0.0f, 0.0f); - ASSERT_EQ(0, resultValue); } /** diff --git a/window_scene/test/unittest/scene_session_test5.cpp b/window_scene/test/unittest/scene_session_test5.cpp index 9ded5b7c1299ba413431cf3c483646428c53df09..14f83040e58e5ade56ffb291eb970083b398d5b9 100644 --- a/window_scene/test/unittest/scene_session_test5.cpp +++ b/window_scene/test/unittest/scene_session_test5.cpp @@ -157,12 +157,10 @@ HWTEST_F(SceneSessionTest5, HookAvoidAreaInCompatibleMode, TestSize.Level1) session->property_->SetCompatibleModeProperty(compatibleModeProperty); session->property_->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING); session->HookAvoidAreaInCompatibleMode(rect, AvoidAreaType::TYPE_SYSTEM, avoidArea); - EXPECT_TRUE(avoidArea.topRect_ == invalidRect); compatibleModeProperty->SetIsAdaptToImmersive(true); session->property_->SetCompatibleModeProperty(compatibleModeProperty); session->property_->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN); session->HookAvoidAreaInCompatibleMode(rect, AvoidAreaType::TYPE_SYSTEM, avoidArea); - EXPECT_TRUE(avoidArea.topRect_ == invalidRect); // test top system avoidArea session->property_->GetCompatibleModeProperty()->SetIsAdaptToImmersive(true); @@ -2166,7 +2164,6 @@ HWTEST_F(SceneSessionTest5, CompatibilityModeWindowScaleTransfer, TestSize.Level info.screenId_ = 0; sptr mainSession = sptr::MakeSptr(info, nullptr); WSRect preRect = { 100, 100, 400, 400 }; - WSRect noChangeRect = { 100, 100, 400, 400 }; WSRect resultRect = { 200, 200, 200, 200 }; float scaleX = 0.5f; float scaleY = 0.5f; @@ -2176,14 +2173,12 @@ HWTEST_F(SceneSessionTest5, CompatibilityModeWindowScaleTransfer, TestSize.Level compatibleModeProperty->SetIsAdaptToProportionalScale(false); mainSession->property_->SetCompatibleModeProperty(compatibleModeProperty); mainSession->CompatibilityModeWindowScaleTransfer(preRect, isScale); - EXPECT_EQ(noChangeRect, preRect); compatibleModeProperty->SetIsAdaptToProportionalScale(true); mainSession->property_->SetCompatibleModeProperty(compatibleModeProperty); mainSession->CompatibilityModeWindowScaleTransfer(preRect, isScale); EXPECT_EQ(resultRect, preRect); isScale = false; mainSession->CompatibilityModeWindowScaleTransfer(preRect, isScale); - EXPECT_EQ(noChangeRect, preRect); } /** diff --git a/window_scene/test/unittest/session_specific_window_test.cpp b/window_scene/test/unittest/session_specific_window_test.cpp index d9a1eab8c124692dd1d3b76fbcb667c99f52cd3b..1e7e7fd8a373f998b2a6a4a3498058bf97c5eda5 100644 --- a/window_scene/test/unittest/session_specific_window_test.cpp +++ b/window_scene/test/unittest/session_specific_window_test.cpp @@ -183,11 +183,9 @@ HWTEST_F(SessionSpecificWindowTest, ClearSpecificSessionCbMap01, TestSize.Level1 info.bundleName_ = "ClearSpecificSessionCbMap01"; sptr sceneSession = sptr::MakeSptr(info, nullptr); sptr session = sptr::MakeSptr(info); - auto result = false; sceneSession->clearCallbackMapFunc_ = nullptr; sceneSession->ClearSpecificSessionCbMap(); usleep(WAIT_SYNC_IN_NS); - ASSERT_EQ(result, false); ASSERT_NE(sceneSession, nullptr); } diff --git a/window_scene/test/unittest/session_stub_test.cpp b/window_scene/test/unittest/session_stub_test.cpp index cf565667cbc2fa3adaf11f7ba35dcec66d8f8ce0..b01e22ea0fe378bdb8550b5548840c66e4ff1d57 100644 --- a/window_scene/test/unittest/session_stub_test.cpp +++ b/window_scene/test/unittest/session_stub_test.cpp @@ -1398,7 +1398,6 @@ HWTEST_F(SessionStubTest, HandleUpdateKeyFrameCloneNode, Function | SmallTest | ASSERT_EQ(result, ERR_NONE); int32_t ret = 0; ASSERT_EQ(reply.ReadInt32(ret), true); - ASSERT_EQ(ret, 0); } /** diff --git a/window_scene/test/unittest/session_test.cpp b/window_scene/test/unittest/session_test.cpp index 89768221ad7aa40bc35e4d0af736c02b750ffc37..e538580d4ff3001d2c83662ab4abeb998d500f97 100644 --- a/window_scene/test/unittest/session_test.cpp +++ b/window_scene/test/unittest/session_test.cpp @@ -40,6 +40,12 @@ namespace OHOS { namespace Rosen { namespace { const std::string UNDEFINED = "undefined"; + std::string g_errLog; + void MyLogCallback(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, + const char *msg) + { + g_errLog = msg; + } } class WindowSessionTest : public testing::Test { @@ -1667,9 +1673,12 @@ HWTEST_F(WindowSessionTest, GetAndSetSessionRequestRect, TestSize.Level1) */ HWTEST_F(WindowSessionTest, SetSessionRect01, TestSize.Level1) { + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); WSRect rect = session_->GetSessionRect(); session_->SetSessionRect(rect); - ASSERT_EQ(rect, session_->GetSessionRect()); + EXPECT_TRUE(g_errLog.find("id: %{public}d skip same rect") != std::string::npos); + LOG_SetCallback(nullptr); } /** diff --git a/window_scene/test/unittest/session_test3.cpp b/window_scene/test/unittest/session_test3.cpp index aa0ec8283b3d8c508bd4b4dcab789867e04bb98c..d14d0b3195ddb363f69e5b3008a7c382721cb45c 100644 --- a/window_scene/test/unittest/session_test3.cpp +++ b/window_scene/test/unittest/session_test3.cpp @@ -645,7 +645,6 @@ HWTEST_F(WindowSessionTest3, NotifyClick, TestSize.Level1) session_->SetClickListener(func); session_->NotifyClick(false, false); EXPECT_EQ(resultValue, 1); - EXPECT_EQ(hasRequestFocus, false); EXPECT_EQ(hasIsClick, false); } @@ -1017,7 +1016,6 @@ HWTEST_F(WindowSessionTest3, NotifySessionPropertyChange01, TestSize.Level1) [&resultValue](int32_t persistentid, WindowInfoKey windowInfoKey) { resultValue = 1; }; session_->sessionPropertyChangeNotifyManagerFunc_ = nullptr; session_->NotifySessionPropertyChange(WindowInfoKey::WINDOW_RECT); - EXPECT_EQ(resultValue, 0); session_->SetSessionPropertyChangeNotifyManagerListener(func); session_->NotifySessionPropertyChange(WindowInfoKey::WINDOW_RECT); @@ -1173,7 +1171,6 @@ HWTEST_F(WindowSessionTest3, GetIsHighlighted, Function | SmallTest | Level2) ASSERT_NE(session_, nullptr); bool isHighlighted = false; ASSERT_EQ(session_->GetIsHighlighted(isHighlighted), WSError::WS_OK); - ASSERT_EQ(isHighlighted, false); } } // namespace } // namespace Rosen diff --git a/window_scene/test/unittest/session_test4.cpp b/window_scene/test/unittest/session_test4.cpp index 1ec4a6f112387743ce0e83ab6f29cddd0683b106..12ef0f99e1133b4f295531aee4dfdd726f460076 100644 --- a/window_scene/test/unittest/session_test4.cpp +++ b/window_scene/test/unittest/session_test4.cpp @@ -41,6 +41,12 @@ namespace Rosen { namespace { const std::string UNDEFINED = "undefined"; constexpr HiviewDFX::HiLogLabel LABEL = { LOG_CORE, HILOG_DOMAIN_WINDOW, "WindowSessionTest4" }; + std::string g_errLog; + void MyLogCallback(const LogType type, const LogLevel level, const unsigned int domain, const char *tag, + const char *msg) + { + g_errLog = msg; + } } // namespace namespace { std::string g_logMsg; @@ -935,16 +941,18 @@ HWTEST_F(WindowSessionTest4, ShouldCreateDetectTaskInRecent, TestSize.Level1) */ HWTEST_F(WindowSessionTest4, CreateWindowStateDetectTask, TestSize.Level1) { + g_errLog.clear(); + LOG_SetCallback(MyLogCallback); auto isScreenLockedCallback = [this]() { return ssm_->IsScreenLocked(); }; session_->RegisterIsScreenLockedCallback(isScreenLockedCallback); session_->SetSessionState(SessionState::STATE_CONNECT); bool isAttach = true; session_->CreateWindowStateDetectTask(isAttach, WindowMode::WINDOW_MODE_UNDEFINED); - ASSERT_EQ(isAttach, true); + EXPECT_FALSE(g_errLog.find("Window attach state and session state mismatch, ") != std::string::npos); session_->handler_ = nullptr; session_->CreateWindowStateDetectTask(false, WindowMode::WINDOW_MODE_UNDEFINED); - ASSERT_EQ(session_->handler_, nullptr); + LOG_SetCallback(nullptr); } /** diff --git a/window_scene/test/unittest/ssmgr_specific_window_test.cpp b/window_scene/test/unittest/ssmgr_specific_window_test.cpp index 3f453a4a5ac0f57a73baa34b564026a145b5f9f8..ce2228d3c9605dbc3c9dcd53736f0bddfe8682b4 100644 --- a/window_scene/test/unittest/ssmgr_specific_window_test.cpp +++ b/window_scene/test/unittest/ssmgr_specific_window_test.cpp @@ -252,7 +252,6 @@ HWTEST_F(SSMgrSpecificWindowTest, IsKeyboardForeground, TestSize.Level1) ssm_->sceneSessionMap_.insert({ 0, sceneSession }); session->property_ = sptr::MakeSptr(); - ASSERT_NE(session->property_, nullptr); if (session->property_) { auto result1 = session->GetWindowType(); diff --git a/window_scene/test/unittest/system_session_test.cpp b/window_scene/test/unittest/system_session_test.cpp index a421e35164117f7862100b4a0ea540d056903c8d..5710f34387b6996cbec8f61bbbbaf00351a9242a 100644 --- a/window_scene/test/unittest/system_session_test.cpp +++ b/window_scene/test/unittest/system_session_test.cpp @@ -318,15 +318,12 @@ HWTEST_F(SystemSessionTest, UpdateCameraWindowStatus01, TestSize.Level1) bool result = false; systemSession_->UpdateCameraWindowStatus(true); - ASSERT_EQ(result, false); systemSession_->specificCallback_ = specificCallback; systemSession_->UpdateCameraWindowStatus(true); - ASSERT_EQ(result, false); systemSession_->property_->SetWindowType(WindowType::WINDOW_TYPE_FLOAT_CAMERA); systemSession_->UpdateCameraWindowStatus(true); - ASSERT_EQ(result, false); systemSession_->specificCallback_->onCameraFloatSessionChange_ = [&result](uint32_t accessTokenId, bool isShowing) { result = isShowing; @@ -353,7 +350,6 @@ HWTEST_F(SystemSessionTest, UpdateCameraWindowStatus02, TestSize.Level1) sysSession->property_->SetWindowType(WindowType::WINDOW_TYPE_PIP); sysSession->property_->SetWindowMode(WindowMode::WINDOW_MODE_PIP); sysSession->UpdateCameraWindowStatus(true); - ASSERT_EQ(result, false); sysSession->specificCallback_->onCameraSessionChange_ = [&result](uint32_t accessTokenId, bool isShowing) { result = isShowing; @@ -372,7 +368,6 @@ HWTEST_F(SystemSessionTest, UpdateCameraWindowStatus02, TestSize.Level1) result = false; sysSession->pipTemplateInfo_.pipTemplateType = static_cast(PiPTemplateType::VIDEO_LIVE); sysSession->UpdateCameraWindowStatus(true); - ASSERT_EQ(result, false); } /** @@ -706,7 +701,8 @@ HWTEST_F(SystemSessionTest, NotifyClientToUpdateRect03, TestSize.Level1) sysSession->dirtyFlags_ = 0; sysSession->isKeyboardPanelEnabled_ = true; - sysSession->Session::UpdateSizeChangeReason(SizeChangeReason::MAXIMIZE); + auto res = sysSession->Session::UpdateSizeChangeReason(SizeChangeReason::MAXIMIZE); + EXPECT_EQ(res, WSError::WS_OK); sptr specificCallback = sptr::MakeSptr(); @@ -714,17 +710,18 @@ HWTEST_F(SystemSessionTest, NotifyClientToUpdateRect03, TestSize.Level1) sysSession->specificCallback_ = specificCallback; sysSession->specificCallback_->onUpdateAvoidArea_ = nullptr; sysSession->GetLayoutController()->SetSessionRect({ 0, 0, 800, 800 }); - sysSession->NotifyClientToUpdateRect("SystemSessionTest", nullptr); + res = sysSession->NotifyClientToUpdateRect("SystemSessionTest", nullptr); usleep(WAIT_ASYNC_US); - EXPECT_EQ(sysSession->dirtyFlags_, 0); + EXPECT_EQ(res, WSError::WS_OK); sysSession->dirtyFlags_ = 0; sysSession->SetScbCoreEnabled(true); sysSession->Session::UpdateSizeChangeReason(SizeChangeReason::MAXIMIZE); sysSession->specificCallback_->onUpdateAvoidArea_ = [](const int32_t& persistentId) {}; - sysSession->NotifyClientToUpdateRect("SystemSessionTest", nullptr); + res = sysSession->NotifyClientToUpdateRect("SystemSessionTest", nullptr); usleep(WAIT_ASYNC_US); EXPECT_EQ(sysSession->dirtyFlags_, static_cast(SessionUIDirtyFlag::AVOID_AREA)); + EXPECT_EQ(res, WSError::WS_OK); } /**