add in new ut wm

Signed-off-by: z30042987 <zhouminghui8@huawei.com>
This commit is contained in:
z30042987 2023-07-15 17:20:23 +08:00
parent 4e86de6b90
commit 053bc66fa1
4 changed files with 581 additions and 61 deletions

View File

@ -52,6 +52,7 @@ public:
MOCK_METHOD1(RaiseToAppTop, WmErrorCode(uint32_t windowId));
MOCK_METHOD1(GetSystemConfig, WMError(SystemConfig& systemConfig));
MOCK_METHOD2(DispatchKeyEvent, void(uint32_t windowId, std::shared_ptr<MMI::KeyEvent> event));
MOCK_METHOD0(GetMaximizeMode, MaximizeMode());
};
}
} // namespace OHOS

View File

@ -47,6 +47,8 @@ public:
MOCK_METHOD1(GetAvoidAreaByType, AvoidArea(AvoidAreaType type));
MOCK_METHOD1(SetAspectRatio, WSError(float ratio));
MOCK_METHOD1(ResetAspectRatio, WSError(float ratio));
MOCK_METHOD1(OnNeedAvoid, WSError(bool status));
MOCK_METHOD1(SetGlobalMaximizeMode, WSError(MaximizeMode mode));
};
} // namespace Rosen
} // namespace OHOS

View File

