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