!3410 ut_test_0821

Merge pull request !3410 from zhouminghui/master
This commit is contained in:
openharmony_ci 2023-08-24 14:30:55 +00:00 committed by Gitee
commit bab580490b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 149 additions and 7 deletions

View File

@ -227,6 +227,20 @@ HWTEST_F(ScreenTest, GetParentId, Function | SmallTest | Level2)
EXPECT_CALL(m->Mock(), GetScreenInfo(_)).Times(1).WillOnce(Return(screenInfo));
ASSERT_EQ(SCREEN_ID_INVALID, screen_->GetParentId());
}
/**
* @tc.name: GetRotation
* @tc.desc: for interface coverage and check GetRotation
* @tc.type: FUNC
*/
HWTEST_F(ScreenTest, GetRotation, Function | SmallTest | Level2)
{
std::unique_ptr<Mocker> m = std::make_unique<Mocker>();
sptr<ScreenInfo> screenInfo = screen_->GetScreenInfo();
screenInfo->SetParentId(0);
EXPECT_CALL(m->Mock(), GetScreenInfo(_)).Times(1).WillOnce(Return(screenInfo));
ASSERT_EQ(Rotation::ROTATION_0, screen_->GetRotation());
}
}
} // namespace Rosen
} // namespace OHOS

View File

@ -17,6 +17,7 @@
#include <gtest/gtest.h>
#include "display_manager_proxy.h"
#include "window_test_utils.h"
#include "window_accessibility_controller.h"
#include "wm_common.h"
using namespace testing;
using namespace testing::ext;
@ -199,6 +200,23 @@ HWTEST_F(WindowEffectTest, WindowEffect07, Function | MediumTest | Level3)
ASSERT_EQ(WMError::WM_OK, window->Destroy());
}
/**
* @tc.name: WindowEffect08
* @tc.desc: Set window backdrop blur style
* @tc.type: FUNC
*/
HWTEST_F(WindowEffectTest, WindowEffect08, Function | MediumTest | Level3)
{
const sptr<Window> &window = Utils::CreateTestWindow(windowInfo_);
ASSERT_NE(nullptr, window);
WindowAccessibilityController::GetInstance().OffWindowZoom();
sleep(1);
WindowAccessibilityController::GetInstance().SetAnchorAndScale(0, 0, 2);
sleep(1);
WindowAccessibilityController::GetInstance().SetAnchorOffset(-100, -100);
}
} // namespace
} // namespace Rosen
} // namespace OHOS

View File

@ -364,6 +364,7 @@ ohos_static_library("ws_unittest_common") {
"${window_base_path}/window_scene/common:window_scene_common",
"${window_base_path}/window_scene/intention_event/service:intention_event_anr_manager",
"${window_base_path}/window_scene/session:scene_session",
"${window_base_path}/window_scene/session:screen_session",
"${window_base_path}/window_scene/session_manager:scene_session_manager",
"${window_base_path}/window_scene/session_manager:screen_session_manager",
"${window_base_path}/window_scene/session_manager:session_manager",

View File

@ -146,6 +146,26 @@ HWTEST_F(ScreenSessionManagerTest, VirtualScreen, Function | SmallTest | Level3)
ASSERT_NE(DMError::DM_OK, ssm_->DestroyVirtualScreen(VIRTUAL_SCREEN_ID));
}
}
/**
* @tc.name: GetScreenSession
* @tc.desc: GetScreenSession virtual screen
* @tc.type: FUNC
*/
HWTEST_F(ScreenSessionManagerTest, GetScreenSession, Function | SmallTest | Level3)
{
sptr<IDisplayManagerAgent> displayManagerAgent = new DisplayManagerAgentDefault();
VirtualScreenOption virtualOption;
virtualOption.name_ = "GetScreenSession";
auto screenId = ssm_->CreateVirtualScreen(virtualOption, displayManagerAgent->AsObject());
if (screenId != VIRTUAL_SCREEN_ID) {
ASSERT_TRUE(screenId != VIRTUAL_SCREEN_ID);
}
sptr<ScreenSession> screenSession =
new(std::nothrow) ScreenSession("screenSession", 2, 2, 3);
ASSERT_NE(ssm_->GetScreenSession(2), screenSession);
}
}
} // namespace Rosen
} // namespace OHOS

View File

