• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "copy_file_core.h"
17 
18 #include <gtest/gtest.h>
19 
20 namespace OHOS::FileManagement::ModuleFileIO::Test {
21 using namespace testing;
22 using namespace testing::ext;
23 using namespace std;
24 
25 class CopyFileCoreTest : public testing::Test {
26 public:
27     static void SetUpTestCase(void);
28     static void TearDownTestCase(void);
29     void SetUp();
30     void TearDown();
31 };
32 
SetUpTestCase(void)33 void CopyFileCoreTest::SetUpTestCase(void)
34 {
35     GTEST_LOG_(INFO) << "SetUpTestCase";
36 }
37 
TearDownTestCase(void)38 void CopyFileCoreTest::TearDownTestCase(void)
39 {
40     GTEST_LOG_(INFO) << "TearDownTestCase";
41 }
42 
SetUp(void)43 void CopyFileCoreTest::SetUp(void)
44 {
45     GTEST_LOG_(INFO) << "SetUp";
46 }
47 
TearDown(void)48 void CopyFileCoreTest::TearDown(void)
49 {
50     GTEST_LOG_(INFO) << "TearDown";
51 }
52 
53 /**
54  * @tc.name: CopyFileCoreTest_DoCopyFile_001
55  * @tc.desc: Test function of CopyFileCore::ValidMode interface for FALSE.
56  * @tc.size: MEDIUM
57  * @tc.type: FUNC
58  * @tc.level Level 1
59  */
60 HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_001, testing::ext::TestSize.Level1)
61 {
62     GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_001";
63 
64     FileInfo src;
65     FileInfo dest;
66     optional<int32_t> mode = std::make_optional(1);
67 
68     auto res = CopyFileCore::DoCopyFile(src, dest, mode);
69     EXPECT_EQ(res.IsSuccess(), false);
70 
71     GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_001";
72 }
73 
74 /**
75  * @tc.name: CopyFileCoreTest_DoCopyFile_002
76  * @tc.desc: Test function of CopyFileCore::ValidMode interface for FALSE.
77  * @tc.size: MEDIUM
78  * @tc.type: FUNC
79  * @tc.level Level 1
80  */
81 HWTEST_F(CopyFileCoreTest, CopyFileCoreTest_DoCopyFile_002, testing::ext::TestSize.Level1)
82 {
83     GTEST_LOG_(INFO) << "CopyFileCoreTest-begin CopyFileCoreTest_DoCopyFile_002";
84 
85     FileInfo src;
86     FileInfo dest;
87     src.isPath = true;
88     dest.isPath = true;
89     src.path = std::make_unique<char[]>(1);
90     dest.path = std::make_unique<char[]>(1);
91 
92     auto res = CopyFileCore::DoCopyFile(src, dest);
93     EXPECT_EQ(res.IsSuccess(), false);
94 
95     GTEST_LOG_(INFO) << "CopyFileCoreTest-end CopyFileCoreTest_DoCopyFile_002";
96 }
97 
98 } // namespace OHOS::FileManagement::ModuleFileIO::Test