Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
2be4c294
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看板
提交
2be4c294
编写于
4月 01, 2022
作者:
S
shuzhouhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fileio stream write返回错误,测试用例对应修改
Signed-off-by:
N
shuzhouhao
<
shuzhouhao@huawei.com
>
上级
940d85e8
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
18 addition
and
16 deletion
+18
-16
storage/storagefileioerrorjstest/src/main/js/default/test/Common.js
...oragefileioerrorjstest/src/main/js/default/test/Common.js
+3
-3
storage/storagefileioerrorjstest/src/main/js/default/test/FileIOError.test.js
...oerrorjstest/src/main/js/default/test/FileIOError.test.js
+1
-1
storage/storagefileiojstest/src/main/js/default/test/Common.js
...ge/storagefileiojstest/src/main/js/default/test/Common.js
+1
-4
storage/storagefileiojstest/src/main/js/default/test/module_fileio/class_stream/write.test.js
.../js/default/test/module_fileio/class_stream/write.test.js
+13
-8
未找到文件。
storage/storagefileioerrorjstest/src/main/js/default/test/Common.js
浏览文件 @
2be4c294
...
...
@@ -96,15 +96,15 @@ export function fileToReadAndWrite(fpath) {
}
}
export
function
appName
(
testName
)
{
const
BASE_PATH
=
'
/data/
accounts/account_0/appdata/ohos.acts.stroage.fileio
/
'
const
BASE_PATH
=
'
/data/
storage/el2/base/haps/entry
/
'
return
BASE_PATH
+
testName
}
export
function
nextFileName
(
testName
)
{
const
BASE_PATH
=
'
/data/
accounts/account_0/appdata/ohos.acts.stroage.fileio
/cache/
'
const
BASE_PATH
=
'
/data/
storage/el2/base/haps/entry
/cache/
'
return
BASE_PATH
+
testName
}
export
function
fileName
(
testName
)
{
const
BASE_PATH
=
'
/data/
accounts/account_0/appdata/ohos.acts.stroage.fileio
/files/
'
const
BASE_PATH
=
'
/data/
storage/el2/base/haps/entry
/files/
'
return
BASE_PATH
+
testName
}
export
function
cacheFileName
(
testName
)
{
...
...
storage/storagefileioerrorjstest/src/main/js/default/test/FileIOError.test.js
浏览文件 @
2be4c294
...
...
@@ -13,7 +13,7 @@
* limitations under the License.
*/
import
fileio
from
'
@
system
.fileio
'
import
fileio
from
'
@
ohos
.fileio
'
import
{
describe
,
it
,
...
...
storage/storagefileiojstest/src/main/js/default/test/Common.js
浏览文件 @
2be4c294
...
...
@@ -74,10 +74,7 @@ export function fileToWriteOnly(fpath) {
return
false
}
}
export
function
nextFileName1
(
testName
)
{
const
BASE_PATH
=
'
/data/accounts/account_0/appdata/ohos.acts.storage.fileio/cache/
'
return
BASE_PATH
+
testName
+
'
_
'
+
randomString
(
testName
.
length
);
}
export
async
function
nextFileName
(
testName
)
{
let
context
=
featureAbility
.
getContext
();
let
data
=
await
context
.
getFilesDir
();
...
...
storage/storagefileiojstest/src/main/js/default/test/module_fileio/class_stream/write.test.js
浏览文件 @
2be4c294
...
...
@@ -14,7 +14,7 @@
*/
import
{
fileio
,
FILE_CONTENT
,
prepareFile
,
nextFileName
1
,
nextFileName
,
fileio
,
FILE_CONTENT
,
prepareFile
,
nextFileName
,
describe
,
it
,
expect
,
}
from
'
../../Common
'
;
...
...
@@ -36,16 +36,18 @@ describe('fileio_stream', function () {
try
{
let
ss
=
fileio
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
ss
!==
null
).
assertTrue
();
ss
.
write
(
new
ArrayBuffer
(
4096
),
{
let
length
=
4096
;
ss
.
write
(
new
ArrayBuffer
(
length
),
{
position
:
1
}).
then
(
function
(
len
)
{
expect
(
len
==
(
FILE_CONTENT
.
length
-
1
)
).
assertTrue
();
expect
(
len
==
length
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
();
done
();
})
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_stream_write_async_000 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
done
();
}
});
...
...
@@ -59,20 +61,23 @@ describe('fileio_stream', function () {
* @tc.require
*/
it
(
'
fileio_test_stream_write_async_001
'
,
0
,
async
function
(
done
)
{
let
fpath
=
nextFileName1
(
'
fileio_test_stream_write_async_001
'
);
let
fpath
=
await
nextFileName
(
'
fileio_test_stream_write_async_001
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
ss
=
fileio
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
ss
!==
null
).
assertTrue
();
ss
.
write
(
new
ArrayBuffer
(
4096
),
{
offset
:
1
,
encoding
:
'
utf-8
'
},
function
(
err
,
bytesWritten
)
{
expect
(
bytesWritten
==
(
FILE_CONTENT
.
length
-
1
)).
assertTrue
();
let
length
=
4096
;
let
offset
=
1
;
ss
.
write
(
new
ArrayBuffer
(
length
),
{
offset
:
offset
,
encoding
:
'
utf-8
'
},
function
(
err
,
bytesWritten
)
{
expect
(
bytesWritten
==
(
length
-
offset
)).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
();
done
();
});
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_stream_write_async_001 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
done
();
}
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录