!7945 生命周期UT分支覆盖率补充

Merge pull request !7945 from hubijie/master
This commit is contained in:
openharmony_ci 2024-08-08 14:13:59 +00:00 committed by Gitee
commit 661070e61a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 131 additions and 1 deletions

View File

@ -776,6 +776,10 @@ HWTEST_F(SceneSessionTest, GetKeyboardAvoidArea, Function | SmallTest | Level2)
int ret = 1;
scensession->GetKeyboardAvoidArea(overlapRect, avoidArea);
ASSERT_EQ(ret, 1);
scensession->SetSessionProperty(nullptr);
scensession->GetKeyboardAvoidArea(overlapRect, avoidArea);
ASSERT_EQ(nullptr, scensession->GetSessionProperty());
}
/**
@ -833,6 +837,13 @@ HWTEST_F(SceneSessionTest, SetSystemBarProperty, Function | SmallTest | Level2)
scensession->property_ = property;
ASSERT_EQ(scensession->SetSystemBarProperty(WindowType::WINDOW_TYPE_FLOAT_CAMERA, statusBarProperty),
WSError::WS_OK);
scensession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback();
EXPECT_NE(nullptr, scensession->sessionChangeCallback_);
scensession->sessionChangeCallback_->OnSystemBarPropertyChange_ = [](
const std::unordered_map<WindowType, SystemBarProperty>& propertyMap){};
ASSERT_EQ(scensession->SetSystemBarProperty(WindowType::WINDOW_TYPE_FLOAT_CAMERA, statusBarProperty),
WSError::WS_OK);
}
/**
@ -856,6 +867,11 @@ HWTEST_F(SceneSessionTest, OnShowWhenLocked, Function | SmallTest | Level2)
int ret = 0;
scensession->OnShowWhenLocked(false);
ASSERT_EQ(ret, 0);
scensession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback();
EXPECT_NE(scensession->sessionChangeCallback_, nullptr);
scensession->sessionChangeCallback_->OnShowWhenLocked_ = [](bool showWhenLocked){};
ASSERT_EQ(scensession->OnShowWhenLocked(false), WSError::WS_OK);
}
/**
@ -931,6 +947,14 @@ HWTEST_F(SceneSessionTest, GetAvoidAreaByType, Function | SmallTest | Level2)
scensession->GetAvoidAreaByType(AvoidAreaType::TYPE_KEYBOARD);
scensession->GetAvoidAreaByType(AvoidAreaType::TYPE_SYSTEM_GESTURE);
EXPECT_NE(scensession, nullptr);
property->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
scensession->property_ = property;
scensession->GetAvoidAreaByType(AvoidAreaType::TYPE_CUTOUT);
scensession->GetAvoidAreaByType(AvoidAreaType::TYPE_SYSTEM);
scensession->GetAvoidAreaByType(AvoidAreaType::TYPE_KEYBOARD);
scensession->GetAvoidAreaByType(AvoidAreaType::TYPE_SYSTEM_GESTURE);
EXPECT_NE(scensession, nullptr);
}
/**
@ -1040,6 +1064,11 @@ HWTEST_F(SceneSessionTest, OnNeedAvoid, Function | SmallTest | Level2)
scensession = new (std::nothrow) SceneSession(info, specificCallback_);
EXPECT_NE(scensession, nullptr);
ASSERT_EQ(scensession->OnNeedAvoid(false), WSError::WS_OK);
scensession->sessionChangeCallback_ = new SceneSession::SessionChangeCallback();
EXPECT_NE(scensession->sessionChangeCallback_, nullptr);
scensession->sessionChangeCallback_->OnNeedAvoid_ = [](bool state){};
ASSERT_EQ(scensession->OnNeedAvoid(false), WSError::WS_OK);
}
/**
@ -1181,6 +1210,10 @@ HWTEST_F(SceneSessionTest, NotifyPropertyWhenConnect, Function | SmallTest | Lev
scensession->property_ = property;
scensession->NotifyPropertyWhenConnect();
ASSERT_EQ(ret, 1);
scensession->SetSessionProperty(nullptr);
scensession->NotifyPropertyWhenConnect();
ASSERT_EQ(scensession->GetSessionProperty(), nullptr);
}
/**
@ -1507,7 +1540,13 @@ HWTEST_F(SceneSessionTest, UpdateInputMethodSessionRect, Function | SmallTest |
EXPECT_NE(sceneSession, nullptr);
sceneSession->SetSessionProperty(nullptr);
sceneSession->UpdateInputMethodSessionRect(rect, newWinRect, newRequestRect);
auto res = sceneSession->UpdateInputMethodSessionRect(rect, newWinRect, newRequestRect);
ASSERT_EQ(res, false);
property->SetKeyboardSessionGravity(SessionGravity::SESSION_GRAVITY_FLOAT, p);
sceneSession->SetSessionProperty(property);
res = sceneSession->UpdateInputMethodSessionRect(rect, newWinRect, newRequestRect);
ASSERT_EQ(res, false);
}
/**

View File

@ -1095,6 +1095,16 @@ HWTEST_F(SceneSessionTest2, SetPiPControlEvent, Function | SmallTest | Level2)
sceneSession->SetSessionProperty(property);
res = sceneSession->SetPiPControlEvent(controlType, status);
ASSERT_EQ(res, WSError::WS_ERROR_NULLPTR);
property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
sceneSession->property_ = property;
ASSERT_EQ(sceneSession->SetPiPControlEvent(controlType, status), WSError::WS_ERROR_INVALID_TYPE);
sceneSession->sessionStage_ = sptr<SessionStageMocker>::MakeSptr();
property->SetWindowType(WindowType::WINDOW_TYPE_PIP);
property->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
sceneSession->property_ = property;
ASSERT_EQ(sceneSession->SetPiPControlEvent(controlType, status), WSError::WS_OK);
}
/**
@ -1349,6 +1359,9 @@ HWTEST_F(SceneSessionTest2, OnSessionEvent01, Function | SmallTest | Level2)
EXPECT_NE(sceneSession->sessionChangeCallback_, nullptr);
auto result = sceneSession->OnSessionEvent(event);
ASSERT_EQ(result, WSError::WS_OK);
event = SessionEvent::EVENT_END_MOVE;
ASSERT_EQ(sceneSession->OnSessionEvent(event), WSError::WS_OK);
}
/**
@ -1416,6 +1429,9 @@ HWTEST_F(SceneSessionTest2, RaiseAppMainWindowToTop, Function | SmallTest | Leve
bool showWhenLocked = true;
sceneSession->OnShowWhenLocked(showWhenLocked);
sceneSession->NotifyPropertyWhenConnect();
sceneSession->focusedOnShow_ = false;
sceneSession->RaiseAppMainWindowToTop();
}
/**
@ -1478,6 +1494,27 @@ HWTEST_F(SceneSessionTest2, GetAINavigationBarArea, Function | SmallTest | Level
WSRect rect;
AvoidArea avoidArea;
sceneSession->GetAINavigationBarArea(rect, avoidArea);
sceneSession->SetIsDisplayStatusBarTemporarily(true);
sceneSession->GetAINavigationBarArea(rect, avoidArea);
ASSERT_EQ(sceneSession->GetIsDisplayStatusBarTemporarily(), true);
auto property = sptr<WindowSessionProperty>::MakeSptr();
EXPECT_NE(property, nullptr);
property->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
sceneSession->property_ = property;
sceneSession->GetAINavigationBarArea(rect, avoidArea);
sceneSession->SetSessionProperty(nullptr);
sceneSession->GetAINavigationBarArea(rect, avoidArea);
property->SetWindowMode(WindowMode::WINDOW_MODE_FLOATING);
sceneSession->SetSessionProperty(property);
sceneSession->specificCallback_->onGetAINavigationBarArea_ = [](uint64_t displayId) {
WSRect rect = {1, 1, 1, 1};
return rect;
};
sceneSession->GetAINavigationBarArea(rect, avoidArea);
}
/**
@ -1525,6 +1562,17 @@ HWTEST_F(SceneSessionTest2, TransferPointerEvent03, Function | SmallTest | Level
float vpr = 0.0;
sceneSession->FixRectByLimits(limits, rect, ratio, isDecor, vpr);
sceneSession->SetPipActionEvent("pointerEvent", 0);
auto property = sptr<WindowSessionProperty>::MakeSptr();
EXPECT_NE(property, nullptr);
property->SetWindowType(WindowType::WINDOW_TYPE_FLOAT);
sceneSession->SetSessionProperty(property);
ASSERT_EQ(WSError::WS_ERROR_INVALID_TYPE, sceneSession->SetPipActionEvent("pointerEvent", 0));
sceneSession->sessionStage_ = sptr<SessionStageMocker>::MakeSptr();
property->SetWindowType(WindowType::WINDOW_TYPE_PIP);
property->SetWindowMode(WindowMode::WINDOW_MODE_PIP);
ASSERT_EQ(WSError::WS_OK, sceneSession->SetPipActionEvent("pointerEvent", 0));
}
/**
@ -1793,6 +1841,30 @@ HWTEST_F(SceneSessionTest2, GetSubWindowModalType, Function | SmallTest | Level2
result = sceneSession->GetSubWindowModalType();
ASSERT_EQ(result, SubWindowModalType::TYPE_DIALOG);
}
/**
* @tc.name: CheckGetAvoidAreaAvailable
* @tc.desc: CheckGetAvoidAreaAvailable
* @tc.type: FUNC
*/
HWTEST_F(SceneSessionTest2, CheckGetAvoidAreaAvailable, Function | SmallTest | Level2)
{
SessionInfo info;
info.abilityName_ = "CheckGetAvoidAreaAvailable";
info.bundleName_ = "CheckGetAvoidAreaAvailable";
sptr<SceneSession> sceneSession = new (std::nothrow) SceneSession(info, nullptr);
EXPECT_NE(sceneSession, nullptr);
sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
EXPECT_NE(property, nullptr);
property->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
sceneSession->SetSessionProperty(property);
sceneSession->CheckGetAvoidAreaAvailable(AvoidAreaType::TYPE_SYSTEM);
property->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
sceneSession->SetSessionProperty(property);
sceneSession->CheckGetAvoidAreaAvailable(AvoidAreaType::TYPE_SYSTEM);
}
}
}
}

