From 577311984d11ee80258823f2e5940dd7aac24fca Mon Sep 17 00:00:00 2001 From: pwx1285814 Date: Thu, 11 Apr 2024 09:34:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=90=86=E5=91=8A=E8=AD=A6=E5=B9=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0ut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: pwx1285814 Change-Id: Ife6186f4357e29c76431a03b928edf879a1e0396 Signed-off-by: pwx1285814 --- common/src/dscreen_util.cpp | 24 +-- common/test/unittest/BUILD.gn | 7 +- .../unittest/include/screen_common_test.h | 3 +- common/test/unittest/resource/BUILD.gn | 24 +++ .../test/unittest/src/screen_common_test.cpp | 11 +- distributedscreen.gni | 1 - .../handlerinitsink_fuzzer/BUILD.gn | 8 +- .../BUILD.gn | 8 +- .../BUILD.gn | 8 +- .../BUILD.gn | 8 +- .../proxyinitsink_fuzzer/BUILD.gn | 10 +- .../BUILD.gn | 10 +- .../BUILD.gn | 8 +- .../sinkproxydscreennotify_fuzzer/BUILD.gn | 8 +- .../callbackonnotifyregresult_fuzzer/BUILD.gn | 8 +- .../BUILD.gn | 8 +- .../callbackonremoterequest_fuzzer/BUILD.gn | 8 +- .../BUILD.gn | 8 +- .../handlerinitsource_fuzzer/BUILD.gn | 8 +- .../BUILD.gn | 8 +- .../BUILD.gn | 8 +- .../BUILD.gn | 8 +- .../BUILD.gn | 8 +- .../proxydscreennotify_fuzzer/BUILD.gn | 8 +- .../proxyinitsource_fuzzer/BUILD.gn | 8 +- .../BUILD.gn | 8 +- .../BUILD.gn | 8 +- .../test/unittest/screensinktest/BUILD.gn | 5 +- .../src/dscreen_sink_handler_test.cpp | 4 +- .../test/unittest/screensourcetest/BUILD.gn | 5 +- .../callback/dscreen_source_callback_test.h | 4 +- .../callback/dscreen_source_callback_test.cpp | 4 +- .../src/dscreen_source_handler_test.cpp | 4 +- .../fuzztest/pluginhardware_fuzzer/BUILD.gn | 8 +- .../registerpluginlistener_fuzzer/BUILD.gn | 8 +- .../fuzztest/unpluginhardware_fuzzer/BUILD.gn | 8 +- .../test/unittest/screenhandler/BUILD.gn | 11 +- .../include/dscreen_handler_test.h | 4 +- .../src/dscreen_handler_test.cpp | 38 ++++- .../common/test/unittest/databuffer/BUILD.gn | 5 +- .../unittest/databuffer/data_buffer_test.cpp | 91 +++++++++- .../test/unittest/decision_center/BUILD.gn | 9 +- .../screen_decision_center_test.cpp | 155 +++++++++++++++--- .../screen_decision_center_test.h | 23 ++- .../common/test/unittest/imageJpeg/BUILD.gn | 7 +- .../imageJpeg/jpeg_image_processor_test.cpp | 4 +- services/common/test/unittest/utils/BUILD.gn | 5 +- .../unittest/utils/dscreen_fwkkit_test.cpp | 4 +- .../unittest/utils/dscreen_hidumper_test.cpp | 4 +- .../utils/dscreen_maprelation_test.cpp | 4 +- .../test/unittest/utils/video_param_test.cpp | 16 +- services/screenclient/test/unittest/BUILD.gn | 5 +- .../test/unittest/src/screen_client_test.cpp | 4 +- .../src/screen_client_window_adapter_test.cpp | 4 +- services/screendemo/decoder_demo.cpp | 4 +- services/screendemo/test.cpp | 12 +- .../dscreenmgr/onchange_fuzzer/BUILD.gn | 8 +- .../sinkservice/dscreenservice/BUILD.gn | 5 +- .../src/dscreen_sink_stub_test.cpp | 4 +- .../1.0/include/screenregion_test.h | 4 +- .../1.0/include/screenregionmgr_test.h | 4 +- .../include/av_receiver_engine_adapter_test.h | 4 +- .../2.0/include/screenregion_test.h | 4 +- .../2.0/include/screenregionmgr_test.h | 4 +- .../sinkservice/screenregionmgr/BUILD.gn | 5 +- .../1.0/include/dscreen_manager_test.h | 4 +- .../dscreenmgr/1.0/include/dscreen_test.h | 4 +- .../dscreenmgr/1.0/src/dscreen_test.cpp | 14 +- .../1.0/src/screen_manager_adapter_test.cpp | 14 +- .../include/av_sender_engine_adapter_test.h | 4 +- .../2.0/include/dscreen_manager_test.h | 4 +- .../dscreenmgr/2.0/include/dscreen_test.h | 4 +- .../2.0/src/dscreen_manager_test.cpp | 4 +- .../dscreenmgr/2.0/src/dscreen_test.cpp | 14 +- .../sourceservice/dscreenmgr/BUILD.gn | 5 +- .../sourceservice/dscreenservice/BUILD.gn | 5 +- .../src/dscreen_source_stub_test.cpp | 4 +- .../decoder/src/image_sink_decoder.cpp | 9 +- .../onbufferavailable_fuzzer/BUILD.gn | 8 +- .../onbufferavailable_fuzzer/BUILD.gn | 8 +- .../onerror_fuzzer/BUILD.gn | 9 +- .../oninputbufferavailable_fuzzer/BUILD.gn | 9 +- .../onoutputbufferavailable_fuzzer/BUILD.gn | 9 +- .../onoutputformatchanged_fuzzer/BUILD.gn | 9 +- .../test/unittest/screendatachannel/BUILD.gn | 11 +- .../src/screen_data_channel_impl_test.cpp | 8 +- .../unittest/screensinkprocessor/BUILD.gn | 8 +- .../include/image_sink_decoder_test.h | 4 +- .../include/image_sink_processor_test.h | 4 +- .../src/image_sink_decoder_test.cpp | 125 +++++++++++++- .../src/image_sink_processor_test.cpp | 12 +- .../test/unittest/screensinktrans/BUILD.gn | 8 +- .../include/screen_sink_trans_test.h | 4 +- .../src/screen_sink_trans_test.cpp | 12 +- .../unittest/screensourceprocessor/BUILD.gn | 5 +- .../include/image_source_encoder_test.h | 4 +- .../include/image_source_processor_test.h | 4 +- .../test/unittest/screensourcetrans/BUILD.gn | 5 +- .../include/screen_source_trans_test.h | 4 +- .../src/screen_source_trans_test.cpp | 20 +-- .../unittest/screentranstestutils/BUILD.gn | 5 +- .../src/screen_callback_test.cpp | 56 ++++++- .../softbusadapter/include/softbus_adapter.h | 6 +- .../softbusadapter/src/softbus_adapter.cpp | 4 +- .../softbusonbytesreceived_fuzzer/BUILD.gn | 11 +- .../softbusonbytesreceived_fuzzer.cpp | 4 +- .../softbusonmessagereceived_fuzzer/BUILD.gn | 11 +- .../softbusonmessagereceived_fuzzer.cpp | 4 +- .../softbusonsessionclosed_fuzzer/BUILD.gn | 11 +- .../softbusonsessionclosed_fuzzer.cpp | 4 +- .../softbusonsessionopened_fuzzer/BUILD.gn | 11 +- .../softbusonsessionopened_fuzzer.cpp | 8 +- .../softbusonstreamreceived_fuzzer/BUILD.gn | 11 +- .../softbusonstreamreceived_fuzzer.cpp | 4 +- .../softbusadapter/test/unittest/BUILD.gn | 5 +- .../unittest/include/softbus_adapter_test.h | 4 +- .../unittest/src/softbus_adapter_test.cpp | 40 ++++- 117 files changed, 814 insertions(+), 507 deletions(-) create mode 100644 common/test/unittest/resource/BUILD.gn diff --git a/common/src/dscreen_util.cpp b/common/src/dscreen_util.cpp index e0836d39..f6dceb83 100644 --- a/common/src/dscreen_util.cpp +++ b/common/src/dscreen_util.cpp @@ -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 @@ -85,24 +85,24 @@ std::string GetRandomID() std::string GetAnonyString(const std::string &value) { - constexpr size_t INT32_SHORT_ID_LENGTH = 20; - constexpr size_t INT32_MIN_ID_LENGTH = 3; + constexpr size_t int32ShortIdLength = 20; + constexpr size_t int32MinIdLength = 3; std::string result; std::string tmpStr("******"); size_t strLen = value.length(); - if (strLen < INT32_MIN_ID_LENGTH) { + if (strLen < int32MinIdLength) { return tmpStr; } - if (strLen <= INT32_SHORT_ID_LENGTH) { + if (strLen <= int32ShortIdLength) { result += value[0]; result += tmpStr; result += value[strLen - 1]; } else { - constexpr size_t INT32_PLAINTEXT_LENGTH = 4; - result.append(value, 0, INT32_PLAINTEXT_LENGTH); + constexpr size_t int32PlainTextLength = 4; + result.append(value, 0, int32PlainTextLength); result += tmpStr; - result.append(value, strLen - INT32_PLAINTEXT_LENGTH, INT32_PLAINTEXT_LENGTH); + result.append(value, strLen - int32PlainTextLength, int32PlainTextLength); } return result; @@ -110,14 +110,14 @@ std::string GetAnonyString(const std::string &value) std::string GetInterruptString(const std::string &value) { - constexpr size_t INT32_MIN_ID_LENGTH = 3; - constexpr size_t STRING_HALF_LENGTH = 2; + constexpr size_t int32MinIdLength = 3; + constexpr size_t stringHalfLength = 2; std::string res; size_t strlen = value.length(); - if (strlen <= INT32_MIN_ID_LENGTH) { + if (strlen <= int32MinIdLength) { res = value; } else { - res = value.substr(0, strlen / STRING_HALF_LENGTH); + res = value.substr(0, strlen / stringHalfLength); } return res; diff --git a/common/test/unittest/BUILD.gn b/common/test/unittest/BUILD.gn index 7204ccb4..7b6ab4e5 100644 --- a/common/test/unittest/BUILD.gn +++ b/common/test/unittest/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023 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 @@ -40,7 +40,10 @@ ohos_unittest("ScreenCommonTest") { "${common_path}/test/unittest/src/screen_common_test.cpp", ] - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "${common_path}/test/unittest/resource:dscreen_unittest_public_config", + ] deps = [ "${common_path}:distributed_screen_utils" ] diff --git a/common/test/unittest/include/screen_common_test.h b/common/test/unittest/include/screen_common_test.h index c2654dc6..97f8a969 100644 --- a/common/test/unittest/include/screen_common_test.h +++ b/common/test/unittest/include/screen_common_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 @@ -27,6 +27,7 @@ public: void SetUp(); void TearDown(); const std::string eventName = "eventName"; + const std::string longEventName = "1234567890123456789012345678901234567890"; int32_t errCode = -100; int32_t saId = 4808; const std::string errMsg = "errMsg"; diff --git a/common/test/unittest/resource/BUILD.gn b/common/test/unittest/resource/BUILD.gn new file mode 100644 index 00000000..7c8b5eec --- /dev/null +++ b/common/test/unittest/resource/BUILD.gn @@ -0,0 +1,24 @@ +# Copyright (c) 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 +# +# 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. + +config("dscreen_unittest_public_config") { + cflags = [ + "-g", + "-O0", + "-Wno-unused-variable", + "-fno-omit-frame-pointer", + "-Dprivate=public", + "-Dprotected=public", + "-frtti", + ] +} diff --git a/common/test/unittest/src/screen_common_test.cpp b/common/test/unittest/src/screen_common_test.cpp index 2a01870b..122550e6 100644 --- a/common/test/unittest/src/screen_common_test.cpp +++ b/common/test/unittest/src/screen_common_test.cpp @@ -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 @@ -62,6 +62,15 @@ HWTEST_F(ScreenCommonTest, common_002, TestSize.Level1) ReportRegisterScreenEvent(eventName, devId, dhId, errMsg); ReportUnRegisterScreenEvent(eventName, devId, dhId, errMsg); ReportScreenMirrorEvent(eventName, devId, dhId, errMsg); + ReportSaFail(longEventName, errCode, saId, errMsg); + ReportSaFail(longEventName, errCode, saId, errMsg); + ReportRegisterFail(longEventName, errCode, devId, dhId, errMsg); + ReportUnRegisterFail(longEventName, errCode, devId, dhId, errMsg); + ReportOptFail(longEventName, errCode, errMsg); + ReportSaEvent(longEventName, saId, errMsg); + ReportRegisterScreenEvent(longEventName, devId, dhId, errMsg); + ReportUnRegisterScreenEvent(longEventName, devId, dhId, errMsg); + ReportScreenMirrorEvent(longEventName, devId, dhId, errMsg); std::string value = "Id"; std::string ret = GetAnonyString(value); EXPECT_EQ("******", ret); diff --git a/distributedscreen.gni b/distributedscreen.gni index 85655724..2fe9ad80 100644 --- a/distributedscreen.gni +++ b/distributedscreen.gni @@ -16,4 +16,3 @@ fuzz_test_path = "distributed_screen/distributed_screen" common_path = "${distributedscreen_path}/common" services_path = "${distributedscreen_path}/services" interfaces_path = "${distributedscreen_path}/interfaces" -build_flags = [ "-Werror" ] diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlerinitsink_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlerinitsink_fuzzer/BUILD.gn index 9cfab359..0490c2d2 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlerinitsink_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlerinitsink_fuzzer/BUILD.gn @@ -29,12 +29,8 @@ ohos_fuzztest("HandlerInitSinkFuzzTest") { "${interfaces_path}/innerkits/native_cpp/screen_sink/include", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] sources = [ "initsink_fuzzer.cpp" ] diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handleronremotesinksvrdied_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handleronremotesinksvrdied_fuzzer/BUILD.gn index 4f6f8b86..68e2f0b9 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handleronremotesinksvrdied_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handleronremotesinksvrdied_fuzzer/BUILD.gn @@ -29,12 +29,8 @@ ohos_fuzztest("HandlerOnRemoteSinkSvrDiedFuzzTest") { "${interfaces_path}/innerkits/native_cpp/screen_sink/include", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] sources = [ "onremotesinksvrdied_fuzzer.cpp" ] diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlersubscribelocalhardware_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlersubscribelocalhardware_fuzzer/BUILD.gn index bae58298..f9062eab 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlersubscribelocalhardware_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlersubscribelocalhardware_fuzzer/BUILD.gn @@ -29,12 +29,8 @@ ohos_fuzztest("HandlerSubscribeLocalHardwareFuzzTest") { "${interfaces_path}/innerkits/native_cpp/screen_sink/include", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] sources = [ "subscribelocalhardware_fuzzer.cpp" ] diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlerunsubscribelocalhardware_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlerunsubscribelocalhardware_fuzzer/BUILD.gn index 371aa256..5cbeb4a0 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlerunsubscribelocalhardware_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_handler/handlerunsubscribelocalhardware_fuzzer/BUILD.gn @@ -29,12 +29,8 @@ ohos_fuzztest("HandlerUnsubscribeLocalHardwareFuzzTest") { "${interfaces_path}/innerkits/native_cpp/screen_sink/include", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] sources = [ "unsubscribelocalhardware_fuzzer.cpp" ] diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyinitsink_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyinitsink_fuzzer/BUILD.gn index 4179e98a..66e376a9 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyinitsink_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyinitsink_fuzzer/BUILD.gn @@ -29,15 +29,11 @@ ohos_fuzztest("ProxyInitSinkFuzzTest") { "${interfaces_path}/innerkits/native_cpp/screen_sink/include", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "initsink_fuzzer.cpp" ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] + deps = [ "${interfaces_path}/innerkits/native_cpp/screen_sink:distributed_screen_sink_sdk" ] defines = [ diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxysubscribelocalhardware_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxysubscribelocalhardware_fuzzer/BUILD.gn index ac317ba0..f5117dba 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxysubscribelocalhardware_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxysubscribelocalhardware_fuzzer/BUILD.gn @@ -29,15 +29,11 @@ ohos_fuzztest("ProxySubscribeLocalHardwareFuzzTest") { "${interfaces_path}/innerkits/native_cpp/screen_sink/include", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "subscribelocalhardware_fuzzer.cpp" ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] + deps = [ "${interfaces_path}/innerkits/native_cpp/screen_sink:distributed_screen_sink_sdk" ] defines = [ diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyunsubscribelocalhardware_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyunsubscribelocalhardware_fuzzer/BUILD.gn index 63f57dca..7819d466 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyunsubscribelocalhardware_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/proxyunsubscribelocalhardware_fuzzer/BUILD.gn @@ -29,12 +29,8 @@ ohos_fuzztest("ProxyUnsubscribeLocalHardwareFuzzTest") { "${interfaces_path}/innerkits/native_cpp/screen_sink/include", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] sources = [ "unsubscribelocalhardware_fuzzer.cpp" ] diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/sinkproxydscreennotify_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/sinkproxydscreennotify_fuzzer/BUILD.gn index b4f990aa..a58c858d 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/sinkproxydscreennotify_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_sink_proxy/sinkproxydscreennotify_fuzzer/BUILD.gn @@ -29,12 +29,8 @@ ohos_fuzztest("SinkProxyDScreenNotifyFuzzTest") { "${interfaces_path}/innerkits/native_cpp/screen_sink/include", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] sources = [ "sinkproxydscreennotify_fuzzer.cpp" ] diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/BUILD.gn index 13d5eb32..0ab91c8f 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyregresult_fuzzer/BUILD.gn @@ -32,12 +32,8 @@ ohos_fuzztest("CallBackOnNotifyRegResultFuzzTest") { "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] sources = [ "callbackonnotifyregresult_fuzzer.cpp" ] diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/BUILD.gn index 8e641b4f..59fb84a5 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonnotifyunregresult_fuzzer/BUILD.gn @@ -32,12 +32,8 @@ ohos_fuzztest("CallBackOnNotifyUnregResultFuzzTest") { "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] sources = [ "callbackonnotifyunregresult_fuzzer.cpp" ] diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/BUILD.gn index fa7fe27a..461d166d 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_callback/callbackonremoterequest_fuzzer/BUILD.gn @@ -31,12 +31,8 @@ ohos_fuzztest("CallbackOnRemoteRequestFuzzTest") { "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] sources = [ "callbackonremoterequest_fuzzer.cpp" ] diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerconfigdistributedhardware_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerconfigdistributedhardware_fuzzer/BUILD.gn index 1ee23f19..b5c7f407 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerconfigdistributedhardware_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerconfigdistributedhardware_fuzzer/BUILD.gn @@ -31,12 +31,8 @@ ohos_fuzztest("HandlerConfigDistributedHardwareFuzzTest") { "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] sources = [ "configdistributedhardware_fuzzer.cpp" ] diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/BUILD.gn index 39e2de0e..50046322 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerinitsource_fuzzer/BUILD.gn @@ -31,12 +31,8 @@ ohos_fuzztest("HandlerInitSourceFuzzTest") { "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] sources = [ "initsource_fuzzer.cpp" ] diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/BUILD.gn index 0b1dc166..534f0eb5 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handleronremotesourcesvrdied_fuzzer/BUILD.gn @@ -31,12 +31,8 @@ ohos_fuzztest("HandlerOnRemoteSourceSvrDiedFuzzTest") { "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] sources = [ "onremotesourcesvrdied_fuzzer.cpp" ] diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/BUILD.gn index 2a1d1f64..819381c4 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerregisterdistributedhardware_fuzzer/BUILD.gn @@ -32,12 +32,8 @@ ohos_fuzztest("HandlerRegisterDistributedHardwareFuzzTest") { "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] sources = [ "registerdistributedhardware_fuzzer.cpp" ] diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer/BUILD.gn index a593be88..8b0fcd17 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_handler/handlerunregisterdistributedhardware_fuzzer/BUILD.gn @@ -32,12 +32,8 @@ ohos_fuzztest("HandlerUnregisterDistributedHardwareFuzzTest") { "${interfaces_path}/innerkits/native_cpp/test/include", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] sources = [ "unregisterdistributedhardware_fuzzer.cpp" ] diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/BUILD.gn index c3368602..ccc2b485 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyconfigdistributedhardware_fuzzer/BUILD.gn @@ -31,12 +31,8 @@ ohos_fuzztest("ProxyConfigDistributedHardwareFuzzTest") { "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] sources = [ "configdistributedhardware_fuzzer.cpp" ] diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/BUILD.gn index cf704a15..71c89e9c 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxydscreennotify_fuzzer/BUILD.gn @@ -31,12 +31,8 @@ ohos_fuzztest("ProxyDScreenNotifyFuzzTest") { "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] sources = [ "dscreennotify_fuzzer.cpp" ] diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyinitsource_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyinitsource_fuzzer/BUILD.gn index 4d38b33d..2e4ecb94 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyinitsource_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyinitsource_fuzzer/BUILD.gn @@ -31,12 +31,8 @@ ohos_fuzztest("ProxyInitSourceFuzzTest") { "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] sources = [ "initsource_fuzzer.cpp" ] diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/BUILD.gn index 9eebc5ca..b14c8675 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyregisterdistributedhardware_fuzzer/BUILD.gn @@ -31,12 +31,8 @@ ohos_fuzztest("ProxyRegisterDistributedHardwareFuzzTest") { "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] sources = [ "registerdistributedhardware_fuzzer.cpp" ] diff --git a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/BUILD.gn b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/BUILD.gn index 32078c41..46f3be16 100644 --- a/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/fuzztest/dscreen_source_proxy/proxyunregisterdistributedhardware_fuzzer/BUILD.gn @@ -31,12 +31,8 @@ ohos_fuzztest("ProxyUnregisterDistributedHardwareFuzzTest") { "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] sources = [ "unregisterdistributedhardware_fuzzer.cpp" ] diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensinktest/BUILD.gn b/interfaces/innerkits/native_cpp/test/unittest/screensinktest/BUILD.gn index 21ec9a19..56a525ca 100644 --- a/interfaces/innerkits/native_cpp/test/unittest/screensinktest/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/unittest/screensinktest/BUILD.gn @@ -43,7 +43,10 @@ ohos_unittest("ScreenSinkTest") { sources = [ "${interfaces_path}/innerkits/native_cpp/test/unittest/screensinktest/src/dscreen_sink_handler_test.cpp" ] - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "${common_path}/test/unittest/resource:dscreen_unittest_public_config", + ] deps = [ "${interfaces_path}/innerkits/native_cpp/screen_sink:distributed_screen_sink_sdk", diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensinktest/src/dscreen_sink_handler_test.cpp b/interfaces/innerkits/native_cpp/test/unittest/screensinktest/src/dscreen_sink_handler_test.cpp index 7bae4e82..67185737 100644 --- a/interfaces/innerkits/native_cpp/test/unittest/screensinktest/src/dscreen_sink_handler_test.cpp +++ b/interfaces/innerkits/native_cpp/test/unittest/screensinktest/src/dscreen_sink_handler_test.cpp @@ -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 @@ -13,10 +13,8 @@ * limitations under the License. */ -#define private public #include "dscreen_sink_load_callback.h" #include "dscreen_sink_handler_test.h" -#undef private using namespace testing; using namespace testing::ext; diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/BUILD.gn b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/BUILD.gn index 64cf1f3e..331104b7 100644 --- a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/BUILD.gn +++ b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/BUILD.gn @@ -47,7 +47,10 @@ ohos_unittest("ScreenSourceTest") { "${interfaces_path}/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp", ] - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "${common_path}/test/unittest/resource:dscreen_unittest_public_config", + ] deps = [ "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/include/callback/dscreen_source_callback_test.h b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/include/callback/dscreen_source_callback_test.h index 24f1e2d6..1dea2a11 100644 --- a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/include/callback/dscreen_source_callback_test.h +++ b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/include/callback/dscreen_source_callback_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 @@ -30,7 +30,7 @@ public: static void TearDownTestCase(void); void SetUp(); void TearDown(); - + sptr dScreenSourceCallback_ = nullptr; }; } diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/callback/dscreen_source_callback_test.cpp b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/callback/dscreen_source_callback_test.cpp index 67de9fb4..c889aa6c 100644 --- a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/callback/dscreen_source_callback_test.cpp +++ b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/callback/dscreen_source_callback_test.cpp @@ -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 @@ -13,9 +13,7 @@ * limitations under the License. */ -#define private public #include "dscreen_source_callback_test.h" -#undef private using namespace testing; using namespace testing::ext; diff --git a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp index c69e255d..38400d68 100644 --- a/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp +++ b/interfaces/innerkits/native_cpp/test/unittest/screensourcetest/src/dscreen_source_handler_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 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 @@ -13,13 +13,11 @@ * limitations under the License. */ -#define private public #include "dscreen_source_handler_test.h" #include "if_system_ability_manager.h" #include "dscreen_source_load_callback.h" #include "iservice_registry.h" #include "dscreen_constants.h" -#undef private using namespace testing; using namespace testing::ext; diff --git a/screenhandler/test/fuzztest/pluginhardware_fuzzer/BUILD.gn b/screenhandler/test/fuzztest/pluginhardware_fuzzer/BUILD.gn index ec137a6c..b514afce 100644 --- a/screenhandler/test/fuzztest/pluginhardware_fuzzer/BUILD.gn +++ b/screenhandler/test/fuzztest/pluginhardware_fuzzer/BUILD.gn @@ -29,12 +29,8 @@ ohos_fuzztest("PluginHardwareFuzzTest") { "${distributedscreen_path}/screenhandler/include", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] sources = [ "pluginhardware_fuzzer.cpp" ] diff --git a/screenhandler/test/fuzztest/registerpluginlistener_fuzzer/BUILD.gn b/screenhandler/test/fuzztest/registerpluginlistener_fuzzer/BUILD.gn index 4b679f27..d7f1f8b6 100644 --- a/screenhandler/test/fuzztest/registerpluginlistener_fuzzer/BUILD.gn +++ b/screenhandler/test/fuzztest/registerpluginlistener_fuzzer/BUILD.gn @@ -29,12 +29,8 @@ ohos_fuzztest("RegisterPluginListenerFuzzTest") { "${distributedscreen_path}/screenhandler/include", ] - cflags = [ - "-fno-omit-frame-pointer", - "-g", - "-O0", - "-Wno-unused-variable", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] sources = [ "registerpluginlistener_fuzzer.cpp" ] diff --git a/screenhandler/test/fuzztest/unpluginhardware_fuzzer/BUILD.gn b/screenhandler/test/fuzztest/unpluginhardware_fuzzer/BUILD.gn index 2f071618..0dd1e215 100644 --- a/screenhandler/test/fuzztest/unpluginhardware_fuzzer/BUILD.gn +++ b/screenhandler/test/fuzztest/unpluginhardware_fuzzer/BUILD.gn @@ -29,12 +29,8 @@ ohos_fuzztest("UnPluginHardwareFuzzTest") { "${distributedscreen_path}/screenhandler/include", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] sources = [ "unpluginhardware_fuzzer.cpp" ] diff --git a/screenhandler/test/unittest/screenhandler/BUILD.gn b/screenhandler/test/unittest/screenhandler/BUILD.gn index 246d2edd..6fc2f86b 100644 --- a/screenhandler/test/unittest/screenhandler/BUILD.gn +++ b/screenhandler/test/unittest/screenhandler/BUILD.gn @@ -37,7 +37,10 @@ ohos_unittest("DscreenHandlerTest") { sources = [ "${distributedscreen_path}/screenhandler/test/unittest/screenhandler/src/dscreen_handler_test.cpp" ] - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "${common_path}/test/unittest/resource:dscreen_unittest_public_config", + ] deps = [ "${distributedscreen_path}/screenhandler:distributed_screen_handler", @@ -62,10 +65,4 @@ ohos_unittest("DscreenHandlerTest") { "DH_LOG_TAG=\"DscreenHandlerTest\"", "LOG_DOMAIN=0xD004140", ] - - cflags = [ - "-frtti", - "-fexceptions", - ] - cflags_cc = cflags } diff --git a/screenhandler/test/unittest/screenhandler/include/dscreen_handler_test.h b/screenhandler/test/unittest/screenhandler/include/dscreen_handler_test.h index 3e0ea6e7..73c16c82 100644 --- a/screenhandler/test/unittest/screenhandler/include/dscreen_handler_test.h +++ b/screenhandler/test/unittest/screenhandler/include/dscreen_handler_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 @@ -19,11 +19,9 @@ #include #include -#define private public #include "dscreen_handler.h" #include "dscreen_errcode.h" #include "ihardware_handler.h" -#undef private namespace OHOS { namespace DistributedHardware { diff --git a/screenhandler/test/unittest/screenhandler/src/dscreen_handler_test.cpp b/screenhandler/test/unittest/screenhandler/src/dscreen_handler_test.cpp index e1268a64..9230dfca 100644 --- a/screenhandler/test/unittest/screenhandler/src/dscreen_handler_test.cpp +++ b/screenhandler/test/unittest/screenhandler/src/dscreen_handler_test.cpp @@ -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 @@ -13,10 +13,8 @@ * limitations under the License. */ -#define private public -#include "dscreen_constants.h" #include "dscreen_handler_test.h" -#undef private +#include "dscreen_constants.h" using namespace testing; using namespace testing::ext; @@ -42,9 +40,11 @@ HWTEST_F(DScreenHandlerTest, Initialize_001, TestSize.Level1) int32_t ret = DScreenHandler::GetInstance().Initialize(); uint64_t screenId = SCREEN_ID_DEFAULT; DScreenHandler::GetInstance().screenListener_->OnConnect(screenId); + screenId = 9999999; + DScreenHandler::GetInstance().screenListener_->OnConnect(screenId); + DScreenHandler::GetInstance().screenListener_->OnDisconnect(screenId); screenId = 1; DScreenHandler::GetInstance().screenListener_->OnConnect(screenId); - const std::string dhId = "dhId"; const std::string attr = "attr"; const std::string subtype = "screen"; @@ -57,6 +57,31 @@ HWTEST_F(DScreenHandlerTest, Initialize_001, TestSize.Level1) EXPECT_EQ(DH_SUCCESS, ret); } +/** + * @tc.name: ByteCalculate_001 + * @tc.desc: Verify the ByteCalculate function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DScreenHandlerTest, ByteCalculate_001, TestSize.Level1) +{ + uint32_t ret = DScreenHandler::GetInstance().screenListener_->ByteCalculate(320); + EXPECT_EQ(320, ret); + ret = DScreenHandler::GetInstance().screenListener_->ByteCalculate(312); + EXPECT_EQ(320, ret); +} + +/** + * @tc.name: Query_001 + * @tc.desc: Verify the Query function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DScreenHandlerTest, Query_001, TestSize.Level1) +{ + EXPECT_EQ(DScreenHandler::GetInstance().Query().empty(), false); +} + /** * @tc.name: RegisterPluginListener_001 * @tc.desc: Verify the RegisterPluginListener function. @@ -67,8 +92,9 @@ HWTEST_F(DScreenHandlerTest, RegisterPluginListener_001, TestSize.Level1) { std::shared_ptr listener = std::make_shared(); DScreenHandler::GetInstance().RegisterPluginListener(listener); - EXPECT_EQ(listener, DScreenHandler::GetInstance().listener_); + DScreenHandler::GetInstance().UnRegisterPluginListener(); + EXPECT_EQ(nullptr, DScreenHandler::GetInstance().listener_); } /** diff --git a/services/common/test/unittest/databuffer/BUILD.gn b/services/common/test/unittest/databuffer/BUILD.gn index 4ca0bf54..63275332 100644 --- a/services/common/test/unittest/databuffer/BUILD.gn +++ b/services/common/test/unittest/databuffer/BUILD.gn @@ -41,7 +41,10 @@ ohos_unittest("DataBufferTest") { "${services_path}/common/test/unittest/databuffer/data_buffer_test.cpp", ] - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "${common_path}/test/unittest/resource:dscreen_unittest_public_config", + ] deps = [ "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", diff --git a/services/common/test/unittest/databuffer/data_buffer_test.cpp b/services/common/test/unittest/databuffer/data_buffer_test.cpp index d6afac5a..0ff100e8 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-2023 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 @@ -13,10 +13,8 @@ * limitations under the License. */ -#define private public #include "data_buffer_test.h" #include "dscreen_errcode.h" -#undef private using namespace testing::ext; @@ -31,7 +29,12 @@ void DataBufferTest::SetUp() dataBuffer_ = std::make_shared(capacity); } -void DataBufferTest::TearDown() {} +void DataBufferTest::TearDown() +{ + if (dataBuffer_ != nullptr) { + dataBuffer_ = nullptr; + } +} /** * @tc.name: Capacity_001 @@ -57,6 +60,30 @@ HWTEST_F(DataBufferTest, Data_001, TestSize.Level1) EXPECT_NE(nullptr, actual); } +/** + * @tc.name: SetDataNumber_001 + * @tc.desc: Verify the SetDataNumber function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DataBufferTest, SetDataNumber_001, TestSize.Level1) +{ + dataBuffer_->SetDataNumber(10); + EXPECT_EQ(10, dataBuffer_->DataNumber()); +} + +/** + * @tc.name: SetDataType_001 + * @tc.desc: Verify the SetDataType function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DataBufferTest, SetDataType_001, TestSize.Level1) +{ + dataBuffer_->SetDataType(VIDEO_PART_SCREEN_DATA); + EXPECT_EQ(VIDEO_PART_SCREEN_DATA, dataBuffer_->DataType()); +} + /** * @tc.name: ResetCapcity_001 * @tc.desc: Verify the ResetCapcity function. @@ -110,6 +137,22 @@ HWTEST_F(DataBufferTest, AddData_002, TestSize.Level1) delete [] inputData; } +/** + * @tc.name: AddData_003 + * @tc.desc: Verify the AddData function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DataBufferTest, AddData_003, TestSize.Level1) +{ + unsigned char *inputData = new unsigned char[10] {0}; + dataBuffer_->~DataBuffer(); + EXPECT_EQ(nullptr, dataBuffer_->data_); + dataBuffer_->AddData(10, inputData); + EXPECT_NE(10, dataBuffer_->Capacity()); + delete [] inputData; +} + /** * @tc.name: GetData_001 * @tc.desc: Verify the GetData function. @@ -122,5 +165,45 @@ HWTEST_F(DataBufferTest, GetData_001, TestSize.Level1) EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, dataBuffer_->GetData(10, 10, outputData)); delete [] outputData; } + +/** + * @tc.name: GetData_002 + * @tc.desc: Verify the GetData function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DataBufferTest, GetData_002, TestSize.Level1) +{ + uint8_t *outputData = nullptr; + EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, dataBuffer_->GetData(0, 0, outputData)); +} + +/** + * @tc.name: GetData_003 + * @tc.desc: Verify the GetData function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DataBufferTest, GetData_003, TestSize.Level1) +{ + uint8_t *outputData = new uint8_t[1] {0}; + dataBuffer_->~DataBuffer(); + EXPECT_EQ(nullptr, dataBuffer_->data_); + EXPECT_NE(DH_SUCCESS, dataBuffer_->GetData(0, 0, outputData)); + delete [] outputData; +} + +/** + * @tc.name: AddDirtyRect_001 + * @tc.desc: Verify the AddDirtyRect function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(DataBufferTest, AddDirtyRect_001, TestSize.Level1) +{ + DirtyRect rect = {1, 1, 1, 1, 1}; + dataBuffer_->AddDirtyRect(rect); + EXPECT_NE(0, dataBuffer_->GetDirtyRectVec().size()); +} } // 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 index e239ccc8..d51a7bfd 100644 --- a/services/common/test/unittest/decision_center/BUILD.gn +++ b/services/common/test/unittest/decision_center/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023 Huawei Device Co., Ltd. +# Copyright (c) 2023-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 @@ -26,9 +26,11 @@ config("module_private_config") { "${services_path}/common/databuffer/include", "${services_path}/common/decision_center/include", "${services_path}/common/imageJpeg/include", + "${services_path}/common/screen_channel/include", "${services_path}/common/utils/include", "${services_path}/screentransport/screensourceprocessor/encoder/include", "${services_path}/screentransport/screensourceprocessor/include", + "${services_path}/screentransport/screensourcetrans/include", ] } @@ -43,7 +45,10 @@ ohos_unittest("ScreenDecisionCenterTest") { sources = [ "${services_path}/common/test/unittest/decision_center/screen_decision_center_test.cpp" ] - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "${common_path}/test/unittest/resource:dscreen_unittest_public_config", + ] deps = [ "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans" ] 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 7ecc3eb4..8fb13cf7 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) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -12,7 +12,6 @@ * 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" @@ -20,7 +19,7 @@ #include "iimage_source_processor.h" #include "iimage_source_processor_listener.h" #include "jpeg_image_processor.h" -#undef private +#include "screen_source_trans.h" using namespace testing; using namespace testing::ext; @@ -41,7 +40,12 @@ void ScreenDecisionCenterTest::SetUp(void) decision = std::make_shared(param_); } -void ScreenDecisionCenterTest::TearDown(void) {} +void ScreenDecisionCenterTest::TearDown(void) +{ + if (decision != nullptr) { + decision = nullptr; + } +} /** * @tc.name: IsDirtyRectValid_001 @@ -65,10 +69,42 @@ HWTEST_F(ScreenDecisionCenterTest, IsDirtyRectValid_001, TestSize.Level1) HWTEST_F(ScreenDecisionCenterTest, IsDirtyRectValid_002, TestSize.Level1) { std::vector damages; - OHOS::Rect damage = {-1, -1, 0, 0}; + OHOS::Rect damage = {-1, 0, 0, 0}; damages.push_back(damage); int32_t ret = decision->IsDirtyRectValid(damages); EXPECT_EQ(false, ret); + + damages.clear(); + decision->configParam_.SetScreenWidth(1); + damage = {2, 0, 0, 0}; + damages.push_back(damage); + ret = decision->IsDirtyRectValid(damages); + EXPECT_EQ(false, ret); + + damages.clear(); + decision->configParam_.SetScreenHeight(1); + damage = {1, -1, 0, 0}; + damages.push_back(damage); + ret = decision->IsDirtyRectValid(damages); + EXPECT_EQ(false, ret); + + damages.clear(); + damage = {1, 2, 0, 0}; + damages.push_back(damage); + ret = decision->IsDirtyRectValid(damages); + EXPECT_EQ(false, ret); + + damages.clear(); + damage = {1, 0, 0, 0}; + damages.push_back(damage); + ret = decision->IsDirtyRectValid(damages); + EXPECT_EQ(false, ret); + + damages.clear(); + damage = {0, 1, 0, 0}; + damages.push_back(damage); + ret = decision->IsDirtyRectValid(damages); + EXPECT_EQ(true, ret); } /** @@ -80,25 +116,36 @@ HWTEST_F(ScreenDecisionCenterTest, IsDirtyRectValid_002, TestSize.Level1) HWTEST_F(ScreenDecisionCenterTest, IsDirtyRectValid_003, TestSize.Level1) { std::vector damages; - OHOS::Rect damage = {1, 2, 1, 2}; + decision->configParam_.SetScreenWidth(1); + decision->configParam_.SetScreenHeight(1); + OHOS::Rect damage = {0, 0, -1, 0}; 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.clear(); + damage = {0, 0, 10, 0}; damages.push_back(damage); - int32_t ret = decision->IsDirtyRectValid(damages); + ret = decision->IsDirtyRectValid(damages); + EXPECT_EQ(false, ret); + + damages.clear(); + damage = {0, 0, 0, -1}; + damages.push_back(damage); + ret = decision->IsDirtyRectValid(damages); + EXPECT_EQ(false, ret); + + damages.clear(); + damage = {0, 0, 0, 10}; + damages.push_back(damage); + ret = decision->IsDirtyRectValid(damages); EXPECT_EQ(false, ret); + + damages.clear(); + damage = {0, 0, 0, 0}; + damages.push_back(damage); + ret = decision->IsDirtyRectValid(damages); + EXPECT_EQ(true, ret); } /** @@ -107,11 +154,12 @@ HWTEST_F(ScreenDecisionCenterTest, IsDirtyRectValid_004, TestSize.Level1) * @tc.type: FUNC * @tc.require: Issue Number */ -HWTEST_F(ScreenDecisionCenterTest, IsDirtyRectValid_005, TestSize.Level1) +HWTEST_F(ScreenDecisionCenterTest, IsDirtyRectValid_004, TestSize.Level1) { std::vector damages; OHOS::Rect damage = {2, 2, 2, 2}; damages.push_back(damage); + damages.push_back(damage); int32_t ret = decision->IsDirtyRectValid(damages); EXPECT_EQ(true, ret); } @@ -186,6 +234,47 @@ HWTEST_F(ScreenDecisionCenterTest, InputBufferImage_001, TestSize.Level1) EXPECT_EQ(ERR_DH_SCREEN_SURFACE_BUFFER_INVALIED, ret); } +/** + * @tc.name: InputBufferImage_002 + * @tc.desc: Verify the InputBufferImage function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenDecisionCenterTest, InputBufferImage_002, TestSize.Level1) +{ + std::vector damages; + sptr buffer = SurfaceBuffer::Create(); + decision->imageProcessor_ = std::make_shared(); + decision->imageJpeg_ = std::make_shared(param_); + int32_t ret = decision->InputBufferImage(buffer, damages); + EXPECT_EQ(DH_SUCCESS, ret); + + OHOS::Rect damage = {0, 0, 0, 0}; + damages.push_back(damage); + decision->frameCount_ = ScreenDecisionCenter::MIN_SURPPORT_FRAME_COUNT - 1; + ret = decision->InputBufferImage(buffer, damages); + EXPECT_EQ(DH_SUCCESS, ret); + + decision->frameCount_ = ScreenDecisionCenter::MIN_SURPPORT_FRAME_COUNT; + decision->sendFullTime_ = time(nullptr) - ScreenDecisionCenter::FORCE_FULL_IMAGE_TIME_INTERAL - 1; + ret = decision->InputBufferImage(buffer, damages); + EXPECT_EQ(DH_SUCCESS, ret); + + damages.clear(); + damage = {-1, 0, 0, 0}; + damages.push_back(damage); + decision->sendFullTime_ = time(nullptr); + ret = decision->InputBufferImage(buffer, damages); + EXPECT_EQ(DH_SUCCESS, ret); + + damages.clear(); + damage = {0, 0, 2600, 2780}; + damages.push_back(damage); + decision->sendFullTime_ = time(nullptr); + ret = decision->InputBufferImage(buffer, damages); + EXPECT_EQ(DH_SUCCESS, ret); +} + /** * @tc.name: ConfigureDecisionCenter_001 * @tc.desc: Verify the ConfigureDecisionCenter function. @@ -200,6 +289,34 @@ HWTEST_F(ScreenDecisionCenterTest, ConfigureDecisionCenter_001, TestSize.Level1) EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, ret); } +/** + * @tc.name: ConfigureDecisionCenter_002 + * @tc.desc: Verify the ConfigureDecisionCenter function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenDecisionCenterTest, ConfigureDecisionCenter_002, TestSize.Level1) +{ + std::shared_ptr listener = std::make_shared(); + std::shared_ptr imageProcessor = nullptr; + int32_t ret = decision->ConfigureDecisionCenter(listener, imageProcessor); + EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, ret); +} + +/** + * @tc.name: ConfigureDecisionCenter_003 + * @tc.desc: Verify the ConfigureDecisionCenter function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenDecisionCenterTest, ConfigureDecisionCenter_003, TestSize.Level1) +{ + std::shared_ptr listener = std::make_shared(); + std::shared_ptr imageProcessor = std::make_shared(); + int32_t ret = decision->ConfigureDecisionCenter(listener, imageProcessor); + EXPECT_EQ(DH_SUCCESS, ret); +} + /** * @tc.name: SetJpegSurface_001 * @tc.desc: Verify the SetJpegSurface function. 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 index 36bd4761..b83fc644 100644 --- a/services/common/test/unittest/decision_center/screen_decision_center_test.h +++ b/services/common/test/unittest/decision_center/screen_decision_center_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -30,6 +30,27 @@ public: VideoParam param_; std::shared_ptr decision = nullptr; }; + +class ImageSourceProcessorStub : public ImageSourceProcessor { +public: + ImageSourceProcessorStub() = default; + ~ImageSourceProcessorStub() = default; + int32_t ProcessFullImage(sptr &surfaceBuffer) + { + return 0; + } +}; + +class JpegImageProcessorStub : public JpegImageProcessor { +public: + explicit JpegImageProcessorStub(const VideoParam &configParam) : JpegImageProcessor(configParam) {}; + ~JpegImageProcessorStub() = default; + + int32_t ProcessDamageSurface(sptr &surfaceBuffer, const std::vector &damages) + { + return 0; + } +}; } // 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 index fe49cf11..cfb5035a 100644 --- a/services/common/test/unittest/imageJpeg/BUILD.gn +++ b/services/common/test/unittest/imageJpeg/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023 Huawei Device Co., Ltd. +# Copyright (c) 2023-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 @@ -42,7 +42,10 @@ ohos_unittest("JpegImageProcessorTest") { sources = [ "${services_path}/common/test/unittest/imageJpeg/jpeg_image_processor_test.cpp" ] - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "${common_path}/test/unittest/resource:dscreen_unittest_public_config", + ] deps = [ "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans" ] 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 b26eb6d1..7addbd28 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) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -12,13 +12,11 @@ * 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; diff --git a/services/common/test/unittest/utils/BUILD.gn b/services/common/test/unittest/utils/BUILD.gn index cd895f74..58f2bbfc 100644 --- a/services/common/test/unittest/utils/BUILD.gn +++ b/services/common/test/unittest/utils/BUILD.gn @@ -44,7 +44,10 @@ ohos_unittest("UtilsTest") { "${services_path}/common/test/unittest/utils/video_param_test.cpp", ] - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "${common_path}/test/unittest/resource:dscreen_unittest_public_config", + ] deps = [ "${services_path}/screenservice/sinkservice:distributed_screen_sink", diff --git a/services/common/test/unittest/utils/dscreen_fwkkit_test.cpp b/services/common/test/unittest/utils/dscreen_fwkkit_test.cpp index 5c6a91f4..63fa8fc9 100644 --- a/services/common/test/unittest/utils/dscreen_fwkkit_test.cpp +++ b/services/common/test/unittest/utils/dscreen_fwkkit_test.cpp @@ -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 @@ -13,11 +13,9 @@ * limitations under the License. */ -#define private public #include "dscreen_fwkkit_test.h" #include "distributed_hardware_fwk_kit.h" #include "dscreen_fwkkit.h" -#undef private using namespace testing::ext; diff --git a/services/common/test/unittest/utils/dscreen_hidumper_test.cpp b/services/common/test/unittest/utils/dscreen_hidumper_test.cpp index b3d0d82e..c74ad12a 100644 --- a/services/common/test/unittest/utils/dscreen_hidumper_test.cpp +++ b/services/common/test/unittest/utils/dscreen_hidumper_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -13,9 +13,7 @@ * limitations under the License. */ -#define private public #include "dscreen_hidumper_test.h" -#undef private using namespace testing::ext; diff --git a/services/common/test/unittest/utils/dscreen_maprelation_test.cpp b/services/common/test/unittest/utils/dscreen_maprelation_test.cpp index 0e033631..edfa7ff9 100644 --- a/services/common/test/unittest/utils/dscreen_maprelation_test.cpp +++ b/services/common/test/unittest/utils/dscreen_maprelation_test.cpp @@ -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 @@ -13,9 +13,7 @@ * limitations under the License. */ -#define private public #include "dscreen_maprelation_test.h" -#undef private using json = nlohmann::json; diff --git a/services/common/test/unittest/utils/video_param_test.cpp b/services/common/test/unittest/utils/video_param_test.cpp index 49578400..0aa27050 100644 --- a/services/common/test/unittest/utils/video_param_test.cpp +++ b/services/common/test/unittest/utils/video_param_test.cpp @@ -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 @@ -13,9 +13,7 @@ * limitations under the License. */ -#define private public #include "video_param_test.h" -#undef private using json = nlohmann::json; @@ -23,7 +21,7 @@ using namespace testing::ext; namespace OHOS { namespace DistributedHardware { -constexpr static uint32_t videoDataNum = 480; +constexpr static uint32_t VIDEO_DATA_NUM = 480; void VideoParamTest::SetUpTestCase(void) {} void VideoParamTest::TearDownTestCase(void) {} @@ -147,10 +145,10 @@ HWTEST_F(VideoParamTest, to_json_001, TestSize.Level1) uint8_t codecType = DEFAULT_CODECTYPE; VideoParam videoParam; - videoParam.SetScreenWidth(videoDataNum); - videoParam.SetScreenHeight(videoDataNum); - videoParam.SetVideoWidth(videoDataNum); - videoParam.SetVideoHeight(videoDataNum); + videoParam.SetScreenWidth(VIDEO_DATA_NUM); + videoParam.SetScreenHeight(VIDEO_DATA_NUM); + videoParam.SetVideoWidth(VIDEO_DATA_NUM); + videoParam.SetVideoHeight(VIDEO_DATA_NUM); videoParam.SetFps(fps); videoParam.SetVideoFormat(videoFormat); videoParam.SetCodecType(codecType); @@ -158,7 +156,7 @@ HWTEST_F(VideoParamTest, to_json_001, TestSize.Level1) uint32_t jsonVideoWidth = 0; j.at(KEY_VIDEO_WIDTH).get_to(jsonVideoWidth); - EXPECT_EQ(videoDataNum, jsonVideoWidth); + EXPECT_EQ(VIDEO_DATA_NUM, jsonVideoWidth); } /** diff --git a/services/screenclient/test/unittest/BUILD.gn b/services/screenclient/test/unittest/BUILD.gn index d46c5a7e..0e19567d 100644 --- a/services/screenclient/test/unittest/BUILD.gn +++ b/services/screenclient/test/unittest/BUILD.gn @@ -40,7 +40,10 @@ ohos_unittest("ScreenClientTest") { "${services_path}/screenclient/test/unittest/src/screen_client_window_adapter_test.cpp", ] - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "${common_path}/test/unittest/resource:dscreen_unittest_public_config", + ] deps = [ "${common_path}:distributed_screen_utils", diff --git a/services/screenclient/test/unittest/src/screen_client_test.cpp b/services/screenclient/test/unittest/src/screen_client_test.cpp index 0b7ad4d6..a6903ff6 100644 --- a/services/screenclient/test/unittest/src/screen_client_test.cpp +++ b/services/screenclient/test/unittest/src/screen_client_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 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 @@ -13,9 +13,7 @@ * limitations under the License. */ -#define private public #include "screen_client_test.h" -#undef private using namespace testing::ext; 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 ac490a27..0c09a7cd 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 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 @@ -13,9 +13,7 @@ * limitations under the License. */ -#define private public #include "screen_client_window_adapter_test.h" -#undef private using namespace testing::ext; diff --git a/services/screendemo/decoder_demo.cpp b/services/screendemo/decoder_demo.cpp index cb5b74a2..201c9aa1 100644 --- a/services/screendemo/decoder_demo.cpp +++ b/services/screendemo/decoder_demo.cpp @@ -233,8 +233,8 @@ void VDecDemo::InputFunc() while (isRunning_.load()) { unique_lock lock(signal_->inMutex_); - signal_->inCond_.wait(lock, [this]() { return signal_->inQueue_.size() > 0 - && signal_->availableInputBufferQueue_.size() > 0; }); + signal_->inCond_.wait( + lock, [this]() { return signal_->inQueue_.size() > 0 && signal_->availableInputBufferQueue_.size() > 0; }); if (!isRunning_.load()) { break; diff --git a/services/screendemo/test.cpp b/services/screendemo/test.cpp index 64676981..f0791488 100644 --- a/services/screendemo/test.cpp +++ b/services/screendemo/test.cpp @@ -46,14 +46,14 @@ using namespace OHOS::MediaAVCodec; using namespace OHOS::Security::AccessToken; namespace { - static char const *g_pkgName = "ohos.dsoftbus.tool"; + static char const *DSOFTBUS_TOOL_PKG_NAME = "ohos.dsoftbus.tool"; const uint32_t MAX_WINDOW_WIDTH = 2560; const uint32_t MAX_WINDOW_HEIGHT = 2772; const uint32_t DCODE_WIDTH = 1920; const uint32_t DCODE_HEIGHT = 1080; } -vector> QueryRemoteScreenInfo() +static vector> QueryRemoteScreenInfo() { vector> allScreens; ScreenManager::GetInstance().GetAllScreens(allScreens); @@ -235,14 +235,14 @@ static void PrintNodeProperty(NodeBasicInfo *nodeInfo) printf("NetworkId = %s\n", GetAnonyString(nodeInfo->networkId).c_str()); NodeDeviceInfoKey key = NODE_KEY_UDID; unsigned char udid[UDID_BUF_LEN] = {0}; - if (GetNodeKeyInfo(g_pkgName, nodeInfo->networkId, key, udid, UDID_BUF_LEN) != 0) { + if (GetNodeKeyInfo(DSOFTBUS_TOOL_PKG_NAME, nodeInfo->networkId, key, udid, UDID_BUF_LEN) != 0) { printf("GetNodeKeyInfo Fail!\n"); } else { printf("Udid = %s\n", GetAnonyString(reinterpret_cast(udid)).c_str()); } key = NODE_KEY_UUID; unsigned char uuid[UUID_BUF_LEN] = {0}; - if (GetNodeKeyInfo(g_pkgName, nodeInfo->networkId, key, uuid, UUID_BUF_LEN) != 0) { + if (GetNodeKeyInfo(DSOFTBUS_TOOL_PKG_NAME, nodeInfo->networkId, key, uuid, UUID_BUF_LEN) != 0) { printf("GetNodeKeyInfo Fail!\n"); } else { printf("Uuid = %s\n", GetAnonyString(reinterpret_cast(udid)).c_str()); @@ -273,13 +273,13 @@ static void QueryRemoteDeviceInfo() NodeBasicInfo *remoteNodeInfo = nullptr; int32_t infoNum = 0; printf("-----------Local Device Info------\n"); - if (GetLocalNodeDeviceInfo(g_pkgName, &localNodeinfo) != 0) { + if (GetLocalNodeDeviceInfo(DSOFTBUS_TOOL_PKG_NAME, &localNodeinfo) != 0) { printf("LnnGetLocalNodeInfo Fail!\n"); return; } PrintNodeProperty(&localNodeinfo); printf("-------Remote Device info---------\n"); - if (GetAllNodeDeviceInfo(g_pkgName, &remoteNodeInfo, &infoNum) != 0) { + if (GetAllNodeDeviceInfo(DSOFTBUS_TOOL_PKG_NAME, &remoteNodeInfo, &infoNum) != 0) { printf("GetAllNodeDeviceInfo Fail!\n"); return; } diff --git a/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/onchange_fuzzer/BUILD.gn b/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/onchange_fuzzer/BUILD.gn index e7eaffc6..fa32683e 100644 --- a/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/onchange_fuzzer/BUILD.gn +++ b/services/screenservice/test/fuzztest/sourceservice/dscreenmgr/onchange_fuzzer/BUILD.gn @@ -34,12 +34,8 @@ ohos_fuzztest("OnChangeFuzzTest") { "${services_path}/screentransport/screensourcetrans/include", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] sources = [ "onchange_fuzzer.cpp" ] diff --git a/services/screenservice/test/unittest/sinkservice/dscreenservice/BUILD.gn b/services/screenservice/test/unittest/sinkservice/dscreenservice/BUILD.gn index aa2bd625..f29179a5 100644 --- a/services/screenservice/test/unittest/sinkservice/dscreenservice/BUILD.gn +++ b/services/screenservice/test/unittest/sinkservice/dscreenservice/BUILD.gn @@ -39,7 +39,10 @@ ohos_unittest("DScreenSinkStubTest") { sources = [ "${services_path}/screenservice/test/unittest/sinkservice/dscreenservice/src/dscreen_sink_stub_test.cpp" ] - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "${common_path}/test/unittest/resource:dscreen_unittest_public_config", + ] deps = [ "${interfaces_path}/innerkits/native_cpp/screen_sink:distributed_screen_sink_sdk", diff --git a/services/screenservice/test/unittest/sinkservice/dscreenservice/src/dscreen_sink_stub_test.cpp b/services/screenservice/test/unittest/sinkservice/dscreenservice/src/dscreen_sink_stub_test.cpp index baab2b08..dd4bdb5a 100644 --- a/services/screenservice/test/unittest/sinkservice/dscreenservice/src/dscreen_sink_stub_test.cpp +++ b/services/screenservice/test/unittest/sinkservice/dscreenservice/src/dscreen_sink_stub_test.cpp @@ -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 @@ -84,7 +84,7 @@ HWTEST_F(DScreenSinkStubTest, InitSink_001, TestSize.Level1) int32_t ret = sinkProxy.InitSink("params000"); EXPECT_EQ(DH_SUCCESS, ret); - + ret = sinkProxy.InitSink(""); EXPECT_EQ(ERR_DH_SCREEN_INPUT_PARAM_INVALID, ret); } diff --git a/services/screenservice/test/unittest/sinkservice/screenregionmgr/1.0/include/screenregion_test.h b/services/screenservice/test/unittest/sinkservice/screenregionmgr/1.0/include/screenregion_test.h index ab55fff9..cf6b77c4 100644 --- a/services/screenservice/test/unittest/sinkservice/screenregionmgr/1.0/include/screenregion_test.h +++ b/services/screenservice/test/unittest/sinkservice/screenregionmgr/1.0/include/screenregion_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 @@ -19,11 +19,9 @@ #include #include -#define private public #include "dscreen_errcode.h" #include "screen_sink_trans.h" #include "1.0/include/screenregion.h" -#undef private namespace OHOS { namespace DistributedHardware { diff --git a/services/screenservice/test/unittest/sinkservice/screenregionmgr/1.0/include/screenregionmgr_test.h b/services/screenservice/test/unittest/sinkservice/screenregionmgr/1.0/include/screenregionmgr_test.h index 32e8b6cf..101e3de0 100644 --- a/services/screenservice/test/unittest/sinkservice/screenregionmgr/1.0/include/screenregionmgr_test.h +++ b/services/screenservice/test/unittest/sinkservice/screenregionmgr/1.0/include/screenregionmgr_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 @@ -19,10 +19,8 @@ #include #include -#define private public #include "dscreen_errcode.h" #include "1.0/include/screenregionmgr.h" -#undef private namespace OHOS { namespace DistributedHardware { diff --git a/services/screenservice/test/unittest/sinkservice/screenregionmgr/2.0/include/av_receiver_engine_adapter_test.h b/services/screenservice/test/unittest/sinkservice/screenregionmgr/2.0/include/av_receiver_engine_adapter_test.h index 741f0080..c3dccae2 100644 --- a/services/screenservice/test/unittest/sinkservice/screenregionmgr/2.0/include/av_receiver_engine_adapter_test.h +++ b/services/screenservice/test/unittest/sinkservice/screenregionmgr/2.0/include/av_receiver_engine_adapter_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -19,10 +19,8 @@ #include #include -#define private public #include "dscreen_errcode.h" #include "2.0/include/av_receiver_engine_adapter.h" -#undef private namespace OHOS { namespace DistributedHardware { diff --git a/services/screenservice/test/unittest/sinkservice/screenregionmgr/2.0/include/screenregion_test.h b/services/screenservice/test/unittest/sinkservice/screenregionmgr/2.0/include/screenregion_test.h index 5295a4e6..36998dd2 100644 --- a/services/screenservice/test/unittest/sinkservice/screenregionmgr/2.0/include/screenregion_test.h +++ b/services/screenservice/test/unittest/sinkservice/screenregionmgr/2.0/include/screenregion_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -19,11 +19,9 @@ #include #include -#define private public #include "dscreen_errcode.h" #include "screen_sink_trans.h" #include "2.0/include/screenregion.h" -#undef private namespace OHOS { namespace DistributedHardware { diff --git a/services/screenservice/test/unittest/sinkservice/screenregionmgr/2.0/include/screenregionmgr_test.h b/services/screenservice/test/unittest/sinkservice/screenregionmgr/2.0/include/screenregionmgr_test.h index d93f73ef..a61b78c4 100644 --- a/services/screenservice/test/unittest/sinkservice/screenregionmgr/2.0/include/screenregionmgr_test.h +++ b/services/screenservice/test/unittest/sinkservice/screenregionmgr/2.0/include/screenregionmgr_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -20,9 +20,7 @@ #include #include "dscreen_errcode.h" -#define private public #include "2.0/include/screenregionmgr.h" -#undef private namespace OHOS { namespace DistributedHardware { diff --git a/services/screenservice/test/unittest/sinkservice/screenregionmgr/BUILD.gn b/services/screenservice/test/unittest/sinkservice/screenregionmgr/BUILD.gn index 59b6980d..227e32ce 100644 --- a/services/screenservice/test/unittest/sinkservice/screenregionmgr/BUILD.gn +++ b/services/screenservice/test/unittest/sinkservice/screenregionmgr/BUILD.gn @@ -57,7 +57,10 @@ ohos_unittest("DscreenRegionMgrTest") { "${services_path}/screenservice/test/unittest/sinkservice/screenregionmgr/2.0/src/screenregionmgr_test.cpp", ] - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "${common_path}/test/unittest/resource:dscreen_unittest_public_config", + ] deps = [ "${services_path}/screenclient:distributed_screen_client", diff --git a/services/screenservice/test/unittest/sourceservice/dscreenmgr/1.0/include/dscreen_manager_test.h b/services/screenservice/test/unittest/sourceservice/dscreenmgr/1.0/include/dscreen_manager_test.h index 679bc085..2b2f057e 100644 --- a/services/screenservice/test/unittest/sourceservice/dscreenmgr/1.0/include/dscreen_manager_test.h +++ b/services/screenservice/test/unittest/sourceservice/dscreenmgr/1.0/include/dscreen_manager_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 @@ -19,10 +19,8 @@ #include #include -#define private public #include "dscreen_errcode.h" #include "1.0/include/dscreen_manager.h" -#undef private namespace OHOS { namespace DistributedHardware { diff --git a/services/screenservice/test/unittest/sourceservice/dscreenmgr/1.0/include/dscreen_test.h b/services/screenservice/test/unittest/sourceservice/dscreenmgr/1.0/include/dscreen_test.h index 10a0a29b..7b4e3c23 100644 --- a/services/screenservice/test/unittest/sourceservice/dscreenmgr/1.0/include/dscreen_test.h +++ b/services/screenservice/test/unittest/sourceservice/dscreenmgr/1.0/include/dscreen_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 @@ -19,9 +19,7 @@ #include #include -#define private public #include "1.0/include/dscreen.h" -#undef private namespace OHOS { namespace DistributedHardware { namespace V1_0 { diff --git a/services/screenservice/test/unittest/sourceservice/dscreenmgr/1.0/src/dscreen_test.cpp b/services/screenservice/test/unittest/sourceservice/dscreenmgr/1.0/src/dscreen_test.cpp index 2f0c494a..bc5b6873 100644 --- a/services/screenservice/test/unittest/sourceservice/dscreenmgr/1.0/src/dscreen_test.cpp +++ b/services/screenservice/test/unittest/sourceservice/dscreenmgr/1.0/src/dscreen_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 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 @@ -18,7 +18,6 @@ #include "nativetoken_kit.h" #include "token_setproc.h" -#define private public #include "dscreen_constants.h" #include "dscreen_errcode.h" #include "1.0/include/dscreen_manager.h" @@ -26,7 +25,6 @@ #include "dscreen_util.h" #include "video_param.h" #include "screen_source_trans.h" -#undef private using namespace testing; using namespace testing::ext; @@ -34,7 +32,7 @@ using namespace testing::ext; namespace OHOS { namespace DistributedHardware { namespace V1_0 { -constexpr static uint32_t videoDataNum = 480; +constexpr static uint32_t VIDEO_DATA_NUM = 480; void DScreenTestV1::SetUpTestCase(void) {} void DScreenTestV1::TearDownTestCase(void) {} @@ -48,10 +46,10 @@ void DScreenTestV1::SetUp(void) dScreen_->videoParam_ = std::make_shared(); dScreen_->videoParam_->SetCodecType(VIDEO_CODEC_TYPE_VIDEO_H264); dScreen_->videoParam_->SetVideoFormat(VIDEO_DATA_FORMAT_YUVI420); - dScreen_->videoParam_->SetVideoHeight(videoDataNum); - dScreen_->videoParam_->SetVideoWidth(videoDataNum); - dScreen_->videoParam_->SetScreenHeight(videoDataNum); - dScreen_->videoParam_->SetScreenWidth(videoDataNum); + dScreen_->videoParam_->SetVideoHeight(VIDEO_DATA_NUM); + dScreen_->videoParam_->SetVideoWidth(VIDEO_DATA_NUM); + dScreen_->videoParam_->SetScreenHeight(VIDEO_DATA_NUM); + dScreen_->videoParam_->SetScreenWidth(VIDEO_DATA_NUM); dScreen_->videoParam_->SetFps(DEFAULT_FPS); dScreen_->devId_ = "peerDevId"; } diff --git a/services/screenservice/test/unittest/sourceservice/dscreenmgr/1.0/src/screen_manager_adapter_test.cpp b/services/screenservice/test/unittest/sourceservice/dscreenmgr/1.0/src/screen_manager_adapter_test.cpp index f127296b..e10ff981 100644 --- a/services/screenservice/test/unittest/sourceservice/dscreenmgr/1.0/src/screen_manager_adapter_test.cpp +++ b/services/screenservice/test/unittest/sourceservice/dscreenmgr/1.0/src/screen_manager_adapter_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 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 @@ -15,9 +15,7 @@ #include "1.0/include/screen_manager_adapter_test.h" -#define private public #include "common/include/screen_manager_adapter.h" -#undef private #include "dscreen_constants.h" #include "dscreen_errcode.h" #include "dscreen_util.h" @@ -31,7 +29,7 @@ using namespace testing::ext; namespace OHOS { namespace DistributedHardware { -constexpr static uint32_t videoDataNum = 480; +constexpr static uint32_t VIDEO_DATA_NUM = 480; void DScreenManagerAdapterTest::SetUpTestCase(void) {} void DScreenManagerAdapterTest::TearDownTestCase(void) {} @@ -256,14 +254,14 @@ HWTEST_F(DScreenManagerAdapterTest, GetMapRelation_002, TestSize.Level1) std::string dhId = "dhId"; ScreenMgrAdapter::GetInstance().screenIdMap_.clear(); std::shared_ptr videoParam = std::make_shared(); - videoParam->SetScreenWidth(videoDataNum); - videoParam->SetScreenHeight(videoDataNum); + videoParam->SetScreenWidth(VIDEO_DATA_NUM); + videoParam->SetScreenHeight(VIDEO_DATA_NUM); uint64_t screenId = ScreenMgrAdapter::GetInstance().CreateVirtualScreen(devId, dhId, videoParam); std::shared_ptr ret = ScreenMgrAdapter::GetInstance().GetMapRelation(screenId); - DisablePermissionAccess(tokenId_); - EXPECT_NE(nullptr, ret); ScreenMgrAdapter::GetInstance().RemoveVirtualScreen(screenId); ScreenMgrAdapter::GetInstance().screenIdMap_.clear(); + DisablePermissionAccess(tokenId_); + EXPECT_NE(nullptr, ret); } } } \ No newline at end of file diff --git a/services/screenservice/test/unittest/sourceservice/dscreenmgr/2.0/include/av_sender_engine_adapter_test.h b/services/screenservice/test/unittest/sourceservice/dscreenmgr/2.0/include/av_sender_engine_adapter_test.h index 19b4b4c6..e870d8c3 100644 --- a/services/screenservice/test/unittest/sourceservice/dscreenmgr/2.0/include/av_sender_engine_adapter_test.h +++ b/services/screenservice/test/unittest/sourceservice/dscreenmgr/2.0/include/av_sender_engine_adapter_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -18,10 +18,8 @@ #include -#define private public #include "dscreen_errcode.h" #include "2.0/include/av_sender_engine_adapter.h" -#undef private namespace OHOS { namespace DistributedHardware { diff --git a/services/screenservice/test/unittest/sourceservice/dscreenmgr/2.0/include/dscreen_manager_test.h b/services/screenservice/test/unittest/sourceservice/dscreenmgr/2.0/include/dscreen_manager_test.h index 05352b3b..1683c190 100644 --- a/services/screenservice/test/unittest/sourceservice/dscreenmgr/2.0/include/dscreen_manager_test.h +++ b/services/screenservice/test/unittest/sourceservice/dscreenmgr/2.0/include/dscreen_manager_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -20,9 +20,7 @@ #include #include "dscreen_errcode.h" -#define private public #include "2.0/include/dscreen_manager.h" -#undef private namespace OHOS { namespace DistributedHardware { diff --git a/services/screenservice/test/unittest/sourceservice/dscreenmgr/2.0/include/dscreen_test.h b/services/screenservice/test/unittest/sourceservice/dscreenmgr/2.0/include/dscreen_test.h index 4e348dd5..052d623a 100644 --- a/services/screenservice/test/unittest/sourceservice/dscreenmgr/2.0/include/dscreen_test.h +++ b/services/screenservice/test/unittest/sourceservice/dscreenmgr/2.0/include/dscreen_test.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -19,9 +19,7 @@ #include #include -#define private public #include "2.0/include/dscreen.h" -#undef private namespace OHOS { namespace DistributedHardware { namespace V2_0 { diff --git a/services/screenservice/test/unittest/sourceservice/dscreenmgr/2.0/src/dscreen_manager_test.cpp b/services/screenservice/test/unittest/sourceservice/dscreenmgr/2.0/src/dscreen_manager_test.cpp index efb17055..0fdf2b36 100644 --- a/services/screenservice/test/unittest/sourceservice/dscreenmgr/2.0/src/dscreen_manager_test.cpp +++ b/services/screenservice/test/unittest/sourceservice/dscreenmgr/2.0/src/dscreen_manager_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -13,10 +13,8 @@ * limitations under the License. */ -#define private public #include "2.0/include/dscreen_manager_test.h" #include "common/include/screen_manager_adapter.h" -#undef private #include "xcollie/watchdog.h" using namespace testing; diff --git a/services/screenservice/test/unittest/sourceservice/dscreenmgr/2.0/src/dscreen_test.cpp b/services/screenservice/test/unittest/sourceservice/dscreenmgr/2.0/src/dscreen_test.cpp index 84c08e79..260de368 100644 --- a/services/screenservice/test/unittest/sourceservice/dscreenmgr/2.0/src/dscreen_test.cpp +++ b/services/screenservice/test/unittest/sourceservice/dscreenmgr/2.0/src/dscreen_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -16,7 +16,6 @@ #include "2.0/include/dscreen_test.h" #include "xcollie/watchdog.h" -#define private public #include "dscreen_constants.h" #include "dscreen_errcode.h" #include "2.0/include/dscreen_manager.h" @@ -24,7 +23,6 @@ #include "dscreen_util.h" #include "video_param.h" #include "screen_source_trans.h" -#undef private using namespace testing; using namespace testing::ext; @@ -32,7 +30,7 @@ using namespace testing::ext; namespace OHOS { namespace DistributedHardware { namespace V2_0 { -constexpr static uint32_t videoDataNum = 480; +constexpr static uint32_t VIDEO_DATA_NUM = 480; void DScreenTestV2::SetUpTestCase(void) {} void DScreenTestV2::TearDownTestCase(void) {} @@ -46,10 +44,10 @@ void DScreenTestV2::SetUp(void) dScreen_->videoParam_ = std::make_shared(); dScreen_->videoParam_->SetCodecType(VIDEO_CODEC_TYPE_VIDEO_H264); dScreen_->videoParam_->SetVideoFormat(VIDEO_DATA_FORMAT_YUVI420); - dScreen_->videoParam_->SetVideoHeight(videoDataNum); - dScreen_->videoParam_->SetVideoWidth(videoDataNum); - dScreen_->videoParam_->SetScreenHeight(videoDataNum); - dScreen_->videoParam_->SetScreenWidth(videoDataNum); + dScreen_->videoParam_->SetVideoHeight(VIDEO_DATA_NUM); + dScreen_->videoParam_->SetVideoWidth(VIDEO_DATA_NUM); + dScreen_->videoParam_->SetScreenHeight(VIDEO_DATA_NUM); + dScreen_->videoParam_->SetScreenWidth(VIDEO_DATA_NUM); dScreen_->videoParam_->SetFps(DEFAULT_FPS); dScreen_->devId_ = "peerDevId"; } diff --git a/services/screenservice/test/unittest/sourceservice/dscreenmgr/BUILD.gn b/services/screenservice/test/unittest/sourceservice/dscreenmgr/BUILD.gn index 0d990214..c0fc4323 100644 --- a/services/screenservice/test/unittest/sourceservice/dscreenmgr/BUILD.gn +++ b/services/screenservice/test/unittest/sourceservice/dscreenmgr/BUILD.gn @@ -59,7 +59,10 @@ ohos_unittest("DscreenMgrTest") { "${services_path}/screenservice/test/unittest/sourceservice/dscreenmgr/2.0/src/dscreen_test.cpp", ] - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "${common_path}/test/unittest/resource:dscreen_unittest_public_config", + ] deps = [ "${distributedscreen_path}/common:distributed_screen_utils", diff --git a/services/screenservice/test/unittest/sourceservice/dscreenservice/BUILD.gn b/services/screenservice/test/unittest/sourceservice/dscreenservice/BUILD.gn index b03cc16b..fffb46fb 100644 --- a/services/screenservice/test/unittest/sourceservice/dscreenservice/BUILD.gn +++ b/services/screenservice/test/unittest/sourceservice/dscreenservice/BUILD.gn @@ -44,7 +44,10 @@ ohos_unittest("DScreenSourceStubTest") { "${services_path}/screenservice/test/unittest/sourceservice/dscreenservice/src/dscreen_source_stub_test.cpp", ] - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "${common_path}/test/unittest/resource:dscreen_unittest_public_config", + ] deps = [ "${interfaces_path}/innerkits/native_cpp/screen_source:distributed_screen_source_sdk", diff --git a/services/screenservice/test/unittest/sourceservice/dscreenservice/src/dscreen_source_stub_test.cpp b/services/screenservice/test/unittest/sourceservice/dscreenservice/src/dscreen_source_stub_test.cpp index 37738b8c..1277198e 100644 --- a/services/screenservice/test/unittest/sourceservice/dscreenservice/src/dscreen_source_stub_test.cpp +++ b/services/screenservice/test/unittest/sourceservice/dscreenservice/src/dscreen_source_stub_test.cpp @@ -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 @@ -13,10 +13,8 @@ * limitations under the License. */ -#define private public #include "dscreen_source_stub_test.h" #include "dscreen_constants.h" -#undef private #include diff --git a/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp b/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp index 19672585..1f15ec41 100644 --- a/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp +++ b/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 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 @@ -479,9 +479,10 @@ void ImageSinkDecoder::DecodeScreenData() int32_t bufferIndex = 0; { std::unique_lock lock(dataMutex_); - decodeCond_.wait_for(lock, std::chrono::milliseconds(DECODE_WAIT_MILLISECONDS), - [this]() { return (!videoDataQueue_.empty() && !availableInputIndexsQueue_.empty() - && !availableInputBufferQueue_.empty()); }); + decodeCond_.wait_for(lock, std::chrono::milliseconds(DECODE_WAIT_MILLISECONDS), [this]() { + return (!videoDataQueue_.empty() && !availableInputIndexsQueue_.empty() && + !availableInputBufferQueue_.empty()); + }); if (videoDataQueue_.empty() || availableInputIndexsQueue_.empty() || availableInputBufferQueue_.empty()) { DHLOGD("%{public}s: Index queue or data queue or buffer queue is empty.", DSCREEN_LOG_TAG); diff --git a/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/BUILD.gn index 270aa094..42cc79d7 100644 --- a/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/BUILD.gn +++ b/services/screentransport/test/fuzztest/screensinkprocessor/onbufferavailable_fuzzer/BUILD.gn @@ -39,12 +39,8 @@ ohos_fuzztest("OnBufferAvailableFuzzTest") { "${services_path}/softbusadapter/include", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] sources = [ "onbufferavailable_fuzzer.cpp" ] diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/BUILD.gn index a18bbd46..f5882ae5 100644 --- a/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/BUILD.gn +++ b/services/screentransport/test/fuzztest/screensourceprocessor/onbufferavailable_fuzzer/BUILD.gn @@ -39,12 +39,8 @@ ohos_fuzztest("OnBufferAvailableFuzzTest") { "${services_path}/softbusadapter/include", ] - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] sources = [ "onbufferavailable_fuzzer.cpp" ] diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onerror_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensourceprocessor/onerror_fuzzer/BUILD.gn index 46fe25fa..b0d78ab5 100644 --- a/services/screentransport/test/fuzztest/screensourceprocessor/onerror_fuzzer/BUILD.gn +++ b/services/screentransport/test/fuzztest/screensourceprocessor/onerror_fuzzer/BUILD.gn @@ -21,12 +21,9 @@ ohos_fuzztest("OnErrorFuzzTest") { module_out_path = "${fuzz_test_path}/imageencodercallback" fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screensourceprocessor/onerror_fuzzer" - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] + sources = [ "onerror_fuzzer.cpp" ] include_dirs = [ diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/oninputbufferavailable_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensourceprocessor/oninputbufferavailable_fuzzer/BUILD.gn index 7c13758b..61da1bcd 100644 --- a/services/screentransport/test/fuzztest/screensourceprocessor/oninputbufferavailable_fuzzer/BUILD.gn +++ b/services/screentransport/test/fuzztest/screensourceprocessor/oninputbufferavailable_fuzzer/BUILD.gn @@ -21,12 +21,9 @@ ohos_fuzztest("OnInputBufferAvailableFuzzTest") { module_out_path = "${fuzz_test_path}/imageencodercallback" fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screensourceprocessor/oninputbufferavailable_fuzzer" - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] + sources = [ "oninputbufferavailable_fuzzer.cpp" ] include_dirs = [ diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onoutputbufferavailable_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputbufferavailable_fuzzer/BUILD.gn index fe7715a5..be3c6620 100644 --- a/services/screentransport/test/fuzztest/screensourceprocessor/onoutputbufferavailable_fuzzer/BUILD.gn +++ b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputbufferavailable_fuzzer/BUILD.gn @@ -21,12 +21,9 @@ ohos_fuzztest("OnOutputBufferAvailableFuzzTest") { module_out_path = "${fuzz_test_path}/imageencodercallback" fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screensourceprocessor/onoutputbufferavailable_fuzzer" - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] + sources = [ "onoutputbufferavailable_fuzzer.cpp" ] include_dirs = [ diff --git a/services/screentransport/test/fuzztest/screensourceprocessor/onoutputformatchanged_fuzzer/BUILD.gn b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputformatchanged_fuzzer/BUILD.gn index ed51e86a..34b832e7 100644 --- a/services/screentransport/test/fuzztest/screensourceprocessor/onoutputformatchanged_fuzzer/BUILD.gn +++ b/services/screentransport/test/fuzztest/screensourceprocessor/onoutputformatchanged_fuzzer/BUILD.gn @@ -21,12 +21,9 @@ ohos_fuzztest("OnOutputFormatChangedFuzzTest") { module_out_path = "${fuzz_test_path}/imageencodercallback" fuzz_config_file = "${services_path}/screentransport/test/fuzztest/screensourceprocessor/onoutputformatchanged_fuzzer" - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] + sources = [ "onoutputformatchanged_fuzzer.cpp" ] include_dirs = [ diff --git a/services/screentransport/test/unittest/screendatachannel/BUILD.gn b/services/screentransport/test/unittest/screendatachannel/BUILD.gn index 0fc6328b..434548f5 100644 --- a/services/screentransport/test/unittest/screendatachannel/BUILD.gn +++ b/services/screentransport/test/unittest/screendatachannel/BUILD.gn @@ -47,7 +47,10 @@ ohos_unittest("DataChannelTest") { sources = [ "${services_path}/screentransport/test/unittest/screendatachannel/src/screen_data_channel_impl_test.cpp" ] - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "${common_path}/test/unittest/resource:dscreen_unittest_public_config", + ] deps = [ "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", @@ -70,12 +73,6 @@ ohos_unittest("DataChannelTest") { "DH_LOG_TAG=\"datachanneltest\"", "LOG_DOMAIN=0xD004140", ] - - cflags = [ - "-frtti", - "-fexceptions", - ] - cflags_cc = cflags } group("data_channel_test") { diff --git a/services/screentransport/test/unittest/screendatachannel/src/screen_data_channel_impl_test.cpp b/services/screentransport/test/unittest/screendatachannel/src/screen_data_channel_impl_test.cpp index 9f5b0dac..7f4d6ab2 100644 --- a/services/screentransport/test/unittest/screendatachannel/src/screen_data_channel_impl_test.cpp +++ b/services/screentransport/test/unittest/screendatachannel/src/screen_data_channel_impl_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 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 @@ -13,11 +13,9 @@ * limitations under the License. */ -#define private public #include "screen_data_channel_impl_test.h" #include "dscreen_util.h" #include "dscreen_json_util.h" -#undef private #include "accesstoken_kit.h" #include "nativetoken_kit.h" #include "token_setproc.h" @@ -28,8 +26,8 @@ using namespace testing::ext; namespace OHOS { namespace DistributedHardware { namespace { - const std::string PEER_SESSION_NAME = "ohos.dhardware.dscreen.session8647073e02e7a78f09473aa122"; - const std::string REMOTE_DEV_ID = "f6d4c0864707aefte7a78f09473aa122ff57fc81c00981fcf5be989e7d112591"; + const std::string PEER_SESSION_NAME = "ohos.dhardware.dscreen.session8647073e02e7a78f09473aa123"; + const std::string REMOTE_DEV_ID = "f6d4c0864707aefte7a78f09473aa122ff57fc81c00981fcf5be989e7d112123"; const std::string DSCREEN_PKG_NAME_TEST = "ohos.dhardware.dscreen"; } void ScreenDataChannelImplTest::SetUpTestCase(void) {} diff --git a/services/screentransport/test/unittest/screensinkprocessor/BUILD.gn b/services/screentransport/test/unittest/screensinkprocessor/BUILD.gn index 16f674f3..a46b88b2 100644 --- a/services/screentransport/test/unittest/screensinkprocessor/BUILD.gn +++ b/services/screentransport/test/unittest/screensinkprocessor/BUILD.gn @@ -53,7 +53,10 @@ ohos_unittest("SinkProcessorTest") { "${services_path}/screentransport/test/unittest/screensinkprocessor/src/image_sink_processor_test.cpp", ] - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "${common_path}/test/unittest/resource:dscreen_unittest_public_config", + ] deps = [ "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", @@ -75,9 +78,6 @@ ohos_unittest("SinkProcessorTest") { "DH_LOG_TAG=\"sinkprocessorest\"", "LOG_DOMAIN=0xD004140", ] - - cflags = [ "-frtti" ] - cflags_cc = cflags } group("sink_processor_test") { diff --git a/services/screentransport/test/unittest/screensinkprocessor/include/image_sink_decoder_test.h b/services/screentransport/test/unittest/screensinkprocessor/include/image_sink_decoder_test.h index 96029c79..f43d2b0e 100644 --- a/services/screentransport/test/unittest/screensinkprocessor/include/image_sink_decoder_test.h +++ b/services/screentransport/test/unittest/screensinkprocessor/include/image_sink_decoder_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 @@ -18,9 +18,7 @@ #include -#define private public #include "image_sink_decoder.h" -#undef private #include "iscreen_channel_listener.h" #include "screentrans_test_utils.h" diff --git a/services/screentransport/test/unittest/screensinkprocessor/include/image_sink_processor_test.h b/services/screentransport/test/unittest/screensinkprocessor/include/image_sink_processor_test.h index 1d6984d3..f595b420 100644 --- a/services/screentransport/test/unittest/screensinkprocessor/include/image_sink_processor_test.h +++ b/services/screentransport/test/unittest/screensinkprocessor/include/image_sink_processor_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 @@ -18,9 +18,7 @@ #include -#define private public #include "image_sink_processor.h" -#undef private #include "iscreen_channel_listener.h" #include "screentrans_test_utils.h" diff --git a/services/screentransport/test/unittest/screensinkprocessor/src/image_sink_decoder_test.cpp b/services/screentransport/test/unittest/screensinkprocessor/src/image_sink_decoder_test.cpp index c855d00b..4b726456 100644 --- a/services/screentransport/test/unittest/screensinkprocessor/src/image_sink_decoder_test.cpp +++ b/services/screentransport/test/unittest/screensinkprocessor/src/image_sink_decoder_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 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 @@ -22,22 +22,23 @@ #include "dscreen_errcode.h" #include "dscreen_log.h" #include "iconsumer_surface.h" +#include "buffer/avsharedmemorybase.h" using namespace testing::ext; namespace OHOS { namespace DistributedHardware { -constexpr static uint32_t videoDataNum = 480; +constexpr static uint32_t VIDEO_DATA_NUM = 480; void ImageSinkDecoderTest::SetUpTestCase(void) {} void ImageSinkDecoderTest::TearDownTestCase(void) {} void ImageSinkDecoderTest::SetUp(void) { - param_.screenWidth_ = videoDataNum; - param_.screenHeight_ = videoDataNum; - param_.videoWidth_ = videoDataNum; - param_.videoHeight_ = videoDataNum; + param_.screenWidth_ = VIDEO_DATA_NUM; + param_.screenHeight_ = VIDEO_DATA_NUM; + param_.videoWidth_ = VIDEO_DATA_NUM; + param_.videoHeight_ = VIDEO_DATA_NUM; param_.codecType_ = VIDEO_CODEC_TYPE_VIDEO_H264; param_.videoFormat_ = VIDEO_DATA_FORMAT_YUVI420; param_.fps_ = FPS; @@ -151,6 +152,17 @@ HWTEST_F(ImageSinkDecoderTest, stop_decoder_test_001, TestSize.Level1) EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, imageDecoder_->StopDecoder()); } +/** + * @tc.name: stop_decoder_test_002 + * @tc.desc: Verify the StopDecoder function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ImageSinkDecoderTest, stop_decoder_test_002, TestSize.Level1) +{ + EXPECT_EQ(ERR_DH_SCREEN_CODEC_FLUSH_FAILED, imageDecoder_->StopDecoder()); +} + /** * @tc.name: init_video_decoder_test_001 * @tc.desc: Verify the InitVideoDecoder function. @@ -274,6 +286,33 @@ HWTEST_F(ImageSinkDecoderTest, set_output_surface_test_001, TestSize.Level1) EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, imageDecoder_->SetOutputSurface(pSurface)); } +/** + * @tc.name: InputScreenData_test_001 + * @tc.desc: Verify the InputScreenData function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ImageSinkDecoderTest, InputScreenData_test_001, TestSize.Level1) +{ + EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, imageDecoder_->InputScreenData(nullptr)); +} + +/** + * @tc.name: InputScreenData_test_002 + * @tc.desc: Verify the InputScreenData function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ImageSinkDecoderTest, InputScreenData_test_002, TestSize.Level1) +{ + std::shared_ptr data = std::make_shared(10); + for (uint32_t i = 0; i < DATA_QUEUE_MAX_SIZE + 1; i++) { + imageDecoder_->videoDataQueue_.push(data); + } + EXPECT_EQ(DH_SUCCESS, imageDecoder_->InputScreenData(data)); + std::queue>().swap(imageDecoder_->videoDataQueue_); +} + /** * @tc.name: on_input_buffer_available_test_001 * @tc.desc: Verify the OnInputBufferAvailable function. @@ -355,6 +394,80 @@ HWTEST_F(ImageSinkDecoderTest, ProcessData_001, TestSize.Level1) EXPECT_EQ(ERR_DH_SCREEN_CODEC_SURFACE_ERROR, ret); } +/** + * @tc.name: ProcessData_002 + * @tc.desc: Verify the DecodeScreenData function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ImageSinkDecoderTest, ProcessData_002, TestSize.Level1) +{ + imageDecoder_->videoDecoder_ = nullptr; + std::shared_ptr screenData = std::make_shared(100); + int32_t ret = imageDecoder_->ProcessData(screenData, 0); + EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, ret); +} + +/** + * @tc.name: ProcessData_003 + * @tc.desc: Verify the DecodeScreenData function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ImageSinkDecoderTest, ProcessData_003, TestSize.Level1) +{ + std::shared_ptr screenData = nullptr; + int32_t ret = imageDecoder_->ProcessData(screenData, 0); + EXPECT_EQ(ERR_DH_SCREEN_TRANS_NULL_VALUE, ret); +} + +/** + * @tc.name: ProcessData_004 + * @tc.desc: Verify the DecodeScreenData function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ImageSinkDecoderTest, ProcessData_004, TestSize.Level1) +{ + std::shared_ptr buffer = nullptr; + imageDecoder_->availableInputBufferQueue_.push(buffer); + std::shared_ptr screenData = std::make_shared(100); + int32_t ret = imageDecoder_->ProcessData(screenData, 0); + EXPECT_EQ(ERR_DH_SCREEN_CODEC_SURFACE_ERROR, ret); +} + +/** + * @tc.name: ProcessData_005 + * @tc.desc: Verify the DecodeScreenData function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ImageSinkDecoderTest, ProcessData_005, TestSize.Level1) +{ + std::shared_ptr buffer = Media::AVSharedMemoryBase::CreateFromLocal(100, + Media::AVSharedMemory::FLAGS_READ_WRITE, "userBuffer");; + imageDecoder_->availableInputBufferQueue_.push(buffer); + std::shared_ptr screenData = std::make_shared(100); + int32_t ret = imageDecoder_->ProcessData(screenData, 0); + EXPECT_EQ(ERR_DH_SCREEN_CODEC_SURFACE_ERROR, ret); +} + +/** + * @tc.name: ProcessData_006 + * @tc.desc: Verify the DecodeScreenData function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ImageSinkDecoderTest, ProcessData_006, TestSize.Level1) +{ + std::shared_ptr buffer = Media::AVSharedMemoryBase::CreateFromLocal(100, + Media::AVSharedMemory::FLAGS_READ_WRITE, "userBuffer");; + imageDecoder_->availableInputBufferQueue_.push(buffer); + std::shared_ptr screenData = std::make_shared(110); + int32_t ret = imageDecoder_->ProcessData(screenData, 0); + EXPECT_EQ(ERR_DH_SCREEN_CODEC_SURFACE_ERROR, ret); +} + /** * @tc.name: start_input_thread_test_001 * @tc.desc: Verify the StartInputThread StopInputThread function. diff --git a/services/screentransport/test/unittest/screensinkprocessor/src/image_sink_processor_test.cpp b/services/screentransport/test/unittest/screensinkprocessor/src/image_sink_processor_test.cpp index 9d40d5d3..7dd6a0a6 100644 --- a/services/screentransport/test/unittest/screensinkprocessor/src/image_sink_processor_test.cpp +++ b/services/screentransport/test/unittest/screensinkprocessor/src/image_sink_processor_test.cpp @@ -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 @@ -26,17 +26,17 @@ using namespace testing::ext; namespace OHOS { namespace DistributedHardware { -constexpr static uint32_t videoDataNum = 480; +constexpr static uint32_t VIDEO_DATA_NUM = 480; void ImageSinkProcessorTest::SetUpTestCase(void) {} void ImageSinkProcessorTest::TearDownTestCase(void) {} void ImageSinkProcessorTest::SetUp(void) { - param_.screenWidth_ = videoDataNum; - param_.screenHeight_ = videoDataNum; - param_.videoWidth_ = videoDataNum; - param_.videoHeight_ = videoDataNum; + param_.screenWidth_ = VIDEO_DATA_NUM; + param_.screenHeight_ = VIDEO_DATA_NUM; + param_.videoWidth_ = VIDEO_DATA_NUM; + param_.videoHeight_ = VIDEO_DATA_NUM; param_.fps_ = FPS; param_.codecType_ = VIDEO_CODEC_TYPE_VIDEO_H264; param_.videoFormat_ = VIDEO_DATA_FORMAT_YUVI420; diff --git a/services/screentransport/test/unittest/screensinktrans/BUILD.gn b/services/screentransport/test/unittest/screensinktrans/BUILD.gn index 7d1f0bb7..6b4550dc 100644 --- a/services/screentransport/test/unittest/screensinktrans/BUILD.gn +++ b/services/screentransport/test/unittest/screensinktrans/BUILD.gn @@ -50,7 +50,10 @@ ohos_unittest("SinkTransTest") { sources = [ "${services_path}/screentransport/test/unittest/screensinktrans/src/screen_sink_trans_test.cpp" ] - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "${common_path}/test/unittest/resource:dscreen_unittest_public_config", + ] deps = [ "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", @@ -73,9 +76,6 @@ ohos_unittest("SinkTransTest") { "DH_LOG_TAG=\"sinktranstest\"", "LOG_DOMAIN=0xD004140", ] - - cflags = [ "-frtti" ] - cflags_cc = cflags } group("sink_trans_test") { diff --git a/services/screentransport/test/unittest/screensinktrans/include/screen_sink_trans_test.h b/services/screentransport/test/unittest/screensinktrans/include/screen_sink_trans_test.h index 6210ae38..0626e374 100644 --- a/services/screentransport/test/unittest/screensinktrans/include/screen_sink_trans_test.h +++ b/services/screentransport/test/unittest/screensinktrans/include/screen_sink_trans_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 @@ -19,9 +19,7 @@ #include #include "iscreen_sink_trans_callback.h" -#define private public #include "screen_sink_trans.h" -#undef private #include "screentrans_test_utils.h" namespace OHOS { diff --git a/services/screentransport/test/unittest/screensinktrans/src/screen_sink_trans_test.cpp b/services/screentransport/test/unittest/screensinktrans/src/screen_sink_trans_test.cpp index 4dfce5b0..a15838fa 100644 --- a/services/screentransport/test/unittest/screensinktrans/src/screen_sink_trans_test.cpp +++ b/services/screentransport/test/unittest/screensinktrans/src/screen_sink_trans_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 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 @@ -26,7 +26,7 @@ using namespace testing::ext; namespace OHOS { namespace DistributedHardware { -constexpr static uint32_t videoDataNum = 480; +constexpr static uint32_t VIDEO_DATA_NUM = 480; void ScreenSinkTransTest::SetUpTestCase(void) {} void ScreenSinkTransTest::TearDownTestCase(void) {} @@ -43,10 +43,10 @@ void ScreenSinkTransTest::SetUp(void) trans_->decoderSurface_ = pSurface; trans_->transCallback_ = std::make_shared(); - param_.screenWidth_ = videoDataNum; - param_.screenHeight_ = videoDataNum; - param_.videoWidth_ = videoDataNum; - param_.videoHeight_ = videoDataNum; + param_.screenWidth_ = VIDEO_DATA_NUM; + param_.screenHeight_ = VIDEO_DATA_NUM; + param_.videoWidth_ = VIDEO_DATA_NUM; + param_.videoHeight_ = VIDEO_DATA_NUM; param_.codecType_ = VIDEO_CODEC_TYPE_VIDEO_H264; param_.videoFormat_ = VIDEO_DATA_FORMAT_YUVI420; param_.fps_ = FPS; diff --git a/services/screentransport/test/unittest/screensourceprocessor/BUILD.gn b/services/screentransport/test/unittest/screensourceprocessor/BUILD.gn index 646b4802..d10b49cd 100644 --- a/services/screentransport/test/unittest/screensourceprocessor/BUILD.gn +++ b/services/screentransport/test/unittest/screensourceprocessor/BUILD.gn @@ -50,7 +50,10 @@ ohos_unittest("SourceProcessorTest") { "${services_path}/screentransport/test/unittest/screensourceprocessor/src/image_source_processor_test.cpp", ] - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "${common_path}/test/unittest/resource:dscreen_unittest_public_config", + ] deps = [ "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", diff --git a/services/screentransport/test/unittest/screensourceprocessor/include/image_source_encoder_test.h b/services/screentransport/test/unittest/screensourceprocessor/include/image_source_encoder_test.h index 12d3d4d8..c200360f 100644 --- a/services/screentransport/test/unittest/screensourceprocessor/include/image_source_encoder_test.h +++ b/services/screentransport/test/unittest/screensourceprocessor/include/image_source_encoder_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 @@ -22,9 +22,7 @@ #include "dscreen_constants.h" #include "dscreen_errcode.h" #include "dscreen_log.h" -#define private public #include "image_source_encoder.h" -#undef private namespace OHOS { namespace DistributedHardware { diff --git a/services/screentransport/test/unittest/screensourceprocessor/include/image_source_processor_test.h b/services/screentransport/test/unittest/screensourceprocessor/include/image_source_processor_test.h index ce6f62a4..a23d606a 100644 --- a/services/screentransport/test/unittest/screensourceprocessor/include/image_source_processor_test.h +++ b/services/screentransport/test/unittest/screensourceprocessor/include/image_source_processor_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 @@ -20,9 +20,7 @@ #include "dscreen_errcode.h" #include "dscreen_log.h" -#define private public #include "image_source_processor.h" -#undef private namespace OHOS { namespace DistributedHardware { diff --git a/services/screentransport/test/unittest/screensourcetrans/BUILD.gn b/services/screentransport/test/unittest/screensourcetrans/BUILD.gn index 6b5db7f1..369834ea 100644 --- a/services/screentransport/test/unittest/screensourcetrans/BUILD.gn +++ b/services/screentransport/test/unittest/screensourcetrans/BUILD.gn @@ -50,7 +50,10 @@ ohos_unittest("SourceTransTest") { sources = [ "${services_path}/screentransport/test/unittest/screensourcetrans/src/screen_source_trans_test.cpp" ] - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "${common_path}/test/unittest/resource:dscreen_unittest_public_config", + ] deps = [ "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", diff --git a/services/screentransport/test/unittest/screensourcetrans/include/screen_source_trans_test.h b/services/screentransport/test/unittest/screensourcetrans/include/screen_source_trans_test.h index f0c29807..3d023518 100644 --- a/services/screentransport/test/unittest/screensourcetrans/include/screen_source_trans_test.h +++ b/services/screentransport/test/unittest/screensourcetrans/include/screen_source_trans_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 @@ -19,13 +19,11 @@ #include #include -#define private public #include "dscreen_errcode.h" #include "dscreen_log.h" #include "image_source_processor.h" #include "screen_data_channel_impl.h" #include "screen_source_trans.h" -#undef private namespace OHOS { namespace DistributedHardware { diff --git a/services/screentransport/test/unittest/screensourcetrans/src/screen_source_trans_test.cpp b/services/screentransport/test/unittest/screensourcetrans/src/screen_source_trans_test.cpp index e3016b3d..2fbd7d56 100644 --- a/services/screentransport/test/unittest/screensourcetrans/src/screen_source_trans_test.cpp +++ b/services/screentransport/test/unittest/screensourcetrans/src/screen_source_trans_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 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 @@ -23,7 +23,7 @@ using namespace testing::ext; namespace OHOS { namespace DistributedHardware { -constexpr static uint32_t videoDataNum = 480; +constexpr static uint32_t VIDEO_DATA_NUM = 480; void ScreenSourceTransTest::SetUpTestCase(void) {} void ScreenSourceTransTest::TearDownTestCase(void) {} @@ -118,17 +118,17 @@ HWTEST_F(ScreenSourceTransTest, SetUp_002, TestSize.Level1) VideoParam localParam; localParam.SetCodecType(VIDEO_CODEC_TYPE_VIDEO_H264); localParam.SetVideoFormat(VIDEO_DATA_FORMAT_YUVI420); - localParam.SetVideoHeight(videoDataNum); - localParam.SetVideoWidth(videoDataNum); - localParam.SetScreenHeight(videoDataNum); - localParam.SetScreenWidth(videoDataNum); + localParam.SetVideoHeight(VIDEO_DATA_NUM); + localParam.SetVideoWidth(VIDEO_DATA_NUM); + localParam.SetScreenHeight(VIDEO_DATA_NUM); + localParam.SetScreenWidth(VIDEO_DATA_NUM); VideoParam remoteParam; remoteParam.SetCodecType(VIDEO_CODEC_TYPE_VIDEO_H264); remoteParam.SetVideoFormat(VIDEO_DATA_FORMAT_YUVI420); - remoteParam.SetVideoHeight(videoDataNum); - remoteParam.SetVideoWidth(videoDataNum); - remoteParam.SetScreenHeight(videoDataNum); - remoteParam.SetScreenWidth(videoDataNum); + remoteParam.SetVideoHeight(VIDEO_DATA_NUM); + remoteParam.SetVideoWidth(VIDEO_DATA_NUM); + remoteParam.SetScreenHeight(VIDEO_DATA_NUM); + remoteParam.SetScreenWidth(VIDEO_DATA_NUM); int32_t actual = trans->SetUp(localParam, remoteParam, "peerDevId"); DisablePermissionAccess(tokenId_); diff --git a/services/screentransport/test/unittest/screentranstestutils/BUILD.gn b/services/screentransport/test/unittest/screentranstestutils/BUILD.gn index d6b0e509..36c8da89 100644 --- a/services/screentransport/test/unittest/screentranstestutils/BUILD.gn +++ b/services/screentransport/test/unittest/screentranstestutils/BUILD.gn @@ -51,7 +51,10 @@ ohos_unittest("ScreenCallbackTest") { sources = [ "${services_path}/screentransport/test/unittest/screentranstestutils/src/screen_callback_test.cpp" ] - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "${common_path}/test/unittest/resource:dscreen_unittest_public_config", + ] deps = [ "${services_path}/screentransport/screensinktrans:distributed_screen_sinktrans", diff --git a/services/screentransport/test/unittest/screentranstestutils/src/screen_callback_test.cpp b/services/screentransport/test/unittest/screentranstestutils/src/screen_callback_test.cpp index 8a39c7ce..163e8773 100644 --- a/services/screentransport/test/unittest/screentranstestutils/src/screen_callback_test.cpp +++ b/services/screentransport/test/unittest/screentranstestutils/src/screen_callback_test.cpp @@ -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 @@ -18,7 +18,6 @@ #include "avcodec_common.h" #include "meta/format.h" -#define private public #include "dscreen_constants.h" #include "dscreen_errcode.h" #include "screen_callback_test.h" @@ -29,7 +28,6 @@ #include "screen_data_channel_impl.h" #include "image_sink_decoder.h" #include "image_decoder_callback.h" -#undef private using namespace testing::ext; namespace OHOS { @@ -148,7 +146,7 @@ HWTEST_F(ScreenCallbackTest, RegisterStateCallback_006, TestSize.Level1) { std::shared_ptr callback = std::make_shared(); int32_t actual = sinkTrans->RegisterStateCallback(callback); - + std::string peerDevId = "peerDevId"; std::shared_ptr screenChannel = std::make_shared(peerDevId); std::shared_ptr listener = std::make_shared(); @@ -164,5 +162,55 @@ HWTEST_F(ScreenCallbackTest, RegisterStateCallback_006, TestSize.Level1) EXPECT_EQ(DH_SUCCESS, actual); } + +/** + * @tc.name: RegisterStateCallback_007 + * @tc.desc: Verify the RegisterStateCallback function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenCallbackTest, RegisterStateCallback_007, TestSize.Level1) +{ + std::shared_ptr callback = std::make_shared(); + int32_t actual = sinkTrans->RegisterStateCallback(callback); + std::shared_ptr encoderCallback = std::make_shared(nullptr); + MediaAVCodec::AVCodecErrorType errorType = MediaAVCodec::AVCODEC_ERROR_INTERNAL; + int32_t errorCode = 0; + encoderCallback->OnError(errorType, errorCode); + uint32_t index = 0; + MediaAVCodec::AVCodecBufferInfo info; + MediaAVCodec::AVCodecBufferFlag flag = MediaAVCodec::AVCODEC_BUFFER_FLAG_NONE; + std::shared_ptr buffer = nullptr; + encoderCallback->OnOutputBufferAvailable(index, info, flag, buffer); + encoderCallback->OnInputBufferAvailable(index, buffer); + Media::Format format; + encoderCallback->OnOutputFormatChanged(format); + EXPECT_EQ(DH_SUCCESS, actual); +} + +/** + * @tc.name: RegisterStateCallback_008 + * @tc.desc: Verify the RegisterStateCallback function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(ScreenCallbackTest, RegisterStateCallback_008, TestSize.Level1) +{ + std::shared_ptr callback = std::make_shared(); + int32_t actual = sinkTrans->RegisterStateCallback(callback); + std::shared_ptr decoderCallback = std::make_shared(nullptr); + MediaAVCodec::AVCodecErrorType errorType = MediaAVCodec::AVCODEC_ERROR_INTERNAL; + int32_t errorCode = 0; + decoderCallback->OnError(errorType, errorCode); + uint32_t index = 0; + MediaAVCodec::AVCodecBufferInfo info; + MediaAVCodec::AVCodecBufferFlag flag = MediaAVCodec::AVCODEC_BUFFER_FLAG_NONE; + std::shared_ptr buffer = nullptr; + decoderCallback->OnOutputBufferAvailable(index, info, flag, buffer); + decoderCallback->OnInputBufferAvailable(index, buffer); + Media::Format format; + decoderCallback->OnOutputFormatChanged(format); + EXPECT_EQ(DH_SUCCESS, actual); +} } // namespace DistributedHardware } // namespace OHOS \ No newline at end of file diff --git a/services/softbusadapter/include/softbus_adapter.h b/services/softbusadapter/include/softbus_adapter.h index 65a66650..4780047d 100644 --- a/services/softbusadapter/include/softbus_adapter.h +++ b/services/softbusadapter/include/softbus_adapter.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 @@ -73,8 +73,8 @@ private: ISocketListener sessListener_; /* while can not find the listener in mapListeners_, return nullListener_ point to null ptr. */ - std::map serverIdMap_; - std::map devId2SessIdMap_; + std::map serverIdMap_; + std::map devId2SessIdMap_; std::shared_ptr nullListener_; std::map> mapListeners_; std::map> mapSessListeners_; diff --git a/services/softbusadapter/src/softbus_adapter.cpp b/services/softbusadapter/src/softbus_adapter.cpp index c05009e8..66b4430c 100644 --- a/services/softbusadapter/src/softbus_adapter.cpp +++ b/services/softbusadapter/src/softbus_adapter.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 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 @@ -116,7 +116,7 @@ int32_t SoftbusAdapter::CreateSoftbusSessionServer(const std::string &pkgname, c } } } - + SocketInfo serverInfo = { .name = const_cast(sessionName.c_str()), .pkgName = const_cast(pkgname.c_str()), diff --git a/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/BUILD.gn b/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/BUILD.gn index 6f073755..36b525b0 100644 --- a/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/BUILD.gn +++ b/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023 Huawei Device Co., Ltd. +# Copyright (c) 2023-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 @@ -21,12 +21,9 @@ ohos_fuzztest("SoftbusOnBytesReceivedFuzzTest") { module_out_path = "${fuzz_test_path}/softbusadapter" fuzz_config_file = "${services_path}/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer" - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] + sources = [ "softbusonbytesreceived_fuzzer.cpp" ] include_dirs = [ diff --git a/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/softbusonbytesreceived_fuzzer.cpp b/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/softbusonbytesreceived_fuzzer.cpp index 42d3239e..50e6ad6d 100644 --- a/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/softbusonbytesreceived_fuzzer.cpp +++ b/services/softbusadapter/test/fuzztest/softbusonbytesreceived_fuzzer/softbusonbytesreceived_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -23,9 +23,7 @@ #include "isoftbus_listener.h" #include "softbus_bus_center.h" #include "softbus_common.h" -#define private public #include "softbus_adapter.h" -#undef private namespace OHOS { namespace DistributedHardware { diff --git a/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/BUILD.gn b/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/BUILD.gn index e7afe09b..f6dbb0ba 100644 --- a/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/BUILD.gn +++ b/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023 Huawei Device Co., Ltd. +# Copyright (c) 2023-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 @@ -21,12 +21,9 @@ ohos_fuzztest("SoftbusOnMessageReceivedFuzzTest") { module_out_path = "${fuzz_test_path}/softbusadapter" fuzz_config_file = "${services_path}/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer" - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] + sources = [ "softbusonmessagereceived_fuzzer.cpp" ] include_dirs = [ diff --git a/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/softbusonmessagereceived_fuzzer.cpp b/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/softbusonmessagereceived_fuzzer.cpp index e0278d3c..54ed28a0 100644 --- a/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/softbusonmessagereceived_fuzzer.cpp +++ b/services/softbusadapter/test/fuzztest/softbusonmessagereceived_fuzzer/softbusonmessagereceived_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -23,9 +23,7 @@ #include "isoftbus_listener.h" #include "softbus_bus_center.h" #include "softbus_common.h" -#define private public #include "softbus_adapter.h" -#undef private namespace OHOS { namespace DistributedHardware { diff --git a/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/BUILD.gn b/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/BUILD.gn index 95035875..bb63ac68 100644 --- a/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/BUILD.gn +++ b/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023 Huawei Device Co., Ltd. +# Copyright (c) 2023-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 @@ -21,12 +21,9 @@ ohos_fuzztest("SoftbusOnSessionClosedFuzzTest") { module_out_path = "${fuzz_test_path}/softbusadapter" fuzz_config_file = "${services_path}/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer" - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] + sources = [ "softbusonsessionclosed_fuzzer.cpp" ] include_dirs = [ diff --git a/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/softbusonsessionclosed_fuzzer.cpp b/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/softbusonsessionclosed_fuzzer.cpp index 96f0d5f2..cde841ca 100644 --- a/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/softbusonsessionclosed_fuzzer.cpp +++ b/services/softbusadapter/test/fuzztest/softbusonsessionclosed_fuzzer/softbusonsessionclosed_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -23,9 +23,7 @@ #include "isoftbus_listener.h" #include "softbus_bus_center.h" #include "softbus_common.h" -#define private public #include "softbus_adapter.h" -#undef private namespace OHOS { namespace DistributedHardware { diff --git a/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/BUILD.gn b/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/BUILD.gn index 4be4cf40..78ab9843 100644 --- a/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/BUILD.gn +++ b/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023 Huawei Device Co., Ltd. +# Copyright (c) 2023-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 @@ -21,12 +21,9 @@ ohos_fuzztest("SoftbusOnSessionOpenedFuzzTest") { module_out_path = "${fuzz_test_path}/softbusadapter" fuzz_config_file = "${services_path}/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer" - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] + sources = [ "softbusonsessionopened_fuzzer.cpp" ] include_dirs = [ diff --git a/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/softbusonsessionopened_fuzzer.cpp b/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/softbusonsessionopened_fuzzer.cpp index 75194106..b62681fc 100644 --- a/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/softbusonsessionopened_fuzzer.cpp +++ b/services/softbusadapter/test/fuzztest/softbusonsessionopened_fuzzer/softbusonsessionopened_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -23,15 +23,13 @@ #include "isoftbus_listener.h" #include "softbus_bus_center.h" #include "softbus_common.h" -#define private public #include "softbus_adapter.h" -#undef private namespace OHOS { namespace DistributedHardware { namespace { - const std::string PEER_SESSION_NAME = "ohos.dhardware.dscreen.session8647073e02e7a78f09473aa122"; - const std::string REMOTE_DEV_ID = "f6d4c0864707aefte7a78f09473aa122ff57fc81c00981fcf5be989e7d112591"; + const std::string PEER_SESSION_NAME = "ohos.dhardware.dscreen.session8647073e02e7a78f09473aa124"; + const std::string REMOTE_DEV_ID = "f6d4c0864707aefte7a78f09473aa122ff57fc81c00981fcf5be989e7d112124"; const std::string DSCREEN_PKG_NAME_TEST = "ohos.dhardware.dscreen"; } void SoftbusOnSessionOpenedFuzzTest(const uint8_t* data, size_t size) diff --git a/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/BUILD.gn b/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/BUILD.gn index a73e5dd2..7d6f7107 100644 --- a/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/BUILD.gn +++ b/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2023 Huawei Device Co., Ltd. +# Copyright (c) 2023-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 @@ -21,12 +21,9 @@ ohos_fuzztest("SoftbusOnStreamReceivedFuzzTest") { module_out_path = "${fuzz_test_path}/softbusadapter" fuzz_config_file = "${services_path}/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer" - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] + configs = + [ "${common_path}/test/unittest/resource:dscreen_unittest_public_config" ] + sources = [ "softbusonstreamreceived_fuzzer.cpp" ] include_dirs = [ diff --git a/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/softbusonstreamreceived_fuzzer.cpp b/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/softbusonstreamreceived_fuzzer.cpp index 9dafd759..aadd6fde 100644 --- a/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/softbusonstreamreceived_fuzzer.cpp +++ b/services/softbusadapter/test/fuzztest/softbusonstreamreceived_fuzzer/softbusonstreamreceived_fuzzer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-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 @@ -21,9 +21,7 @@ #include "isoftbus_listener.h" #include "softbus_bus_center.h" #include "softbus_common.h" -#define private public #include "softbus_adapter.h" -#undef private namespace OHOS { namespace DistributedHardware { diff --git a/services/softbusadapter/test/unittest/BUILD.gn b/services/softbusadapter/test/unittest/BUILD.gn index 48fa3fdd..278dde6b 100644 --- a/services/softbusadapter/test/unittest/BUILD.gn +++ b/services/softbusadapter/test/unittest/BUILD.gn @@ -45,7 +45,10 @@ ohos_unittest("SoftBusAdapterTest") { sources = [ "${services_path}/softbusadapter/test/unittest/src/softbus_adapter_test.cpp" ] - configs = [ ":module_private_config" ] + configs = [ + ":module_private_config", + "${common_path}/test/unittest/resource:dscreen_unittest_public_config", + ] deps = [ "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", diff --git a/services/softbusadapter/test/unittest/include/softbus_adapter_test.h b/services/softbusadapter/test/unittest/include/softbus_adapter_test.h index 3fa3c8f4..5ace873b 100644 --- a/services/softbusadapter/test/unittest/include/softbus_adapter_test.h +++ b/services/softbusadapter/test/unittest/include/softbus_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 @@ -26,9 +26,7 @@ #include "dscreen_errcode.h" #include "dscreen_util.h" #include "isoftbus_listener.h" -#define private public #include "softbus_adapter.h" -#undef private namespace OHOS { namespace DistributedHardware { diff --git a/services/softbusadapter/test/unittest/src/softbus_adapter_test.cpp b/services/softbusadapter/test/unittest/src/softbus_adapter_test.cpp index 6a0bd22f..f299396b 100644 --- a/services/softbusadapter/test/unittest/src/softbus_adapter_test.cpp +++ b/services/softbusadapter/test/unittest/src/softbus_adapter_test.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2023 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 @@ -23,8 +23,8 @@ using namespace testing::ext; namespace OHOS { namespace DistributedHardware { namespace { - const std::string PEER_SESSION_NAME = "ohos.dhardware.dscreen.session8647073e02e7a78f09473aa122"; - const std::string REMOTE_DEV_ID = "f6d4c0864707aefte7a78f09473aa122ff57fc81c00981fcf5be989e7d112591"; + const std::string PEER_SESSION_NAME = "ohos.dhardware.dscreen.session8647073e02e7a78f09473aa125"; + const std::string REMOTE_DEV_ID = "f6d4c0864707aefte7a78f09473aa122ff57fc81c00981fcf5be989e7d112125"; const std::string DSCREEN_PKG_NAME_TEST = "ohos.dhardware.dscreen"; } void SoftbusAdapterTest::SetUpTestCase(void) {} @@ -134,6 +134,40 @@ HWTEST_F(SoftbusAdapterTest, CreateSoftbusSessionServer_002, TestSize.Level1) softbusAdapter.RemoveSoftbusSessionServer(pkgname, sessionName, peerDevId); } +/** + * @tc.name: CreateSoftbusSessionServer_003 + * @tc.desc: Verify the CreateSoftbusSessionServer function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(SoftbusAdapterTest, CreateSoftbusSessionServer_003, TestSize.Level1) +{ + std::string pkgName = "ohos.dhardware.dscreentest"; + std::string sessionName = DATA_SESSION_NAME; + std::string peerDevId = "peerDevId"; + softbusAdapter.serverIdMap_.clear(); + softbusAdapter.serverIdMap_.insert(std::make_pair(100000, sessionName + "_" + peerDevId)); + int32_t actual = softbusAdapter.CreateSoftbusSessionServer(pkgName, sessionName, peerDevId); + EXPECT_EQ(DH_SUCCESS, actual); +} + +/** + * @tc.name: CreateSoftbusSessionServer_004 + * @tc.desc: Verify the CreateSoftbusSessionServer function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(SoftbusAdapterTest, CreateSoftbusSessionServer_004, TestSize.Level1) +{ + std::string pkgName = "ohos.dhardware.dscreentest"; + std::string sessionName = DATA_SESSION_NAME; + std::string peerDevId = "peerDevId"; + softbusAdapter.serverIdMap_.clear(); + softbusAdapter.serverIdMap_.insert(std::make_pair(100000, sessionName + "__" + peerDevId)); + int32_t actual = softbusAdapter.CreateSoftbusSessionServer(pkgName, sessionName, peerDevId); + EXPECT_EQ(ERR_DH_SCREEN_ADAPTER_BAD_VALUE, actual); +} + /** * @tc.name: RegisterSoftbusListener_001 * @tc.desc: Verify the RegisterSoftbusListener function. -- Gitee