Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
362cd0dc
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看板
未验证
提交
362cd0dc
编写于
9月 29, 2022
作者:
O
openharmony_ci
提交者:
Gitee
9月 29, 2022
浏览文件
操作
浏览文件
下载
差异文件
!5775 testClearInterval 修复 beta3
Merge pull request !5775 from Nicklaus/master
上级
e80153fb
8984f1bb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
462 addition
and
457 deletion
+462
-457
arkui/ace_js_attribute_api/src/main/js/test/basicabilityapi.test.js
...js_attribute_api/src/main/js/test/basicabilityapi.test.js
+462
-457
未找到文件。
arkui/ace_js_attribute_api/src/main/js/test/basicabilityapi.test.js
浏览文件 @
362cd0dc
...
...
@@ -19,505 +19,510 @@ import router from '@system.router';
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
;
export
default
function
basicabilityapi
()
{
describe
(
'
basicabilityapi
'
,
function
()
{
let
testResult
;
let
testResultFail
;
let
test
;
beforeAll
(
function
()
{
testResult
=
true
;
testResultFail
=
false
;
test
=
"
success
"
});
beforeEach
(
function
()
{
});
afterEach
(
function
()
{
});
afterAll
(
function
()
{
});
async
function
backToIndex
(){
let
backToIndexPromise
=
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
router
.
back
({
uri
:
'
pages/index/index
'
});
resolve
();
},
500
);
describe
(
'
basicabilityapi
'
,
function
()
{
let
testResult
;
let
testResultFail
;
let
test
;
beforeAll
(
function
()
{
testResult
=
true
;
testResultFail
=
false
;
test
=
"
success
"
});
let
clearPromise
=
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
router
.
clear
();
resolve
();
},
500
);
});
await
backToIndexPromise
.
then
(()
=>
{
return
clearPromise
;
beforeEach
(
function
()
{
});
}
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0100
* @tc.name testClearInterval
* @tc.desc Cancel the repetitive timing tasks previously set by setInterval.
*/
it
(
'
testClearInterval
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testClearInterval START
'
);
let
res
=
0
;
let
testTimes
=
5
let
intervalID
=
-
1
;
let
promise1
=
new
Promise
((
resolve
,
reject
)
=>
{
intervalID
=
setInterval
(
function
()
{
if
(
res
===
testTimes
){
clearInterval
(
intervalID
);
}
res
++
;
console
.
info
(
'
testClearInterval res =
'
+
res
);
resolve
();
},
100
);
afterEach
(
function
()
{
});
Promise
.
all
([
promise1
]).
then
(()
=>
{
console
.
info
(
'
testClearInterval finally
'
);
expect
(
testTimes
).
assertEqual
(
res
);
console
.
info
(
'
testClearInterval END
'
);
done
();
afterAll
(
function
()
{
});
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0200
* @tc.name testConsole
* @tc.desc Print a text message.
*/
it
(
'
testConsole
'
,
0
,
function
()
{
console
.
info
(
'
testConsole START
'
);
try
{
const
versionCode
=
1.1
;
console
.
info
(
'
[console.info] versionCode:
'
+
versionCode
);
console
.
debug
(
'
[console.debug] versionCode:
'
+
versionCode
);
console
.
log
(
'
[console.log] versionCode:
'
+
versionCode
);
console
.
warn
(
'
[console.warn] versionCode:
'
+
versionCode
);
console
.
error
(
'
[console.error] versionCode:
'
+
versionCode
);
expect
(
test
).
assertEqual
(
'
success
'
);
console
.
info
(
'
testConsole END
'
);
}
catch
(
e
){
console
.
info
(
'
testConsole ERROR
'
+
e
);
async
function
backToIndex
(){
let
backToIndexPromise
=
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
router
.
back
({
uri
:
'
pages/index/index
'
});
resolve
();
},
500
);
});
let
clearPromise
=
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
router
.
clear
();
resolve
();
},
500
);
});
await
backToIndexPromise
.
then
(()
=>
{
return
clearPromise
;
});
}
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0300
* @tc.name testRouterPush
* @tc.desc Go to the specified page of the application.
*/
it
(
'
testRouterPush
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testRouterPush START
'
);
let
options
=
{
uri
:
'
pages/routerPush/index
'
}
let
promise1
=
new
Promise
((
resolve
,
reject
)
=>
{
router
.
push
(
options
);
resolve
();
});
let
promise2
=
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
let
pages
=
router
.
getState
();
console
.
info
(
"
[router.push] getState
"
+
JSON
.
stringify
(
pages
));
expect
(
"
pages/routerPush/
"
).
assertEqual
(
pages
.
path
);
console
.
info
(
"
[router.push] getLength:
"
+
router
.
getLength
());
expect
(
"
2
"
).
assertEqual
(
router
.
getLength
());
console
.
info
(
'
testRouterPush SUCCESS
'
);
resolve
();
},
500
);
});
await
promise1
.
then
(()
=>
{
return
promise2
;
});
await
backToIndex
();
console
.
info
(
'
testRouterPush END
'
);
done
();
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0310
* @tc.name testRouterPushNotExist
* @tc.desc Test push not exist page.
*/
it
(
'
testRouterPushNotExist
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testRouterPushNotExist START
'
);
let
promise1
=
new
Promise
((
resolve
,
reject
)
=>
{
router
.
push
({
uri
:
'
pages/routerNotExist/index
'
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0100
* @tc.name testClearInterval
* @tc.desc Cancel the repetitive timing tasks previously set by setInterval.
*/
it
(
'
testClearInterval
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testClearInterval START
'
);
let
res
=
0
;
let
intervalID
=
-
1
;
let
promise1
=
new
Promise
((
resolve
,
reject
)
=>
{
intervalID
=
setInterval
(
function
()
{
res
++
;
console
.
info
(
'
testClearInterval res =
'
+
res
);
resolve
();
},
100
);
});
let
promise2
=
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(
function
()
{
console
.
info
(
'
[clearInterval] start
'
);
clearInterval
(
intervalID
);
console
.
info
(
'
[clearInterval] end
'
);
resolve
();
},
600
);
});
Promise
.
all
([
promise1
,
promise2
]).
then
(()
=>
{
console
.
info
(
'
testClearInterval finally
'
);
expect
(
5
).
assertEqual
(
res
);
console
.
info
(
'
testClearInterval END
'
);
done
();
});
resolve
();
});
let
promise2
=
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
let
pages
=
router
.
getState
();
console
.
info
(
"
testRouterPushNotExist getState
"
+
JSON
.
stringify
(
pages
));
expect
(
"
pages/index/
"
).
assertEqual
(
pages
.
path
);
console
.
info
(
"
testRouterPushNotExist getLength:
"
+
router
.
getLength
());
expect
(
"
1
"
).
assertEqual
(
router
.
getLength
());
console
.
info
(
'
testRouterPushNotExist success
'
);
resolve
();
},
500
);
});
await
promise1
.
then
(()
=>
{
return
promise2
;
});
console
.
info
(
'
testRouterPushNotExist END
'
);
done
();
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0400
* @tc.name testRouterReplace
* @tc.desc Replace the current page with a page in the application, and destroy the replaced page.
*/
it
(
'
testRouterReplace
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testRouterReplace START
'
);
let
options
=
{
uri
:
'
pages/routerPush/index
'
}
let
promise1
=
new
Promise
((
resolve
,
reject
)
=>
{
router
.
push
(
options
);
resolve
();
});
let
repleasePage
=
{
uri
:
'
pages/routerReplace/index
'
}
let
promise2
=
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
router
.
replace
(
repleasePage
);
resolve
();
},
500
);
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0200
* @tc.name testConsole
* @tc.desc Print a text message.
*/
it
(
'
testConsole
'
,
0
,
function
()
{
console
.
info
(
'
testConsole START
'
);
try
{
const
versionCode
=
1.1
;
console
.
info
(
'
[console.info] versionCode:
'
+
versionCode
);
console
.
debug
(
'
[console.debug] versionCode:
'
+
versionCode
);
console
.
log
(
'
[console.log] versionCode:
'
+
versionCode
);
console
.
warn
(
'
[console.warn] versionCode:
'
+
versionCode
);
console
.
error
(
'
[console.error] versionCode:
'
+
versionCode
);
expect
(
test
).
assertEqual
(
'
success
'
);
console
.
info
(
'
testConsole END
'
);
}
catch
(
e
){
console
.
info
(
'
testConsole ERROR
'
+
e
);
}
});
//替换堆栈数量不会变
let
promise3
=
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
let
pages
=
router
.
getState
();
console
.
info
(
"
[router.replace] getState
"
+
JSON
.
stringify
(
pages
));
expect
(
"
pages/routerReplace/
"
).
assertEqual
(
pages
.
path
);
console
.
info
(
"
[router.replace] getLength:
"
+
router
.
getLength
());
expect
(
"
2
"
).
assertEqual
(
router
.
getLength
());
console
.
info
(
'
testRouterReplace SUCCESS
'
);
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0300
* @tc.name testRouterPush
* @tc.desc Go to the specified page of the application.
*/
it
(
'
testRouterPush
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testRouterPush START
'
);
let
options
=
{
uri
:
'
pages/routerPush/index
'
}
let
promise1
=
new
Promise
((
resolve
,
reject
)
=>
{
router
.
push
(
options
);
resolve
();
},
1000
);
});
await
promise1
.
then
(()
=>
{
return
promise2
;
}).
then
(()
=>
{
return
promise3
;
});
let
promise2
=
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
let
pages
=
router
.
getState
();
console
.
info
(
"
[router.push] getState
"
+
JSON
.
stringify
(
pages
));
expect
(
"
pages/routerPush/
"
).
assertEqual
(
pages
.
path
);
console
.
info
(
"
[router.push] getLength:
"
+
router
.
getLength
());
expect
(
"
2
"
).
assertEqual
(
router
.
getLength
());
console
.
info
(
'
testRouterPush SUCCESS
'
);
resolve
();
},
500
);
});
await
promise1
.
then
(()
=>
{
return
promise2
;
});
await
backToIndex
();
console
.
info
(
'
testRouterPush END
'
);
done
();
});
await
backToIndex
();
console
.
info
(
'
testRouterReplace END
'
);
done
();
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0410
* @tc.name testRouterReplaceNotExist
* @tc.desc Test replace not exist page.
*/
it
(
'
testRouterReplaceNotExist
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testRouterReplaceNotExist START
'
);
await
setTimeout
(()
=>
{
router
.
replace
({
uri
:
'
pages/routerNotExist/index
'
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0310
* @tc.name testRouterPushNotExist
* @tc.desc Test push not exist page.
*/
it
(
'
testRouterPushNotExist
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testRouterPushNotExist START
'
);
let
promise1
=
new
Promise
((
resolve
,
reject
)
=>
{
router
.
push
({
uri
:
'
pages/routerNotExist/index
'
});
resolve
();
});
},
500
);
await
setTimeout
(()
=>
{
let
pages
=
router
.
getState
();
console
.
info
(
"
testRouterReplaceNotExist getState
"
+
JSON
.
stringify
(
pages
));
expect
(
"
pages/index/
"
).
assertEqual
(
pages
.
path
);
console
.
info
(
"
testRouterReplaceNotExist getLength:
"
+
router
.
getLength
());
expect
(
"
1
"
).
assertEqual
(
router
.
getLength
());
console
.
info
(
'
testRouterReplaceNotExist END
'
);
let
promise2
=
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
let
pages
=
router
.
getState
();
console
.
info
(
"
testRouterPushNotExist getState
"
+
JSON
.
stringify
(
pages
));
expect
(
"
pages/index/
"
).
assertEqual
(
pages
.
path
);
console
.
info
(
"
testRouterPushNotExist getLength:
"
+
router
.
getLength
());
expect
(
"
1
"
).
assertEqual
(
router
.
getLength
());
console
.
info
(
'
testRouterPushNotExist success
'
);
resolve
();
},
500
);
});
await
promise1
.
then
(()
=>
{
return
promise2
;
});
console
.
info
(
'
testRouterPushNotExist END
'
);
done
();
},
1000
);
});
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0500
* @tc.name testRouterBack
* @tc.desc Return to the previous page or the specified page.
*/
it
(
'
testRouterBack
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testRouterBack START
'
);
let
promise1
=
new
Promise
((
resolve
,
reject
)
=>
{
router
.
push
({
uri
:
'
pages/routerPush/index
'
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0400
* @tc.name testRouterReplace
* @tc.desc Replace the current page with a page in the application, and destroy the replaced page.
*/
it
(
'
testRouterReplace
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testRouterReplace START
'
);
let
options
=
{
uri
:
'
pages/routerPush/index
'
}
let
promise1
=
new
Promise
((
resolve
,
reject
)
=>
{
router
.
push
(
options
);
resolve
();
});
let
repleasePage
=
{
uri
:
'
pages/routerReplace/index
'
}
let
promise2
=
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
router
.
replace
(
repleasePage
);
resolve
();
},
500
);
});
//替换堆栈数量不会变
let
promise3
=
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
let
pages
=
router
.
getState
();
console
.
info
(
"
[router.replace] getState
"
+
JSON
.
stringify
(
pages
));
expect
(
"
pages/routerReplace/
"
).
assertEqual
(
pages
.
path
);
console
.
info
(
"
[router.replace] getLength:
"
+
router
.
getLength
());
expect
(
"
2
"
).
assertEqual
(
router
.
getLength
());
console
.
info
(
'
testRouterReplace SUCCESS
'
);
resolve
();
},
1000
);
});
resolve
();
await
promise1
.
then
(()
=>
{
return
promise2
;
}).
then
(()
=>
{
return
promise3
;
});
await
backToIndex
();
console
.
info
(
'
testRouterReplace END
'
);
done
();
});
let
promise2
=
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
router
.
back
({
uri
:
'
pages/index/index
'
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0410
* @tc.name testRouterReplaceNotExist
* @tc.desc Test replace not exist page.
*/
it
(
'
testRouterReplaceNotExist
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testRouterReplaceNotExist START
'
);
await
setTimeout
(()
=>
{
router
.
replace
({
uri
:
'
pages/routerNotExist/index
'
});
resolve
();
},
500
);
});
let
promise3
=
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
await
setTimeout
(()
=>
{
let
pages
=
router
.
getState
();
console
.
info
(
"
[router.back]
getState
"
+
JSON
.
stringify
(
pages
));
console
.
info
(
"
testRouterReplaceNotExist
getState
"
+
JSON
.
stringify
(
pages
));
expect
(
"
pages/index/
"
).
assertEqual
(
pages
.
path
);
console
.
info
(
"
[router.back]
getLength:
"
+
router
.
getLength
());
console
.
info
(
"
testRouterReplaceNotExist
getLength:
"
+
router
.
getLength
());
expect
(
"
1
"
).
assertEqual
(
router
.
getLength
());
console
.
info
(
'
testRouter
Back SUCCESS
'
);
resolv
e
();
console
.
info
(
'
testRouter
ReplaceNotExist END
'
);
don
e
();
},
1000
);
});
await
promise1
.
then
(()
=>
{
return
promise2
;
}).
then
(()
=>
{
return
promise3
;
});
console
.
info
(
'
testRouterBack END
'
);
done
();
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0600
* @tc.name testRouterClear
* @tc.desc Clear all historical pages in the page stack, and only keep the current page as the top page.
*/
it
(
'
testRouterClear
'
,
0
,
function
()
{
console
.
info
(
'
testRouterClear START
'
);
router
.
clear
();
console
.
info
(
"
[router.clear] router.getLength:
"
+
router
.
getLength
());
expect
(
"
1
"
).
assertEqual
(
router
.
getLength
());
console
.
info
(
'
testRouterClear END
'
);
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0700
* @tc.name testRouterLength
* @tc.desc Get the number of pages currently in the page stack.
*/
it
(
'
testRouterLength
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testRouterLength START
'
);
let
size
=
router
.
getLength
();
console
.
info
(
'
[router.getLength] pages stack size =
'
+
size
);
expect
(
size
).
assertEqual
(
'
1
'
);
let
options
=
{
uri
:
'
pages/routerPush/index
'
}
let
promise1
=
new
Promise
((
resolve
,
reject
)
=>
{
router
.
push
(
options
);
resolve
();
});
let
promise2
=
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
console
.
info
(
"
testRouterLength getLength:
"
+
router
.
getLength
());
expect
(
"
2
"
).
assertEqual
(
router
.
getLength
());
console
.
info
(
'
testRouterLength SUCCESS
'
);
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0500
* @tc.name testRouterBack
* @tc.desc Return to the previous page or the specified page.
*/
it
(
'
testRouterBack
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testRouterBack START
'
);
let
promise1
=
new
Promise
((
resolve
,
reject
)
=>
{
router
.
push
({
uri
:
'
pages/routerPush/index
'
});
resolve
();
},
500
);
});
let
promise2
=
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
router
.
back
({
uri
:
'
pages/index/index
'
});
resolve
();
},
500
);
});
let
promise3
=
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
let
pages
=
router
.
getState
();
console
.
info
(
"
[router.back] getState
"
+
JSON
.
stringify
(
pages
));
expect
(
"
pages/index/
"
).
assertEqual
(
pages
.
path
);
console
.
info
(
"
[router.back] getLength:
"
+
router
.
getLength
());
expect
(
"
1
"
).
assertEqual
(
router
.
getLength
());
console
.
info
(
'
testRouterBack SUCCESS
'
);
resolve
();
},
1000
);
});
await
promise1
.
then
(()
=>
{
return
promise2
;
}).
then
(()
=>
{
return
promise3
;
});
console
.
info
(
'
testRouterBack END
'
);
done
();
});
await
promise1
.
then
(()
=>
{
return
promise2
;
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0600
* @tc.name testRouterClear
* @tc.desc Clear all historical pages in the page stack, and only keep the current page as the top page.
*/
it
(
'
testRouterClear
'
,
0
,
function
()
{
console
.
info
(
'
testRouterClear START
'
);
router
.
clear
();
console
.
info
(
"
[router.clear] router.getLength:
"
+
router
.
getLength
());
expect
(
"
1
"
).
assertEqual
(
router
.
getLength
());
console
.
info
(
'
testRouterClear END
'
);
});
await
backToIndex
();
console
.
info
(
'
testRouterLength END
'
);
done
();
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0800
* @tc.name testRouterGetState
* @tc.desc Get the status information of the current page.
*/
it
(
'
testRouterGetState
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testRouterGetState START
'
);
await
setTimeout
(()
=>
{
let
page
=
router
.
getState
();
console
.
info
(
'
[router.getState] index:
'
+
page
.
index
);
console
.
info
(
'
[router.getState] name:
'
+
page
.
name
);
console
.
info
(
'
[router.getState] path:
'
+
page
.
path
);
expect
(
page
.
index
).
assertEqual
(
1
);
expect
(
page
.
name
).
assertEqual
(
'
index
'
);
expect
(
page
.
path
).
assertEqual
(
'
pages/index/
'
);
console
.
info
(
'
testRouterGetState END
'
);
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0700
* @tc.name testRouterLength
* @tc.desc Get the number of pages currently in the page stack.
*/
it
(
'
testRouterLength
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testRouterLength START
'
);
let
size
=
router
.
getLength
();
console
.
info
(
'
[router.getLength] pages stack size =
'
+
size
);
expect
(
size
).
assertEqual
(
'
1
'
);
let
options
=
{
uri
:
'
pages/routerPush/index
'
}
let
promise1
=
new
Promise
((
resolve
,
reject
)
=>
{
router
.
push
(
options
);
resolve
();
});
let
promise2
=
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
console
.
info
(
"
testRouterLength getLength:
"
+
router
.
getLength
());
expect
(
"
2
"
).
assertEqual
(
router
.
getLength
());
console
.
info
(
'
testRouterLength SUCCESS
'
);
resolve
();
},
500
);
});
await
promise1
.
then
(()
=>
{
return
promise2
;
});
await
backToIndex
();
console
.
info
(
'
testRouterLength END
'
);
done
();
},
500
);
});
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0900
* @tc.name testPromptShowToast
* @tc.desc Show text pop-up window.
*/
it
(
'
testPromptShowToast
'
,
0
,
function
()
{
try
{
console
.
info
(
'
testPromptShowToast START
'
);
const
delay
=
5000
;
prompt
.
showToast
({
message
:
'
message
'
,
duration
:
delay
,
});
expect
(
test
).
assertEqual
(
'
success
'
);
console
.
info
(
'
[prompt.showToast] success
'
);
console
.
info
(
'
testPromptShowToast END
'
);
}
catch
(
e
){
console
.
log
(
'
testPromptShowToast ERROR
'
+
e
);
}
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0800
* @tc.name testRouterGetState
* @tc.desc Get the status information of the current page.
*/
it
(
'
testRouterGetState
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testRouterGetState START
'
);
await
setTimeout
(()
=>
{
let
page
=
router
.
getState
();
console
.
info
(
'
[router.getState] index:
'
+
page
.
index
);
console
.
info
(
'
[router.getState] name:
'
+
page
.
name
);
console
.
info
(
'
[router.getState] path:
'
+
page
.
path
);
expect
(
page
.
index
).
assertEqual
(
1
);
expect
(
page
.
name
).
assertEqual
(
'
index
'
);
expect
(
page
.
path
).
assertEqual
(
'
pages/index/
'
);
console
.
info
(
'
testRouterGetState END
'
);
done
();
},
500
);
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1000
* @tc.name testPromptDialog
* @tc.desc Display the dialog box in the page.
*/
it
(
'
testPromptDialog
'
,
0
,
function
()
{
console
.
info
(
'
testPromptDialog START
'
)
try
{
prompt
.
showDialog
({
title
:
'
dialog showDialog test
'
,
message
:
'
message of dialog
'
,
buttons
:
[
{
text
:
'
OK
'
,
color
:
'
#0000ff
'
,
index
:
0
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0900
* @tc.name testPromptShowToast
* @tc.desc Show text pop-up window.
*/
it
(
'
testPromptShowToast
'
,
0
,
function
()
{
try
{
console
.
info
(
'
testPromptShowToast START
'
);
const
delay
=
5000
;
prompt
.
showToast
({
message
:
'
message
'
,
duration
:
delay
,
});
expect
(
test
).
assertEqual
(
'
success
'
);
console
.
info
(
'
[prompt.showToast] success
'
);
console
.
info
(
'
testPromptShowToast END
'
);
}
catch
(
e
){
console
.
log
(
'
testPromptShowToast ERROR
'
+
e
);
}
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1000
* @tc.name testPromptDialog
* @tc.desc Display the dialog box in the page.
*/
it
(
'
testPromptDialog
'
,
0
,
function
()
{
console
.
info
(
'
testPromptDialog START
'
)
try
{
prompt
.
showDialog
({
title
:
'
dialog showDialog test
'
,
message
:
'
message of dialog
'
,
buttons
:
[
{
text
:
'
OK
'
,
color
:
'
#0000ff
'
,
index
:
0
}
],
success
:
function
(
ret
)
{
console
.
info
(
"
[prompt.showDialog] ret.index
"
+
ret
.
index
);
expect
(
testResult
).
toBeTrue
();
},
cancel
:
function
()
{
console
.
log
(
'
[prompt.showDialog] dialog cancel callback
'
);
expect
(
testResultFail
).
toBeTrue
();
},
complete
:
function
()
{
console
.
log
(
'
[prompt.showDialog] complete
'
);
}
],
success
:
function
(
ret
)
{
console
.
info
(
"
[prompt.showDialog] ret.index
"
+
ret
.
index
);
expect
(
testResult
).
toBeTrue
();
},
cancel
:
function
()
{
console
.
log
(
'
[prompt.showDialog] dialog cancel callback
'
);
expect
(
testResultFail
).
toBeTrue
();
},
complete
:
function
()
{
console
.
log
(
'
[prompt.showDialog] complete
'
);
}
});
console
.
info
(
'
testPromptDialog END
'
);
}
catch
(
e
)
{
console
.
info
(
'
testPromptDialog error
'
+
e
);
}
});
});
console
.
info
(
'
testPromptDialog END
'
);
}
catch
(
e
)
{
console
.
info
(
'
testPromptDialog error
'
+
e
);
}
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1100
* @tc.name testConfigurationGetLocale
* @tc.desc Get the current language and region of the app. Synchronize with the language and region.
*/
it
(
'
testConfigurationGetLocale
'
,
0
,
function
()
{
console
.
info
(
'
testConfigurationGetLocale START
'
);
const
localeInfo
=
configuration
.
getLocale
();
console
.
info
(
"
[configuration.getLocale] localeInfo:
"
+
JSON
.
stringify
(
localeInfo
));
console
.
info
(
"
[configuration.getLocale] language:
"
+
localeInfo
.
language
);
console
.
info
(
"
[configuration.getLocale] countryOrRegion:
"
+
localeInfo
.
countryOrRegion
);
console
.
info
(
"
[configuration.getLocale] dir:
"
+
localeInfo
.
dir
);
expect
(
localeInfo
.
language
).
assertEqual
(
'
zh
'
);
expect
(
localeInfo
.
dir
).
assertEqual
(
'
ltr
'
);
console
.
info
(
'
testConfigurationGetLocale END
'
);
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1100
* @tc.name testConfigurationGetLocale
* @tc.desc Get the current language and region of the app. Synchronize with the language and region.
*/
it
(
'
testConfigurationGetLocale
'
,
0
,
function
()
{
console
.
info
(
'
testConfigurationGetLocale START
'
);
const
localeInfo
=
configuration
.
getLocale
();
console
.
info
(
"
[configuration.getLocale] localeInfo:
"
+
JSON
.
stringify
(
localeInfo
));
console
.
info
(
"
[configuration.getLocale] language:
"
+
localeInfo
.
language
);
console
.
info
(
"
[configuration.getLocale] countryOrRegion:
"
+
localeInfo
.
countryOrRegion
);
console
.
info
(
"
[configuration.getLocale] dir:
"
+
localeInfo
.
dir
);
expect
(
localeInfo
.
language
).
assertEqual
(
'
zh
'
);
expect
(
localeInfo
.
dir
).
assertEqual
(
'
ltr
'
);
console
.
info
(
'
testConfigurationGetLocale END
'
);
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1200
* @tc.name testSetTimeout
* @tc.desc Set up a timer that executes a function or a specified piece of code after the timer expires.
*/
it
(
'
testSetTimeout
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testSetTimeout START
'
);
let
startTime
=
new
Date
().
getTime
();
const
delay
=
200
;
await
setTimeout
(
function
(
v1
,
v2
)
{
let
endTime
=
new
Date
().
getTime
();
console
.
info
(
"
[setTimeout] startTime:
"
+
startTime
);
console
.
info
(
"
[setTimeout] endTime:
"
+
endTime
);
console
.
info
(
'
[setTimeout] delay:
'
+
(
endTime
-
startTime
));
console
.
info
(
'
[setTimeout] v1:
'
+
v1
);
console
.
info
(
'
[setTimeout] v2:
'
+
v2
);
expect
(
'
test
'
).
assertEqual
(
v1
);
expect
(
'
message
'
).
assertEqual
(
v2
);
expect
(
endTime
-
startTime
>=
delay
).
assertTrue
();
console
.
info
(
'
testSetTimeout END
'
);
done
();
},
delay
,
'
test
'
,
'
message
'
);
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1200
* @tc.name testSetTimeout
* @tc.desc Set up a timer that executes a function or a specified piece of code after the timer expires.
*/
it
(
'
testSetTimeout
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testSetTimeout START
'
);
let
startTime
=
new
Date
().
getTime
();
const
delay
=
200
;
await
setTimeout
(
function
(
v1
,
v2
)
{
let
endTime
=
new
Date
().
getTime
();
console
.
info
(
"
[setTimeout] startTime:
"
+
startTime
);
console
.
info
(
"
[setTimeout] endTime:
"
+
endTime
);
console
.
info
(
'
[setTimeout] delay:
'
+
(
endTime
-
startTime
));
console
.
info
(
'
[setTimeout] v1:
'
+
v1
);
console
.
info
(
'
[setTimeout] v2:
'
+
v2
);
expect
(
'
test
'
).
assertEqual
(
v1
);
expect
(
'
message
'
).
assertEqual
(
v2
);
expect
(
endTime
-
startTime
>=
delay
).
assertTrue
();
console
.
info
(
'
testSetTimeout END
'
);
done
();
},
delay
,
'
test
'
,
'
message
'
);
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1300
* @tc.name testClearTimeout
* @tc.desc The timer previously established by calling setTimeout() is cancelled.
*/
it
(
'
testClearTimeout
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testClearTimeout START
'
);
let
res
=
0
;
let
timeoutID
=
setTimeout
(
function
()
{
res
++
;
},
700
);
await
setTimeout
(
function
()
{
console
.
info
(
'
testClearTimeout delay 0.5s
'
)
clearTimeout
(
timeoutID
);
console
.
info
(
"
[clearTimeout] success
"
);
},
500
);
await
setTimeout
(
function
()
{
expect
(
0
).
assertEqual
(
res
);
console
.
info
(
'
testClearTimeout END
'
);
done
();
},
1000
);
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1300
* @tc.name testClearTimeout
* @tc.desc The timer previously established by calling setTimeout() is cancelled.
*/
it
(
'
testClearTimeout
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testClearTimeout START
'
);
let
res
=
0
;
let
timeoutID
=
setTimeout
(
function
()
{
res
++
;
},
700
);
await
setTimeout
(
function
()
{
console
.
info
(
'
testClearTimeout delay 0.5s
'
)
clearTimeout
(
timeoutID
);
console
.
info
(
"
[clearTimeout] success
"
);
},
500
);
await
setTimeout
(
function
()
{
expect
(
0
).
assertEqual
(
res
);
console
.
info
(
'
testClearTimeout END
'
);
done
();
},
1000
);
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1400
* @tc.name testSetInterval
* @tc.desc Call a function or execute a code segment repeatedly, with a fixed time delay between each call.
*/
it
(
'
testSetInterval
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testSetInterval START
'
);
let
res
=
0
;
let
intervalID
=
setInterval
(
function
()
{
res
++
;
},
100
);
await
setTimeout
(
function
()
{
expect
(
9
).
assertEqual
(
res
);
console
.
info
(
'
testSetInterval SUCCESS
'
);
clearInterval
(
intervalID
);
console
.
info
(
'
testSetInterval END
'
);
done
();
},
1000
);
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1400
* @tc.name testSetInterval
* @tc.desc Call a function or execute a code segment repeatedly, with a fixed time delay between each call.
*/
it
(
'
testSetInterval
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testSetInterval START
'
);
let
res
=
0
;
let
intervalID
=
setInterval
(
function
()
{
res
++
;
},
100
);
await
setTimeout
(
function
()
{
expect
(
9
).
assertEqual
(
res
);
console
.
info
(
'
testSetInterval SUCCESS
'
);
clearInterval
(
intervalID
);
console
.
info
(
'
testSetInterval END
'
);
done
();
},
1000
);
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1500
* @tc.name testRequestAnimationFrame
* @tc.desc Sets a vsync after which a function will be executed.
*/
it
(
'
testRequestAnimationFrame
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testRequestAnimationFrame START
'
);
let
requestId
=
requestAnimationFrame
(
function
()
{
console
.
info
(
'
testRequestAnimationFrame success
'
);
expect
(
true
).
assertTrue
();
done
();
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1500
* @tc.name testRequestAnimationFrame
* @tc.desc Sets a vsync after which a function will be executed.
*/
it
(
'
testRequestAnimationFrame
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testRequestAnimationFrame START
'
);
let
requestId
=
requestAnimationFrame
(
function
()
{
console
.
info
(
'
testRequestAnimationFrame success
'
);
expect
(
true
).
assertTrue
();
done
();
});
});
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1600
* @tc.name testCancelAnimationFrame
* @tc.desc Indicates the vsync callback ID returned by "requestAnimationFrame()".
*/
it
(
'
testCancelAnimationFrame
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testCancelAnimationFrame START
'
);
let
result
=
true
;
let
requestId
=
requestAnimationFrame
(
function
()
{
console
.
info
(
'
testCancelAnimationFrame fail
'
);
result
=
false
;
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1600
* @tc.name testCancelAnimationFrame
* @tc.desc Indicates the vsync callback ID returned by "requestAnimationFrame()".
*/
it
(
'
testCancelAnimationFrame
'
,
0
,
async
function
(
done
)
{
console
.
info
(
'
testCancelAnimationFrame START
'
);
let
result
=
true
;
let
requestId
=
requestAnimationFrame
(
function
()
{
console
.
info
(
'
testCancelAnimationFrame fail
'
);
result
=
false
;
});
cancelAnimationFrame
(
requestId
);
await
setTimeout
(
function
()
{
expect
(
result
).
assertTrue
();
done
();
},
1000
);
});
cancelAnimationFrame
(
requestId
);
await
setTimeout
(
function
()
{
expect
(
result
).
assertTrue
();
done
();
},
1000
);
});
});
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录