@ -107,12 +107,12 @@ HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession01, Function
option->SetWindowName("CreateAndConnectSpecificSession01");
sptr<WindowSceneSessionImpl> windowscenesession = new (std::nothrow) WindowSceneSessionImpl(option);
ASSERT_NE(nullptr, windowscenesession);
windowscenesession->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowscenesession->CreateAndConnectSpecificSession());
windowscenesession->property_->SetPersistentId(100);
windowscenesession->property_->SetParentPersistentId(11);
windowscenesession->property_->SetParentId(11);
windowscenesession->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowscenesession->CreateAndConnectSpecificSession());
windowscenesession->property_->SetPersistentId(102);
windowscenesession->property_->SetParentPersistentId(100);
windowscenesession->property_->SetParentId(100);
SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
ASSERT_NE(nullptr, session);
@ -121,7 +121,36 @@ HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession01, Function
ASSERT_EQ(WMError::WM_OK, windowscenesession->Create(abilityContext_, session));
windowscenesession->hostSession_ = session;
EXPECT_CALL(*(session), CreateAndConnectSpecificSession(_, _, _, _, _, _)).WillOnce(Return(WSError::WS_OK));
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, windowscenesession->CreateAndConnectSpecificSession());
}
/**
* @tc.name: CreateAndConnectSpecificSession02
* @tc.desc: CreateAndConnectSpecificSession
* @tc.type: FUNC
*/
HWTEST_F(WindowSceneSessionImplTest, CreateAndConnectSpecificSession02, Function | SmallTest | Level2)
{
sptr<WindowOption> option_ = new (std::nothrow) WindowOption();
option_->SetWindowTag(WindowTag::SUB_WINDOW);
option_->SetWindowName("ChildWindow0002");
sptr<WindowSceneSessionImpl> parentscenesession_ = new (std::nothrow) WindowSceneSessionImpl(option_);
ASSERT_NE(nullptr, parentscenesession_);
SessionInfo sessionInfo_ = { "CreateTestBundle0", "CreateTestModule0", "CreateTestAbility0" };
sptr<SessionMocker> session_ = new (std::nothrow) SessionMocker(sessionInfo_);
ASSERT_NE(nullptr, session_);
EXPECT_CALL(*(session_), Connect(_, _, _, _, _, _)).WillOnce(Return(WSError::WS_OK));
ASSERT_EQ(WMError::WM_OK, parentscenesession_->Create(abilityContext_, session_));
parentscenesession_->property_->SetParentPersistentId(102);
parentscenesession_->property_->SetParentId(102);
parentscenesession_->property_->type_ = WindowType::APP_MAIN_WINDOW_BASE;
parentscenesession_->hostSession_ = session_;
EXPECT_CALL(*(session_), CreateAndConnectSpecificSession(_, _, _, _, _, _)).WillOnce(Return(WSError::WS_OK));
parentscenesession_->property_->type_ = WindowType::APP_SUB_WINDOW_BASE;
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, parentscenesession_->CreateAndConnectSpecificSession());
}
/**
@ -180,23 +209,27 @@ HWTEST_F(WindowSceneSessionImplTest, FindParentSessionByParentId01, Function | S
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
option->SetWindowTag(WindowTag::MAIN_WINDOW);
option->SetWindowName("Connect01");
option->SetWindowName("FindParentSessionByParentId01");
sptr<WindowSceneSessionImpl> parentscenesession = new (std::nothrow) WindowSceneSessionImpl(option);
ASSERT_NE(nullptr, parentscenesession);
parentscenesession->property_->SetPersistentId(100);
WindowSessionImpl::windowSessionMap_["parentWindow"] = std::make_pair(1, parentscenesession);
parentscenesession->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
ASSERT_TRUE(parentscenesession->FindMainWindowWithContext() == nullptr);
parentscenesession->SetWindowType(WindowType::ABOVE_APP_SYSTEM_WINDOW_END);
ASSERT_TRUE(parentscenesession->FindMainWindowWithContext() == nullptr);
sptr<WindowOption> option_ = new WindowOption();
option_->SetWindowTag(WindowTag::MAIN_WINDOW);
option_->SetWindowName("Connect01");
sptr<WindowSceneSessionImpl> childscenesession = new (std::nothrow) WindowSceneSessionImpl(option_);
ASSERT_TRUE(nullptr == childscenesession->FindParentSessionByParentId(101));
childscenesession->property_->SetPersistentId(101);
childscenesession->property_->SetParentId(100);
childscenesession->property_->SetParentPersistentId(100);
parentscenesession->property_->SetPersistentId(1112);
parentscenesession->property_->SetParentId(1000);
parentscenesession->property_->SetParentPersistentId(1000);
parentscenesession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
ASSERT_NE(nullptr, session);
sptr<WindowSessionImpl> parent = childscenesession->FindParentSessionByParentId(101);
ASSERT_FALSE(nullptr != childscenesession->FindParentSessionByParentId(101));
EXPECT_CALL(*(session), Connect(_, _, _, _, _, _)).WillOnce(Return(WSError::WS_OK));
ASSERT_EQ(WMError::WM_OK, parentscenesession->Create(abilityContext_, session));
parentscenesession->hostSession_ = session;
ASSERT_TRUE(nullptr != parentscenesession->FindParentSessionByParentId(1112));
}
/**
@ -208,14 +241,41 @@ HWTEST_F(WindowSceneSessionImplTest, FindMainWindowWithContext01, Function | Sma
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
option->SetWindowTag(WindowTag::MAIN_WINDOW);
option->SetWindowName("Connect01");
option->SetWindowName("FindMainWindowWithContext01");
sptr<WindowSceneSessionImpl> parentscenesession = new (std::nothrow) WindowSceneSessionImpl(option);
ASSERT_NE(nullptr, parentscenesession);
parentscenesession->property_->SetPersistentId(100);
parentscenesession->SetWindowType(WindowType::WINDOW_TYPE_DIALOG);
ASSERT_FALSE(parentscenesession->FindMainWindowWithContext() == nullptr);
parentscenesession->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
ASSERT_TRUE(parentscenesession->FindMainWindowWithContext() == nullptr);
parentscenesession->SetWindowType(WindowType::ABOVE_APP_SYSTEM_WINDOW_END);
ASSERT_TRUE(parentscenesession->FindMainWindowWithContext() == nullptr);
parentscenesession->property_->SetPersistentId(1002);
parentscenesession->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
ASSERT_NE(nullptr, session);
EXPECT_CALL(*(session), Connect(_, _, _, _, _, _)).WillOnce(Return(WSError::WS_OK));
ASSERT_EQ(WMError::WM_OK, parentscenesession->Create(abilityContext_, session));
parentscenesession->hostSession_ = session;
ASSERT_TRUE(nullptr != parentscenesession->FindParentSessionByParentId(1002));
sptr<WindowOption> option_ = new (std::nothrow) WindowOption();
option_->SetWindowTag(WindowTag::MAIN_WINDOW);
option_->SetWindowName("FindMainWindowWithContext02");
sptr<WindowSceneSessionImpl> parentscenesession_ = new (std::nothrow) WindowSceneSessionImpl(option_);
ASSERT_NE(nullptr, parentscenesession_);
SessionInfo sessionInfo_ = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
sptr<SessionMocker> session_ = new (std::nothrow) SessionMocker(sessionInfo_);
ASSERT_NE(nullptr, session_);
EXPECT_CALL(*(session_), Connect(_, _, _, _, _, _)).WillOnce(Return(WSError::WS_OK));
ASSERT_EQ(WMError::WM_OK, parentscenesession_->Create(abilityContext_, session_));
parentscenesession_->hostSession_ = session_;
parentscenesession_->property_->type_ = WindowType::WINDOW_TYPE_DIALOG;
ASSERT_FALSE(parentscenesession_->FindMainWindowWithContext() == nullptr);
}
/**
@ -655,6 +715,414 @@ HWTEST_F(WindowSceneSessionImplTest, LimitCameraFloatWindowMininumSize, Function
uint32_t height = 31;
window->LimitCameraFloatWindowMininumSize(width, height);
}
/*
* @tc.name: NotifyWindowNeedAvoid
* @tc.desc: NotifyWindowNeedAvoid test
* @tc.type: FUNC
*/
HWTEST_F(WindowSceneSessionImplTest, NotifyWindowNeedAvoid, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
sptr<WindowSceneSessionImpl> window = new (std::nothrow) WindowSceneSessionImpl(option);
ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->NotifyWindowNeedAvoid(false));
window->state_ = WindowState::STATE_SHOWN;
SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
ASSERT_NE(nullptr, session);
window->property_->SetPersistentId(190);
window->hostSession_ = session;
EXPECT_CALL(*(session), OnNeedAvoid(false)).WillOnce(Return(WSError::WS_OK));
ASSERT_EQ(WMError::WM_OK, window->NotifyWindowNeedAvoid(false));
}
/*
* @tc.name: SetLayoutFullScreenByApiVersion
* @tc.desc: SetLayoutFullScreenByApiVersion test
* @tc.type: FUNC
*/
HWTEST_F(WindowSceneSessionImplTest, SetLayoutFullScreenByApiVersion, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
sptr<WindowSceneSessionImpl> window = new (std::nothrow) WindowSceneSessionImpl(option);
ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetLayoutFullScreenByApiVersion(false));
window->state_ = WindowState::STATE_SHOWN;
window->property_->SetPersistentId(190);
SessionInfo sessionInfo = { "CreateTestBundle", "CreateTestModule", "CreateTestAbility" };
sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
ASSERT_NE(nullptr, session);
window->hostSession_ = session;
EXPECT_CALL(*(session), OnSessionEvent(SessionEvent::EVENT_MAXIMIZE)).WillOnce(Return(WSError::WS_OK));
ASSERT_EQ(WMError::WM_OK, window->SetLayoutFullScreenByApiVersion(false));
}
/*
* @tc.name: SetGlobalMaximizeMode
* @tc.desc: SetGlobalMaximizeMode test
* @tc.type: FUNC
*/
HWTEST_F(WindowSceneSessionImplTest, SetGlobalMaximizeMode, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
sptr<WindowSceneSessionImpl> window = new (std::nothrow) WindowSceneSessionImpl(option);
ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetGlobalMaximizeMode(MaximizeMode::MODE_RECOVER));
window->state_ = WindowState::STATE_SHOWN;
SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"};
sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
ASSERT_NE(nullptr, session);
window->property_->SetPersistentId(190);
window->hostSession_ = session;
window->property_->SetWindowType(WindowType::APP_SUB_WINDOW_BASE);
ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, window->SetGlobalMaximizeMode(MaximizeMode::MODE_RECOVER));
window->property_->SetWindowType(WindowType::APP_MAIN_WINDOW_BASE);
EXPECT_CALL(*(session), SetGlobalMaximizeMode(MaximizeMode::MODE_RECOVER)).WillOnce(Return(WSError::WS_OK));
ASSERT_EQ(WMError::WM_OK, window->SetGlobalMaximizeMode(MaximizeMode::MODE_RECOVER));
}
/*
* @tc.name: CheckParmAndPermission
* @tc.desc: CheckParmAndPermission test
* @tc.type: FUNC
*/
HWTEST_F(WindowSceneSessionImplTest, CheckParmAndPermission, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
sptr<WindowSceneSessionImpl> window = new (std::nothrow) WindowSceneSessionImpl(option);
window->property_->SetWindowName("CheckParmAndPermission");
window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
auto surfaceNode = window->GetSurfaceNode();
if (surfaceNode == nullptr)
{
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->CheckParmAndPermission());
}
else
{
ASSERT_EQ(WMError::WM_OK, window->CheckParmAndPermission());
window->property_->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
ASSERT_EQ(WMError::WM_OK, window->CheckParmAndPermission());
}
}
/*
* @tc.name: SetBackdropBlurStyle
* @tc.desc: SetBackdropBlurStyle test
* @tc.type: FUNC
*/
HWTEST_F(WindowSceneSessionImplTest, SetBackdropBlurStyle, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
sptr<WindowSceneSessionImpl> window = new (std::nothrow) WindowSceneSessionImpl(option);
window->property_->SetWindowName("SetBackdropBlurStyle");
window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
ASSERT_EQ(WMError::WM_OK, window->SetBackdropBlurStyle(WindowBlurStyle::WINDOW_BLUR_OFF));
ASSERT_EQ(WMError::WM_OK, window->SetBackdropBlurStyle(WindowBlurStyle::WINDOW_BLUR_THICK));
}
/*
* @tc.name: SetTurnScreenOn
* @tc.desc: SetTurnScreenOn test
* @tc.type: FUNC
*/
HWTEST_F(WindowSceneSessionImplTest, SetTurnScreenOn, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
sptr<WindowSceneSessionImpl> window = new (std::nothrow) WindowSceneSessionImpl(option);
window->property_->SetWindowName("SetBackdropBlurStyle");
window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetTurnScreenOn(false));
window->property_->SetPersistentId(1);
SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"};
sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
ASSERT_NE(nullptr, session);
window->hostSession_ = session;
ASSERT_EQ(WMError::WM_OK, window->SetTurnScreenOn(false));
}
/*
* @tc.name: SetBlur
* @tc.desc: SetBlur test
* @tc.type: FUNC
*/
HWTEST_F(WindowSceneSessionImplTest, SetBlur, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
sptr<WindowSceneSessionImpl> window = new (std::nothrow) WindowSceneSessionImpl(option);
window->property_->SetWindowName("SetBlur");
auto surfaceNode = window->GetSurfaceNode();
if (surfaceNode == nullptr)
{
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->CheckParmAndPermission());
}
else
{
window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, window->SetBlur(-1.0));
ASSERT_EQ(WMError::WM_OK, window->SetBlur(1.0));
}
}
/*
* @tc.name: SetKeepScreenOn
* @tc.desc: SetKeepScreenOn test
* @tc.type: FUNC
*/
HWTEST_F(WindowSceneSessionImplTest, SetKeepScreenOn, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
sptr<WindowSceneSessionImpl> window = new (std::nothrow) WindowSceneSessionImpl(option);
window->property_->SetWindowName("SetKeepScreenOn");
window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetKeepScreenOn(false));
window->property_->SetPersistentId(1);
SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"};
sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
ASSERT_NE(nullptr, session);
window->hostSession_ = session;
ASSERT_EQ(WMError::WM_OK, window->SetKeepScreenOn(false));
ASSERT_FALSE(window->IsKeepScreenOn());
}
/*
* @tc.name: SetPrivacyMode
* @tc.desc: SetPrivacyMode test
* @tc.type: FUNC
*/
HWTEST_F(WindowSceneSessionImplTest, SetPrivacyMode, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
sptr<WindowSceneSessionImpl> window = new (std::nothrow) WindowSceneSessionImpl(option);
window->property_->SetWindowName("SetPrivacyMode");
window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
ASSERT_EQ(WMError::WM_DO_NOTHING, window->SetPrivacyMode(false));
ASSERT_EQ(false, window->IsPrivacyMode());
}
/*
* @tc.name: IsPrivacyMode
* @tc.desc: IsPrivacyMode test
* @tc.type: FUNC
*/
HWTEST_F(WindowSceneSessionImplTest, IsPrivacyModec, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
sptr<WindowSceneSessionImpl> window = new (std::nothrow) WindowSceneSessionImpl(option);
window->property_->SetWindowName("IsPrivacyModec");
window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
window->SetPrivacyMode(false);
}
/*
* @tc.name: SetSystemPrivacyMode
* @tc.desc: SetSystemPrivacyMode test
* @tc.type: FUNC
*/
HWTEST_F(WindowSceneSessionImplTest, SetSystemPrivacyMode, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
sptr<WindowSceneSessionImpl> window = new (std::nothrow) WindowSceneSessionImpl(option);
window->property_->SetWindowName("SetSystemPrivacyMode");
window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
window->SetSystemPrivacyMode(false);
ASSERT_EQ(false, window->property_->GetSystemPrivacyMode());
}
/*
* @tc.name: SetSnapshotSkip
* @tc.desc: SetSnapshotSkip test
* @tc.type: FUNC
*/
HWTEST_F(WindowSceneSessionImplTest, SetSnapshotSkip, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
sptr<WindowSceneSessionImpl> window = new (std::nothrow) WindowSceneSessionImpl(option);
window->property_->SetWindowName("SetSnapshotSkip");
window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
ASSERT_EQ(WMError::WM_OK, window->SetSnapshotSkip(false));
}
/*
* @tc.name: SetLayoutFullScreen
* @tc.desc: SetLayoutFullScreen test
* @tc.type: FUNC
*/
HWTEST_F(WindowSceneSessionImplTest, SetLayoutFullScreen, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
sptr<WindowSceneSessionImpl> window = new (std::nothrow) WindowSceneSessionImpl(option);
window->property_->SetWindowName("SetLayoutFullScreen");
window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetLayoutFullScreen(false));
window->property_->SetPersistentId(1);
SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"};
sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
ASSERT_NE(nullptr, session);
window->hostSession_ = session;
ASSERT_EQ(WMError::WM_OK, window->SetLayoutFullScreen(false));
ASSERT_EQ(true, window->IsLayoutFullScreen());
}
/*
* @tc.name: SetFullScreen
* @tc.desc: SetFullScreen test
* @tc.type: FUNC
*/
HWTEST_F(WindowSceneSessionImplTest, SetFullScreen, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
sptr<WindowSceneSessionImpl> window = new (std::nothrow) WindowSceneSessionImpl(option);
window->property_->SetWindowName("SetFullScreen");
window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
ASSERT_EQ(WMError::WM_ERROR_INVALID_WINDOW, window->SetFullScreen(false));
window->property_->SetPersistentId(1);
SessionInfo sessionInfo = {"CreateTestBundle", "CreateTestModule", "CreateTestAbility"};
sptr<SessionMocker> session = new (std::nothrow) SessionMocker(sessionInfo);
ASSERT_NE(nullptr, session);
window->hostSession_ = session;
ASSERT_EQ(WMError::WM_OK, window->SetFullScreen(false));
ASSERT_EQ(false, window->IsFullScreen());
}
/*
* @tc.name: SetShadowOffsetX
* @tc.desc: SetShadowOffsetX test
* @tc.type: FUNC
*/
HWTEST_F(WindowSceneSessionImplTest, SetShadowOffsetX, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
sptr<WindowSceneSessionImpl> window = new (std::nothrow) WindowSceneSessionImpl(option);
window->property_->SetWindowName("SetKeepScreenOn");
window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
auto surfaceNode = window->GetSurfaceNode();
if (surfaceNode == nullptr)
{
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->CheckParmAndPermission());
}
else
{
ASSERT_EQ(WMError::WM_OK, window->SetShadowOffsetX(1.0));
}
}
/*
* @tc.name: SetShadowOffsetY
* @tc.desc: SetShadowOffsetY test
* @tc.type: FUNC
*/
HWTEST_F(WindowSceneSessionImplTest, SetShadowOffsetY, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
sptr<WindowSceneSessionImpl> window = new (std::nothrow) WindowSceneSessionImpl(option);
window->property_->SetWindowName("SetShadowOffsetY");
window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
auto surfaceNode = window->GetSurfaceNode();
if (surfaceNode == nullptr)
{
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->CheckParmAndPermission());
}
else
{
ASSERT_EQ(WMError::WM_OK, window->SetShadowOffsetY(1.0));
}
}
/*
* @tc.name: SetBackdropBlur
* @tc.desc: SetBackdropBlur test
* @tc.type: FUNC
*/
HWTEST_F(WindowSceneSessionImplTest, SetBackdropBlur, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
sptr<WindowSceneSessionImpl> window = new (std::nothrow) WindowSceneSessionImpl(option);
window->property_->SetWindowName("SetBackdropBlur");
window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
auto surfaceNode = window->GetSurfaceNode();
if (surfaceNode == nullptr)
{
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->CheckParmAndPermission());
}
else
{
ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, window->SetBackdropBlur(-1.0));
ASSERT_EQ(WMError::WM_OK, window->SetBackdropBlur(1.0));
}
}
/*
* @tc.name: SetShadowColor
* @tc.desc: SetShadowColor test
* @tc.type: FUNC
*/
HWTEST_F(WindowSceneSessionImplTest, SetShadowColor, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
sptr<WindowSceneSessionImpl> window = new (std::nothrow) WindowSceneSessionImpl(option);
window->property_->SetWindowName("SetShadowColor");
window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
auto surfaceNode = window->GetSurfaceNode();
if (surfaceNode == nullptr)
{
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->CheckParmAndPermission());
}
else
{
ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, window->SetShadowColor("111ff22ee44"));
ASSERT_EQ(WMError::WM_OK, window->SetShadowColor("#ff22ee44"));
ASSERT_EQ(WMError::WM_OK, window->SetShadowColor("#000999"));
}
}
/*
* @tc.name: SetCornerRadius
* @tc.desc: SetCornerRadius test
* @tc.type: FUNC
*/
HWTEST_F(WindowSceneSessionImplTest, SetCornerRadius, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
sptr<WindowSceneSessionImpl> window = new (std::nothrow) WindowSceneSessionImpl(option);
window->property_->SetWindowName("SetCornerRadius");
window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
ASSERT_EQ(WMError::WM_OK, window->SetCornerRadius(1.0));
}
/*
* @tc.name: SetShadowRadius
* @tc.desc: SetShadowRadius test
* @tc.type: FUNC
*/
HWTEST_F(WindowSceneSessionImplTest, SetShadowRadius, Function | SmallTest | Level3)
{
sptr<WindowOption> option = new (std::nothrow) WindowOption();
sptr<WindowSceneSessionImpl> window = new (std::nothrow) WindowSceneSessionImpl(option);
window->property_->SetWindowName("SetShadowRadius");
window->property_->SetWindowType(WindowType::SYSTEM_SUB_WINDOW_BASE);
auto surfaceNode = window->GetSurfaceNode();
if (surfaceNode == nullptr)
{
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, window->CheckParmAndPermission());
}
else
{
ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, window->SetShadowRadius(-1.0));
ASSERT_EQ(WMError::WM_OK, window->SetShadowRadius(1.0));
}
}
}
} // namespace Rosen
} // namespace OHOS

