Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
b7738f91
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看板
提交
b7738f91
编写于
6月 10, 2022
作者:
R
raoxian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update storage sandbox path
Signed-off-by:
N
raoxian
<
raoxian@huawei.com
>
上级
3cc42ce3
变更
6
展开全部
显示空白变更内容
内联
并排
Showing
6 changed file
with
233 addition
and
164 deletion
+233
-164
storage/storagefileioerrorjstest/src/main/js/default/test/Common.js
...oragefileioerrorjstest/src/main/js/default/test/Common.js
+9
-4
storage/storagefileioerrorjstest/src/main/js/default/test/FileIOError.test.js
...oerrorjstest/src/main/js/default/test/FileIOError.test.js
+55
-44
storage/storagefileiojstest/src/main/js/default/test/Common.js
...ge/storagefileiojstest/src/main/js/default/test/Common.js
+3
-7
storage/storagefileiojstest/src/main/js/default/test/FileIOStream.test.js
...ileiojstest/src/main/js/default/test/FileIOStream.test.js
+163
-98
storage/storagefilejstest/src/main/js/default/test/Common.js
storage/storagefilejstest/src/main/js/default/test/Common.js
+3
-7
storage/storagefilejstest/src/main/js/default/test/File.test.js
...e/storagefilejstest/src/main/js/default/test/File.test.js
+0
-4
未找到文件。
storage/storagefileioerrorjstest/src/main/js/default/test/Common.js
浏览文件 @
b7738f91
...
...
@@ -14,6 +14,7 @@
*/
import
fileio
from
'
@ohos.fileio
'
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
export
const
FILE_CONTENT
=
'
hello world
'
...
...
@@ -32,12 +33,16 @@ export function prepareFile(fpath, content) {
}
}
export
function
nextFileName
(
testName
)
{
const
BASE_PATH
=
'
/data/storage/el2/base/haps/entry/cache/
'
export
async
function
nextFileName
(
testName
)
{
let
context
=
featureAbility
.
getContext
();
let
data
=
await
context
.
getCacheDir
();
let
BASE_PATH
=
data
+
'
/
'
;
return
BASE_PATH
+
testName
}
export
function
fileName
(
testName
)
{
const
BASE_PATH
=
'
/data/storage/el2/base/haps/entry/files/
'
export
async
function
fileName
(
testName
)
{
let
context
=
featureAbility
.
getContext
();
let
data
=
await
context
.
getFilesDir
();
let
BASE_PATH
=
data
+
'
/
'
;
return
BASE_PATH
+
testName
}
...
...
storage/storagefileioerrorjstest/src/main/js/default/test/FileIOError.test.js
浏览文件 @
b7738f91
...
...
@@ -38,8 +38,8 @@ describe('FileIOError', function () {
* @tc.name fileio_test_error_000
* @tc.desc Function of API, Delete directories with files
*/
it
(
'
fileio_test_error_000
'
,
0
,
function
(
)
{
let
dpath
=
fileName
(
'
fileio_test_error_000d
'
);
it
(
'
fileio_test_error_000
'
,
0
,
async
function
(
done
)
{
let
dpath
=
await
fileName
(
'
fileio_test_error_000d
'
);
let
fpath
=
dpath
+
'
/fileio_test_error_000f
'
;
fileio
.
mkdirSync
(
dpath
);
expect
(
prepareFile
(
fpath
,
'
hello
'
)).
assertTrue
();
...
...
@@ -49,10 +49,11 @@ describe('FileIOError', function () {
fileio
.
rmdirSync
(
dpath
);
}
catch
(
err
)
{
console
.
log
(
'
fileio_test_error_000 has failed for
'
+
err
);
console
.
info
(
'
fileio_test_error_000 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
Directory not empty
'
)).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
fileio
.
rmdirSync
(
dpath
);
done
();
}
});
...
...
@@ -61,8 +62,8 @@ describe('FileIOError', function () {
* @tc.name fileio_test_error_001
* @tc.desc Function of API, delete file
*/
it
(
'
fileio_test_error_001
'
,
0
,
function
(
)
{
let
fpath
=
fileName
(
'
fileio_test_error_001f
'
);
it
(
'
fileio_test_error_001
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
fileName
(
'
fileio_test_error_001f
'
);
expect
(
prepareFile
(
fpath
,
'
hello
'
)).
assertTrue
();
try
{
let
fd
=
fileio
.
openSync
(
fpath
);
...
...
@@ -71,9 +72,10 @@ describe('FileIOError', function () {
expect
(
null
).
assertFail
();
}
catch
(
err
)
{
console
.
log
(
'
fileio_test_error_001 has failed for
'
+
err
);
console
.
info
(
'
fileio_test_error_001 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
Not a directory
'
)).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
...
...
@@ -82,17 +84,18 @@ describe('FileIOError', function () {
* @tc.name fileio_test_error_002
* @tc.desc Function of API, flags=0o102. missing mode parameter.
*/
it
(
'
fileio_test_error_002
'
,
0
,
function
(
)
{
let
fpath
=
nextFileName
(
'
fileio_test_error_002
'
);
it
(
'
fileio_test_error_002
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_error_002
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
openSync
(
fpath
,
0o102
);
expect
(
null
).
assertFail
();
}
catch
(
err
)
{
console
.
log
(
'
fileio_test_error_002 has failed for
'
+
err
);
console
.
info
(
'
fileio_test_error_002 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
called with O_CREAT/O_TMPFILE but no mode
'
)).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
...
...
@@ -101,15 +104,16 @@ describe('FileIOError', function () {
* @tc.name fileio_test_error_003
* @tc.desc Function of API, flags=0o102, missing mode parameter.
*/
it
(
'
fileio_test_error_003
'
,
0
,
function
(
)
{
let
fpath
=
nextFileName
(
'
fileio_test_error_003
'
);
it
(
'
fileio_test_error_003
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_error_003
'
);
try
{
fileio
.
openSync
(
fpath
,
0o102
);
expect
(
null
).
assertFail
();
}
catch
(
err
)
{
console
.
log
(
'
fileio_test_error_003 has failed for
'
+
err
);
console
.
info
(
'
fileio_test_error_003 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
called with O_CREAT/O_TMPFILE but no mode
'
)).
assertTrue
();
done
();
}
});
...
...
@@ -118,16 +122,17 @@ describe('FileIOError', function () {
* @tc.name fileio_test_error_004
* @tc.desc Function of API, flags=0o302. The test file is exist.
*/
it
(
'
fileio_test_error_004
'
,
0
,
function
(
)
{
let
fpath
=
nextFileName
(
'
fileio_test_error_004
'
);
it
(
'
fileio_test_error_004
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_error_004
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
openSync
(
fpath
,
0o302
,
0o666
);
}
catch
(
err
)
{
console
.
log
(
'
fileio_test_error_004 has failed for
'
+
err
);
console
.
info
(
'
fileio_test_error_004 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
File exists
'
)).
assertTrue
();
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
...
...
@@ -136,16 +141,17 @@ describe('FileIOError', function () {
* @tc.name fileio_test_error_005
* @tc.desc Function of API, flags=0o100002. The test file is exist.
*/
it
(
'
fileio_test_error_005
'
,
0
,
function
(
)
{
let
fpath
=
nextFileName
(
'
fileio_test_error_005
'
);
it
(
'
fileio_test_error_005
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_error_005
'
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileio
.
openSync
(
fpath
,
0o100002
);
expect
(
null
).
assertFail
();
}
catch
(
err
)
{
console
.
log
(
'
fileio_test_error_005 has failed for
'
+
err
);
console
.
info
(
'
fileio_test_error_005 has failed for
'
+
err
);
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
...
...
@@ -154,17 +160,18 @@ describe('FileIOError', function () {
* @tc.name fileio_test_error_006
* @tc.desc Function of API, flags=0o40002 The test file is exist.
*/
it
(
'
fileio_test_error_006
'
,
0
,
function
(
)
{
let
dpath
=
nextFileName
(
'
fileio_test_error_006
'
);
it
(
'
fileio_test_error_006
'
,
0
,
async
function
(
done
)
{
let
dpath
=
await
nextFileName
(
'
fileio_test_error_006
'
);
fileio
.
mkdirSync
(
dpath
);
try
{
fileio
.
openSync
(
dpath
,
0o40002
);
expect
(
null
).
assertFail
();
}
catch
(
err
)
{
console
.
log
(
'
fileio_test_error_006 has failed for
'
+
err
);
console
.
info
(
'
fileio_test_error_006 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
called with O_CREAT/O_TMPFILE but no mode
'
)).
assertTrue
();
fileio
.
rmdirSync
(
dpath
);
done
();
}
});
...
...
@@ -173,8 +180,8 @@ describe('FileIOError', function () {
* @tc.name fileio_test_error_007
* @tc.desc Function of API, flags=0o400002. The test file is exist.
*/
it
(
'
fileio_test_error_007
'
,
0
,
function
(
)
{
let
fpath
=
nextFileName
(
'
fileio_test_error_007
'
);
it
(
'
fileio_test_error_007
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_error_007
'
);
let
txt
=
'
h
'
expect
(
prepareFile
(
fpath
,
txt
)).
assertTrue
();
try
{
...
...
@@ -182,8 +189,9 @@ describe('FileIOError', function () {
expect
(
null
).
assertFail
();
}
catch
(
err
)
{
console
.
log
(
'
fileio_test_error_007 has failed for
'
+
err
);
console
.
info
(
'
fileio_test_error_007 has failed for
'
+
err
);
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
...
...
@@ -192,8 +200,8 @@ describe('FileIOError', function () {
* @tc.name fileio_test_error_008
* @tc.desc Function of API, flags=0o400002. The test file is exist.
*/
it
(
'
fileio_test_error_008
'
,
0
,
function
(
)
{
let
fpath
=
nextFileName
(
'
fileio_test_error_008
'
);
it
(
'
fileio_test_error_008
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_error_008
'
);
let
txt
=
randomString
(
5000
);
expect
(
prepareFile
(
fpath
,
txt
)).
assertTrue
();
try
{
...
...
@@ -201,8 +209,9 @@ describe('FileIOError', function () {
expect
(
null
).
assertFail
();
}
catch
(
err
)
{
console
.
log
(
'
fileio_test_error_008 has failed for
'
+
err
);
console
.
info
(
'
fileio_test_error_008 has failed for
'
+
err
);
fileio
.
unlinkSync
(
fpath
);
done
();
}
});
...
...
@@ -211,15 +220,16 @@ describe('FileIOError', function () {
* @tc.name fileio_test_error_009
* @tc.desc Function of API, flags=0o10000102. The test file is exist.
*/
it
(
'
fileio_test_error_009
'
,
0
,
function
(
)
{
let
fpath
=
nextFileName
(
'
fileio_test_error_009
'
);
it
(
'
fileio_test_error_009
'
,
0
,
async
function
(
done
)
{
let
fpath
=
await
nextFileName
(
'
fileio_test_error_009
'
);
try
{
fileio
.
openSync
(
fpath
,
0o10000102
);
expect
(
null
).
assertFail
();
}
catch
(
err
)
{
console
.
log
(
'
fileio_test_error_009 has failed for
'
+
err
);
console
.
info
(
'
fileio_test_error_009 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
called with O_CREAT/O_TMPFILE but no mode
'
)).
assertTrue
();
done
();
}
});
...
...
@@ -228,17 +238,18 @@ describe('FileIOError', function () {
* @tc.name fileio_test_error_010
* @tc.desc Function of API, flags=0o200000. Invalid argument.
*/
it
(
'
fileio_test_error_010
'
,
0
,
function
(
)
{
let
dpath
=
fileName
(
'
fileio_test_error_010d
'
);
it
(
'
fileio_test_error_010
'
,
0
,
async
function
(
done
)
{
let
dpath
=
await
fileName
(
'
fileio_test_error_010d
'
);
fileio
.
mkdirSync
(
dpath
);
try
{
fileio
.
openSync
(
dpath
,
0o200000
);
expect
(
null
).
assertFail
();
}
catch
(
err
)
{
console
.
log
(
'
fileio_test_error_010 has failed for
'
+
err
);
console
.
info
(
'
fileio_test_error_010 has failed for
'
+
err
);
expect
(
isInclude
(
err
.
message
,
'
Invalid argument
'
)).
assertTrue
();
fileio
.
rmdirSync
(
dpath
);
done
();
}
});
...
...
storage/storagefileiojstest/src/main/js/default/test/Common.js
浏览文件 @
b7738f91
...
...
@@ -19,7 +19,7 @@ import featureAbility from '@ohos.ability.featureAbility';
export
const
FILE_CONTENT
=
'
hello world
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
describe
,
it
,
expect
}
from
'
deccjsunit/index
'
...
...
@@ -77,8 +77,8 @@ export function fileToWriteOnly(fpath) {
export
async
function
nextFileName
(
testName
)
{
let
context
=
featureAbility
.
getContext
();
let
data
=
await
context
.
get
Files
Dir
();
let
BASE_PATH
=
data
.
substring
(
0
,
data
.
length
-
5
)
+
'
cache
/
'
;
let
data
=
await
context
.
get
Cache
Dir
();
let
BASE_PATH
=
data
+
'
/
'
;
return
BASE_PATH
+
testName
+
'
_
'
+
randomString
(
testName
.
length
);
}
export
async
function
fileName
(
testName
)
{
...
...
@@ -126,10 +126,6 @@ export {
isString
,
isBoolean
,
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
};
\ No newline at end of file
storage/storagefileiojstest/src/main/js/default/test/FileIOStream.test.js
浏览文件 @
b7738f91
此差异已折叠。
点击以展开。
storage/storagefilejstest/src/main/js/default/test/Common.js
浏览文件 @
b7738f91
...
...
@@ -19,7 +19,7 @@ import featureAbility from '@ohos.ability.featureAbility'
export
const
FILE_CONTENT
=
'
hello world
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
describe
,
it
,
expect
}
from
'
deccjsunit/index
'
...
...
@@ -51,8 +51,8 @@ export function prepareEmptyFile(fpath) {
export
async
function
nextFileName
(
testName
)
{
var
context
=
featureAbility
.
getContext
();
let
data
=
await
context
.
get
Files
Dir
();
let
BASE_PATH
=
data
.
substring
(
0
,
data
.
length
-
5
)
+
'
cache
/
'
;
let
data
=
await
context
.
get
Cache
Dir
();
let
BASE_PATH
=
data
+
'
/
'
;
return
BASE_PATH
+
testName
}
export
async
function
fileName
(
testName
)
{
...
...
@@ -91,10 +91,6 @@ export function randomString(num) {
export
{
fileio
,
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
};
\ No newline at end of file
storage/storagefilejstest/src/main/js/default/test/File.test.js
浏览文件 @
b7738f91
...
...
@@ -17,10 +17,6 @@ import fileio from '@ohos.fileio';
import
file
from
'
@system.file
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录