diff --git a/frameworks/native/distributed_file_inner/src/copy/remote_file_copy_manager.cpp b/frameworks/native/distributed_file_inner/src/copy/remote_file_copy_manager.cpp index dc041875573f92aaf7c3b54c9e4406d5a53326c3..947d6bf71d74d2e89f1569bd605c8991119c1517 100644 --- a/frameworks/native/distributed_file_inner/src/copy/remote_file_copy_manager.cpp +++ b/frameworks/native/distributed_file_inner/src/copy/remote_file_copy_manager.cpp @@ -194,7 +194,7 @@ int32_t RemoteFileCopyManager::RemoteCancel(const std::string &srcUri, const std auto callingUid = IPCSkeleton::GetCallingUid(); if (callingUid != (*item)->callingUid) { LOGE("RemoteCancel failed, calling uid=%{public}d has no permission to cancel copy for uid=%{public}d.", - callingUid, (*item)->callingUid); + callingUid, (*item)->callingUid); return EPERM; } LOGI("RemoteCancel success"); @@ -223,7 +223,7 @@ int32_t RemoteFileCopyManager::RemoteCopy(const std::string &srcUri, const std:: LOGE("CreateFileInfos failed,ret= %{public}d", ret); return ret; } - std::function processCallback = + std::function processCallback = [&listener](uint64_t processSize, uint64_t totalSize) -> void { if (processSize != totalSize) { listener->OnFileReceive(totalSize, processSize); diff --git a/services/distributedfiledaemon/test/unittest/network/softbus/softbus_permission_check_test.cpp b/services/distributedfiledaemon/test/unittest/network/softbus/softbus_permission_check_test.cpp index 7f3eab66bff55467502631401bdbb6f0f05f1b74..d1ad0f5744eb20306026fb35be41209d3692c608 100644 --- a/services/distributedfiledaemon/test/unittest/network/softbus/softbus_permission_check_test.cpp +++ b/services/distributedfiledaemon/test/unittest/network/softbus/softbus_permission_check_test.cpp @@ -209,7 +209,7 @@ HWTEST_F(SoftbusPermissionCheckTest, SoftbusPermissionCheckTest_GetLocalAccountI EXPECT_EQ(res, false); #endif - EXPECT_CALL(*otherMethodMock_, QueryActiveOsAccountIds(_))// GetLocalDeviceInfo = false + EXPECT_CALL(*otherMethodMock_, QueryActiveOsAccountIds(_)) // GetLocalDeviceInfo = false .WillOnce(DoAll(SetArgReferee<0>(userIds), Return(FileManagement::E_OK))); #ifdef SUPPORT_SAME_ACCOUNT osAccountInfo.uid_ = "test"; diff --git a/test/mock/device_manager_impl_mock.cpp b/test/mock/device_manager_impl_mock.cpp index b528a6cbb27e1dab0eb784230580ea490d3629c5..07876f10e7f2be5cb3d9ccc768560bdf1f7f5e5d 100644 --- a/test/mock/device_manager_impl_mock.cpp +++ b/test/mock/device_manager_impl_mock.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023 Huawei Device Co., Ltd. + * Copyright (c) 2023-2025 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 @@ -368,7 +368,7 @@ int32_t DeviceManagerImpl::GetNetworkTypeByNetworkId(const std::string &pkgName, } #endif -bool DeviceManagerImpl::CheckSrcAccessControl(const DmAccessCaller &caller,const DmAccessCallee &callee) +bool DeviceManagerImpl::CheckSrcAccessControl(const DmAccessCaller &caller, const DmAccessCallee &callee) { if (DfsDeviceManagerImpl::dfsDeviceManagerImpl == nullptr) { std::cout << "dfsDeviceManagerImpl is nullptr" << std::endl; @@ -377,7 +377,7 @@ bool DeviceManagerImpl::CheckSrcAccessControl(const DmAccessCaller &caller,const return DfsDeviceManagerImpl::dfsDeviceManagerImpl->CheckSrcAccessControl(caller, callee); } -bool DeviceManagerImpl::CheckSinkAccessControl(const DmAccessCaller &caller,const DmAccessCallee &callee) +bool DeviceManagerImpl::CheckSinkAccessControl(const DmAccessCaller &caller, const DmAccessCallee &callee) { if (DfsDeviceManagerImpl::dfsDeviceManagerImpl == nullptr) { std::cout << "dfsDeviceManagerImpl is nullptr" << std::endl; @@ -386,7 +386,7 @@ bool DeviceManagerImpl::CheckSinkAccessControl(const DmAccessCaller &caller,cons return DfsDeviceManagerImpl::dfsDeviceManagerImpl->CheckSinkAccessControl(caller, callee); } -bool DeviceManagerImpl::CheckSrcIsSameAccount(const DmAccessCaller &caller,const DmAccessCallee &callee) +bool DeviceManagerImpl::CheckSrcIsSameAccount(const DmAccessCaller &caller, const DmAccessCallee &callee) { if (DfsDeviceManagerImpl::dfsDeviceManagerImpl == nullptr) { std::cout << "dfsDeviceManagerImpl is nullptr" << std::endl; @@ -395,7 +395,7 @@ bool DeviceManagerImpl::CheckSrcIsSameAccount(const DmAccessCaller &caller,const return DfsDeviceManagerImpl::dfsDeviceManagerImpl->CheckSrcIsSameAccount(caller, callee); } -bool DeviceManagerImpl::CheckSinkIsSameAccount(const DmAccessCaller &caller,const DmAccessCallee &callee) +bool DeviceManagerImpl::CheckSinkIsSameAccount(const DmAccessCaller &caller, const DmAccessCallee &callee) { if (DfsDeviceManagerImpl::dfsDeviceManagerImpl == nullptr) { std::cout << "dfsDeviceManagerImpl is nullptr" << std::endl; diff --git a/test/mock/device_manager_impl_mock.h b/test/mock/device_manager_impl_mock.h index e7da200c23d384536b6721a8e4932e4936b8ce5e..aab0008ed29da95b620fada44a2900593324452e 100644 --- a/test/mock/device_manager_impl_mock.h +++ b/test/mock/device_manager_impl_mock.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Huawei Device Co., Ltd. + * Copyright (C) 2024-2025 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 @@ -37,10 +37,10 @@ public: const std::string &extra, std::shared_ptr callback) = 0; virtual int32_t UnRegisterDevStateCallback(const std::string &pkgName) = 0; virtual int32_t GetLocalDeviceInfo(const std::string &pkgName, DmDeviceInfo &info) = 0; - virtual bool CheckSrcAccessControl(const DmAccessCaller &caller,const DmAccessCallee &callee) = 0; - virtual bool CheckSinkAccessControl(const DmAccessCaller &caller,const DmAccessCallee &callee) = 0; - virtual bool CheckSrcIsSameAccount(const DmAccessCaller &caller,const DmAccessCallee &callee) = 0; - virtual bool CheckSinkIsSameAccount(const DmAccessCaller &caller,const DmAccessCallee &callee) = 0; + virtual bool CheckSrcAccessControl(const DmAccessCaller &caller, const DmAccessCallee &callee) = 0; + virtual bool CheckSinkAccessControl(const DmAccessCaller &caller, const DmAccessCallee &callee) = 0; + virtual bool CheckSrcIsSameAccount(const DmAccessCaller &caller, const DmAccessCallee &callee) = 0; + virtual bool CheckSinkIsSameAccount(const DmAccessCaller &caller, const DmAccessCallee &callee) = 0; #ifdef NORMAL_MOCK virtual int32_t GetNetworkTypeByNetworkId(const std::string &pkgName, const std::string &netWorkId, int32_t &netWorkType) = 0; @@ -63,10 +63,10 @@ public: MOCK_METHOD1(UnRegisterDevStateCallback, int32_t(const std::string &pkgName)); MOCK_METHOD2(GetLocalNodeDeviceInfo, int32_t(const char *pkgName, NodeBasicInfo *info)); MOCK_METHOD2(GetLocalDeviceInfo, int32_t(const std::string &pkgName, DmDeviceInfo &info)); - MOCK_METHOD2(CheckSrcAccessControl, bool(const DmAccessCaller &caller,const DmAccessCallee &callee)); - MOCK_METHOD2(CheckSinkAccessControl, bool(const DmAccessCaller &caller,const DmAccessCallee &callee)); - MOCK_METHOD2(CheckSrcIsSameAccount, bool(const DmAccessCaller &caller,const DmAccessCallee &callee)); - MOCK_METHOD2(CheckSinkIsSameAccount, bool(const DmAccessCaller &caller,const DmAccessCallee &callee)); + MOCK_METHOD2(CheckSrcAccessControl, bool(const DmAccessCaller &caller, const DmAccessCallee &callee)); + MOCK_METHOD2(CheckSinkAccessControl, bool(const DmAccessCaller &caller, const DmAccessCallee &callee)); + MOCK_METHOD2(CheckSrcIsSameAccount, bool(const DmAccessCaller &caller, const DmAccessCallee &callee)); + MOCK_METHOD2(CheckSinkIsSameAccount, bool(const DmAccessCaller &caller, const DmAccessCallee &callee)); #ifdef NORMAL_MOCK MOCK_METHOD3(GetNetworkTypeByNetworkId, int32_t(const std::string &pkgName, const std::string &netWorkId, int32_t &netWorkType)); diff --git a/test/unittests/distributed_file_inner/copy/remote_file_copy_manager_test.cpp b/test/unittests/distributed_file_inner/copy/remote_file_copy_manager_test.cpp index 4ee604018d08c19f43ecb8afb4632718e8825233..808031f676550b6ffd5eac62861c4f34f19dab92 100644 --- a/test/unittests/distributed_file_inner/copy/remote_file_copy_manager_test.cpp +++ b/test/unittests/distributed_file_inner/copy/remote_file_copy_manager_test.cpp @@ -32,7 +32,8 @@ std::string g_physicalPath = "/test/test"; int32_t g_getPhysicalPath = 0; namespace OHOS::AppFileService { -int32_t SandboxHelper::GetPhysicalPath(const std::string &fileUri, const std::string &userId, std::string &physicalPath) +int32_t SandboxHelper::GetPhysicalPath(const std::string &fileUri, + const std::string &userId, std::string &physicalPath) { physicalPath = g_physicalPath; return g_getPhysicalPath; @@ -98,20 +99,24 @@ HWTEST_F(RemoteFileCopyManagerTest, RemoteFileCopyManager_Copy_0001, TestSize.Le sptr listenerCallback; - auto ret = Storage::DistributedFile::RemoteFileCopyManager::GetInstance()->RemoteCopy("", localUri, listenerCallback, userId, copyPath); + auto ret = Storage::DistributedFile::RemoteFileCopyManager::GetInstance()->RemoteCopy( + "", localUri, listenerCallback, userId, copyPath); EXPECT_EQ(ret, EINVAL); - ret = Storage::DistributedFile::RemoteFileCopyManager::GetInstance()->RemoteCopy(localUri, "", listenerCallback, userId, copyPath); + ret = Storage::DistributedFile::RemoteFileCopyManager::GetInstance()->RemoteCopy( + localUri, "", listenerCallback, userId, copyPath); EXPECT_EQ(ret, EINVAL); - ret = Storage::DistributedFile::RemoteFileCopyManager::GetInstance()->RemoteCopy("", "", listenerCallback, userId, copyPath); + ret = Storage::DistributedFile::RemoteFileCopyManager::GetInstance()->RemoteCopy( + "", "", listenerCallback, userId, copyPath); EXPECT_EQ(ret, EINVAL); string remoteUri = "/data/test/Copy/?networkid=/"; if (!ForceCreateDirectory(remoteUri)) { GTEST_LOG_(INFO) << "RemoteFileCopyManager_Copy_0001 create dir err"; } - ret = Storage::DistributedFile::RemoteFileCopyManager::GetInstance()->RemoteCopy(remoteUri, "", listenerCallback, userId, copyPath); + ret = Storage::DistributedFile::RemoteFileCopyManager::GetInstance()->RemoteCopy( + remoteUri, "", listenerCallback, userId, copyPath); EXPECT_EQ(ret, EINVAL); if (!ForceRemoveDirectory(remoteUri)) { GTEST_LOG_(INFO) << "RemoteFileCopyManager_Copy_0001 remove dir err"; @@ -233,7 +238,8 @@ HWTEST_F(RemoteFileCopyManagerTest, RemoteFileCopyManager_CreateFileInfos_0001, infos->srcUri = ""; int32_t userId = 100; string copyPath = "/data/storage/el2/distributedfiles/123412345/test.txt"; - int32_t ret = Storage::DistributedFile::RemoteFileCopyManager::GetInstance()->CreateFileInfos("", "", infos, userId, copyPath); + int32_t ret = Storage::DistributedFile::RemoteFileCopyManager::GetInstance()->CreateFileInfos( + "", "", infos, userId, copyPath); EXPECT_EQ(ret, E_OK); GTEST_LOG_(INFO) << "RemoteFileCopyManager_CreateFileInfos_0001 End"; }