1 /*
2  * Copyright (C) 2024 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 "gtest/gtest.h"
17 #include "osal/filesystem/file_system.h"
18 
19 using namespace testing::ext;
20 using namespace OHOS::Media;
21 
22 namespace {
23 const std::string DUMP_PARAM = "w";
24 const std::string DUMP_FILE_NAME = "DumpBufferTest.es";
25 }
26 
27 namespace OHOS {
28 namespace Media {
29 class FileSystemUnitTest : public testing::Test {
30 public:
SetUpTestCase(void)31     static void SetUpTestCase(void) {};
TearDownTestCase(void)32     static void TearDownTestCase(void) {};
SetUp(void)33     void SetUp(void) {};
TearDown(void)34     void TearDown(void) {};
35 };
36 
37 /**
38  * @tc.name: CreateFiles
39  * @tc.desc: CreateFiles
40  * @tc.type: FUNC
41  */
42 HWTEST_F(FileSystemUnitTest, CreateFiles, TestSize.Level1)
43 {
44     std::shared_ptr<FileSystem> fileSystem = std::make_shared<FileSystem>();
45     EXPECT_TRUE(fileSystem->MakeMultipleDir("/data/test/makeMulti/dir"));
46     EXPECT_TRUE(fileSystem->MakeDir("/data/test/makedir"));
47     EXPECT_TRUE(fileSystem->IsDirectory("/data/test/makedir"));
48     EXPECT_TRUE(fileSystem->IsExists("/data/test/makedir"));
49     EXPECT_EQ(false, fileSystem->IsRegularFile("/data/test/makedir"));
50     fileSystem->ClearFileContent("/data/test/makeMulti/dir");
51     fileSystem->RemoveFilesInDir("/data/test/makedir");
52     EXPECT_TRUE(fileSystem->IsExists("/data/test/makedir"));
53 }
54 }
55 }