View File

@ -308,6 +308,14 @@ HWTEST_F(SceneSessionTest3, NotifyClientToUpdateRectTask, Function | SmallTest |
property->SetWindowType(WindowType::WINDOW_TYPE_KEYBOARD_PANEL);
sceneSession->SetSessionProperty(property);
ASSERT_EQ(WSError::WS_OK, sceneSession->NotifyClientToUpdateRectTask(nullptr));
property->SetWindowType(WindowType::WINDOW_TYPE_KEYBOARD_PANEL);
sceneSession->SetSessionProperty(property);
sceneSession->isKeyboardPanelEnabled_ = true;
ASSERT_EQ(WSError::WS_OK, sceneSession->NotifyClientToUpdateRectTask(nullptr));
std::shared_ptr<RSTransaction> rs;
ASSERT_EQ(WSError::WS_OK, sceneSession->NotifyClientToUpdateRectTask(rs));
}
/**

View File

@ -622,6 +622,17 @@ HWTEST_F(SceneSessionTest5, CheckAspectRatioValid, Function | SmallTest | Level2
windowLimits.maxHeight_ = 10000;
windowLimits.minHeight_ = -10000;
EXPECT_EQ(WSError::WS_OK, session->SetAspectRatio(0.0f));
session->SetSessionProperty(nullptr);
EXPECT_EQ(WSError::WS_ERROR_NULLPTR, session->SetAspectRatio(0.0f));
sptr<WindowSessionProperty> property = new (std::nothrow) WindowSessionProperty();
EXPECT_NE(property, nullptr);
WindowLimits limits = {8, 1, 6, 1, 1, 1.0f, 1.0f};
property->SetWindowLimits(limits);
session->SetSessionProperty(property);
EXPECT_EQ(WSError::WS_ERROR_INVALID_PARAM, session->SetAspectRatio(0.1f));
EXPECT_EQ(WSError::WS_ERROR_INVALID_PARAM, session->SetAspectRatio(10.0f));
}
/**