Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
b6566852
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5995
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
b6566852
编写于
4月 19, 2024
作者:
WOSHIMAHAIFENG
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev-tem' into 'dev'
修改file测试用例,防止ios测试失败 See merge request
!22
上级
4e55aa7a
082dadd4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
84 addition
and
84 deletion
+84
-84
pages/API/get-file-system-manager/get-file-system-manager.test.js
...I/get-file-system-manager/get-file-system-manager.test.js
+53
-13
pages/API/get-file-system-manager/get-file-system-manager.uvue
.../API/get-file-system-manager/get-file-system-manager.uvue
+31
-71
未找到文件。
pages/API/get-file-system-manager/get-file-system-manager.test.js
浏览文件 @
b6566852
...
...
@@ -1137,15 +1137,11 @@ describe('ExtApi-FileManagerTest', () => {
function
isAndroid
()
{
if
(
process
.
env
.
uniTestPlatformInfo
.
indexOf
(
'
web
'
)
>
-
1
||
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
===
'
true
'
)
{
it
(
'
web
'
,
()
=>
{
expect
(
1
).
toBe
(
1
)
})
expect
(
1
).
toBe
(
1
)
return
false
}
if
(
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
().
startsWith
(
'
ios
'
))
{
it
(
'
ios
'
,
()
=>
{
expect
(
1
).
toBe
(
1
)
})
expect
(
1
).
toBe
(
1
)
return
false
}
return
true
...
...
@@ -1247,7 +1243,7 @@ describe('ExtApi-FileManagerTest', () => {
logAble
:
false
,
basePath
:
basePath
})
await
clearDir
(
''
)
//
await clearDir('')
await
page
.
setData
({
logAble
:
false
,
basePath
:
globalTempPath
,
...
...
@@ -1341,7 +1337,7 @@ describe('ExtApi-FileManagerTest', () => {
if
(
!
isAndroid
())
{
return
}
console
.
log
(
'
writeTest
'
,
'
start
'
)
// await clearDir('')
await
page
.
setData
({
logAble
:
false
,
...
...
@@ -1351,13 +1347,13 @@ describe('ExtApi-FileManagerTest', () => {
writeData
:
'
我是一只小小鸟
'
})
await
createFile
()
console
.
log
(
'
writeTest
'
,
'
1
'
)
let
btnWrite
=
await
page
.
$
(
'
#btn-write
'
)
await
btnWrite
.
tap
()
await
isDone
()
let
bytesWritten
=
await
getData
(
"
bytesWritten
"
)
expect
(
bytesWritten
).
toEqual
(
7
)
console
.
log
(
'
writeTest
'
,
'
2
'
)
//writeSyncTest
await
page
.
setData
({
writeFile
:
'
fd/1.txt
'
,
...
...
@@ -1365,18 +1361,19 @@ describe('ExtApi-FileManagerTest', () => {
writeData
:
'
我是
'
})
btnWrite
=
await
page
.
$
(
'
#btn-write
'
)
btnWrite
=
await
page
.
$
(
'
#btn-write
-sync
'
)
await
btnWrite
.
tap
()
await
isDone
()
bytesWritten
=
await
getData
(
"
bytesWritten
"
)
expect
(
bytesWritten
).
toEqual
(
2
)
console
.
log
(
'
writeTest
'
,
'
3
'
)
//fstatTest
let
btnFstat
=
await
page
.
$
(
'
#btn-fstat-file
'
)
await
btnFstat
.
tap
()
await
isDone
()
let
fstat
=
await
getData
(
"
fstat
"
)
expect
(
fstat
.
size
>
0
).
toBe
(
true
)
console
.
log
(
'
writeTest
'
,
'
4
'
)
//fstatSyncTest
btnFstat
=
await
page
.
$
(
'
#btn-fstat-file-sync
'
)
...
...
@@ -1384,6 +1381,7 @@ describe('ExtApi-FileManagerTest', () => {
await
isDone
()
fstat
=
await
getData
(
"
fstat
"
)
expect
(
fstat
.
size
>
0
).
toBe
(
true
)
console
.
log
(
'
writeTest
'
,
'
5
'
)
//ftruncateFileTest
let
btnFTruncateFile
=
await
page
.
$
(
'
#btn-ftruncate-file
'
)
...
...
@@ -1394,15 +1392,57 @@ describe('ExtApi-FileManagerTest', () => {
await
page
.
setData
({
ftruncate
:
''
,
})
console
.
log
(
'
writeTest
'
,
'
6
'
)
//ftruncateFileSyncTest
btnFTruncateFile
=
await
page
.
$
(
'
#btn-ftruncate-file-sync
'
)
await
btnFTruncateFile
.
tap
()
await
isDone
()
ftruncateRet
=
await
getData
(
"
ftruncateRet
"
)
expect
(
fstat
).
not
.
toEqual
(
'
ftruncate:ok
'
)
console
.
log
(
'
writeTest
'
,
'
7
'
)
});
//writeTest writeSyncTest
it
(
'
ftruncateFileTest
'
,
async
()
=>
{
if
(
!
isAndroid
())
{
return
}
console
.
log
(
'
ftruncateFileTest
'
,
'
start
'
)
// await clearDir('')
await
page
.
setData
({
logAble
:
false
,
mkdirFile
:
'
fd
'
,
writeFile
:
'
fd/1.txt
'
,
readFile
:
'
fd/1.txt
'
,
writeData
:
'
我是一只小小鸟我是
'
})
await
createFile
()
console
.
log
(
'
ftruncateFileTest
'
,
'
1
'
)
btnWrite
=
await
page
.
$
(
'
#btn-write-sync
'
)
await
btnWrite
.
tap
()
await
isDone
()
bytesWritten
=
await
getData
(
"
bytesWritten
"
)
expect
(
bytesWritten
).
toEqual
(
9
)
console
.
log
(
'
ftruncateFileTest
'
,
'
3
'
)
//ftruncateFileTest
let
btnFTruncateFile
=
await
page
.
$
(
'
#btn-ftruncate-file
'
)
await
btnFTruncateFile
.
tap
()
await
isDone
()
let
ftruncateRet
=
await
getData
(
"
ftruncateRet
"
)
expect
(
ftruncateRet
).
toEqual
(
'
ftruncate:ok
'
)
await
page
.
setData
({
ftruncate
:
''
,
})
console
.
log
(
'
ftruncateFileTest
'
,
'
6
'
)
//ftruncateFileSyncTest
btnFTruncateFile
=
await
page
.
$
(
'
#btn-ftruncate-file-sync
'
)
await
btnFTruncateFile
.
tap
()
await
isDone
()
ftruncateRet
=
await
getData
(
"
ftruncateRet
"
)
expect
(
ftruncateRet
).
toEqual
(
'
ftruncate:ok
'
)
console
.
log
(
'
ftruncateFileTest
'
,
'
7
'
)
});
//saveFileTest saveFileSyncTest getSavedFileListTest removeSavedFileTest
it
(
'
savefile test
'
,
async
()
=>
{
...
...
pages/API/get-file-system-manager/get-file-system-manager.uvue
浏览文件 @
b6566852
...
...
@@ -66,7 +66,7 @@
<button class="btnstyle" type="primary" @tap="closeSyncTest"
id="btn-close-file-sync">通过文件描述符同步关闭文件{{readFile}}</button>
<button class="btnstyle" type="primary" @tap="writeTest" id="btn-write">通过文件描述符写入文件{{readFile}}</button>
<button class="btnstyle" type="primary" @tap="writeSyncTest" id="btn-
read-file
">同步通过文件描述符写入文件{{readFile}}</button>
<button class="btnstyle" type="primary" @tap="writeSyncTest" id="btn-
write-sync
">同步通过文件描述符写入文件{{readFile}}</button>
<button class="btnstyle" type="primary" @tap="fstatTest" id="btn-fstat-file">通过文件描述符获取{{statFile}}的状态信息</button>
<button class="btnstyle" type="primary" @tap="fstatSyncTest"
id="btn-fstat-file-sync">同步通过文件描述符获取{{statFile}}的状态信息</button>
...
...
@@ -135,7 +135,7 @@
fstat: null as Stats | null,
ftruncateRet: '',
readZipFile: 'to.zip',
getSavedFileListRet:'',
getSavedFileListRet:
'',
/**
* 待测试的全局环境变量
*/
...
...
@@ -1007,87 +1007,47 @@
closeSyncTest() {
console.log('closeSyncTest')
const fileManager = uni.getFileSystemManager()
fileManager.open({
filePath: `${this.basePath}${this.readFile}`,
flag: "r+",
success: (res : OpenFileSuccessResult) => {
console.log("success", res)
if (res.fd.length <= 0) {
this.done = true
return
}
try {
console.log('closeSync')
fileManager.closeSync({
fd: res.fd
} as CloseSyncOptions)
if (this.logAble) {
this.log += 'closeSyncTest success:' + '\n\n'
}
this.done = true
this.closeFileRet = "close:ok"
} catch (e) {
if (this.logAble) {
this.log += 'closeSyncTest fail:' + JSON.stringify(e) + '\n\n'
}
console.log('fail', e)
this.done = true
}
},
fail: (res : UniError) => {
if (this.logAble) {
this.log += 'openFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
this.done = true
try {
console.log('closeSync')
fileManager.closeSync({
fd: this.openFileSyncTest()
} as CloseSyncOptions)
if (this.logAble) {
this.log += 'closeSyncTest success:' + '\n\n'
}
} as OpenFileOptions)
this.done = true
this.closeFileRet = "close:ok"
} catch (e) {
if (this.logAble) {
this.log += 'closeSyncTest fail:' + JSON.stringify(e) + '\n\n'
}
console.log('fail', e)
this.done = true
}
},
closeTest() {
const fileManager = uni.getFileSystemManager()
fileManager.open({
filePath: `${this.basePath}${this.readFile}`,
flag: "r+",
success: (res : OpenFileSuccessResult) => {
console.log("success", res)
if (res.fd.length <= 0) {
this.done = true
return
fileManager.close({
fd: this.openFileSyncTest(),
success: (res : FileManagerSuccessResult) => {
if (this.logAble) {
this.log += 'closeTest success:' + JSON.stringify(res) + '\n\n'
}
fileManager.close({
fd: res.fd,
success: (res : FileManagerSuccessResult) => {
if (this.logAble) {
this.log += 'closeTest success:' + JSON.stringify(res) + '\n\n'
}
this.closeFileRet = res.errMsg
console.log("success", res)
},
fail: (res : UniError) => {
if (this.logAble) {
this.log += 'closeTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
},
complete: (_) => {
this.done = true
}
} as CloseOptions)
this.closeFileRet = res.errMsg
console.log("success", res)
},
fail: (res : UniError) => {
if (this.logAble) {
this.log += '
openFil
eTest fail:' + JSON.stringify(res) + '\n\n'
this.log += '
clos
eTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
},
complete: (_) => {
this.done = true
}
} as OpenFileOptions)
} as CloseOptions)
},
writeTest() {
const fileManager = uni.getFileSystemManager()
...
...
@@ -1257,7 +1217,7 @@
this.log += 'ftruncateFileSyncTest success:' + '\n\n'
}
this.done = true
this.ftruncateRet = ''
this.ftruncateRet = '
ftruncate:ok
'
} catch (e) {
if (this.logAble) {
this.log += 'ftruncateFileSyncTest fail:' + JSON.stringify(e) + '\n\n'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录