Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
462855a5
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6067
Star
93
Fork
166
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
19
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
19
Issue
19
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
462855a5
编写于
4月 17, 2024
作者:
WOSHIMAHAIFENG
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev_file' into 'dev'
添加file测试用例 See merge request
!13
上级
716fcaa8
c724790e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
66 addition
and
68 deletion
+66
-68
pages/API/get-file-system-manager/get-file-system-manager.test.js
...I/get-file-system-manager/get-file-system-manager.test.js
+60
-63
pages/API/get-file-system-manager/get-file-system-manager.uvue
.../API/get-file-system-manager/get-file-system-manager.uvue
+6
-5
未找到文件。
pages/API/get-file-system-manager/get-file-system-manager.test.js
浏览文件 @
462855a5
...
...
@@ -937,7 +937,7 @@ describe('ExtApi-FileManagerTest', () => {
});
it
(
'
appendFileTest
'
,
async
()
=>
{
if
(
!
isAndroid
())
{
if
(
!
isAndroid
())
{
return
}
...
...
@@ -994,7 +994,7 @@ describe('ExtApi-FileManagerTest', () => {
//renameFileSync copyFileSyncTest appendFileSyncTest truncateFileTest truncateFileSyncTest
it
(
'
sync test
'
,
async
()
=>
{
if
(
!
isAndroid
())
{
if
(
!
isAndroid
())
{
return
}
...
...
@@ -1149,50 +1149,10 @@ describe('ExtApi-FileManagerTest', () => {
}
return
true
}
//saveFileTest saveFileSyncTest getSavedFileListTest removeSavedFileTest
it
(
'
savefile test
'
,
async
()
=>
{
if
(
!
isAndroid
()){
return
}
let
globalTempPath
=
await
getData
(
'
globalTempPath
'
)
let
basePath
=
await
getData
(
'
basePath
'
)
await
page
.
setData
({
basePath
:
basePath
})
await
clearDir
(
''
)
await
page
.
setData
({
basePath
:
globalTempPath
,
temFile
:
'
save/1.txt
'
,
mkdirFile
:
'
save
'
,
writeFile
:
'
save/1.txt
'
,
accessFile
:
'
1.txt
'
})
await
createFile
()
await
page
.
setData
({
basePath
:
basePath
,
temFile
:
'
save/1.txt
'
,
})
let
btnSaveFile
=
await
page
.
$
(
'
#btn-save-file
'
)
await
btnSaveFile
.
tap
()
await
isDone
()
let
saveFileRet
=
await
getData
(
"
saveFileRet
"
)
expect
(
saveFileRet
).
not
.
toBe
(
''
);
await
page
.
setData
({
saveFileRet
:
''
})
await
clearDir
(
''
)
});
it
(
'
saveFileSyncTest
'
,
async
()
=>
{
if
(
!
isAndroid
())
{
if
(
!
isAndroid
())
{
return
}
...
...
@@ -1200,10 +1160,12 @@ describe('ExtApi-FileManagerTest', () => {
let
globalTempPath
=
await
getData
(
'
globalTempPath
'
)
let
basePath
=
await
getData
(
'
basePath
'
)
await
page
.
setData
({
logAble
:
false
,
basePath
:
basePath
})
await
clearDir
(
''
)
await
page
.
setData
({
logAble
:
false
,
basePath
:
globalTempPath
,
temFile
:
'
save/2.txt
'
,
mkdirFile
:
'
save
'
,
...
...
@@ -1217,32 +1179,21 @@ describe('ExtApi-FileManagerTest', () => {
})
btnSaveFile
=
await
page
.
$
(
'
#btn-save-file-sync
'
)
await
btnSaveFile
.
tap
()
await
isDone
()
let
btnRemoveSavedFileRet
=
await
page
.
$
(
'
#btn-remove-saved-file
'
)
await
btnRemoveSavedFileRet
.
tap
()
let
removeSavedFileRet
=
await
getData
(
"
removeSavedFileRet
"
)
expect
(
removeSavedFileRet
).
toEqual
(
'
removeSavedFile:ok
'
)
await
isDone
()
await
page
.
setData
({
removeSavedFileRet
:
''
})
let
btnSavedFileList
=
await
page
.
$
(
'
#btn-getsaved-filelist
'
)
await
btnSavedFileList
.
tap
()
await
isDone
()
let
fileListSuccess
=
await
getData
(
"
fileListSuccess
"
)
expect
(
fileListSuccess
.
length
>
0
).
toEqual
(
true
)
await
clearDir
(
''
)
});
it
(
'
getSavedFileListTest
'
,
async
()
=>
{
if
(
!
isAndroid
())
{
if
(
!
isAndroid
())
{
return
}
...
...
@@ -1250,10 +1201,12 @@ describe('ExtApi-FileManagerTest', () => {
let
globalTempPath
=
await
getData
(
'
globalTempPath
'
)
let
basePath
=
await
getData
(
'
basePath
'
)
await
page
.
setData
({
logAble
:
false
,
basePath
:
basePath
})
await
clearDir
(
''
)
await
page
.
setData
({
logAble
:
false
,
basePath
:
globalTempPath
,
temFile
:
'
save/2.txt
'
,
mkdirFile
:
'
save
'
,
...
...
@@ -1267,7 +1220,6 @@ describe('ExtApi-FileManagerTest', () => {
})
btnSaveFile
=
await
page
.
$
(
'
#btn-save-file-sync
'
)
await
btnSaveFile
.
tap
()
await
isDone
()
let
btnSavedFileList
=
await
page
.
$
(
'
#btn-getsaved-filelist
'
)
await
btnSavedFileList
.
tap
()
...
...
@@ -1275,14 +1227,12 @@ describe('ExtApi-FileManagerTest', () => {
let
fileListSuccess
=
await
getData
(
"
fileListSuccess
"
)
expect
(
fileListSuccess
.
length
>
0
).
toEqual
(
true
)
await
clearDir
(
''
)
});
it
(
'
removeSavedFileTest
'
,
async
()
=>
{
if
(
!
isAndroid
())
{
if
(
!
isAndroid
())
{
return
}
...
...
@@ -1290,10 +1240,12 @@ describe('ExtApi-FileManagerTest', () => {
let
globalTempPath
=
await
getData
(
'
globalTempPath
'
)
let
basePath
=
await
getData
(
'
basePath
'
)
await
page
.
setData
({
logAble
:
false
,
basePath
:
basePath
})
await
clearDir
(
''
)
await
page
.
setData
({
logAble
:
false
,
basePath
:
globalTempPath
,
temFile
:
'
save/2.txt
'
,
mkdirFile
:
'
save
'
,
...
...
@@ -1318,13 +1270,14 @@ describe('ExtApi-FileManagerTest', () => {
//openFiletest openFileSynctest closeTest closeTestSync writeTest writeSyncTest
it
(
'
openFiletest
'
,
async
()
=>
{
if
(
!
isAndroid
())
{
if
(
!
isAndroid
())
{
return
}
await
clearDir
(
''
)
await
page
.
setData
({
logAble
:
false
,
mkdirFile
:
'
fd
'
,
writeFile
:
'
fd/1.txt
'
,
readFile
:
'
fd/1.txt
'
...
...
@@ -1349,13 +1302,14 @@ describe('ExtApi-FileManagerTest', () => {
});
// closeTest closeTestSync
it
(
'
closeTest
'
,
async
()
=>
{
if
(
!
isAndroid
())
{
if
(
!
isAndroid
())
{
return
}
await
clearDir
(
''
)
await
page
.
setData
({
logAble
:
false
,
mkdirFile
:
'
fd
'
,
writeFile
:
'
fd/1.txt
'
,
readFile
:
'
fd/1.txt
'
...
...
@@ -1380,12 +1334,13 @@ describe('ExtApi-FileManagerTest', () => {
});
//writeTest writeSyncTest
it
(
'
writeTest
'
,
async
()
=>
{
if
(
!
isAndroid
())
{
if
(
!
isAndroid
())
{
return
}
await
clearDir
(
''
)
await
page
.
setData
({
logAble
:
false
,
mkdirFile
:
'
fd
'
,
writeFile
:
'
fd/1.txt
'
,
readFile
:
'
fd/1.txt
'
,
...
...
@@ -1443,4 +1398,46 @@ describe('ExtApi-FileManagerTest', () => {
expect
(
fstat
).
not
.
toEqual
(
'
ftruncate:ok
'
)
});
//saveFileTest saveFileSyncTest getSavedFileListTest removeSavedFileTest
it
(
'
savefile test
'
,
async
()
=>
{
if
(
!
isAndroid
())
{
return
}
let
globalTempPath
=
await
getData
(
'
globalTempPath
'
)
let
basePath
=
await
getData
(
'
basePath
'
)
await
page
.
setData
({
logAble
:
false
,
basePath
:
basePath
})
await
clearDir
(
''
)
await
page
.
setData
({
basePath
:
globalTempPath
,
temFile
:
'
save/1.txt
'
,
mkdirFile
:
'
save
'
,
writeFile
:
'
save/1.txt
'
,
accessFile
:
'
1.txt
'
})
await
createFile
()
await
page
.
setData
({
basePath
:
basePath
,
temFile
:
'
save/1.txt
'
,
})
let
btnSaveFile
=
await
page
.
$
(
'
#btn-save-file
'
)
await
btnSaveFile
.
tap
()
await
isDone
()
let
saveFileRet
=
await
getData
(
"
saveFileRet
"
)
expect
(
saveFileRet
).
not
.
toBe
(
''
);
await
page
.
setData
({
saveFileRet
:
''
})
// await clearDir('')
});
});
pages/API/get-file-system-manager/get-file-system-manager.uvue
浏览文件 @
462855a5
...
...
@@ -718,7 +718,6 @@
},
saveFileTest: function (_ : any) {
const fileManager = uni.getFileSystemManager()
console.log('=====' + uni.env.USER_DATA_PATH)
fileManager.saveFile({
tempFilePath: `${this.globalTempPath}${this.temFile}`,
// filePath:`${this.basePath}local/`,
...
...
@@ -728,13 +727,15 @@
}
console.log('success', res)
this.saveFileRet = res.savedFilePath
this.done = true
},
fail: (res : UniError) => {
if (this.logAble) {
this.log += 'saveFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
console.log('
saveFileTest
fail', res)
this.lastFailError = res
this.done = true
},
complete: (_) => {
this.done = true
...
...
@@ -752,7 +753,7 @@
//todo 后面打开
// this.saveFileRet=res
} catch (e) {
console.log(e)
console.log(
'saveFileSyncTest:'+
e)
this.done = true
}
},
...
...
@@ -788,14 +789,14 @@
if (this.logAble) {
this.log += 'getSavedFileListTest success:' + JSON.stringify(res) + '\n\n'
}
console.log("success", res)
console.log("
getSavedFileListTest
success", res)
this.fileListSuccess = res.fileList
},
fail: (res : UniError) => {
if (this.logAble) {
this.log += 'getSavedFileListTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
console.log('
getSavedFileListTest
fail', res)
this.lastFailError = res
},
complete: (res : any) => {
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录