From c1d7c5ea9a2609567d7045133e67233c2380efef Mon Sep 17 00:00:00 2001 From: chensihan Date: Mon, 23 Sep 2024 16:18:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0ut=E7=94=A8=E4=BE=8B=20Signed?= =?UTF-8?q?-off-by:=20chensihan=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backup_impl/service_reverse_test.cpp | 66 +++++++ .../backup_tool/tools_op_restore_test.cpp | 48 +++++ .../backup_utils/b_filesystem/b_dir_test.cpp | 178 ++++++++++++++++++ 3 files changed, 292 insertions(+) diff --git a/tests/unittests/backup_api/backup_impl/service_reverse_test.cpp b/tests/unittests/backup_api/backup_impl/service_reverse_test.cpp index 98bccfac2..374fcda50 100644 --- a/tests/unittests/backup_api/backup_impl/service_reverse_test.cpp +++ b/tests/unittests/backup_api/backup_impl/service_reverse_test.cpp @@ -1751,4 +1751,70 @@ HWTEST_F(ServiceReverseTest, SUB_backup_ServiceReverse_IncrementalBackupOnResult } GTEST_LOG_(INFO) << "ServiceReverseTest-end SUB_backup_ServiceReverse_IncrementalBackupOnResultReport_0101"; } + +/** + * @tc.number: SUB_backup_ServiceReverse_IncrementalBackupOnProcessInfo_0100 + * @tc.name: SUB_backup_ServiceReverse_IncrementalBackupOnProcessInfo_0100 + * @tc.desc: 测试 IncrementalBackupOnProcessInfo 接口 + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: I9116W + */ +HWTEST_F(ServiceReverseTest, SUB_backup_ServiceReverse_IncrementalBackupOnProcessInfo_0100, + testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "ServiceReverseTest-begin SUB_backup_ServiceReverse_IncrementalBackupOnProcessInfo_0100"; + try { + IncrementalInit(IServiceReverse::Scenario::BACKUP, 1); + if (service_ == nullptr) { + GTEST_LOG_(INFO) << + "SUB_backup_ServiceReverse_IncrementalBackupOnProcessInfo_0100 service_ == nullptr"; + return; + } + std::string bundleName = BUNDLE_NAME; + std::string processInfo; + service_->IncrementalBackupOnProcessInfo(bundleName, processInfo); + + IncrementalInit(IServiceReverse::Scenario::RESTORE); + service_->IncrementalBackupOnProcessInfo(bundleName, processInfo); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "ServiceReverseTest-an exception occurred by IncrementalBackupOnProcessInfo."; + } + GTEST_LOG_(INFO) << "ServiceReverseTest-end SUB_backup_ServiceReverse_IncrementalBackupOnProcessInfo_0100"; +} + +/** + * @tc.number: SUB_backup_ServiceReverse_IncrementalRestoreOnProcessInfo_0100 + * @tc.name: SUB_backup_ServiceReverse_IncrementalRestoreOnProcessInfo_0100 + * @tc.desc: 测试 IncrementalRestoreOnProcessInfo 接口 + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: I9116W + */ +HWTEST_F(ServiceReverseTest, SUB_backup_ServiceReverse_IncrementalRestoreOnProcessInfo_0100, + testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "ServiceReverseTest-begin SUB_backup_ServiceReverse_IncrementalRestoreOnProcessInfo_0100"; + try { + IncrementalInit(IServiceReverse::Scenario::RESTORE, 1); + if (service_ == nullptr) { + GTEST_LOG_(INFO) << + "SUB_backup_ServiceReverse_IncrementalRestoreOnProcessInfo_0100 service_ == nullptr"; + return; + } + std::string bundleName = BUNDLE_NAME; + std::string processInfo; + service_->IncrementalRestoreOnProcessInfo(bundleName, processInfo); + + IncrementalInit(IServiceReverse::Scenario::BACKUP); + service_->IncrementalRestoreOnProcessInfo(bundleName, processInfo); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "ServiceReverseTest-an exception occurred by IncrementalRestoreOnProcessInfo."; + } + GTEST_LOG_(INFO) << "ServiceReverseTest-end SUB_backup_ServiceReverse_IncrementalRestoreOnProcessInfo_0100"; +} } // namespace OHOS::FileManagement::Backup \ No newline at end of file diff --git a/tests/unittests/backup_tools/backup_tool/tools_op_restore_test.cpp b/tests/unittests/backup_tools/backup_tool/tools_op_restore_test.cpp index 6244fabf5..58277f639 100644 --- a/tests/unittests/backup_tools/backup_tool/tools_op_restore_test.cpp +++ b/tests/unittests/backup_tools/backup_tool/tools_op_restore_test.cpp @@ -994,4 +994,52 @@ HWTEST_F(ToolsOpRestoreTest, tools_op_restore_Exec_1304, testing::ext::TestSize. } GTEST_LOG_(INFO) << "ToolsOpRestoreTest-end tools_op_restore_Exec_1304"; } + +/** + * @tc.number: SUB_backup_tools_op_restore_1305 + * @tc.name: tools_op_restore_Exec_1305 + * @tc.desc: test func + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: I9NOPD + */ +HWTEST_F(ToolsOpRestoreTest, tools_op_restore_Exec_1305, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "ToolsOpRestoreTest-begin tools_op_restore_Exec_1305"; + try { + map> mapArgToVal; + mapArgToVal["bundles"] = {"com.example.app2backup/"}; + int ret = Exec(mapArgToVal); + EXPECT_LT(ret, 0); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "ToolsOpRestoreTest-an exception occurred by construction."; + } + GTEST_LOG_(INFO) << "ToolsOpRestoreTest-end tools_op_restore_Exec_1305"; +} + +/** + * @tc.number: SUB_backup_tools_op_restore_1306 + * @tc.name: tools_op_restore_Exec_1306 + * @tc.desc: test func + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: I9NOPD + */ +HWTEST_F(ToolsOpRestoreTest, tools_op_restore_Exec_1306, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "ToolsOpRestoreTest-begin tools_op_restore_Exec_1306"; + try { + map> mapArgToVal; + mapArgToVal["pathCapFile"] = {"/data/backup/recived/com.example.app2backup/"}; + int ret = Exec(mapArgToVal); + EXPECT_LT(ret, 0); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "ToolsOpRestoreTest-an exception occurred by construction."; + } + GTEST_LOG_(INFO) << "ToolsOpRestoreTest-end tools_op_restore_Exec_1306"; +} } // namespace OHOS::FileManagement::Backup \ No newline at end of file diff --git a/tests/unittests/backup_utils/b_filesystem/b_dir_test.cpp b/tests/unittests/backup_utils/b_filesystem/b_dir_test.cpp index 531a63406..01c57d5ef 100644 --- a/tests/unittests/backup_utils/b_filesystem/b_dir_test.cpp +++ b/tests/unittests/backup_utils/b_filesystem/b_dir_test.cpp @@ -343,4 +343,182 @@ HWTEST_F(BDirTest, b_dir_GetFile_0100, testing::ext::TestSize.Level1) } GTEST_LOG_(INFO) << "BDirTest-end b_dir_GetFile_0100"; } + +/** + * @tc.number: SUB_backup_b_dir_GetBackupList_0100 + * @tc.name: b_dir_GetBackupList_0100 + * @tc.desc: Test function of GetBackupList interface + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: I6F3GV + */ +HWTEST_F(BDirTest, b_dir_GetBackupList_0100, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "BDirTest-begin b_dir_GetBackupList_0100"; + try { + vector includes; + vector excludes; + auto [bigFiles, smallFiles] = BDir::GetBackupList(includes, excludes); + EXPECT_EQ(bigFiles.size(), 0); + EXPECT_EQ(smallFiles.size(), 0); + } catch (...) { + GTEST_LOG_(INFO) << "BDirTest-an exception occurred."; + } + GTEST_LOG_(INFO) << "BDirTest-end b_dir_GetBackupList_0100"; +} + +/** + * @tc.number: SUB_backup_b_dir_GetBackupList_0200 + * @tc.name: b_dir_GetBackupList_0200 + * @tc.desc: Test function of GetBackupList interface + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: I6F3GV + */ +HWTEST_F(BDirTest, b_dir_GetBackupList_0200, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "BDirTest-begin b_dir_GetBackupList_0200"; + try { + vector includes = {"/data/"}; + vector excludes; + auto [bigFiles, smallFiles] = BDir::GetBackupList(includes, excludes); + EXPECT_NE(bigFiles.size(), 0); + EXPECT_NE(smallFiles.size(), 0); + } catch (...) { + GTEST_LOG_(INFO) << "BDirTest-an exception occurred."; + } + GTEST_LOG_(INFO) << "BDirTest-end b_dir_GetBackupList_0200"; +} + +/** + * @tc.number: SUB_backup_b_dir_GetBackupList_0300 + * @tc.name: b_dir_GetBackupList_0300 + * @tc.desc: Test function of GetBackupList interface + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: I6F3GV + */ +HWTEST_F(BDirTest, b_dir_GetBackupList_0300, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "BDirTest-begin b_dir_GetBackupList_0300"; + try { + vector includes = {"/data/app"}; + vector excludes; + auto [bigFiles, smallFiles] = BDir::GetBackupList(includes, excludes); + EXPECT_NE(bigFiles.size(), 0); + EXPECT_NE(smallFiles.size(), 0); + } catch (...) { + GTEST_LOG_(INFO) << "BDirTest-an exception occurred."; + } + GTEST_LOG_(INFO) << "BDirTest-end b_dir_GetBackupList_0300"; +} + +/** + * @tc.number: SUB_backup_b_dir_GetBackupList_0400 + * @tc.name: b_dir_GetBackupList_0400 + * @tc.desc: Test function of GetBackupList interface + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: I6F3GV + */ +HWTEST_F(BDirTest, b_dir_GetBackupList_0400, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "BDirTest-begin b_dir_GetBackupList_0400"; + try { + vector includes = {{}, {}}; + vector excludes = {{}}; + auto [bigFiles, smallFiles] = BDir::GetBackupList(includes, excludes); + EXPECT_EQ(bigFiles.size(), 0); + EXPECT_EQ(smallFiles.size(), 0); + } catch (...) { + GTEST_LOG_(INFO) << "BDirTest-an exception occurred."; + } + GTEST_LOG_(INFO) << "BDirTest-end b_dir_GetBackupList_0400"; +} + +/** + * @tc.number: SUB_backup_b_dir_GetUser0FileStat_0100 + * @tc.name: b_dir_GetUser0FileStat_0100 + * @tc.desc: Test function of GetUser0FileStat interface + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: I6F3GV + */ +HWTEST_F(BDirTest, b_dir_GetUser0FileStat_0100, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "BDirTest-begin b_dir_GetUser0FileStat_0100"; + try { + vector bigFile; + vector smallFile; + vector allFiles; + vector smallFiles; + vector bigFiles; + BDir::GetUser0FileStat(bigFile, smallFile, allFiles, smallFiles, bigFiles); + EXPECT_EQ(bigFiles.size(), 0); + } catch (...) { + GTEST_LOG_(INFO) << "BDirTest-an exception occurred."; + } + GTEST_LOG_(INFO) << "BDirTest-end b_dir_GetUser0FileStat_0100"; +} + +/** + * @tc.number: SUB_backup_b_dir_GetUser0FileStat_0200 + * @tc.name: b_dir_GetUser0FileStat_0200 + * @tc.desc: Test function of GetUser0FileStat interface + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: I6F3GV + */ +HWTEST_F(BDirTest, b_dir_GetUser0FileStat_0200, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "BDirTest-begin b_dir_GetUser0FileStat_0200"; + try { + vector includes = {"/data/"}; + vector excludes; + auto [bigFile, smallFile] = BDir::GetBackupList(includes, excludes); + vector allFiles; + vector smallFiles; + vector bigFiles; + BDir::GetUser0FileStat(bigFile, smallFile, allFiles, smallFiles, bigFiles); + EXPECT_NE(smallFiles.size(), 0); + EXPECT_NE(bigFiles.size(), 0); + } catch (...) { + GTEST_LOG_(INFO) << "BDirTest-an exception occurred."; + } + GTEST_LOG_(INFO) << "BDirTest-end b_dir_GetUser0FileStat_0200"; +} + +/** + * @tc.number: SUB_backup_b_dir_GetUser0FileStat_0300 + * @tc.name: b_dir_GetUser0FileStat_0300 + * @tc.desc: Test function of GetUser0FileStat interface + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: I6F3GV + */ +HWTEST_F(BDirTest, b_dir_GetUser0FileStat_0300, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "BDirTest-begin b_dir_GetUser0FileStat_0300"; + try { + vector includes = {{}, {}}; + vector excludes = {{}}; + auto [bigFile, smallFile] = BDir::GetBackupList(includes, excludes); + vector allFiles; + vector smallFiles; + vector bigFiles; + BDir::GetUser0FileStat(bigFile, smallFile, allFiles, smallFiles, bigFiles); + EXPECT_EQ(smallFiles.size(), 0); + EXPECT_EQ(bigFiles.size(), 0); + } catch (...) { + GTEST_LOG_(INFO) << "BDirTest-an exception occurred."; + } + GTEST_LOG_(INFO) << "BDirTest-end b_dir_GetUser0FileStat_0300"; +} } // namespace OHOS::FileManagement::Backup \ No newline at end of file -- Gitee