!2283 增加cloud_sync_service ut

Merge pull request !2283 from 钟柠/ut_gn
This commit is contained in:
openharmony_ci 2024-11-21 03:01:16 +00:00 committed by Gitee
commit a8587ba8bd
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 395 additions and 2 deletions

View File

@ -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
@ -16,10 +16,12 @@ import("//foundation/filemanagement/dfs_service/distributedfile.gni")
group("cloudsync_sa_test") {
testonly = true
deps = [
"cycle_task:cloudsync_sa_cycle_task_test",
"dentry:cloudsync_sa_dentry_test",
"ipc:cloudsync_sa_ipc_test",
"log:cloudsync_sa_log_test",
"sync_rule:cloudsync_sa_sync_rule_test",
"system:utils_system_src_test",
"transport:cloudsync_sa_transport_test",
]
}

View File

@ -0,0 +1,91 @@
# 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.
import("//build/test.gni")
import("//foundation/filemanagement/dfs_service/distributedfile.gni")
ohos_unittest("cloud_sync_service_cycle_task_test") {
module_out_path = "filemanagement/dfs_service"
sources = [
"${distributedfile_path}/frameworks/native/cloudsync_kit_inner/src/cloud_sync_common.cpp",
"${distributedfile_path}/test/unittests/cloudsync_sa/mock/parameters.cpp",
"${services_path}/cloudsyncservice/src/cycle_task/cycle_task.cpp",
"${services_path}/cloudsyncservice/src/cycle_task/cycle_task_runner.cpp",
"${services_path}/cloudsyncservice/src/cycle_task/tasks/database_backup_task.cpp",
"${services_path}/cloudsyncservice/src/cycle_task/tasks/optimize_storage_task.cpp",
"${services_path}/cloudsyncservice/src/cycle_task/tasks/periodic_check_task.cpp",
"${services_path}/cloudsyncservice/src/cycle_task/tasks/report_statistics_task.cpp",
"${services_path}/cloudsyncservice/src/cycle_task/tasks/save_subscription_task.cpp",
"cloud_sync_service_cycle_task_test.cpp",
]
include_dirs = [
"${clouddisk_database_path}/include",
"${distributedfile_path}/test/unittests/cloudsync_api/cloudsync_impl/include",
"${distributedfile_path}/test/unittests/cloudsync_sa/mock/",
"${services_path}/cloudsyncservice/include",
"${services_path}/cloudsyncservice/include/cycle_task",
"${services_path}/cloudsyncservice/include/cycle_task/tasks",
]
deps = [
"${clouddisk_database_path}:clouddisk_database",
"${innerkits_native_path}/cloud_file_kit_inner:cloudfile_kit",
"${utils_path}:libdistributedfiledentry",
"${utils_path}:libdistributedfileutils",
]
external_deps = [
"ability_base:want",
"ability_base:zuri",
"ability_runtime:dataobs_manager",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"dfs_service:cloudsync_kit_inner",
"ffrt:libffrt",
"googletest:gmock",
"googletest:gtest",
"hilog:libhilog",
"hisysevent:libhisysevent",
"hitrace:hitrace_meter",
"ipc:ipc_single",
"libfuse:libfuse",
"os_account:os_account_innerkits",
"relational_store:native_rdb",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
defines = [
"private=public",
"protected=public",
"LOG_DOMAIN=0xD004307",
"LOG_TAG=\"CLOUDSYNC_TEST\"",
]
if (cloudsync_service_hicollie_enable) {
external_deps += [ "hicollie:libhicollie" ]
defines += [ "HICOLLIE_ENABLE" ]
}
if (cloudsync_service_resource_schedule) {
external_deps += [ "resource_schedule_service:ressched_client" ]
defines += [ "CLOUDSYNC_SERVICE_RESOURCE_SCHEDULE" ]
}
use_exceptions = true
}
group("cloudsync_sa_cycle_task_test") {
testonly = true
deps = [ ":cloud_sync_service_cycle_task_test" ]
}

View File

@ -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
@ -385,6 +385,123 @@ ohos_unittest("system_load_test") {
use_exceptions = true
}
ohos_unittest("screen_status_listener_test") {
branch_protector_ret = "pac_ret"
sanitize = {
ubsan = true
boundary_sanitize = true
cfi = true
cfi_cross_dso = true
debug = true
blocklist = "${distributedfile_path}/cfi_blocklist.txt"
}
module_out_path = "filemanagement/dfs_service"
sources = [
"${distributedfile_path}/services/cloudsyncservice/src/sync_rule/screen_status_listener.cpp",
"screen_status_listener_test.cpp",
]
include_dirs = [
"${services_path}/cloudsyncservice/include",
"${services_path}/cloudsyncservice/include/sync_rule",
"${innerkits_native_path}/cloudsync_kit_inner",
"${distributedfile_path}/adapter/cloud_adapter_example/include",
"${utils_path}/log/include",
]
deps = [
"${innerkits_native_path}/cloud_file_kit_inner:cloudfile_kit",
"${services_path}/cloudsyncservice:cloudsync_sa_static",
"${utils_path}:libdistributedfileutils",
]
external_deps = [
"ability_base:want",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"googletest:gmock",
"googletest:gtest",
"hilog:libhilog",
"hisysevent:libhisysevent",
"init:libbegetutil",
"ipc:ipc_core",
"netmanager_base:net_conn_manager_if",
"relational_store:native_rdb",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
defines = [
"private=public",
"LOG_DOMAIN=0xD004310",
"LOG_TAG=\"CLOUD_SYNC_TEST\"",
]
if (cloudsync_service_resource_schedule) {
external_deps += [ "resource_schedule_service:ressched_client" ]
defines += [ "CLOUDSYNC_SERVICE_RESOURCE_SCHEDULE" ]
}
use_exceptions = true
}
ohos_unittest("user_status_listener_test") {
branch_protector_ret = "pac_ret"
sanitize = {
ubsan = true
boundary_sanitize = true
cfi = true
cfi_cross_dso = true
debug = true
blocklist = "${distributedfile_path}/cfi_blocklist.txt"
}
module_out_path = "filemanagement/dfs_service"
sources = [
"${distributedfile_path}/services/cloudsyncservice/src/sync_rule/user_status_listener.cpp",
"user_status_listener_test.cpp",
]
include_dirs = [
"${services_path}/cloudsyncservice/include",
"${services_path}/cloudsyncservice/include/sync_rule",
"${services_path}/cloudsyncservice/include/transport/softbus",
"${innerkits_native_path}/cloudsync_kit_inner",
"${distributedfile_path}/adapter/cloud_adapter_example/include",
"${utils_path}/log/include",
]
deps = [
"${innerkits_native_path}/cloud_file_kit_inner:cloudfile_kit",
"${services_path}/cloudsyncservice:cloudsync_sa_static",
"${utils_path}:libdistributedfileutils",
]
external_deps = [
"ability_base:want",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"googletest:gmock",
"googletest:gtest",
"hilog:libhilog",
"hisysevent:libhisysevent",
"init:libbegetutil",
"ipc:ipc_core",
"netmanager_base:net_conn_manager_if",
"relational_store:native_rdb",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
defines = [
"private=public",
"LOG_DOMAIN=0xD004310",
"LOG_TAG=\"CLOUD_SYNC_TEST\"",
]
if (cloudsync_service_resource_schedule) {
external_deps += [ "resource_schedule_service:ressched_client" ]
defines += [ "CLOUDSYNC_SERVICE_RESOURCE_SCHEDULE" ]
}
use_exceptions = true
}
group("cloudsync_sa_sync_rule_test") {
testonly = true
deps = [
@ -393,6 +510,8 @@ group("cloudsync_sa_sync_rule_test") {
":cloud_status_test",
":network_set_manager_test",
":network_status_test",
":screen_status_listener_test",
":system_load_test",
":user_status_listener_test",
]
}

View File

@ -0,0 +1,181 @@
# 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.
import("//build/test.gni")
import("//foundation/filemanagement/dfs_service/distributedfile.gni")
ohos_unittest("cloud_sync_service_transport_manager_test") {
module_out_path = "filemanagement/dfs_service"
sources = [
"${distributedfile_path}/frameworks/native/cloudsync_kit_inner/src/cloud_sync_common.cpp",
"${distributedfile_path}/test/mock/cloudsyncservice/transport/softbus_adapter_mock.cpp",
"${distributedfile_path}/test/mock/cloudsyncservice/transport/softbus_session_mock.cpp",
"${distributedfile_path}/test/mock/socket_mock.cpp",
"${distributedfile_path}/test/unittests/cloudsync_sa/mock/parameters.cpp",
"${services_path}/cloudsyncservice/src/ipc/download_asset_callback_manager.cpp",
"${services_path}/cloudsyncservice/src/ipc/download_asset_callback_proxy.cpp",
"${services_path}/cloudsyncservice/src/transport/file_transfer_manager.cpp",
"${services_path}/cloudsyncservice/src/transport/message_handler.cpp",
"${services_path}/cloudsyncservice/src/transport/softbus/session_manager.cpp",
"file_transfer_manager_test.cpp",
"message_handler_test.cpp",
"softbus/session_manager_test.cpp",
]
include_dirs = [
"${clouddisk_database_path}/include",
"${distributedfile_path}/test/mock",
"${distributedfile_path}/test/mock/cloudsyncservice/transport",
"${distributedfile_path}/test/unittests/cloudsync_api/cloudsync_impl/include",
"${distributedfile_path}/test/unittests/cloudsync_sa/mock/",
"${services_path}/cloudsyncservice/include",
"${services_path}/cloudsyncservice/include/transport",
"${services_path}/cloudsyncservice/include/transport/softbus",
"${services_path}/cloudfiledaemon/include/cloud_disk",
"${innerkits_native_path}/cloudsync_kit_inner",
]
deps = [
"${clouddisk_database_path}:clouddisk_database",
"${innerkits_native_path}/cloud_file_kit_inner:cloudfile_kit",
"${utils_path}:libdistributedfiledentry",
"${utils_path}:libdistributedfileutils",
]
external_deps = [
"ability_base:want",
"ability_base:zuri",
"ability_runtime:dataobs_manager",
"app_file_service:sandbox_helper_native",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"dfs_service:cloudsync_kit_inner",
"dsoftbus:softbus_client",
"ffrt:libffrt",
"googletest:gmock",
"googletest:gtest",
"hilog:libhilog",
"hisysevent:libhisysevent",
"hitrace:hitrace_meter",
"ipc:ipc_single",
"libfuse:libfuse",
"netmanager_base:net_conn_manager_if",
"os_account:os_account_innerkits",
"relational_store:native_rdb",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
defines = [
"private=public",
"LOG_DOMAIN=0xD004307",
"LOG_TAG=\"CLOUDSYNC_TEST\"",
]
if (cloudsync_service_hicollie_enable) {
external_deps += [ "hicollie:libhicollie" ]
defines += [ "HICOLLIE_ENABLE" ]
}
if (cloudsync_service_resource_schedule) {
external_deps += [ "resource_schedule_service:ressched_client" ]
defines += [ "CLOUDSYNC_SERVICE_RESOURCE_SCHEDULE" ]
}
use_exceptions = true
}
ohos_unittest("cloud_sync_service_transport_softbus_test") {
module_out_path = "filemanagement/dfs_service"
sources = [
"${distributedfile_path}/frameworks/native/cloudsync_kit_inner/src/cloud_sync_common.cpp",
"${distributedfile_path}/test/mock/socket_mock.cpp",
"${distributedfile_path}/test/unittests/cloudsync_sa/mock/parameters.cpp",
"${services_path}/cloudsyncservice/src/ipc/download_asset_callback_manager.cpp",
"${services_path}/cloudsyncservice/src/ipc/download_asset_callback_proxy.cpp",
"${services_path}/cloudsyncservice/src/transport/file_transfer_manager.cpp",
"${services_path}/cloudsyncservice/src/transport/message_handler.cpp",
"${services_path}/cloudsyncservice/src/transport/softbus/session_manager.cpp",
"${services_path}/cloudsyncservice/src/transport/softbus/softbus_adapter.cpp",
"${services_path}/cloudsyncservice/src/transport/softbus/softbus_session.cpp",
"softbus/softbus_adapter_test.cpp",
"softbus/softbus_session_test.cpp",
]
include_dirs = [
"${clouddisk_database_path}/include",
"${distributedfile_path}/test/mock",
"${distributedfile_path}/test/unittests/cloudsync_api/cloudsync_impl/include",
"${distributedfile_path}/test/unittests/cloudsync_sa/mock/",
"${services_path}/cloudsyncservice/include",
"${services_path}/cloudsyncservice/include/transport",
"${services_path}/cloudsyncservice/include/transport/softbus",
"${services_path}/cloudfiledaemon/include/cloud_disk",
"${innerkits_native_path}/cloudsync_kit_inner",
]
deps = [
"${clouddisk_database_path}:clouddisk_database",
"${innerkits_native_path}/cloud_file_kit_inner:cloudfile_kit",
"${utils_path}:libdistributedfiledentry",
"${utils_path}:libdistributedfileutils",
]
external_deps = [
"ability_base:want",
"ability_base:zuri",
"ability_runtime:dataobs_manager",
"app_file_service:sandbox_helper_native",
"c_utils:utils",
"common_event_service:cesfwk_innerkits",
"dfs_service:cloudsync_kit_inner",
"dsoftbus:softbus_client",
"ffrt:libffrt",
"googletest:gmock",
"googletest:gtest",
"hilog:libhilog",
"hisysevent:libhisysevent",
"hitrace:hitrace_meter",
"ipc:ipc_single",
"libfuse:libfuse",
"netmanager_base:net_conn_manager_if",
"os_account:os_account_innerkits",
"relational_store:native_rdb",
"safwk:system_ability_fwk",
"samgr:samgr_proxy",
]
defines = [
"private=public",
"LOG_DOMAIN=0xD004307",
"LOG_TAG=\"CLOUDSYNC_TEST\"",
]
if (cloudsync_service_hicollie_enable) {
external_deps += [ "hicollie:libhicollie" ]
defines += [ "HICOLLIE_ENABLE" ]
}
if (cloudsync_service_resource_schedule) {
external_deps += [ "resource_schedule_service:ressched_client" ]
defines += [ "CLOUDSYNC_SERVICE_RESOURCE_SCHEDULE" ]
}
use_exceptions = true
}
group("cloudsync_sa_transport_test") {
testonly = true
deps = [
":cloud_sync_service_transport_manager_test",
":cloud_sync_service_transport_softbus_test",
]
}