Fix the remaining unavailable TDD

Signed-off-by: xujintong <xujintong@huawei.com>
This commit is contained in:
xujintong 2023-12-19 21:39:26 +08:00
parent 3f29bb6359
commit 882aedacad
6 changed files with 121 additions and 27 deletions

33
cfi_blocklist.txt Normal file
View File

@ -0,0 +1,33 @@
# Copyright (C) 2022-2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# 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.
[cfi]
type:*OHOS::Parcel*
type:*OHOS::RefBase*
type:*OHOS::MessageParcel*
type:*OHOS::IRemoteObject*
type:*OHOS::IRemoteBroker*
type:*OHOS::IRemoteProxy*
type:*OHOS::BrokerRegistration*
type:*OHOS::BrokerDelegator*
type:*OHOS::BrokerCreator*
type:*OHOS::ISystemAbilityManager*
type:*OHOS::ThreadPool*
type:*OHOS::IPCSkeleton*
type:*OHOS::Security::AccessToken::AccessTokenKit*
type:*OHOS::AAFwk::SystemAbilityManagerClient*
type:*OHOS::SystemAbility*
type:*OHOS::AppExecFwk*
type:*OHOS::AAFwk::AbilityConnectionStub*
src:*third_party/googletest/googlemock/include/gmock/*
src:*third_party/googletest/googletest/include/gtest/*

View File

@ -0,0 +1,69 @@
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "module_app_gallery/app_gallery_dispose_proxy.h"
#include <string>
#include <gtest/gtest.h>
#include "message_parcel.h"
#include "want.h"
#include "module_app_gallery/app_gallery_service_connection.h"
namespace OHOS::FileManagement::Backup {
using namespace std;
AppGalleryDisposeProxy::AppGalleryDisposeProxy()
{
GTEST_LOG_(INFO) << "AppGalleryDisposeProxy is OK";
}
AppGalleryDisposeProxy::~AppGalleryDisposeProxy()
{
GTEST_LOG_(INFO) << "~AppGalleryDisposeProxy is OK";
}
sptr<AppGalleryDisposeProxy> AppGalleryDisposeProxy::GetInstance()
{
return new AppGalleryDisposeProxy;
}
DisposeErr AppGalleryDisposeProxy::StartBackup(const std::string &bundleName)
{
return DoDispose(bundleName, DisposeOperation::START_BACKUP);
}
DisposeErr AppGalleryDisposeProxy::EndBackup(const std::string &bundleName)
{
return DoDispose(bundleName, DisposeOperation::END_BACKUP);
}
DisposeErr AppGalleryDisposeProxy::StartRestore(const std::string &bundleName)
{
return DoDispose(bundleName, DisposeOperation::START_RESTORE);
}
DisposeErr AppGalleryDisposeProxy::EndRestore(const std::string &bundleName)
{
return DoDispose(bundleName, DisposeOperation::END_RESTORE);
}
DisposeErr AppGalleryDisposeProxy::DoDispose(const std::string &bundleName, DisposeOperation disposeOperation)
{
return DisposeErr::OK;
}
} // namespace OHOS::FileManagement::Backup

View File

@ -32,7 +32,7 @@ void SvcBackupConnection::OnAbilityConnectDone(const AppExecFwk::ElementName &el
int resultCode)
{
isConnected_.store(true);
backupProxy_ = iface_cast<SvcExtensionProxy>(remoteObject);
backupProxy_ = iface_cast<IExtension>(remoteObject);
string bundleName = "";
callConnDone_(move(bundleName));
}

View File

@ -76,6 +76,7 @@ ohos_unittest("backup_sa_impl_test") {
cfi = true
cfi_cross_dso = true
debug = false
blocklist = "${path_backup}/cfi_blocklist.txt"
}
use_exceptions = true

View File

@ -18,6 +18,7 @@ ohos_unittest("module_ipc_test") {
module_out_path = path_module_out_tests
sources = [
"${path_backup_mock}/timer/timer_mock.cpp",
"service_reverse_proxy_test.cpp",
"service_stub_test.cpp",
"svc_backup_connection_test.cpp",
@ -50,6 +51,13 @@ ohos_unittest("module_ipc_test") {
"storage_service:storage_manager_sa_proxy",
]
sanitize = {
cfi = true
cfi_cross_dso = true
debug = false
blocklist = "${path_backup}/cfi_blocklist.txt"
}
use_exceptions = true
}
@ -58,7 +66,8 @@ ohos_unittest("backup_service_test") {
sources = [
"${path_backup_mock}/accesstoken/accesstoken_kit_mock.cpp",
"${path_backup}/services/backup_sa/src/module_app_gallery/app_gallery_dispose_proxy.cpp",
"${path_backup_mock}/module_ipc/app_gallery_dispose_proxy_mock.cpp",
"${path_backup_mock}/timer/timer_mock.cpp",
"${path_backup}/services/backup_sa/src/module_ipc/service.cpp",
"${path_backup}/services/backup_sa/src/module_ipc/svc_restore_deps_manager.cpp",
"service_test.cpp",
@ -96,6 +105,13 @@ ohos_unittest("backup_service_test") {
"storage_service:storage_manager_sa_proxy",
]
sanitize = {
cfi = true
cfi_cross_dso = true
debug = false
blocklist = "${path_backup}/cfi_blocklist.txt"
}
use_exceptions = true
}

View File

@ -62,31 +62,6 @@ void SvcBackupConnectionTest::TearDown()
backupCon_ = nullptr;
}
/**
* @tc.number: SUB_BackupConnection_OnAbilityConnectDone_0100
* @tc.name: SUB_BackupConnection_OnAbilityConnectDone_0100
* @tc.desc: OnAbilityConnectDone
* @tc.size: MEDIUM
* @tc.type: FUNC
* @tc.level Level 1
* @tc.require: I6F3GV
*/
HWTEST_F(SvcBackupConnectionTest, SUB_BackupConnection_OnAbilityConnectDone_0100, testing::ext::TestSize.Level1)
{
GTEST_LOG_(INFO) << "SvcBackupConnectionTest-begin SUB_BackupConnection_OnAbilityConnectDone_0100";
AppExecFwk::ElementName element;
string bundleName = "";
element.SetBundleName(bundleName);
int resultCode = 1;
sptr<BackupExtExtensionMock> mock = sptr(new BackupExtExtensionMock());
backupCon_->OnAbilityConnectDone(element, mock->AsObject(), resultCode);
bool ret = backupCon_->IsExtAbilityConnected();
EXPECT_TRUE(ret);
mock = nullptr;
backupCon_->OnAbilityConnectDone(element, nullptr, resultCode);
GTEST_LOG_(INFO) << "SvcBackupConnectionTest-end SUB_BackupConnection_OnAbilityConnectDone_0100";
}
/**
* @tc.number: SUB_BackupConnection_OnAbilityDisconnectDone_0100
* @tc.name: SUB_BackupConnection_OnAbilityDisconnectDone_0100