From fe0c58b55ff62451d491d5d57c4d7be4764c7d57 Mon Sep 17 00:00:00 2001 From: jaychao Date: Fri, 29 Dec 2023 11:11:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=87=E4=BB=BD=E6=81=A2=E5=A4=8DTDD?= =?UTF-8?q?=E8=A1=A5=E5=85=85-/b=5Fsession=5Frestore=5Ftest=E3=80=81/b=5Fs?= =?UTF-8?q?ession=5Frestore=5Fasync=5Ftest.cpp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: jaychao --- .../b_session_restore_async_test.cpp | 30 ++++++++++++++++++- .../b_session_restore_test.cpp | 6 ++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/tests/moduletests/backup_kit_inner/b_session_restore_async_test.cpp b/tests/moduletests/backup_kit_inner/b_session_restore_async_test.cpp index e9badac6b..3c0c3f196 100644 --- a/tests/moduletests/backup_kit_inner/b_session_restore_async_test.cpp +++ b/tests/moduletests/backup_kit_inner/b_session_restore_async_test.cpp @@ -21,10 +21,10 @@ #include "b_error/b_error.h" #include "b_file_info.h" -#include "b_session_restore_async.h" #include "backup_kit_inner.h" #include "unique_fd.h" #include "utils_mock_global_variable.h" +#include "b_session_restore_async.h" namespace OHOS::FileManagement::Backup { using namespace std; @@ -250,4 +250,32 @@ HWTEST_F(BSessionRestoreAsyncTest, SUB_backup_b_session_restore_async_0600, test } GTEST_LOG_(INFO) << "BSessionRestoreAsyncTest-end SUB_backup_b_session_restore_async_0600"; } + +/** + * @tc.number: SUB_backup_b_session_restore_async_0700 + * @tc.name: SUB_backup_b_session_restore_async_0700 + * @tc.desc: 测试OnBackupServiceDied接口 + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + * @tc.require: I7L7A6 + */ +HWTEST_F(BSessionRestoreAsyncTest, SUB_backup_b_session_restore_async_0700, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "BSessionRestoreAsyncTest-begin SUB_backup_b_session_restore_async_0700"; + try { + GTEST_LOG_(INFO) << "GetInstance is true"; + SetMockGetInstance(true); + GTEST_LOG_(INFO) << "callbacks_.onBackupServiceDied is nullptr"; + callbacks_.onBackupServiceDied = nullptr; + restorePtr_->OnBackupServiceDied(); + GTEST_LOG_(INFO) << "callbacks_.onBackupServiceDied is not nullptr"; + Init(); + restorePtr_->OnBackupServiceDied(); + } catch (...) { + EXPECT_TRUE(false); + GTEST_LOG_(INFO) << "BSessionRestoreAsyncTest-an exception occurred by OnBackupServiceDied."; + } + GTEST_LOG_(INFO) << "BSessionRestoreAsyncTest-end SUB_backup_b_session_restore_async_0700"; +} } // namespace OHOS::FileManagement::Backup \ No newline at end of file diff --git a/tests/moduletests/backup_kit_inner/b_session_restore_test.cpp b/tests/moduletests/backup_kit_inner/b_session_restore_test.cpp index 77bded075..fc7806dd0 100644 --- a/tests/moduletests/backup_kit_inner/b_session_restore_test.cpp +++ b/tests/moduletests/backup_kit_inner/b_session_restore_test.cpp @@ -19,13 +19,13 @@ #include "b_error/b_error.h" #include "b_file_info.h" #include "backup_kit_inner.h" -#include "test_manager.h" #include "unique_fd.h" #include "utils_mock_global_variable.h" +#include "test_manager.h" -#include -#include #include +#include +#include namespace OHOS::FileManagement::Backup { using namespace std; -- Gitee