Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
5bacbe98
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看板
未验证
提交
5bacbe98
编写于
6月 09, 2022
作者:
O
openharmony_ci
提交者:
Gitee
6月 09, 2022
浏览文件
操作
浏览文件
下载
差异文件
!3483 update fileio xts
Merge pull request !3483 from zhangxingxia/master
上级
33f1a568
e29c98bb
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
110 addition
and
28 deletion
+110
-28
storage/storagefileiojstest/src/main/js/default/test/FileIOStream.test.js
...ileiojstest/src/main/js/default/test/FileIOStream.test.js
+7
-8
storage/storagefileiojstest/src/main/js/default/test/module_fileio/class_stream/read.test.js
...n/js/default/test/module_fileio/class_stream/read.test.js
+63
-9
storage/storagefileiojstest/src/main/js/default/test/module_fileio/class_stream/write.test.js
.../js/default/test/module_fileio/class_stream/write.test.js
+40
-11
未找到文件。
storage/storagefileiojstest/src/main/js/default/test/FileIOStream.test.js
浏览文件 @
5bacbe98
...
...
@@ -1390,19 +1390,18 @@ describe('fileIOTestStream', function () {
let
fpath
=
await
nextFileName
(
'
fileio_test_stream_read_sync_005
'
);
let
text
=
'
0123456789abcdefg
'
;
expect
(
prepareFile
(
fpath
,
text
)).
assertTrue
();
let
ss
=
fileio
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
ss
!==
null
).
assertTrue
();
try
{
var
ss
=
fileio
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
ss
!==
null
).
assertTrue
();
let
len
=
ss
.
readSync
(
new
ArrayBuffer
(
4096
),
{
ss
.
readSync
(
new
ArrayBuffer
(
4096
),
{
position
:
-
1
});
expect
(
len
==
text
.
length
).
assertTrue
();
ss
.
closeSync
();
fileio
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
---fileio_test_stream_read_sync_005 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
console
.
info
(
'
fileio_test_stream_read_sync_005 has failed for
'
+
e
);
expect
(
e
.
message
==
"
option.position shall be positive number
"
).
assertTrue
();
ss
.
closeSync
();
fileio
.
unlinkSync
(
fpath
);
}
});
...
...
storage/storagefileiojstest/src/main/js/default/test/module_fileio/class_stream/read.test.js
浏览文件 @
5bacbe98
...
...
@@ -123,6 +123,7 @@ describe('fileio_stream_read', function () {
expect
(
ss
!==
null
).
assertTrue
();
let
readout
=
await
ss
.
read
(
new
ArrayBuffer
(
4096
),
{
offset
:
4096
});
expect
(
readout
.
bytesRead
==
0
).
assertTrue
();
expect
(
readout
.
offset
==
4096
).
assertTrue
();
ss
.
closeSync
();
fileio
.
unlinkSync
(
fpath
);
done
();
...
...
@@ -151,10 +152,15 @@ describe('fileio_stream_read', function () {
expect
(
ss
!==
null
).
assertTrue
();
let
options
=
{
offset
:
1
,
position
:
5
position
:
6
}
let
readout
=
await
ss
.
read
(
new
ArrayBuffer
(
4096
),
options
);
expect
(
readout
.
bytesRead
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
readout
.
bytesRead
==
FILE_CONTENT
.
length
-
6
).
assertTrue
();
expect
(
readout
.
offset
==
1
).
assertTrue
();
let
start
=
readout
.
offset
;
let
end
=
readout
.
offset
+
readout
.
bytesRead
;
let
result
=
String
.
fromCharCode
.
apply
(
null
,
new
Uint8Array
(
readout
.
buffer
.
slice
(
start
,
end
)));
expect
(
result
==
"
world
"
).
assertTrue
();
ss
.
closeSync
();
fileio
.
unlinkSync
(
fpath
);
done
();
...
...
@@ -267,7 +273,7 @@ describe('fileio_stream_read', function () {
/**
* @tc.number SUB_DF_FILEIO_STREAM_READASYNC_0900
* @tc.name fileio_test_stream_read_async_009
* @tc.desc Test read() interface, When the length is negative.
* @tc.desc Test read() interface, When the length is negative
,equivalent to omitting the parameter
.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -279,15 +285,13 @@ describe('fileio_stream_read', function () {
let
ss
=
fileio
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
ss
!==
null
).
assertTrue
();
try
{
let
readout
=
await
ss
.
read
(
new
ArrayBuffer
(
4096
),
{
length
:
-
1
});
console
.
info
(
"
====>
"
+
readout
.
bytesRead
);
done
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_stream_read_async_009 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Failed GetReadArg
"
).
assertTrue
();
let
readout
=
await
ss
.
read
(
new
ArrayBuffer
(
16
),
{
offset
:
13
,
length
:
-
1
});
expect
(
readout
.
bytesRead
==
3
).
assertTrue
();
ss
.
closeSync
();
fileio
.
unlinkSync
(
fpath
);
done
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_stream_read_async_009 has failed for
'
+
err
);
}
});
...
...
@@ -340,4 +344,54 @@ describe('fileio_stream_read', function () {
console
.
info
(
'
fileio_test_stream_read_async_011 has failed for
'
+
err
);
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_READASYNC_1200
* @tc.name fileio_test_stream_read_async_012
* @tc.desc Test read() interface, When the position is negative.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_stream_read_async_012
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stream_read_async_012
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
ss
=
fileio
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
ss
!==
null
).
assertTrue
();
try
{
await
ss
.
read
(
new
ArrayBuffer
(
4096
),
{
position
:
-
1
});
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_stream_read_async_012 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Failed GetReadArg
"
).
assertTrue
();
ss
.
closeSync
();
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_READASYNC_1300
* @tc.name fileio_test_stream_read_async_013
* @tc.desc Test read() interface,When the parameter type is wrong.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_stream_read_async_013
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stream_read_async_013
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
ss
=
fileio
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
ss
!==
null
).
assertTrue
();
try
{
await
ss
.
read
(
""
);
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_stream_read_async_013 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Failed GetReadArg
"
).
assertTrue
();
ss
.
closeSync
();
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
});
storage/storagefileiojstest/src/main/js/default/test/module_fileio/class_stream/write.test.js
浏览文件 @
5bacbe98
...
...
@@ -113,7 +113,7 @@ describe('fileio_stream_write', function () {
/**
* @tc.number SUB_DF_FILEIO_STREAM_WRITEASYNC_0300
* @tc.name fileio_test_stream_write_async_003
* @tc.desc Test write() interface,When the
length is 1
.
* @tc.desc Test write() interface,When the
offset is 1 and position is 5
.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -126,9 +126,14 @@ describe('fileio_stream_write', function () {
try
{
let
ss
=
fileio
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
ss
!==
null
).
assertTrue
();
let
content
=
"
hello, world
"
;
let
bytesWritten
=
await
ss
.
write
(
content
,
{
length
:
1
,
encoding
:
'
utf-8
'
});
expect
(
bytesWritten
==
1
).
assertTrue
();
let
content
=
"
test
"
;
let
bytesWritten
=
await
ss
.
write
(
content
,
{
offset
:
1
,
position
:
5
,
encoding
:
'
utf-8
'
});
expect
(
bytesWritten
==
content
.
length
-
1
).
assertTrue
();
let
readOut
=
await
ss
.
read
(
new
ArrayBuffer
(
4096
),
{
offset
:
0
,
position
:
0
});
let
start
=
readOut
.
offset
;
let
end
=
readOut
.
offset
+
readOut
.
bytesRead
;
let
result
=
String
.
fromCharCode
.
apply
(
null
,
new
Uint8Array
(
readOut
.
buffer
.
slice
(
start
,
end
)));
expect
(
result
==
"
helloestrld
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
ss
.
closeSync
();
done
();
...
...
@@ -330,7 +335,7 @@ describe('fileio_stream_write', function () {
/**
* @tc.number SUB_DF_FILEIO_STREAM_WRITEASYNC_1100
* @tc.name fileio_test_stream_write_async_011
* @tc.desc Test write() interface,When the length is negative.
* @tc.desc Test write() interface,When the length is negative
,equivalent to omitting the parameter
.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -343,15 +348,13 @@ describe('fileio_stream_write', function () {
expect
(
ss
!==
null
).
assertTrue
();
try
{
let
content
=
"
hello, world
"
;
let
number
=
await
ss
.
write
(
content
,
{
length
:
-
1
});
console
.
info
(
"
====>
"
+
number
);
done
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_stream_write_async_011 has failed for
'
+
err
);
expect
(
err
.
message
==
"
Invalid option.length, positive integer is desired
"
).
assertTrue
();
let
number
=
await
ss
.
write
(
content
,
{
offset
:
1
,
length
:
-
1
});
expect
(
number
==
content
.
length
-
1
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
ss
.
closeSync
();
done
();
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_stream_write_async_011 has failed for
'
+
err
);
}
});
...
...
@@ -432,4 +435,30 @@ describe('fileio_stream_write', function () {
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_WRITEASYNC_1500
* @tc.name fileio_test_stream_write_async_015
* @tc.desc Test write() interface,When the position is negative.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileio_test_stream_write_async_015
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_stream_write_async_015
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
ss
=
fileio
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
ss
!==
null
).
assertTrue
();
try
{
let
content
=
"
hello, world
"
;
await
ss
.
write
(
content
,
{
position
:
-
1
});
}
catch
(
err
)
{
console
.
info
(
'
fileio_test_stream_write_async_015 has failed for
'
+
err
);
expect
(
err
.
message
==
"
option.position shall be positive number
"
).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
ss
.
closeSync
();
done
();
}
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录