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 e9badac6b36cf72a9dafa31b8a0e2a9881eb4a37..3c0c3f196cf6fdd9124d13487bd8ae5dcf525042 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 77bded075e92f4ad1b095e24c4beb3db98652fc4..fc7806dd08afae8a158e059456dddc931345ffc8 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;