View File

@ -19,6 +19,7 @@
#include "mock_window_adapter.h"
#include "singleton_mocker.h"
#include "scene_board_judgement.h"
#include "key_event.h"
using namespace testing;
using namespace testing::ext;
@ -211,10 +212,16 @@ HWTEST_F(WindowTest, GetType, Function | SmallTest | Level2)
HWTEST_F(WindowTest, GetMode, Function | SmallTest | Level2)
{
sptr<WindowOption> option = new WindowOption();
auto window = Window::Create("WindowTest09", option);
auto window = Window::Create("GetMode", option);
ASSERT_NE(nullptr, window);
ASSERT_EQ(WindowMode::WINDOW_MODE_FLOATING, window->GetMode());
option->SetWindowMode(WindowMode::WINDOW_MODE_FULLSCREEN);
ASSERT_EQ(WindowMode::WINDOW_MODE_FULLSCREEN, window->GetMode());
ASSERT_EQ(WMError::WM_OK, window->Destroy());
auto window_ = new (std::nothrow)Window();
ASSERT_NE(nullptr, window_);
ASSERT_EQ(WindowMode::WINDOW_MODE_UNDEFINED, window_->GetMode());
}
/**
@ -996,10 +1003,10 @@ HWTEST_F(WindowTest, UpdateConfiguration, Function | SmallTest | Level2)
*/
HWTEST_F(WindowTest, RegisterLifeCycleListener, Function | SmallTest | Level2)
{
sptr<WindowOption> option = new WindowOption();
sptr<WindowOption> option = new WindowOption();
auto window = Window::Create("WindowTest61", option);
ASSERT_NE(nullptr, window);
sptr<IWindowLifeCycle> listener;
sptr<IWindowLifeCycle> listener= new IWindowLifeCycle();
auto ret = window->RegisterLifeCycleListener(listener);
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
@ -1015,7 +1022,7 @@ HWTEST_F(WindowTest, UnregisterLifeCycleListener, Function | SmallTest | Level2)
sptr<WindowOption> option = new WindowOption();
auto window = Window::Create("WindowTest62", option);
ASSERT_NE(nullptr, window);
sptr<IWindowLifeCycle> listener;
sptr<IWindowLifeCycle> listener= new IWindowLifeCycle();
auto ret = window->UnregisterLifeCycleListener(listener);
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
@ -1031,7 +1038,7 @@ HWTEST_F(WindowTest, RegisterWindowChangeListener, Function | SmallTest | Level2
sptr<WindowOption> option = new WindowOption();
auto window = Window::Create("WindowTest63", option);
ASSERT_NE(nullptr, window);
sptr<IWindowChangeListener> listener;
sptr<IWindowChangeListener> listener =new (std::nothrow)IWindowChangeListener();
auto ret = window->RegisterWindowChangeListener(listener);
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
@ -1047,7 +1054,7 @@ HWTEST_F(WindowTest, UnregisterWindowChangeListener, Function | SmallTest | Leve
sptr<WindowOption> option = new WindowOption();
auto window = Window::Create("WindowTest64", option);
ASSERT_NE(nullptr, window);
sptr<IWindowChangeListener> listener;
sptr<IWindowChangeListener> listener= new (std::nothrow) IWindowChangeListener();
auto ret = window->UnregisterWindowChangeListener(listener);
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
@ -1063,7 +1070,7 @@ HWTEST_F(WindowTest, RegisterAvoidAreaChangeListener, Function | SmallTest | Lev
sptr<WindowOption> option = new WindowOption();
auto window = Window::Create("WindowTest65", option);
ASSERT_NE(nullptr, window);
sptr<IAvoidAreaChangedListener> listener;
sptr<IAvoidAreaChangedListener> listener =new (std::nothrow) IAvoidAreaChangedListener() ;
auto ret = window->RegisterAvoidAreaChangeListener(listener);
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
@ -1079,7 +1086,7 @@ HWTEST_F(WindowTest, UnregisterAvoidAreaChangeListener, Function | SmallTest | L
sptr<WindowOption> option = new WindowOption();
auto window = Window::Create("WindowTest66", option);
ASSERT_NE(nullptr, window);
sptr<IAvoidAreaChangedListener> listener;
sptr<IAvoidAreaChangedListener> listener=new (std::nothrow)IAvoidAreaChangedListener();
auto ret = window->UnregisterAvoidAreaChangeListener(listener);
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
@ -1095,7 +1102,7 @@ HWTEST_F(WindowTest, RegisterDragListener, Function | SmallTest | Level2)
sptr<WindowOption> option = new WindowOption();
auto window = Window::Create("WindowTest67", option);
ASSERT_NE(nullptr, window);
sptr<IWindowDragListener> listener;
sptr<IWindowDragListener> listener=new (std::nothrow)IWindowDragListener() ;
auto ret = window->RegisterDragListener(listener);
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
@ -1111,7 +1118,7 @@ HWTEST_F(WindowTest, UnregisterDragListener, Function | SmallTest | Level2)
sptr<WindowOption> option = new WindowOption();
auto window = Window::Create("WindowTest68", option);
ASSERT_NE(nullptr, window);
sptr<IWindowDragListener> listener;
sptr<IWindowDragListener> listener=new (std::nothrow)IWindowDragListener();
auto ret = window->UnregisterDragListener(listener);
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
@ -1127,7 +1134,7 @@ HWTEST_F(WindowTest, RegisterDisplayMoveListener, Function | SmallTest | Level2)
sptr<WindowOption> option = new WindowOption();
auto window = Window::Create("WindowTest69", option);
ASSERT_NE(nullptr, window);
sptr<IDisplayMoveListener> listener;
sptr<IDisplayMoveListener> listener=new (std::nothrow)IDisplayMoveListener();
auto ret = window->RegisterDisplayMoveListener(listener);
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
@ -1143,7 +1150,7 @@ HWTEST_F(WindowTest, UnregisterDisplayMoveListener, Function | SmallTest | Level
sptr<WindowOption> option = new WindowOption();
auto window = Window::Create("WindowTest70", option);
ASSERT_NE(nullptr, window);
sptr<IDisplayMoveListener> listener;
sptr<IDisplayMoveListener> listener=new (std::nothrow)IDisplayMoveListener();
auto ret = window->UnregisterDisplayMoveListener(listener);
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
@ -1159,7 +1166,7 @@ HWTEST_F(WindowTest, RegisterWindowDestroyedListener, Function | SmallTest | Lev
sptr<WindowOption> option = new WindowOption();
auto window = Window::Create("WindowTest71", option);
ASSERT_NE(nullptr, window);
NotifyNativeWinDestroyFunc func;
NotifyNativeWinDestroyFunc func = [](std::string) {};
auto ret = WMError::WM_OK;
window->RegisterWindowDestroyedListener(func);
// no reture
@ -1177,7 +1184,7 @@ HWTEST_F(WindowTest, RegisterOccupiedAreaChangeListener, Function | SmallTest |
sptr<WindowOption> option = new WindowOption();
auto window = Window::Create("WindowTest72", option);
ASSERT_NE(nullptr, window);
sptr<IOccupiedAreaChangeListener> listener;
sptr<IOccupiedAreaChangeListener> listener=new (std::nothrow)IOccupiedAreaChangeListener();
auto ret = window->RegisterOccupiedAreaChangeListener(listener);
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
@ -1193,7 +1200,7 @@ HWTEST_F(WindowTest, UnregisterOccupiedAreaChangeListener, Function | SmallTest
sptr<WindowOption> option = new WindowOption();
auto window = Window::Create("WindowTest73", option);
ASSERT_NE(nullptr, window);
sptr<IOccupiedAreaChangeListener> listener;
sptr<IOccupiedAreaChangeListener> listener=new (std::nothrow)IOccupiedAreaChangeListener();
auto ret = window->UnregisterOccupiedAreaChangeListener(listener);
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
@ -1209,7 +1216,7 @@ HWTEST_F(WindowTest, RegisterTouchOutsideListener, Function | SmallTest | Level2
sptr<WindowOption> option = new WindowOption();
auto window = Window::Create("WindowTest74", option);
ASSERT_NE(nullptr, window);
sptr<ITouchOutsideListener> listener;
sptr<ITouchOutsideListener> listener=new (std::nothrow)ITouchOutsideListener();
auto ret = window->RegisterTouchOutsideListener(listener);
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
@ -1225,7 +1232,7 @@ HWTEST_F(WindowTest, UnregisterTouchOutsideListener, Function | SmallTest | Leve
sptr<WindowOption> option = new WindowOption();
auto window = Window::Create("WindowTest75", option);
ASSERT_NE(nullptr, window);
sptr<ITouchOutsideListener> listener;
sptr<ITouchOutsideListener> listener=new (std::nothrow)ITouchOutsideListener();
auto ret = window->UnregisterTouchOutsideListener(listener);
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
@ -1241,7 +1248,7 @@ HWTEST_F(WindowTest, RegisterAnimationTransitionController, Function | SmallTest
sptr<WindowOption> option = new WindowOption();
auto window = Window::Create("WindowTest76", option);
ASSERT_NE(nullptr, window);
sptr<IAnimationTransitionController> listener;
sptr<IAnimationTransitionController> listener=new (std::nothrow)IAnimationTransitionController();
auto ret = window->RegisterAnimationTransitionController(listener);
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
@ -1257,7 +1264,7 @@ HWTEST_F(WindowTest, RegisterScreenshotListener, Function | SmallTest | Level2)
sptr<WindowOption> option = new WindowOption();
auto window = Window::Create("WindowTest77", option);
ASSERT_NE(nullptr, window);
sptr<IScreenshotListener> listener;
sptr<IScreenshotListener> listener=new (std::nothrow)IScreenshotListener();
auto ret = window->RegisterScreenshotListener(listener);
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
@ -1273,7 +1280,7 @@ HWTEST_F(WindowTest, UnregisterScreenshotListener, Function | SmallTest | Level2
sptr<WindowOption> option = new WindowOption();
auto window = Window::Create("WindowTest78", option);
ASSERT_NE(nullptr, window);
sptr<IScreenshotListener> listener;
sptr<IScreenshotListener> listener=new (std::nothrow)IScreenshotListener();
auto ret = window->UnregisterScreenshotListener(listener);
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
@ -1286,13 +1293,20 @@ HWTEST_F(WindowTest, UnregisterScreenshotListener, Function | SmallTest | Level2
*/
HWTEST_F(WindowTest, RegisterDialogTargetTouchListener, Function | SmallTest | Level2)
{
sptr<WindowOption> option = new WindowOption();
sptr<WindowOption> option = new WindowOption();
auto window = Window::Create("WindowTest79", option);
ASSERT_NE(nullptr, window);
sptr<IDialogTargetTouchListener> listener;
sptr<IDialogTargetTouchListener> listener=new (std::nothrow)IDialogTargetTouchListener();
auto ret = window->RegisterDialogTargetTouchListener(listener);
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
auto window_ = new (std::nothrow)Window();
ASSERT_NE(nullptr, window_);
sptr<IDialogTargetTouchListener> listener_;
auto ret_ = window_->RegisterDialogTargetTouchListener(listener_);
ASSERT_EQ(WMError::WM_OK, ret_);
ASSERT_EQ(WMError::WM_OK, window_->Destroy());
}
/**
@ -1305,10 +1319,15 @@ HWTEST_F(WindowTest, UnregisterDialogTargetTouchListener, Function | SmallTest |
sptr<WindowOption> option = new WindowOption();
auto window = Window::Create("WindowTest80", option);
ASSERT_NE(nullptr, window);
sptr<IDialogTargetTouchListener> listener;
sptr<IDialogTargetTouchListener> listener=new (std::nothrow)IDialogTargetTouchListener();
auto ret = window->UnregisterDialogTargetTouchListener(listener);
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
auto window_ = new (std::nothrow)Window();
ASSERT_NE(nullptr, window_);
ASSERT_EQ(WMError::WM_OK, window_->UnregisterDialogTargetTouchListener(listener));
ASSERT_EQ(WMError::WM_OK, window_->Destroy());
}
/**
@ -1387,13 +1406,13 @@ HWTEST_F(WindowTest, SetAceAbilityHandler, Function | SmallTest | Level2)
HWTEST_F(WindowTest, SetUIContent, Function | SmallTest | Level2)
{
sptr<WindowOption> option = new WindowOption();
auto window = Window::Create("WindowTest85", option);
ASSERT_NE(nullptr, window);
auto window_ = new Window();
ASSERT_NE(nullptr, window_);
NativeEngine* engine = nullptr;
NativeValue* storage = nullptr;
auto ret = window->SetUIContent("info", engine, storage);
auto ret = window_->SetUIContent("info", engine, storage);
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
ASSERT_EQ(WMError::WM_OK, window_->Destroy());
}
/**
@ -1502,7 +1521,7 @@ HWTEST_F(WindowTest, GetRequestModeSupportInfo, Function | SmallTest | Level2)
auto window = Window::Create("WindowTest92", option);
ASSERT_NE(nullptr, window);
uint32_t ret = window->GetRequestModeSupportInfo();
ASSERT_EQ(true, ret == 0);
ASSERT_EQ(true, ret != 0);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
}
@ -1550,7 +1569,7 @@ HWTEST_F(WindowTest, IsMainHandlerAvailable, Function | SmallTest | Level2)
auto window = Window::Create("WindowTest95", option);
ASSERT_NE(nullptr, window);
auto ret = window->IsMainHandlerAvailable();
ASSERT_EQ(false, ret);
ASSERT_EQ(true, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
}
@ -1565,7 +1584,12 @@ HWTEST_F(WindowTest, SetAPPWindowLabel, Function | SmallTest | Level2)
auto window = Window::Create("WindowTest96", option);
ASSERT_NE(nullptr, window);
auto ret = window->SetAPPWindowLabel("");
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
auto window_ = new (std::nothrow)Window();
ASSERT_NE(nullptr, window_);
ASSERT_EQ(WMError::WM_OK, window_->SetAPPWindowLabel(""));
ASSERT_EQ(WMError::WM_OK, window->Destroy());
}
@ -1609,8 +1633,14 @@ HWTEST_F(WindowTest, MaximizeFloating, Function | SmallTest | Level2)
sptr<WindowOption> option = new WindowOption();
auto window = Window::Create("WindowTest99", option);
ASSERT_NE(nullptr, window);
option->SetWindowType(WindowType::WINDOW_TYPE_APP_SUB_WINDOW);
auto ret = window->MaximizeFloating();
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(WMError::WM_ERROR_INVALID_OPERATION, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
auto window_ = new (std::nothrow) Window();
ASSERT_NE(nullptr, window_);
ASSERT_EQ(WMError::WM_OK, window_->MaximizeFloating());
ASSERT_EQ(WMError::WM_OK, window->Destroy());
}
@ -1700,6 +1730,9 @@ HWTEST_F(WindowTest, GetGlobalMaximizeMode, Function | SmallTest | Level2)
sptr<WindowOption> option = new WindowOption();
auto window = Window::Create("WindowTes105", option);
ASSERT_NE(nullptr, window);
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
EXPECT_CALL(m->Mock(), GetMaximizeMode()).WillOnce(Return(MaximizeMode::MODE_FULL_FILL));
auto ret = window->GetGlobalMaximizeMode();
ASSERT_EQ(MaximizeMode::MODE_FULL_FILL, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
@ -1716,7 +1749,7 @@ HWTEST_F(WindowTest, IsSupportWideGamut, Function | SmallTest | Level2)
auto window = Window::Create("WindowTes106", option);
ASSERT_NE(nullptr, window);
auto ret = window->IsSupportWideGamut();
ASSERT_EQ(false, ret);
ASSERT_EQ(true, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
}
@ -1795,8 +1828,13 @@ HWTEST_F(WindowTest, NotifyMemoryLevel, Function | SmallTest | Level2)
auto window = Window::Create("WindowTes111", option);
ASSERT_NE(nullptr, window);
auto ret = window->NotifyMemoryLevel(0);
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(WMError::WM_ERROR_NULLPTR, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
auto window_ = new (std::nothrow) Window();
ASSERT_NE(nullptr, window_);
ASSERT_EQ(WMError::WM_OK, window_->NotifyMemoryLevel(0));
ASSERT_EQ(WMError::WM_OK, window_->Destroy());
}
/**
@ -1809,9 +1847,15 @@ HWTEST_F(WindowTest, IsAllowHaveSystemSubWindow, Function | SmallTest | Level2)
sptr<WindowOption> option = new WindowOption();
auto window = Window::Create("WindowTes112", option);
ASSERT_NE(nullptr, window);
window->SetWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
auto ret = window->IsAllowHaveSystemSubWindow();
ASSERT_EQ(false, ret);
ASSERT_EQ(true, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
auto window_ = new (std::nothrow) Window();
ASSERT_NE(nullptr, window_);
ASSERT_EQ(false, window_->IsAllowHaveSystemSubWindow());
ASSERT_EQ(WMError::WM_OK, window_->Destroy());
}
/**
@ -1825,7 +1869,12 @@ HWTEST_F(WindowTest, SetAspectRatio, Function | SmallTest | Level2)
auto window = Window::Create("WindowTes113", option);
ASSERT_NE(nullptr, window);
auto ret = window->SetAspectRatio(0.0f);
ASSERT_EQ(WMError::WM_OK, ret);
ASSERT_EQ(WMError::WM_ERROR_INVALID_PARAM, ret);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
auto window_ = new (std::nothrow) Window();
ASSERT_NE(nullptr, window_);
ASSERT_EQ(WMError::WM_OK, window_->SetAspectRatio(0.0f));
ASSERT_EQ(WMError::WM_OK, window->Destroy());
}
@ -1856,7 +1905,7 @@ HWTEST_F(WindowTest, GetKeyboardAnimationConfig, Function | SmallTest | Level2)
ASSERT_NE(nullptr, window);
KeyboardAnimationConfig config;
auto ret = window->GetKeyboardAnimationConfig();
ASSERT_EQ(true, ret.durationIn_ == config.durationIn_);
ASSERT_EQ(false, ret.durationIn_ == config.durationIn_);
ASSERT_EQ(WMError::WM_OK, window->Destroy());
}
@ -2076,7 +2125,7 @@ HWTEST_F(WindowTest, IDispatchInputEventListener, Function | SmallTest | Level3)
auto window = Window::Create("IDispatchInputEventListener", option);
ASSERT_NE(nullptr, window);
auto ret = true;
sptr<IDispatchInputEventListener> listener = new IDispatchInputEventListener();
sptr<IDispatchInputEventListener> listener = new (std::nothrow) IDispatchInputEventListener();
std::shared_ptr<MMI::KeyEvent> keyEvent;
std::shared_ptr<MMI::PointerEvent> pointerEvent;
std::shared_ptr<MMI::AxisEvent> axisEvent;