• 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 <fcntl.h>
17 #include <gtest/gtest.h>
18 #include <sys/stat.h>
19 #include <memory>
20 
21 #include "assistant.h"
22 #include "dfs_error.h"
23 #include "file_operations_cloud.cpp"
24 
25 namespace OHOS::FileManagement::CloudDisk::Test {
26 using namespace testing;
27 using namespace testing::ext;
28 
29 constexpr int32_t USER_ID = 100;
30 class FileOperationsCloudStaticTest : public testing::Test {
31 public:
32     static void SetUpTestCase(void);
33     static void TearDownTestCase(void);
34     void SetUp();
35     void TearDown();
36     static inline shared_ptr<FileOperationsCloud> fileOperationsCloud_ = nullptr;
37     static inline shared_ptr<AssistantMock> insMock = nullptr;
38 };
39 
SetUpTestCase(void)40 void FileOperationsCloudStaticTest::SetUpTestCase(void)
41 {
42     fileOperationsCloud_ = make_shared<FileOperationsCloud>();
43     insMock = make_shared<AssistantMock>();
44     Assistant::ins = insMock;
45     GTEST_LOG_(INFO) << "SetUpTestCase";
46 }
47 
TearDownTestCase(void)48 void FileOperationsCloudStaticTest::TearDownTestCase(void)
49 {
50     Assistant::ins = nullptr;
51     insMock = nullptr;
52     fileOperationsCloud_ = nullptr;
53     GTEST_LOG_(INFO) << "TearDownTestCase";
54 }
55 
SetUp(void)56 void FileOperationsCloudStaticTest::SetUp(void)
57 {
58     GTEST_LOG_(INFO) << "SetUp";
59 }
60 
TearDown(void)61 void FileOperationsCloudStaticTest::TearDown(void)
62 {
63     GTEST_LOG_(INFO) << "TearDown";
64 }
65 
66 /**
67  * @tc.name: HandleNewSessionTest001
68  * @tc.desc: Verify the HandleNewSession function
69  * @tc.type: FUNC
70  * @tc.require: issuesI91IOG
71  */
72 HWTEST_F(FileOperationsCloudStaticTest, HandleNewSessionTest001, TestSize.Level1)
73 {
74     GTEST_LOG_(INFO) << "HandleNewSessionTest001 Start";
75     try {
76         string path = "/data";
77         string cloudId = "100";
78         string assets = "content";
79         struct CloudDiskFuseData *data = new CloudDiskFuseData;
80         data->userId = 100;
81         std::shared_ptr<CloudDatabase> database = make_shared<CloudDatabase>(100, "test");
82         std::shared_ptr<CloudDiskFile> filePtr = make_shared<CloudDiskFile>();
83         SessionCountParams sessionParam = {path, cloudId, assets};
84         auto readSession = database->NewAssetReadSession(data->userId, "file", cloudId, assets, path);
85         data->readSessionCache[path] = readSession;
86         data->readSessionCache[path]->sessionCount = 1;
87 
88         HandleNewSession(data, sessionParam, filePtr, database);
89         EXPECT_EQ(filePtr->readSession->sessionCount, data->readSessionCache[path]->sessionCount);
90         delete data;
91     } catch (...) {
92         EXPECT_TRUE(false);
93         GTEST_LOG_(INFO) << "HandleNewSessionTest001 ERROR";
94     }
95     GTEST_LOG_(INFO) << "HandleNewSessionTest001 End";
96 }
97 
98 /**
99  * @tc.name: HandleNewSessionTest002
100  * @tc.desc: Verify the HandleNewSession function
101  * @tc.type: FUNC
102  * @tc.require: issuesI91IOG
103  */
104 HWTEST_F(FileOperationsCloudStaticTest, HandleNewSessionTest002, TestSize.Level1)
105 {
106     GTEST_LOG_(INFO) << "HandleNewSessionTest002 Start";
107     try {
108         string path = "/data";
109         string cloudId = "100";
110         string assets = "content";
111         struct CloudDiskFuseData *data = new CloudDiskFuseData;
112         std::shared_ptr<CloudDatabase> database = make_shared<CloudDatabase>(100, "test");
113         std::shared_ptr<CloudDiskFile> filePtr = make_shared<CloudDiskFile>();
114         SessionCountParams sessionParam = {path, cloudId, assets};
115         if (data->readSessionCache.find(path) != data->readSessionCache.end()) {
116             data->readSessionCache.erase(path);
117         }
118 
119         HandleNewSession(data, sessionParam, filePtr, database);
120         EXPECT_EQ(filePtr->readSession->sessionCount, 0);
121         delete data;
122     } catch (...) {
123         EXPECT_TRUE(false);
124         GTEST_LOG_(INFO) << "HandleNewSessionTest002 ERROR";
125     }
126     GTEST_LOG_(INFO) << "HandleNewSessionTest002 End";
127 }
128 
129 /**
130  * @tc.name: HandleNewSessionTest003
131  * @tc.desc: Verify the HandleNewSession function
132  * @tc.type: FUNC
133  * @tc.require: issuesI91IOG
134  */
135 HWTEST_F(FileOperationsCloudStaticTest, HandleNewSessionTest003, TestSize.Level1)
136 {
137     GTEST_LOG_(INFO) << "HandleNewSessionTest003 Start";
138     try {
139         string path = "/data";
140         string cloudId = "100";
141         string assets = "content";
142         struct CloudDiskFuseData *data = new CloudDiskFuseData;
143         data->userId = 100;
144         std::shared_ptr<CloudDatabase> database = make_shared<CloudDatabase>(100, "test");
145         std::shared_ptr<CloudDiskFile> filePtr = make_shared<CloudDiskFile>();
146         SessionCountParams sessionParam = {path, cloudId, assets};
147         auto readSession = database->NewAssetReadSession(data->userId, "file", cloudId, assets, path);
148         data->readSessionCache[path] = readSession;
149         data->readSessionCache[path]->sessionCount = 2;
150 
151         HandleNewSession(data, sessionParam, filePtr, database);
152         EXPECT_EQ(filePtr->readSession->sessionCount, data->readSessionCache[path]->sessionCount);
153         delete data;
154     } catch (...) {
155         EXPECT_TRUE(false);
156         GTEST_LOG_(INFO) << "HandleNewSessionTest003 ERROR";
157     }
158     GTEST_LOG_(INFO) << "HandleNewSessionTest003 End";
159 }
160 
161 
162 /**
163  * @tc.name: ErasePathCacheTest001
164  * @tc.desc: Verify the ErasePathCache function
165  * @tc.type: FUNC
166  * @tc.require: issuesI91IOG
167  */
168 HWTEST_F(FileOperationsCloudStaticTest, ErasePathCacheTest001, TestSize.Level1)
169 {
170     GTEST_LOG_(INFO) << "ErasePathCacheTest001 Start";
171     try {
172         string path = "/data";
173         struct CloudDiskFuseData *data = new CloudDiskFuseData;
174         if (data->readSessionCache.find(path) != data->readSessionCache.end()) {
175             data->readSessionCache.erase(path);
176         }
177 
178         ErasePathCache(path, data);
179         EXPECT_EQ(data->readSessionCache.count(path), 0);
180         delete data;
181     } catch (...) {
182         EXPECT_TRUE(false);
183         GTEST_LOG_(INFO) << "ErasePathCacheTest001 ERROR";
184     }
185     GTEST_LOG_(INFO) << "ErasePathCacheTest001 End";
186 }
187 
188 /**
189  * @tc.name: ErasePathCacheTest002
190  * @tc.desc: Verify the ErasePathCache function
191  * @tc.type: FUNC
192  * @tc.require: issuesI91IOG
193  */
194 HWTEST_F(FileOperationsCloudStaticTest, ErasePathCacheTest002, TestSize.Level1)
195 {
196     GTEST_LOG_(INFO) << "ErasePathCacheTest002 Start";
197     try {
198         string path = "/data";
199         CloudDiskFuseData *data = new CloudDiskFuseData;
200         string cloudId = "100";
201         string assets = "content";
202         data->userId = 100;
203         std::shared_ptr<CloudDatabase> database = make_shared<CloudDatabase>(100, "test");
204         std::shared_ptr<CloudDiskFile> filePtr = make_shared<CloudDiskFile>();
205         struct SessionCountParams sessionParam = {path, cloudId, assets};
206         auto readSession = database->NewAssetReadSession(data->userId, "file", cloudId, assets, path);
207         data->readSessionCache[path] = readSession;
208 
209         ErasePathCache(path, data);
210         EXPECT_EQ(data->readSessionCache.count(path), 0);
211         delete data;
212     } catch (...) {
213         EXPECT_TRUE(false);
214         GTEST_LOG_(INFO) << "ErasePathCacheTest002 ERROR";
215     }
216     GTEST_LOG_(INFO) << "ErasePathCacheTest002 End";
217 }
218 
219 /**
220  * @tc.name: GetNewSessionTest001
221  * @tc.desc: Verify the GetNewSession function
222  * @tc.type: FUNC
223  * @tc.require: issuesI91IOG
224  */
225 HWTEST_F(FileOperationsCloudStaticTest, GetNewSessionTest001, TestSize.Level1)
226 {
227     GTEST_LOG_(INFO) << "GetNewSessionTest001 Start";
228     try {
229         std::shared_ptr<CloudDiskInode> inoPtr = make_shared<CloudDiskInode>();
230         inoPtr->cloudId = "123";
231         inoPtr->bundleName = "com.example.test";
232         string path = "/data";
233         CloudDiskFuseData *data = new CloudDiskFuseData;
234         data->userId = 100;
235         std::shared_ptr<CloudDatabase> database = make_shared<CloudDatabase>(0, "com.example.test");
236         MetaBase metaBase;
237         metaBase.fileType = FILE_TYPE_THUMBNAIL;
238         std::shared_ptr<CloudDiskMetaFile> metaFile = make_shared<CloudDiskMetaFile>(0, "com.example.test", "123");
239         std::shared_ptr<CloudDiskFile> filePtr = make_shared<CloudDiskFile>();
240         CloudOpenParams cloudOpenParams = {metaBase, metaFile, filePtr};
241 
242         auto ret = GetNewSession(inoPtr, path, data, database, cloudOpenParams);
243         EXPECT_EQ(ret, E_RDB);
244         delete data;
245     } catch (...) {
246         EXPECT_TRUE(false);
247         GTEST_LOG_(INFO) << "GetNewSessionTest001 ERROR";
248     }
249     GTEST_LOG_(INFO) << "GetNewSessionTest001 End";
250 }
251 
252 /**
253  * @tc.name: GetNewSessionTest002
254  * @tc.desc: Verify the GetNewSession function
255  * @tc.type: FUNC
256  * @tc.require: issuesI91IOG
257  */
258 HWTEST_F(FileOperationsCloudStaticTest, GetNewSessionTest002, TestSize.Level1)
259 {
260     GTEST_LOG_(INFO) << "GetNewSessionTest002 Start";
261     try {
262         std::shared_ptr<CloudDiskInode> inoPtr = make_shared<CloudDiskInode>();
263         inoPtr->cloudId = "123";
264         inoPtr->bundleName = "com.example.test";
265         string path = "/data";
266         CloudDiskFuseData *data = new CloudDiskFuseData;
267         data->userId = 100;
268         std::shared_ptr<CloudDatabase> database = make_shared<CloudDatabase>(0, "com.example.test");
269         MetaBase metaBase;
270         metaBase.fileType = FILE_TYPE_CONTENT;
271         std::shared_ptr<CloudDiskMetaFile> metaFile = make_shared<CloudDiskMetaFile>(0, "com.example.test", "123");
272         std::shared_ptr<CloudDiskFile> filePtr = make_shared<CloudDiskFile>();
273         CloudOpenParams cloudOpenParams = {metaBase, metaFile, filePtr};
274 
275         auto ret = GetNewSession(inoPtr, path, data, database, cloudOpenParams);
276         EXPECT_EQ(filePtr->readSession->sessionCount, data->readSessionCache[path]->sessionCount);
277         EXPECT_EQ(ret, E_OK);
278         delete data;
279     } catch (...) {
280         EXPECT_TRUE(false);
281         GTEST_LOG_(INFO) << "GetNewSessionTest002 ERROR";
282     }
283     GTEST_LOG_(INFO) << "GetNewSessionTest002 End";
284 }
285 
286 /**
287  * @tc.name: HandleReleaseTest001
288  * @tc.desc: Verify the ReleaseHandle function
289  * @tc.type: FUNC
290  * @tc.require: issuesI91IOG
291  */
292 HWTEST_F(FileOperationsCloudStaticTest, HandleReleaseTest001, TestSize.Level1)
293 {
294     GTEST_LOG_(INFO) << "HandleReleaseTest001 Start";
295     try {
296         string path = "/data";
297         string cloudId = "100";
298         string assets = "content";
299         CloudDiskFuseData *data = new CloudDiskFuseData;
300         data->userId = 100;
301         std::shared_ptr<CloudDatabase> database = make_shared<CloudDatabase>(100, "test");
302         std::shared_ptr<CloudDiskInode> inoPtr = make_shared<CloudDiskInode>();
303         inoPtr->bundleName = "Test";
304         inoPtr->cloudId = "100";
305         std::shared_ptr<CloudDiskFile> filePtr = make_shared<CloudDiskFile>();
306         struct SessionCountParams sessionParam = {path, cloudId, assets};
307         auto readSession = database->NewAssetReadSession(data->userId, "file", cloudId, assets, path);
308         filePtr->readSession = readSession;
309         filePtr->readSession->sessionCount = 1;
310 
311         HandleRelease(filePtr, inoPtr, data);
312         EXPECT_EQ(filePtr->readSession, nullptr);
313         delete data;
314     } catch (...) {
315         EXPECT_TRUE(false);
316         GTEST_LOG_(INFO) << "HandleReleaseTest001 ERROR";
317     }
318     GTEST_LOG_(INFO) << "HandleReleaseTest001 End";
319 }
320 
321 /**
322  * @tc.name: HandleReleaseTest002
323  * @tc.desc: Verify the ReleaseHandle function
324  * @tc.type: FUNC
325  * @tc.require: issuesI91IOG
326  */
327 HWTEST_F(FileOperationsCloudStaticTest, HandleReleaseTest002, TestSize.Level1)
328 {
329     GTEST_LOG_(INFO) << "HandleReleaseTest002 Start";
330     try {
331         string path = "/data";
332         string cloudId = "100";
333         string assets = "content";
334         CloudDiskFuseData *data = new CloudDiskFuseData;
335         data->userId = 100;
336         std::shared_ptr<CloudDatabase> database = make_shared<CloudDatabase>(100, "test");
337         std::shared_ptr<CloudDiskInode> inoPtr = make_shared<CloudDiskInode>();
338         inoPtr->bundleName = "Test";
339         inoPtr->cloudId = "100";
340         std::shared_ptr<CloudDiskFile> filePtr = make_shared<CloudDiskFile>();
341         struct SessionCountParams sessionParam = {path, cloudId, assets};
342         auto readSession = database->NewAssetReadSession(data->userId, "file", cloudId, assets, path);
343         filePtr->readSession = readSession;
344         filePtr->readSession->sessionCount = 2;
345 
346         HandleRelease(filePtr, inoPtr, data);
347         EXPECT_EQ(filePtr->readSession->sessionCount, 1);
348         delete data;
349     } catch (...) {
350         EXPECT_TRUE(false);
351         GTEST_LOG_(INFO) << "HandleReleaseTest002 ERROR";
352     }
353     GTEST_LOG_(INFO) << "HandleReleaseTest002 End";
354 }
355 
356 /**
357  * @tc.name: HandleReleaseTest003
358  * @tc.desc: Verify the ReleaseHandle function
359  * @tc.type: FUNC
360  * @tc.require: issuesI91IOG
361  */
362 HWTEST_F(FileOperationsCloudStaticTest, HandleReleaseTest003, TestSize.Level1)
363 {
364     GTEST_LOG_(INFO) << "HandleReleaseTest003 Start";
365     try {
366         string path = "/data";
367         string cloudId = "100";
368         string assets = "content";
369         CloudDiskFuseData *data = new CloudDiskFuseData;
370         data->userId = 100;
371         std::shared_ptr<CloudDatabase> database = make_shared<CloudDatabase>(100, "test");
372         std::shared_ptr<CloudDiskInode> inoPtr = make_shared<CloudDiskInode>();
373         inoPtr->bundleName = "Test";
374         inoPtr->cloudId = "100";
375         std::shared_ptr<CloudDiskFile> filePtr = make_shared<CloudDiskFile>();
376         struct SessionCountParams sessionParam = {path, cloudId, assets};
377         auto readSession = database->NewAssetReadSession(data->userId, "file", cloudId, assets, path);
378         filePtr->readSession = readSession;
379         filePtr->readSession->sessionCount = 0;
380 
381         HandleRelease(filePtr, inoPtr, data);
382         EXPECT_EQ(filePtr->readSession->sessionCount, -1);
383         delete data;
384     } catch (...) {
385         EXPECT_TRUE(false);
386         GTEST_LOG_(INFO) << "HandleReleaseTest003 ERROR";
387     }
388     GTEST_LOG_(INFO) << "HandleReleaseTest003 End";
389 }
390 
391 /**
392  * @tc.name: HandleOpenFailTest001
393  * @tc.desc: Verify the ReleaseHandle function
394  * @tc.type: FUNC
395  * @tc.require: issuesI91IOG
396  */
397 HWTEST_F(FileOperationsCloudStaticTest, HandleOpenFailTest001, TestSize.Level1)
398 {
399     GTEST_LOG_(INFO) << "HandleOpenFailTest001 Start";
400     try {
401         string path = "/data";
402         CloudDiskFuseData *data = new CloudDiskFuseData;
403         fuse_file_info *fi = new fuse_file_info;
404         std::shared_ptr<CloudDiskFile> filePtr = make_shared<CloudDiskFile>();
405         filePtr->readSession = nullptr;
406         std::shared_ptr<CloudDiskInode> inoPtr = make_shared<CloudDiskInode>();
407         inoPtr->fileName = "Test";
408         fuse_ino_t ino = 0;
409         HandleOpenErrorParams params = {filePtr, inoPtr, ino};
410         string cloudId = "100";
411         string assets = "content";
412         data->userId = 100;
413         std::shared_ptr<CloudDatabase> database = make_shared<CloudDatabase>(100, "test");
414         auto readSession = database->NewAssetReadSession(data->userId, "file", cloudId, assets, path);
415         data->readSessionCache[path] = readSession;
416 
417         HandleOpenFail(params, path, data, fi);
418         EXPECT_EQ(data->readSessionCache.count(path), 0);
419         delete fi;
420         delete data;
421     } catch (...) {
422         EXPECT_TRUE(false);
423         GTEST_LOG_(INFO) << "HandleOpenFailTest001 ERROR";
424     }
425     GTEST_LOG_(INFO) << "HandleOpenFailTest001 End";
426 }
427 
428 /**
429  * @tc.name: HandleSessionNullTest001
430  * @tc.desc: Verify the HandleSessionNull function
431  * @tc.type: FUNC
432  * @tc.require: issuesI91IOG
433  */
434 HWTEST_F(FileOperationsCloudStaticTest, HandleSessionNullTest001, TestSize.Level1)
435 {
436     GTEST_LOG_(INFO) << "HandleSessionNullTest001 Start";
437     try {
438         string path = "/data";
439         CloudDiskFuseData *data = new CloudDiskFuseData;
440         fuse_file_info *fi = new fuse_file_info;
441         std::shared_ptr<CloudDiskFile> filePtr = make_shared<CloudDiskFile>();
442         filePtr->readSession = nullptr;
443         std::shared_ptr<CloudDiskInode> inoPtr = make_shared<CloudDiskInode>();
444         inoPtr->fileName = "Test";
445         fuse_ino_t ino = 0;
446         HandleOpenErrorParams params = {filePtr, inoPtr, ino};
447         string cloudId = "100";
448         string assets = "content";
449         data->userId = 100;
450         std::shared_ptr<CloudDatabase> database = make_shared<CloudDatabase>(100, "test");
451         auto readSession = database->NewAssetReadSession(data->userId, "file", cloudId, assets, path);
452         data->readSessionCache[path] = readSession;
453 
454         HandleSessionNull(params, data, fi);
455         EXPECT_EQ(data->readSessionCache[path], readSession);
456         delete fi;
457         delete data;
458     } catch (...) {
459         EXPECT_TRUE(false);
460         GTEST_LOG_(INFO) << "HandleSessionNullTest001 ERROR";
461     }
462     GTEST_LOG_(INFO) << "HandleSessionNullTest001 End";
463 }
464 
465 /**
466  * @tc.name: HandleCloudReopenTest001
467  * @tc.desc: Verify the HandleCloudReopen function
468  * @tc.type: FUNC
469  * @tc.require: I6H5MH
470  */
471 HWTEST_F(FileOperationsCloudStaticTest, HandleCloudReopenTest001, TestSize.Level1)
472 {
473     GTEST_LOG_(INFO) << "HandleCloudReopenTest001 start";
474     try {
475         string cloudId = "100";
476         string assets = "content";
477         string path = "/data";
478         CloudDiskFuseData *data = new CloudDiskFuseData;
479         data->userId = 100;
480         fuse_file_info *fi = new fuse_file_info;
481         std::shared_ptr<CloudDiskFile> filePtr = make_shared<CloudDiskFile>();
482         filePtr->readSession = nullptr;
483         filePtr->type = CLOUD_DISK_FILE_TYPE_UNKNOWN;
484         std::shared_ptr<CloudDiskInode> inoPtr = make_shared<CloudDiskInode>();
485         inoPtr->fileName = "Test";
486         MetaBase metaBase(inoPtr->fileName);
487         metaBase.fileType = FILE_TYPE_CONTENT;
488         std::shared_ptr<CloudDiskMetaFile> metaFile = make_shared<CloudDiskMetaFile>(0, "com.example.test", "123");
489         CloudOpenParams params = {metaBase, metaFile, filePtr};
490         fuse_req_t req = nullptr;
491         std::shared_ptr<CloudDatabase> database = make_shared<CloudDatabase>(100, "test");
492         filePtr->readSession = database->NewAssetReadSession(data->userId, "file", cloudId, assets, path);
493         EXPECT_CALL(*insMock, fuse_reply_open(_, _)).WillOnce(Return(E_OK));
494 
495         HandleCloudReopen(fi, data, inoPtr, params, req);
496         EXPECT_EQ(filePtr->type, CLOUD_DISK_FILE_TYPE_CLOUD);
497         delete fi;
498         delete data;
499     } catch (...) {
500         EXPECT_TRUE(false);
501         GTEST_LOG_(INFO) << "HandleCloudReopenTest001 failed";
502     }
503     GTEST_LOG_(INFO) << "HandleCloudReopenTest001 end";
504 }
505 
506 /**
507  * @tc.name: HandleCloudReopenTest002
508  * @tc.desc: Verify the HandleCloudReopen function
509  * @tc.type: FUNC
510  * @tc.require: I6H5MH
511  */
512 HWTEST_F(FileOperationsCloudStaticTest, HandleCloudReopenTest002, TestSize.Level1)
513 {
514     GTEST_LOG_(INFO) << "HandleCloudReopenTest002 start";
515     try {
516         string cloudId = "100";
517         string assets = "content";
518         string path = "/data";
519         CloudDiskFuseData *data = new CloudDiskFuseData;
520         data->userId = 0;
521         fuse_file_info *fi = new fuse_file_info;
522         std::shared_ptr<CloudDiskFile> filePtr = make_shared<CloudDiskFile>();
523         filePtr->readSession = nullptr;
524         filePtr->type = CLOUD_DISK_FILE_TYPE_UNKNOWN;
525         std::shared_ptr<CloudDiskInode> inoPtr = make_shared<CloudDiskInode>();
526         inoPtr->fileName = "Test";
527         MetaBase metaBase(inoPtr->fileName);
528         metaBase.fileType = FILE_TYPE_LCD;
529         std::shared_ptr<CloudDiskMetaFile> metaFile = make_shared<CloudDiskMetaFile>(0, "com.example.test", "123");
530         CloudOpenParams params = {metaBase, metaFile, filePtr};
531         fuse_req_t req = nullptr;
532         std::shared_ptr<CloudDatabase> database = make_shared<CloudDatabase>(100, "test");
533         filePtr->readSession = database->NewAssetReadSession(data->userId, "file", cloudId, assets, path);
534         EXPECT_CALL(*insMock, fuse_reply_err(_, _)).WillOnce(Return(E_OK));
535 
536         HandleCloudReopen(fi, data, inoPtr, params, req);
537         EXPECT_EQ(filePtr->type, CLOUD_DISK_FILE_TYPE_UNKNOWN);
538         delete fi;
539         delete data;
540     } catch (...) {
541         EXPECT_TRUE(false);
542         GTEST_LOG_(INFO) << "HandleCloudReopenTest002 failed";
543     }
544     GTEST_LOG_(INFO) << "HandleCloudReopenTest002 end";
545 }
546 
547 /**
548  * @tc.name: HandleCloudReopenTest003
549  * @tc.desc: Verify the HandleCloudReopen function
550  * @tc.type: FUNC
551  * @tc.require: I6H5MH
552  */
553 HWTEST_F(FileOperationsCloudStaticTest, HandleCloudReopenTest003, TestSize.Level1)
554 {
555     GTEST_LOG_(INFO) << "HandleCloudReopenTest003 start";
556     try {
557         string cloudId = "100";
558         string assets = "content";
559         string path = "/data";
560         CloudDiskFuseData *data = new CloudDiskFuseData;
561         data->userId = 100;
562         fuse_file_info *fi = new fuse_file_info;
563         std::shared_ptr<CloudDiskFile> filePtr = make_shared<CloudDiskFile>();
564         filePtr->readSession = nullptr;
565         filePtr->type = CLOUD_DISK_FILE_TYPE_UNKNOWN;
566         std::shared_ptr<CloudDiskInode> inoPtr = make_shared<CloudDiskInode>();
567         inoPtr->fileName = "Test";
568         MetaBase metaBase(inoPtr->fileName);
569         metaBase.fileType = FILE_TYPE_LCD;
570         std::shared_ptr<CloudDiskMetaFile> metaFile = make_shared<CloudDiskMetaFile>(0, "com.example.test", "123");
571         CloudOpenParams params = {metaBase, metaFile, filePtr};
572         fuse_req_t req = nullptr;
573         std::shared_ptr<CloudDatabase> database = make_shared<CloudDatabase>(100, "test");
574         filePtr->readSession = database->NewAssetReadSession(data->userId, "file", cloudId, assets, path);
575         EXPECT_CALL(*insMock, fuse_reply_open(_, _)).WillOnce(Return(E_OK));
576 
577         HandleCloudReopen(fi, data, inoPtr, params, req);
578         EXPECT_EQ(filePtr->type, CLOUD_DISK_FILE_TYPE_LOCAL);
579         delete fi;
580         delete data;
581     } catch (...) {
582         EXPECT_TRUE(false);
583         GTEST_LOG_(INFO) << "HandleCloudReopenTest003 failed";
584     }
585     GTEST_LOG_(INFO) << "HandleCloudReopenTest003 end";
586 }
587 }