Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
336913f9
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6007
Star
91
Fork
164
代码
文件
提交
分支
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看板
提交
336913f9
编写于
4月 19, 2024
作者:
WOSHIMAHAIFENG
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'alpha-file' into 'alpha'
修改file测试用例,防止ios测试失败 See merge request
!23
上级
5a5371a9
11a92737
变更
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
浏览文件 @
336913f9
...
@@ -1137,15 +1137,11 @@ describe('ExtApi-FileManagerTest', () => {
...
@@ -1137,15 +1137,11 @@ describe('ExtApi-FileManagerTest', () => {
function
isAndroid
()
{
function
isAndroid
()
{
if
(
process
.
env
.
uniTestPlatformInfo
.
indexOf
(
'
web
'
)
>
-
1
||
process
.
env
.
UNI_AUTOMATOR_APP_WEBVIEW
===
'
true
'
)
{
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
return
false
}
}
if
(
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
().
startsWith
(
'
ios
'
))
{
if
(
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
().
startsWith
(
'
ios
'
))
{
it
(
'
ios
'
,
()
=>
{
expect
(
1
).
toBe
(
1
)
expect
(
1
).
toBe
(
1
)
})
return
false
return
false
}
}
return
true
return
true
...
@@ -1247,7 +1243,7 @@ describe('ExtApi-FileManagerTest', () => {
...
@@ -1247,7 +1243,7 @@ describe('ExtApi-FileManagerTest', () => {
logAble
:
false
,
logAble
:
false
,
basePath
:
basePath
basePath
:
basePath
})
})
await
clearDir
(
''
)
//
await clearDir('')
await
page
.
setData
({
await
page
.
setData
({
logAble
:
false
,
logAble
:
false
,
basePath
:
globalTempPath
,
basePath
:
globalTempPath
,
...
@@ -1341,7 +1337,7 @@ describe('ExtApi-FileManagerTest', () => {
...
@@ -1341,7 +1337,7 @@ describe('ExtApi-FileManagerTest', () => {
if
(
!
isAndroid
())
{
if
(
!
isAndroid
())
{
return
return
}
}
console
.
log
(
'
writeTest
'
,
'
start
'
)
// await clearDir('')
// await clearDir('')
await
page
.
setData
({
await
page
.
setData
({
logAble
:
false
,
logAble
:
false
,
...
@@ -1351,13 +1347,13 @@ describe('ExtApi-FileManagerTest', () => {
...
@@ -1351,13 +1347,13 @@ describe('ExtApi-FileManagerTest', () => {
writeData
:
'
我是一只小小鸟
'
writeData
:
'
我是一只小小鸟
'
})
})
await
createFile
()
await
createFile
()
console
.
log
(
'
writeTest
'
,
'
1
'
)
let
btnWrite
=
await
page
.
$
(
'
#btn-write
'
)
let
btnWrite
=
await
page
.
$
(
'
#btn-write
'
)
await
btnWrite
.
tap
()
await
btnWrite
.
tap
()
await
isDone
()
await
isDone
()
let
bytesWritten
=
await
getData
(
"
bytesWritten
"
)
let
bytesWritten
=
await
getData
(
"
bytesWritten
"
)
expect
(
bytesWritten
).
toEqual
(
7
)
expect
(
bytesWritten
).
toEqual
(
7
)
console
.
log
(
'
writeTest
'
,
'
2
'
)
//writeSyncTest
//writeSyncTest
await
page
.
setData
({
await
page
.
setData
({
writeFile
:
'
fd/1.txt
'
,
writeFile
:
'
fd/1.txt
'
,
...
@@ -1365,18 +1361,19 @@ describe('ExtApi-FileManagerTest', () => {
...
@@ -1365,18 +1361,19 @@ describe('ExtApi-FileManagerTest', () => {
writeData
:
'
我是
'
writeData
:
'
我是
'
})
})
btnWrite
=
await
page
.
$
(
'
#btn-write
'
)
btnWrite
=
await
page
.
$
(
'
#btn-write
-sync
'
)
await
btnWrite
.
tap
()
await
btnWrite
.
tap
()
await
isDone
()
await
isDone
()
bytesWritten
=
await
getData
(
"
bytesWritten
"
)
bytesWritten
=
await
getData
(
"
bytesWritten
"
)
expect
(
bytesWritten
).
toEqual
(
2
)
expect
(
bytesWritten
).
toEqual
(
2
)
console
.
log
(
'
writeTest
'
,
'
3
'
)
//fstatTest
//fstatTest
let
btnFstat
=
await
page
.
$
(
'
#btn-fstat-file
'
)
let
btnFstat
=
await
page
.
$
(
'
#btn-fstat-file
'
)
await
btnFstat
.
tap
()
await
btnFstat
.
tap
()
await
isDone
()
await
isDone
()
let
fstat
=
await
getData
(
"
fstat
"
)
let
fstat
=
await
getData
(
"
fstat
"
)
expect
(
fstat
.
size
>
0
).
toBe
(
true
)
expect
(
fstat
.
size
>
0
).
toBe
(
true
)
console
.
log
(
'
writeTest
'
,
'
4
'
)
//fstatSyncTest
//fstatSyncTest
btnFstat
=
await
page
.
$
(
'
#btn-fstat-file-sync
'
)
btnFstat
=
await
page
.
$
(
'
#btn-fstat-file-sync
'
)
...
@@ -1384,6 +1381,7 @@ describe('ExtApi-FileManagerTest', () => {
...
@@ -1384,6 +1381,7 @@ describe('ExtApi-FileManagerTest', () => {
await
isDone
()
await
isDone
()
fstat
=
await
getData
(
"
fstat
"
)
fstat
=
await
getData
(
"
fstat
"
)
expect
(
fstat
.
size
>
0
).
toBe
(
true
)
expect
(
fstat
.
size
>
0
).
toBe
(
true
)
console
.
log
(
'
writeTest
'
,
'
5
'
)
//ftruncateFileTest
//ftruncateFileTest
let
btnFTruncateFile
=
await
page
.
$
(
'
#btn-ftruncate-file
'
)
let
btnFTruncateFile
=
await
page
.
$
(
'
#btn-ftruncate-file
'
)
...
@@ -1394,15 +1392,57 @@ describe('ExtApi-FileManagerTest', () => {
...
@@ -1394,15 +1392,57 @@ describe('ExtApi-FileManagerTest', () => {
await
page
.
setData
({
await
page
.
setData
({
ftruncate
:
''
,
ftruncate
:
''
,
})
})
console
.
log
(
'
writeTest
'
,
'
6
'
)
//ftruncateFileSyncTest
//ftruncateFileSyncTest
btnFTruncateFile
=
await
page
.
$
(
'
#btn-ftruncate-file-sync
'
)
btnFTruncateFile
=
await
page
.
$
(
'
#btn-ftruncate-file-sync
'
)
await
btnFTruncateFile
.
tap
()
await
btnFTruncateFile
.
tap
()
await
isDone
()
await
isDone
()
ftruncateRet
=
await
getData
(
"
ftruncateRet
"
)
ftruncateRet
=
await
getData
(
"
ftruncateRet
"
)
expect
(
fstat
).
not
.
toEqual
(
'
ftruncate:ok
'
)
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
//saveFileTest saveFileSyncTest getSavedFileListTest removeSavedFileTest
it
(
'
savefile test
'
,
it
(
'
savefile test
'
,
async
()
=>
{
async
()
=>
{
...
...
pages/API/get-file-system-manager/get-file-system-manager.uvue
浏览文件 @
336913f9
...
@@ -66,7 +66,7 @@
...
@@ -66,7 +66,7 @@
<button class="btnstyle" type="primary" @tap="closeSyncTest"
<button class="btnstyle" type="primary" @tap="closeSyncTest"
id="btn-close-file-sync">通过文件描述符同步关闭文件{{readFile}}</button>
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="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="fstatTest" id="btn-fstat-file">通过文件描述符获取{{statFile}}的状态信息</button>
<button class="btnstyle" type="primary" @tap="fstatSyncTest"
<button class="btnstyle" type="primary" @tap="fstatSyncTest"
id="btn-fstat-file-sync">同步通过文件描述符获取{{statFile}}的状态信息</button>
id="btn-fstat-file-sync">同步通过文件描述符获取{{statFile}}的状态信息</button>
...
@@ -135,7 +135,7 @@
...
@@ -135,7 +135,7 @@
fstat: null as Stats | null,
fstat: null as Stats | null,
ftruncateRet: '',
ftruncateRet: '',
readZipFile: 'to.zip',
readZipFile: 'to.zip',
getSavedFileListRet:'',
getSavedFileListRet:
'',
/**
/**
* 待测试的全局环境变量
* 待测试的全局环境变量
*/
*/
...
@@ -1007,19 +1007,10 @@
...
@@ -1007,19 +1007,10 @@
closeSyncTest() {
closeSyncTest() {
console.log('closeSyncTest')
console.log('closeSyncTest')
const fileManager = uni.getFileSystemManager()
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 {
try {
console.log('closeSync')
console.log('closeSync')
fileManager.closeSync({
fileManager.closeSync({
fd: res.fd
fd: this.openFileSyncTest()
} as CloseSyncOptions)
} as CloseSyncOptions)
if (this.logAble) {
if (this.logAble) {
this.log += 'closeSyncTest success:' + '\n\n'
this.log += 'closeSyncTest success:' + '\n\n'
...
@@ -1033,32 +1024,11 @@
...
@@ -1033,32 +1024,11 @@
console.log('fail', e)
console.log('fail', e)
this.done = true
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
}
} as OpenFileOptions)
},
},
closeTest() {
closeTest() {
const fileManager = uni.getFileSystemManager()
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({
fileManager.close({
fd: res.fd
,
fd: this.openFileSyncTest()
,
success: (res : FileManagerSuccessResult) => {
success: (res : FileManagerSuccessResult) => {
if (this.logAble) {
if (this.logAble) {
this.log += 'closeTest success:' + JSON.stringify(res) + '\n\n'
this.log += 'closeTest success:' + JSON.stringify(res) + '\n\n'
...
@@ -1079,16 +1049,6 @@
...
@@ -1079,16 +1049,6 @@
} as CloseOptions)
} as CloseOptions)
},
},
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
}
} as OpenFileOptions)
},
writeTest() {
writeTest() {
const fileManager = uni.getFileSystemManager()
const fileManager = uni.getFileSystemManager()
fileManager.open({
fileManager.open({
...
@@ -1257,7 +1217,7 @@
...
@@ -1257,7 +1217,7 @@
this.log += 'ftruncateFileSyncTest success:' + '\n\n'
this.log += 'ftruncateFileSyncTest success:' + '\n\n'
}
}
this.done = true
this.done = true
this.ftruncateRet = ''
this.ftruncateRet = '
ftruncate:ok
'
} catch (e) {
} catch (e) {
if (this.logAble) {
if (this.logAble) {
this.log += 'ftruncateFileSyncTest fail:' + JSON.stringify(e) + '\n\n'
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录