Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
85ca05ce
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,发现更多精彩内容 >>
提交
85ca05ce
编写于
8月 21, 2023
作者:
F
fengjq
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add XTS for FileURI object
Signed-off-by:
N
fengjq
<
fengjunqing@huawei.com
>
上级
5cbefa9f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
110 addition
and
0 deletion
+110
-0
storage/storagefileurijstest/src/main/js/test/fileuri.test.js
...age/storagefileurijstest/src/main/js/test/fileuri.test.js
+110
-0
未找到文件。
storage/storagefileurijstest/src/main/js/test/fileuri.test.js
浏览文件 @
85ca05ce
...
...
@@ -93,5 +93,115 @@ describe('file_uri_test', function () {
}
});
/**
* @tc.number SUB_STORAGE_FileUri_Parameter_0000
* @tc.name FileUri_Parameter_Name_000
* @tc.desc Get the FileURI object through 'path' and validates the properties of the FileURI object.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
FileUri_Parameter_Name_000
'
,
0
,
async
function
()
{
try
{
let
name
=
'
sync_000.txt
'
;
let
path
=
'
/data/storage/el2/base/haps/entry/files/sync_000.txt
'
;
let
uri
=
fileUri
.
getUriFromPath
(
path
);
let
fileFromPath
=
fs
.
openSync
(
path
,
fs
.
OpenMode
.
CREATE
|
fs
.
OpenMode
.
READ_WRITE
);
fs
.
writeSync
(
fileFromPath
.
fd
,
CONTENT
);
let
fileUriObject
=
new
fileUri
.
FileUri
(
fileFromPath
.
path
);
expect
(
name
===
fileUriObject
.
name
).
assertTrue
();
expect
(
path
===
fileUriObject
.
path
).
assertTrue
();
expect
(
uri
===
fileUriObject
.
toString
()).
assertTrue
();
fs
.
closeSync
(
fileFromPath
);
let
fileFromUri
=
fs
.
openSync
(
fileUriObject
.
toString
(),
fs
.
OpenMode
.
READ_ONLY
);
let
readLen
=
fs
.
readSync
(
fileFromUri
.
fd
,
new
ArrayBuffer
(
32
),
{
offset
:
0
});
expect
(
readLen
===
CONTENT
.
length
).
assertTrue
();
fs
.
closeSync
(
fileFromUri
);
fs
.
unlinkSync
(
path
);
}
catch
(
e
)
{
console
.
log
(
'
FileUri_Parameter_Name_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_STORAGE_FileUri_Parameter_0100
* @tc.name FileUri_Parameter_Name_001
* @tc.desc Get the FileURI object through 'uri' and validates the properties of the FileURI object.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
FileUri_Parameter_Name_001
'
,
0
,
async
function
()
{
try
{
let
name
=
'
sync_001.txt
'
;
let
path
=
'
/data/storage/el2/base/haps/entry/files/sync_001.txt
'
;
let
uri
=
fileUri
.
getUriFromPath
(
path
);
let
fileUriObject
=
new
fileUri
.
FileUri
(
uri
);
expect
(
name
===
fileUriObject
.
name
).
assertTrue
();
expect
(
path
===
fileUriObject
.
path
).
assertTrue
();
expect
(
uri
===
fileUriObject
.
toString
()).
assertTrue
();
let
fileFromPath
=
fs
.
openSync
(
fileUriObject
.
path
,
fs
.
OpenMode
.
CREATE
|
fs
.
OpenMode
.
READ_WRITE
);
fs
.
writeSync
(
fileFromPath
.
fd
,
CONTENT
);
expect
(
name
===
fileFromPath
.
name
).
assertTrue
();
expect
(
path
===
fileFromPath
.
path
).
assertTrue
();
fs
.
closeSync
(
fileFromPath
);
let
fileFromUri
=
fs
.
openSync
(
fileUriObject
.
toString
(),
fs
.
OpenMode
.
READ_ONLY
);
let
readLen
=
fs
.
readSync
(
fileFromUri
.
fd
,
new
ArrayBuffer
(
32
),
{
offset
:
0
});
expect
(
readLen
===
CONTENT
.
length
).
assertTrue
();
fs
.
closeSync
(
fileFromUri
);
fs
.
unlinkSync
(
path
);
}
catch
(
e
)
{
console
.
log
(
'
FileUri_Parameter_Name_001 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_STORAGE_FileUri_Parameter_0200
* @tc.name FileUri_Parameter_Name_002
* @tc.desc Get the FileURI object through an empty string or uri which has no suffix directories.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
FileUri_Parameter_Name_002
'
,
0
,
async
function
()
{
try
{
let
uri
=
fileUri
.
getUriFromPath
(
''
);
let
fileUriObject01
=
new
fileUri
.
FileUri
(
uri
);
expect
(
fileUriObject01
.
name
===
''
).
assertTrue
();
expect
(
fileUriObject01
.
path
===
''
).
assertTrue
();
expect
(
uri
===
fileUriObject01
.
toString
()
&&
uri
===
'
file://ohos.acts.storage.fileuri
'
).
assertTrue
();
let
fileUriObject02
=
new
fileUri
.
FileUri
(
''
);
expect
(
fileUriObject02
.
name
===
''
).
assertTrue
();
expect
(
fileUriObject02
.
path
===
''
).
assertTrue
();
expect
(
uri
===
fileUriObject02
.
toString
()
&&
uri
===
'
file://ohos.acts.storage.fileuri
'
).
assertTrue
();
}
catch
(
e
)
{
console
.
log
(
'
FileUri_Parameter_Name_002 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_STORAGE_FileUri_Parameter_0300
* @tc.name FileUri_Parameter_Name_003
* @tc.desc Enter the illegal parameter type.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
FileUri_Parameter_Name_003
'
,
0
,
async
function
()
{
try
{
new
fileUri
.
FileUri
(
0
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
console
.
log
(
'
FileUri_Parameter_Name_003 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
}
});
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录