Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
eccbee5b
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,发现更多精彩内容 >>
未验证
提交
eccbee5b
编写于
2月 17, 2023
作者:
O
openharmony_ci
提交者:
Gitee
2月 17, 2023
浏览文件
操作
浏览文件
下载
差异文件
!7378 Add XTS for class_stream interfaces of mod_fs
Merge pull request !7378 from zhuhongtao666/class_stream
上级
fabeeb4e
22722524
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
2060 addition
and
0 deletion
+2060
-0
storage/storagefileiov9jstest/src/main/js/test/class_stream/close.test.js
...ileiov9jstest/src/main/js/test/class_stream/close.test.js
+214
-0
storage/storagefileiov9jstest/src/main/js/test/class_stream/flush.test.js
...ileiov9jstest/src/main/js/test/class_stream/flush.test.js
+171
-0
storage/storagefileiov9jstest/src/main/js/test/class_stream/read.test.js
...fileiov9jstest/src/main/js/test/class_stream/read.test.js
+681
-0
storage/storagefileiov9jstest/src/main/js/test/class_stream/write.test.js
...ileiov9jstest/src/main/js/test/class_stream/write.test.js
+994
-0
未找到文件。
storage/storagefileiov9jstest/src/main/js/test/class_stream/close.test.js
0 → 100644
浏览文件 @
eccbee5b
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
{
fileIO
,
FILE_CONTENT
,
prepareFile
,
nextFileName
,
describe
,
it
,
expect
,
}
from
'
../Common
'
;
export
default
function
fileIOStreamClose
()
{
describe
(
'
fileIO_fs_stream_close
'
,
function
()
{
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSESYNC_0000
* @tc.name fileIO_test_stream_close_sync_000
* @tc.desc Test the closeSync() interface of class Stream.
* Open a file stream, close file stream.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileIO_test_stream_close_sync_000
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_stream_close_sync_000
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
ss
=
fileIO
.
createStreamSync
(
fpath
,
'
r
'
);
expect
(
ss
!==
null
).
assertTrue
();
ss
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_stream_close_sync_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
})
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSESYNC_0100
* @tc.name fileIO_test_stream_close_sync_001
* @tc.desc Test the closeSync() interface of class Stream.
* Invalid parameter, don't requrie any parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_stream_close_sync_001
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_stream_close_sync_001
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
ss
=
fileIO
.
createStreamSync
(
fpath
,
'
r
'
);
try
{
expect
(
ss
!==
null
).
assertTrue
();
ss
.
closeSync
(
1
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
ss
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_stream_close_sync_001 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
}
})
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSESYNC_0200
* @tc.name fileIO_test_stream_close_sync_002
* @tc.desc Test the closeSync() interface of class Stream.
* The file stream has been closed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_stream_close_sync_002
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_stream_close_sync_002
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
ss
=
fileIO
.
createStreamSync
(
fpath
,
'
r
'
);
try
{
expect
(
ss
!==
null
).
assertTrue
();
ss
.
closeSync
();
ss
.
closeSync
();
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_stream_close_sync_002 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900005
&&
e
.
message
==
'
I/O error
'
).
assertTrue
();
}
})
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSEASYNC_0000
* @tc.name fileIO_test_stream_close_async_000
* @tc.desc Test the close() interface of class Stream. Promise.
* Open a file stream, close file stream.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 1
* @tc.require
*/
it
(
'
fileIO_test_stream_close_async_000
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_stream_close_async_000
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
ss
=
fileIO
.
createStreamSync
(
fpath
,
'
r
'
);
expect
(
ss
!==
null
).
assertTrue
();
await
ss
.
close
();
fileIO
.
unlinkSync
(
fpath
);
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_stream_close_async_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSEASYNC_0100
* @tc.name fileIO_test_stream_close_async_001
* @tc.desc Test the close() interface of class Stream. Callback.
* Open a file stream, close file stream.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 1
* @tc.require
*/
it
(
'
fileIO_test_stream_close_async_001
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_stream_close_async_001
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
ss
=
fileIO
.
createStreamSync
(
fpath
,
'
r
'
);
expect
(
ss
!==
null
).
assertTrue
();
ss
.
close
((
err
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_stream_close_async_001 error package:
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
}
fileIO
.
unlinkSync
(
fpath
);
})
done
();
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_stream_close_async_001 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSEASYNC_0200
* @tc.name fileIO_test_stream_close_async_002
* @tc.desc Test the close() interface of class Stream. Promise.
* The file stream has been closed.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_stream_close_async_002
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_stream_close_async_002
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
ss
=
fileIO
.
createStreamSync
(
fpath
,
'
r
'
);
expect
(
ss
!==
null
).
assertTrue
();
await
ss
.
close
();
await
ss
.
close
();
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_stream_close_async_002 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900005
&&
e
.
message
==
'
I/O error
'
).
assertTrue
();
done
();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_CLOSEASYNC_0300
* @tc.name fileIO_test_stream_close_async_003
* @tc.desc Test the close() interface of class Stream. Promise.
* Invalid parameter, don't requrie any parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_stream_close_async_003
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_stream_close_async_003
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
ss
=
fileIO
.
createStreamSync
(
fpath
,
'
r
'
);
expect
(
ss
!==
null
).
assertTrue
();
await
ss
.
close
(
1
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_stream_close_async_003 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
done
();
}
});
})
}
storage/storagefileiov9jstest/src/main/js/test/class_stream/flush.test.js
0 → 100644
浏览文件 @
eccbee5b
/*
* Copyright (C) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
{
fileIO
,
FILE_CONTENT
,
prepareFile
,
nextFileName
,
describe
,
it
,
expect
,
}
from
'
../Common
'
;
export
default
function
fileIOStreamFlush
()
{
describe
(
'
fileIO_fs_stream_flush
'
,
function
()
{
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSHSYNC_0000
* @tc.name fileIO_test_stream_flush_sync_000
* @tc.desc Test the flushSync() interface of class Stream.
* Refresh file stream.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileIO_test_stream_flush_sync_000
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_stream_flush_sync_000
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
ss
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
ss
!==
null
).
assertTrue
();
expect
(
ss
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
ss
.
flushSync
();
ss
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_stream_flush_sync_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSHSYNC_0100
* @tc.name fileIO_test_stream_flush_sync_001
* @tc.desc Test the flushSync() interface of class Stream.
* Invalid parameter, don't requrie any parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_stream_flush_sync_001
'
,
0
,
async
function
()
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_stream_flush_sync_001
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
ss
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
try
{
expect
(
ss
!==
null
).
assertTrue
();
ss
.
flushSync
(
1
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
ss
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_stream_flush_sync_001 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSHASYNC_0000
* @tc.name fileIO_test_stream_flush_async_000
* @tc.desc Test the flush() interface of class Stream. Promise.then().catch()
* Refresh the file stream.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_stream_flush_async_000
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_stream_flush_async_000
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
ss
=
await
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
ss
!==
null
).
assertTrue
();
expect
(
ss
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
ss
.
flush
().
then
(()
=>
{
ss
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
'
fileIO_test_stream_flush_async_000 error package
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
});
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_stream_flush_async_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSHASYNC_0100
* @tc.name fileIO_test_stream_flush_async_001
* @tc.desc Test the flush() interface of class Stream. Callback.
* Refresh the file stream.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 1
* @tc.require
*/
it
(
'
fileIO_test_stream_flush_async_001
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_stream_flush_async_001
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
let
ss
=
await
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
expect
(
ss
!==
null
).
assertTrue
();
expect
(
ss
.
writeSync
(
FILE_CONTENT
)
==
FILE_CONTENT
.
length
).
assertTrue
();
ss
.
flush
((
err
)
=>
{
if
(
err
)
{
console
.
log
(
'
fileIO_test_stream_flush_async_001 error package
'
+
JSON
.
stringify
(
err
));
expect
(
false
).
assertTrue
();
}
ss
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
done
();
})
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_stream_flush_async_001 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_STREAM_FLUSHASYNC_0100
* @tc.name fileIO_test_stream_flush_async_001
* @tc.desc Test the flush() interface of class Stream. Promise.
* Refresh the file stream.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_stream_flush_sync_001
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileIO_test_stream_flush_sync_001
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
ss
=
fileIO
.
createStreamSync
(
fpath
,
'
r+
'
);
try
{
expect
(
ss
!==
null
).
assertTrue
();
await
ss
.
flush
(
1
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
ss
.
closeSync
();
fileIO
.
unlinkSync
(
fpath
);
console
.
log
(
'
fileIO_test_stream_flush_sync_001 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
done
();
}
});
});
}
storage/storagefileiov9jstest/src/main/js/test/class_stream/read.test.js
0 → 100644
浏览文件 @
eccbee5b
此差异已折叠。
点击以展开。
storage/storagefileiov9jstest/src/main/js/test/class_stream/write.test.js
0 → 100644
浏览文件 @
eccbee5b
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录