Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
1e7958a2
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看板
提交
1e7958a2
编写于
1月 14, 2022
作者:
S
Storage sandboxing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改fileio测试套报错,file代码和黄区同步
Signed-off-by:
N
Storage sandboxing
<
raoxian@huawei.com
>
上级
a0a2e479
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
33 addition
and
77 deletion
+33
-77
storage/storagefileiojstest/Test.json
storage/storagefileiojstest/Test.json
+1
-1
storage/storagefileiojstest/src/main/js/default/test/FileIO.test.js
...oragefileiojstest/src/main/js/default/test/FileIO.test.js
+3
-6
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/read.test.js
...c/main/js/default/test/module_fileio/members/read.test.js
+2
-1
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/readtext.test.js
...in/js/default/test/module_fileio/members/readtext.test.js
+2
-3
storage/storagefilejstest/Test.json
storage/storagefilejstest/Test.json
+1
-1
storage/storagefilejstest/src/main/js/default/test/Common.js
storage/storagefilejstest/src/main/js/default/test/Common.js
+7
-46
storage/storagefilejstest/src/main/js/default/test/File.test.js
...e/storagefilejstest/src/main/js/default/test/File.test.js
+17
-19
未找到文件。
storage/storagefileiojstest/Test.json
浏览文件 @
1e7958a2
...
...
@@ -2,7 +2,7 @@
"description"
:
"Configuration for storage file and fileio Tests"
,
"driver"
:
{
"type"
:
"JSUnitTest"
,
"test-timeout"
:
"
6
00000"
,
"test-timeout"
:
"
30
00000"
,
"package"
:
"ohos.acts.storage.fileio"
,
"shell-timeout"
:
"60000"
},
...
...
storage/storagefileiojstest/src/main/js/default/test/FileIO.test.js
浏览文件 @
1e7958a2
...
...
@@ -3745,12 +3745,11 @@ describe('fileIOTest', function () {
let
fpath
=
await
nextFileName
(
'
fileio_test_fchown_sync_006
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
stat
=
fileio
.
statSync
(
fpath
);
let
UID
=
stat
.
uid
let
GID
=
null
let
UID
=
stat
.
uid
;
let
fd
;
try
{
fd
=
fileio
.
openSync
(
fpath
);
expect
(
fileio
.
fchownSync
(
fd
,
UID
,
GID
)
);
fileio
.
fchownSync
(
fd
,
UID
,
0
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
...
...
@@ -3769,11 +3768,9 @@ describe('fileIOTest', function () {
let
fpath
=
await
nextFileName
(
'
fileio_test_fchown_sync_007
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
let
fd
;
let
UID
=
null
let
GID
=
null
try
{
fd
=
fileio
.
openSync
(
fpath
,
0o2
);
expect
(
fileio
.
fchownSync
(
fd
,
UID
,
GID
)
);
fileio
.
fchownSync
(
fd
,
0
,
0
);
expect
(
null
).
assertFail
();
}
catch
(
e
)
{
...
...
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/read.test.js
浏览文件 @
1e7958a2
...
...
@@ -447,7 +447,7 @@ describe('fileio_read', function () {
*/
it
(
'
fileio_test_read_async_006
'
,
0
,
async
function
(
done
)
{
let
fd
;
const
invalidOffset
=
999
99
;
const
invalidOffset
=
999
;
let
fpath
=
await
nextFileName
(
'
fileio_test_read_async_006
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
...
...
@@ -458,6 +458,7 @@ describe('fileio_read', function () {
offset
:
invalidOffset
,
});
expect
(
null
).
assertFail
();
done
();
}
catch
(
e
)
{
expect
(
fileio
.
closeSync
(
fd
)
==
null
).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
();
...
...
storage/storagefileiojstest/src/main/js/default/test/module_fileio/members/readtext.test.js
浏览文件 @
1e7958a2
...
...
@@ -59,8 +59,7 @@ describe('fileio_readtext', function () {
try
{
let
str
=
fileio
.
readTextSync
(
fpath
,
{
position
:
pos
});
console
.
log
(
str
);
expect
(
str
==
FILE_CONTENT
.
substr
(
pos
,
FILE_CONTENT
.
length
)).
assertTrue
();
expect
(
str
==
FILE_CONTENT
.
substring
(
pos
,
FILE_CONTENT
.
length
+
1
)).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_readtext_sync_001 has failed for
'
+
e
);
...
...
@@ -85,7 +84,7 @@ describe('fileio_readtext', function () {
try
{
let
str
=
fileio
.
readTextSync
(
fpath
,
{
position
:
pos
,
length
:
len
});
expect
(
str
==
FILE_CONTENT
.
substr
(
pos
,
len
)).
assertTrue
();
expect
(
str
==
FILE_CONTENT
.
substr
ing
(
pos
,
len
+
1
)).
assertTrue
();
expect
(
fileio
.
unlinkSync
(
fpath
)
==
null
).
assertTrue
();
}
catch
(
e
)
{
console
.
log
(
'
fileio_test_readtext_sync_002 has failed for
'
+
e
);
...
...
storage/storagefilejstest/Test.json
浏览文件 @
1e7958a2
...
...
@@ -2,7 +2,7 @@
"description"
:
"Configuration for storage file Tests"
,
"driver"
:
{
"type"
:
"JSUnitTest"
,
"test-timeout"
:
"60000"
,
"test-timeout"
:
"60000
0
"
,
"package"
:
"ohos.acts.storage.file"
,
"shell-timeout"
:
"60000"
},
...
...
storage/storagefilejstest/src/main/js/default/test/Common.js
浏览文件 @
1e7958a2
...
...
@@ -14,7 +14,7 @@
*/
import
fileio
from
'
@ohos.fileio
'
;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
export
const
FILE_CONTENT
=
'
hello world
'
;
...
...
@@ -31,7 +31,7 @@ export function prepareFile(fpath, content) {
fileio
.
fsyncSync
(
fd
)
fileio
.
closeSync
(
fd
)
return
true
}
}
catch
(
e
)
{
console
.
log
(
'
Failed to prepareFile for
'
+
e
)
return
false
...
...
@@ -48,46 +48,21 @@ export function prepareEmptyFile(fpath) {
return
false
}
}
export
function
fileToReadOnly
(
fpath
)
{
try
{
let
fd
=
fileio
.
openSync
(
fpath
,
0o1
)
fileio
.
fchmodSync
(
fd
,
0o444
)
fileio
.
fsyncSync
(
fd
)
fileio
.
closeSync
(
fd
)
return
true
}
catch
(
e
)
{
console
.
log
(
'
Failed to fileToReadOnly for
'
+
e
);
return
false
}
}
export
function
fileToWriteOnly
(
fpath
)
{
try
{
let
fd
=
fileio
.
openSync
(
fpath
,
0o2
)
fileio
.
fchmodSync
(
fd
,
0o222
)
fileio
.
fsyncSync
(
fd
)
fileio
.
closeSync
(
fd
)
return
true
}
catch
(
e
)
{
console
.
log
(
'
Failed to fileToWriteOnly
'
+
e
)
return
false
}
}
export
async
function
nextFileName
(
testName
)
{
let
context
=
featureAbility
.
getContext
();
var
context
=
featureAbility
.
getContext
();
let
data
=
await
context
.
getFilesDir
();
let
BASE_PATH
=
data
.
substring
(
0
,
data
.
length
-
5
)
+
'
cache/
'
;
return
BASE_PATH
+
testName
}
export
async
function
fileName
(
testName
)
{
let
context
=
featureAbility
.
getContext
();
var
context
=
featureAbility
.
getContext
();
let
data
=
await
context
.
getFilesDir
();
let
BASE_PATH
=
data
+
'
/
'
;
return
BASE_PATH
+
testName
}
export
async
function
cacheFileName
(
testName
)
{
let
context
=
featureAbility
.
getContext
();
var
context
=
featureAbility
.
getContext
();
let
data
=
await
context
.
getFilesDir
();
let
BASE_PATH
=
data
+
'
/cache/
'
;
return
BASE_PATH
+
testName
...
...
@@ -101,6 +76,7 @@ export function sleep(n) {
}
}
}
export
function
randomString
(
num
)
{
let
len
=
num
;
var
$chars
=
'
aaaabbbbcccc
'
;
...
...
@@ -112,23 +88,8 @@ export function randomString(num) {
return
pwd
;
}
function
isIntNum
(
val
)
{
return
typeof
val
===
'
number
'
&&
val
%
1
===
0
;
}
function
isString
(
str
)
{
return
(
typeof
str
==
'
string
'
)
&&
str
.
constructor
==
String
;
}
function
isBoolean
(
val
)
{
return
typeof
val
==
'
boolean
'
;
}
export
{
fileio
,
isIntNum
,
isString
,
isBoolean
,
describe
,
beforeAll
,
beforeEach
,
...
...
storage/storagefilejstest/src/main/js/default/test/File.test.js
浏览文件 @
1e7958a2
...
...
@@ -24,7 +24,7 @@ import {
it
,
expect
}
from
'
deccjsunit/index
'
from
'
deccjsunit/index
'
import
{
FILE_CONTENT
,
prepareFile
,
...
...
@@ -35,7 +35,7 @@ import {
nextFileName
,
sleep
}
from
'
./Common
'
from
'
./Common
'
describe
(
'
fileTest
'
,
function
()
{
...
...
@@ -1006,18 +1006,18 @@ describe('fileTest', function () {
*/
it
(
'
File_writeArrayBuffer_009
'
,
0
,
async
function
(
done
)
{
let
buf
=
new
Uint8Array
([
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
]);
file
.
writeArrayBuffer
({
uri
:
'
internal://cache/File_writeArrayBuffer_009
'
,
buffer
:
buf
,
success
:
function
()
{
console
.
log
(
'
File_writeArrayBuffer_009 call success
'
);
done
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
'
File_writeArrayBuffer_009 fail
'
);
expect
(
null
).
assertFail
();
},
});
file
.
writeArrayBuffer
({
uri
:
'
internal://cache/File_writeArrayBuffer_009
'
,
buffer
:
buf
,
success
:
function
()
{
console
.
log
(
'
File_writeArrayBuffer_009 call success
'
);
done
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
'
File_writeArrayBuffer_009 fail
'
);
expect
(
null
).
assertFail
();
},
});
file
.
readArrayBuffer
({
uri
:
'
internal://cache/File_writeArrayBuffer_009
'
,
success
:
function
(
data
)
{
...
...
@@ -1318,9 +1318,7 @@ describe('fileTest', function () {
done
();
},
fail
:
function
(
data
,
code
)
{
console
.
error
(
"
call fail callback fail, code:
"
+
code
+
"
, data:
"
+
data
);
console
.
error
(
"
call fail callback fail, code:
"
+
code
+
"
, data:
"
+
data
);
expect
(
null
).
assertFail
();
},
});
...
...
@@ -2823,7 +2821,7 @@ describe('fileTest', function () {
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
'
File_Copy_005 , code:
'
+
code
+
'
, data:
'
+
data
);
expect
(
code
==
30
1
).
assertTrue
();
expect
(
code
==
30
0
).
assertTrue
();
done
();
},
});
...
...
@@ -3332,7 +3330,7 @@ describe('fileTest', function () {
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)
!==
null
).
assertTrue
();
expect
(
prepareFile
(
ffpath
,
FILE_CONTENT
)
!==
null
).
assertTrue
();
expect
(
prepareFile
(
fffpath
,
FILE_CONTENT
)
!==
null
).
assertTrue
();
}
}
catch
(
e
)
{
console
.
log
(
'
File_List_010 has failed for
'
+
e
);
expect
(
null
).
assertFail
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录