Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
ba794f6c
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,发现更多精彩内容 >>
提交
ba794f6c
编写于
11月 15, 2021
作者:
S
Storage sandboxing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
删除storage下storagefileiojstest的file案例
Signed-off-by:
N
Storage sandboxing
<
raoxian050@chinasoftinc.com
>
上级
9670e5c8
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
26 addition
and
3847 deletion
+26
-3847
storage/storagefileiojstest/src/main/js/default/test/Common.js
...ge/storagefileiojstest/src/main/js/default/test/Common.js
+21
-16
storage/storagefileiojstest/src/main/js/default/test/File.test.js
...storagefileiojstest/src/main/js/default/test/File.test.js
+0
-3789
storage/storagefileiojstest/src/main/js/default/test/FileIO.test.js
...oragefileiojstest/src/main/js/default/test/FileIO.test.js
+0
-37
storage/storagefileiojstest/src/main/js/default/test/FileIODirent.test.js
...ileiojstest/src/main/js/default/test/FileIODirent.test.js
+1
-1
storage/storagefileiojstest/src/main/js/default/test/FileIOStream.test.js
...ileiojstest/src/main/js/default/test/FileIOStream.test.js
+4
-3
storage/storagefileiojstest/src/main/js/default/test/List.test.js
...storagefileiojstest/src/main/js/default/test/List.test.js
+0
-1
未找到文件。
storage/storagefileiojstest/src/main/js/default/test/Common.js
浏览文件 @
ba794f6c
...
@@ -13,9 +13,14 @@
...
@@ -13,9 +13,14 @@
* limitations under the License.
* limitations under the License.
*/
*/
import
fileio
from
'
@
system.fileio
'
import
fileio
from
'
@
ohos.fileio
'
;
export
const
FILE_CONTENT
=
'
hello world
'
export
const
FILE_CONTENT
=
'
hello world
'
;
import
{
expect
}
from
'
deccjsunit/index
'
export
function
prepareFile
(
fpath
,
content
)
{
export
function
prepareFile
(
fpath
,
content
)
{
try
{
try
{
...
@@ -39,7 +44,7 @@ export function prepareFile1(fpath, content) {
...
@@ -39,7 +44,7 @@ export function prepareFile1(fpath, content) {
fileio
.
fsyncSync
(
fd
)
fileio
.
fsyncSync
(
fd
)
fileio
.
closeSync
(
fd
)
fileio
.
closeSync
(
fd
)
return
true
return
true
}
}
catch
(
e
)
{
catch
(
e
)
{
console
.
log
(
'
Failed to prepareFile for
'
+
e
)
console
.
log
(
'
Failed to prepareFile for
'
+
e
)
return
false
return
false
...
@@ -50,7 +55,7 @@ export function prepareEmptyFile(fpath) {
...
@@ -50,7 +55,7 @@ export function prepareEmptyFile(fpath) {
let
fd
=
fileio
.
openSync
(
fpath
,
0o102
,
0o777
)
let
fd
=
fileio
.
openSync
(
fpath
,
0o102
,
0o777
)
fileio
.
closeSync
(
fd
)
fileio
.
closeSync
(
fd
)
return
true
return
true
}
}
catch
(
e
)
{
catch
(
e
)
{
console
.
log
(
'
Failed to prepareFile for
'
+
e
)
console
.
log
(
'
Failed to prepareFile for
'
+
e
)
return
false
return
false
...
@@ -63,7 +68,7 @@ export function fileToReadOnly(fpath) {
...
@@ -63,7 +68,7 @@ export function fileToReadOnly(fpath) {
fileio
.
fsyncSync
(
fd
)
fileio
.
fsyncSync
(
fd
)
fileio
.
closeSync
(
fd
)
fileio
.
closeSync
(
fd
)
return
true
return
true
}
}
catch
(
e
)
{
catch
(
e
)
{
console
.
log
(
'
Failed to fileToReadOnly for
'
+
e
);
console
.
log
(
'
Failed to fileToReadOnly for
'
+
e
);
return
false
return
false
...
@@ -76,7 +81,7 @@ export function fileToWriteOnly(fpath) {
...
@@ -76,7 +81,7 @@ export function fileToWriteOnly(fpath) {
fileio
.
fsyncSync
(
fd
)
fileio
.
fsyncSync
(
fd
)
fileio
.
closeSync
(
fd
)
fileio
.
closeSync
(
fd
)
return
true
return
true
}
}
catch
(
e
)
{
catch
(
e
)
{
console
.
log
(
'
Failed to fileToWriteOnly
'
+
e
)
console
.
log
(
'
Failed to fileToWriteOnly
'
+
e
)
return
false
return
false
...
@@ -89,7 +94,7 @@ export function fileToReadAndWrite(fpath) {
...
@@ -89,7 +94,7 @@ export function fileToReadAndWrite(fpath) {
fileio
.
fsyncSync
(
fd
)
fileio
.
fsyncSync
(
fd
)
fileio
.
closeSync
(
fd
)
fileio
.
closeSync
(
fd
)
return
true
return
true
}
}
catch
(
e
)
{
catch
(
e
)
{
console
.
log
(
'
Failed to fileToReadAndWrite
'
+
e
);
console
.
log
(
'
Failed to fileToReadAndWrite
'
+
e
);
return
false
return
false
...
@@ -97,27 +102,27 @@ export function fileToReadAndWrite(fpath) {
...
@@ -97,27 +102,27 @@ export function fileToReadAndWrite(fpath) {
}
}
export
function
appName
(
testName
)
{
export
function
appName
(
testName
)
{
const
BASE_PATH
=
'
/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/
'
const
BASE_PATH
=
'
/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/
'
return
BASE_PATH
+
testName
return
BASE_PATH
+
testName
+
'
_
'
+
randomString
(
testName
.
length
);
}
}
export
function
nextFileName
(
testName
)
{
export
function
nextFileName
(
testName
)
{
const
BASE_PATH
=
'
/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/cache/
'
const
BASE_PATH
=
'
/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/cache/
'
return
BASE_PATH
+
testName
return
BASE_PATH
+
testName
+
'
_
'
+
randomString
(
testName
.
length
);
}
}
export
function
fileName
(
testName
)
{
export
function
fileName
(
testName
)
{
const
BASE_PATH
=
'
/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/files/
'
const
BASE_PATH
=
'
/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/files/
'
return
BASE_PATH
+
testName
return
BASE_PATH
+
testName
+
'
_
'
+
randomString
(
testName
.
length
);
}
}
export
function
cacheFileName
(
testName
)
{
export
function
cacheFileName
(
testName
)
{
const
BASE_PATH
=
'
/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/files/cache/
'
const
BASE_PATH
=
'
/data/accounts/account_0/appdata/ohos.acts.stroage.fileio/files/cache/
'
return
BASE_PATH
+
testName
return
BASE_PATH
+
testName
+
'
_
'
+
randomString
(
testName
.
length
);
}
}
export
function
differentFileName
(
testName
)
{
export
function
differentFileName
(
testName
)
{
const
BASE_PATH
=
'
/data/accounts/account_0/ohos.acts.distributeddatamgr.distributedfile/
'
const
BASE_PATH
=
'
/data/accounts/account_0/ohos.acts.distributeddatamgr.distributedfile/
'
return
BASE_PATH
+
testName
return
BASE_PATH
+
testName
+
'
_
'
+
randomString
(
testName
.
length
);
}
}
export
function
differentCacheName
(
testName
)
{
export
function
differentCacheName
(
testName
)
{
const
BASE_PATH
=
'
/data/accounts/account_0/ohos.acts.distributeddatamgr.distributedfile/cache/
'
const
BASE_PATH
=
'
/data/accounts/account_0/ohos.acts.distributeddatamgr.distributedfile/cache/
'
return
BASE_PATH
+
testName
return
BASE_PATH
+
testName
+
'
_
'
+
randomString
(
testName
.
length
);
}
}
export
function
getFileTextLen
(
fpath
)
{
export
function
getFileTextLen
(
fpath
)
{
...
@@ -130,7 +135,7 @@ export function getFileTextLen(fpath) {
...
@@ -130,7 +135,7 @@ export function getFileTextLen(fpath) {
console
.
log
(
'
file lenth:
'
+
len
)
console
.
log
(
'
file lenth:
'
+
len
)
expect
(
ss
.
closeSync
()
!==
null
).
assertTrue
()
expect
(
ss
.
closeSync
()
!==
null
).
assertTrue
()
return
len
return
len
}
}
catch
(
e
)
{
catch
(
e
)
{
console
.
log
(
'
Failed to getFileTextLen
'
+
e
)
console
.
log
(
'
Failed to getFileTextLen
'
+
e
)
expect
(
ss
.
closeSync
()
!==
null
).
assertTrue
()
expect
(
ss
.
closeSync
()
!==
null
).
assertTrue
()
...
@@ -143,7 +148,7 @@ export function isFileExist(fpath) {
...
@@ -143,7 +148,7 @@ export function isFileExist(fpath) {
console
.
log
(
'
file:
'
+
fpath
)
console
.
log
(
'
file:
'
+
fpath
)
console
.
log
(
'
status:exist
'
)
console
.
log
(
'
status:exist
'
)
return
true
return
true
}
}
catch
(
e
)
{
catch
(
e
)
{
console
.
log
(
'
file:
'
+
fpath
)
console
.
log
(
'
file:
'
+
fpath
)
console
.
log
(
'
status:non-existen
'
)
console
.
log
(
'
status:non-existen
'
)
...
@@ -167,4 +172,4 @@ export function randomString(num) {
...
@@ -167,4 +172,4 @@ export function randomString(num) {
pwd
+=
$chars
.
charAt
(
Math
.
floor
(
Math
.
random
()
*
maxPos
));
pwd
+=
$chars
.
charAt
(
Math
.
floor
(
Math
.
random
()
*
maxPos
));
}
}
return
pwd
;
return
pwd
;
}
}
\ No newline at end of file
storage/storagefileiojstest/src/main/js/default/test/File.test.js
已删除
100644 → 0
浏览文件 @
9670e5c8
此差异已折叠。
点击以展开。
storage/storagefileiojstest/src/main/js/default/test/FileIO.test.js
浏览文件 @
ba794f6c
...
@@ -14,8 +14,6 @@
...
@@ -14,8 +14,6 @@
*/
*/
import
fileio
from
'
@ohos.fileio
'
;
import
fileio
from
'
@ohos.fileio
'
;
import
file
from
'
@system.file
'
;
import
bundle_mgr
from
'
@ohos.bundle_mgr
'
import
{
import
{
describe
,
describe
,
beforeAll
,
beforeAll
,
...
@@ -1592,41 +1590,6 @@ describe('fileIOTest', function () {
...
@@ -1592,41 +1590,6 @@ describe('fileIOTest', function () {
}
}
});
});
/**
* @tc.number SUB_STORAGE_FileIO_ReadSync_0000
* @tc.name fileio_test_read_sync_000
* @tc.desc Function of API, readSync.
*/
it
(
'
fileio_test_read_sync_000
'
,
0
,
async
function
(
done
)
{
let
fpath
=
nextFileName
(
'
fileio_test_read_sync_000
'
);
let
text
=
'
0123456789abcdefg
'
;
expect
(
prepareFile
(
fpath
,
text
)).
assertTrue
();
sleep
(
10
)
try
{
let
fd
=
fileio
.
openSync
(
fpath
,
0o2
);
let
len
=
fileio
.
readSync
(
fd
,
new
ArrayBuffer
(
4096
));
expect
(
len
==
text
.
length
).
assertTrue
();
expect
(
fileio
.
closeSync
(
fd
)
!==
null
).
assertTrue
();
file
.
readText
({
uri
:
'
internal://cache/fileio_test_read_sync_000
'
,
success
:
function
(
data
)
{
console
.
log
(
'
call readText success:
'
+
data
.
text
);
expect
(
text
==
data
.
text
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
!==
null
).
assertTrue
();
done
();
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
'
call fail callback fail, code:
'
+
code
+
'
, data:
'
+
data
);
expect
(
null
).
assertFail
();
},
});
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_read_sync_000 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
}
});
/**
/**
* @tc.number SUB_STORAGE_FileIO_ReadSync_0100
* @tc.number SUB_STORAGE_FileIO_ReadSync_0100
* @tc.name fileio_test_read_sync_001
* @tc.name fileio_test_read_sync_001
...
...
storage/storagefileiojstest/src/main/js/default/test/FileIODirent.test.js
浏览文件 @
ba794f6c
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
* limitations under the License.
* limitations under the License.
*/
*/
import
fileio
from
'
@
system
.fileio
'
;
import
fileio
from
'
@
ohos
.fileio
'
;
import
{
import
{
describe
,
describe
,
it
,
it
,
...
...
storage/storagefileiojstest/src/main/js/default/test/FileIOStream.test.js
浏览文件 @
ba794f6c
...
@@ -14,7 +14,6 @@
...
@@ -14,7 +14,6 @@
*/
*/
import
fileio
from
'
@ohos.fileio
'
;
import
fileio
from
'
@ohos.fileio
'
;
import
file
from
'
@system.file
'
import
{
import
{
describe
,
describe
,
beforeAll
,
beforeAll
,
...
@@ -713,7 +712,9 @@ describe('fileIOTestStream', function () {
...
@@ -713,7 +712,9 @@ describe('fileIOTestStream', function () {
*/
*/
it
(
'
fileio_test_stream_fdopen_stream_sync_001
'
,
0
,
function
()
{
it
(
'
fileio_test_stream_fdopen_stream_sync_001
'
,
0
,
function
()
{
try
{
try
{
expect
(
fileio
.
fdopenStreamSync
(
-
1
,
'
r
'
)
==
null
).
assertTrue
();
let
fd
=
-
1
;
let
mode
=
'
r+
'
;
fileio
.
fdopenStreamSync
(
fd
,
mode
);
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
catch
(
e
)
{
catch
(
e
)
{
...
@@ -1278,7 +1279,7 @@ describe('fileIOTestStream', function () {
...
@@ -1278,7 +1279,7 @@ describe('fileIOTestStream', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
try
{
let
fd
=
fileio
.
openSync
(
fpath
,
0o2
);
let
fd
=
fileio
.
openSync
(
fpath
,
0o2
);
expect
(
fileio
.
fdopenStreamSync
(
fd
,
''
)
==
null
).
assertTrue
();
fileio
.
fdopenStreamSync
(
fd
,
''
)
expect
(
null
).
assertFail
();
expect
(
null
).
assertFail
();
}
}
catch
(
e
)
{
catch
(
e
)
{
...
...
storage/storagefileiojstest/src/main/js/default/test/List.test.js
浏览文件 @
ba794f6c
...
@@ -13,7 +13,6 @@
...
@@ -13,7 +13,6 @@
* limitations under the License.
* limitations under the License.
*/
*/
require
(
'
./File.test.js
'
)
require
(
'
./FileIO.test.js
'
)
require
(
'
./FileIO.test.js
'
)
require
(
'
./FileIODir.test.js
'
)
require
(
'
./FileIODir.test.js
'
)
require
(
'
./FileIODirent.test.js
'
)
require
(
'
./FileIODirent.test.js
'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录