From 255267c5477829bdaf523d4c256ee49954badf30 Mon Sep 17 00:00:00 2001 From: yangbiao59 Date: Fri, 20 Jun 2025 15:47:50 +0800 Subject: [PATCH 1/5] add tdd Signed-off-by: yangbiao59 --- interfaces/test/unittest/js/BUILD.gn | 9 + .../properties/copy_file_core_mock_test.cpp | 408 ++++++++++++++++ .../mod_fs/properties/copy_file_core_test.cpp | 98 ++++ .../properties/fsync_core_mock_test.cpp | 98 ++++ .../js/mod_fs/properties/lseek_core_test.cpp | 115 +++++ .../mod_fs/properties/move_core_mock_test.cpp | 450 ++++++++++++++++++ .../js/mod_fs/properties/move_core_test.cpp | 166 +++++++ .../properties/rename_core_mock_test.cpp | 102 ++++ .../mod_fs/properties/stat_core_mock_test.cpp | 153 ++++++ .../js/mod_fs/properties/stat_core_test.cpp | 94 ++++ 10 files changed, 1693 insertions(+) create mode 100644 interfaces/test/unittest/js/mod_fs/properties/copy_file_core_mock_test.cpp create mode 100644 interfaces/test/unittest/js/mod_fs/properties/copy_file_core_test.cpp create mode 100644 interfaces/test/unittest/js/mod_fs/properties/fsync_core_mock_test.cpp create mode 100644 interfaces/test/unittest/js/mod_fs/properties/lseek_core_test.cpp create mode 100644 interfaces/test/unittest/js/mod_fs/properties/move_core_mock_test.cpp create mode 100644 interfaces/test/unittest/js/mod_fs/properties/move_core_test.cpp create mode 100644 interfaces/test/unittest/js/mod_fs/properties/rename_core_mock_test.cpp create mode 100644 interfaces/test/unittest/js/mod_fs/properties/stat_core_mock_test.cpp create mode 100644 interfaces/test/unittest/js/mod_fs/properties/stat_core_test.cpp diff --git a/interfaces/test/unittest/js/BUILD.gn b/interfaces/test/unittest/js/BUILD.gn index d3fc839a0..f11999473 100644 --- a/interfaces/test/unittest/js/BUILD.gn +++ b/interfaces/test/unittest/js/BUILD.gn @@ -35,11 +35,15 @@ ohos_unittest("ani_file_fs_test") { "mod_fs/class_randomaccessfile/fs_randomaccessfile_test.cpp", "mod_fs/class_stream/fs_stream_test.cpp", "mod_fs/properties/close_core_test.cpp", + "mod_fs/properties/copy_file_core_test.cpp", "mod_fs/properties/create_randomaccessfile_core_test.cpp", "mod_fs/properties/create_stream_core_test.cpp", "mod_fs/properties/fdopen_stream_core_test.cpp", "mod_fs/properties/listfile_core_test.cpp", + "mod_fs/properties/lseek_core_test.cpp", + "mod_fs/properties/move_core_test.cpp", "mod_fs/properties/read_text_core_test.cpp", + "mod_fs/properties/stat_core_test.cpp", ] deps = [ @@ -85,8 +89,13 @@ ohos_unittest("ani_file_fs_mock_test") { sources = [ "mod_fs/class_randomaccessfile/fs_randomaccessfile_mock_test.cpp", + "mod_fs/properties/copy_file_core_mock_test.cpp", "mod_fs/properties/create_randomaccessfile_core_mock_test.cpp", + "mod_fs/properties/fsync_core_mock_test.cpp", "mod_fs/properties/mock/uv_fs_mock.cpp", + "mod_fs/properties/move_core_mock_test.cpp", + "mod_fs/properties/rename_core_mock_test.cpp", + "mod_fs/properties/stat_core_mock_test.cpp", ] deps = [ diff --git a/interfaces/test/unittest/js/mod_fs/properties/copy_file_core_mock_test.cpp b/interfaces/test/unittest/js/mod_fs/properties/copy_file_core_mock_test.cpp new file mode 100644 index 000000000..af533602a --- /dev/null +++ b/interfaces/test/unittest/js/mod_fs/properties/copy_file_core_mock_test.cpp @@ -0,0 +1,408 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "copy_file_core.h" +#include "uv_fs_mock.h" + +#include + +namespace OHOS::FileManagement::ModuleFileIO::Test { +using namespace testing; +using namespace testing::ext; +using namespace std; + +class CopyFileCoreTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + static inline shared_ptr uvfs = nullptr; +}; + +void CopyFileCoreTest::SetUpTestCase(void) +{ + uvfs = std::make_shared(); + Uvfs::ins = uvfs; + GTEST_LOG_(INFO) << "SetUpTestCase"; +} + +void CopyFileCoreTest::TearDownTestCase(void) +{ + Uvfs::ins = nullptr; + uvfs = nullptr; + GTEST_LOG_(INFO) << "TearDownTestCase"; +} + +void CopyFileCoreTest::SetUp(void) +{ + GTEST_LOG_(INFO) << "SetUp"; +} + +void CopyFileCoreTest::TearDown(void) +{ + GTEST_LOG_(INFO) << "TearDown"; +} + +/** + * @tc.name: CopyFileCoreTest_DoCopyFile_001 + * @tc.desc: Test function of CopyFileCore::ValidMode interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_001, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_001"; + + FileInfo src; + FileInfo dest; + optional mode = std::make_optional(1); + + auto res = CopyFileCore::DoCopyFile(src, dest, mode); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_001"; +} + +/** + * @tc.name: CopyFileCoreTest_DoCopyFile_003 + * @tc.desc: Test function of CopyFileCore::OpenFile.OpenCore interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_003, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_003"; + + FileInfo src; + FileInfo dest; + src.isPath = true; + dest.isPath = false; + + EXPECT_CALL(*uvfs, uv_fs_open(_, _, _, _, _, _)).Times(1).WillOnce(Return(-1)); + + auto res = CopyFileCore::DoCopyFile(src, dest); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_003"; +} + +/** + * @tc.name: CopyFileCoreTest_DoCopyFile_004 + * @tc.desc: Test function of CopyFileCore::OpenFile.OpenCore interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_004, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_004"; + + FileInfo src; + FileInfo dest; + src.isPath = true; + dest.isPath = false; + src.fdg = make_unique(1); + + EXPECT_CALL(*uvfs, uv_fs_open(_, _, _, _, _, _)).Times(1).WillOnce(Return(1)); + + auto res = CopyFileCore::DoCopyFile(src, dest); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_004"; +} + +/** + * @tc.name: CopyFileCoreTest_DoCopyFile_005 + * @tc.desc: Test function of CopyFileCore::OpenFile.OpenCore interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_005, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_005"; + + FileInfo src; + FileInfo dest; + src.isPath = false; + dest.isPath = true; + int fd = open("test.txt", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); + ASSERT_NE(fd, -1); + src.fdg = make_unique(fd); + + EXPECT_CALL(*uvfs, uv_fs_open(_, _, _, _, _, _)).Times(1).WillOnce(Return(-1)); + + auto res = CopyFileCore::DoCopyFile(src, dest); + EXPECT_EQ(res.IsSuccess(), false); + close(fd); + + GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_005"; +} + +/** + * @tc.name: CopyFileCoreTest_DoCopyFile_006 + * @tc.desc: Test function of CopyFileCore::OpenFile.OpenCore interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_006, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_006"; + + FileInfo src; + FileInfo dest; + src.isPath = false; + dest.isPath = true; + int fd = open("test.txt", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); + ASSERT_NE(fd, -1); + src.fdg = make_unique(fd); + + EXPECT_CALL(*uvfs, uv_fs_open(_, _, _, _, _, _)).Times(1).WillOnce(Return(1)); + + auto res = CopyFileCore::DoCopyFile(src, dest); + EXPECT_EQ(res.IsSuccess(), true); + close(fd); + + GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_006"; +} + +/** + * @tc.name: CopyFileCoreTest_DoCopyFile_007 + * @tc.desc: Test function of CopyFileCore::OpenFile.TruncateCore interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_007, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_007"; + + FileInfo src; + FileInfo dest; + src.isPath = false; + dest.isPath = false; + int fd = open("test.txt", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); + ASSERT_NE(fd, -1); + src.fdg = make_unique(fd); + dest.fdg = make_unique(fd); + + EXPECT_CALL(*uvfs, uv_fs_ftruncate(_, _, _, _, _)).Times(1).WillOnce(Return(-1)); + + auto res = CopyFileCore::DoCopyFile(src, dest); + EXPECT_EQ(res.IsSuccess(), false); + close(fd); + + GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_007"; +} + +/** + * @tc.name: CopyFileCoreTest_DoCopyFile_008 + * @tc.desc: Test function of CopyFileCore::OpenFile.TruncateCore interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_008, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_008"; + + FileInfo src; + FileInfo dest; + src.isPath = false; + dest.isPath = false; + int fd = open("test.txt", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); + ASSERT_NE(fd, -1); + src.fdg = make_unique(fd); + dest.fdg = make_unique(); + + EXPECT_CALL(*uvfs, uv_fs_ftruncate(_, _, _, _, _)).Times(1).WillOnce(Return(1)); + + auto res = CopyFileCore::DoCopyFile(src, dest); + EXPECT_EQ(res.IsSuccess(), false); + close(fd); + + GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_008"; +} + +/** + * @tc.name: CopyFileCoreTest_DoCopyFile_009 + * @tc.desc: Test function of CopyFileCore::OpenFile.TruncateCore interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_009, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_009"; + + FileInfo src; + FileInfo dest; + src.isPath = false; + dest.isPath = false; + + int srcfd = open("src.txt", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); + int destfd = open("dest.txt", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); + ASSERT_NE(srcfd, -1); + ASSERT_NE(destfd, -1); + src.fdg = make_unique(srcfd); + dest.fdg = make_unique(destfd); + + EXPECT_CALL(*uvfs, uv_fs_ftruncate(_, _, _, _, _)).Times(1).WillOnce(Return(1)); + + auto res = CopyFileCore::DoCopyFile(src, dest); + EXPECT_EQ(res.IsSuccess(), true); + close(srcfd); + close(destfd); + + GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_009"; +} + +/** + * @tc.name: CopyFileCoreTest_DoCopyFile_0010 + * @tc.desc: Test function of CopyFileCore::OpenFile.SendFileCore interface for false. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_0010, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_0010"; + + FileInfo src; + FileInfo dest; + src.isPath = false; + dest.isPath = true; + + int srcfd = open("src.txt", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); + ASSERT_NE(srcfd, -1); + const char* data = "Hello, World!"; + ssize_t len = write(srcfd, data, strlen(data)); + ASSERT_NE(len, -1); + src.fdg = make_unique(srcfd); + + EXPECT_CALL(*uvfs, uv_fs_open(_, _, _, _, _, _)).Times(1).WillOnce(Return(1)); + EXPECT_CALL(*uvfs, uv_fs_sendfile(_, _, _, _, _, _, _)).Times(1).WillOnce(Return(-1)); + + auto res = CopyFileCore::DoCopyFile(src, dest); + EXPECT_EQ(res.IsSuccess(), false); + close(srcfd); + + GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_0010"; +} + +/** + * @tc.name: CopyFileCoreTest_DoCopyFile_0011 + * @tc.desc: Test function of CopyFileCore::OpenFile.SendFileCore interface for false. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_0011, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_0011"; + + FileInfo src; + FileInfo dest; + src.isPath = false; + dest.isPath = true; + + int srcfd = open("src.txt", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); + ASSERT_NE(srcfd, -1); + const char* data = "Hello, World!"; + ssize_t len = write(srcfd, data, strlen(data)); + ASSERT_NE(len, -1); + src.fdg = make_unique(srcfd); + + EXPECT_CALL(*uvfs, uv_fs_open(_, _, _, _, _, _)).Times(1).WillOnce(Return(1)); + EXPECT_CALL(*uvfs, uv_fs_sendfile(_, _, _, _, _, _, _)).Times(1).WillOnce(Return(len + 1)); + + auto res = CopyFileCore::DoCopyFile(src, dest); + EXPECT_EQ(res.IsSuccess(), false); + close(srcfd); + + GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_0011"; +} + +/** + * @tc.name: CopyFileCoreTest_DoCopyFile_0012 + * @tc.desc: Test function of CopyFileCore::OpenFile.SendFileCore interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_0012, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_0012"; + + FileInfo src; + FileInfo dest; + src.isPath = false; + dest.isPath = true; + + int srcfd = open("src.txt", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); + ASSERT_NE(srcfd, -1); + const char* data = "Hello, World!"; + ssize_t len = write(srcfd, data, strlen(data)); + ASSERT_NE(len, -1); + src.fdg = make_unique(srcfd); + + EXPECT_CALL(*uvfs, uv_fs_open(_, _, _, _, _, _)).Times(1).WillOnce(Return(1)); + EXPECT_CALL(*uvfs, uv_fs_sendfile(_, _, _, _, _, _, _)).Times(1).WillOnce(Return(len)); + + auto res = CopyFileCore::DoCopyFile(src, dest); + EXPECT_EQ(res.IsSuccess(), true); + close(srcfd); + + GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_0012"; +} + +/** + * @tc.name: CopyFileCoreTest_DoCopyFile_0013 + * @tc.desc: Test function of CopyFileCore::OpenFile.SendFileCore interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_0013, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_0013"; + + FileInfo src; + FileInfo dest; + src.isPath = false; + dest.isPath = true; + + int srcfd = open("src.txt", O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); + ASSERT_NE(srcfd, -1); + const char* data = "Hello, World!"; + ssize_t len = write(srcfd, data, strlen(data)); + ASSERT_NE(len, -1); + src.fdg = make_unique(srcfd); + + EXPECT_CALL(*uvfs, uv_fs_open(_, _, _, _, _, _)).Times(1).WillOnce(Return(1)); + EXPECT_CALL(*uvfs, uv_fs_sendfile(_, _, _, _, _, _, _)).Times(1).WillOnce(Return(0)); + + auto res = CopyFileCore::DoCopyFile(src, dest); + EXPECT_EQ(res.IsSuccess(), false); + close(srcfd); + + GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_0013"; +} + +} // namespace OHOS::FileManagement::ModuleFileIO::Test \ No newline at end of file diff --git a/interfaces/test/unittest/js/mod_fs/properties/copy_file_core_test.cpp b/interfaces/test/unittest/js/mod_fs/properties/copy_file_core_test.cpp new file mode 100644 index 000000000..8d14cda0e --- /dev/null +++ b/interfaces/test/unittest/js/mod_fs/properties/copy_file_core_test.cpp @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "copy_file_core.h" + +#include + +namespace OHOS::FileManagement::ModuleFileIO::Test { +using namespace testing; +using namespace testing::ext; +using namespace std; + +class CopyFileCoreMockTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; + +void CopyFileCoreMockTest::SetUpTestCase(void) +{ + GTEST_LOG_(INFO) << "SetUpTestCase"; +} + +void CopyFileCoreMockTest::TearDownTestCase(void) +{ + GTEST_LOG_(INFO) << "TearDownTestCase"; +} + +void CopyFileCoreMockTest::SetUp(void) +{ + GTEST_LOG_(INFO) << "SetUp"; +} + +void CopyFileCoreMockTest::TearDown(void) +{ + GTEST_LOG_(INFO) << "TearDown"; +} + +/** + * @tc.name: CopyFileCoreMockTest_DoCopyFile_001 + * @tc.desc: Test function of CopyFileCore::ValidMode interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(CopyFileCoreMockTest, CopyFileCoreMockTest_DoCopyFile_001, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-begin CopyFileCoreMockTest_DoCopyFile_001"; + + FileInfo src; + FileInfo dest; + optional mode = std::make_optional(1); + + auto res = CopyFileCore::DoCopyFile(src, dest, mode); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-end CopyFileCoreMockTest_DoCopyFile_001"; +} + +/** + * @tc.name: CopyFileCoreMockTest_DoCopyFile_002 + * @tc.desc: Test function of CopyFileCore::ValidMode interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(CopyFileCoreMockTest, CopyFileCoreMockTest_DoCopyFile_002, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-begin CopyFileCoreMockTest_DoCopyFile_002"; + + FileInfo src; + FileInfo dest; + src.isPath = true; + dest.isPath = true; + src.path = std::make_unique(1); + dest.path = std::make_unique(1); + + auto res = CopyFileCore::DoCopyFile(src, dest); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-end CopyFileCoreMockTest_DoCopyFile_002"; +} + +} // namespace OHOS::FileManagement::ModuleFileIO::Test \ No newline at end of file diff --git a/interfaces/test/unittest/js/mod_fs/properties/fsync_core_mock_test.cpp b/interfaces/test/unittest/js/mod_fs/properties/fsync_core_mock_test.cpp new file mode 100644 index 000000000..688a5bca0 --- /dev/null +++ b/interfaces/test/unittest/js/mod_fs/properties/fsync_core_mock_test.cpp @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "fsync_core.h" +#include "uv_fs_mock.h" + +#include + +namespace OHOS::FileManagement::ModuleFileIO::Test { +using namespace testing; +using namespace testing::ext; +using namespace std; + +class FsyncCoreMockTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + static inline shared_ptr uvfs = nullptr; +}; + +void FsyncCoreMockTest::SetUpTestCase(void) +{ + uvfs = std::make_shared(); + Uvfs::ins = uvfs; + GTEST_LOG_(INFO) << "SetUpTestCase"; +} + +void FsyncCoreMockTest::TearDownTestCase(void) +{ + Uvfs::ins = nullptr; + uvfs = nullptr; + GTEST_LOG_(INFO) << "TearDownTestCase"; +} + +void FsyncCoreMockTest::SetUp(void) +{ + GTEST_LOG_(INFO) << "SetUp"; +} + +void FsyncCoreMockTest::TearDown(void) +{ + GTEST_LOG_(INFO) << "TearDown"; +} + +/** + * @tc.name: FsyncCoreMockTest_DoFsync_001 + * @tc.desc: Test function of RenameCore::DoFsync interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(FsyncCoreMockTest, FsyncCoreMockTest_DoFsync_001, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "FsyncCoreMockTest-begin FsyncCoreMockTest_DoFsync_001"; + + EXPECT_CALL(*uvfs, uv_fs_fsync(_, _, _, _)).WillOnce(Return(-1)); + + auto res = FsyncCore::DoFsync(1); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "FsyncCoreMockTest-end FsyncCoreMockTest_DoFsync_001"; +} + +/** + * @tc.name: FsyncCoreMockTest_DoFsync_002 + * @tc.desc: Test function of RenameCore::DoFsync interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(FsyncCoreMockTest, FsyncCoreMockTest_DoFsync_002, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "FsyncCoreMockTest-begin FsyncCoreMockTest_DoFsync_002"; + + EXPECT_CALL(*uvfs, uv_fs_fsync(_, _, _, _)).WillOnce(Return(1)); + + auto res = FsyncCore::DoFsync(1); + EXPECT_EQ(res.IsSuccess(), true); + + GTEST_LOG_(INFO) << "FsyncCoreMockTest-end FsyncCoreMockTest_DoFsync_002"; +} + + +} // namespace OHOS::FileManagement::ModuleFileIO::Test \ No newline at end of file diff --git a/interfaces/test/unittest/js/mod_fs/properties/lseek_core_test.cpp b/interfaces/test/unittest/js/mod_fs/properties/lseek_core_test.cpp new file mode 100644 index 000000000..f5bd78bb7 --- /dev/null +++ b/interfaces/test/unittest/js/mod_fs/properties/lseek_core_test.cpp @@ -0,0 +1,115 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "lseek_core.h" + +#include + +namespace OHOS::FileManagement::ModuleFileIO::Test { +using namespace testing; +using namespace testing::ext; +using namespace std; + +class LseekCoreTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; + +void LseekCoreTest::SetUpTestCase(void) +{ + GTEST_LOG_(INFO) << "SetUpTestCase"; +} + +void LseekCoreTest::TearDownTestCase(void) +{ + GTEST_LOG_(INFO) << "TearDownTestCase"; +} + +void LseekCoreTest::SetUp(void) +{ + GTEST_LOG_(INFO) << "SetUp"; +} + +void LseekCoreTest::TearDown(void) +{ + GTEST_LOG_(INFO) << "TearDown"; +} + +/** + * @tc.name: LseekCoreTest_DoLseek_001 + * @tc.desc: Test function of LseekCore::DoLseek interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(LseekCoreTest, LseekCoreTest_DoLseek_001, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "LseekCoreTest-begin LseekCoreTest_DoLseek_001"; + + int32_t fd = -1; + int64_t offset = 0; + + auto res = LseekCore::DoLseek(fd, offset); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "LseekCoreTest-end LseekCoreTest_DoLseek_001"; +} + +/** + * @tc.name: LseekCoreTest_DoLseek_002 + * @tc.desc: Test function of LseekCore::DoLseek interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(LseekCoreTest, LseekCoreTest_DoLseek_002, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "LseekCoreTest-begin LseekCoreTest_DoLseek_002"; + + int32_t fd = 1; + int64_t offset = 0; + optional pos = std::make_optional(static_cast(-1)); + + auto res = LseekCore::DoLseek(fd, offset, pos); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "LseekCoreTest-end LseekCoreTest_DoLseek_002"; +} + +/** + * @tc.name: LseekCoreTest_DoLseek_003 + * @tc.desc: Test function of LseekCore::DoLseek interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(LseekCoreTest, LseekCoreTest_DoLseek_003, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "LseekCoreTest-begin LseekCoreTest_DoLseek_003"; + + int32_t fd = 1; + int64_t offset = 0; + optional pos = std::make_optional(SeekPos::CURRENT); + + auto res = LseekCore::DoLseek(fd, offset, pos); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "LseekCoreTest-end LseekCoreTest_DoLseek_003"; +} + +} // namespace OHOS::FileManagement::ModuleFileIO::Test \ No newline at end of file diff --git a/interfaces/test/unittest/js/mod_fs/properties/move_core_mock_test.cpp b/interfaces/test/unittest/js/mod_fs/properties/move_core_mock_test.cpp new file mode 100644 index 000000000..175fd3ab1 --- /dev/null +++ b/interfaces/test/unittest/js/mod_fs/properties/move_core_mock_test.cpp @@ -0,0 +1,450 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "move_core.h" +#include "uv_fs_mock.h" + +#include + +namespace OHOS::FileManagement::ModuleFileIO::Test { +using namespace testing; +using namespace testing::ext; +using namespace std; + +class MoveCoreMockTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + static inline std::shared_ptr uvMock = nullptr; +}; + +void MoveCoreMockTest::SetUpTestCase(void) +{ + GTEST_LOG_(INFO) << "SetUpTestCase"; + uvMock = std::make_shared(); + Uvfs::ins = uvMock; +} + +void MoveCoreMockTest::TearDownTestCase(void) +{ + GTEST_LOG_(INFO) << "TearDownTestCase"; + Uvfs::ins = nullptr; + uvMock = nullptr; +} + +void MoveCoreMockTest::SetUp(void) +{ + GTEST_LOG_(INFO) << "SetUp"; +} + +void MoveCoreMockTest::TearDown(void) +{ + GTEST_LOG_(INFO) << "TearDown"; +} + +extern "C" { + const char* uv_err_name(int err) + { + return "EXDEV"; + } +} + +/** + * @tc.name: MoveCoreMockTest_DoMove_000 + * @tc.desc: Test function of MoveCore::DoMove interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_000, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "MoveCoreMockTest-begin MoveCoreMockTest_DoMove_000"; + + std::string src; + std::string dest; + + EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(0)); + EXPECT_CALL(*uvMock, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(0)); + + auto res = MoveCore::DoMove(src, dest); + EXPECT_EQ(res.IsSuccess(), true); + + GTEST_LOG_(INFO) << "MoveCoreMockTest-end MoveCoreMockTest_DoMove_000"; +} + +/** + * @tc.name: MoveCoreMockTest_DoMove_001 + * @tc.desc: Test function of MoveCore::DoMove interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_001, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "MoveCoreMockTest-begin MoveCoreMockTest_DoMove_001"; + + std::string src; + std::string dest; + + EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(0)); + EXPECT_CALL(*uvMock, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(-1)); + + auto res = MoveCore::DoMove(src, dest); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "MoveCoreMockTest-end MoveCoreMockTest_DoMove_001"; +} + +/** + * @tc.name: MoveCoreMockTest_DoMove_002 + * @tc.desc: Test function of MoveCore::DoMove interface for FAILED. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_002, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "MoveCoreMockTest-begin MoveCoreMockTest_DoMove_002"; + + std::string src; + std::string dest; + optional mode = std::make_optional(MODE_FORCE_MOVE); + + EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(0)); + EXPECT_CALL(*uvMock, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(-1)); + + auto res = MoveCore::DoMove(src, dest, mode); + EXPECT_EQ(res.IsSuccess(), false); + GTEST_LOG_(INFO) << "MoveCoreMockTest-end MoveCoreMockTest_DoMove_002"; +} + +/** + * @tc.name: MoveCoreMockTest_DoMove_003 + * @tc.desc: Test function of MoveCore::DoMove interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_003, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "MoveCoreMockTest-begin MoveCoreMockTest_DoMove_003"; + + std::string src; + std::string dest; + + EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(-1)); + + auto res = MoveCore::DoMove(src, dest); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "MoveCoreMockTest-end MoveCoreMockTest_DoMove_003"; +} + +/** + * @tc.name: MoveCoreMockTest_DoMove_004 + * @tc.desc: Test function of MoveCore::DoMove interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_004, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "MoveCoreMockTest-begin MoveCoreMockTest_DoMove_004"; + + std::string src; + std::string dest; + optional mode = std::make_optional(MODE_THROW_ERR); + + EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(1)).WillOnce(Return(0)); + + auto res = MoveCore::DoMove(src, dest, mode); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "MoveCoreMockTest-end MoveCoreMockTest_DoMove_004"; +} + +/** + * @tc.name: MoveCoreMockTest_DoMove_005 + * @tc.desc: Test function of MoveCore::DoMove interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_005, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "MoveCoreMockTest-begin MoveCoreMockTest_DoMove_005"; + + std::string src; + std::string dest; + optional mode = std::make_optional(MODE_THROW_ERR); + + EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(1)).WillOnce(Return(-1)); + + auto res = MoveCore::DoMove(src, dest, mode); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "MoveCoreMockTest-end MoveCoreMockTest_DoMove_005"; +} + +/** + * @tc.name: MoveCoreMockTest_DoMove_006 + * @tc.desc: Test function of MoveCore::DoMove interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_006, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "MoveCoreMockTest-begin MoveCoreMockTest_DoMove_006"; + + std::string src; + std::string dest; + optional mode = std::make_optional(MODE_FORCE_MOVE); + + EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(1)); + EXPECT_CALL(*uvMock, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(-1)); + + auto res = MoveCore::DoMove(src, dest, mode); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "MoveCoreMockTest-end MoveCoreMockTest_DoMove_006"; +} + +/** + * @tc.name: MoveCoreMockTest_DoMove_007 + * @tc.desc: Test function of MoveCore::DoMove interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_007, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "MoveCoreMockTest-begin MoveCoreMockTest_DoMove_007"; + + std::string src; + std::string dest; + optional mode = std::make_optional(MODE_FORCE_MOVE); + + EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(1)); + EXPECT_CALL(*uvMock, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(1)); + + auto res = MoveCore::DoMove(src, dest, mode); + EXPECT_EQ(res.IsSuccess(), true); + + GTEST_LOG_(INFO) << "MoveCoreMockTest-end MoveCoreMockTest_DoMove_007"; +} + +/** + * @tc.name: MoveCoreMockTest_DoMove_008 + * @tc.desc: Test function of MoveCore::DoMove interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_008, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "MoveCoreMockTest-begin MoveCoreMockTest_DoMove_008"; + + std::string src; + std::string dest; + + EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(0)); + EXPECT_CALL(*uvMock, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(1)); + + auto res = MoveCore::DoMove(src, dest); + EXPECT_EQ(res.IsSuccess(), true); + + GTEST_LOG_(INFO) << "MoveCoreMockTest-end MoveCoreMockTest_DoMove_008"; +} + +/** + * @tc.name: MoveCoreMockTest_DoMove_009 + * @tc.desc: Test function of MoveCore::DoMove interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_009, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "MoveCoreMockTest-begin MoveCoreMockTest_DoMove_009"; + + std::string src; + std::string dest; + optional mode = std::make_optional(MODE_FORCE_MOVE); + + EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(1)); + EXPECT_CALL(*uvMock, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(-1)); + EXPECT_CALL(*uvMock, uv_fs_stat(_, _, _, _)).WillOnce(Return(-1)); + + auto res = MoveCore::DoMove(src, dest, mode); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "MoveCoreMockTest-end MoveCoreMockTest_DoMove_009"; +} + +/** + * @tc.name: MoveCoreMockTest_DoMove_0010 + * @tc.desc: Test function of MoveCore::DoMove interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_0010, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "MoveCoreMockTest-begin MoveCoreMockTest_DoMove_0010"; + + std::string src; + std::string dest = "file.txt"; + optional mode = std::make_optional(MODE_FORCE_MOVE); + + int fd = open(dest.c_str(), O_RDWR | O_CREAT, 0666); + ASSERT_NE(fd, -1); + + EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(1)); + EXPECT_CALL(*uvMock, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(-1)); + EXPECT_CALL(*uvMock, uv_fs_stat(_, _, _, _)).WillOnce(Return(1)); + + auto res = MoveCore::DoMove(src, dest, mode); + EXPECT_EQ(res.IsSuccess(), false); + close(fd); + + GTEST_LOG_(INFO) << "MoveCoreMockTest-end MoveCoreMockTest_DoMove_0010"; +} + +/** + * @tc.name: MoveCoreMockTest_DoMove_0011 + * @tc.desc: Test function of MoveCore::DoMove interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_0011, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "MoveCoreMockTest-begin MoveCoreMockTest_DoMove_0011"; + + std::string src; + std::string dest; + optional mode = std::make_optional(MODE_FORCE_MOVE); + + EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(1)); + EXPECT_CALL(*uvMock, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(-1)); + EXPECT_CALL(*uvMock, uv_fs_stat(_, _, _, _)).WillOnce(Return(1)); + + auto res = MoveCore::DoMove(src, dest, mode); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "MoveCoreMockTest-end MoveCoreMockTest_DoMove_0011"; +} + +/** + * @tc.name: MoveCoreMockTest_DoMove_0012 + * @tc.desc: Test function of MoveCore::DoMove interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_0012, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "MoveCoreMockTest-begin MoveCoreMockTest_DoMove_0012"; + + std::string src = "file.txt"; + std::string dest = "dest.txt"; + optional mode = std::make_optional(MODE_FORCE_MOVE); + + int fd = open(src.c_str(), O_RDWR | O_CREAT, 0666); + ASSERT_NE(fd, -1); + + EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(1)); + EXPECT_CALL(*uvMock, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(-1)); + EXPECT_CALL(*uvMock, uv_fs_stat(_, _, _, _)).WillOnce(Return(1)); + EXPECT_CALL(*uvMock, uv_fs_unlink(_, _, _, _)).WillOnce(Return(-1)).WillOnce(Return(-1)); + + auto res = MoveCore::DoMove(src, dest, mode); + EXPECT_EQ(res.IsSuccess(), false); + + ASSERT_EQ(unlink(src.c_str()), 0); + close(fd); + + GTEST_LOG_(INFO) << "MoveCoreMockTest-end MoveCoreMockTest_DoMove_0012"; +} + +/** + * @tc.name: MoveCoreMockTest_DoMove_0013 + * @tc.desc: Test function of MoveCore::DoMove interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_0013, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "MoveCoreMockTest-begin MoveCoreMockTest_DoMove_0013"; + + std::string src = "file.txt"; + std::string dest = "dest.txt"; + optional mode = std::make_optional(MODE_FORCE_MOVE); + + int fd = open(src.c_str(), O_RDWR | O_CREAT, 0666); + ASSERT_NE(fd, -1); + + EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(1)); + EXPECT_CALL(*uvMock, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(-1)); + EXPECT_CALL(*uvMock, uv_fs_stat(_, _, _, _)).WillOnce(Return(1)); + EXPECT_CALL(*uvMock, uv_fs_unlink(_, _, _, _)).WillOnce(Return(-1)).WillOnce(Return(1)); + + auto res = MoveCore::DoMove(src, dest, mode); + EXPECT_EQ(res.IsSuccess(), false); + + ASSERT_EQ(unlink(src.c_str()), 0); + close(fd); + + GTEST_LOG_(INFO) << "MoveCoreMockTest-end MoveCoreMockTest_DoMove_0013"; +} + +/** + * @tc.name: MoveCoreMockTest_DoMove_0014 + * @tc.desc: Test function of MoveCore::DoMove interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(MoveCoreMockTest, MoveCoreMockTest_DoMove_0014, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "MoveCoreMockTest-begin MoveCoreMockTest_DoMove_0013"; + + std::string src = "file.txt"; + std::string dest = "dest.txt"; + optional mode = std::make_optional(MODE_FORCE_MOVE); + + int fd = open(src.c_str(), O_RDWR | O_CREAT, 0666); + ASSERT_NE(fd, -1); + + EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(1)); + EXPECT_CALL(*uvMock, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(-1)); + EXPECT_CALL(*uvMock, uv_fs_stat(_, _, _, _)).WillOnce(Return(1)); + EXPECT_CALL(*uvMock, uv_fs_unlink(_, _, _, _)).WillOnce(Return(1)); + + auto res = MoveCore::DoMove(src, dest, mode); + EXPECT_EQ(res.IsSuccess(), true); + + ASSERT_EQ(unlink(src.c_str()), 0); + close(fd); + + GTEST_LOG_(INFO) << "MoveCoreMockTest-end MoveCoreMockTest_DoMove_0013"; +} + + +} // namespace OHOS::FileManagement::ModuleFileIO::Test \ No newline at end of file diff --git a/interfaces/test/unittest/js/mod_fs/properties/move_core_test.cpp b/interfaces/test/unittest/js/mod_fs/properties/move_core_test.cpp new file mode 100644 index 000000000..e17eeaf30 --- /dev/null +++ b/interfaces/test/unittest/js/mod_fs/properties/move_core_test.cpp @@ -0,0 +1,166 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "move_core.h" + +#include +#include + + +namespace OHOS::FileManagement::ModuleFileIO::Test { +using namespace testing; +using namespace testing::ext; +using namespace std; + +class MoveCoreTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; + +void MoveCoreTest::SetUpTestCase(void) +{ + GTEST_LOG_(INFO) << "SetUpTestCase"; +} + +void MoveCoreTest::TearDownTestCase(void) +{ + GTEST_LOG_(INFO) << "TearDownTestCase"; +} + +void MoveCoreTest::SetUp(void) +{ + GTEST_LOG_(INFO) << "SetUp"; +} + +void MoveCoreTest::TearDown(void) +{ + GTEST_LOG_(INFO) << "TearDown"; +} + +/** + * @tc.name: MoveCoreTest_DoMove_001 + * @tc.desc: Test function of MoveCore::DoMove interface for ERROR. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(MoveCoreTest, MoveCoreTest_DoMove_001, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "MoveCoreTest-begin MoveCoreTest_DoMove_001"; + + std::string src = ""; + std::string dest = ""; + + auto res = MoveCore::DoMove(src, dest); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "MoveCoreTest-end MoveCoreTest_DoMove_001"; +} + +/** + * @tc.name: MoveCoreTest_DoMove_002 + * @tc.desc: Test function of MoveCore::DoMove interface for ERROR. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(MoveCoreTest, MoveCoreTest_DoMove_002, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "MoveCoreTest-begin MoveCoreTest_DoMove_002"; + + std::string src = "/src.txt"; + std::string dest = ""; + + auto res = MoveCore::DoMove(src, dest); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "MoveCoreTest-end MoveCoreTest_DoMove_002"; +} + +/** + * @tc.name: MoveCoreTest_DoMove_003 + * @tc.desc: Test function of MoveCore::DoMove interface for ERROR. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(MoveCoreTest, MoveCoreTest_DoMove_003, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "MoveCoreTest-begin MoveCoreTest_DoMove_003"; + + std::string src = "/src.txt"; + std::string dest = "/dest.txt"; + int mode = 3; + + auto res = MoveCore::DoMove(src, dest, mode); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "MoveCoreTest-end MoveCoreTest_DoMove_003"; +} + +/** + * @tc.name: MoveCoreTest_DoMove_004 + * @tc.desc: Test function of MoveCore::DoMove interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(MoveCoreTest, MoveCoreTest_DoMove_004, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "MoveCoreTest-begin MoveCoreTest_DoMove_004"; + + std::string src = "dir"; + std::string dest = "/dest.txt"; + int mode = 3; + + std::filesystem::path dirpath = "dir"; + ASSERT_TRUE(std::filesystem::create_directories(dirpath)); + + auto res = MoveCore::DoMove(src, dest, mode); + EXPECT_EQ(res.IsSuccess(), false); + + std::filesystem::remove(dirpath); + GTEST_LOG_(INFO) << "MoveCoreTest-end MoveCoreTest_DoMove_004"; +} + +/** + * @tc.name: MoveCoreTest_DoMove_005 + * @tc.desc: Test function of MoveCore::DoMove interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(MoveCoreTest, MoveCoreTest_DoMove_005, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "MoveCoreTest-begin MoveCoreTest_DoMove_005"; + + std::string src = "/src.txt"; + std::string dest = "dir"; + int mode = 3; + + std::filesystem::path dirpath = "dir"; + ASSERT_TRUE(std::filesystem::create_directories(dirpath)); + + auto res = MoveCore::DoMove(src, dest, mode); + EXPECT_EQ(res.IsSuccess(), false); + + std::filesystem::remove(dirpath); + GTEST_LOG_(INFO) << "MoveCoreTest-end MoveCoreTest_DoMove_005"; +} + +} // namespace OHOS::FileManagement::ModuleFileIO::Test \ No newline at end of file diff --git a/interfaces/test/unittest/js/mod_fs/properties/rename_core_mock_test.cpp b/interfaces/test/unittest/js/mod_fs/properties/rename_core_mock_test.cpp new file mode 100644 index 000000000..910487a21 --- /dev/null +++ b/interfaces/test/unittest/js/mod_fs/properties/rename_core_mock_test.cpp @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "rename_core.h" +#include "uv_fs_mock.h" + +#include + +namespace OHOS::FileManagement::ModuleFileIO::Test { +using namespace testing; +using namespace testing::ext; +using namespace std; + +class RenameCoreMockTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + static inline shared_ptr uvfs = nullptr; +}; + +void RenameCoreMockTest::SetUpTestCase(void) +{ + uvfs = std::make_shared(); + Uvfs::ins = uvfs; + GTEST_LOG_(INFO) << "SetUpTestCase"; +} + +void RenameCoreMockTest::TearDownTestCase(void) +{ + Uvfs::ins = nullptr; + uvfs = nullptr; + GTEST_LOG_(INFO) << "TearDownTestCase"; +} + +void RenameCoreMockTest::SetUp(void) +{ + GTEST_LOG_(INFO) << "SetUp"; +} + +void RenameCoreMockTest::TearDown(void) +{ + GTEST_LOG_(INFO) << "TearDown"; +} + +/** + * @tc.name: RenameCoreMockTest_DoRename_001 + * @tc.desc: Test function of RenameCore::DoRename interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(RenameCoreMockTest, RenameCoreMockTest_DoRename_001, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RenameCoreMockTest-begin RenameCoreMockTest_DoRename_001"; + string src; + string dest; + + EXPECT_CALL(*uvfs, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(-1)); + + auto res = RenameCore::DoRename(src, dest); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "RenameCoreMockTest-end RenameCoreMockTest_DoRename_001"; +} + +/** + * @tc.name: RenameCoreMockTest_DoRename_002 + * @tc.desc: Test function of RenameCore::DoRename interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(RenameCoreMockTest, RenameCoreMockTest_DoRename_002, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "RenameCoreMockTest-begin RenameCoreMockTest_DoRename_002"; + string src; + string dest; + + EXPECT_CALL(*uvfs, uv_fs_rename(_, _, _, _, _)).WillOnce(Return(1)); + + auto res = RenameCore::DoRename(src, dest); + EXPECT_EQ(res.IsSuccess(), true); + + GTEST_LOG_(INFO) << "RenameCoreMockTest-end RenameCoreMockTest_DoRename_002"; +} + + +} // namespace OHOS::FileManagement::ModuleFileIO::Test \ No newline at end of file diff --git a/interfaces/test/unittest/js/mod_fs/properties/stat_core_mock_test.cpp b/interfaces/test/unittest/js/mod_fs/properties/stat_core_mock_test.cpp new file mode 100644 index 000000000..65958c9a0 --- /dev/null +++ b/interfaces/test/unittest/js/mod_fs/properties/stat_core_mock_test.cpp @@ -0,0 +1,153 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "stat_core.h" +#include "uv_fs_mock.h" + +#include +#include + +namespace OHOS::FileManagement::ModuleFileIO::Test { +using namespace testing; +using namespace testing::ext; +using namespace std; + +class StatCoreMockTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); + static inline shared_ptr uvfs = nullptr; +}; + +void StatCoreMockTest::SetUpTestCase(void) +{ + uvfs = std::make_shared(); + Uvfs::ins = uvfs; + GTEST_LOG_(INFO) << "SetUpTestCase"; +} + +void StatCoreMockTest::TearDownTestCase(void) +{ + Uvfs::ins = nullptr; + uvfs = nullptr; + GTEST_LOG_(INFO) << "TearDownTestCase"; +} + +void StatCoreMockTest::SetUp(void) +{ + GTEST_LOG_(INFO) << "SetUp"; +} + +void StatCoreMockTest::TearDown(void) +{ + GTEST_LOG_(INFO) << "TearDown"; +} + +/** + * @tc.name: StatCoreMockTest_DoStat_001 + * @tc.desc: Test function of StatCore::DoStat interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(StatCoreMockTest, StatCoreMockTest_DoStat_001, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "StatCoreMockTest-begin StatCoreMockTest_DoStat_001"; + + FileInfo fileinfo; + fileinfo.path = std::make_unique(1); + fileinfo.isPath = true; + + EXPECT_CALL(*uvfs, uv_fs_stat(_, _, _, _)).WillOnce(Return(-1)); + + auto res = StatCore::DoStat(fileinfo); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "StatCoreMockTest-end StatCoreMockTest_DoStat_001"; +} + +/** + * @tc.name: StatCoreMockTest_DoStat_002 + * @tc.desc: Test function of StatCore::DoStat interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(StatCoreMockTest, StatCoreMockTest_DoStat_002, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "StatCoreMockTest-begin StatCoreMockTest_DoStat_002"; + + FileInfo fileinfo; + fileinfo.path = std::make_unique(1); + fileinfo.isPath = true; + + EXPECT_CALL(*uvfs, uv_fs_stat(_, _, _, _)).WillOnce(Return(1)); + + auto res = StatCore::DoStat(fileinfo); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "StatCoreMockTest-end StatCoreMockTest_DoStat_002"; +} + +/** + * @tc.name: StatCoreMockTest_DoStat_003 + * @tc.desc: Test function of StatCore::DoStat interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(StatCoreMockTest, StatCoreMockTest_DoStat_003, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "StatCoreMockTest-begin StatCoreMockTest_DoStat_003"; + + FileInfo fileinfo; + fileinfo.path = std::make_unique(1); + fileinfo.isPath = false; + + EXPECT_CALL(*uvfs, uv_fs_stat(_, _, _, _)).WillOnce(Return(-1)); + + auto res = StatCore::DoStat(fileinfo); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "StatCoreMockTest-end StatCoreMockTest_DoStat_003"; +} + +/** + * @tc.name: StatCoreMockTest_DoStat_004 + * @tc.desc: Test function of StatCore::DoStat interface for SUCCESS. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(StatCoreMockTest, StatCoreMockTest_DoStat_004, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "StatCoreMockTest-begin StatCoreMockTest_DoStat_004"; + + FileInfo fileinfo; + fileinfo.path = std::make_unique(1); + fileinfo.fdg = std::make_unique(1); + fileinfo.isPath = false; + + EXPECT_CALL(*uvfs, uv_fs_stat(_, _, _, _)).WillOnce(Return(-1)); + + auto res = StatCore::DoStat(fileinfo); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "StatCoreMockTest-end StatCoreMockTest_DoStat_004"; +} + +} // namespace OHOS::FileManagement::ModuleFileIO::Test \ No newline at end of file diff --git a/interfaces/test/unittest/js/mod_fs/properties/stat_core_test.cpp b/interfaces/test/unittest/js/mod_fs/properties/stat_core_test.cpp new file mode 100644 index 000000000..f11d92625 --- /dev/null +++ b/interfaces/test/unittest/js/mod_fs/properties/stat_core_test.cpp @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "stat_core.h" + +#include + +namespace OHOS::FileManagement::ModuleFileIO::Test { +using namespace testing; +using namespace testing::ext; +using namespace std; + +class StatCoreTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; + +void StatCoreTest::SetUpTestCase(void) +{ + GTEST_LOG_(INFO) << "SetUpTestCase"; +} + +void StatCoreTest::TearDownTestCase(void) +{ + GTEST_LOG_(INFO) << "TearDownTestCase"; +} + +void StatCoreTest::SetUp(void) +{ + GTEST_LOG_(INFO) << "SetUp"; +} + +void StatCoreTest::TearDown(void) +{ + GTEST_LOG_(INFO) << "TearDown"; +} + +/** + * @tc.name: StatCoreTest_DoStat_001 + * @tc.desc: Test function of StatCore::DoStat interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(StatCoreTest, StatCoreTest_DoStat_001, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "StatCoreTest-begin StatCoreTest_DoStat_001"; + + FileInfo fileinfo; + + auto res = StatCore::DoStat(fileinfo); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "StatCoreTest-end StatCoreTest_DoStat_001"; +} + +/** + * @tc.name: StatCoreTest_DoStat_002 + * @tc.desc: Test function of StatCore::DoStat interface for FALSE. + * @tc.size: MEDIUM + * @tc.type: FUNC + * @tc.level Level 1 + */ +HWTEST_F(StatCoreTest, StatCoreTest_DoStat_002, testing::ext::TestSize.Level1) +{ + GTEST_LOG_(INFO) << "StatCoreTest-begin StatCoreTest_DoStat_002"; + + FileInfo fileinfo; + fileinfo.path = std::make_unique(1); + fileinfo.fdg = std::make_unique(-1); + fileinfo.isPath = false; + + auto res = StatCore::DoStat(fileinfo); + EXPECT_EQ(res.IsSuccess(), false); + + GTEST_LOG_(INFO) << "StatCoreTest-end StatCoreTest_DoStat_002"; +} + +} // namespace OHOS::FileManagement::ModuleFileIO::Test \ No newline at end of file -- Gitee From 331d3545118f7a470e6173c9abcc22df1db0a53d Mon Sep 17 00:00:00 2001 From: yangbiao59 Date: Sat, 21 Jun 2025 06:16:33 +0000 Subject: [PATCH 2/5] modify Signed-off-by: yangbiao59 --- interfaces/kits/js/src/mod_fs/properties/access_core.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/interfaces/kits/js/src/mod_fs/properties/access_core.cpp b/interfaces/kits/js/src/mod_fs/properties/access_core.cpp index d97f4aa80..299cb24f7 100644 --- a/interfaces/kits/js/src/mod_fs/properties/access_core.cpp +++ b/interfaces/kits/js/src/mod_fs/properties/access_core.cpp @@ -177,7 +177,6 @@ static bool ValidAccessArgs(const std::string &path, const std::optional Date: Sat, 21 Jun 2025 09:40:42 +0000 Subject: [PATCH 3/5] update interfaces/test/unittest/js/BUILD.gn. Signed-off-by: yangbiao59 --- interfaces/test/unittest/js/BUILD.gn | 1 - 1 file changed, 1 deletion(-) diff --git a/interfaces/test/unittest/js/BUILD.gn b/interfaces/test/unittest/js/BUILD.gn index 798f8d539..fe98f9851 100644 --- a/interfaces/test/unittest/js/BUILD.gn +++ b/interfaces/test/unittest/js/BUILD.gn @@ -104,7 +104,6 @@ ohos_unittest("ani_file_fs_mock_test") { "mod_fs/properties/rename_core_mock_test.cpp", "mod_fs/properties/stat_core_mock_test.cpp", "mod_fs/properties/mock/system_mock.cpp", - "mod_fs/properties/mock/uv_fs_mock.cpp", "mod_fs/properties/open_core_mock_test.cpp", ] -- Gitee From 466f1caa6a20551b92abf81581c604cfe6010239 Mon Sep 17 00:00:00 2001 From: yangbiao59 Date: Thu, 26 Jun 2025 06:39:37 +0000 Subject: [PATCH 4/5] modify Signed-off-by: yangbiao59 --- .../properties/access_core_mock_test.cpp | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/interfaces/test/unittest/js/mod_fs/properties/access_core_mock_test.cpp b/interfaces/test/unittest/js/mod_fs/properties/access_core_mock_test.cpp index b054b2a07..f4480c5de 100644 --- a/interfaces/test/unittest/js/mod_fs/properties/access_core_mock_test.cpp +++ b/interfaces/test/unittest/js/mod_fs/properties/access_core_mock_test.cpp @@ -146,27 +146,4 @@ HWTEST_F(AccessCoreMockTest, AccessCoreMockTest_DoAccess_004, testing::ext::Test GTEST_LOG_(INFO) << "AccessCoreMockTest-end AccessCoreMockTest_DoAccess_004"; } -/** - * @tc.name: AccessCoreMockTest_DoAccess_005 - * @tc.desc: Test function of AccessCore::DoAccess interface for success. - * @tc.size: MEDIUM - * @tc.type: FUNC - * @tc.level Level 1 - */ -HWTEST_F(AccessCoreMockTest, AccessCoreMockTest_DoAccess_005, testing::ext::TestSize.Level1) -{ - GTEST_LOG_(INFO) << "AccessCoreMockTest-begin AccessCoreMockTest_DoAccess_005"; - - std::string path = DISTRIBUTED_FILE_PREFIX; - AccessModeType mode = AccessModeType::EXIST; - AccessFlag flag = LOCAL_FLAG; - - EXPECT_CALL(*uvMock, uv_fs_access(_, _, _, _, _)).WillOnce(Return(0)); - - auto res = AccessCore::DoAccess(path, mode, flag); - EXPECT_EQ(res.IsSuccess(), true); - - GTEST_LOG_(INFO) << "AccessCoreMockTest-end AccessCoreMockTest_DoAccess_005"; -} - } // OHOS::FileManagement::ModuleFileIO::Test \ No newline at end of file -- Gitee From bb94ab7a6578eaba2d94ad796938a373c71c4e17 Mon Sep 17 00:00:00 2001 From: yangbiao59 Date: Fri, 27 Jun 2025 08:20:06 +0000 Subject: [PATCH 5/5] add Tdd2 Signed-off-by: yangbiao59 --- .../properties/copy_file_core_mock_test.cpp | 123 +++++++----------- .../mod_fs/properties/copy_file_core_test.cpp | 26 ++-- .../mod_fs/properties/stat_core_mock_test.cpp | 2 +- 3 files changed, 63 insertions(+), 88 deletions(-) diff --git a/interfaces/test/unittest/js/mod_fs/properties/copy_file_core_mock_test.cpp b/interfaces/test/unittest/js/mod_fs/properties/copy_file_core_mock_test.cpp index af533602a..0988ca22a 100644 --- a/interfaces/test/unittest/js/mod_fs/properties/copy_file_core_mock_test.cpp +++ b/interfaces/test/unittest/js/mod_fs/properties/copy_file_core_mock_test.cpp @@ -23,7 +23,7 @@ using namespace testing; using namespace testing::ext; using namespace std; -class CopyFileCoreTest : public testing::Test { +class CopyFileCoreMockTest : public testing::Test { public: static void SetUpTestCase(void); static void TearDownTestCase(void); @@ -32,40 +32,40 @@ public: static inline shared_ptr uvfs = nullptr; }; -void CopyFileCoreTest::SetUpTestCase(void) +void CopyFileCoreMockTest::SetUpTestCase(void) { uvfs = std::make_shared(); Uvfs::ins = uvfs; GTEST_LOG_(INFO) << "SetUpTestCase"; } -void CopyFileCoreTest::TearDownTestCase(void) +void CopyFileCoreMockTest::TearDownTestCase(void) { Uvfs::ins = nullptr; uvfs = nullptr; GTEST_LOG_(INFO) << "TearDownTestCase"; } -void CopyFileCoreTest::SetUp(void) +void CopyFileCoreMockTest::SetUp(void) { GTEST_LOG_(INFO) << "SetUp"; } -void CopyFileCoreTest::TearDown(void) +void CopyFileCoreMockTest::TearDown(void) { GTEST_LOG_(INFO) << "TearDown"; } /** - * @tc.name: CopyFileCoreTest_DoCopyFile_001 + * @tc.name: CopyFileCoreMockTest_DoCopyFile_001 * @tc.desc: Test function of CopyFileCore::ValidMode interface for FALSE. * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 */ -HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_001, testing::ext::TestSize.Level1) +HWTEST_F(CopyFileCoreMockTest, CopyFileCoreMockTest_DoCopyFile_001, testing::ext::TestSize.Level1) { - GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_001"; + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-begin CopyFileCoreMockTest_DoCopyFile_001"; FileInfo src; FileInfo dest; @@ -74,19 +74,19 @@ HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_001, testing::ext::TestSi auto res = CopyFileCore::DoCopyFile(src, dest, mode); EXPECT_EQ(res.IsSuccess(), false); - GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_001"; + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-end CopyFileCoreMockTest_DoCopyFile_001"; } /** - * @tc.name: CopyFileCoreTest_DoCopyFile_003 + * @tc.name: CopyFileCoreMockTest_DoCopyFile_003 * @tc.desc: Test function of CopyFileCore::OpenFile.OpenCore interface for FALSE. * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 */ -HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_003, testing::ext::TestSize.Level1) +HWTEST_F(CopyFileCoreMockTest, CopyFileCoreMockTest_DoCopyFile_003, testing::ext::TestSize.Level1) { - GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_003"; + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-begin CopyFileCoreMockTest_DoCopyFile_003"; FileInfo src; FileInfo dest; @@ -98,44 +98,19 @@ HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_003, testing::ext::TestSi auto res = CopyFileCore::DoCopyFile(src, dest); EXPECT_EQ(res.IsSuccess(), false); - GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_003"; + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-end CopyFileCoreMockTest_DoCopyFile_003"; } /** - * @tc.name: CopyFileCoreTest_DoCopyFile_004 + * @tc.name: CopyFileCoreMockTest_DoCopyFile_005 * @tc.desc: Test function of CopyFileCore::OpenFile.OpenCore interface for FALSE. * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 */ -HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_004, testing::ext::TestSize.Level1) +HWTEST_F(CopyFileCoreMockTest, CopyFileCoreMockTest_DoCopyFile_005, testing::ext::TestSize.Level1) { - GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_004"; - - FileInfo src; - FileInfo dest; - src.isPath = true; - dest.isPath = false; - src.fdg = make_unique(1); - - EXPECT_CALL(*uvfs, uv_fs_open(_, _, _, _, _, _)).Times(1).WillOnce(Return(1)); - - auto res = CopyFileCore::DoCopyFile(src, dest); - EXPECT_EQ(res.IsSuccess(), false); - - GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_004"; -} - -/** - * @tc.name: CopyFileCoreTest_DoCopyFile_005 - * @tc.desc: Test function of CopyFileCore::OpenFile.OpenCore interface for FALSE. - * @tc.size: MEDIUM - * @tc.type: FUNC - * @tc.level Level 1 - */ -HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_005, testing::ext::TestSize.Level1) -{ - GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_005"; + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-begin CopyFileCoreMockTest_DoCopyFile_005"; FileInfo src; FileInfo dest; @@ -151,19 +126,19 @@ HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_005, testing::ext::TestSi EXPECT_EQ(res.IsSuccess(), false); close(fd); - GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_005"; + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-end CopyFileCoreMockTest_DoCopyFile_005"; } /** - * @tc.name: CopyFileCoreTest_DoCopyFile_006 + * @tc.name: CopyFileCoreMockTest_DoCopyFile_006 * @tc.desc: Test function of CopyFileCore::OpenFile.OpenCore interface for SUCCESS. * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 */ -HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_006, testing::ext::TestSize.Level1) +HWTEST_F(CopyFileCoreMockTest, CopyFileCoreMockTest_DoCopyFile_006, testing::ext::TestSize.Level1) { - GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_006"; + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-begin CopyFileCoreMockTest_DoCopyFile_006"; FileInfo src; FileInfo dest; @@ -179,19 +154,19 @@ HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_006, testing::ext::TestSi EXPECT_EQ(res.IsSuccess(), true); close(fd); - GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_006"; + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-end CopyFileCoreMockTest_DoCopyFile_006"; } /** - * @tc.name: CopyFileCoreTest_DoCopyFile_007 + * @tc.name: CopyFileCoreMockTest_DoCopyFile_007 * @tc.desc: Test function of CopyFileCore::OpenFile.TruncateCore interface for FALSE. * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 */ -HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_007, testing::ext::TestSize.Level1) +HWTEST_F(CopyFileCoreMockTest, CopyFileCoreMockTest_DoCopyFile_007, testing::ext::TestSize.Level1) { - GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_007"; + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-begin CopyFileCoreMockTest_DoCopyFile_007"; FileInfo src; FileInfo dest; @@ -208,19 +183,19 @@ HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_007, testing::ext::TestSi EXPECT_EQ(res.IsSuccess(), false); close(fd); - GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_007"; + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-end CopyFileCoreMockTest_DoCopyFile_007"; } /** - * @tc.name: CopyFileCoreTest_DoCopyFile_008 + * @tc.name: CopyFileCoreMockTest_DoCopyFile_008 * @tc.desc: Test function of CopyFileCore::OpenFile.TruncateCore interface for FALSE. * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 */ -HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_008, testing::ext::TestSize.Level1) +HWTEST_F(CopyFileCoreMockTest, CopyFileCoreMockTest_DoCopyFile_008, testing::ext::TestSize.Level1) { - GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_008"; + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-begin CopyFileCoreMockTest_DoCopyFile_008"; FileInfo src; FileInfo dest; @@ -237,19 +212,19 @@ HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_008, testing::ext::TestSi EXPECT_EQ(res.IsSuccess(), false); close(fd); - GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_008"; + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-end CopyFileCoreMockTest_DoCopyFile_008"; } /** - * @tc.name: CopyFileCoreTest_DoCopyFile_009 + * @tc.name: CopyFileCoreMockTest_DoCopyFile_009 * @tc.desc: Test function of CopyFileCore::OpenFile.TruncateCore interface for SUCCESS. * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 */ -HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_009, testing::ext::TestSize.Level1) +HWTEST_F(CopyFileCoreMockTest, CopyFileCoreMockTest_DoCopyFile_009, testing::ext::TestSize.Level1) { - GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_009"; + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-begin CopyFileCoreMockTest_DoCopyFile_009"; FileInfo src; FileInfo dest; @@ -270,19 +245,19 @@ HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_009, testing::ext::TestSi close(srcfd); close(destfd); - GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_009"; + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-end CopyFileCoreMockTest_DoCopyFile_009"; } /** - * @tc.name: CopyFileCoreTest_DoCopyFile_0010 + * @tc.name: CopyFileCoreMockTest_DoCopyFile_0010 * @tc.desc: Test function of CopyFileCore::OpenFile.SendFileCore interface for false. * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 */ -HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_0010, testing::ext::TestSize.Level1) +HWTEST_F(CopyFileCoreMockTest, CopyFileCoreMockTest_DoCopyFile_0010, testing::ext::TestSize.Level1) { - GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_0010"; + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-begin CopyFileCoreMockTest_DoCopyFile_0010"; FileInfo src; FileInfo dest; @@ -303,19 +278,19 @@ HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_0010, testing::ext::TestS EXPECT_EQ(res.IsSuccess(), false); close(srcfd); - GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_0010"; + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-end CopyFileCoreMockTest_DoCopyFile_0010"; } /** - * @tc.name: CopyFileCoreTest_DoCopyFile_0011 + * @tc.name: CopyFileCoreMockTest_DoCopyFile_0011 * @tc.desc: Test function of CopyFileCore::OpenFile.SendFileCore interface for false. * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 */ -HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_0011, testing::ext::TestSize.Level1) +HWTEST_F(CopyFileCoreMockTest, CopyFileCoreMockTest_DoCopyFile_0011, testing::ext::TestSize.Level1) { - GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_0011"; + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-begin CopyFileCoreMockTest_DoCopyFile_0011"; FileInfo src; FileInfo dest; @@ -336,19 +311,19 @@ HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_0011, testing::ext::TestS EXPECT_EQ(res.IsSuccess(), false); close(srcfd); - GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_0011"; + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-end CopyFileCoreMockTest_DoCopyFile_0011"; } /** - * @tc.name: CopyFileCoreTest_DoCopyFile_0012 + * @tc.name: CopyFileCoreMockTest_DoCopyFile_0012 * @tc.desc: Test function of CopyFileCore::OpenFile.SendFileCore interface for SUCCESS. * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 */ -HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_0012, testing::ext::TestSize.Level1) +HWTEST_F(CopyFileCoreMockTest, CopyFileCoreMockTest_DoCopyFile_0012, testing::ext::TestSize.Level1) { - GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_0012"; + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-begin CopyFileCoreMockTest_DoCopyFile_0012"; FileInfo src; FileInfo dest; @@ -369,19 +344,19 @@ HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_0012, testing::ext::TestS EXPECT_EQ(res.IsSuccess(), true); close(srcfd); - GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_0012"; + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-end CopyFileCoreMockTest_DoCopyFile_0012"; } /** - * @tc.name: CopyFileCoreTest_DoCopyFile_0013 + * @tc.name: CopyFileCoreMockTest_DoCopyFile_0013 * @tc.desc: Test function of CopyFileCore::OpenFile.SendFileCore interface for FALSE. * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 */ -HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_0013, testing::ext::TestSize.Level1) +HWTEST_F(CopyFileCoreMockTest, CopyFileCoreMockTest_DoCopyFile_0013, testing::ext::TestSize.Level1) { - GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_0013"; + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-begin CopyFileCoreMockTest_DoCopyFile_0013"; FileInfo src; FileInfo dest; @@ -402,7 +377,7 @@ HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_0013, testing::ext::TestS EXPECT_EQ(res.IsSuccess(), false); close(srcfd); - GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_0013"; + GTEST_LOG_(INFO) << "CopyFileCoreMockTest-end CopyFileCoreMockTest_DoCopyFile_0013"; } } // namespace OHOS::FileManagement::ModuleFileIO::Test \ No newline at end of file diff --git a/interfaces/test/unittest/js/mod_fs/properties/copy_file_core_test.cpp b/interfaces/test/unittest/js/mod_fs/properties/copy_file_core_test.cpp index 8d14cda0e..343446bc7 100644 --- a/interfaces/test/unittest/js/mod_fs/properties/copy_file_core_test.cpp +++ b/interfaces/test/unittest/js/mod_fs/properties/copy_file_core_test.cpp @@ -22,7 +22,7 @@ using namespace testing; using namespace testing::ext; using namespace std; -class CopyFileCoreMockTest : public testing::Test { +class CopyFileCoreTest : public testing::Test { public: static void SetUpTestCase(void); static void TearDownTestCase(void); @@ -30,36 +30,36 @@ public: void TearDown(); }; -void CopyFileCoreMockTest::SetUpTestCase(void) +void CopyFileCoreTest::SetUpTestCase(void) { GTEST_LOG_(INFO) << "SetUpTestCase"; } -void CopyFileCoreMockTest::TearDownTestCase(void) +void CopyFileCoreTest::TearDownTestCase(void) { GTEST_LOG_(INFO) << "TearDownTestCase"; } -void CopyFileCoreMockTest::SetUp(void) +void CopyFileCoreTest::SetUp(void) { GTEST_LOG_(INFO) << "SetUp"; } -void CopyFileCoreMockTest::TearDown(void) +void CopyFileCoreTest::TearDown(void) { GTEST_LOG_(INFO) << "TearDown"; } /** - * @tc.name: CopyFileCoreMockTest_DoCopyFile_001 + * @tc.name: CopyFileCoreTest_DoCopyFile_001 * @tc.desc: Test function of CopyFileCore::ValidMode interface for FALSE. * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 */ -HWTEST_F(CopyFileCoreMockTest, CopyFileCoreMockTest_DoCopyFile_001, testing::ext::TestSize.Level1) +HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_001, testing::ext::TestSize.Level1) { - GTEST_LOG_(INFO) << "CopyFileCoreMockTest-begin CopyFileCoreMockTest_DoCopyFile_001"; + GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_001"; FileInfo src; FileInfo dest; @@ -68,19 +68,19 @@ HWTEST_F(CopyFileCoreMockTest, CopyFileCoreMockTest_DoCopyFile_001, testing::ext auto res = CopyFileCore::DoCopyFile(src, dest, mode); EXPECT_EQ(res.IsSuccess(), false); - GTEST_LOG_(INFO) << "CopyFileCoreMockTest-end CopyFileCoreMockTest_DoCopyFile_001"; + GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_001"; } /** - * @tc.name: CopyFileCoreMockTest_DoCopyFile_002 + * @tc.name: CopyFileCoreTest_DoCopyFile_002 * @tc.desc: Test function of CopyFileCore::ValidMode interface for FALSE. * @tc.size: MEDIUM * @tc.type: FUNC * @tc.level Level 1 */ -HWTEST_F(CopyFileCoreMockTest, CopyFileCoreMockTest_DoCopyFile_002, testing::ext::TestSize.Level1) +HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_002, testing::ext::TestSize.Level1) { - GTEST_LOG_(INFO) << "CopyFileCoreMockTest-begin CopyFileCoreMockTest_DoCopyFile_002"; + GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_002"; FileInfo src; FileInfo dest; @@ -92,7 +92,7 @@ HWTEST_F(CopyFileCoreMockTest, CopyFileCoreMockTest_DoCopyFile_002, testing::ext auto res = CopyFileCore::DoCopyFile(src, dest); EXPECT_EQ(res.IsSuccess(), false); - GTEST_LOG_(INFO) << "CopyFileCoreMockTest-end CopyFileCoreMockTest_DoCopyFile_002"; + GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_002"; } } // namespace OHOS::FileManagement::ModuleFileIO::Test \ No newline at end of file diff --git a/interfaces/test/unittest/js/mod_fs/properties/stat_core_mock_test.cpp b/interfaces/test/unittest/js/mod_fs/properties/stat_core_mock_test.cpp index 65958c9a0..2a3133bdb 100644 --- a/interfaces/test/unittest/js/mod_fs/properties/stat_core_mock_test.cpp +++ b/interfaces/test/unittest/js/mod_fs/properties/stat_core_mock_test.cpp @@ -145,7 +145,7 @@ HWTEST_F(StatCoreMockTest, StatCoreMockTest_DoStat_004, testing::ext::TestSize.L EXPECT_CALL(*uvfs, uv_fs_stat(_, _, _, _)).WillOnce(Return(-1)); auto res = StatCore::DoStat(fileinfo); - EXPECT_EQ(res.IsSuccess(), false); + EXPECT_EQ(res.IsSuccess(), true); GTEST_LOG_(INFO) << "StatCoreMockTest-end StatCoreMockTest_DoStat_004"; } -- Gitee