Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
d066cdf4
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
大约 1 年 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
d066cdf4
编写于
5月 26, 2022
作者:
O
openharmony_ci
提交者:
Gitee
5月 26, 2022
浏览文件
操作
浏览文件
下载
差异文件
!3307 update access.test.js
Merge pull request !3307 from raoxian/master
上级
aa83f0cd
54fcea17
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
140 addition
and
80 deletion
+140
-80
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/access.test.js
...main/js/default/test/module_fileio/members/access.test.js
+140
-80
未找到文件。
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/access.test.js
浏览文件 @
d066cdf4
...
...
@@ -25,7 +25,7 @@ describe('fileio_access', function () {
* @tc.name fileio_test_access_sync_000
* @tc.desc Test accessSync() interface.
* This interface shall work properly in normal case
* @tc.size MEDIUM
(中型)
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
...
...
@@ -35,20 +35,20 @@ describe('fileio_access', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
expect
(
fileio
.
accessSync
(
fpath
)
==
null
).
assertTrue
(
);
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
(
);
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_access_sync_000 has failed for
'
+
e
);
fileio
.
accessSync
(
fpath
);
fileio
.
unlinkSync
(
fpath
);
}
catch
(
e
rr
)
{
console
.
info
(
'
fileio_test_access_sync_000 has failed for
'
+
err
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSSYNC_0
01
0
* @tc.number SUB_DF_FILEIO_ACCESSSYNC_0
10
0
* @tc.name fileio_test_access_sync_001
* @tc.desc Test accessSync() interface.
* T
his interface shall throw an exception when the fpath is not given
* @tc.size MEDIUM
(中型)
* T
est that the current process has write permission.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
...
...
@@ -58,20 +58,20 @@ describe('fileio_access', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
expect
(
fileio
.
accessSync
(
fpath
,
0x2
)
==
null
).
assertTrue
(
);
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
(
);
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_access_sync_001
'
+
e
);
fileio
.
accessSync
(
fpath
,
2
);
fileio
.
unlinkSync
(
fpath
);
}
catch
(
e
rr
)
{
console
.
info
(
'
fileio_test_access_sync_001 has failed for
'
+
err
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSSYNC_0
02
0
* @tc.number SUB_DF_FILEIO_ACCESSSYNC_0
20
0
* @tc.name fileio_test_access_sync_002
* @tc.desc Test accessSync() interface.
* T
his interface shall throw an exception when the fpath is not given
* @tc.size MEDIUM
(中型)
* T
est that the current process has read permission.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
...
...
@@ -81,20 +81,20 @@ describe('fileio_access', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
expect
(
fileio
.
accessSync
(
fpath
,
0x4
)
==
null
).
assertTrue
(
);
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
(
);
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_access_sync_002
'
+
e
);
fileio
.
accessSync
(
fpath
,
4
);
fileio
.
unlinkSync
(
fpath
);
}
catch
(
e
rr
)
{
console
.
info
(
'
fileio_test_access_sync_002 has failed for
'
+
err
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSSYNC_0
03
0
* @tc.number SUB_DF_FILEIO_ACCESSSYNC_0
30
0
* @tc.name fileio_test_access_sync_003
* @tc.desc Test accessSync() interface.
* T
his interface shall throw an exception when the fpath is not given
.
* @tc.size MEDIUM
(中型)
* T
est that the current process has read and write permissions
.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
...
...
@@ -104,32 +104,55 @@ describe('fileio_access', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
expect
(
fileio
.
accessSync
(
fpath
,
0x2
|
0x4
)
==
null
).
assertTrue
(
);
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
(
);
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_access_sync_003
'
+
e
);
fileio
.
accessSync
(
fpath
,
2
|
4
);
fileio
.
unlinkSync
(
fpath
);
}
catch
(
e
rr
)
{
console
.
info
(
'
fileio_test_access_sync_003 has failed for
'
+
err
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSSYNC_0
04
0
* @tc.number SUB_DF_FILEIO_ACCESSSYNC_0
40
0
* @tc.name fileio_test_access_sync_004
* @tc.desc Test accessSync() interface.
* T
his interface shall throw an exception when the fpath is not given
* @tc.size MEDIUM
(中型)
* T
est that the current process has executable permissions.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_access_sync_004
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileIOTest
'
);
let
fpath
=
await
nextFileName
(
'
fileio_test_access_sync_004
'
);
fileio
.
openSync
(
fpath
,
0o102
,
0o777
);
try
{
fileio
.
accessSync
(
fpath
);
fileio
.
accessSync
(
fpath
,
1
);
fileio
.
unlinkSync
(
fpath
);
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_access_sync_004 has failed for
'
+
err
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_access_sync_004
'
+
e
);
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSSYNC_0500
* @tc.name fileio_test_access_sync_005
* @tc.desc Test accessSync() interface.
* The test file is not exist.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_access_sync_005
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileio_test_access_sync_005
'
);
try
{
fileio
.
accessSync
(
fpath
);
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_access_sync_005 has failed for
'
+
err
);
expect
(
err
.
message
==
'
No such file or directory
'
).
assertTrue
();
}
});
...
...
@@ -137,8 +160,8 @@ describe('fileio_access', function () {
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0000
* @tc.name fileio_test_access_async_000
* @tc.desc Test accessAsync() interface.
* This interface shall
throw an exception when the fpath is not given
* @tc.size MEDIUM
(中型)
* This interface shall
work properly in normal case.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
...
...
@@ -149,20 +172,20 @@ describe('fileio_access', function () {
try
{
await
fileio
.
access
(
fpath
);
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
done
();
}
catch
(
err
or
)
{
console
.
log
(
'
fileio_test_access_async_000 has failed for
'
+
erro
r
);
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_access_async_000 has failed for
'
+
er
r
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0
01
0
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0
10
0
* @tc.name fileio_test_access_async_001
* @tc.desc Test accessAsync() interface.
*
This interface shall throw an exception when the fpath is not given
* @tc.size MEDIUM
(中型)
*
Use promise to test that the current process has read permission. Async method reads data from file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
...
...
@@ -172,27 +195,25 @@ describe('fileio_access', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
expect
(
await
fileio
.
access
(
fpath
,
4
)
==
null
).
assertTrue
(
);
await
fileio
.
access
(
fpath
,
4
);
let
fd
=
fileio
.
openSync
(
fpath
);
expect
(
isIntNum
(
fd
)).
assertTrue
();
expect
(
(
await
fileio
.
read
(
fd
,
new
ArrayBuffer
(
4096
)))
!=
null
).
assertTrue
();
expect
(
fileio
.
closeSync
(
fd
)
==
null
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
();
expect
((
await
fileio
.
read
(
fd
,
new
ArrayBuffer
(
4096
)))
!=
null
).
assertTrue
();
fileio
.
closeSync
(
fd
);
fileio
.
unlinkSync
(
fpath
);
done
();
}
catch
(
err
or
)
{
console
.
log
(
'
fileio_test_access_async_001 has failed for
'
+
erro
r
);
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_access_async_001 has failed for
'
+
er
r
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0
02
0
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0
20
0
* @tc.name fileio_test_access_async_002
* @tc.desc Test accessAsync() interface.
* T
his interface shall throw an exception when the fpath is not given
* @tc.size MEDIUM
(中型)
* T
est file exists.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
...
...
@@ -203,21 +224,21 @@ describe('fileio_access', function () {
try
{
fileio
.
access
(
fpath
,
function
(
error
)
{
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
(
);
fileio
.
unlinkSync
(
fpath
);
done
();
});
}
catch
(
err
or
)
{
console
.
log
(
'
fileio_test_access_async_002 has failed for
'
+
erro
r
);
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_access_async_002 has failed for
'
+
er
r
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0
03
0
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0
30
0
* @tc.name fileio_test_access_async_003
* @tc.desc Test accessAsync() interface.
*
This interface shall throw an exception when the fpath is not given
* @tc.size MEDIUM
(中型)
*
Use callback to test that the current process has read permission. Async method reads data from file.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
...
...
@@ -230,46 +251,85 @@ describe('fileio_access', function () {
fileio
.
access
(
fpath
,
4
,
async
function
(
error
)
{
let
fd
=
fileio
.
openSync
(
fpath
);
expect
(
isIntNum
(
fd
)).
assertTrue
();
expect
(
(
await
fileio
.
read
(
fd
,
new
ArrayBuffer
(
4096
)))
!=
null
).
assertTrue
();
expect
(
fileio
.
closeSync
(
fd
)
==
null
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
();
expect
((
await
fileio
.
read
(
fd
,
new
ArrayBuffer
(
4096
)))
!=
null
).
assertTrue
();
fileio
.
closeSync
(
fd
);
fileio
.
unlinkSync
(
fpath
);
});
done
();
}
catch
(
err
or
)
{
console
.
log
(
'
fileio_test_access_async_003 has failed for
'
+
erro
r
);
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_access_async_003 has failed for
'
+
er
r
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0
04
0
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0
40
0
* @tc.name fileio_test_access_async_004
* @tc.desc Test accessAsync() interface.
*
This interface shall throw an exception when the fpath is not given
.
* @tc.size MEDIUM
(中型)
*
Use promises to test that the current process has executable permissions
.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_access_async_004
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_access_async_004
'
);
fileio
.
openSync
(
fpath
,
0o102
,
0o777
);
try
{
fileio
.
access
(
fpath
)
.
then
(
function
(
err
)
{
expect
(
null
).
assertFail
();
await
fileio
.
access
(
fpath
,
1
);
fileio
.
unlinkSync
(
fpath
);
done
();
})
.
catch
(
function
(
e
)
{
expect
(
!!
e
).
assertTrue
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_access_async_004 has failed for
'
+
err
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0500
* @tc.name fileio_test_access_async_005
* @tc.desc Test accessAsync() interface.
* Use callback to test that the current process has write permission.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_access_async_005
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_access_async_005
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
access
(
fpath
,
2
,
function
(
error
)
{
fileio
.
unlinkSync
(
fpath
);
done
();
});
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_access_async_004 has failed for
'
+
e
);
}
catch
(
e
rr
)
{
console
.
info
(
'
fileio_test_access_async_005 has failed for
'
+
err
);
expect
(
null
).
assertFail
();
}
});
/**
* @tc.number SUB_DF_FILEIO_ACCESSASYNC_0600
* @tc.name fileio_test_access_async_006
* @tc.desc Test accessAsync() interface.
* Async test file does not exist.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_access_async_006
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_access_async_006
'
);
try
{
await
fileio
.
access
(
fpath
);
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_access_async_006 has failed for
'
+
err
);
expect
(
err
.
message
==
'
No such file or directory
'
).
assertTrue
();
done
();
}
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录