From f7eb3a358a6417ad77bebe5e9abf6918130c7680 Mon Sep 17 00:00:00 2001 From: liuhonglin9 Date: Tue, 12 Dec 2023 09:34:03 +0000 Subject: [PATCH] NotifyTddBugFix Signed-off-by: liuhonglin9 Change-Id: I943daa7ee680472a067b61cde38a3e0df151b74e --- test/unittest/BUILD.gn | 5 ++++- test/unittest/external_notify_test.cpp | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 6ac19bba..624f5b03 100644 --- a/test/unittest/BUILD.gn +++ b/test/unittest/BUILD.gn @@ -72,7 +72,10 @@ ohos_unittest("external_file_access_test") { } module_out_path = "user_file_service/tests" - sources = [ "external_file_access_test.cpp" ] + sources = [ + "external_file_access_test.cpp", + "external_notify_test.cpp", + ] include_dirs = [ "${ability_runtime_path}/interfaces/kits/native/appkit/ability_runtime/context", diff --git a/test/unittest/external_notify_test.cpp b/test/unittest/external_notify_test.cpp index 5618df0f..c9b01304 100644 --- a/test/unittest/external_notify_test.cpp +++ b/test/unittest/external_notify_test.cpp @@ -290,12 +290,14 @@ HWTEST_F(FileExtensionNotifyTest, external_file_access_notify_0001, testing::ext result = g_fah->Delete(newFileUri2); EXPECT_EQ(result, OHOS::FileAccessFwk::ERR_OK); usleep(SLEEP_TIME); - EXPECT_EQ(g_notifyEvent, DELETE_EVENT); + EXPECT_TRUE(g_notifyEvent == DELETE_EVENT || g_notifyEvent == MOVED_SELF) + << "g_notifyEvent value: " << g_notifyEvent; EXPECT_EQ(g_notifyUri, newFileUri2.ToString()); result = g_fah->Delete(newFileUri3); EXPECT_EQ(result, OHOS::FileAccessFwk::ERR_OK); usleep(SLEEP_TIME); - EXPECT_EQ(g_notifyEvent, DELETE_EVENT); + EXPECT_TRUE(g_notifyEvent == DELETE_EVENT || g_notifyEvent == MOVED_SELF) + << "g_notifyEvent value: " << g_notifyEvent; EXPECT_EQ(g_notifyUri, newFileUri3.ToString()); sleep(1); @@ -554,7 +556,8 @@ HWTEST_F(FileExtensionNotifyTest, external_file_access_notify_0005, testing::ext result = g_fah->Delete(uri_dirSub1); EXPECT_EQ(result, OHOS::FileAccessFwk::ERR_OK); usleep(SLEEP_TIME); - EXPECT_EQ(g_notifyEvent, DELETE_EVENT); + EXPECT_TRUE(g_notifyEvent == DELETE_EVENT || g_notifyEvent == MOVED_FROM) + << "g_notifyEvent value: " << g_notifyEvent; EXPECT_EQ(g_notifyUri, uri_dirSub1.ToString()); sleep(2); @@ -599,7 +602,8 @@ HWTEST_F(FileExtensionNotifyTest, external_file_access_notify_0006, testing::ext result = g_fah->Delete(newFileUri1); EXPECT_EQ(result, OHOS::FileAccessFwk::ERR_OK); usleep(SLEEP_TIME); - EXPECT_EQ(g_notifyEvent, DELETE_EVENT); + EXPECT_TRUE(g_notifyEvent == DELETE_EVENT || g_notifyEvent == MOVED_SELF) + << "g_notifyEvent value: " << g_notifyEvent; EXPECT_EQ(g_notifyUri, newFileUri1.ToString()); sleep(1); result = g_fah->UnregisterNotify(newFileUri1, myObserver1); @@ -705,7 +709,8 @@ HWTEST_F(FileExtensionNotifyTest, external_file_access_notify_0009, testing::ext EXPECT_EQ(result, OHOS::FileAccessFwk::ERR_OK); result = g_fah->Delete(newFileUri1); usleep(SLEEP_TIME); - EXPECT_EQ(g_notifyEvent, DELETE_EVENT); + EXPECT_TRUE(g_notifyEvent == DELETE_EVENT || g_notifyEvent == MOVED_SELF) + << "g_notifyEvent value: " << g_notifyEvent; EXPECT_EQ(g_notifyUri, newFileUri1.ToString()); sleep(1); EXPECT_EQ(result, OHOS::FileAccessFwk::ERR_OK); @@ -823,7 +828,8 @@ HWTEST_F(FileExtensionNotifyTest, external_file_access_notify_0011, testing::ext result = g_fah->Delete(renameFileUri1); EXPECT_EQ(result, OHOS::FileAccessFwk::ERR_OK); usleep(SLEEP_TIME); - EXPECT_EQ(g_notifyEvent, DELETE_EVENT); + EXPECT_TRUE(g_notifyEvent == DELETE_EVENT || g_notifyEvent == MOVED_SELF) + << "g_notifyEvent value: " << g_notifyEvent; EXPECT_EQ(g_notifyUri, newFileUri1.ToString()); EXPECT_NE(g_notifyFlag, DELETE_EVENT); -- Gitee