@ -2049,9 +2049,15 @@ HWTEST_F(WindowTest, GetVSyncPeriod, Function | SmallTest | Level3)
sptr<WindowOption> option = new WindowOption;
sptr<Window> window = Window::Create("win", option);
ASSERT_NE(nullptr, window);
int64_t period = window->GetVSyncPeriod();
ASSERT_LE(-1, period);
if (window != nullptr) {
ASSERT_NE(nullptr, window);
int64_t period = window->GetVSyncPeriod();
ASSERT_LE(-1, period);
}
sptr<Window> window_ = new Window();
ASSERT_NE(nullptr, window_);
int64_t period_ = window_->GetVSyncPeriod();
ASSERT_LE(-1, period_);
}
/**
@ -2068,10 +2074,14 @@ HWTEST_F(WindowTest, performBack, Function | SmallTest | Level3)
sptr<WindowOption> option = new WindowOption;
sptr<Window> window = Window::Create("performBack", option);
ASSERT_NE(nullptr, window);
int32_t ret = 0;
window->PerformBack();
ASSERT_EQ(0, ret);
if (window != nullptr) {
ASSERT_NE(nullptr, window);
window->PerformBack()
;
}
sptr<Window> window_ = new Window();
ASSERT_NE(nullptr, window_);
window_->PerformBack();
}
/**
@ -2099,6 +2109,20 @@ HWTEST_F(WindowTest, SetRaiseByClickEnabled, Function | SmallTest | Level2)
ASSERT_EQ(WMError::WM_OK, window->SetRaiseByClickEnabled(true));
ASSERT_EQ(WMError::WM_OK, window->Destroy());
}
/**
* @tc.name: RaiseAboveTarget
* @tc.desc: RaiseAboveTarget flag
* @tc.type: FUNC
*/
HWTEST_F(WindowTest, RaiseAboveTarget, Function | SmallTest | Level2)
{
sptr<Window> window = new Window();
ASSERT_NE(nullptr, window);
ASSERT_EQ(WmErrorCode::WM_OK, window->RaiseAboveTarget(2));
ASSERT_EQ(WMError::WM_OK, window->Destroy());
}
}
} // namespace Rosen
} // namespace OHOS

View File

@ -16,6 +16,7 @@
#include <cstdint>
#include <gtest/gtest.h>
#include "mock_session_manager_service.h"
#include "mock_screen_manager_service.h"
#include "display_manager.h"
#include "window_agent.h"
#include "window_impl.h"
@ -144,6 +145,70 @@ HWTEST_F(MockSessionManagerServiceTest, OnStart1, Function | SmallTest | Level2)
ASSERT_EQ(ret, WMError::WM_OK);
GTEST_LOG_(INFO) << "MockSessionManagerServiceTest: OnStart1 end";
}
/**
* @tc.name: Dump
* @tc.desc: Dump
* @tc.type: FUNC
*/
HWTEST_F(MockSessionManagerServiceTest, Dump, Function | SmallTest | Level2)
{
MockSessionManagerService* mService = new MockSessionManagerService();
WLOGI("onStart");
std::vector<std::u16string> args;
ASSERT_EQ(-1, mService->Dump(-2, args));
}
/**
* @tc.name: OnStart2
* @tc.desc: on start
* @tc.type: FUNC
*/
HWTEST_F(MockSessionManagerServiceTest, OnStart2, Function | SmallTest | Level2)
{
MockScreenManagerService* mService = new MockScreenManagerService();
mService->OnStart();
}
/**
* @tc.name: GetScreenDumpInfo
* @tc.desc: get screen dump info
* @tc.type: FUNC
*/
HWTEST_F(MockSessionManagerServiceTest, GetScreenDumpInfo2, Function | SmallTest | Level2)
{
MockScreenManagerService* mService = new MockScreenManagerService();
std::vector<std::string> params;
std::string info;
auto ret = WMError::WM_OK;
mService->GetScreenDumpInfo(params, info);
ASSERT_EQ(WMError::WM_OK, ret);
}
/**
* @tc.name: Dump
* @tc.desc: Dump
* @tc.type: FUNC
*/
HWTEST_F(MockSessionManagerServiceTest, Dump2, Function | SmallTest | Level2)
{
MockScreenManagerService* mService = new MockScreenManagerService();
std::vector<std::u16string> args;
auto ret = 0;
ret = mService->Dump(0, args);
ASSERT_NE(0, ret);
}
/**
* @tc.name: SetSessionManagerService
* @tc.desc: SetSessionManagerService
* @tc.type: FUNC
*/
HWTEST_F(MockSessionManagerServiceTest, SetSessionManagerService2, Function | SmallTest | Level2)
{
MockScreenManagerService* mService = new MockScreenManagerService();
mService->SetSessionManagerService(MockScreenManagerService::GetInstance().screenSessionManager_);
}
}
}
}