diff --git a/services/screenclient/test/unittest/include/screen_client_test.h b/services/screenclient/test/unittest/include/screen_client_test.h index 465c22dbdc6f40c108a5dcb5a675eb2c33197219..1f21e1855d5c4671095b93a3ec70feff60e2e7d9 100644 --- a/services/screenclient/test/unittest/include/screen_client_test.h +++ b/services/screenclient/test/unittest/include/screen_client_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -31,6 +31,8 @@ public: static void TearDownTestCase(void); void SetUp(); void TearDown(); + + std::shared_ptr windowProperty_; }; } // namespace DistributedHardware } // namespace OHOS diff --git a/services/screenclient/test/unittest/include/screen_client_window_adapter_test.h b/services/screenclient/test/unittest/include/screen_client_window_adapter_test.h index db0bcc01e8fbfe70e05b83dd1d8eca0e9374551d..a4cfd2cf7dcd0292e5c18e6a51fe4fb05177be2d 100644 --- a/services/screenclient/test/unittest/include/screen_client_window_adapter_test.h +++ b/services/screenclient/test/unittest/include/screen_client_window_adapter_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -36,6 +36,8 @@ public: static void TearDownTestCase(void); void SetUp(); void TearDown(); + + std::shared_ptr windowProperty_; }; } // namespace DistributedHardware } // namespace OHOS diff --git a/services/screenclient/test/unittest/src/screen_client_test.cpp b/services/screenclient/test/unittest/src/screen_client_test.cpp index a6903ff60bbbf61c69967f3ad81f26151ee91726..0585e0a011fc95096e96e4723c937389fadea0b0 100644 --- a/services/screenclient/test/unittest/src/screen_client_test.cpp +++ b/services/screenclient/test/unittest/src/screen_client_test.cpp @@ -19,13 +19,23 @@ using namespace testing::ext; namespace OHOS { namespace DistributedHardware { +constexpr static uint32_t VIDEO_DATA_NUM = 480; + void ScreenClientTest::SetUpTestCase(void) {} void ScreenClientTest::TearDownTestCase(void) {} -void ScreenClientTest::SetUp() {} +void ScreenClientTest::SetUp() +{ + windowProperty_ = std::make_shared(); + windowProperty_->width = VIDEO_DATA_NUM; + windowProperty_->height = VIDEO_DATA_NUM; +} -void ScreenClientTest::TearDown() {} +void ScreenClientTest::TearDown() +{ + windowProperty_ = nullptr; +} /** * @tc.name: AddWindow_001 @@ -35,8 +45,8 @@ void ScreenClientTest::TearDown() {} */ HWTEST_F(ScreenClientTest, AddWindow_001, TestSize.Level1) { - std::shared_ptr windowProperty = nullptr; - int32_t ret = ScreenClient::GetInstance().AddWindow(windowProperty); + windowProperty_ = nullptr; + int32_t ret = ScreenClient::GetInstance().AddWindow(windowProperty_); EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_ADD_WINDOW_ERROR, ret); } @@ -48,8 +58,7 @@ HWTEST_F(ScreenClientTest, AddWindow_001, TestSize.Level1) */ HWTEST_F(ScreenClientTest, AddWindow_002, TestSize.Level1) { - std::shared_ptr windowProperty = std::make_shared(); - int32_t expectId = ScreenClient::GetInstance().AddWindow(windowProperty); + int32_t expectId = ScreenClient::GetInstance().AddWindow(windowProperty_); int32_t ret = ScreenClient::GetInstance().RemoveWindow(expectId); EXPECT_EQ(DH_SUCCESS, ret); } @@ -74,8 +83,7 @@ HWTEST_F(ScreenClientTest, ShowWindow_001, TestSize.Level1) */ HWTEST_F(ScreenClientTest, ShowWindow_002, TestSize.Level1) { - std::shared_ptr windowProperty = std::make_shared(); - int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty); + int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty_); int32_t ret = ScreenClient::GetInstance().ShowWindow(windowId); EXPECT_EQ(DH_SUCCESS, ret); ret = ScreenClient::GetInstance().RemoveWindow(windowId); @@ -118,8 +126,7 @@ HWTEST_F(ScreenClientTest, HideWindow_001, TestSize.Level1) */ HWTEST_F(ScreenClientTest, HideWindow_002, TestSize.Level1) { - std::shared_ptr windowProperty = std::make_shared(); - int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty); + int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty_); int32_t ret = ScreenClient::GetInstance().HideWindow(windowId); EXPECT_EQ(DH_SUCCESS, ret); ret = ScreenClient::GetInstance().RemoveWindow(windowId); @@ -162,8 +169,7 @@ HWTEST_F(ScreenClientTest, MoveWindow_001, TestSize.Level1) */ HWTEST_F(ScreenClientTest, MoveWindow_002, TestSize.Level1) { - std::shared_ptr windowProperty = std::make_shared(); - int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty); + int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty_); int32_t ret = ScreenClient::GetInstance().MoveWindow(windowId, 0, 0); EXPECT_EQ(DH_SUCCESS, ret); ret = ScreenClient::GetInstance().RemoveWindow(windowId); @@ -206,8 +212,7 @@ HWTEST_F(ScreenClientTest, RemoveWindow_001, TestSize.Level1) */ HWTEST_F(ScreenClientTest, RemoveWindow_002, TestSize.Level1) { - std::shared_ptr windowProperty = std::make_shared(); - int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty); + int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty_); int32_t ret = ScreenClient::GetInstance().RemoveWindow(windowId); EXPECT_EQ(DH_SUCCESS, ret); } @@ -245,8 +250,7 @@ HWTEST_F(ScreenClientTest, GetSurface_001, TestSize.Level1) */ HWTEST_F(ScreenClientTest, GetSurface_002, TestSize.Level1) { - std::shared_ptr windowProperty = std::make_shared(); - int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty); + int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty_); sptr actualSurface = ScreenClient::GetInstance().GetSurface(windowId); EXPECT_NE(nullptr, actualSurface); int32_t ret = ScreenClient::GetInstance().RemoveWindow(windowId); @@ -261,8 +265,7 @@ HWTEST_F(ScreenClientTest, GetSurface_002, TestSize.Level1) */ HWTEST_F(ScreenClientTest, DestroyAllWindow_001, TestSize.Level1) { - std::shared_ptr windowProperty = std::make_shared(); - ScreenClient::GetInstance().AddWindow(windowProperty); + ScreenClient::GetInstance().AddWindow(windowProperty_); int32_t ret = ScreenClient::GetInstance().DestroyAllWindow(); EXPECT_EQ(DH_SUCCESS, ret); } diff --git a/services/screenclient/test/unittest/src/screen_client_window_adapter_test.cpp b/services/screenclient/test/unittest/src/screen_client_window_adapter_test.cpp index e13587782a9585e16d4f7dc9597c1af9b7939cbd..d777533f850bc693c18eff0cb412542db7cce615 100644 --- a/services/screenclient/test/unittest/src/screen_client_window_adapter_test.cpp +++ b/services/screenclient/test/unittest/src/screen_client_window_adapter_test.cpp @@ -19,13 +19,23 @@ using namespace testing::ext; namespace OHOS { namespace DistributedHardware { +constexpr static uint32_t VIDEO_DATA_NUM = 480; + void ScreenClientWindowAdapterTest::SetUpTestCase(void) {} void ScreenClientWindowAdapterTest::TearDownTestCase(void) {} -void ScreenClientWindowAdapterTest::SetUp() {} +void ScreenClientWindowAdapterTest::SetUp() +{ + windowProperty_ = std::make_shared(); + windowProperty_->width = VIDEO_DATA_NUM; + windowProperty_->height = VIDEO_DATA_NUM; +} -void ScreenClientWindowAdapterTest::TearDown() {} +void ScreenClientWindowAdapterTest::TearDown() +{ + windowProperty_ = nullptr; +} /** * @tc.name: CreateWindow_001 @@ -35,8 +45,8 @@ void ScreenClientWindowAdapterTest::TearDown() {} */ HWTEST_F(ScreenClientWindowAdapterTest, CreateWindow_001, TestSize.Level1) { - std::shared_ptr windowProperty = nullptr; - EXPECT_EQ(nullptr, ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty, 0)); + windowProperty_ = nullptr; + EXPECT_EQ(nullptr, ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty_, 0)); } /** @@ -47,9 +57,8 @@ HWTEST_F(ScreenClientWindowAdapterTest, CreateWindow_001, TestSize.Level1) */ HWTEST_F(ScreenClientWindowAdapterTest, CreateWindow_002, TestSize.Level1) { - std::shared_ptr windowProperty = std::make_shared(); int32_t windowId = 0; - sptr actualSurface = ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty, windowId); + sptr actualSurface = ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty_, windowId); EXPECT_NE(nullptr, actualSurface); int32_t ret = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); EXPECT_EQ(DH_SUCCESS, ret); @@ -75,9 +84,8 @@ HWTEST_F(ScreenClientWindowAdapterTest, ShowWindow_001, TestSize.Level1) */ HWTEST_F(ScreenClientWindowAdapterTest, ShowWindow_002, TestSize.Level1) { - std::shared_ptr windowProperty = std::make_shared(); int32_t windowId = 100; - ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty, windowId); + ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty_, windowId); int32_t ret = ScreenClientWindowAdapter::GetInstance().ShowWindow(windowId); EXPECT_EQ(DH_SUCCESS, ret); ret = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); @@ -119,9 +127,8 @@ HWTEST_F(ScreenClientWindowAdapterTest, HideWindow_001, TestSize.Level1) */ HWTEST_F(ScreenClientWindowAdapterTest, HideWindow_002, TestSize.Level1) { - std::shared_ptr windowProperty = std::make_shared(); int32_t windowId = 0; - ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty, windowId); + ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty_, windowId); int32_t ret = ScreenClientWindowAdapter::GetInstance().HideWindow(windowId); EXPECT_EQ(DH_SUCCESS, ret); ret = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); @@ -164,9 +171,8 @@ HWTEST_F(ScreenClientWindowAdapterTest, MoveWindow_001, TestSize.Level1) */ HWTEST_F(ScreenClientWindowAdapterTest, MoveWindow_002, TestSize.Level1) { - std::shared_ptr windowProperty = std::make_shared(); int32_t windowId = 0; - ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty, windowId); + ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty_, windowId); int32_t ret = ScreenClientWindowAdapter::GetInstance().MoveWindow(windowId, 0, 0); EXPECT_EQ(DH_SUCCESS, ret); ret = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); @@ -209,9 +215,8 @@ HWTEST_F(ScreenClientWindowAdapterTest, RemoveWindow_001, TestSize.Level1) */ HWTEST_F(ScreenClientWindowAdapterTest, RemoveWindow_002, TestSize.Level1) { - std::shared_ptr windowProperty = std::make_shared(); int32_t windowId = 0; - ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty, windowId); + ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty_, windowId); int32_t ret = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); EXPECT_EQ(DH_SUCCESS, ret); } diff --git a/services/screenservice/test/unittest/sinkservice/screenregionmgr/1.0/src/screenregion_test.cpp b/services/screenservice/test/unittest/sinkservice/screenregionmgr/1.0/src/screenregion_test.cpp index 1d22cc310a8d329ade64e955d99bc6223523964a..790088874e0683299fef60f1919d15a39fe22ffb 100644 --- a/services/screenservice/test/unittest/sinkservice/screenregionmgr/1.0/src/screenregion_test.cpp +++ b/services/screenservice/test/unittest/sinkservice/screenregionmgr/1.0/src/screenregion_test.cpp @@ -22,6 +22,8 @@ using namespace testing::ext; namespace OHOS { namespace DistributedHardware { namespace V1_0 { +constexpr static uint32_t VIDEO_DATA_NUM = 480; + void ScreenRegionTestV1::SetUpTestCase(void) {} void ScreenRegionTestV1::TearDownTestCase(void) {} @@ -137,6 +139,8 @@ HWTEST_F(ScreenRegionTestV1, GetVideoParam_001, TestSize.Level1) HWTEST_F(ScreenRegionTestV1, GetWindowProperty_001, TestSize.Level1) { screenRegion_->windowProperty_ = std::make_shared(); + screenRegion_->windowProperty_->width = VIDEO_DATA_NUM; + screenRegion_->windowProperty_->height = VIDEO_DATA_NUM; std::shared_ptr ret = screenRegion_->GetWindowProperty(); EXPECT_EQ(screenRegion_->windowProperty_, ret); } diff --git a/services/screenservice/test/unittest/sinkservice/screenregionmgr/1.0/src/screenregionmgr_test.cpp b/services/screenservice/test/unittest/sinkservice/screenregionmgr/1.0/src/screenregionmgr_test.cpp index 2a2ff601bf1f840241c383a933bfdb685d908976..a42c723f8e67bbb9cfb7e0a20cc6d6cea51ee406 100644 --- a/services/screenservice/test/unittest/sinkservice/screenregionmgr/1.0/src/screenregionmgr_test.cpp +++ b/services/screenservice/test/unittest/sinkservice/screenregionmgr/1.0/src/screenregionmgr_test.cpp @@ -21,6 +21,8 @@ using namespace testing::ext; namespace OHOS { namespace DistributedHardware { namespace V1_0 { +constexpr static uint32_t VIDEO_DATA_NUM = 480; + void ScreenRegionManagerTestV1::SetUpTestCase(void) {} void ScreenRegionManagerTestV1::TearDownTestCase(void) {} @@ -99,8 +101,8 @@ HWTEST_F(ScreenRegionManagerTestV1, ReleaseAllRegions_003, TestSize.Level1) std::shared_ptr windowProperty = std::make_shared(); windowProperty->startX = 0; windowProperty->startY = 0; - windowProperty->width = 100; - windowProperty->height = 100; + windowProperty->width = VIDEO_DATA_NUM; + windowProperty->height = VIDEO_DATA_NUM; ScreenRegionManager::GetInstance().PublishMessage(topic, screenId, remoteDevId, windowId, windowProperty); int32_t ret = ScreenRegionManager::GetInstance().ReleaseAllRegions(); diff --git a/services/screenservice/test/unittest/sinkservice/screenregionmgr/2.0/src/screenregion_test.cpp b/services/screenservice/test/unittest/sinkservice/screenregionmgr/2.0/src/screenregion_test.cpp index e17ecea06fe5b7853a2d61804e834d38ff6a3ce7..97701531255491121a7bb0b2599dfa9e63a37da9 100644 --- a/services/screenservice/test/unittest/sinkservice/screenregionmgr/2.0/src/screenregion_test.cpp +++ b/services/screenservice/test/unittest/sinkservice/screenregionmgr/2.0/src/screenregion_test.cpp @@ -25,6 +25,8 @@ using namespace testing::ext; namespace OHOS { namespace DistributedHardware { namespace V2_0 { +constexpr static uint32_t VIDEO_DATA_NUM = 480; + void ScreenRegionTestV2::SetUpTestCase(void) {} void ScreenRegionTestV2::TearDownTestCase(void) {} @@ -329,7 +331,13 @@ HWTEST_F(ScreenRegionTestV2, SetUp_001, TestSize.Level1) content = contentJson.dump(); EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, screenRegion_->SetUp(content)); + ScreenRect screenRect; + screenRect.startX = 0; + screenRect.startY = 0; + screenRect.width = VIDEO_DATA_NUM; + screenRect.height = VIDEO_DATA_NUM; DScreenMapRelation dScreenMapRelation; + dScreenMapRelation.SetScreenRect(screenRect); contentJson[KEY_MAPRELATION] = dScreenMapRelation; content = contentJson.dump(); screenRegion_->receiverAdapter_ = nullptr; @@ -337,6 +345,7 @@ HWTEST_F(ScreenRegionTestV2, SetUp_001, TestSize.Level1) screenRegion_->receiverAdapter_ = std::make_shared(); EXPECT_EQ(DH_SUCCESS, screenRegion_->SetUp(content)); + screenRegion_->Release(); } /** @@ -359,10 +368,16 @@ HWTEST_F(ScreenRegionTestV2, ConfigWindow_001, TestSize.Level1) */ HWTEST_F(ScreenRegionTestV2, ConfigWindow_002, TestSize.Level1) { + ScreenRect screenRect; + screenRect.startX = 0; + screenRect.startY = 0; + screenRect.width = VIDEO_DATA_NUM; + screenRect.height = VIDEO_DATA_NUM; + DScreenMapRelation dScreenMapRelation; screenRegion_->mapRelation_ = std::make_shared(); - std::shared_ptr windowProperty = std::make_shared(); - ScreenClient::GetInstance().AddWindow(windowProperty); + screenRegion_->mapRelation_->SetScreenRect(screenRect); EXPECT_EQ(DH_SUCCESS, screenRegion_->ConfigWindow()); + screenRegion_->Release(); } /**