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 #include "mountpoint/mount_manager.h"
16 
17 #include <memory>
18 #include <unistd.h>
19 
20 #include "gtest/gtest.h"
21 
22 #include "mountpoint/mount_point.h"
23 #include "utils_directory.h"
24 
25 namespace OHOS {
26 namespace Storage {
27 namespace DistributedFile {
28 namespace Test {
29 using namespace testing::ext;
30 using namespace std;
31 
32 class MountManagerTest : public testing::Test {
33 public:
SetUpTestCase(void)34     static void SetUpTestCase(void) {};
TearDownTestCase(void)35     static void TearDownTestCase(void) {};
SetUp()36     void SetUp() {};
TearDown()37     void TearDown() {};
38 };
39 
40 /**
41  * @tc.name: MountManagerTest_MountManager_0100
42  * @tc.desc: Verify the MountManager class.
43  * @tc.type: FUNC
44  * @tc.require: I9KETY
45  */
46 HWTEST_F(MountManagerTest, MountManagerTest_MountManager_0100, TestSize.Level1)
47 {
48     GTEST_LOG_(INFO) << "MountManagerTest_MountManager_0100 start";
49     MountManager::GetInstance()->Umount("test");
50     Utils::MountArgument mountArg{.userId_ = 100,
51                                   .relativePath_ = "data/test",
52                                   .accountless_ = true};
53     unique_ptr<MountPoint> uniquePoint = std::make_unique<MountPoint>(mountArg);
54     MountManager::GetInstance()->Mount(move(uniquePoint));
55 
56     auto smp = make_shared<MountPoint>(mountArg);
57     weak_ptr<MountPoint> weakPoint = smp;
58     MountManager::GetInstance()->Umount(weakPoint);
59     EXPECT_TRUE(true);
60     GTEST_LOG_(INFO) << "MountManagerTest_MountManager_0100 end";
61 }
62 } // namespace Test
63 } // namespace DistributedFile
64 } // namespace Storage
65 } // namespace OHOS
66