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 "distributed_file_daemon_proxy.h"
17 #include "file_mount_manager.h"
18 #include <gmock/gmock.h>
19 #include <gtest/gtest.h>
20 #include "dfs_error.h"
21
22 namespace OHOS::Storage::DistributedFile::Test {
23 using namespace OHOS::FileManagement;
24 using namespace testing;
25 using namespace testing::ext;
26 using namespace std;
27
28 class FileMountManagerTest : public testing::Test {
29 public:
30 static void SetUpTestCase(void);
31 static void TearDownTestCase(void);
32 void SetUp();
33 void TearDown();
34 public:
35 static inline shared_ptr<FileMountManager> filemountmanager_ = nullptr;
36 };
37
SetUpTestCase(void)38 void FileMountManagerTest::SetUpTestCase(void)
39 {
40 GTEST_LOG_(INFO) << "SetUpTestCase";
41 }
42
TearDownTestCase(void)43 void FileMountManagerTest::TearDownTestCase(void)
44 {
45 GTEST_LOG_(INFO) << "TearDownTestCase";
46 }
47
SetUp(void)48 void FileMountManagerTest::SetUp(void)
49 {
50 GTEST_LOG_(INFO) << "SetUp";
51 }
52
TearDown(void)53 void FileMountManagerTest::TearDown(void)
54 {
55 GTEST_LOG_(INFO) << "TearDown";
56 }
57
58 /**
59 * @tc.name: FileMountManager_GetDfsUrisDirFromLocal_0100
60 * @tc.desc: The execution of the GetDfsUrisDirFromLocal failed.
61 * @tc.type: FUNC
62 * @tc.require: I7TDJK
63 */
64 HWTEST_F(FileMountManagerTest, FileMountManager_GetDfsUrisDirFromLocal_0100, TestSize.Level1)
65 {
66 GTEST_LOG_(INFO) << "FileMountManager_GetDfsUrisDirFromLocal_0100 Start";
67 std::vector<std::string> uriList = {""};
68 int32_t userId = 101;
69 std::string str = "test";
70 AppFileService::ModuleRemoteFileShare::HmdfsUriInfo uriInfo;
71 uriInfo.uriStr = "test";
72 uriInfo.fileSize = 2;
73 std::unordered_map<std::string, AppFileService::ModuleRemoteFileShare::HmdfsUriInfo> uriToDfsUriMaps;
74 uriToDfsUriMaps.insert({str, uriInfo});
75
76 auto ret = filemountmanager_->GetDfsUrisDirFromLocal(uriList, userId, uriToDfsUriMaps);
77 EXPECT_EQ(ret, E_SA_LOAD_FAILED);
78 GTEST_LOG_(INFO) << "FileMountManager_GetDfsUrisDirFromLocal_0100 End";
79 }
80
81 }