Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
3f3b45c9
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看板
未验证
提交
3f3b45c9
编写于
9月 01, 2023
作者:
O
openharmony_ci
提交者:
Gitee
9月 01, 2023
浏览文件
操作
浏览文件
下载
差异文件
!9868 Supplemental XTS testcases for synchronous interfaces.
Merge pull request !9868 from 冯俊青/copyDirSync
上级
5342630b
081cb86c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
1051 addition
and
25 deletion
+1051
-25
storage/storagefileiov9jstest/src/main/js/test/members/copyDir.test.js
...gefileiov9jstest/src/main/js/test/members/copyDir.test.js
+362
-12
storage/storagefileiov9jstest/src/main/js/test/members/moveDir.test.js
...gefileiov9jstest/src/main/js/test/members/moveDir.test.js
+487
-9
storage/storagestatfsjstest/src/main/js/test/statvfs.test.js
storage/storagestatfsjstest/src/main/js/test/statvfs.test.js
+202
-4
未找到文件。
storage/storagefileiov9jstest/src/main/js/test/members/copyDir.test.js
浏览文件 @
3f3b45c9
...
...
@@ -15,7 +15,7 @@
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
{
fileIO
,
FILE_CONTENT
,
prepareFile
,
describe
,
it
,
expect
,
randomString
fileIO
,
FILE_CONTENT
,
prepareFile
,
describe
,
it
,
expect
,
randomString
,
nextFileName
}
from
'
../Common
'
;
export
default
function
fileIOCopyDir
()
{
...
...
@@ -74,11 +74,361 @@ export default function fileIOCopyDir() {
}
}
/**
* @tc.number SUB_DF_FILEIO_COPYDIR_SYNC_0000
* @tc.name fileIO_test_copyDir_sync_000
* @tc.desc Test copyDirSync() interface.
* There is no target folder(src) under path dest. Mode is DIRMODE_FILE_COPY_REPLACE.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_copyDir_sync_000
'
,
3
,
async
function
()
{
let
dpath
=
await
featureAbility
.
getContext
().
getFilesDir
()
+
'
/fileIO_test_copyDir_sync_000
'
;
let
ddpath
=
dpath
+
'
/srcDir_first
'
;
let
ffpath
=
ddpath
+
'
/srcFile_first_01
'
;
let
ffpath2
=
ddpath
+
'
/srcFile_first_02
'
;
let
dddpath
=
ddpath
+
'
/srcDir_second
'
;
let
fffpath
=
dddpath
+
'
/srcFile_second_01
'
;
let
ddpath2
=
dpath
+
'
/destDir_first
'
;
let
ffpath3
=
ddpath2
+
'
/destFile_first_01
'
;
fileIO
.
mkdirSync
(
dpath
);
fileIO
.
mkdirSync
(
ddpath
);
fileIO
.
mkdirSync
(
ddpath2
);
fileIO
.
mkdirSync
(
dddpath
);
expect
(
prepareFile
(
ffpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
prepareFile
(
ffpath2
,
FILE_CONTENT
)).
assertTrue
();
expect
(
prepareFile
(
ffpath3
,
FILE_CONTENT
)).
assertTrue
();
expect
(
prepareFile
(
fffpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileIO
.
copyDirSync
(
ddpath
,
ddpath2
,
DIRMODE_FILE_COPY_REPLACE
);
let
stat1
=
fileIO
.
statSync
(
ddpath2
+
'
/srcDir_first/srcFile_first_02
'
);
expect
(
stat1
.
size
==
FILE_CONTENT
.
length
).
assertTrue
();
let
stat2
=
fileIO
.
statSync
(
ddpath2
+
'
/srcDir_first/srcFile_first_01
'
);
expect
(
stat2
.
size
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
fileIO
.
accessSync
(
ddpath
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
ddpath2
+
'
/srcDir_first/srcDir_second
'
)).
assertTrue
();
let
stat3
=
fileIO
.
statSync
(
ddpath2
+
'
/srcDir_first/srcDir_second/srcFile_second_01
'
);
expect
(
stat3
.
size
==
FILE_CONTENT
.
length
).
assertTrue
();
fileIO
.
rmdirSync
(
dpath
);
}
catch
(
err
)
{
console
.
log
(
'
fileIO_test_copyDir_sync_000 has failed for
'
+
err
.
message
+
'
, code:
'
+
err
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPYDIR_SYNC_0100
* @tc.name fileIO_test_copyDir_sync_001
* @tc.desc Test copyDirSync() interface.
* There is a file with a different name from the source folder in the target folder. Mode is DIRMODE_FILE_COPY_REPLACE.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_copyDir_sync_001
'
,
3
,
async
function
()
{
let
dpath
=
await
featureAbility
.
getContext
().
getFilesDir
()
+
'
/fileIO_test_copyDir_sync_001
'
;
let
ddpath
=
dpath
+
'
/srcDir_first
'
;
let
ffpath
=
ddpath
+
'
/srcFile_first_01
'
;
let
ffpath2
=
ddpath
+
'
/srcFile_first_02
'
;
let
dddpath
=
ddpath
+
'
/srcDir_second
'
;
let
fffpath
=
dddpath
+
'
/srcFile_second_01
'
;
let
ddpath2
=
dpath
+
'
/destDir_first
'
;
let
ffpath3
=
ddpath2
+
'
/destFile_first_01
'
;
let
dddpath2
=
ddpath2
+
'
/srcDir_first
'
;
let
fffpath2
=
dddpath2
+
'
/destFile_second_01
'
;
fileIO
.
mkdirSync
(
dpath
);
fileIO
.
mkdirSync
(
ddpath
);
fileIO
.
mkdirSync
(
ddpath2
);
fileIO
.
mkdirSync
(
dddpath
);
fileIO
.
mkdirSync
(
dddpath2
);
expect
(
prepareFile
(
ffpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
prepareFile
(
ffpath2
,
FILE_CONTENT
)).
assertTrue
();
expect
(
prepareFile
(
ffpath3
,
FILE_CONTENT
)).
assertTrue
();
expect
(
prepareFile
(
fffpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
prepareFile
(
fffpath2
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileIO
.
copyDirSync
(
ddpath
,
ddpath2
,
DIRMODE_FILE_COPY_REPLACE
);
let
stat1
=
fileIO
.
statSync
(
ddpath2
+
'
/srcDir_first/srcFile_first_02
'
);
expect
(
stat1
.
size
==
FILE_CONTENT
.
length
).
assertTrue
();
let
stat2
=
fileIO
.
statSync
(
ddpath2
+
'
/srcDir_first/srcFile_first_01
'
);
expect
(
stat2
.
size
==
FILE_CONTENT
.
length
).
assertTrue
();
expect
(
fileIO
.
accessSync
(
ddpath
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
ddpath2
+
'
/srcDir_first/srcDir_second
'
)).
assertTrue
();
let
stat3
=
fileIO
.
statSync
(
ddpath2
+
'
/srcDir_first/srcDir_second/srcFile_second_01
'
);
expect
(
stat3
.
size
==
FILE_CONTENT
.
length
).
assertTrue
();
let
stat4
=
fileIO
.
statSync
(
ddpath2
+
'
/srcDir_first/destFile_second_01
'
);
expect
(
stat4
.
size
==
FILE_CONTENT
.
length
).
assertTrue
();
fileIO
.
rmdirSync
(
dpath
);
}
catch
(
err
)
{
console
.
log
(
'
fileIO_test_copyDir_sync_001 has failed for
'
+
err
.
message
+
'
, code:
'
+
err
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPYDIR_SYNC_0200
* @tc.name fileIO_test_copyDir_sync_002
* @tc.desc Test copyDirSync() interface.
* There is a file with the same name as the source folder in the target folder. Mode is DIRMODE_FILE_COPY_THROW_ERR.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileIO_test_copyDir_sync_002
'
,
0
,
async
function
()
{
let
dpath
=
await
readyFiles
(
'
fileIO_test_copyDir_sync_002
'
);
try
{
let
dirnet1
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
expect
(
dirnet1
.
length
==
4
).
assertTrue
();
fileIO
.
copyDirSync
(
dpath
.
srcDir
,
dpath
.
destDir
,
DIRMODE_FILE_COPY_THROW_ERR
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
log
(
'
fileIO_test_copyDir_sync_002 has failed for
'
+
err
.
message
+
'
, code:
'
+
err
.
code
);
expect
(
err
.
code
==
13900015
&&
err
.
message
==
'
File exists
'
).
assertTrue
();
let
dirent2
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
expect
(
dirent2
.
length
==
8
).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
srcDir
)).
assertTrue
();
let
stat1
=
fileIO
.
statSync
(
dpath
.
srcDir
+
'
/srcFile_first_01
'
);
let
stat2
=
fileIO
.
statSync
(
dpath
.
srcDir
+
'
/srcDir_first/srcFile_second_01
'
);
let
stat3
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcFile_first_01
'
);
let
stat4
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_01
'
);
expect
(
stat1
.
size
!=
stat3
.
size
&&
stat3
.
size
==
20
).
assertTrue
();
expect
(
stat2
.
size
!=
stat4
.
size
&&
stat4
.
size
==
50
).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcFile_first_02
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_02
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/destFile_second_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/destFile_third_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcDir_second/srcFile_third_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcDir_second/srcFile_third_02
'
)).
assertTrue
();
expect
(
err
.
data
.
length
==
2
).
assertTrue
();
fileIO
.
rmdirSync
(
dpath
.
baseDir
);
}
});
/**
* @tc.number SUB_DF_FILEIO_COPYDIR_SYNC_0300
* @tc.name fileIO_test_copyDir_sync_003
* @tc.desc Test copyDirSync() interface.
* There is a target folder(src) under path dest and it is not empty. Mode is DIRMODE_FILE_COPY_REPLACE.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileIO_test_copyDir_sync_003
'
,
0
,
async
function
()
{
let
dpath
=
await
readyFiles
(
'
fileIO_test_copyDir_sync_003
'
);
try
{
let
dirnet1
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
expect
(
dirnet1
.
length
==
4
).
assertTrue
();
let
stat1
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcFile_first_01
'
);
let
stat2
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_01
'
);
fileIO
.
copyDirSync
(
dpath
.
srcDir
,
dpath
.
destDir
,
DIRMODE_FILE_COPY_REPLACE
);
expect
(
fileIO
.
accessSync
(
dpath
.
srcDir
)).
assertTrue
();
let
stat3
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcFile_first_01
'
);
expect
(
stat1
.
size
!=
stat3
.
size
&&
stat3
.
size
==
10
).
assertTrue
();
let
stat4
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_01
'
);
expect
(
stat2
.
size
!=
stat4
.
size
&&
stat4
.
size
==
30
).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcFile_first_02
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_02
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/destFile_second_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/destFile_third_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcDir_second/srcFile_third_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcDir_second/srcFile_third_02
'
)).
assertTrue
();
let
dirent2
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
expect
(
dirent2
.
length
==
8
).
assertTrue
();
fileIO
.
rmdirSync
(
dpath
.
baseDir
);
}
catch
(
err
)
{
console
.
log
(
'
fileIO_test_copyDir_sync_003 has failed for
'
+
err
.
message
+
'
, code:
'
+
err
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPYDIR_SYNC_0400
* @tc.name fileIO_test_copyDir_sync_004
* @tc.desc Test copyDirSync() interface.
* Invalid mode.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_copyDir_sync_004
'
,
3
,
async
function
()
{
let
dpath
=
await
featureAbility
.
getContext
().
getFilesDir
()
+
'
/fileIO_test_copyDir_sync_004
'
;
let
ddpath1
=
dpath
+
'
/srcDir
'
;
let
ddpath2
=
dpath
+
'
/destDir
'
;
let
dddpath1
=
ddpath1
+
'
/srcDir_first
'
;
let
fpath1
=
ddpath1
+
'
/srcFile_first_01
'
;
fileIO
.
mkdirSync
(
dpath
);
fileIO
.
mkdirSync
(
ddpath1
);
fileIO
.
mkdirSync
(
ddpath2
);
fileIO
.
mkdirSync
(
dddpath1
);
expect
(
prepareFile
(
fpath1
,
randomString
(
10
))).
assertTrue
();
try
{
const
INVALIDE_MODE
=
-
1
;
fileIO
.
copyDirSync
(
ddpath1
,
ddpath2
,
INVALIDE_MODE
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
fileIO
.
rmdirSync
(
dpath
);
console
.
log
(
'
fileIO_test_copyDir_sync_004 has failed for
'
+
err
.
message
+
'
, code:
'
+
err
.
code
);
expect
(
err
.
code
==
13900020
&&
err
.
message
==
'
Invalid argument
'
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPYDIRSYNC_0500
* @tc.name fileIO_test_copyDir_sync_005
* @tc.desc Test copyDirSync() interface.
* The path point to a file, not a directory.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_copyDir_sync_005
'
,
3
,
async
function
()
{
let
dpath
=
await
nextFileName
(
'
fileIO_test_copyDir_sync_005
'
);
let
fpath
=
dpath
+
'
/file_000.txt
'
;
let
ddpath
=
dpath
+
'
/dir_000
'
;
let
ffpath
=
ddpath
+
'
/file_000.txt
'
;
fileIO
.
mkdirSync
(
dpath
);
fileIO
.
mkdirSync
(
ddpath
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileIO
.
copyDirSync
(
fpath
,
ffpath
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
fileIO
.
rmdirSync
(
dpath
);
console
.
log
(
'
fileIO_test_copyDir_sync_005 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPYDIRSYNC_0600
* @tc.name fileIO_test_copyDir_sync_006
* @tc.desc Test copyDirSync() interface.
* Invalid path. Can not move the same path.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_copyDir_sync_006
'
,
3
,
async
function
()
{
let
dpath
=
await
featureAbility
.
getContext
().
getFilesDir
()
+
'
/fileIO_test_copyDir_sync_006
'
;
let
ddpath1
=
dpath
+
'
/srcDir
'
;
let
ddpath2
=
dpath
+
'
/destDir
'
;
let
dddpath1
=
ddpath1
+
'
/srcDir_first
'
;
let
fpath1
=
ddpath1
+
'
/srcFile_first_01
'
;
fileIO
.
mkdirSync
(
dpath
);
fileIO
.
mkdirSync
(
ddpath1
);
fileIO
.
mkdirSync
(
ddpath2
);
fileIO
.
mkdirSync
(
dddpath1
);
expect
(
prepareFile
(
fpath1
,
randomString
(
10
))).
assertTrue
();
try
{
fileIO
.
copyDirSync
(
ddpath1
,
ddpath1
,
DIRMODE_FILE_COPY_THROW_ERR
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
fileIO
.
rmdirSync
(
dpath
);
console
.
log
(
'
fileIO_test_copyDir_sync_006 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPYDIRSYNC_0700
* @tc.name fileIO_test_copyDir_sync_007
* @tc.desc Test copyDirSync() interface.
* Invalid path. Can not move subPath.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_copyDir_sync_007
'
,
3
,
async
function
()
{
let
dpath
=
await
featureAbility
.
getContext
().
getFilesDir
()
+
'
/fileIO_test_copyDir_sync_007
'
;
let
ddpath1
=
dpath
+
'
/srcDir
'
;
let
dddpath1
=
ddpath1
+
'
/srcDir_first
'
;
let
fpath1
=
ddpath1
+
'
/srcFile_first_01
'
;
let
fpath2
=
ddpath1
+
'
/srcFile_first_02
'
;
let
ffpath1
=
dddpath1
+
'
/srcFile_second_01
'
;
let
ffpath2
=
dddpath1
+
'
/srcFile_second_02
'
;
fileIO
.
mkdirSync
(
dpath
);
fileIO
.
mkdirSync
(
ddpath1
);
fileIO
.
mkdirSync
(
dddpath1
);
expect
(
prepareFile
(
fpath1
,
randomString
(
10
))).
assertTrue
();
expect
(
prepareFile
(
fpath2
,
randomString
(
15
))).
assertTrue
();
expect
(
prepareFile
(
ffpath1
,
randomString
(
20
))).
assertTrue
();
expect
(
prepareFile
(
ffpath2
,
randomString
(
25
))).
assertTrue
();
try
{
fileIO
.
copyDirSync
(
ddpath1
,
dddpath1
,
DIRMODE_FILE_COPY_THROW_ERR
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
fileIO
.
rmdirSync
(
dpath
);
console
.
log
(
'
fileIO_test_copyDir_sync_007 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_COPYDIR_SYNC_1600
* @tc.name fileIO_test_copyDir_sync_008
* @tc.desc Test copyDirSync() interface.
* There is no target folder(src) under path dest. Mode is undefined.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_copyDir_sync_008
'
,
3
,
async
function
()
{
let
dpath
=
await
readyFiles
(
'
fileIO_test_copyDir_sync_008
'
);
try
{
let
dirnet1
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
expect
(
dirnet1
.
length
==
4
).
assertTrue
();
fileIO
.
copyDirSync
(
dpath
.
srcDir
,
dpath
.
destDir
,
undefined
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
console
.
log
(
'
fileIO_test_copyDir_sync_008 has failed for
'
+
err
.
message
+
'
, code:
'
+
err
.
code
);
expect
(
err
.
code
==
13900015
&&
err
.
message
==
'
File exists
'
).
assertTrue
();
let
dirent2
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
expect
(
dirent2
.
length
==
8
).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
srcDir
)).
assertTrue
();
let
stat1
=
fileIO
.
statSync
(
dpath
.
srcDir
+
'
/srcFile_first_01
'
);
let
stat2
=
fileIO
.
statSync
(
dpath
.
srcDir
+
'
/srcDir_first/srcFile_second_01
'
);
let
stat3
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcFile_first_01
'
);
let
stat4
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_01
'
);
expect
(
stat1
.
size
!=
stat3
.
size
&&
stat3
.
size
==
20
).
assertTrue
();
expect
(
stat2
.
size
!=
stat4
.
size
&&
stat4
.
size
==
50
).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcFile_first_02
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_02
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/destFile_second_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/destFile_third_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcDir_second/srcFile_third_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcDir_second/srcFile_third_02
'
)).
assertTrue
();
expect
(
err
.
data
.
length
==
2
).
assertTrue
();
fileIO
.
rmdirSync
(
dpath
.
baseDir
);
}
});
/**
* @tc.number SUB_DF_FILEIO_COPYDIR_ASYNC_0000
* @tc.name fileIO_test_copyDir_async_000
* @tc.desc Test copyDir() interface.Promise.
* There is no target folder(src) under path dest.Mode is DIRMODE_FILE_COPY_REPLACE.
* There is no target folder(src) under path dest.
Mode is DIRMODE_FILE_COPY_REPLACE.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
...
...
@@ -124,7 +474,7 @@ export default function fileIOCopyDir() {
* @tc.number SUB_DF_FILEIO_COPYDIR_ASYNC_0100
* @tc.name fileIO_test_copyDir_async_001
* @tc.desc Test copyDir() interface.Callback.
* There is no target folder(src) under path dest.Mode is DIRMODE_FILE_COPY_REPLACE.
* There is no target folder(src) under path dest.
Mode is DIRMODE_FILE_COPY_REPLACE.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
...
...
@@ -175,7 +525,7 @@ export default function fileIOCopyDir() {
* @tc.number SUB_DF_FILEIO_COPYDIR_ASYNC_0200
* @tc.name fileIO_test_copyDir_async_002
* @tc.desc Test copyDir() interface.Promise.
* There is a file with a different name from the source folder in the target folder.Mode is DIRMODE_FILE_COPY_REPLACE.
* There is a file with a different name from the source folder in the target folder.
Mode is DIRMODE_FILE_COPY_REPLACE.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
...
...
@@ -227,7 +577,7 @@ export default function fileIOCopyDir() {
* @tc.number SUB_DF_FILEIO_COPYDIR_ASYNC_0300
* @tc.name fileIO_test_copyDir_async_003
* @tc.desc Test copyDir() interface.Callback.
* There is a file with a different name from the source folder in the target folder.Mode is DIRMODE_FILE_COPY_REPLACE.
* There is a file with a different name from the source folder in the target folder.
Mode is DIRMODE_FILE_COPY_REPLACE.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
...
...
@@ -284,7 +634,7 @@ export default function fileIOCopyDir() {
* @tc.number SUB_DF_FILEIO_COPYDIR_ASYNC_0400
* @tc.name fileIO_test_copyDir_async_004
* @tc.desc Test copyDir() interface.Promise.
* There is a file with the same name as the source folder in the target folder.Mode is DIRMODE_FILE_COPY_THROW_ERR.
* There is a file with the same name as the source folder in the target folder.
Mode is DIRMODE_FILE_COPY_THROW_ERR.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -327,7 +677,7 @@ export default function fileIOCopyDir() {
* @tc.number SUB_DF_FILEIO_COPYDIR_ASYNC_0500
* @tc.name fileIO_test_copyDir_async_005
* @tc.desc Test copyDir() interface.Callback.
* There is a file with the same name as the source folder in the target folder.Mode is DIRMODE_FILE_COPY_THROW_ERR.
* There is a file with the same name as the source folder in the target folder.
Mode is DIRMODE_FILE_COPY_THROW_ERR.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -374,7 +724,7 @@ export default function fileIOCopyDir() {
* @tc.number SUB_DF_FILEIO_COPYDIR_ASYNC_0600
* @tc.name fileIO_test_copyDir_async_006
* @tc.desc Test copyDir() interface.Promise.
* There is a target folder(src) under path dest and it is not empty.Mode is DIRMODE_FILE_COPY_REPLACE.
* There is a target folder(src) under path dest and it is not empty.
Mode is DIRMODE_FILE_COPY_REPLACE.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -415,7 +765,7 @@ export default function fileIOCopyDir() {
* @tc.number SUB_DF_FILEIO_COPYDIR_ASYNC_0700
* @tc.name fileIO_test_copyDir_async_007
* @tc.desc Test copyDir() interface.Callback.
* There is a target folder(src) under path dest and it is not empty.Mode is DIRMODE_FILE_COPY_REPLACE.
* There is a target folder(src) under path dest and it is not empty.
Mode is DIRMODE_FILE_COPY_REPLACE.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -693,7 +1043,7 @@ export default function fileIOCopyDir() {
* @tc.number SUB_DF_FILEIO_COPYDIR_ASYNC_1600
* @tc.name fileIO_test_copyDir_async_016
* @tc.desc Test copyDir() interface.Promise.
* There is no target folder(src) under path dest.Mode is undefined.
* There is no target folder(src) under path dest.
Mode is undefined.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
...
...
@@ -707,7 +1057,7 @@ export default function fileIOCopyDir() {
expect
(
dirnet1
.
length
==
4
).
assertTrue
();
await
fileIO
.
copyDir
(
dpath
.
srcDir
,
dpath
.
destDir
,
undefined
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
}
catch
(
err
)
{
console
.
log
(
'
fileIO_test_copyDir_async_016 has failed for
'
+
err
.
message
+
'
, code:
'
+
err
.
code
);
expect
(
err
.
code
==
13900015
&&
err
.
message
==
'
File exists
'
).
assertTrue
();
let
dirent2
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
...
...
@@ -736,7 +1086,7 @@ export default function fileIOCopyDir() {
* @tc.number SUB_DF_FILEIO_COPYDIR_ASYNC_1700
* @tc.name fileIO_test_copyDir_async_017
* @tc.desc Test copyDir() interface.Callback.
* There is no target folder(src) under path dest.Mode is undefined.
* There is no target folder(src) under path dest.
Mode is undefined.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
...
...
storage/storagefileiov9jstest/src/main/js/test/members/moveDir.test.js
浏览文件 @
3f3b45c9
...
...
@@ -76,6 +76,485 @@ export default function fileIOMoveDir() {
}
}
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_0000
* @tc.name fileIO_test_moveDir_sync_000
* @tc.desc Test moveDirSync() interface.
* There is no target folder(src) under path dest.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileIO_test_moveDir_sync_000
'
,
0
,
async
function
()
{
let
dpath
=
await
featureAbility
.
getContext
().
getFilesDir
()
+
'
/fileIO_test_moveDir_sync_000
'
;
let
ddpath1
=
dpath
+
'
/srcDir
'
;
let
ddpath2
=
dpath
+
'
/destDir
'
;
let
fpath1
=
ddpath1
+
'
/srcFile_first_01
'
;
let
fpath2
=
ddpath1
+
'
/srcFile_first_02
'
;
let
dddpath
=
ddpath1
+
'
/srcDir_first
'
;
let
ffpath1
=
dddpath
+
'
/srcFile_second_01
'
;
let
ffpath2
=
dddpath
+
'
/srcFile_second_02
'
;
fileIO
.
mkdirSync
(
dpath
);
fileIO
.
mkdirSync
(
ddpath1
);
fileIO
.
mkdirSync
(
ddpath2
);
fileIO
.
mkdirSync
(
dddpath
);
expect
(
prepareFile
(
fpath1
,
randomString
(
10
))).
assertTrue
();
expect
(
prepareFile
(
fpath2
,
randomString
(
15
))).
assertTrue
();
expect
(
prepareFile
(
ffpath1
,
randomString
(
20
))).
assertTrue
();
expect
(
prepareFile
(
ffpath2
,
randomString
(
25
))).
assertTrue
();
try
{
let
stat1
=
fileIO
.
statSync
(
fpath1
);
let
stat2
=
fileIO
.
statSync
(
ffpath1
);
fileIO
.
moveDirSync
(
ddpath1
,
ddpath2
);
expect
(
fileIO
.
accessSync
(
ddpath1
)).
assertFalse
();
expect
(
fileIO
.
accessSync
(
ddpath2
+
'
/srcDir/srcFile_first_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
ddpath2
+
'
/srcDir/srcDir_first/srcFile_second_01
'
)).
assertTrue
();
let
stat3
=
fileIO
.
statSync
(
ddpath2
+
'
/srcDir/srcFile_first_01
'
);
expect
(
stat1
.
size
==
stat3
.
size
).
assertTrue
();
let
stat4
=
fileIO
.
statSync
(
ddpath2
+
'
/srcDir/srcDir_first/srcFile_second_01
'
);
expect
(
stat2
.
size
==
stat4
.
size
).
assertTrue
();
fileIO
.
rmdirSync
(
dpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_moveDir_sync_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_0100
* @tc.name fileIO_test_moveDir_sync_001
* @tc.desc Test moveDirSync() interface.
* There is a target folder(src) under path dest but it is empty.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileIO_test_moveDir_sync_001
'
,
0
,
async
function
()
{
let
dpath
=
await
featureAbility
.
getContext
().
getFilesDir
()
+
'
/fileIO_test_moveDir_sync_001
'
;
let
ddpath1
=
dpath
+
'
/srcDir
'
;
let
ddpath2
=
dpath
+
'
/destDir
'
;
let
dddpath2
=
ddpath2
+
'
/srcDir
'
;
let
fpath1
=
ddpath1
+
'
/srcFile_first_01
'
;
let
fpath2
=
ddpath1
+
'
/srcFile_first_02
'
;
let
dddpath1
=
ddpath1
+
'
/srcDir_first
'
;
let
ffpath1
=
dddpath1
+
'
/srcFile_second_01
'
;
let
ffpath2
=
dddpath1
+
'
/srcFile_second_02
'
;
fileIO
.
mkdirSync
(
dpath
);
fileIO
.
mkdirSync
(
ddpath1
);
fileIO
.
mkdirSync
(
ddpath2
);
fileIO
.
mkdirSync
(
dddpath1
);
fileIO
.
mkdirSync
(
dddpath2
);
expect
(
prepareFile
(
fpath1
,
randomString
(
10
))).
assertTrue
();
expect
(
prepareFile
(
fpath2
,
randomString
(
15
))).
assertTrue
();
expect
(
prepareFile
(
ffpath1
,
randomString
(
20
))).
assertTrue
();
expect
(
prepareFile
(
ffpath2
,
randomString
(
25
))).
assertTrue
();
try
{
let
stat1
=
fileIO
.
statSync
(
fpath1
);
let
stat2
=
fileIO
.
statSync
(
ffpath1
);
fileIO
.
moveDirSync
(
ddpath1
,
ddpath2
);
expect
(
fileIO
.
accessSync
(
ddpath1
)).
assertFalse
();
expect
(
fileIO
.
accessSync
(
ddpath2
+
'
/srcDir/srcFile_first_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
ddpath2
+
'
/srcDir/srcDir_first/srcFile_second_01
'
)).
assertTrue
();
let
stat3
=
fileIO
.
statSync
(
ddpath2
+
'
/srcDir/srcFile_first_01
'
);
expect
(
stat1
.
size
==
stat3
.
size
).
assertTrue
();
let
stat4
=
fileIO
.
statSync
(
ddpath2
+
'
/srcDir/srcDir_first/srcFile_second_01
'
);
expect
(
stat2
.
size
==
stat4
.
size
).
assertTrue
();
fileIO
.
rmdirSync
(
dpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_moveDir_sync_001 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_0200
* @tc.name fileIO_test_moveDir_sync_002
* @tc.desc Test moveDirSync() interface.
* There is a target folder(src) under path dest and it is not empty. Mode is DIRMODE_DIRECTORY_REPLACE.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileIO_test_moveDir_sync_002
'
,
0
,
async
function
()
{
let
dpath
=
await
readyFiles
(
'
fileIO_test_moveDir_sync_002
'
);
try
{
let
stat1
=
fileIO
.
statSync
(
dpath
.
srcDir
+
'
/srcFile_first_01
'
);
let
stat2
=
fileIO
.
statSync
(
dpath
.
srcDir
+
'
/srcDir_first/srcFile_second_01
'
);
let
dirent1
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
expect
(
dirent1
.
length
==
4
).
assertTrue
();
fileIO
.
moveDirSync
(
dpath
.
srcDir
,
dpath
.
destDir
,
DIRMODE_DIRECTORY_REPLACE
);
expect
(
fileIO
.
accessSync
(
dpath
.
srcDir
)).
assertFalse
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/destFile_second_01
'
)).
assertFalse
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/destFile_third_01
'
)).
assertFalse
();
let
stat3
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcFile_first_01
'
);
expect
(
stat1
.
size
==
stat3
.
size
).
assertTrue
();
let
stat4
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_01
'
);
expect
(
stat2
.
size
==
stat4
.
size
).
assertTrue
();
let
dirent2
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
expect
(
dirent2
.
length
==
6
).
assertTrue
();
fileIO
.
rmdirSync
(
dpath
.
baseDir
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_moveDir_sync_002 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_0300
* @tc.name fileIO_test_moveDir_sync_003
* @tc.desc Test moveDirSync() interface.
* There is a target folder(src) under path dest and it is not empty. Mode is DIRMODE_FILE_REPLACE.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileIO_test_moveDir_sync_003
'
,
0
,
async
function
()
{
let
dpath
=
await
readyFiles
(
'
fileIO_test_moveDir_sync_003
'
);
try
{
let
stat1
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcFile_first_01
'
);
let
stat2
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_01
'
);
let
dirent1
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
expect
(
dirent1
.
length
==
4
).
assertTrue
();
fileIO
.
moveDirSync
(
dpath
.
srcDir
,
dpath
.
destDir
,
DIRMODE_FILE_REPLACE
);
expect
(
fileIO
.
accessSync
(
dpath
.
srcDir
)).
assertFalse
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/destFile_second_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/destFile_third_01
'
)).
assertTrue
();
let
stat3
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcFile_first_01
'
);
expect
(
stat1
.
size
!=
stat3
.
size
&&
stat3
.
size
==
10
).
assertTrue
();
let
stat4
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_01
'
);
expect
(
stat2
.
size
!=
stat4
.
size
&&
stat4
.
size
==
30
).
assertTrue
();
let
dirent2
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
expect
(
dirent2
.
length
==
8
).
assertTrue
();
fileIO
.
rmdirSync
(
dpath
.
baseDir
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_moveDir_sync_003 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_0400
* @tc.name fileIO_test_moveDir_sync_004
* @tc.desc Test moveDirSync() interface.
* There is a target folder(src) under path dest and it is not empty. Mode is DIRMODE_FILE_THROW_ERR.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileIO_test_moveDir_sync_004
'
,
0
,
async
function
()
{
let
dpath
=
await
readyFiles
(
'
fileIO_test_moveDir_async_008
'
);
try
{
let
dirnet1
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
expect
(
dirnet1
.
length
==
4
).
assertTrue
();
fileIO
.
moveDirSync
(
dpath
.
srcDir
,
dpath
.
destDir
,
DIRMODE_FILE_THROW_ERR
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_moveDir_sync_004 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
let
stat1
=
fileIO
.
statSync
(
dpath
.
srcDir
+
'
/srcFile_first_01
'
);
let
stat2
=
fileIO
.
statSync
(
dpath
.
srcDir
+
'
/srcDir_first/srcFile_second_01
'
);
let
stat3
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcFile_first_01
'
);
expect
(
stat1
.
size
!=
stat3
.
size
&&
stat3
.
size
==
20
).
assertTrue
();
let
stat4
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_01
'
);
expect
(
stat2
.
size
!=
stat4
.
size
&&
stat4
.
size
==
50
).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcFile_first_02
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_02
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/destFile_second_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/destFile_third_01
'
)).
assertTrue
();
expect
(
fileIO
.
accessSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_01
'
)).
assertTrue
();
let
dirent2
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
expect
(
dirent2
.
length
==
8
).
assertTrue
();
fileIO
.
rmdirSync
(
dpath
.
baseDir
);
expect
(
e
.
code
==
13900015
&&
e
.
message
==
'
File exists
'
).
assertTrue
();
expect
(
e
.
data
.
length
==
2
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_0500
* @tc.name fileIO_test_moveDir_sync_005
* @tc.desc Test moveDirSync() interface.
* There is a target folder(src) under path dest and it is not empty. Mode is DIRMODE_DIRECTORY_THROW_ERR.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
fileIO_test_moveDir_sync_005
'
,
0
,
async
function
()
{
let
dpath
=
await
featureAbility
.
getContext
().
getFilesDir
()
+
'
/fileIO_test_moveDir_sync_005
'
;
let
ddpath1
=
dpath
+
'
/srcDir
'
;
let
ddpath2
=
dpath
+
'
/destDir
'
;
let
dddpath1
=
ddpath1
+
'
/srcDir_first
'
;
let
dddpath2
=
ddpath2
+
'
/srcDir
'
;
let
fpath1
=
ddpath1
+
'
/srcFile_first_01
'
;
let
fpath2
=
ddpath1
+
'
/srcFile_first_02
'
;
let
fpath3
=
dddpath2
+
'
/srcFile_first_01
'
;
let
fpath4
=
dddpath2
+
'
/destFile_first_01
'
;
fileIO
.
mkdirSync
(
dpath
);
fileIO
.
mkdirSync
(
ddpath1
);
fileIO
.
mkdirSync
(
ddpath2
);
fileIO
.
mkdirSync
(
dddpath1
);
fileIO
.
mkdirSync
(
dddpath2
);
expect
(
prepareFile
(
fpath1
,
randomString
(
10
))).
assertTrue
();
expect
(
prepareFile
(
fpath2
,
randomString
(
15
))).
assertTrue
();
expect
(
prepareFile
(
fpath3
,
randomString
(
20
))).
assertTrue
();
expect
(
prepareFile
(
fpath4
,
randomString
(
25
))).
assertTrue
();
try
{
fileIO
.
moveDirSync
(
ddpath1
,
ddpath2
,
DIRMODE_DIRECTORY_THROW_ERR
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
fileIO
.
rmdirSync
(
dpath
);
console
.
log
(
'
fileIO_test_moveDir_sync_005 has failed for
'
+
err
.
message
+
'
, code:
'
+
err
.
code
);
expect
(
err
.
code
==
13900032
&&
err
.
message
==
'
Directory not empty
'
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_0600
* @tc.name fileIO_test_moveDir_sync_006
* @tc.desc Test moveDirSync() interface.
* Src is empty and there is a target folder(src) under path dest but it is empty.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_moveDir_sync_006
'
,
3
,
async
function
()
{
let
dpath
=
await
nextFileName
(
'
fileIO_test_moveDir_sync_006
'
);
let
fpath
=
dpath
+
'
/file_006.txt
'
;
let
ddpath
=
dpath
+
'
/dir_006
'
;
let
ddpath2
=
dpath
+
'
/dir2_006
'
;
let
ffpath3
=
ddpath2
+
'
/new.txt
'
;
let
dddpath3
=
ddpath2
+
'
/dir_006
'
;
fileIO
.
mkdirSync
(
dpath
);
fileIO
.
mkdirSync
(
ddpath
);
fileIO
.
mkdirSync
(
ddpath2
);
fileIO
.
mkdirSync
(
dddpath3
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
prepareFile
(
ffpath3
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileIO
.
moveDirSync
(
ddpath
,
ddpath2
,
DIRMODE_FILE_REPLACE
);
expect
(
fileIO
.
accessSync
(
ddpath
)).
assertFalse
();
fileIO
.
rmdirSync
(
dpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_moveDir_sync_006 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_0700
* @tc.name fileIO_test_moveDir_sync_007
* @tc.desc Test moveDirSync() interface.
* Src is empty and there is no target folder(src) under path dest.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_moveDir_sync_007
'
,
3
,
async
function
()
{
let
dpath
=
await
nextFileName
(
'
fileIO_test_moveDir_sync_007
'
);
let
fpath
=
dpath
+
'
/file_007.txt
'
;
let
ddpath
=
dpath
+
'
/dir_007
'
;
let
ddpath2
=
dpath
+
'
/dir2_007
'
;
let
ffpath3
=
ddpath2
+
'
/new.txt
'
;
fileIO
.
mkdirSync
(
dpath
);
fileIO
.
mkdirSync
(
ddpath
);
fileIO
.
mkdirSync
(
ddpath2
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
expect
(
prepareFile
(
ffpath3
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileIO
.
moveDirSync
(
ddpath
,
ddpath2
,
DIRMODE_FILE_REPLACE
);
expect
(
fileIO
.
accessSync
(
ddpath
)).
assertFalse
();
fileIO
.
rmdirSync
(
dpath
);
}
catch
(
e
)
{
console
.
log
(
'
fileIO_test_moveDir_sync_007 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_0800
* @tc.name fileIO_test_moveDir_sync_008
* @tc.desc Test moveDirSync() interface.
* Invalid mode.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_moveDir_sync_008
'
,
3
,
async
function
()
{
let
dpath
=
await
featureAbility
.
getContext
().
getFilesDir
()
+
'
/fileIO_test_moveDir_sync_008
'
;
let
ddpath1
=
dpath
+
'
/srcDir
'
;
let
ddpath2
=
dpath
+
'
/destDir
'
;
let
dddpath1
=
ddpath1
+
'
/srcDir_first
'
;
let
fpath1
=
ddpath1
+
'
/srcFile_first_01
'
;
fileIO
.
mkdirSync
(
dpath
);
fileIO
.
mkdirSync
(
ddpath1
);
fileIO
.
mkdirSync
(
ddpath2
);
fileIO
.
mkdirSync
(
dddpath1
);
expect
(
prepareFile
(
fpath1
,
randomString
(
10
))).
assertTrue
();
try
{
const
INVALIDE_MODE
=
-
1
;
fileIO
.
moveDirSync
(
ddpath1
,
ddpath2
,
INVALIDE_MODE
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
fileIO
.
rmdirSync
(
dpath
);
console
.
log
(
'
fileIO_test_moveDir_sync_008 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_0900
* @tc.name fileIO_test_moveDir_sync_009
* @tc.desc Test moveDirSync() interface.
* The path point to a file, not a directory.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_moveDir_sync_009
'
,
3
,
async
function
()
{
let
dpath
=
await
nextFileName
(
'
fileIO_test_moveDir_sync_009
'
);
let
fpath
=
dpath
+
'
/file_000.txt
'
;
let
ddpath
=
dpath
+
'
/dir_000
'
;
let
ffpath
=
ddpath
+
'
/file_000.txt
'
;
fileIO
.
mkdirSync
(
dpath
);
fileIO
.
mkdirSync
(
ddpath
);
expect
(
prepareFile
(
fpath
,
FILE_CONTENT
)).
assertTrue
();
try
{
fileIO
.
moveDirSync
(
fpath
,
ffpath
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
fileIO
.
rmdirSync
(
dpath
);
console
.
log
(
'
fileIO_test_moveDir_sync_009 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_1000
* @tc.name fileIO_test_moveDir_sync_010
* @tc.desc Test moveDirSync() interface.
* Invalid path. Can not move the same path.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_moveDir_sync_010
'
,
3
,
async
function
()
{
let
dpath
=
await
featureAbility
.
getContext
().
getFilesDir
()
+
'
/fileIO_test_moveDir_sync_010
'
;
let
ddpath1
=
dpath
+
'
/srcDir
'
;
let
ddpath2
=
dpath
+
'
/destDir
'
;
let
dddpath1
=
ddpath1
+
'
/srcDir_first
'
;
let
fpath1
=
ddpath1
+
'
/srcFile_first_01
'
;
fileIO
.
mkdirSync
(
dpath
);
fileIO
.
mkdirSync
(
ddpath1
);
fileIO
.
mkdirSync
(
ddpath2
);
fileIO
.
mkdirSync
(
dddpath1
);
expect
(
prepareFile
(
fpath1
,
randomString
(
10
))).
assertTrue
();
try
{
fileIO
.
moveDirSync
(
ddpath1
,
ddpath1
,
DIRMODE_FILE_THROW_ERR
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
fileIO
.
rmdirSync
(
dpath
);
console
.
log
(
'
fileIO_test_moveDir_sync_010 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_1100
* @tc.name fileIO_test_moveDir_sync_011
* @tc.desc Test moveDirSync() interface.
* Invalid path. Can not move subPath.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_moveDir_sync_011
'
,
3
,
async
function
()
{
let
dpath
=
await
featureAbility
.
getContext
().
getFilesDir
()
+
'
/fileIO_test_moveDir_sync_011
'
;
let
ddpath1
=
dpath
+
'
/srcDir
'
;
let
dddpath1
=
ddpath1
+
'
/srcDir_first
'
;
let
fpath1
=
ddpath1
+
'
/srcFile_first_01
'
;
let
fpath2
=
ddpath1
+
'
/srcFile_first_02
'
;
let
ffpath1
=
dddpath1
+
'
/srcFile_second_01
'
;
let
ffpath2
=
dddpath1
+
'
/srcFile_second_02
'
;
fileIO
.
mkdirSync
(
dpath
);
fileIO
.
mkdirSync
(
ddpath1
);
fileIO
.
mkdirSync
(
dddpath1
);
expect
(
prepareFile
(
fpath1
,
randomString
(
10
))).
assertTrue
();
expect
(
prepareFile
(
fpath2
,
randomString
(
15
))).
assertTrue
();
expect
(
prepareFile
(
ffpath1
,
randomString
(
20
))).
assertTrue
();
expect
(
prepareFile
(
ffpath2
,
randomString
(
25
))).
assertTrue
();
try
{
fileIO
.
moveDirSync
(
ddpath1
,
dddpath1
,
DIRMODE_FILE_THROW_ERR
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
fileIO
.
rmdirSync
(
dpath
);
console
.
log
(
'
fileIO_test_moveDir_sync_011 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
'
Invalid argument
'
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_1200
* @tc.name fileIO_test_moveDir_sync_012
* @tc.desc Test moveDirSync() interface.
* There is a target folder(src) under path dest and it is not empty. Mode is DIRMODE_DIRECTORY_THROW_ERR.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
fileIO_test_moveDir_sync_012
'
,
3
,
async
function
()
{
let
dpath
=
await
featureAbility
.
getContext
().
getFilesDir
()
+
'
/fileIO_test_moveDir_sync_012
'
;
let
ddpath1
=
dpath
+
'
/srcDir
'
;
let
ddpath2
=
dpath
+
'
/destDir
'
;
let
dddpath1
=
ddpath1
+
'
/srcDir_first
'
;
let
dddpath2
=
ddpath2
+
'
/srcDir
'
;
let
fpath1
=
ddpath1
+
'
/srcFile_first_01
'
;
let
fpath2
=
ddpath1
+
'
/srcFile_first_02
'
;
let
fpath3
=
dddpath2
+
'
/srcFile_first_01
'
;
let
fpath4
=
dddpath2
+
'
/destFile_first_01
'
;
fileIO
.
mkdirSync
(
dpath
);
fileIO
.
mkdirSync
(
ddpath1
);
fileIO
.
mkdirSync
(
ddpath2
);
fileIO
.
mkdirSync
(
dddpath1
);
fileIO
.
mkdirSync
(
dddpath2
);
expect
(
prepareFile
(
fpath1
,
randomString
(
10
))).
assertTrue
();
expect
(
prepareFile
(
fpath2
,
randomString
(
15
))).
assertTrue
();
expect
(
prepareFile
(
fpath3
,
randomString
(
20
))).
assertTrue
();
expect
(
prepareFile
(
fpath4
,
randomString
(
25
))).
assertTrue
();
try
{
fileIO
.
moveDirSync
(
ddpath1
,
ddpath2
,
DIRMODE_DIRECTORY_THROW_ERR
);
expect
(
false
).
assertTrue
();
}
catch
(
err
)
{
fileIO
.
rmdirSync
(
dpath
);
console
.
log
(
'
fileIO_test_moveDir_sync_012 has failed for
'
+
err
.
message
+
'
, code:
'
+
err
.
code
);
expect
(
err
.
code
==
13900032
&&
err
.
message
==
'
Directory not empty
'
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_FILEIO_MOVEDIR_ASYNC_0000
* @tc.name fileIO_test_moveDir_async_000
...
...
@@ -282,7 +761,7 @@ export default function fileIOMoveDir() {
* @tc.number SUB_DF_FILEIO_MOVEDIR_ASYNC_0400
* @tc.name fileIO_test_moveDir_async_004
* @tc.desc Test moveFile() interface.Promise.
* There is a target folder(src) under path dest and it is not empty.Mode is DIRMODE_DIRECTORY_REPLACE.
* There is a target folder(src) under path dest and it is not empty.
Mode is DIRMODE_DIRECTORY_REPLACE.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -318,7 +797,7 @@ export default function fileIOMoveDir() {
* @tc.number SUB_DF_FILEIO_MOVEDIR_ASYNC_0500
* @tc.name fileIO_test_moveDir_async_005
* @tc.desc Test moveFile() interface.Callback.
* There is a target folder(src) under path dest and it is not empty.Mode is DIRMODE_DIRECTORY_REPLACE.
* There is a target folder(src) under path dest and it is not empty.
Mode is DIRMODE_DIRECTORY_REPLACE.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -359,7 +838,7 @@ export default function fileIOMoveDir() {
* @tc.number SUB_DF_FILEIO_MOVEDIR_ASYNC_0600
* @tc.name fileIO_test_moveDir_async_006
* @tc.desc Test moveFile() interface.Promise.
* There is a target folder(src) under path dest and it is not empty.Mode is DIRMODE_FILE_REPLACE.
* There is a target folder(src) under path dest and it is not empty.
Mode is DIRMODE_FILE_REPLACE.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -371,7 +850,6 @@ export default function fileIOMoveDir() {
try
{
let
stat1
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcFile_first_01
'
);
let
stat2
=
fileIO
.
statSync
(
dpath
.
destDir
+
'
/srcDir/srcDir_first/srcFile_second_01
'
);
let
dirent1
=
fileIO
.
listFileSync
(
dpath
.
destDir
,
{
recursion
:
true
});
expect
(
dirent1
.
length
==
4
).
assertTrue
();
await
fileIO
.
moveDir
(
dpath
.
srcDir
,
dpath
.
destDir
,
DIRMODE_FILE_REPLACE
);
...
...
@@ -396,7 +874,7 @@ export default function fileIOMoveDir() {
* @tc.number SUB_DF_FILEIO_MOVEDIR_ASYNC_0700
* @tc.name fileIO_test_moveDir_async_007
* @tc.desc Test moveFile() interface.Callback.
* There is a target folder(src) under path dest and it is not empty.Mode is DIRMODE_FILE_REPLACE.
* There is a target folder(src) under path dest and it is not empty.
Mode is DIRMODE_FILE_REPLACE.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -437,7 +915,7 @@ export default function fileIOMoveDir() {
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_0800
* @tc.name fileIO_test_moveDir_async_008
* @tc.desc Test moveFile() interface.Promise.
* There is a target folder(src) under path dest and it is not empty.Mode is DIRMODE_FILE_THROW_ERR.
* There is a target folder(src) under path dest and it is not empty.
Mode is DIRMODE_FILE_THROW_ERR.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -477,7 +955,7 @@ export default function fileIOMoveDir() {
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_0900
* @tc.name fileIO_test_moveDir_async_009
* @tc.desc Test moveFile() interface.Callback.
* There is a target folder(src) under path dest and it is not empty.Mode is DIRMODE_FILE_THROW_ERR.
* There is a target folder(src) under path dest and it is not empty.
Mode is DIRMODE_FILE_THROW_ERR.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -520,7 +998,7 @@ export default function fileIOMoveDir() {
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_1000
* @tc.name fileIO_test_moveDir_async_010
* @tc.desc Test moveFile() interface.Promise.
* There is a target folder(src) under path dest and it is not empty.Mode is DIRMODE_DIRECTORY_THROW_ERR.
* There is a target folder(src) under path dest and it is not empty.
Mode is DIRMODE_DIRECTORY_THROW_ERR.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
@@ -544,7 +1022,7 @@ export default function fileIOMoveDir() {
* @tc.number SUB_DF_FILEIO_MOVEDIRSYNC_1100
* @tc.name fileIO_test_moveDir_async_011
* @tc.desc Test moveFile() interface.Callback.
* There is a target folder(src) under path dest and it is not empty.Mode is DIRMODE_DIRECTORY_THROW_ERR.
* There is a target folder(src) under path dest and it is not empty.
Mode is DIRMODE_DIRECTORY_THROW_ERR.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
...
...
storage/storagestatfsjstest/src/main/js/test/statvfs.test.js
浏览文件 @
3f3b45c9
/*
* Copyright (C) 202
2
Huawei Device Co., Ltd.
* Copyright (C) 202
3
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
...
...
@@ -19,6 +19,204 @@ import featureAbility from '@ohos.ability.featureAbility';
export
default
function
statvfs_test
()
{
describe
(
'
statvfs_test
'
,
function
()
{
/**
* @tc.number SUB_DF_STATFS_GET_FREE_SIZE_SYNC_0000
* @tc.name statvfs_test_get_free_size_sync_000
* @tc.desc Test getFreeSizeSync() interfaces, when the path is a sandbox path, promise way back.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
statvfs_test_get_free_size_sync_000
'
,
0
,
async
function
()
{
try
{
let
context
=
featureAbility
.
getContext
();
let
data
=
await
context
.
getFilesDir
();
let
number
=
statvfs
.
getFreeSizeSync
(
data
);
console
.
log
(
"
getFreeSize getFilesDir===>
"
+
(
number
/
1024
));
expect
(
isIntNum
(
number
)).
assertTrue
();
}
catch
(
e
)
{
console
.
log
(
'
statvfs_test_get_free_size_sync_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_FREE_SIZE_SYNC_0100
* @tc.name statvfs_test_get_free_size_sync_001
* @tc.desc Test getFreeSizeSync() interfaces, when the path is dev, callback way back.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
statvfs_test_get_free_size_sync_001
'
,
0
,
async
function
()
{
try
{
let
number
=
statvfs
.
getFreeSizeSync
(
"
/dev
"
);
console
.
log
(
"
getFreeSizeNumber dev===>:
"
+
(
number
/
1024
));
expect
(
isIntNum
(
number
)).
assertTrue
();
}
catch
(
e
)
{
console
.
log
(
'
statvfs_test_get_free_size_sync_001 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_FREE_SIZE_SYNC_0200
* @tc.name statvfs_test_get_free_size_sync_002
* @tc.desc Test getFreeSizeSync() interfaces, when the parameter type is wrong.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
statvfs_test_get_free_size_sync_002
'
,
3
,
async
function
()
{
try
{
statvfs
.
getFreeSizeSync
(
1
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
console
.
log
(
'
statvfs_test_get_free_size_sync_002 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
"
Invalid argument
"
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_FREE_SIZE_SYNC_0300
* @tc.name statvfs_test_get_free_size_sync_003
* @tc.desc Test getFreeSizeSync() interfaces, when there are no parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
statvfs_test_get_free_size_sync_003
'
,
3
,
async
function
()
{
try
{
statvfs
.
getFreeSizeSync
();
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
console
.
log
(
'
statvfs_test_get_free_size_sync_003 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
"
Invalid argument
"
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_FREE_SIZE_SYNC_0500
* @tc.name statvfs_test_get_free_size_sync_005
* @tc.desc Test getFreeSizeSync() interfaces, when the path is empty.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
statvfs_test_get_free_size_sync_005
'
,
3
,
async
function
()
{
try
{
statvfs
.
getFreeSizeSync
(
""
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
console
.
log
(
'
statvfs_test_get_free_size_sync_005 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900002
&&
e
.
message
==
'
No such file or directory
'
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_TOTAL_SIZE_SYNC_0000
* @tc.name statvfs_test_get_total_size_sync_000
* @tc.desc Test getTotalSizeSync() interfaces, when the path is a sandbox path, promise way back.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
statvfs_test_get_total_size_sync_000
'
,
0
,
async
function
()
{
try
{
let
context
=
featureAbility
.
getContext
();
let
data
=
await
context
.
getFilesDir
();
let
number
=
statvfs
.
getTotalSizeSync
(
data
);
console
.
log
(
"
getTotalSizeNumber GetFilesDir====>:
"
+
(
number
/
1024
));
expect
(
isIntNum
(
number
)).
assertTrue
();
}
catch
(
e
)
{
console
.
log
(
'
statvfs_test_get_total_size_sync_000 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_TOTAL_SIZE_SYNC_0100
* @tc.name statvfs_test_get_total_size_sync_001
* @tc.desc Test getTotalSizeSync() interfaces, when the path is dev, callback way back.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 0
* @tc.require
*/
it
(
'
statvfs_test_get_total_size_sync_001
'
,
0
,
async
function
()
{
try
{
let
number
=
statvfs
.
getTotalSizeSync
(
"
/dev
"
);
console
.
log
(
"
getTotalSizeNumber dev===>:
"
+
(
number
/
1024
));
expect
(
isIntNum
(
number
)).
assertTrue
();
}
catch
(
e
)
{
console
.
log
(
'
statvfs_test_get_total_size_sync_001 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_TOTAL_SIZE_SYNC_0200
* @tc.name statvfs_test_get_total_size_sync_002
* @tc.desc Test getTotalSizeSync() interfaces, when the parameter type is wrong.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
statvfs_test_get_total_size_sync_002
'
,
3
,
async
function
()
{
try
{
statvfs
.
getTotalSizeSync
(
1
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
console
.
log
(
'
statvfs_test_get_total_size_sync_002 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
"
Invalid argument
"
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_TOTAL_SIZE_SYNC_0300
* @tc.name statvfs_test_get_total_size_sync_003
* @tc.desc Test getTotalSizeSync() interfaces, when there are no parameters.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
statvfs_test_get_total_size_sync_003
'
,
3
,
async
function
()
{
try
{
statvfs
.
getTotalSizeSync
();
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
console
.
log
(
'
statvfs_test_get_total_size_sync_003 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900020
&&
e
.
message
==
"
Invalid argument
"
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_TOTAL_SIZE_SYNC_0400
* @tc.name statvfs_test_get_total_size_sync_004
* @tc.desc Test getTotalSizeSync() interfaces, when the path is empty.
* @tc.size MEDIUM
* @tc.type Function
* @tc.level Level 3
* @tc.require
*/
it
(
'
statvfs_test_get_total_size_sync_004
'
,
3
,
async
function
()
{
try
{
statvfs
.
getTotalSizeSync
(
""
);
expect
(
false
).
assertTrue
();
}
catch
(
e
)
{
console
.
log
(
'
statvfs_test_get_total_size_sync_004 has failed for
'
+
e
.
message
+
'
, code:
'
+
e
.
code
);
expect
(
e
.
code
==
13900002
&&
e
.
message
==
'
No such file or directory
'
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_FREE_SIZE_0000
* @tc.name statvfs_test_get_free_size_async_000
...
...
@@ -203,7 +401,7 @@ describe('statvfs_test', function () {
expect
(
false
).
assertTrue
();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_TOTAL_SIZE_0200
* @tc.name statvfs_test_get_total_size_async_002
...
...
@@ -224,7 +422,7 @@ describe('statvfs_test', function () {
done
();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_TOTAL_SIZE_0300
* @tc.name statvfs_test_get_total_size_async_003
...
...
@@ -245,7 +443,7 @@ describe('statvfs_test', function () {
done
();
}
});
/**
* @tc.number SUB_DF_STATFS_GET_TOTAL_SIZE_0400
* @tc.name statvfs_test_get_total_size_async_004
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录