Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
c3e236bd
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看板
提交
c3e236bd
编写于
6月 29, 2022
作者:
H
hughes27
1
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Signed-off-by: hughes27 <290679795@qq.com>
modify update xts
上级
a044ceeb
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
867 addition
and
405 deletion
+867
-405
updater/update_test/src/main/js/default/test/update.test.js
updater/update_test/src/main/js/default/test/update.test.js
+867
-405
未找到文件。
updater/update_test/src/main/js/default/test/update.test.js
浏览文件 @
c3e236bd
/*
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file ex
cep
t in compliance with the License.
* you may not use this file ex
pec
t in compliance with the License.
* You may obtain a copy of the License at
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
...
@@ -21,6 +21,14 @@ let param_value1 = 0;
...
@@ -21,6 +21,14 @@ let param_value1 = 0;
let
param_value2
=
0
;
let
param_value2
=
0
;
let
expect_value
=
0
;
let
expect_value
=
0
;
let
upgradeInfo
=
{
upgradeApp
:
"
com.hmos.ouc
"
,
businessType
:
{
vendor
:
"
public
"
,
subType
:
1
}
}
let
updateState
=
{
let
updateState
=
{
UPDATE_STATE_INIT
:
0
,
UPDATE_STATE_INIT
:
0
,
UPDATE_STATE_CHECK_VERSION_ON
:
10
,
UPDATE_STATE_CHECK_VERSION_ON
:
10
,
...
@@ -53,12 +61,12 @@ describe('updateclient', function() {
...
@@ -53,12 +61,12 @@ describe('updateclient', function() {
});
});
beforeEach
(
function
()
{
beforeEach
(
function
()
{
if
(
updater
===
undefined
)
{
if
(
updater
===
undefined
)
{
updater
=
client
.
get
Updater
(
'
/data/updater/updater.zip
'
,
'
OTA
'
);
updater
=
client
.
get
OnlineUpdater
(
upgradeInfo
);
console
.
info
(
"
beforeEach updater
"
+
updater
);
console
.
info
(
"
UPDATE_TEST
beforeEach updater
"
+
updater
);
}
}
});
});
afterEach
(
function
()
{
afterEach
(
function
()
{
updater
=
None
;
updater
=
undefined
;
});
});
afterAll
(
function
()
{
afterAll
(
function
()
{
param_value1
=
0
;
param_value1
=
0
;
...
@@ -88,29 +96,6 @@ describe('updateclient', function() {
...
@@ -88,29 +96,6 @@ describe('updateclient', function() {
console
.
info
(
'
testGetUpdate END
'
);
console
.
info
(
'
testGetUpdate END
'
);
});
});
/**
* @tc.number SUB_UPDATE_JS_API_0002
* @tc.name testGetUpdate2
* @tc.desc Test incorrect parameters.
*/
it
(
'
testGetUpdate2
'
,
0
,
function
()
{
console
.
info
(
'
testGetUpdate2 START
'
);
try
{
if
(
client
===
undefined
)
{
console
.
error
(
"
client not defined
"
);
return
;
}
let
tmpUpdater
=
client
.
getUpdater
(
'
/data/updater/updater.zip
'
,
'
44444
'
);
console
.
info
(
"
testGetUpdate3 updater
"
+
tmpUpdater
);
expect
(
tmpUpdater
===
undefined
).
assertTrue
();
}
catch
(
e
)
{
console
.
error
(
'
[testGetUpdate] fail.
'
+
e
);
}
console
.
info
(
'
[client.getUpdate] success.
'
);
console
.
info
(
'
testGetUpdate2 END
'
);
});
/**
/**
* @tc.number SUB_UPDATE_JS_API_0003
* @tc.number SUB_UPDATE_JS_API_0003
* @tc.name testGetUpdate3
* @tc.name testGetUpdate3
...
@@ -139,51 +124,6 @@ describe('updateclient', function() {
...
@@ -139,51 +124,6 @@ describe('updateclient', function() {
console
.
info
(
'
testGetUpdate3 END
'
);
console
.
info
(
'
testGetUpdate3 END
'
);
});
});
/**
* @tc.number SUB_UPDATE_JS_API_0004
* @tc.name testGetUpdate4
* @tc.desc Test incorrect parameters.
*/
it
(
'
testGetUpdate4
'
,
0
,
function
()
{
console
.
info
(
'
testGetUpdate4 START
'
);
try
{
if
(
client
===
undefined
)
{
console
.
error
(
"
client not defined
"
);
return
;
}
let
tmpUpdater
=
client
.
getUpdater
(
function
(){
});
expect
(
tmpUpdater
===
undefined
).
assertTrue
();
}
catch
(
e
)
{
console
.
error
(
'
[testGetUpdate4] fail.
'
+
e
);
}
console
.
info
(
'
[client.getUpdate] success.
'
);
console
.
info
(
'
testGetUpdate4 END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0005
* @tc.name testGetUpdate5
* @tc.desc Test incorrect parameters.
*/
it
(
'
testGetUpdate5
'
,
0
,
function
()
{
console
.
info
(
'
testGetUpdate5 START
'
);
try
{
if
(
client
===
undefined
)
{
console
.
error
(
"
client not defined
"
);
return
;
}
let
tmpUpdater
=
client
.
getUpdater
(
param_value1
,
param_value2
);
expect
(
tmpUpdater
===
undefined
).
assertTrue
();
}
catch
(
e
)
{
console
.
error
(
'
[testGetUpdate] fail.
'
+
e
);
}
console
.
info
(
'
[client.getUpdate] success.
'
);
console
.
info
(
'
testGetUpdate5 END
'
);
});
/**
/**
* @tc.number SUB_UPDATE_JS_API_0006
* @tc.number SUB_UPDATE_JS_API_0006
* @tc.name testGetNewVersionInfo1
* @tc.name testGetNewVersionInfo1
...
@@ -194,7 +134,7 @@ describe('updateclient', function() {
...
@@ -194,7 +134,7 @@ describe('updateclient', function() {
try
{
try
{
let
ret
=
updater
.
getNewVersionInfo
(
function
(
err
,
data
){
let
ret
=
updater
.
getNewVersionInfo
(
function
(
err
,
data
){
console
.
log
(
"
getNewVersionInfo success
"
+
data
);
console
.
log
(
"
getNewVersionInfo success
"
+
data
);
expect
(
data
.
status
).
assertEqual
(
0
);
// Has new version.
expect
(
data
.
versionDigestInfo
.
versionDigest
).
assertInstanceOf
(
'
String
'
);
});
});
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -282,14 +222,7 @@ describe('updateclient', function() {
...
@@ -282,14 +222,7 @@ describe('updateclient', function() {
try
{
try
{
let
ret
=
updater
.
getNewVersionInfo
().
then
(
data
=>
{
let
ret
=
updater
.
getNewVersionInfo
().
then
(
data
=>
{
console
.
log
(
"
getNewVersionInfo success
"
+
data
);
console
.
log
(
"
getNewVersionInfo success
"
+
data
);
expect
(
data
.
status
).
assertEqual
(
0
);
// Has new version.
expect
(
data
.
versionDigestInfo
.
versionDigest
).
assertInstanceOf
(
'
String
'
);
expect
(
data
.
checkResults
.
size
>
0
).
assertTrue
();
console
.
log
(
`info versionName = `
+
data
.
checkResults
[
0
].
versionName
);
console
.
log
(
`info versionCode = `
+
data
.
checkResults
[
0
].
versionCode
);
console
.
log
(
`info verifyInfo = `
+
data
.
checkResults
[
0
].
verifyInfo
);
console
.
log
(
`info descriptionId = `
+
data
.
checkResults
[
0
].
descriptionId
);
console
.
log
(
`info content = `
+
data
.
descriptionInfo
[
0
].
content
);
console
.
log
(
`info size = `
+
data
.
checkResults
[
0
].
size
);
}).
catch
(
error
=>
}).
catch
(
error
=>
console
.
error
(
"
getNewVersionInfo catch
"
+
error
)
console
.
error
(
"
getNewVersionInfo catch
"
+
error
)
);
);
...
@@ -392,14 +325,7 @@ describe('updateclient', function() {
...
@@ -392,14 +325,7 @@ describe('updateclient', function() {
try
{
try
{
let
ret
=
updater
.
checkNewVersion
(
function
(
err
,
data
){
let
ret
=
updater
.
checkNewVersion
(
function
(
err
,
data
){
console
.
log
(
"
checkNewVersion success
"
+
data
);
console
.
log
(
"
checkNewVersion success
"
+
data
);
expect
(
data
.
status
).
assertEqual
(
0
);
// Has new version.
expect
(
data
.
status
).
assertEqual
(
-
1
);
// Has new version.
expect
(
data
.
checkResults
.
size
>
0
).
assertTrue
();
console
.
log
(
`info versionName = `
+
data
.
checkResults
[
0
].
versionName
);
console
.
log
(
`info versionCode = `
+
data
.
checkResults
[
0
].
versionCode
);
console
.
log
(
`info verifyInfo = `
+
data
.
checkResults
[
0
].
verifyInfo
);
console
.
log
(
`info descriptionId = `
+
data
.
checkResults
[
0
].
descriptionId
);
console
.
log
(
`info content = `
+
data
.
descriptionInfo
[
0
].
content
);
console
.
log
(
`info size = `
+
data
.
checkResults
[
0
].
size
);
},
},
error
=>
{
error
=>
{
console
.
log
(
"
checkNewVersion error
"
+
error
)
console
.
log
(
"
checkNewVersion error
"
+
error
)
...
@@ -490,14 +416,7 @@ describe('updateclient', function() {
...
@@ -490,14 +416,7 @@ describe('updateclient', function() {
try
{
try
{
let
ret
=
updater
.
checkNewVersion
().
then
(
data
=>
{
let
ret
=
updater
.
checkNewVersion
().
then
(
data
=>
{
console
.
log
(
"
checkNewVersion success
"
+
data
);
console
.
log
(
"
checkNewVersion success
"
+
data
);
expect
(
data
.
status
).
assertEqual
(
0
);
expect
(
data
.
status
).
assertEqual
(
-
1
);
expect
(
data
.
checkResults
.
size
>
0
).
assertTrue
();
console
.
log
(
`info versionName = `
+
data
.
checkResults
[
0
].
versionName
);
console
.
log
(
`info versionCode = `
+
data
.
checkResults
[
0
].
versionCode
);
console
.
log
(
`info verifyInfo = `
+
data
.
checkResults
[
0
].
verifyInfo
);
console
.
log
(
`info descriptionId = `
+
data
.
checkResults
[
0
].
descriptionId
);
console
.
log
(
`info content = `
+
data
.
descriptionInfo
[
0
].
content
);
console
.
log
(
`info size = `
+
data
.
checkResults
[
0
].
size
);
}).
catch
(
error
=>
}).
catch
(
error
=>
console
.
error
(
"
checkNewVersion error
"
+
error
)
console
.
error
(
"
checkNewVersion error
"
+
error
)
);
);
...
@@ -591,55 +510,70 @@ describe('updateclient', function() {
...
@@ -591,55 +510,70 @@ describe('updateclient', function() {
/**
/**
* @tc.number SUB_UPDATE_JS_API_0026
* @tc.number SUB_UPDATE_JS_API_0026
* @tc.name testSetUp
datePolicy001
* @tc.name testSetUp
gradePolicyAndGetUpgradePolicyCallback
* @tc.desc Test
and
set the upgrade strategy, check whether the result is correct.
* @tc.desc Test set the upgrade strategy, check whether the result is correct.
*/
*/
it
(
'
testSetUp
datePolicy001
'
,
0
,
function
()
{
it
(
'
testSetUp
gradePolicyAndGetUpgradePolicyCallback
'
,
0
,
function
()
{
console
.
info
(
'
testSetUpdatePolicy001
START
'
+
updater
);
console
.
info
(
'
UPDATE_TEST testSetUpgradePolicyAndGetUpgradePolicyCallback
START
'
+
updater
);
// Set strategy.
// Set strategy.
let
policy
=
{
let
policy
=
{
autoDownload
:
false
,
downloadStrategy
:
false
,
autoDownloadNet
:
true
,
autoUpgradeStrategy
:
false
,
mode
:
2
,
autoUpgradePeriods
:[
2
,
3
]
autoUpgradeInterval
:
[
2
,
3
],
autoUpgradeCondition
:
2
}
}
try
{
try
{
let
ret
=
updater
.
setUp
dat
ePolicy
(
policy
,
function
(
err
,
data
){
let
ret
=
updater
.
setUp
grad
ePolicy
(
policy
,
function
(
err
,
data
){
console
.
log
(
"
setUpdat
ePolicy success
"
+
data
);
console
.
log
(
"
UPDATE_TEST setUpgrad
ePolicy success
"
+
data
);
expect
(
data
).
assertEqual
(
0
);
expect
(
data
).
assertEqual
(
0
);
});
});
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
ret
=
updater
.
getUpgradePolicy
(
function
(
err
,
data
){
console
.
log
(
"
UPDATE_TEST getUpgradePolicy success
"
+
data
);
expect
(
data
.
downloadStrategy
).
assertEqual
(
false
);
expect
(
data
.
autoUpgradeStrategy
).
assertEqual
(
false
);
expect
(
data
.
autoUpgradePeriods
[
0
]).
assertEqual
(
2
);
expect
(
data
.
autoUpgradePeriods
[
1
]).
assertEqual
(
3
);
});
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
error
(
'
[testSetUpdatePolicy001
] fail.
'
+
e
);
console
.
error
(
'
UPDATE_TEST [testSetUpgradePolicyAndGetUpgradePolicyCallback
] fail.
'
+
e
);
}
}
console
.
info
(
'
[setUpdatePolicy
] success.
'
);
console
.
info
(
'
UPDATE_TEST [testSetUpgradePolicyAndGetUpgradePolicyCallback
] success.
'
);
console
.
info
(
'
testSetUpdatePolicy001
END
'
);
console
.
info
(
'
UPDATE_TEST testSetUpgradePolicyAndGetUpgradePolicyCallback
END
'
);
});
});
/**
/**
* @tc.number SUB_UPDATE_JS_API_0027
* @tc.number SUB_UPDATE_JS_API_0027
* @tc.name test
GetUpdatePolicy001
* @tc.name test
SetUpgradePolicyAndGetUpgradePolicyPromise
* @tc.desc Test
get update, policy func 001
.
* @tc.desc Test
set the upgrade strategy, check whether the result is correct
.
*/
*/
it
(
'
testGetUpdatePolicy001
'
,
0
,
function
()
{
it
(
'
testSetUpgradePolicyAndGetUpgradePolicyPromise
'
,
0
,
function
()
{
console
.
info
(
'
testGetUpdatePolicy001 START
'
);
console
.
info
(
'
UPDATE_TEST testSetUpgradePolicyAndGetUpgradePolicyPromise START
'
+
updater
);
// Set strategy.
let
policy
=
{
downloadStrategy
:
false
,
autoUpgradeStrategy
:
false
,
autoUpgradePeriods
:[
2
,
3
]
}
try
{
try
{
let
ret
=
updater
.
getUpdatePolicy
(
function
(
err
,
data
){
let
ret
=
updater
.
setUpgradePolicy
(
policy
).
then
((
err
,
data
)
=>
{
console
.
log
(
"
getUpdatePolicy success
"
+
data
);
console
.
log
(
"
UPDATE_TEST setUpgradePolicy success
"
+
data
);
expect
(
data
.
autoDownload
).
assertEqual
(
false
);
expect
(
data
).
assertEqual
(
0
);
expect
(
data
.
autoDownloadNet
).
assertEqual
(
true
);
expect
(
data
.
mode
).
assertEqual
(
2
);
expect
(
data
.
autoUpgradeInterval
[
0
]).
assertEqual
(
2
);
expect
(
data
.
autoUpgradeInterval
[
1
]).
assertEqual
(
3
);
});
});
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret
).
assertInstanceOf
(
'
Promise
'
);
ret
=
updater
.
getUpgradePolicy
().
then
((
err
,
data
)
=>
{
console
.
log
(
"
UPDATE_TEST getUpgradePolicy success
"
+
data
);
expect
(
data
.
downloadStrategy
).
assertEqual
(
false
);
expect
(
data
.
autoUpgradeStrategy
).
assertEqual
(
false
);
expect
(
data
.
autoUpgradePeriods
[
0
]).
assertEqual
(
2
);
expect
(
data
.
autoUpgradePeriods
[
1
]).
assertEqual
(
3
);
});
expect
(
ret
).
assertInstanceOf
(
'
Promise
'
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
error
(
'
[testGetUpdatePolicy001
] fail.
'
+
e
);
console
.
error
(
'
UPDATE_TEST [testSetUpgradePolicyAndGetUpgradePolicyPromise
] fail.
'
+
e
);
}
}
console
.
info
(
'
[getUpdatePolicy
] success.
'
);
console
.
info
(
'
UPDATE_TEST [testSetUpgradePolicyAndGetUpgradePolicyPromise
] success.
'
);
console
.
info
(
'
testGetUpdatePolicy001
END
'
);
console
.
info
(
'
UPDATE_TEST testSetUpgradePolicyAndGetUpgradePolicyPromise
END
'
);
});
});
/**
/**
...
@@ -650,11 +584,9 @@ describe('updateclient', function() {
...
@@ -650,11 +584,9 @@ describe('updateclient', function() {
it
(
'
testSetUpdatePolicy002
'
,
0
,
function
()
{
it
(
'
testSetUpdatePolicy002
'
,
0
,
function
()
{
console
.
info
(
'
testSetUpdatePolicy002 START
'
+
updater
);
console
.
info
(
'
testSetUpdatePolicy002 START
'
+
updater
);
let
policy
=
{
let
policy
=
{
autoDownload
:
true
,
downloadStrategy
:
true
,
autoDownloadNet
:
true
,
autoUpgradeStrategy
:
false
,
mode
:
2
,
autoUpgradePeriods
:[
2
,
3
]
autoUpgradeInterval
:
[
2
,
3
],
autoUpgradeCondition
:
2
}
}
try
{
try
{
let
ret
=
updater
.
setUpdatePolicy
(
policy
,
function
(
err
,
data
){
let
ret
=
updater
.
setUpdatePolicy
(
policy
,
function
(
err
,
data
){
...
@@ -662,6 +594,14 @@ describe('updateclient', function() {
...
@@ -662,6 +594,14 @@ describe('updateclient', function() {
expect
(
data
).
assertEqual
(
0
);
expect
(
data
).
assertEqual
(
0
);
});
});
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
ret
=
updater
.
getUpgradePolicy
(
function
(
err
,
data
){
console
.
log
(
"
UPDATE_TEST getUpgradePolicy success
"
+
data
);
expect
(
data
.
downloadStrategy
).
assertEqual
(
true
);
expect
(
data
.
autoUpgradeStrategy
).
assertEqual
(
false
);
expect
(
data
.
autoUpgradePeriods
[
0
]).
assertEqual
(
2
);
expect
(
data
.
autoUpgradePeriods
[
1
]).
assertEqual
(
3
);
});
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
error
(
'
[testSetUpdatePolicy002] fail.
'
+
e
);
console
.
error
(
'
[testSetUpdatePolicy002] fail.
'
+
e
);
}
}
...
@@ -670,31 +610,6 @@ describe('updateclient', function() {
...
@@ -670,31 +610,6 @@ describe('updateclient', function() {
console
.
info
(
'
testSetUpdatePolicy002 END
'
);
console
.
info
(
'
testSetUpdatePolicy002 END
'
);
});
});
/**
* @tc.number SUB_UPDATE_JS_API_0029
* @tc.name testGetUpdatePolicy002
* @tc.desc Get the modified strategy.
*/
it
(
'
testGetUpdatePolicy002
'
,
0
,
function
()
{
console
.
info
(
'
testGetUpdatePolicy002 START
'
);
try
{
let
ret
=
updater
.
getUpdatePolicy
(
function
(
err
,
data
){
console
.
log
(
"
getUpdatePolicy success
"
+
data
);
expect
(
data
.
autoDownload
).
assertEqual
(
true
);
expect
(
data
.
autoDownloadNet
).
assertEqual
(
true
);
expect
(
data
.
mode
).
assertEqual
(
2
);
expect
(
data
.
autoUpgradeInterval
[
0
]).
assertEqual
(
2
);
expect
(
data
.
autoUpgradeInterval
[
1
]).
assertEqual
(
3
);
});
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
}
catch
(
e
)
{
console
.
error
(
'
[testGetUpdatePolicy002] fail.
'
+
e
);
}
console
.
info
(
'
[getUpdatePolicy] success.
'
);
console
.
info
(
'
testGetUpdatePolicy002 END
'
);
});
/**
/**
* @tc.number SUB_UPDATE_JS_API_0030
* @tc.number SUB_UPDATE_JS_API_0030
* @tc.name testSetUpdatePolicy003
* @tc.name testSetUpdatePolicy003
...
@@ -704,11 +619,9 @@ describe('updateclient', function() {
...
@@ -704,11 +619,9 @@ describe('updateclient', function() {
console
.
info
(
'
testSetUpdatePolicy003 START
'
+
updater
);
console
.
info
(
'
testSetUpdatePolicy003 START
'
+
updater
);
// Set strategy.
// Set strategy.
let
policy
=
{
let
policy
=
{
autoDownload
:
false
,
downloadStrategy
:
true
,
autoDownloadNet
:
false
,
autoUpgradeStrategy
:
true
,
mode
:
2
,
autoUpgradePeriods
:[
2
,
3
]
autoUpgradeInterval
:
[
2
,
3
],
autoUpgradeCondition
:
2
}
}
try
{
try
{
let
ret
=
updater
.
setUpdatePolicy
(
policy
,
function
(
err
,
data
){
let
ret
=
updater
.
setUpdatePolicy
(
policy
,
function
(
err
,
data
){
...
@@ -716,6 +629,14 @@ describe('updateclient', function() {
...
@@ -716,6 +629,14 @@ describe('updateclient', function() {
expect
(
data
).
assertEqual
(
0
);
expect
(
data
).
assertEqual
(
0
);
})
})
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
ret
=
updater
.
getUpgradePolicy
(
function
(
err
,
data
){
console
.
log
(
"
UPDATE_TEST getUpgradePolicy success
"
+
data
);
expect
(
data
.
downloadStrategy
).
assertEqual
(
true
);
expect
(
data
.
autoUpgradeStrategy
).
assertEqual
(
true
);
expect
(
data
.
autoUpgradePeriods
[
0
]).
assertEqual
(
2
);
expect
(
data
.
autoUpgradePeriods
[
1
]).
assertEqual
(
3
);
});
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
error
(
'
[testSetUpdatePolicy003] fail.
'
+
e
);
console
.
error
(
'
[testSetUpdatePolicy003] fail.
'
+
e
);
}
}
...
@@ -723,30 +644,6 @@ describe('updateclient', function() {
...
@@ -723,30 +644,6 @@ describe('updateclient', function() {
console
.
info
(
'
testSetUpdatePolicy003 END
'
);
console
.
info
(
'
testSetUpdatePolicy003 END
'
);
});
});
/**
* @tc.number SUB_UPDATE_JS_API_0031
* @tc.name testGetUpdatePolicy003
* @tc.desc Obtain strategy mode.
*/
it
(
'
testGetUpdatePolicy003
'
,
0
,
function
()
{
console
.
info
(
'
testGetUpdatePolicy003 START
'
+
updater
);
try
{
let
ret
=
updater
.
getUpdatePolicy
(
function
(
err
,
data
){
console
.
log
(
"
getUpdatePolicy success
"
+
data
);
expect
(
data
.
autoDownload
).
assertEqual
(
false
);
expect
(
data
.
autoDownloadNet
).
assertEqual
(
false
);
expect
(
data
.
mode
).
assertEqual
(
2
);
expect
(
data
.
autoUpgradeInterval
[
0
]).
assertEqual
(
2
);
expect
(
data
.
autoUpgradeInterval
[
1
]).
assertEqual
(
3
);
})
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
}
catch
(
e
)
{
console
.
error
(
'
[testGetUpdatePolicy003] fail.
'
+
e
);
}
console
.
info
(
'
[getUpdatePolicy] success.
'
);
console
.
info
(
'
testGetUpdatePolicy003 END
'
);
});
/**
/**
* @tc.number SUB_UPDATE_JS_API_0032
* @tc.number SUB_UPDATE_JS_API_0032
* @tc.name testSetUpdatePolicy004
* @tc.name testSetUpdatePolicy004
...
@@ -756,11 +653,9 @@ describe('updateclient', function() {
...
@@ -756,11 +653,9 @@ describe('updateclient', function() {
console
.
info
(
'
testSetUpdatePolicy004 START
'
+
updater
);
console
.
info
(
'
testSetUpdatePolicy004 START
'
+
updater
);
// Set strategy.
// Set strategy.
let
policy
=
{
let
policy
=
{
autoDownload
:
false
,
downloadStrategy
:
true
,
autoDownloadNet
:
false
,
autoUpgradeStrategy
:
true
,
mode
:
1
,
autoUpgradePeriods
:[
3
,
4
]
autoUpgradeInterval
:
[
100
,
100
],
autoUpgradeCondition
:
2
}
}
try
{
try
{
let
ret
=
updater
.
setUpdatePolicy
(
policy
,
function
(
err
,
data
){
let
ret
=
updater
.
setUpdatePolicy
(
policy
,
function
(
err
,
data
){
...
@@ -768,6 +663,14 @@ describe('updateclient', function() {
...
@@ -768,6 +663,14 @@ describe('updateclient', function() {
expect
(
data
).
assertEqual
(
0
);
expect
(
data
).
assertEqual
(
0
);
})
})
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
ret
=
updater
.
getUpgradePolicy
(
function
(
err
,
data
){
console
.
log
(
"
UPDATE_TEST getUpgradePolicy success
"
+
data
);
expect
(
data
.
downloadStrategy
).
assertEqual
(
true
);
expect
(
data
.
autoUpgradeStrategy
).
assertEqual
(
true
);
expect
(
data
.
autoUpgradePeriods
[
0
]).
assertEqual
(
3
);
expect
(
data
.
autoUpgradePeriods
[
1
]).
assertEqual
(
4
);
});
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
error
(
'
[testGetUpdatePolicy003] fail.
'
+
e
);
console
.
error
(
'
[testGetUpdatePolicy003] fail.
'
+
e
);
}
}
...
@@ -775,30 +678,6 @@ describe('updateclient', function() {
...
@@ -775,30 +678,6 @@ describe('updateclient', function() {
console
.
info
(
'
testSetUpdatePolicy004 END
'
);
console
.
info
(
'
testSetUpdatePolicy004 END
'
);
});
});
/**
* @tc.number SUB_UPDATE_JS_API_0033
* @tc.name testGetUpdatePolicy004
* @tc.desc Obtain policy upgrade interval.
*/
it
(
'
testGetUpdatePolicy004
'
,
0
,
function
()
{
console
.
info
(
'
testGetUpdatePolicy004 START
'
+
updater
);
try
{
let
ret
=
updater
.
getUpdatePolicy
(
function
(
err
,
data
){
console
.
log
(
"
getUpdatePolicy success
"
+
data
);
expect
(
data
.
autoDownload
).
assertEqual
(
false
);
expect
(
data
.
autoDownloadNet
).
assertEqual
(
false
);
expect
(
data
.
mode
).
assertEqual
(
1
);
expect
(
data
.
autoUpgradeInterval
[
0
]).
assertEqual
(
expect_value
);
expect
(
data
.
autoUpgradeInterval
[
1
]).
assertEqual
(
expect_value
);
})
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
}
catch
(
e
)
{
console
.
error
(
'
[testGetUpdatePolicy004] fail.
'
+
e
);
}
console
.
info
(
'
[getUpdatePolicy] success.
'
);
console
.
info
(
'
testGetUpdatePolicy004 END
'
);
});
/**
/**
* @tc.number SUB_UPDATE_JS_API_0034
* @tc.number SUB_UPDATE_JS_API_0034
* @tc.name testSetUpdatePolicy005
* @tc.name testSetUpdatePolicy005
...
@@ -846,11 +725,9 @@ describe('updateclient', function() {
...
@@ -846,11 +725,9 @@ describe('updateclient', function() {
console
.
info
(
'
testSetUpdatePolicyPromise START
'
+
updater
);
console
.
info
(
'
testSetUpdatePolicyPromise START
'
+
updater
);
// Set strategy.
// Set strategy.
let
policy
=
{
let
policy
=
{
autoDownload
:
false
,
downloadStrategy
:
false
,
autoDownloadNet
:
true
,
autoUpgradeStrategy
:
true
,
mode
:
2
,
autoUpgradePeriods
:[
3
,
4
]
autoUpgradeInterval
:
[
2
,
3
],
autoUpgradeCondition
:
2
}
}
try
{
try
{
let
ret
=
updater
.
setUpdatePolicy
(
policy
).
then
(
data
=>
{
let
ret
=
updater
.
setUpdatePolicy
(
policy
).
then
(
data
=>
{
...
@@ -876,13 +753,11 @@ describe('updateclient', function() {
...
@@ -876,13 +753,11 @@ describe('updateclient', function() {
console
.
info
(
'
testGetUpdatePolicyPromise START
'
);
console
.
info
(
'
testGetUpdatePolicyPromise START
'
);
try
{
try
{
let
ret
=
updater
.
getUpdatePolicy
().
then
(
data
=>
{
let
ret
=
updater
.
getUpdatePolicy
().
then
(
data
=>
{
console
.
log
(
"
getUpdatePolicy success
"
+
data
);
console
.
log
(
"
UPDATE_TEST getUpgradePolicy success
"
+
data
);
expect
(
data
.
autoDownload
).
assertEqual
(
false
);
expect
(
data
.
downloadStrategy
).
assertEqual
(
false
);
expect
(
data
.
autoDownload
).
assertEqual
(
true
);
expect
(
data
.
autoUpgradeStrategy
).
assertEqual
(
true
);
expect
(
data
.
mode
).
assertEqual
(
2
);
expect
(
data
.
autoUpgradePeriods
[
0
]).
assertEqual
(
3
);
expect
(
data
.
autoUpgradeInterval
[
0
]).
assertEqual
(
2
);
expect
(
data
.
autoUpgradePeriods
[
1
]).
assertEqual
(
4
);
expect
(
data
.
autoUpgradeInterval
[
1
]).
assertEqual
(
3
);
expect
(
data
.
autoUpgradeCondition
).
assertEqual
(
2
);
}).
catch
(
error
=>
}).
catch
(
error
=>
console
.
error
(
"
getUpdatePolicy catch
"
+
error
)
console
.
error
(
"
getUpdatePolicy catch
"
+
error
)
);
);
...
@@ -902,11 +777,9 @@ describe('updateclient', function() {
...
@@ -902,11 +777,9 @@ describe('updateclient', function() {
it
(
'
testSetUpdatePolicyPromise002
'
,
0
,
function
()
{
it
(
'
testSetUpdatePolicyPromise002
'
,
0
,
function
()
{
console
.
info
(
'
testSetUpdatePolicyPromise002 START
'
+
updater
);
console
.
info
(
'
testSetUpdatePolicyPromise002 START
'
+
updater
);
let
policy
=
{
let
policy
=
{
autoDownload
:
true
,
downloadStrategy
:
false
,
autoDownloadNet
:
true
,
autoUpgradeStrategy
:
true
,
mode
:
2
,
autoUpgradePeriods
:[
1
,
2
]
autoUpgradeInterval
:
[
2
,
3
],
autoUpgradeCondition
:
2
}
}
try
{
try
{
let
ret
=
updater
.
setUpdatePolicy
(
policy
).
then
(
data
=>
{
let
ret
=
updater
.
setUpdatePolicy
(
policy
).
then
(
data
=>
{
...
@@ -932,12 +805,11 @@ describe('updateclient', function() {
...
@@ -932,12 +805,11 @@ describe('updateclient', function() {
console
.
info
(
'
testGetUpdatePolicyPromise002 START
'
);
console
.
info
(
'
testGetUpdatePolicyPromise002 START
'
);
try
{
try
{
let
ret
=
updater
.
getUpdatePolicy
().
then
(
data
=>
{
let
ret
=
updater
.
getUpdatePolicy
().
then
(
data
=>
{
console
.
log
(
"
getUpdatePolicy success
"
+
data
);
console
.
log
(
"
UPDATE_TEST getUpgradePolicy success
"
+
data
);
expect
(
data
.
autoDownload
).
assertEqual
(
true
);
expect
(
data
.
downloadStrategy
).
assertEqual
(
false
);
expect
(
data
.
autoDownloadNet
).
assertEqual
(
true
);
expect
(
data
.
autoUpgradeStrategy
).
assertEqual
(
true
);
expect
(
data
.
mode
).
assertEqual
(
2
);
expect
(
data
.
autoUpgradePeriods
[
0
]).
assertEqual
(
1
);
expect
(
data
.
autoUpgradeInterval
[
0
]).
assertEqual
(
2
);
expect
(
data
.
autoUpgradePeriods
[
1
]).
assertEqual
(
2
);
expect
(
data
.
autoUpgradeInterval
[
1
]).
assertEqual
(
3
);
});
});
expect
(
ret
!=
0
).
assertTrue
();
expect
(
ret
!=
0
).
assertTrue
();
}
catch
(
e
)
{
}
catch
(
e
)
{
...
@@ -956,11 +828,9 @@ describe('updateclient', function() {
...
@@ -956,11 +828,9 @@ describe('updateclient', function() {
console
.
info
(
'
testSetUpdatePolicyPromise003 START
'
);
console
.
info
(
'
testSetUpdatePolicyPromise003 START
'
);
// Set strategy.
// Set strategy.
let
policy
=
{
let
policy
=
{
autoDownload
:
false
,
downloadStrategy
:
false
,
autoDownloadNet
:
false
,
autoUpgradeStrategy
:
false
,
mode
:
2
,
autoUpgradePeriods
:[
1
,
2
]
autoUpgradeInterval
:
[
2
,
3
],
autoUpgradeCondition
:
2
}
}
try
{
try
{
let
ret
=
updater
.
setUpdatePolicy
(
policy
).
then
(
data
=>
{
let
ret
=
updater
.
setUpdatePolicy
(
policy
).
then
(
data
=>
{
...
@@ -986,12 +856,11 @@ describe('updateclient', function() {
...
@@ -986,12 +856,11 @@ describe('updateclient', function() {
console
.
info
(
'
testGetUpdatePolicyPromise003 START
'
);
console
.
info
(
'
testGetUpdatePolicyPromise003 START
'
);
try
{
try
{
let
ret
=
updater
.
getUpdatePolicy
().
then
(
data
=>
{
let
ret
=
updater
.
getUpdatePolicy
().
then
(
data
=>
{
console
.
log
(
"
getUpdatePolicy success
"
+
data
);
console
.
log
(
"
UPDATE_TEST getUpgradePolicy success
"
+
data
);
expect
(
data
.
autoDownload
).
assertEqual
(
false
);
expect
(
data
.
downloadStrategy
).
assertEqual
(
false
);
expect
(
data
.
autoDownloadNet
).
assertEqual
(
false
);
expect
(
data
.
autoUpgradeStrategy
).
assertEqual
(
false
);
expect
(
data
.
mode
).
assertEqual
(
2
);
expect
(
data
.
autoUpgradePeriods
[
0
]).
assertEqual
(
1
);
expect
(
data
.
autoUpgradeInterval
[
0
]).
assertEqual
(
2
);
expect
(
data
.
autoUpgradePeriods
[
1
]).
assertEqual
(
2
);
expect
(
data
.
autoUpgradeInterval
[
1
]).
assertEqual
(
3
);
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
console
.
info
(
'
[getUpdatePolicy] error
'
+
error
)
console
.
info
(
'
[getUpdatePolicy] error
'
+
error
)
})
})
...
@@ -1012,11 +881,9 @@ describe('updateclient', function() {
...
@@ -1012,11 +881,9 @@ describe('updateclient', function() {
console
.
info
(
'
testSetUpdatePolicyPromise004 START
'
+
updater
);
console
.
info
(
'
testSetUpdatePolicyPromise004 START
'
+
updater
);
// Set strategy.
// Set strategy.
let
policy
=
{
let
policy
=
{
autoDownload
:
false
,
downloadStrategy
:
false
,
autoDownloadNet
:
false
,
autoUpgradeStrategy
:
false
,
mode
:
1
,
autoUpgradePeriods
:[
2
,
3
]
autoUpgradeInterval
:
[
100
,
100
],
autoUpgradeCondition
:
2
}
}
try
{
try
{
let
ret
=
updater
.
setUpdatePolicy
(
policy
).
then
(
data
=>
{
let
ret
=
updater
.
setUpdatePolicy
(
policy
).
then
(
data
=>
{
...
@@ -1042,12 +909,11 @@ describe('updateclient', function() {
...
@@ -1042,12 +909,11 @@ describe('updateclient', function() {
console
.
info
(
'
testGetUpdatePolicyPromise004 START
'
+
updater
);
console
.
info
(
'
testGetUpdatePolicyPromise004 START
'
+
updater
);
try
{
try
{
let
ret
=
updater
.
getUpdatePolicy
().
then
(
data
=>
{
let
ret
=
updater
.
getUpdatePolicy
().
then
(
data
=>
{
console
.
log
(
"
getUpdatePolicy success
"
+
data
);
console
.
log
(
"
UPDATE_TEST getUpgradePolicy success
"
+
data
);
expect
(
data
.
autoDownload
).
assertEqual
(
false
);
expect
(
data
.
downloadStrategy
).
assertEqual
(
false
);
expect
(
data
.
autoDownloadNet
).
assertEqual
(
false
);
expect
(
data
.
autoUpgradeStrategy
).
assertEqual
(
false
);
expect
(
data
.
mode
).
assertEqual
(
1
);
expect
(
data
.
autoUpgradePeriods
[
0
]).
assertEqual
(
2
);
expect
(
data
.
autoUpgradeInterval
[
0
]).
assertEqual
(
expect_value
);
expect
(
data
.
autoUpgradePeriods
[
1
]).
assertEqual
(
3
);
expect
(
data
.
autoUpgradeInterval
[
1
]).
assertEqual
(
expect_value
);
}).
catch
(
error
=>
{
}).
catch
(
error
=>
{
console
.
info
(
'
[getUpdatePolicy] error
'
+
error
)
console
.
info
(
'
[getUpdatePolicy] error
'
+
error
)
})
})
...
@@ -1096,7 +962,8 @@ describe('updateclient', function() {
...
@@ -1096,7 +962,8 @@ describe('updateclient', function() {
console
.
info
(
'
[getUpdatePolicy] success.
'
);
console
.
info
(
'
[getUpdatePolicy] success.
'
);
console
.
info
(
'
testGetUpdatePolicyPromise005 END
'
);
console
.
info
(
'
testGetUpdatePolicyPromise005 END
'
);
});
});
/*
/**
/**
* @tc.number SUB_UPDATE_JS_API_0046
* @tc.number SUB_UPDATE_JS_API_0046
* @tc.name testDownloadVersion
* @tc.name testDownloadVersion
...
@@ -1106,19 +973,72 @@ describe('updateclient', function() {
...
@@ -1106,19 +973,72 @@ describe('updateclient', function() {
console
.
info
(
'
testDownloadVersion START
'
);
console
.
info
(
'
testDownloadVersion START
'
);
// Open download monitor.
// Open download monitor.
try
{
try
{
updater
.
on
(
'
downloadProgress
'
,
progress
=>
{
let
versionDigestInfo
=
{
console
.
log
(
"
downloadProgress on
"
+
progress
);
versionDigest
:
"
versionDigest test
"
,
console
.
log
(
`downloadProgress status: `
+
progress
.
status
);
}
console
.
log
(
`downloadProgress percent: `
+
progress
.
percent
);
let
downloadOptions
=
{
console
.
log
(
`downloadProgress endReason: `
+
progress
.
endReason
);
allowNetwork
:
1
,
if
(
progress
.
status
===
updateState
.
UPDATE_STATE_DOWNLOAD_SUCCESS
||
order
:
2
progress
.
status
===
updateState
.
UPDATE_STATE_VERIFY_SUCCESS
)
{
}
expect
(
progress
.
percent
).
assertEqual
(
expect_value
);
let
eventClassifyInfo
=
{
updater
.
off
(
"
downloadProgress
"
);
eventClassify
:
0x01000000
,
}
extraInfo
:
""
})
}
let
ret
=
updater
.
download
();
let
ret
=
updater
.
off
(
eventClassifyInfo
,
eventInfo
=>
{
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
console
.
info
(
"
UPDATE_TEST eventInfo is
"
+
JSON
.
stringify
(
eventInfo
));
});
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
ret
=
updater
.
download
(
versionDigestInfo
,
downloadOptions
,
err
=>
{
console
.
info
(
"
UPDATE_TEST error msg is
"
+
JSON
.
stringify
(
err
));
})
console
.
info
(
"
UPDATE_TEST ret is
"
+
ret
);
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
ret
=
updater
.
off
(
eventClassifyInfo
,
eventInfo
=>
{
console
.
info
(
"
UPDATE_TEST eventInfo is
"
+
JSON
.
stringify
(
eventInfo
));
});
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
}
catch
(
e
)
{
console
.
info
(
'
[testDownloadVersion] catch
'
+
e
);
}
console
.
info
(
'
[downloadVersion] success.
'
);
console
.
info
(
'
testDownloadVersion END
'
);
});
/*
/**
* @tc.number SUB_UPDATE_JS_API_0047
* @tc.name testDownloadVersionPromise
* @tc.desc Unsubscribe from monitoring.
*/
it
(
'
testDownloadVersionPromise
'
,
0
,
function
()
{
console
.
info
(
'
testDownloadVersionPromise START
'
);
// Open download monitor.
try
{
let
versionDigestInfo
=
{
versionDigest
:
"
versionDigest test
"
,
}
let
downloadOptions
=
{
allowNetwork
:
1
,
order
:
2
}
let
eventClassifyInfo
=
{
eventClassify
:
0x01000000
,
extraInfo
:
""
}
let
ret
=
updater
.
off
(
eventClassifyInfo
,
eventInfo
=>
{
console
.
info
(
"
UPDATE_TEST eventInfo is
"
+
JSON
.
stringify
(
eventInfo
));
});
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
ret
=
updater
.
download
(
versionDigestInfo
,
downloadOptions
).
then
(
err
=>
{
console
.
info
(
"
UPDATE_TEST error msg is
"
+
JSON
.
stringify
(
err
));
})
console
.
info
(
"
UPDATE_TEST ret is
"
+
ret
);
expect
(
ret
).
assertInstanceOf
(
'
Promise
'
);
ret
=
updater
.
off
(
eventClassifyInfo
,
eventInfo
=>
{
console
.
info
(
"
UPDATE_TEST eventInfo is
"
+
JSON
.
stringify
(
eventInfo
));
});
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
info
(
'
[testDownloadVersion] catch
'
+
e
);
console
.
info
(
'
[testDownloadVersion] catch
'
+
e
);
}
}
...
@@ -1131,7 +1051,7 @@ describe('updateclient', function() {
...
@@ -1131,7 +1051,7 @@ describe('updateclient', function() {
* @tc.number SUB_UPDATE_JS_API_0047
* @tc.number SUB_UPDATE_JS_API_0047
* @tc.name testDownloadVersion02
* @tc.name testDownloadVersion02
* @tc.desc Unsubscribe out of monitoring.
* @tc.desc Unsubscribe out of monitoring.
*
/
*
it('testDownloadVersion02', 0, function() {
it('testDownloadVersion02', 0, function() {
console.info('testDownloadVersion02 START');
console.info('testDownloadVersion02 START');
// Open download monitor
// Open download monitor
...
@@ -1156,6 +1076,7 @@ describe('updateclient', function() {
...
@@ -1156,6 +1076,7 @@ describe('updateclient', function() {
console.info('[downloadVersion] success.');
console.info('[downloadVersion] success.');
console.info('testDownloadVersion END');
console.info('testDownloadVersion END');
});
});
*/
/**
/**
* @tc.number SUB_UPDATE_JS_API_0048
* @tc.number SUB_UPDATE_JS_API_0048
...
@@ -1175,7 +1096,7 @@ describe('updateclient', function() {
...
@@ -1175,7 +1096,7 @@ describe('updateclient', function() {
expect
(
progress
.
percent
).
assertEqual
(
expect_value
);
expect
(
progress
.
percent
).
assertEqual
(
expect_value
);
}
}
})
})
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret
).
assertInstanceOf
(
'
Undefined
'
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
info
(
'
[testDownloadVersion03] catch
'
+
e
);
console
.
info
(
'
[testDownloadVersion03] catch
'
+
e
);
}
}
...
@@ -1193,12 +1114,12 @@ describe('updateclient', function() {
...
@@ -1193,12 +1114,12 @@ describe('updateclient', function() {
try
{
try
{
// Open download monitor.
// Open download monitor.
let
ret
=
updater
.
on
(
'
downloadProgress
'
);
let
ret
=
updater
.
on
(
'
downloadProgress
'
);
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret
).
assertInstanceOf
(
'
Undefined
'
);
let
ret_download
=
updater
.
download
();
let
ret_download
=
updater
.
download
();
expect
(
ret_download
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret_download
).
assertInstanceOf
(
'
Undefined
'
);
// Cancel subscription immediately, no callback will be received.
// Cancel subscription immediately, no callback will be received.
let
ret_off
=
updater
.
off
(
"
downloadProgress
"
);
let
ret_off
=
updater
.
off
(
"
downloadProgress
"
);
expect
(
ret_off
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret_off
).
assertInstanceOf
(
'
Undefined
'
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
info
(
'
[testDownloadVersion04] catch
'
+
e
);
console
.
info
(
'
[testDownloadVersion04] catch
'
+
e
);
}
}
...
@@ -1222,13 +1143,13 @@ describe('updateclient', function() {
...
@@ -1222,13 +1143,13 @@ describe('updateclient', function() {
try
{
try
{
// Open download monitor.
// Open download monitor.
let
ret
=
updater
.
on
(
'
downloadProgress
'
,
testFunction
);
let
ret
=
updater
.
on
(
'
downloadProgress
'
,
testFunction
);
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret
).
assertInstanceOf
(
'
Undefined
'
);
let
ret_download
=
updater
.
download
();
let
ret_download
=
updater
.
download
();
expect
(
ret_download
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret_download
).
assertInstanceOf
(
'
Undefined
'
);
// Cancel subscription immediately, no callback will be received.
// Cancel subscription immediately, no callback will be received.
let
ret_off
=
updater
.
off
(
"
downloadProgress
"
,
testFunction
);
let
ret_off
=
updater
.
off
(
"
downloadProgress
"
,
testFunction
);
expect
(
ret_off
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret_off
).
assertInstanceOf
(
'
Undefined
'
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
info
(
'
[testDownloadVersion05] catch
'
+
e
);
console
.
info
(
'
[testDownloadVersion05] catch
'
+
e
);
}
}
...
@@ -1258,7 +1179,7 @@ describe('updateclient', function() {
...
@@ -1258,7 +1179,7 @@ describe('updateclient', function() {
}
}
})
})
let
ret
=
updater
.
upgrade
();
let
ret
=
updater
.
upgrade
();
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret
).
assertInstanceOf
(
'
Undefined
'
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
info
(
'
[testUpgradeVersion01] catch
'
+
e
);
console
.
info
(
'
[testUpgradeVersion01] catch
'
+
e
);
}
}
...
@@ -1285,12 +1206,12 @@ describe('updateclient', function() {
...
@@ -1285,12 +1206,12 @@ describe('updateclient', function() {
expect
(
progress
.
percent
).
assertEqual
(
expect_value
);
expect
(
progress
.
percent
).
assertEqual
(
expect_value
);
}
}
})
})
expect
(
ret_on
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret_on
).
assertInstanceOf
(
'
Undefined
'
);
let
ret
=
updater
.
upgrade
();
let
ret
=
updater
.
upgrade
();
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret
).
assertInstanceOf
(
'
Undefined
'
);
// Cancel subscription immediately, no callback will be received.
// Cancel subscription immediately, no callback will be received.
let
ret_off
=
updater
.
off
(
"
upgradeProgress
"
);
let
ret_off
=
updater
.
off
(
"
upgradeProgress
"
);
expect
(
ret_off
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret_off
).
assertInstanceOf
(
'
Undefined
'
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
info
(
'
[testUpgradeVersion02] catch
'
+
e
);
console
.
info
(
'
[testUpgradeVersion02] catch
'
+
e
);
}
}
...
@@ -1316,7 +1237,7 @@ describe('updateclient', function() {
...
@@ -1316,7 +1237,7 @@ describe('updateclient', function() {
expect
(
progress
.
percent
).
assertEqual
(
expect_value
);
expect
(
progress
.
percent
).
assertEqual
(
expect_value
);
}
}
})
})
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret
).
assertInstanceOf
(
'
Undefined
'
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
info
(
'
[testUpgradeVersion03] catch
'
+
e
);
console
.
info
(
'
[testUpgradeVersion03] catch
'
+
e
);
}
}
...
@@ -1334,12 +1255,12 @@ describe('updateclient', function() {
...
@@ -1334,12 +1255,12 @@ describe('updateclient', function() {
try
{
try
{
// Open download monitor.
// Open download monitor.
let
ret
=
updater
.
on
(
'
upgradeProgress
'
);
let
ret
=
updater
.
on
(
'
upgradeProgress
'
);
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret
).
assertInstanceOf
(
'
Undefined
'
);
let
ret_upgrade
=
updater
.
upgrade
();
let
ret_upgrade
=
updater
.
upgrade
();
expect
(
ret_upgrade
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret_upgrade
).
assertInstanceOf
(
'
Undefined
'
);
// Cancel subscription immediately, no callback will be received.
// Cancel subscription immediately, no callback will be received.
let
ret_off
=
updater
.
off
(
"
upgradeProgress
"
);
let
ret_off
=
updater
.
off
(
"
upgradeProgress
"
);
expect
(
ret_off
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret_off
).
assertInstanceOf
(
'
Undefined
'
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
info
(
'
[testUpgradeVersion04] catch
'
+
e
);
console
.
info
(
'
[testUpgradeVersion04] catch
'
+
e
);
}
}
...
@@ -1362,13 +1283,13 @@ describe('updateclient', function() {
...
@@ -1362,13 +1283,13 @@ describe('updateclient', function() {
console
.
info
(
'
testUpgradeVersion05 START
'
);
console
.
info
(
'
testUpgradeVersion05 START
'
);
try
{
try
{
let
ret
=
updater
.
on
(
'
upgradeProgress
'
,
testFunction
);
let
ret
=
updater
.
on
(
'
upgradeProgress
'
,
testFunction
);
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret
).
assertInstanceOf
(
'
Undefined
'
);
let
ret_upgrade
=
updater
.
upgrade
();
let
ret_upgrade
=
updater
.
upgrade
();
expect
(
ret_upgrade
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret_upgrade
).
assertInstanceOf
(
'
Undefined
'
);
let
ret_off
=
updater
.
off
(
"
upgradeProgress
"
,
testFunction
);
let
ret_off
=
updater
.
off
(
"
upgradeProgress
"
,
testFunction
);
expect
(
ret_off
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret_off
).
assertInstanceOf
(
'
Undefined
'
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
info
(
'
[testUpgradeVersion05] catch
'
+
e
);
console
.
info
(
'
[testUpgradeVersion05] catch
'
+
e
);
}
}
...
@@ -1487,7 +1408,7 @@ describe('updateclient', function() {
...
@@ -1487,7 +1408,7 @@ describe('updateclient', function() {
console
.
info
(
'
testOffDownload2 START
'
);
console
.
info
(
'
testOffDownload2 START
'
);
try
{
try
{
let
ret
=
updater
.
off
(
"
333333333
"
);
let
ret
=
updater
.
off
(
"
333333333
"
);
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret
).
assertInstanceOf
(
'
Undefined
'
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
info
(
'
[testOffDownload2] catch
'
+
e
);
console
.
info
(
'
[testOffDownload2] catch
'
+
e
);
}
}
...
@@ -1555,7 +1476,7 @@ describe('updateclient', function() {
...
@@ -1555,7 +1476,7 @@ describe('updateclient', function() {
console
.
info
(
'
testOnUpgrade START
'
);
console
.
info
(
'
testOnUpgrade START
'
);
try
{
try
{
let
ret
=
updater
.
on
(
"
upgradeProgress
"
,
function
(){});
let
ret
=
updater
.
on
(
"
upgradeProgress
"
,
function
(){});
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret
).
assertInstanceOf
(
'
Undefined
'
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
info
(
'
[testOnUpgrade] catch
'
+
e
);
console
.
info
(
'
[testOnUpgrade] catch
'
+
e
);
}
}
...
@@ -1640,7 +1561,7 @@ describe('updateclient', function() {
...
@@ -1640,7 +1561,7 @@ describe('updateclient', function() {
console
.
info
(
'
testOffUpgrade START
'
);
console
.
info
(
'
testOffUpgrade START
'
);
try
{
try
{
let
ret
=
updater
.
off
(
"
upgradeProgress
"
);
let
ret
=
updater
.
off
(
"
upgradeProgress
"
);
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret
).
assertInstanceOf
(
'
Undefined
'
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
info
(
'
[testOffUpgrade] catch
'
+
e
);
console
.
info
(
'
[testOffUpgrade] catch
'
+
e
);
}
}
...
@@ -1716,109 +1637,6 @@ describe('updateclient', function() {
...
@@ -1716,109 +1637,6 @@ describe('updateclient', function() {
console
.
info
(
'
testOffUpgrade5 END
'
);
console
.
info
(
'
testOffUpgrade5 END
'
);
});
});
/**
* @tc.number SUB_UPDATE_JS_API_0076
* @tc.name testCancelDownload
* @tc.desc Test Cancel download.
*/
it
(
'
testCancelDownload
'
,
0
,
function
()
{
console
.
info
(
'
testCancelDownload START
'
);
try
{
let
ret
=
updater
.
cancel
();
console
.
info
(
'
updater.cancelUpgrade
'
+
ret
);
expect
(
ret
===
0
).
assertTrue
();
}
catch
(
e
)
{
console
.
info
(
'
[cancel] catch
'
+
e
);
}
console
.
info
(
'
[cancel] success.
'
);
console
.
info
(
'
testCancelDownload END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0077
* @tc.name testCancelDownload2
* @tc.desc Test Cancel download.
*/
it
(
'
testCancelDownload2
'
,
0
,
function
()
{
console
.
info
(
'
testCancelDownload2 START
'
);
try
{
// Open download monitor.
updater
.
on
(
'
downloadProgress
'
,
progress
=>
{
console
.
log
(
"
downloadProgress on
"
+
progress
);
console
.
log
(
`downloadProgress status: `
+
progress
.
status
);
console
.
log
(
`downloadProgress percent: `
+
progress
.
percent
);
console
.
log
(
`downloadProgress endReason: `
+
progress
.
endReason
);
if
(
progress
.
status
===
updateState
.
UPDATE_STATE_DOWNLOAD_SUCCESS
||
progress
.
status
===
updateState
.
UPDATE_STATE_VERIFY_SUCCESS
)
{
expect
(
progress
.
percent
).
assertEqual
(
expect_value
);
updater
.
off
(
"
downloadProgress
"
);
}
})
let
ret
=
updater
.
download
();
expect
(
ret
===
0
).
assertTrue
();
ret
=
updater
.
cancel
();
console
.
info
(
'
updater.cancel
'
+
ret
);
expect
(
ret
===
0
).
assertTrue
();
}
catch
(
e
)
{
console
.
info
(
'
[cancel] catch
'
+
e
);
}
console
.
info
(
'
[cancel] success.
'
);
console
.
info
(
'
testCancelDownload2 END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0078
* @tc.name testCancelDownload3
* @tc.desc Test Cancel download.
*/
it
(
'
testCancelDownload3
'
,
0
,
function
()
{
console
.
info
(
'
testCancelDownload3 START
'
);
try
{
let
ret
=
updater
.
cancel
();
console
.
info
(
'
updater.cancel
'
+
ret
);
expect
(
ret
===
0
).
assertTrue
();
}
catch
(
e
)
{
console
.
info
(
'
[cancel] catch
'
+
e
);
}
console
.
info
(
'
[cancel] success.
'
);
console
.
info
(
'
testCancelDownload3 END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0079
* @tc.name testCancelDownload4
* @tc.desc Test Cancel download.
*/
it
(
'
testCancelDownload4
'
,
0
,
function
()
{
console
.
info
(
'
testCancelDownload4 START
'
);
try
{
let
ret
=
updater
.
cancel
(
""
);
console
.
info
(
'
updater.cancel
'
+
ret
);
expect
(
ret
===
undefined
).
assertTrue
();
}
catch
(
e
)
{
console
.
info
(
'
[cancel] catch
'
+
e
);
}
console
.
info
(
'
[cancel] success.
'
);
console
.
info
(
'
testCancelDownload4 END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0080
* @tc.name testCancelDownload5
* @tc.desc Test Cancel download.
*/
it
(
'
testCancelDownload5
'
,
0
,
function
()
{
console
.
info
(
'
testCancelDownload5 START
'
);
try
{
let
ret
=
updater
.
cancel
(
function
(){});
console
.
info
(
'
updater.cancel
'
+
ret
);
expect
(
ret
===
undefined
).
assertTrue
();
}
catch
(
e
)
{
console
.
info
(
'
[cancel] catch
'
+
e
);
}
console
.
info
(
'
[cancelUpgrade] success.
'
);
console
.
info
(
'
testCancelDownload5 END
'
);
});
/**
/**
* @tc.number SUB_UPDATE_JS_API_0081
* @tc.number SUB_UPDATE_JS_API_0081
* @tc.name testVerifyVersion
* @tc.name testVerifyVersion
...
@@ -1910,11 +1728,11 @@ describe('updateclient', function() {
...
@@ -1910,11 +1728,11 @@ describe('updateclient', function() {
console
.
info
(
'
testVerifyVersion04 START
'
);
console
.
info
(
'
testVerifyVersion04 START
'
);
try
{
try
{
let
ret
=
updater
.
on
(
'
verifyProgress
'
);
let
ret
=
updater
.
on
(
'
verifyProgress
'
);
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret
).
assertInstanceOf
(
'
Undefined
'
);
let
ret_verify
=
updater
.
verifyUpdatePackage
();
let
ret_verify
=
updater
.
verifyUpdatePackage
();
expect
(
ret_verify
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret_verify
).
assertInstanceOf
(
'
Undefined
'
);
let
ret_off
=
updater
.
off
(
"
verifyProgress
"
);
let
ret_off
=
updater
.
off
(
"
verifyProgress
"
);
expect
(
ret_off
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret_off
).
assertInstanceOf
(
'
Undefined
'
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
info
(
'
[testVerifyVersion04] catch
'
+
e
);
console
.
info
(
'
[testVerifyVersion04] catch
'
+
e
);
}
}
...
@@ -1937,11 +1755,11 @@ describe('updateclient', function() {
...
@@ -1937,11 +1755,11 @@ describe('updateclient', function() {
console
.
info
(
'
testVerifyVersion05 START
'
);
console
.
info
(
'
testVerifyVersion05 START
'
);
try
{
try
{
let
ret
=
updater
.
on
(
'
verifyProgress
'
,
testFunction
);
let
ret
=
updater
.
on
(
'
verifyProgress
'
,
testFunction
);
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret
).
assertInstanceOf
(
'
Undefined
'
);
let
ret_verify
=
updater
.
verifyUpdatePackage
(
'
/data/updater/updater.zip
'
,
'
/data/updater/HwOUC/update_auth.sa
'
);
let
ret_verify
=
updater
.
verifyUpdatePackage
(
'
/data/updater/updater.zip
'
,
'
/data/updater/HwOUC/update_auth.sa
'
);
expect
(
ret_verify
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret_verify
).
assertInstanceOf
(
'
Number
'
);
let
ret_off
=
updater
.
off
(
"
verifyProgress
"
,
testFunction
);
let
ret_off
=
updater
.
off
(
"
verifyProgress
"
,
testFunction
);
expect
(
ret_off
).
assertInstanceOf
(
'
Number
'
);
expect
(
ret_off
).
assertInstanceOf
(
'
Undefined
'
);
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
info
(
'
[testVerifyVersion05] catch
'
+
e
);
console
.
info
(
'
[testVerifyVersion05] catch
'
+
e
);
}
}
...
@@ -2069,4 +1887,648 @@ describe('updateclient', function() {
...
@@ -2069,4 +1887,648 @@ describe('updateclient', function() {
console
.
info
(
'
[client.getUpdaterFromOther] success.
'
);
console
.
info
(
'
[client.getUpdaterFromOther] success.
'
);
console
.
info
(
'
testGetUpdaterFromOther END
'
);
console
.
info
(
'
testGetUpdaterFromOther END
'
);
});
});
/**
* @tc.number SUB_UPDATE_JS_API_0092
* @tc.name testPauseDownloadCallback
* @tc.desc Test PauseDownload Callback Type
*/
it
(
'
testPauseDownloadCallback
'
,
0
,
function
()
{
console
.
info
(
'
UPDATE_TEST testPauseDownloadCallback START
'
);
try
{
if
(
updater
===
undefined
)
{
updater
=
client
.
getOnlineUpdater
(
upgradeInfo
);
}
let
versionDigestInfo
=
{
versionDigest
:
"
versionDigest pasue
"
}
let
pauseDownloadOptions
=
{
isAllowAutoResume
:
true
}
let
ret
=
updater
.
pauseDownload
(
versionDigestInfo
,
pauseDownloadOptions
,
err
=>
{
console
.
info
(
"
UPDATE_TEST error msg is
"
+
JSON
.
stringify
(
err
));
})
console
.
info
(
"
UPDATE_TEST ret is
"
+
ret
);
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
}
catch
(
e
)
{
console
.
error
(
'
UPDATE_TEST [testPauseDownloadCallback] fail.
'
+
e
);
}
console
.
info
(
'
UPDATE_TEST [client.testPauseDownloadCallback] success.
'
);
console
.
info
(
'
UPDATE_TEST testPauseDownloadCallback END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0093
* @tc.name testPauseDownloadPromise
* @tc.desc Test PauseDownload promise Type
*/
it
(
'
testPauseDownloadPromise
'
,
0
,
function
()
{
console
.
info
(
'
UPDATE_TEST testPauseDownloadPromise START
'
);
try
{
if
(
updater
===
undefined
)
{
updater
=
client
.
getOnlineUpdater
(
upgradeInfo
);
}
let
versionDigestInfo
=
{
versionDigest
:
"
versionDigest pasue
"
}
let
pauseDownloadOptions
=
{
isAllowAutoResume
:
true
}
let
ret
=
updater
.
pauseDownload
(
versionDigestInfo
,
pauseDownloadOptions
).
then
(
err
=>
{
console
.
info
(
"
UPDATE_TEST error msg is
"
+
JSON
.
stringify
(
err
));
})
console
.
info
(
"
UPDATE_TEST ret is
"
+
ret
);
expect
(
ret
).
assertInstanceOf
(
'
Promise
'
);
}
catch
(
e
)
{
console
.
error
(
'
UPDATE_TEST [testPauseDownloadPromise] fail.
'
+
e
);
}
console
.
info
(
'
UPDATE_TEST [client.testPauseDownloadPromise] success.
'
);
console
.
info
(
'
UPDATE_TEST testPauseDownloadPromise END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0094
* @tc.name testUpgradeCallback
* @tc.desc Test testUpgrade Callback Type
*/
it
(
'
testUpgradeCallback
'
,
0
,
function
()
{
console
.
info
(
'
UPDATE_TEST testUpgradeCallback START
'
);
try
{
if
(
updater
===
undefined
)
{
updater
=
client
.
getOnlineUpdater
(
upgradeInfo
);
}
let
versionDigestInfo
=
{
versionDigest
:
"
versionDigest pasue
"
}
let
upgradeOptions
=
{
order
:
1
}
let
eventClassifyInfo
=
{
eventClassify
:
0x01000000
,
extraInfo
:
""
}
let
ret
=
updater
.
off
(
eventClassifyInfo
,
eventInfo
=>
{
console
.
info
(
"
UPDATE_TEST eventInfo is
"
+
JSON
.
stringify
(
eventInfo
));
});
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
ret
=
updater
.
upgrade
(
versionDigestInfo
,
upgradeOptions
,
err
=>
{
console
.
info
(
"
UPDATE_TEST error msg is
"
+
JSON
.
stringify
(
err
));
})
console
.
info
(
"
UPDATE_TEST ret is
"
+
ret
);
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
ret
=
updater
.
off
(
eventClassifyInfo
,
eventInfo
=>
{
console
.
info
(
"
UPDATE_TEST eventInfo is
"
+
JSON
.
stringify
(
eventInfo
));
});
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
}
catch
(
e
)
{
console
.
error
(
'
UPDATE_TEST [testUpgradeCallback] fail.
'
+
e
);
}
console
.
info
(
'
UPDATE_TEST [client.testUpgradeCallback] success.
'
);
console
.
info
(
'
UPDATE_TEST testUpgradeCallback END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0095
* @tc.name testUpgradePromise
* @tc.desc Test testUpgrade promise Type
*/
it
(
'
testUpgradePromise
'
,
0
,
function
()
{
console
.
info
(
'
UPDATE_TEST testUpgradePromise START
'
);
try
{
if
(
updater
===
undefined
)
{
updater
=
client
.
getOnlineUpdater
(
upgradeInfo
);
}
let
versionDigestInfo
=
{
versionDigest
:
"
versionDigest pasue
"
}
let
upgradeOptions
=
{
order
:
1
}
let
eventClassifyInfo
=
{
eventClassify
:
0x01000000
,
extraInfo
:
""
}
let
ret
=
updater
.
off
(
eventClassifyInfo
,
eventInfo
=>
{
console
.
info
(
"
UPDATE_TEST eventInfo is
"
+
JSON
.
stringify
(
eventInfo
));
});
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
ret
=
updater
.
upgrade
(
versionDigestInfo
,
upgradeOptions
).
then
(
err
=>
{
console
.
info
(
"
UPDATE_TEST error msg is
"
+
JSON
.
stringify
(
err
));
});
console
.
info
(
"
UPDATE_TEST ret is
"
+
ret
);
expect
(
ret
).
assertInstanceOf
(
'
Promise
'
);
ret
=
updater
.
off
(
eventClassifyInfo
,
eventInfo
=>
{
console
.
info
(
"
UPDATE_TEST eventInfo is
"
+
JSON
.
stringify
(
eventInfo
));
});
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
}
catch
(
e
)
{
console
.
error
(
'
UPDATE_TEST [testUpgradePromise] fail.
'
+
e
);
}
console
.
info
(
'
UPDATE_TEST [client.testUpgradePromise] success.
'
);
console
.
info
(
'
UPDATE_TEST testUpgradePromise END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0096
* @tc.name testClearErrorCallback
* @tc.desc Test testClearError Callback Type
*/
it
(
'
testUpgradeCallback
'
,
0
,
function
()
{
console
.
info
(
'
UPDATE_TEST testClearErrorCallback START
'
);
try
{
if
(
updater
===
undefined
)
{
updater
=
client
.
getOnlineUpdater
(
upgradeInfo
);
}
let
versionDigestInfo
=
{
versionDigest
:
"
versionDigest clearError
"
}
let
clearOptions
=
{
status
:
1
}
let
ret
=
updater
.
upgrade
(
versionDigestInfo
,
clearOptions
,
err
=>
{
console
.
info
(
"
UPDATE_TEST error msg is
"
+
JSON
.
stringify
(
err
));
})
expect
(
ret
).
assertInstanceOf
(
'
Undefined
'
);
}
catch
(
e
)
{
console
.
error
(
'
UPDATE_TEST [testClearErrorCallback] fail.
'
+
e
);
}
console
.
info
(
'
UPDATE_TEST [client.testClearErrorCallback] success.
'
);
console
.
info
(
'
UPDATE_TEST testClearErrorCallback END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0097
* @tc.name testClearErrorPromise
* @tc.desc Test testClearError promise Type
*/
it
(
'
testClearErrorPromise
'
,
0
,
function
()
{
console
.
info
(
'
UPDATE_TEST testClearErrorPromise START
'
);
try
{
if
(
updater
===
undefined
)
{
updater
=
client
.
getOnlineUpdater
(
upgradeInfo
);
}
let
versionDigestInfo
=
{
versionDigest
:
"
versionDigest clearError
"
}
let
clearOptions
=
{
status
:
1
}
let
ret
=
updater
.
upgrade
(
versionDigestInfo
,
clearOptions
).
then
(
err
=>
{
console
.
info
(
"
UPDATE_TEST error msg is
"
+
JSON
.
stringify
(
err
));
});
expect
(
ret
).
assertInstanceOf
(
'
Promise
'
);
}
catch
(
e
)
{
console
.
error
(
'
UPDATE_TEST [testClearErrorPromise] fail.
'
+
e
);
}
console
.
info
(
'
UPDATE_TEST [client.testClearErrorPromise] success.
'
);
console
.
info
(
'
UPDATE_TEST testClearErrorPromise END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0098
* @tc.name testterminateUpgradeCallback
* @tc.desc Test testterminateUpgrade Callback Type
*/
it
(
'
testterminateUpgradeCallback
'
,
0
,
function
()
{
console
.
info
(
'
UPDATE_TEST testterminateUpgradeCallback START
'
);
try
{
let
ret
=
updater
.
terminateUpgrade
(
function
(
result
){
console
.
info
(
"
UPDATE_TEST testterminateUpgradeCallback result is
"
+
result
);
});
console
.
info
(
"
UPDATE_TEST testterminateUpgradeCallback ret is
"
+
ret
);
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
}
catch
(
e
)
{
console
.
error
(
'
UPDATE_TEST [testterminateUpgradeCallback] fail.
'
+
e
);
}
console
.
info
(
'
UPDATE_TEST [client.testterminateUpgradeCallback] success.
'
);
console
.
info
(
'
UPDATE_TEST testterminateUpgradeCallback END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0099
* @tc.name testterminateUpgradePromise
* @tc.desc Test testterminateUpgrade Promise Type
*/
it
(
'
testterminateUpgradePromise
'
,
0
,
function
()
{
console
.
info
(
'
UPDATE_TEST testterminateUpgradePromise START
'
);
try
{
let
ret
=
updater
.
terminateUpgrade
().
then
((
result
)
=>
{
console
.
info
(
"
UPDATE_TEST testterminateUpgradePromise result is
"
+
result
);
});
console
.
info
(
"
UPDATE_TEST testterminateUpgradePromise ret is
"
+
ret
);
expect
(
ret
).
assertInstanceOf
(
'
Promise
'
);
}
catch
(
e
)
{
console
.
error
(
'
UPDATE_TEST [testterminateUpgradePromise] fail.
'
+
e
);
}
console
.
info
(
'
UPDATE_TEST [client.testterminateUpgradePromise] success.
'
);
console
.
info
(
'
UPDATE_TEST testterminateUpgradePromise END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0100
* @tc.name testGetRestorer
* @tc.desc Test GetRestorer API
*/
it
(
'
testGetRestorer
'
,
0
,
function
()
{
console
.
info
(
'
UPDATE_TEST testGetRestorer START
'
);
try
{
let
ret
=
updater
.
getRestorer
();
console
.
info
(
"
UPDATE_TEST testGetRestorer ret is
"
+
ret
);
expect
(
ret
).
assertInstanceOf
(
'
Restorer
'
);
}
catch
(
e
)
{
console
.
error
(
'
UPDATE_TEST [testGetRestorer] fail.
'
+
e
);
}
console
.
info
(
'
UPDATE_TEST [client.testGetRestorer] success.
'
);
console
.
info
(
'
UPDATE_TEST testGetRestorer END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0101
* @tc.name testFactoryResetCallback
* @tc.desc Test testFactoryResetCallback API
*/
it
(
'
testFactoryResetCallback
'
,
0
,
function
()
{
console
.
info
(
'
UPDATE_TEST testFactoryResetCallback START
'
);
try
{
let
restorer
=
updater
.
getRestorer
();
console
.
info
(
"
UPDATE_TEST testFactoryResetCallback restorer is
"
+
restorer
);
expect
(
restorer
).
assertInstanceOf
(
'
Restorer
'
);
let
ret
=
restorer
.
factoryReset
((
result
)
=>
{
console
.
info
(
"
UPDATE_TEST testFactoryResetCallback result is
"
+
result
);
})
console
.
info
(
"
UPDATE_TEST testFactoryResetCallback ret is
"
+
ret
);
expect
(
ret
).
assertInstanceOf
(
'
Undefined
'
);
}
catch
(
e
)
{
console
.
error
(
'
UPDATE_TEST [testFactoryResetCallback] fail.
'
+
e
);
}
console
.
info
(
'
UPDATE_TEST [client.testFactoryResetCallback] success.
'
);
console
.
info
(
'
UPDATE_TEST testFactoryResetCallback END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0102
* @tc.name testFactoryResetPromise
* @tc.desc Test testFactoryResetPromise API
*/
it
(
'
testFactoryResetPromise
'
,
0
,
function
()
{
console
.
info
(
'
UPDATE_TEST testFactoryResetPromise START
'
);
try
{
let
restorer
=
updater
.
getRestorer
();
console
.
info
(
"
UPDATE_TEST testFactoryResetPromise restorer is
"
+
restorer
);
expect
(
restorer
).
assertInstanceOf
(
'
Restorer
'
);
let
ret
=
restorer
.
factoryReset
().
then
((
result
)
=>
{
console
.
info
(
"
UPDATE_TEST testFactoryResetPromise result is
"
+
result
);
});
console
.
info
(
"
UPDATE_TEST testFactoryResetPromise ret is
"
+
ret
);
expect
(
ret
).
assertInstanceOf
(
'
Promise
'
);
}
catch
(
e
)
{
console
.
error
(
'
UPDATE_TEST [testFactoryResetPromise] fail.
'
+
e
);
}
console
.
info
(
'
UPDATE_TEST [client.testFactoryResetPromise] success.
'
);
console
.
info
(
'
UPDATE_TEST testFactoryResetPromise END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0103
* @tc.name testGetLocalUpdater
* @tc.desc Test GetRestorer API
*/
it
(
'
testGetLocalUpdater
'
,
0
,
function
()
{
console
.
info
(
'
UPDATE_TEST testGetLocalUpdater START
'
);
try
{
let
restorer
=
updater
.
getRestorer
();
console
.
info
(
"
UPDATE_TEST testGetLocalUpdater restorer is
"
+
restorer
);
expect
(
restorer
).
assertInstanceOf
(
'
Restorer
'
);
let
ret
=
restorer
.
getLocalUpdater
();
console
.
info
(
"
UPDATE_TEST testGetLocalUpdater ret is
"
+
ret
);
expect
(
ret
).
assertInstanceOf
(
'
LocalUpdater
'
);
}
catch
(
e
)
{
console
.
error
(
'
UPDATE_TEST [testGetLocalUpdater] fail.
'
+
e
);
}
console
.
info
(
'
UPDATE_TEST [client.testGetLocalUpdater] success.
'
);
console
.
info
(
'
UPDATE_TEST testGetLocalUpdater END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0104
* @tc.name testVerifyUpgradePackageCallback
* @tc.desc Test GetRestorer API
*/
it
(
'
testVerifyVersionerifyUpgradePackageCallback
'
,
0
,
function
()
{
console
.
info
(
'
UPDATE_TEST testVerifyVersionerifyUpgradePackageCallback START
'
);
try
{
let
restorer
=
updater
.
getRestorer
();
console
.
info
(
"
UPDATE_TEST testVerifyVersionerifyUpgradePackageCallback restorer is
"
+
restorer
);
expect
(
restorer
).
assertInstanceOf
(
'
Restorer
'
);
let
localUpdater
=
restorer
.
getLocalUpdater
();
console
.
info
(
"
UPDATE_TEST testVerifyVersionerifyUpgradePackageCallback localUpdater is
"
+
localUpdater
);
expect
(
localUpdater
).
assertInstanceOf
(
'
LocalUpdater
'
);
let
file
=
{
filePath
:
"
/data/ota_package/updater.zip
"
,
fileType
:
1
};
let
ret
=
localUpdater
.
verifyUpgradePackage
(
file
,
'
/data/ota_package/signing_cert.crt
'
,(
result
)
=>
{
console
.
info
(
"
UPDATE_TEST testVerifyVersionerifyUpgradePackageCallback result is
"
+
result
);
})
console
.
info
(
"
UPDATE_TEST testVerifyVersionerifyUpgradePackageCallback ret is
"
+
ret
);
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
}
catch
(
e
)
{
console
.
error
(
'
UPDATE_TEST [testVerifyVersionerifyUpgradePackageCallback] fail.
'
+
e
);
}
console
.
info
(
'
UPDATE_TEST [client.testVerifyVersionerifyUpgradePackageCallback] success.
'
);
console
.
info
(
'
UPDATE_TEST testVerifyVersionerifyUpgradePackageCallback END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0105
* @tc.name testVerifyUpgradePackagePromise
* @tc.desc Test GetRestorer API
*/
it
(
'
testVerifyUpgradePackagePromise
'
,
0
,
function
()
{
console
.
info
(
'
UPDATE_TEST testVerifyUpgradePackagePromise START
'
);
try
{
let
restorer
=
updater
.
getRestorer
();
console
.
info
(
"
UPDATE_TEST testVerifyUpgradePackagePromise restorer is
"
+
restorer
);
expect
(
restorer
).
assertInstanceOf
(
'
Restorer
'
);
let
localUpdater
=
restorer
.
getLocalUpdater
();
console
.
info
(
"
UPDATE_TEST testVerifyUpgradePackagePromise localUpdater is
"
+
localUpdater
);
expect
(
localUpdater
).
assertInstanceOf
(
'
LocalUpdater
'
);
let
file
=
{
filePath
:
"
/data/ota_package/updater.zip
"
,
fileType
:
1
};
let
ret
=
localUpdater
.
verifyUpgradePackage
(
file
,
'
/data/ota_package/signing_cert.crt
'
).
then
((
result
)
=>
{
console
.
info
(
"
UPDATE_TEST testVerifyUpgradePackagePromise result is
"
+
result
);
})
console
.
info
(
"
UPDATE_TEST testVerifyUpgradePackagePromise ret is
"
+
ret
);
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
}
catch
(
e
)
{
console
.
error
(
'
UPDATE_TEST [testVerifyUpgradePackagePromise] fail.
'
+
e
);
}
console
.
info
(
'
UPDATE_TEST [client.testVerifyUpgradePackagePromise] success.
'
);
console
.
info
(
'
UPDATE_TEST testVerifyUpgradePackagePromise END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0106
* @tc.name testApplyNewVersionCallback
* @tc.desc Test GetRestorer API
*/
it
(
'
testApplyNewVersionCallback
'
,
0
,
function
()
{
console
.
info
(
'
UPDATE_TEST testApplyNewVersionCallback START
'
);
try
{
let
restorer
=
updater
.
getRestorer
();
console
.
info
(
"
UPDATE_TEST testApplyNewVersionCallback restorer is
"
+
restorer
);
expect
(
restorer
).
assertInstanceOf
(
'
Restorer
'
);
let
localUpdater
=
restorer
.
getLocalUpdater
();
console
.
info
(
"
UPDATE_TEST testApplyNewVersionCallback localUpdater is
"
+
localUpdater
);
expect
(
localUpdater
).
assertInstanceOf
(
'
LocalUpdater
'
);
let
files
=
[{
filePath
:
"
/data/ota_package/updater1.zip
"
,
fileType
:
1
},
{
filePath
:
"
/data/ota_package/updater2.zip
"
,
fileType
:
4
}];
let
ret
=
localUpdater
.
applyNewVersion
(
files
,(
result
)
=>
{
console
.
info
(
"
UPDATE_TEST testApplyNewVersionCallback result is
"
+
result
);
})
console
.
info
(
"
UPDATE_TEST testApplyNewVersionCallback ret is
"
+
ret
);
expect
(
ret
).
assertInstanceOf
(
'
Undefined
'
);
}
catch
(
e
)
{
console
.
error
(
'
UPDATE_TEST [testApplyNewVersionCallback] fail.
'
+
e
);
}
console
.
info
(
'
UPDATE_TEST [client.testApplyNewVersionCallback] success.
'
);
console
.
info
(
'
UPDATE_TEST testApplyNewVersionCallback END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0107
* @tc.name testApplyNewVersionPromise
* @tc.desc Test GetRestorer API
*/
it
(
'
testApplyNewVersionPromise
'
,
0
,
function
()
{
console
.
info
(
'
UPDATE_TEST testApplyNewVersionPromise START
'
);
try
{
let
restorer
=
updater
.
getRestorer
();
console
.
info
(
"
UPDATE_TEST testApplyNewVersionPromise restorer is
"
+
restorer
);
expect
(
restorer
).
assertInstanceOf
(
'
Restorer
'
);
let
localUpdater
=
restorer
.
getLocalUpdater
();
console
.
info
(
"
UPDATE_TEST testApplyNewVersionPromise localUpdater is
"
+
localUpdater
);
expect
(
localUpdater
).
assertInstanceOf
(
'
LocalUpdater
'
);
let
files
=
[{
filePath
:
"
/data/ota_package/updater1.zip
"
,
fileType
:
1
},
{
filePath
:
"
/data/ota_package/updater2.zip
"
,
fileType
:
4
}];
let
ret
=
localUpdater
.
applyNewVersion
(
files
).
then
((
result
)
=>
{
console
.
info
(
"
UPDATE_TEST testApplyNewVersionPromise result is
"
+
result
);
})
console
.
info
(
"
UPDATE_TEST testApplyNewVersionPromise ret is
"
+
ret
);
expect
(
ret
).
assertInstanceOf
(
'
Promise
'
);
}
catch
(
e
)
{
console
.
error
(
'
UPDATE_TEST [testApplyNewVersionPromise] fail.
'
+
e
);
}
console
.
info
(
'
UPDATE_TEST [client.testApplyNewVersionPromise] success.
'
);
console
.
info
(
'
UPDATE_TEST testApplyNewVersionPromise END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0108
* @tc.name testGetCurrentVersionInfoCallback
* @tc.desc Test GetUpdater API
*/
it
(
'
testGetCurrentVersionInfoCallback
'
,
0
,
function
()
{
console
.
info
(
'
UPDATE_TEST testGetCurrentVersionInfoCallback START
'
);
try
{
let
ret
=
updater
.
getCurrentVersionInfo
((
err
,
result
)
=>
{
console
.
info
(
"
UPDATE_TEST error msg is
"
+
err
);
console
.
info
(
"
UPDATE_TEST testGetCurrentVersionInfoCallback result is
"
+
result
);
});
console
.
info
(
"
UPDATE_TEST testGetCurrentVersionInfoCallback ret is
"
+
ret
);
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
}
catch
(
e
)
{
console
.
error
(
'
UPDATE_TEST [testGetCurrentVersionInfoCallback] fail.
'
+
e
);
}
console
.
info
(
'
UPDATE_TEST [client.testGetCurrentVersionInfoCallback] success.
'
);
console
.
info
(
'
UPDATE_TEST testGetCurrentVersionInfoCallback END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0109
* @tc.name testGetCurrentVersionInfoPromise
* @tc.desc Test GetUpdater API
*/
it
(
'
testGetCurrentVersionInfoPromise
'
,
0
,
function
()
{
console
.
info
(
'
UPDATE_TEST testGetCurrentVersionInfoPromise START
'
);
try
{
let
ret
=
updater
.
getCurrentVersionInfo
().
then
((
err
,
result
)
=>
{
console
.
info
(
"
UPDATE_TEST error msg is
"
+
err
);
console
.
info
(
"
UPDATE_TEST testGetCurrentVersionInfoPromise result is
"
+
result
);
});
console
.
info
(
"
UPDATE_TEST testGetCurrentVersionInfoPromise ret is
"
+
ret
);
expect
(
ret
).
assertInstanceOf
(
'
Promise
'
);
}
catch
(
e
)
{
console
.
error
(
'
UPDATE_TEST [testGetCurrentVersionInfoPromise] fail.
'
+
e
);
}
console
.
info
(
'
UPDATE_TEST [client.testGetCurrentVersionInfoPromise] success.
'
);
console
.
info
(
'
UPDATE_TEST testGetCurrentVersionInfoPromise END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0110
* @tc.name testResumeDownloadCallback
* @tc.desc Test GetUpdater API
*/
it
(
'
testResumeDownloadCallback
'
,
0
,
function
()
{
console
.
info
(
'
UPDATE_TEST testResumeDownloadCallback START
'
);
try
{
let
versionDigestInfo
=
{
versionDigest
:
"
versionDigest resume
"
}
let
resumeDownloadOptions
=
{
allowNetwork
:
1
}
let
ret
=
updater
.
resumeDownload
(
versionDigestInfo
,
resumeDownloadOptions
,
(
err
)
=>
{
console
.
info
(
"
UPDATE_TEST error msg is
"
+
err
);
});
console
.
info
(
"
UPDATE_TEST testResumeDownloadCallback ret is
"
+
ret
);
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
}
catch
(
e
)
{
console
.
error
(
'
UPDATE_TEST [testResumeDownloadCallback] fail.
'
+
e
);
}
console
.
info
(
'
UPDATE_TEST [client.testResumeDownloadCallback] success.
'
);
console
.
info
(
'
UPDATE_TEST testResumeDownloadCallback END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0111
* @tc.name testResumeDownloadPromise
* @tc.desc Test GetUpdater API
*/
it
(
'
testResumeDownloadPromise
'
,
0
,
function
()
{
console
.
info
(
'
UPDATE_TEST testResumeDownloadPromise START
'
);
try
{
let
versionDigestInfo
=
{
versionDigest
:
"
versionDigest resume
"
}
let
resumeDownloadOptions
=
{
allowNetwork
:
1
}
let
ret
=
updater
.
resumeDownload
(
versionDigestInfo
,
resumeDownloadOptions
).
then
((
err
)
=>
{
console
.
info
(
"
UPDATE_TEST error msg is
"
+
err
);
});
console
.
info
(
"
UPDATE_TEST testResumeDownloadPromise ret is
"
+
ret
);
expect
(
ret
).
assertInstanceOf
(
'
Promise
'
);
}
catch
(
e
)
{
console
.
error
(
'
UPDATE_TEST [testResumeDownloadPromise] fail.
'
+
e
);
}
console
.
info
(
'
UPDATE_TEST [client.testResumeDownloadPromise] success.
'
);
console
.
info
(
'
UPDATE_TEST testResumeDownloadPromise END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0112
* @tc.name testLocalUpdaterOn
* @tc.desc Test GetLocalUpdater API
*/
it
(
'
testLocalUpdaterOn
'
,
0
,
function
()
{
console
.
info
(
'
UPDATE_TEST testLocalUpdaterOn START
'
);
try
{
let
restorer
=
updater
.
getRestorer
();
console
.
info
(
"
UPDATE_TEST testLocalUpdaterOn restorer is
"
+
restorer
);
expect
(
restorer
).
assertInstanceOf
(
'
Restorer
'
);
let
localUpdater
=
restorer
.
getLocalUpdater
();
console
.
info
(
"
UPDATE_TEST testLocalUpdaterOn localUpdater is
"
+
localUpdater
);
expect
(
localUpdater
).
assertInstanceOf
(
'
LocalUpdater
'
);
let
eventClassifyInfo
=
{
eventClassify
:
0x01000000
,
extraInfo
:
""
};
let
ret
=
localUpdater
.
on
(
eventClassifyInfo
,
(
eventInfo
)
=>
{
console
.
info
(
"
UPDATE_TEST testLocalUpdaterOn eventInfo is
"
+
eventInfo
);
});
console
.
info
(
"
UPDATE_TEST testLocalUpdaterOn ret is
"
+
ret
);
expect
(
ret
).
assertInstanceOf
(
'
Undefined
'
);
}
catch
(
e
)
{
console
.
error
(
'
UPDATE_TEST [testLocalUpdaterOn] fail.
'
+
e
);
}
console
.
info
(
'
UPDATE_TEST [client.testLocalUpdaterOn] success.
'
);
console
.
info
(
'
UPDATE_TEST testLocalUpdaterOn END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0113
* @tc.name testLocalUpdaterOff
* @tc.desc Test GetLocalUpdater API
*/
it
(
'
testLocalUpdaterOff
'
,
0
,
function
()
{
console
.
info
(
'
UPDATE_TEST testLocalUpdaterOff START
'
);
try
{
let
restorer
=
updater
.
getRestorer
();
console
.
info
(
"
UPDATE_TEST testLocalUpdaterOff restorer is
"
+
restorer
);
expect
(
restorer
).
assertInstanceOf
(
'
Restorer
'
);
let
localUpdater
=
restorer
.
getLocalUpdater
();
console
.
info
(
"
UPDATE_TEST testLocalUpdaterOff localUpdater is
"
+
localUpdater
);
expect
(
localUpdater
).
assertInstanceOf
(
'
LocalUpdater
'
);
let
eventClassifyInfo
=
{
eventClassify
:
0x01000000
,
extraInfo
:
""
};
let
ret
=
localUpdater
.
off
(
eventClassifyInfo
,
(
eventInfo
)
=>
{
console
.
info
(
"
UPDATE_TEST testLocalUpdaterOff eventInfo is
"
+
eventInfo
);
});
console
.
info
(
"
UPDATE_TEST testLocalUpdaterOff ret is
"
+
ret
);
expect
(
ret
).
assertInstanceOf
(
'
Undefined
'
);
}
catch
(
e
)
{
console
.
error
(
'
UPDATE_TEST [testLocalUpdaterOff] fail.
'
+
e
);
}
console
.
info
(
'
UPDATE_TEST [client.testLocalUpdaterOff] success.
'
);
console
.
info
(
'
UPDATE_TEST testLocalUpdaterOff END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0114
* @tc.name testGetTaskInfoCallback
* @tc.desc Test GetUpdater API
*/
it
(
'
testGetTaskInfoCallback
'
,
0
,
function
()
{
console
.
info
(
'
UPDATE_TEST testGetTaskInfoCallback START
'
);
try
{
let
ret
=
updater
.
getTaskInfo
((
err
,
result
)
=>
{
console
.
info
(
"
UPDATE_TEST error msg is
"
+
err
);
console
.
info
(
"
UPDATE_TEST result is
"
+
result
);
});
console
.
info
(
"
UPDATE_TEST testGetTaskInfoCallback ret is
"
+
ret
);
expect
(
ret
).
assertInstanceOf
(
'
Number
'
);
}
catch
(
e
)
{
console
.
error
(
'
UPDATE_TEST [testGetTaskInfoCallback] fail.
'
+
e
);
}
console
.
info
(
'
UPDATE_TEST [client.testGetTaskInfoCallback] success.
'
);
console
.
info
(
'
UPDATE_TEST testGetTaskInfoCallback END
'
);
});
/**
* @tc.number SUB_UPDATE_JS_API_0115
* @tc.name testGetTaskInfoPromise
* @tc.desc Test GetUpdater API
*/
it
(
'
testGetTaskInfoPromise
'
,
0
,
function
()
{
console
.
info
(
'
UPDATE_TEST testGetTaskInfoPromise START
'
);
try
{
let
ret
=
updater
.
getTaskInfo
().
then
((
err
,
result
)
=>
{
console
.
info
(
"
UPDATE_TEST error msg is
"
+
err
);
console
.
info
(
"
UPDATE_TEST result is
"
+
result
);
});
console
.
info
(
"
UPDATE_TEST testGetTaskInfoPromise ret is
"
+
ret
);
expect
(
ret
).
assertInstanceOf
(
'
Promise
'
);
}
catch
(
e
)
{
console
.
error
(
'
UPDATE_TEST [testGetTaskInfoPromise] fail.
'
+
e
);
}
console
.
info
(
'
UPDATE_TEST [client.testGetTaskInfoPromise] success.
'
);
console
.
info
(
'
UPDATE_TEST testGetTaskInfoPromise END
'
);
});
});
});
鸿蒙社区
@harmonycommunity
mentioned in commit
293bc4a6
·
7月 15, 2022
mentioned in commit
293bc4a6
mentioned in commit 293bc4a67e9cb83b33f5d0d15d484e0da0a7a729
开关提交列表
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录