diff --git a/test/unittest/BUILD.gn b/test/unittest/BUILD.gn index 6ac19bbaa3f7f4ff30f93f2686627a52663e473b..624f5b03ec36f1f01d637f54d88679baa8c8f6ee 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 5618df0f545f6bc7105e230de5f72874b3bbe978..c9b013040077d531bdf1cb020d8ac063f28566ce 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);