From 63b982678d33689cff2a1578767872f1c1116adf Mon Sep 17 00:00:00 2001 From: yangwei_814916 Date: Tue, 4 Apr 2023 22:12:35 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E5=B1=80=E9=83=A8=E5=88=B7=E6=96=B0UT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangwei_814916 --- services/common/test/unittest/BUILD.gn | 2 + .../unittest/databuffer/data_buffer_test.cpp | 67 ++++++ .../test/unittest/decision_center/BUILD.gn | 58 +++++ .../screen_decision_center_test.cpp | 217 ++++++++++++++++++ .../screen_decision_center_test.h | 35 +++ .../common/test/unittest/imageJpeg/BUILD.gn | 57 +++++ .../imageJpeg/jpeg_image_processor_test.cpp | 135 +++++++++++ .../imageJpeg/jpeg_image_processor_test.h | 35 +++ .../screentransport/test/unittest/BUILD.gn | 1 + .../test/unittest/screensourcetrans/BUILD.gn | 1 + 10 files changed, 608 insertions(+) create mode 100644 services/common/test/unittest/decision_center/BUILD.gn create mode 100644 services/common/test/unittest/decision_center/screen_decision_center_test.cpp create mode 100644 services/common/test/unittest/decision_center/screen_decision_center_test.h create mode 100644 services/common/test/unittest/imageJpeg/BUILD.gn create mode 100644 services/common/test/unittest/imageJpeg/jpeg_image_processor_test.cpp create mode 100644 services/common/test/unittest/imageJpeg/jpeg_image_processor_test.h diff --git a/services/common/test/unittest/BUILD.gn b/services/common/test/unittest/BUILD.gn index 95b6e68d..395a775f 100644 --- a/services/common/test/unittest/BUILD.gn +++ b/services/common/test/unittest/BUILD.gn @@ -15,6 +15,8 @@ group("service_common_test") { testonly = true deps = [ "databuffer:data_buffer_test", + "decision_center:screen_decision_center_test", + "imageJpeg:jpeg_image_processor_test", "utils:utils_test", ] } diff --git a/services/common/test/unittest/databuffer/data_buffer_test.cpp b/services/common/test/unittest/databuffer/data_buffer_test.cpp index b1828d2b..ae6ac220 100644 --- a/services/common/test/unittest/databuffer/data_buffer_test.cpp +++ b/services/common/test/unittest/databuffer/data_buffer_test.cpp @@ -15,6 +15,7 @@ #define private public #include "data_buffer_test.h" +#include "dscreen_errcode.h" #undef private using namespace testing::ext; @@ -55,5 +56,71 @@ HWTEST_F(DataBufferTest, Data_001, TestSize.Level1) uint8_t *actual = dataBuffer_->Data(); EXPECT_NE(nullptr, actual); } + +/** + * @tc.name: ResetCapcity_001 + * @tc.desc: Verify the ResetCapcity function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DataBufferTest, ResetCapcity_001, TestSize.Level1) +{ + dataBuffer_->ResetCapcity(10); + EXPECT_EQ(10, dataBuffer_->Capacity()); +} + +/** + * @tc.name: ResetCapcity_002 + * @tc.desc: Verify the ResetCapcity function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DataBufferTest, ResetCapcity_002, TestSize.Level1) +{ + dataBuffer_->ResetCapcity(0); + EXPECT_EQ(1, dataBuffer_->Capacity()); +} + +/** + * @tc.name: AddData_001 + * @tc.desc: Verify the AddData function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DataBufferTest, AddData_001, TestSize.Level1) +{ + unsigned char *inputData = nullptr; + dataBuffer_->AddData(10, inputData); + EXPECT_EQ(1, dataBuffer_->Capacity()); +} + +/** + * @tc.name: AddData_002 + * @tc.desc: Verify the AddData function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DataBufferTest, AddData_002, TestSize.Level1) +{ + unsigned char *inputData = new unsigned char[10] {0}; + dataBuffer_->ResetCapcity(20); + dataBuffer_->SetSize(0); + dataBuffer_->AddData(10, inputData); + EXPECT_EQ(10, dataBuffer_->Capacity()); + delete [] inputData; +} + +/** + * @tc.name: GetData_001 + * @tc.desc: Verify the GetData function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DataBufferTest, GetData_001, TestSize.Level1) +{ + uint8_t *outputData = new uint8_t[10] {0}; + EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, dataBuffer_->GetData(10, 10, outputData)); + delete [] outputData; +} } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/services/common/test/unittest/decision_center/BUILD.gn b/services/common/test/unittest/decision_center/BUILD.gn new file mode 100644 index 00000000..91d234be --- /dev/null +++ b/services/common/test/unittest/decision_center/BUILD.gn @@ -0,0 +1,58 @@ +# Copyright (c) 2023 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") + +module_out_path = "distributed_screen/services/screen_decision_center_test" + +config("module_private_config") { + visibility = [ ":*" ] + + include_dirs = [ + "include", + "${common_path}/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/decision_center/include", + "${services_path}/common/imageJpeg/include", + "${services_path}/common/utils/include", + "${services_path}/screentransport/screensourceprocessor/encoder/include", + "${services_path}/screentransport/screensourceprocessor/include", + ] +} + +## UnitTest screen_decision_center_test +ohos_unittest("ScreenDecisionCenterTest") { + module_out_path = module_out_path + + sources = [ + "${services_path}/common/test/unittest/decision_center/screen_decision_center_test.cpp", + ] + + configs = [ ":module_private_config" ] + + deps = [ + "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", + ] + + external_deps = [ + "graphic_standard:surface", + "multimedia_player_framework:media_client", + ] +} + +group("screen_decision_center_test") { + testonly = true + deps = [ ":ScreenDecisionCenterTest" ] +} diff --git a/services/common/test/unittest/decision_center/screen_decision_center_test.cpp b/services/common/test/unittest/decision_center/screen_decision_center_test.cpp new file mode 100644 index 00000000..48e9deaf --- /dev/null +++ b/services/common/test/unittest/decision_center/screen_decision_center_test.cpp @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#define private public +#include "screen_decision_center_test.h" +#include "dscreen_errcode.h" +#include "surface_type.h" +#include "iconsumer_surface.h" +#include "iimage_source_processor.h" +#include "iimage_source_processor_listener.h" +#include "jpeg_image_processor.h" +#undef private +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace DistributedHardware { +void ScreenDecisionCenterTest::SetUpTestCase(void) {} + +void ScreenDecisionCenterTest::TearDownTestCase(void) {} + +void ScreenDecisionCenterTest::SetUp(void) +{ + param_.screenWidth_ = DSCREEN_MAX_SCREEN_DATA_WIDTH; + param_.screenHeight_ = DSCREEN_MAX_SCREEN_DATA_HEIGHT; + param_.videoWidth_ = DSCREEN_MAX_VIDEO_DATA_WIDTH; + param_.videoHeight_ = DSCREEN_MAX_VIDEO_DATA_HEIGHT; + param_.codecType_ = VIDEO_CODEC_TYPE_VIDEO_H264; + param_.videoFormat_ = VIDEO_DATA_FORMAT_YUVI420; + decision = std::make_shared(param_); +} + +void ScreenDecisionCenterTest::TearDown(void) {} + +/** + * @tc.name: IsDirtyRectValid_001 + * @tc.desc: Verify the IsDirtyRectValid function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenDecisionCenterTest, IsDirtyRectValid_001, TestSize.Level1) +{ + std::vector damages; + int32_t ret = decision->IsDirtyRectValid(damages); + EXPECT_EQ(false, ret); +} + +/** + * @tc.name: IsDirtyRectValid_002 + * @tc.desc: Verify the IsDirtyRectValid function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenDecisionCenterTest, IsDirtyRectValid_002, TestSize.Level1) +{ + std::vector damages; + OHOS::Rect damage = {-1, -1, 0, 0}; + damages.push_back(damage); + int32_t ret = decision->IsDirtyRectValid(damages); + EXPECT_EQ(false, ret); +} + +/** + * @tc.name: IsDirtyRectValid_003 + * @tc.desc: Verify the IsDirtyRectValid function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenDecisionCenterTest, IsDirtyRectValid_003, TestSize.Level1) +{ + std::vector damages; + OHOS::Rect damage = {1, 2, 1, 2}; + damages.push_back(damage); + int32_t ret = decision->IsDirtyRectValid(damages); + EXPECT_EQ(false, ret); +} + +/** + * @tc.name: IsDirtyRectValid_004 + * @tc.desc: Verify the IsDirtyRectValid function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenDecisionCenterTest, IsDirtyRectValid_004, TestSize.Level1) +{ + std::vector damages; + OHOS::Rect damage = {2560, 2772, 2, 2}; + damages.push_back(damage); + int32_t ret = decision->IsDirtyRectValid(damages); + EXPECT_EQ(false, ret); +} + +/** + * @tc.name: IsDirtyRectValid_005 + * @tc.desc: Verify the IsDirtyRectValid function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenDecisionCenterTest, IsDirtyRectValid_005, TestSize.Level1) +{ + std::vector damages; + OHOS::Rect damage = {2, 2, 2, 2}; + damages.push_back(damage); + int32_t ret = decision->IsDirtyRectValid(damages); + EXPECT_EQ(true, ret); +} + +/** + * @tc.name: JudgeDirtyThreshold_001 + * @tc.desc: Verify the JudgeDirtyThreshold function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenDecisionCenterTest, JudgeDirtyThreshold_001, TestSize.Level1) +{ + std::vector damages; + int32_t ret = decision->JudgeDirtyThreshold(damages); + EXPECT_EQ(true, ret); +} + +/** + * @tc.name: JudgeDirtyThreshold_002 + * @tc.desc: Verify the JudgeDirtyThreshold function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenDecisionCenterTest, JudgeDirtyThreshold_002, TestSize.Level1) +{ + std::vector damages; + OHOS::Rect damage = {2, 2, 2, 2}; + damages.push_back(damage); + int32_t ret = decision->JudgeDirtyThreshold(damages); + EXPECT_EQ(true, ret); +} + +/** + * @tc.name: JudgeDirtyThreshold_003 + * @tc.desc: Verify the JudgeDirtyThreshold function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenDecisionCenterTest, JudgeDirtyThreshold_003, TestSize.Level1) +{ + std::vector damages; + OHOS::Rect damage = {0, 0, 2600, 2780}; + damages.push_back(damage); + int32_t ret = decision->JudgeDirtyThreshold(damages); + EXPECT_EQ(false, ret); +} + +/** + * @tc.name: LimitTime_001 + * @tc.desc: Verify the LimitTime function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenDecisionCenterTest, LimitTime_001, TestSize.Level1) +{ + decision->sendFullTime_ = time(nullptr); + int32_t ret = decision->LimitTime(0); + EXPECT_EQ(true, ret); +} + +/** + * @tc.name: InputBufferImage_001 + * @tc.desc: Verify the InputBufferImage function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenDecisionCenterTest, InputBufferImage_001, TestSize.Level1) +{ + std::vector damages; + sptr surfaceBuffer = nullptr; + int32_t ret = decision->InputBufferImage(surfaceBuffer, damages); + EXPECT_EQ(ERR_DH_SCREEN_SURFACE_BUFFER_INVALIED, ret); +} + +/** + * @tc.name: ConfigureDecisionCenter_001 + * @tc.desc: Verify the ConfigureDecisionCenter function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenDecisionCenterTest, ConfigureDecisionCenter_001, TestSize.Level1) +{ + std::shared_ptr listener = nullptr; + std::shared_ptr imageProcessor = nullptr; + int32_t ret = decision->ConfigureDecisionCenter(listener, imageProcessor); + EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, ret); +} + +/** + * @tc.name: SetJpegSurface_001 + * @tc.desc: Verify the SetJpegSurface function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenDecisionCenterTest, SetJpegSurface_001, TestSize.Level1) +{ + decision->imageJpeg_ = std::make_shared(param_); + sptr jpegSurface = IConsumerSurface::Create(); + int32_t ret = decision->SetJpegSurface(jpegSurface); + EXPECT_EQ(DH_SUCCESS, ret); +} +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file diff --git a/services/common/test/unittest/decision_center/screen_decision_center_test.h b/services/common/test/unittest/decision_center/screen_decision_center_test.h new file mode 100644 index 00000000..36bd4761 --- /dev/null +++ b/services/common/test/unittest/decision_center/screen_decision_center_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SCREEN_DECISION_CENTER_TEST_H +#define SCREEN_DECISION_CENTER_TEST_H + +#include +#include "screen_decision_center.h" +#include "video_param.h" +namespace OHOS { +namespace DistributedHardware { +class ScreenDecisionCenterTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + VideoParam param_; + std::shared_ptr decision = nullptr; +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif \ No newline at end of file diff --git a/services/common/test/unittest/imageJpeg/BUILD.gn b/services/common/test/unittest/imageJpeg/BUILD.gn new file mode 100644 index 00000000..1a121f5d --- /dev/null +++ b/services/common/test/unittest/imageJpeg/BUILD.gn @@ -0,0 +1,57 @@ +# Copyright (c) 2023 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 +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/test.gni") +import( + "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") + +module_out_path = "distributed_screen/services/jpeg_image_processor_test" + +config("module_private_config") { + visibility = [ ":*" ] + + include_dirs = [ + "include", + "${common_path}/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/imageJpeg/include", + "${services_path}/common/utils/include", + "${services_path}/screentransport/screensourceprocessor/encoder/include", + "${services_path}/screentransport/screensourceprocessor/include", + ] +} + +## UnitTest jpeg_image_processor_test +ohos_unittest("JpegImageProcessorTest") { + module_out_path = module_out_path + + sources = [ + "${services_path}/common/test/unittest/imageJpeg/jpeg_image_processor_test.cpp", + ] + + configs = [ ":module_private_config" ] + + deps = [ + "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", + ] + + external_deps = [ + "graphic_standard:surface", + "multimedia_player_framework:media_client", + ] +} + +group("jpeg_image_processor_test") { + testonly = true + deps = [ ":JpegImageProcessorTest" ] +} diff --git a/services/common/test/unittest/imageJpeg/jpeg_image_processor_test.cpp b/services/common/test/unittest/imageJpeg/jpeg_image_processor_test.cpp new file mode 100644 index 00000000..187cedbb --- /dev/null +++ b/services/common/test/unittest/imageJpeg/jpeg_image_processor_test.cpp @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2022 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#define private public +#include "jpeg_image_processor_test.h" +#include "data_buffer.h" +#include "dscreen_errcode.h" +#include "iconsumer_surface.h" +#include "surface_type.h" +#undef private +using namespace testing; +using namespace testing::ext; + +namespace OHOS { +namespace DistributedHardware { +void ScreenImageJpegTest::SetUpTestCase(void) {} + +void ScreenImageJpegTest::TearDownTestCase(void) {} + +void ScreenImageJpegTest::SetUp(void) +{ + param_.screenWidth_ = DSCREEN_MAX_SCREEN_DATA_WIDTH; + param_.screenHeight_ = DSCREEN_MAX_SCREEN_DATA_HEIGHT; + param_.videoWidth_ = DSCREEN_MAX_VIDEO_DATA_WIDTH; + param_.videoHeight_ = DSCREEN_MAX_VIDEO_DATA_HEIGHT; + param_.codecType_ = VIDEO_CODEC_TYPE_VIDEO_H264; + param_.videoFormat_ = VIDEO_DATA_FORMAT_YUVI420; + jpeg_ = std::make_shared(param_); +} + +void ScreenImageJpegTest::TearDown(void) {} + +/** + * @tc.name: SetOutputSurface_001 + * @tc.desc: Verify the SetOutputSurface function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenImageJpegTest, SetOutputSurface_001, TestSize.Level1) +{ + sptr jpegSurface = IConsumerSurface::Create(); + int32_t ret = jpeg_->SetOutputSurface(jpegSurface); + EXPECT_EQ(DH_SUCCESS, ret); +} + +/** + * @tc.name: SetOutputSurface_002 + * @tc.desc: Verify the SetOutputSurface function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenImageJpegTest, SetOutputSurface_002, TestSize.Level1) +{ + int32_t ret = jpeg_->SetOutputSurface(nullptr); + EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, ret); +} + +/** + * @tc.name: FillDirtyImages2Surface_001 + * @tc.desc: Verify the FillDirtyImages2Surface function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenImageJpegTest, FillDirtyImages2Surface_001, TestSize.Level1) +{ + jpeg_->imageSurface_ = nullptr; + std::shared_ptr dataBuffer = std::make_shared(10); + DirtyRect rect = {20, 20, 20, 20, 20}; + dataBuffer->AddDirtyRect(rect); + int32_t ret = jpeg_->FillDirtyImages2Surface(dataBuffer, nullptr); + EXPECT_EQ(ERR_DH_SCREEN_SURFACE_INVALIED, ret); +} + +/** + * @tc.name: FillDirtyImages2Surface_002 + * @tc.desc: Verify the FillDirtyImages2Surface function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenImageJpegTest, FillDirtyImages2Surface_002, TestSize.Level1) +{ + sptr consumerSurface = IConsumerSurface::Create(); + sptr prodecer = consumerSurface->GetProducer(); + jpeg_->imageSurface_ = Surface::CreateSurfaceAsProducer(prodecer); + std::shared_ptr dataBuffer = std::make_shared(20); + DirtyRect rect = {2600, 2800, 20, 20, 20}; + dataBuffer->AddDirtyRect(rect); + uint8_t *lastFrame = new uint8_t[20] {0}; + int32_t ret = jpeg_->FillDirtyImages2Surface(dataBuffer, lastFrame); + delete [] lastFrame; + EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, ret); +} + +/** + * @tc.name: CompressRgbaToJpeg_001 + * @tc.desc: Verify the CompressRgbaToJpeg function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenImageJpegTest, CompressRgbaToJpeg_001, TestSize.Level1) +{ + OHOS::Rect damage = {20, 20, 20, 20}; + uint8_t *inputData = new uint8_t[1600] {125}; + std::shared_ptr dataBuffer = std::make_shared(2000); + int32_t ret = jpeg_->CompressRgbaToJpeg(damage, inputData, dataBuffer); + EXPECT_NE(1600, ret); +} + +/** + * @tc.name: ReplaceDamage2LastFrame_001 + * @tc.desc: Verify the ReplaceDamage2LastFrame function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenImageJpegTest, ReplaceDamage2LastFrame_001, TestSize.Level1) +{ + uint8_t *lastframe = new uint8_t[28385280] {125}; + uint8_t *dirtyImageData = new uint8_t[1600] {125}; + DirtyRect rect = {20, 20, 20, 24, 20}; + int32_t ret = jpeg_->ReplaceDamage2LastFrame(lastframe, dirtyImageData, rect); + EXPECT_EQ(DH_SUCCESS, ret); +} +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file diff --git a/services/common/test/unittest/imageJpeg/jpeg_image_processor_test.h b/services/common/test/unittest/imageJpeg/jpeg_image_processor_test.h new file mode 100644 index 00000000..96c4841a --- /dev/null +++ b/services/common/test/unittest/imageJpeg/jpeg_image_processor_test.h @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2023 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 + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SCREEN_IMAGE_JPEG_TEST_H +#define SCREEN_IMAGE_JPEG_TEST_H + +#include +#include "jpeg_image_processor.h" +#include "video_param.h" +namespace OHOS { +namespace DistributedHardware { +class ScreenImageJpegTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + VideoParam param_; + std::shared_ptr jpeg_ = nullptr; +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif \ No newline at end of file diff --git a/services/screentransport/test/unittest/BUILD.gn b/services/screentransport/test/unittest/BUILD.gn index a5e48ee7..906482e6 100644 --- a/services/screentransport/test/unittest/BUILD.gn +++ b/services/screentransport/test/unittest/BUILD.gn @@ -18,6 +18,7 @@ group("screen_transport_test") { "screensinkprocessor:sink_processor_test", "screensinktrans:sink_trans_test", "screensourceprocessor:source_processor_test", + "screensourcetrans:source_trans_test", "screentranstestutils:screen_callback_test", ] } diff --git a/services/screentransport/test/unittest/screensourcetrans/BUILD.gn b/services/screentransport/test/unittest/screensourcetrans/BUILD.gn index 57855fb9..00c3791d 100644 --- a/services/screentransport/test/unittest/screensourcetrans/BUILD.gn +++ b/services/screentransport/test/unittest/screensourcetrans/BUILD.gn @@ -68,6 +68,7 @@ ohos_unittest("SourceTransTest") { external_deps = [ "c_utils:utils", + "graphic_standard:surface", "multimedia_player_framework:media_client", ] } -- Gitee From 235a56ff3ffb8a6642d3b007b118203017d5e1ea Mon Sep 17 00:00:00 2001 From: yangwei_814916 Date: Tue, 4 Apr 2023 22:27:41 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E5=B1=80=E9=83=A8=E5=88=B7=E6=96=B0UT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangwei_814916 --- services/common/test/unittest/databuffer/BUILD.gn | 4 +--- services/common/test/unittest/decision_center/BUILD.gn | 8 ++------ services/common/test/unittest/imageJpeg/BUILD.gn | 8 ++------ 3 files changed, 5 insertions(+), 15 deletions(-) diff --git a/services/common/test/unittest/databuffer/BUILD.gn b/services/common/test/unittest/databuffer/BUILD.gn index 0a323b9e..017acaf1 100644 --- a/services/common/test/unittest/databuffer/BUILD.gn +++ b/services/common/test/unittest/databuffer/BUILD.gn @@ -38,9 +38,7 @@ config("module_private_config") { ohos_unittest("DataBufferTest") { module_out_path = module_out_path - sources = [ - "${services_path}/common/test/unittest/databuffer/data_buffer_test.cpp", - ] + sources = [ "${services_path}/common/test/unittest/databuffer/data_buffer_test.cpp" ] configs = [ ":module_private_config" ] diff --git a/services/common/test/unittest/decision_center/BUILD.gn b/services/common/test/unittest/decision_center/BUILD.gn index 91d234be..b5c26e94 100644 --- a/services/common/test/unittest/decision_center/BUILD.gn +++ b/services/common/test/unittest/decision_center/BUILD.gn @@ -36,15 +36,11 @@ config("module_private_config") { ohos_unittest("ScreenDecisionCenterTest") { module_out_path = module_out_path - sources = [ - "${services_path}/common/test/unittest/decision_center/screen_decision_center_test.cpp", - ] + sources = [ "${services_path}/common/test/unittest/decision_center/screen_decision_center_test.cpp" ] configs = [ ":module_private_config" ] - deps = [ - "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", - ] + deps = [ "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans" ] external_deps = [ "graphic_standard:surface", diff --git a/services/common/test/unittest/imageJpeg/BUILD.gn b/services/common/test/unittest/imageJpeg/BUILD.gn index 1a121f5d..417517d7 100644 --- a/services/common/test/unittest/imageJpeg/BUILD.gn +++ b/services/common/test/unittest/imageJpeg/BUILD.gn @@ -35,15 +35,11 @@ config("module_private_config") { ohos_unittest("JpegImageProcessorTest") { module_out_path = module_out_path - sources = [ - "${services_path}/common/test/unittest/imageJpeg/jpeg_image_processor_test.cpp", - ] + sources = [ "${services_path}/common/test/unittest/imageJpeg/jpeg_image_processor_test.cpp" ] configs = [ ":module_private_config" ] - deps = [ - "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", - ] + deps = [ "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans" ] external_deps = [ "graphic_standard:surface", -- Gitee From 163378086f9598313009e4d4c352e06a39338ce4 Mon Sep 17 00:00:00 2001 From: yangwei_814916 Date: Tue, 4 Apr 2023 22:44:53 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E5=B1=80=E9=83=A8=E5=88=B7=E6=96=B0UT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangwei_814916 --- services/common/test/unittest/databuffer/BUILD.gn | 4 +++- services/common/test/unittest/decision_center/BUILD.gn | 3 +-- services/common/test/unittest/imageJpeg/BUILD.gn | 3 +-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/services/common/test/unittest/databuffer/BUILD.gn b/services/common/test/unittest/databuffer/BUILD.gn index 017acaf1..0a323b9e 100644 --- a/services/common/test/unittest/databuffer/BUILD.gn +++ b/services/common/test/unittest/databuffer/BUILD.gn @@ -38,7 +38,9 @@ config("module_private_config") { ohos_unittest("DataBufferTest") { module_out_path = module_out_path - sources = [ "${services_path}/common/test/unittest/databuffer/data_buffer_test.cpp" ] + sources = [ + "${services_path}/common/test/unittest/databuffer/data_buffer_test.cpp", + ] configs = [ ":module_private_config" ] diff --git a/services/common/test/unittest/decision_center/BUILD.gn b/services/common/test/unittest/decision_center/BUILD.gn index b5c26e94..f40cc06d 100644 --- a/services/common/test/unittest/decision_center/BUILD.gn +++ b/services/common/test/unittest/decision_center/BUILD.gn @@ -12,8 +12,7 @@ # limitations under the License. import("//build/test.gni") -import( - "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") +import("${distributedscreen_path}/distributedscreen.gni") module_out_path = "distributed_screen/services/screen_decision_center_test" diff --git a/services/common/test/unittest/imageJpeg/BUILD.gn b/services/common/test/unittest/imageJpeg/BUILD.gn index 417517d7..b215f319 100644 --- a/services/common/test/unittest/imageJpeg/BUILD.gn +++ b/services/common/test/unittest/imageJpeg/BUILD.gn @@ -12,8 +12,7 @@ # limitations under the License. import("//build/test.gni") -import( - "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") +import("${distributedscreen_path}/distributedscreen.gni") module_out_path = "distributed_screen/services/jpeg_image_processor_test" -- Gitee From 5251324fe8b3062fe2b7f6414efd2b09f1a31c81 Mon Sep 17 00:00:00 2001 From: yangwei_814916 Date: Tue, 4 Apr 2023 22:54:24 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E5=B1=80=E9=83=A8=E5=88=B7=E6=96=B0UT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangwei_814916 --- services/common/test/unittest/decision_center/BUILD.gn | 3 ++- services/common/test/unittest/imageJpeg/BUILD.gn | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/services/common/test/unittest/decision_center/BUILD.gn b/services/common/test/unittest/decision_center/BUILD.gn index f40cc06d..b5c26e94 100644 --- a/services/common/test/unittest/decision_center/BUILD.gn +++ b/services/common/test/unittest/decision_center/BUILD.gn @@ -12,7 +12,8 @@ # limitations under the License. import("//build/test.gni") -import("${distributedscreen_path}/distributedscreen.gni") +import( + "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") module_out_path = "distributed_screen/services/screen_decision_center_test" diff --git a/services/common/test/unittest/imageJpeg/BUILD.gn b/services/common/test/unittest/imageJpeg/BUILD.gn index b215f319..417517d7 100644 --- a/services/common/test/unittest/imageJpeg/BUILD.gn +++ b/services/common/test/unittest/imageJpeg/BUILD.gn @@ -12,7 +12,8 @@ # limitations under the License. import("//build/test.gni") -import("${distributedscreen_path}/distributedscreen.gni") +import( + "//foundation/distributedhardware/distributed_screen/distributedscreen.gni") module_out_path = "distributed_screen/services/jpeg_image_processor_test" -- Gitee From 03ec852339066ec9e84d7f0ed34c2b5c390c8c85 Mon Sep 17 00:00:00 2001 From: yangwei_814916 Date: Thu, 6 Apr 2023 09:58:21 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E5=B1=80=E9=83=A8=E5=88=B7=E6=96=B0UT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangwei_814916 --- services/common/test/unittest/BUILD.gn | 2 +- services/common/test/unittest/databuffer/BUILD.gn | 2 +- services/common/test/unittest/databuffer/data_buffer_test.cpp | 2 +- services/common/test/unittest/databuffer/data_buffer_test.h | 2 +- .../unittest/decision_center/screen_decision_center_test.cpp | 2 +- .../test/unittest/imageJpeg/jpeg_image_processor_test.cpp | 2 +- services/screentransport/test/unittest/BUILD.gn | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/services/common/test/unittest/BUILD.gn b/services/common/test/unittest/BUILD.gn index 395a775f..19d5d5d9 100644 --- a/services/common/test/unittest/BUILD.gn +++ b/services/common/test/unittest/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. +# Copyright (c) 2022-2023 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 diff --git a/services/common/test/unittest/databuffer/BUILD.gn b/services/common/test/unittest/databuffer/BUILD.gn index 0a323b9e..9dfd4e9c 100644 --- a/services/common/test/unittest/databuffer/BUILD.gn +++ b/services/common/test/unittest/databuffer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. +# Copyright (c) 2022-2023 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 diff --git a/services/common/test/unittest/databuffer/data_buffer_test.cpp b/services/common/test/unittest/databuffer/data_buffer_test.cpp index ae6ac220..d6afac5a 100644 --- a/services/common/test/unittest/databuffer/data_buffer_test.cpp +++ b/services/common/test/unittest/databuffer/data_buffer_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 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 diff --git a/services/common/test/unittest/databuffer/data_buffer_test.h b/services/common/test/unittest/databuffer/data_buffer_test.h index b9bf80ff..8e1d9e2b 100644 --- a/services/common/test/unittest/databuffer/data_buffer_test.h +++ b/services/common/test/unittest/databuffer/data_buffer_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2022-2023 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 diff --git a/services/common/test/unittest/decision_center/screen_decision_center_test.cpp b/services/common/test/unittest/decision_center/screen_decision_center_test.cpp index 48e9deaf..2fc79676 100644 --- a/services/common/test/unittest/decision_center/screen_decision_center_test.cpp +++ b/services/common/test/unittest/decision_center/screen_decision_center_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2023 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 diff --git a/services/common/test/unittest/imageJpeg/jpeg_image_processor_test.cpp b/services/common/test/unittest/imageJpeg/jpeg_image_processor_test.cpp index 187cedbb..a3e9f288 100644 --- a/services/common/test/unittest/imageJpeg/jpeg_image_processor_test.cpp +++ b/services/common/test/unittest/imageJpeg/jpeg_image_processor_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Huawei Device Co., Ltd. + * Copyright (c) 2023 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 diff --git a/services/screentransport/test/unittest/BUILD.gn b/services/screentransport/test/unittest/BUILD.gn index 906482e6..51bdfe13 100644 --- a/services/screentransport/test/unittest/BUILD.gn +++ b/services/screentransport/test/unittest/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. +# Copyright (c) 2022-2023 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 -- Gitee From d4a7d2d29a6cc8b1fe7ab79a6220a39f5feaaf33 Mon Sep 17 00:00:00 2001 From: yangwei_814916 Date: Thu, 6 Apr 2023 17:42:24 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E5=B1=80=E9=83=A8=E5=88=B7=E6=96=B0UT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangwei_814916 --- services/common/databuffer/src/data_buffer.cpp | 2 +- services/common/imageJpeg/src/jpeg_image_processor.cpp | 2 +- .../screensinkprocessor/decoder/src/image_sink_decoder.cpp | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/services/common/databuffer/src/data_buffer.cpp b/services/common/databuffer/src/data_buffer.cpp index 12ac906b..d35d1eb7 100644 --- a/services/common/databuffer/src/data_buffer.cpp +++ b/services/common/databuffer/src/data_buffer.cpp @@ -120,7 +120,7 @@ std::vector DataBuffer::GetDirtyRectVec() int32_t DataBuffer::GetData(int32_t offset, int32_t datasize, uint8_t* &output) { - if (offset + datasize > capacity_ || output == nullptr) { + if (static_cast(offset + datasize) > capacity_ || output == nullptr) { DHLOGE("DataBuffer GetData parameter invalid."); return ERR_DH_SCREEN_INPUT_PARAM_INVALID; } diff --git a/services/common/imageJpeg/src/jpeg_image_processor.cpp b/services/common/imageJpeg/src/jpeg_image_processor.cpp index 5fa6337c..40a6d0f8 100644 --- a/services/common/imageJpeg/src/jpeg_image_processor.cpp +++ b/services/common/imageJpeg/src/jpeg_image_processor.cpp @@ -282,7 +282,7 @@ void JpegImageProcessor::DecompressJpegToNV12(size_t jpegSize, uint8_t *inputDat #endif while (cinfo.output_scanline < cinfo.output_height) { (void)jpeg_read_scanlines(&cinfo, buffer, 1); - for (int j = 0 ; j < cinfo.output_width ; j++) { + for (unsigned int j = 0 ; j < cinfo.output_width ; j++) { #ifdef LIBYUV rgb[rgbIndex++] = buffer[0][j * RGB_CHROMA + TWO]; rgb[rgbIndex++] = buffer[0][j * RGB_CHROMA + 1]; diff --git a/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp b/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp index 687c2527..4a869126 100644 --- a/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp +++ b/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp @@ -135,7 +135,7 @@ void ImageSinkDecoder::OffsetProcess(sptr surfaceBuffer, sptrGetStride(); int32_t chromaOffset = configParam_.GetVideoWidth() * configParam_.GetVideoHeight(); - for (int32_t yh = 0 ; yh < configParam_.GetVideoHeight() ; yh++) { + for (unsigned int yh = 0 ; yh < configParam_.GetVideoHeight() ; yh++) { int32_t ret = memcpy_s(windowSurfaceAddr + dstDataOffset, chromaOffset - dstDataOffset, surfaceAddr + srcDataOffset, configParam_.GetVideoWidth()); if (ret != EOK) { @@ -148,7 +148,7 @@ void ImageSinkDecoder::OffsetProcess(sptr surfaceBuffer, sptrGetStride(); - if (alignedWidth == configParam_.GetVideoWidth() && alignedHeight_ == configParam_.GetVideoHeight()) { + if (static_cast(alignedWidth) == configParam_.GetVideoWidth() && + static_cast(alignedHeight_) == configParam_.GetVideoHeight()) { NormalProcess(surfaceBuffer, windowSurfaceBuffer); } else { OffsetProcess(surfaceBuffer, windowSurfaceBuffer); -- Gitee From 1d021e06ffedac40035a17e73e32a08869b7d40e Mon Sep 17 00:00:00 2001 From: yangwei_814916 Date: Thu, 6 Apr 2023 19:37:09 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E5=B1=80=E9=83=A8=E5=88=B7=E6=96=B0UT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yangwei_814916 --- .../imageJpeg/jpeg_image_processor_test.cpp | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/services/common/test/unittest/imageJpeg/jpeg_image_processor_test.cpp b/services/common/test/unittest/imageJpeg/jpeg_image_processor_test.cpp index a3e9f288..b26eb6d1 100644 --- a/services/common/test/unittest/imageJpeg/jpeg_image_processor_test.cpp +++ b/services/common/test/unittest/imageJpeg/jpeg_image_processor_test.cpp @@ -102,21 +102,6 @@ HWTEST_F(ScreenImageJpegTest, FillDirtyImages2Surface_002, TestSize.Level1) EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, ret); } -/** - * @tc.name: CompressRgbaToJpeg_001 - * @tc.desc: Verify the CompressRgbaToJpeg function. - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(ScreenImageJpegTest, CompressRgbaToJpeg_001, TestSize.Level1) -{ - OHOS::Rect damage = {20, 20, 20, 20}; - uint8_t *inputData = new uint8_t[1600] {125}; - std::shared_ptr dataBuffer = std::make_shared(2000); - int32_t ret = jpeg_->CompressRgbaToJpeg(damage, inputData, dataBuffer); - EXPECT_NE(1600, ret); -} - /** * @tc.name: ReplaceDamage2LastFrame_001 * @tc.desc: Verify the ReplaceDamage2LastFrame function. -- Gitee