Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
519d67c5
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看板
未验证
提交
519d67c5
编写于
12月 06, 2022
作者:
O
openharmony_ci
提交者:
Gitee
12月 06, 2022
浏览文件
操作
浏览文件
下载
差异文件
!6777 电话服务register用例整改
Merge pull request !6777 from zhangfuzhi/cherry-pick-1669963077
上级
b475e6e5
dc4d23ab
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
1296 addition
and
2545 deletion
+1296
-2545
telephony/telephonyjstest/netmanager_base/register/src/main/js/test/NetworkManagerRegister.test.js
.../register/src/main/js/test/NetworkManagerRegister.test.js
+1296
-2479
telephony/telephonyjstest/observer/entry/src/main/ets/test/ObserverJsunit.test.ets
.../observer/entry/src/main/ets/test/ObserverJsunit.test.ets
+0
-66
未找到文件。
telephony/telephonyjstest/netmanager_base/register/src/main/js/test/NetworkManagerRegister.test.js
浏览文件 @
519d67c5
/**
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Copyright (C) 2021
-2022
Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
...
...
@@ -13,2523 +13,1340 @@
* limitations under the License.
*/
import
connection
from
'
@ohos.net.connection
'
;
import
{
describe
,
expect
,
it
}
from
'
@ohos/hypium
'
;
import
connection
from
'
@ohos.net.connection
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
export
default
function
Telephony_NetworkManagerRegisterTest
()
{
describe
(
'
Telephony_NetworkManagerRegisterTest
'
,
function
()
{
const
ETH_100
=
100
;
const
TEST_RUN_TIME_2
=
2
;
const
TEST_RUN_TIME_5
=
5
;
const
TEST_RUN_TIME_1000
=
1000
;
const
DELAY
=
1000
;
const
DELAY_TIME
=
1000
;
const
TIMEOUT
=
100
;
const
TIMEOUT_1
=
1000
;
let
VALUE
=
0
;
let
envReady
=
false
;
function
sleep
(
timeout
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
setTimeout
(()
=>
{
resolve
();
},
timeout
);
})
}
function
sleepOther
(
timeout
)
{
for
(
var
t
=
Date
.
now
();
Date
.
now
()
-
t
<=
timeout
;)
;
}
/**
*@tc.number Telephony_NetworkManager_register_Async_0100
*@tc.name Enter bearerTypes and networkCap asempty, set class NetConnection,
* call Register() to activate the default network, and see if the callback information is generated
@tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_0100
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_0100
'
;
let
netConn
=
connection
.
createNetConnection
();
let
returnValue
=
0
;
netConn
.
on
(
'
netAvailable
'
,
(
value
)
=>
{
if
(
value
===
undefined
)
{
console
.
info
(
"
${caseName} on netAvailable fail
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable :
"
+
value
.
netId
);
returnValue
=
value
.
netId
;
}
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
(
value
)
=>
{
if
(
value
===
undefined
)
{
console
.
info
(
"
${caseName} netCapabilitiesChange fail
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle =:
"
+
value
.
netHandle
.
netId
);
expect
(
value
.
netHandle
.
netId
>=
ETH_100
).
assertTrue
();
}
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
value
)
=>
{
if
(
value
===
undefined
)
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange fail
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netLost
'
,
(
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} netLost fail
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost:
"
+
value
.
netId
);
}
});
netConn
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
JSON
.
stringify
(
error
)
+
"
${caseName} register fail: ${error}
"
);
done
();
}
});
await
sleep
(
DELAY
);
console
.
info
(
"
${caseName} returnVaule :
"
+
returnValue
);
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
done
();
}
done
();
});
done
();
});
export
default
function
Telephony_NetworkManagerRegisterTest
()
{
/**
*@tc.number Telephony_NetworkManager_register_Async_0200
*@tc.name Enter bearerTypes and networkCap asempty, set class NetConnection,
* call Register() to activate the default network, and see if the callback information is generated
@tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_0200
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_0200
'
;
let
netSpecifier
=
{
netCapabilities
:
{
bearerTypes
:
[
1
],
}
}
let
netId
=
0
;
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
on
(
'
netAvailable
'
,
(
value
)
=>
{
if
(
value
===
undefined
)
{
console
.
info
(
"
${caseName} on netAvailable fail
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable :
"
+
value
.
netId
);
returnValue
=
value
.
netId
;
}
});
console
.
info
(
"
netAvailable end
"
);
netConn
.
on
(
'
netCapabilitiesChange
'
,
(
value
)
=>
{
if
(
value
===
undefined
)
{
console
.
info
(
"
${caseName} netCapabilitiesChange fail
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle =:
"
+
value
.
netHandle
.
netId
);
expect
(
value
.
netHandle
.
netId
>=
ETH_100
).
assertTrue
();
describe
(
'
Telephony_NetworkManagerRegisterTest
'
,
function
()
{
}
});
console
.
info
(
"
netCapabilitiesChange end
"
);
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
value
)
=>
{
if
(
value
===
undefined
)
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange fail
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle =:
"
+
value
.
netHandle
.
netId
);
}
});
console
.
info
(
"
netConnectionPropertiesChange end
"
);
netConn
.
on
(
'
netLost
'
,
(
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} netLost fail
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost :
"
+
value
.
netId
);
}
});
console
.
info
(
"
netLost end
"
);
netConn
.
on
(
'
netUnavailable
'
,
(
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} netUnavailable fail
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable:
"
+
value
.
netId
);
}
});
console
.
info
(
"
netUnavailable end
"
);
netConn
.
on
(
'
netBlockStatuschange
'
,
(
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} netBlockStatusChange fail
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange :
"
+
value
.
netHandle
.
netId
);
}
});
console
.
info
(
"
netBlockStatuschange end
"
);
netConn
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
}
});
console
.
info
(
"
register end
"
);
await
sleep
(
DELAY
);
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregisterresult: ${error}
"
+
JSON
.
stringify
(
error
));
done
();
}
});
console
.
info
(
"
unregister end
"
);
done
();
});
const
TIMEOUT
=
1000
;
/*
*@tc.number Telephony_NetworkManager_register_Async_0300
*@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection,
* call Register ()to activate the default network,and see if the callback information is generated
*@tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_0300
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_0300
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
0
],
networkCap
:
[
11
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netId
=
0
;
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable:
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost = :
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable = :
"
+
value
);
netId
=
true
;
}
});
netConn
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
}
});
await
sleep
(
DELAY
);
console
.
info
(
"
${caseName} netId : ${netId}
"
);
expect
(
true
).
assertTrue
()
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result: ${error}
"
);
}
});
done
();
});
/**
* @tc.number Telephony_NetworkManager_register_Async_0100
* @tc.name Enter bearerTypes and networkCap asempty, set class NetConnection,
* call Register() to activate the default network, and see if the callback information is generated
@tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_0100
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_0100
'
;
let
netConn
=
connection
.
createNetConnection
();
netConn
.
register
(
function
(
error
)
{
console
.
log
(
"
Telephony_NetworkManager_register_Async_0100 register
"
);
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
return
;
}
netConn
.
on
(
'
netAvailable
'
,
function
(
value
)
{
console
.
log
(
"
netAvailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netCapabilitiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netConnectionPropertiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netLost
'
,
function
(
value
)
{
console
.
log
(
"
netLost
"
+
JSON
.
stringify
(
value
));
});
console
.
log
(
"
Telephony_NetworkManager_register_Async_0100 netLost end
"
);
console
.
log
(
"
Telephony_NetworkManager_register_Async_0100 unregister start
"
);
netConn
.
unregister
(
function
(
error
)
{
console
.
log
(
"
Telephony_NetworkManager_register_Async_0100 unregister
"
);
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
}
done
();
});
});
});
/*
*@tc.number Telephony_NetworkManager_register_Async_0400
*@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection,
* call Register ()to activate the default network,and see if the callback information is generated
*@tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_0400
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_0400
'
;
let
netId
=
0
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
0
],
networkCap
:
[
12
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable:
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost = :
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable = :
"
+
value
);
netId
=
true
;
}
});
netConn
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
}
});
await
sleep
(
DELAY
);
expect
(
true
).
assertTrue
()
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result: ${error.code},${error.message}
"
);
}
});
done
();
});
/**
* @tc.number Telephony_NetworkManager_register_Async_0200
* @tc.name Enter bearerTypes and networkCap asempty, set class NetConnection,
* call Register() to activate the default network, and see if the callback information is generated
@tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_0200
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_0200
'
;
let
netSpecifier
=
{
netCapabilities
:
{
bearerTypes
:
[
1
],
}
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
done
();
return
;
}
netConn
.
on
(
'
netAvailable
'
,
function
(
value
)
{
console
.
log
(
"
netAvailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netCapabilitiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netConnectionPropertiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netLost
'
,
function
(
value
)
{
console
.
log
(
"
netLost
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netUnavailable
'
,
function
(
value
)
{
console
.
log
(
"
netUnavailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netBlockStatusChange
'
,
function
(
value
)
{
console
.
log
(
"
netBlockStatusChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregisterresult:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
}
done
();
});
});
});
/*
*@tc.number Telephony_NetworkManager_register_Async_0500
*@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection,
* call Register() to activate the default network,and see if the callback information is generated
*@tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_0500
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_rgister_Async_0500
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
0
],
networkCap
:
[
15
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netId
=
0
;
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable:
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost = :
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable = :
"
+
value
);
netId
=
true
;
}
});
netConn
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
}
});
await
sleep
(
DELAY
);
expect
(
true
).
assertTrue
()
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result: ${error}
"
);
}
done
();
});
done
();
});
/*
*@tc.number Telephony_NetworkManager_register_Async_0300
*@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection,
* call Register ()to activate the default network,and see if the callback information is generated
*@tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_0300
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_0300
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
0
],
networkCap
:
[
11
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
done
();
return
;
}
netConn
.
on
(
'
netAvailable
'
,
function
(
value
)
{
console
.
log
(
"
netAvailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netBlockStatusChange
'
,
function
(
value
)
{
console
.
log
(
"
netBlockStatusChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netCapabilitiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netConnectionPropertiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netLost
'
,
function
(
value
)
{
console
.
log
(
"
netLost
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netUnavailable
'
,
function
(
value
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
value
));
});
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregister result:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
}
done
();
});
});
});
/*
*@tc.number Telephony_NetworkManager_register_Async_0600
*@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection,
* call Register() to activate the default network,and see if the callback information is generated
*@tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_0600
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_rgister_Async_0600
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
0
],
networkCap
:
[
16
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
let
netId
=
0
;
netConn
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable:
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost = :
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable = :
"
+
value
);
netId
=
true
;
}
});
netConn
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
}
});
await
sleep
(
DELAY
);
expect
(
true
).
assertTrue
()
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result: ${error}
"
);
}
done
();
});
done
();
});
/*
*@tc.number Telephony_NetworkManager_register_Async_0400
*@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection,
* call Register ()to activate the default network,and see if the callback information is generated
*@tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_0400
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_0400
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
0
],
networkCap
:
[
12
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
done
();
return
;
}
netConn
.
on
(
'
netAvailable
'
,
function
(
value
)
{
console
.
log
(
"
netAvailable
"
+
JSON
.
stringify
(
value
))
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netCapabilitiesChange
"
+
JSON
.
stringify
(
value
))
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netConnectionPropertiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netLost
'
,
function
(
value
)
{
console
.
log
(
"
netLost
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netUnavailable
'
,
function
(
value
)
{
console
.
log
(
"
netUnavailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netBlockStatusChange
'
,
function
(
value
)
{
console
.
log
(
"
netBlockStatusChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregisterresult:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
}
done
();
});
});
});
/*
*@tc.number Telephony_NetworkManager_register_Async_0700
*@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection,
* call Register() to activate the default network,and see if the callback information is generated
*@tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_0700
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_rgister_Async_0700
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
0
],
networkCap
:
[
17
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
let
netId
=
0
;
netConn
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable:
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost = :
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable = :
"
+
value
);
netId
=
true
;
}
});
netConn
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
}
});
await
sleep
(
DELAY
);
expect
(
true
).
assertTrue
()
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result: ${error}
"
);
}
done
();
});
done
();
});
/*
*@tc.number Telephony_NetworkManager_register_Async_0500
*@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection,
* call Register() to activate the default network,and see if the callback information is generated
*@tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_0500
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_rgister_Async_0500
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
0
],
networkCap
:
[
15
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
done
();
return
;
}
netConn
.
on
(
'
netAvailable
'
,
function
(
value
)
{
console
.
log
(
"
netAvailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netCapabilitiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netConnectionPropertiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netLost
'
,
function
(
value
)
{
console
.
log
(
"
netLost
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netUnavailable
'
,
function
(
value
)
{
console
.
log
(
"
netUnavailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netBlockStatusChange
'
,
function
(
value
)
{
console
.
log
(
"
netBlockStatusChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregister result:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
}
done
();
});
});
});
/*
*@tc.number Telephony_NetworkManager_register_Async_0800
*@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection,
* call Register() to activate the default network,and see if the callback information is generated
*@tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_0800
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_rgister_Async_0800
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
1
],
networkCap
:
[
0
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
let
netId
=
0
;
netConn
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable:
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost = :
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable = :
"
+
value
);
netId
=
true
;
}
});
netConn
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
}
});
await
sleep
(
DELAY
);
expect
(
true
).
assertTrue
()
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result: ${error}
"
);
}
done
();
});
done
();
});
/*
*@tc.number Telephony_NetworkManager_register_Async_0600
*@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection,
* call Register() to activate the default network,and see if the callback information is generated
*@tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_0600
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_rgister_Async_0600
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
0
],
networkCap
:
[
16
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
done
();
return
;
}
netConn
.
on
(
'
netAvailable
'
,
function
(
value
)
{
console
.
log
(
"
netAvailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netCapabilitiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netConnectionPropertiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netLost
'
,
function
(
value
)
{
console
.
log
(
"
netLost
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netUnavailable
'
,
function
(
value
)
{
console
.
log
(
"
netUnavailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netBlockStatusChange
'
,
function
(
value
)
{
console
.
log
(
"
netBlockStatusChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregisterresult:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
}
done
();
});
});
});
/*
*@tc.number Telephony_NetworkManager_register_Async_0900
*@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection,
* call Register() to activate the default network,and see if the callback information is generated
*@tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_0900
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_rgister_Async_0900
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
1
],
networkCap
:
[
12
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
let
netId
=
0
;
netConn
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable:
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
expect
(
value
.
netHandle
.
netId
>=
ETH_100
).
assertTrue
();
}
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle = :
"
+
value
.
netHandle
.
netId
);
expect
(
value
.
netHandle
.
netId
>=
ETH_100
).
assertTrue
();
}
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
expect
(
value
.
netHandle
.
netId
>=
ETH_100
).
assertTrue
();
}
});
netConn
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost = :
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable = :
"
+
value
);
netId
=
true
;
}
});
netConn
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
}
});
await
sleep
(
10000
);
expect
(
true
).
assertTrue
()
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result: ${error}
"
);
}
done
();
});
done
();
});
/*
*@tc.number Telephony_NetworkManager_register_Async_0700
*@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection,
* call Register() to activate the default network,and see if the callback information is generated
*@tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_0700
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_rgister_Async_0700
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
0
],
networkCap
:
[
17
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
done
();
return
;
}
netConn
.
on
(
'
netAvailable
'
,
function
(
value
)
{
console
.
log
(
"
netAvailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netBlockStatusChange
'
,
function
(
value
)
{
console
.
log
(
"
netBlockStatusChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netCapabilitiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netConnectionPropertiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netLost
'
,
function
(
value
)
{
console
.
log
(
"
netLost
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netUnavailable
'
,
function
(
value
)
{
console
.
log
(
"
netUnavailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregister result:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
}
done
();
});
});
});
/*
*@tc.number Telephony_NetworkManager_register_Async_1000
*@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection,
* call Register() to activate the default network,and see if the callback information is generated
*@tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_1000
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_rgister_Async_1000
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
1
],
networkCap
:
[
12
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
let
netId
=
0
;
netConn
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable:
"
+
value
.
netId
);
expect
(
value
.
netId
>=
ETH_100
).
assertTrue
();
}
});
netConn
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
expect
(
value
.
netHandle
.
netId
>=
ETH_100
).
assertTrue
();
}
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
expect
(
value
.
netHandle
.
netId
>=
ETH_100
).
assertTrue
();
}
});
netConn
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost = :
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable = :
"
+
value
);
netId
=
true
;
}
});
netConn
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
}
});
await
sleep
(
DELAY
);
expect
(
true
).
assertTrue
()
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result: ${error}
"
);
}
done
();
});
done
();
});
/*
*@tc.number Telephony_NetworkManager_register_Async_0800
*@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection,
* call Register() to activate the default network,and see if the callback information is generated
*@tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_0800
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_rgister_Async_0800
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
1
],
networkCap
:
[
0
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
done
();
return
;
}
netConn
.
on
(
'
netAvailable
'
,
function
(
value
)
{
console
.
log
(
"
netAvailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netBlockStatusChange
'
,
function
(
value
)
{
console
.
log
(
"
netBlockStatusChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netCapabilitiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netConnectionPropertiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netLost
'
,
function
(
value
)
{
console
.
log
(
"
netLost
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netUnavailable
'
,
function
(
value
)
{
console
.
log
(
"
netUnavailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregister result:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
}
done
();
});
});
});
/*
*@tc.number Telephony_NetworkManager_register_Async_0900
*@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection,
* call Register() to activate the default network,and see if the callback information is generated
*@tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_0900
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_rgister_Async_0900
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
1
],
networkCap
:
[
12
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
done
();
return
;
}
netConn
.
on
(
'
netAvailable
'
,
function
(
value
)
{
console
.
log
(
"
netAvailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netBlockStatusChange
'
,
function
(
value
)
{
console
.
log
(
"
netBlockStatusChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netCapabilitiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netCapabilitiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netLost
'
,
function
(
value
)
{
console
.
log
(
"
netLost
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netUnavailable
'
,
function
(
value
)
{
console
.
log
(
"
netUnavailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregister result:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
}
done
();
});
});
});
/**
* @tc.number Telephony_NetworkManager_register_Async_1100
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
/*
*@tc.number Telephony_NetworkManager_register_Async_1000
*@tc.name Enter bearerTypes and networkCap as empty, set class NetConnection,
* call Register() to activate the default network,and see if the callback information is generated
*@tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_1000
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_rgister_Async_1000
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
1
],
networkCap
:
[
12
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
done
();
return
;
}
netConn
.
on
(
'
netAvailable
'
,
function
(
value
)
{
console
.
log
(
"
netAvailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netBlockStatusChange
'
,
function
(
value
)
{
console
.
log
(
"
netBlockStatusChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netCapabilitiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netConnectionPropertiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netLost
'
,
function
(
value
)
{
console
.
log
(
"
netLost
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netUnavailable
'
,
function
(
value
)
{
console
.
log
(
"
netUnavailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregister result:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
}
done
();
});
});
});
it
(
'
Telephony_NetworkManager_register_Async_1100
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_1100
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
1
],
networkCap
:
[
15
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netId
=
0
;
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable :
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
expect
(
value
.
netHandle
.
netId
>=
ETH_100
).
assertTrue
();
}
});
netConn
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable
"
+
value
.
netId
);
netId
=
true
;
}
});
netConn
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail ${error}
"
);
}
});
await
sleep
(
DELAY
);
expect
(
true
).
assertTrue
()
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result : ${error}
"
);
}
done
();
});
done
();
});
/**
* @tc.number Telephony_NetworkManager_register_Async_1100
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
/**
* @tc.number Telephony_NetworkManager_register_Async_1200
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_1100
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_1100
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
1
],
networkCap
:
[
15
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
done
();
return
;
}
netConn
.
on
(
'
netAvailable
'
,
function
(
value
)
{
console
.
log
(
"
netAvailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netBlockStatusChange
'
,
function
(
value
)
{
console
.
log
(
"
netBlockStatusChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netCapabilitiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netConnectionPropertiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netLost
'
,
function
(
value
)
{
console
.
log
(
"
netLost
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netUnavailable
'
,
function
(
value
)
{
console
.
log
(
"
netUnavailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregister result:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
}
done
();
});
});
});
it
(
'
Telephony_NetworkManager_register_Async_1200
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_1200
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
1
],
networkCap
:
[
16
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netId
=
0
;
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable :
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
expect
(
value
.
netHandle
.
netId
>=
ETH_100
).
assertTrue
();
}
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle = :
"
+
value
.
netHandle
.
netId
);
expect
(
value
.
netHandle
.
netId
>=
ETH_100
).
assertTrue
();
}
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable
"
+
value
.
netId
);
netId
=
true
;
}
});
netConn
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail ${error}
"
);
}
});
await
sleep
(
DELAY
);
expect
(
true
).
assertTrue
()
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result : ${error}
"
);
}
done
();
});
done
();
});
/**
* @tc.number Telephony_NetworkManager_register_Async_1200
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_1200
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_1200
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
1
],
networkCap
:
[
16
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
done
();
return
;
}
netConn
.
on
(
'
netAvailable
'
,
function
(
value
)
{
console
.
log
(
"
netAvailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netBlockStatusChange
'
,
function
(
value
)
{
console
.
log
(
"
netBlockStatusChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netCapabilitiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netConnectionPropertiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netLost
'
,
function
(
value
)
{
console
.
log
(
"
netLost
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netUnavailable
'
,
function
(
value
)
{
console
.
log
(
"
netUnavailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregister result:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
}
done
();
});
});
});
/**
* @tc.number Telephony_NetworkManager_register_Async_1300
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_1300
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_1300
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
1
],
networkCap
:
[
17
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable :
"
+
value
.
netId
);
expect
(
value
.
netId
).
assertEqual
(
ETH_100
);
}
});
netConn
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
expect
(
value
.
netHandle
.
netId
>=
ETH_100
).
assertTrue
();
}
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle = :
"
+
value
.
netHandle
.
netId
);
expect
(
value
.
netHandle
.
netId
>=
ETH_100
).
assertTrue
();
}
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
expect
(
value
.
netHandle
.
netId
>=
ETH_100
).
assertTrue
();
}
});
netConn
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable
"
+
value
);
}
});
netConn
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail ${error}
"
);
}
});
await
sleep
(
DELAY
);
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result : ${error}
"
);
}
done
();
});
done
();
});
/**
* @tc.number Telephony_NetworkManager_register_Async_1300
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_1300
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_1300
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
1
],
networkCap
:
[
17
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
done
();
return
;
}
netConn
.
on
(
'
netAvailable
'
,
function
(
value
)
{
console
.
log
(
"
netAvailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netBlockStatusChange
'
,
function
(
value
)
{
console
.
log
(
"
netBlockStatusChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netCapabilitiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netConnectionPropertiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netLost
'
,
function
(
value
)
{
console
.
log
(
"
netLost
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netUnavailable
'
,
function
(
value
)
{
console
.
log
(
"
netUnavailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregister result:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
}
done
();
});
});
});
/**
* @tc.number Telephony_NetworkManager_register_Async_1400
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_1400
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_1400
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
2
],
networkCap
:
[
12
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netId
=
0
;
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable :
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable
"
+
value
.
netId
);
netId
=
true
;
}
});
netConn
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail ${error}
"
);
}
});
await
sleep
(
DELAY
);
expect
(
true
).
assertTrue
()
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result : ${error}
"
);
}
done
();
});
done
();
});
/**
* @tc.number Telephony_NetworkManager_register_Async_1400
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
/**
* @tc.number Telephony_NetworkManager_register_Async_1500
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_1400
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_1400
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
2
],
networkCap
:
[
12
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
done
();
return
;
}
netConn
.
on
(
'
netAvailable
'
,
function
(
value
)
{
console
.
log
(
"
netAvailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netBlockStatusChange
'
,
function
(
value
)
{
console
.
log
(
"
netBlockStatusChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netCapabilitiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netConnectionPropertiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netLost
'
,
function
(
value
)
{
console
.
log
(
"
netLost
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netUnavailable
'
,
function
(
value
)
{
console
.
log
(
"
netUnavailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregister result:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
}
done
();
});
});
});
it
(
'
Telephony_NetworkManager_register_Async_1500
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_1500
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
3
],
networkCap
:
[
12
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable :
"
+
value
.
netId
);
VALUE
=
value
.
netId
;
expect
(
VALUE
>=
ETH_100
).
assertTrue
();
}
});
netConn
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable
"
+
value
);
}
});
netConn
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail ${error}
"
);
}
});
await
sleep
(
DELAY
);
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result : ${error}
"
);
}
done
();
});
done
();
});
/**
* @tc.number Telephony_NetworkManager_register_Async_1500
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_1500
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_1500
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
3
],
networkCap
:
[
12
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
done
();
return
;
}
netConn
.
on
(
'
netAvailable
'
,
function
(
value
)
{
console
.
log
(
"
netAvailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netBlockStatusChange
'
,
function
(
value
)
{
console
.
log
(
"
netBlockStatusChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netCapabilitiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netConnectionPropertiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netLost
'
,
function
(
value
)
{
console
.
log
(
"
netLost
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netUnavailable
'
,
function
(
value
)
{
console
.
log
(
"
netUnavailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregister result:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
}
done
();
});
});
});
/**
* @tc.number Telephony_NetworkManager_register_Async_1600
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_1600
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_1600
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
4
],
networkCap
:
[
12
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netId
=
0
;
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable :
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable
"
+
value
);
netId
=
true
;
}
});
netConn
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail ${error}
"
);
}
});
await
sleep
(
DELAY
);
expect
(
true
).
assertTrue
()
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result : ${error}
"
);
}
done
();
});
done
();
});
/**
* @tc.number Telephony_NetworkManager_register_Async_1600
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
/**
* @tc.number Telephony_NetworkManager_register_Async_1700
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_1600
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_1600
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
4
],
networkCap
:
[
12
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
done
();
return
;
}
netConn
.
on
(
'
netAvailable
'
,
function
(
value
)
{
console
.
log
(
"
netAvailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netBlockStatusChange
'
,
function
(
value
)
{
console
.
log
(
"
netBlockStatusChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netCapabilitiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netConnectionPropertiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netLost
'
,
function
(
value
)
{
console
.
log
(
"
netLost
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netUnavailable
'
,
function
(
value
)
{
console
.
log
(
"
netUnavailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregister result:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
}
done
();
});
});
});
it
(
'
Telephony_NetworkManager_register_Async_1700
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_1700
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
5
],
networkCap
:
[
17
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netId
=
0
;
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable :
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable
"
+
value
);
netId
=
true
;
}
});
netConn
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail ${error}
"
);
}
});
await
sleep
(
DELAY
);
expect
(
true
).
assertTrue
()
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result : ${error}
"
);
}
done
();
});
done
();
});
/**
* @tc.number Telephony_NetworkManager_register_Async_1700
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
/**
* @tc.number Telephony_NetworkManager_register_Async_1800
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_1700
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_1700
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
5
],
networkCap
:
[
17
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
done
();
return
;
}
netConn
.
on
(
'
netAvailable
'
,
function
(
value
)
{
console
.
log
(
"
netAvailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netBlockStatusChange
'
,
function
(
value
)
{
console
.
log
(
"
netBlockStatusChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netCapabilitiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netConnectionPropertiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netLost
'
,
function
(
value
)
{
console
.
log
(
"
netLost
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netUnavailable
'
,
function
(
value
)
{
console
.
log
(
"
netUnavailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregister result:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
}
done
();
});
});
});
it
(
'
Telephony_NetworkManager_register_Async_1800
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_1800
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
4
],
networkCap
:
[
12
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netId
=
0
;
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable :
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable
"
+
value
);
netId
=
true
;
}
});
netConn
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail ${error}
"
);
}
});
await
sleep
(
DELAY
);
expect
(
true
).
assertTrue
()
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result : ${error}
"
);
}
done
();
});
await
sleep
(
DELAY
);
let
netConn1
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn1
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable :
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn1
.
on
(
'
netCapabilitiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn1
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn1
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost
"
+
value
.
netId
);
}
});
netConn1
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable
"
+
value
);
netId
=
true
;
}
});
netConn1
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail ${error}
"
);
}
});
await
sleep
(
DELAY
);
expect
(
true
).
assertTrue
()
netConn1
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result : ${error}
"
);
}
done
();
});
done
();
});
/**
* @tc.number Telephony_NetworkManager_register_Async_1800
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
/**
* @tc.number Telephony_NetworkManager_register_Async_1900
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_1800
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_1800
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
4
],
networkCap
:
[
12
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
done
();
return
;
}
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregister result:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
return
;
}
let
netConn1
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn1
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
done
();
return
;
}
netConn1
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregister result:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
}
done
();
});
});
});
});
});
it
(
'
Telephony_NetworkManager_register_Async_1900
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_1900
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
6
],
networkCap
:
[
18
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable :
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable
"
+
value
);
}
});
netConn
.
register
((
error
)
=>
{
if
(
error
)
{
/**
* @tc.number Telephony_NetworkManager_register_Async_1900
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
done
();
}
done
();
});
done
();
});
it
(
'
Telephony_NetworkManager_register_Async_1900
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_1900
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
6
],
networkCap
:
[
18
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register finish:
"
+
JSON
.
stringify
(
error
));
done
();
return
;
}
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregister result:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
}
done
();
});
});
});
/**
* @tc.number Telephony_NetworkManager_register_Async_2000
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
/**
* @tc.number Telephony_NetworkManager_register_Async_2000
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_2000
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_2000
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
0
],
networkCap
:
[
0
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netId
=
0
;
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
expect
(
false
).
assertTrue
()
done
();
});
netConn
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
expect
(
false
).
assertTrue
()
done
();
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
(
error
,
value
)
=>
{
expect
(
false
).
assertTrue
()
done
();
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
expect
(
false
).
assertTrue
()
done
();
});
netConn
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
expect
(
false
).
assertTrue
()
done
();
});
netConn
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
done
();
});
netConn
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail ${error}
"
);
}
});
await
sleep
(
DELAY
);
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result : ${error}
"
);
}
});
done
();
});
it
(
'
Telephony_NetworkManager_register_Async_2000
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_2000
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
0
],
networkCap
:
[
0
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail
"
+
error
);
done
();
return
;
}
netConn
.
on
(
'
netAvailable
'
,
function
(
value
)
{
console
.
log
(
"
netAvailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netBlockStatusChange
'
,
function
(
value
)
{
console
.
log
(
"
netBlockStatusChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netCapabilitiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netConnectionPropertiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netLost
'
,
function
(
value
)
{
console
.
log
(
"
netLost
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netUnavailable
'
,
function
(
value
)
{
console
.
log
(
"
netUnavailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregister fail
"
+
error
);
expect
().
assertFail
();
done
();
}
done
();
});
});
});
/**
* @tc.number Telephony_NetworkManager_register_Async_2100
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_2100
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_2100
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
0
],
networkCap
:
[
0
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netId
=
0
;
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable :
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable
"
+
value
);
netId
=
true
;
}
});
netConn
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail ${error}
"
);
}
});
await
sleep
(
DELAY
);
expect
(
true
).
assertTrue
()
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result : ${error}
"
);
}
done
();
});
let
netSpecifier1
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
0
],
networkCap
:
[
12
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn1
=
connection
.
createNetConnection
(
netSpecifier1
,
TIMEOUT
);
netConn1
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable :
"
+
value
.
netId
);
}
});
netConn1
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn1
.
on
(
'
netCapabilitiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn1
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn1
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost
"
+
value
.
netId
);
}
});
netConn1
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable
"
+
value
);
netId
=
true
;
}
});
netConn1
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail ${error}
"
);
}
});
await
sleep
(
DELAY
);
expect
(
true
).
assertTrue
()
netConn1
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result : ${error}
"
);
}
done
();
});
done
();
});
/**
* @tc.number Telephony_NetworkManager_register_Async_2100
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_2100
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_2100
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
0
],
networkCap
:
[
0
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
done
();
return
;
}
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregister result:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
return
;
}
let
netSpecifier1
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
0
],
networkCap
:
[
12
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn1
=
connection
.
createNetConnection
(
netSpecifier1
,
TIMEOUT
);
netConn1
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
return
;
}
netConn1
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregister result:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
}
done
();
});
});
});
});
});
/**
* @tc.number Telephony_NetworkManager_register_Async_2200
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_2200
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_2200
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
0
],
networkCap
:
[
0
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netId
=
0
;
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable :
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost
"
+
value
.
netId
);
}
});
netConn
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable
"
+
value
.
netId
);
netId
=
true
;
}
});
netConn
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail ${error}
"
);
}
});
await
sleep
(
DELAY
);
expect
(
true
).
assertTrue
()
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result : ${error}
"
);
}
done
();
});
let
netSpecifier1
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
1
],
networkCap
:
[
12
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn1
=
connection
.
createNetConnection
(
netSpecifier1
,
TIMEOUT
);
netConn1
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable :
"
+
value
.
netId
);
}
});
netConn1
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn1
.
on
(
'
netCapabilitiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn1
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
}
});
netConn1
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost
"
+
value
.
netId
);
}
});
netConn1
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable
"
+
value
.
netId
);
netId
=
true
;
}
});
netConn1
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail ${error}
"
);
}
});
await
sleep
(
DELAY
);
expect
(
true
).
assertTrue
()
netConn1
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result : ${error}
"
);
}
done
();
});
done
();
});
/**
* @tc.number Telephony_NetworkManager_register_Async_2200
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_2200
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_2200
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
0
],
networkCap
:
[
0
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
done
();
return
;
}
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregister result:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
return
;
}
let
netSpecifier1
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
1
],
networkCap
:
[
12
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn1
=
connection
.
createNetConnection
(
netSpecifier1
,
TIMEOUT
);
netConn1
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
return
;
}
netConn1
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregister result:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
}
done
();
});
});
});
});
});
/**
* @tc.number Telephony_NetworkManager_register_Async_2300
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_2300
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_2300
'
;
let
netConn
=
connection
.
createNetConnection
();
let
returnValue
=
0
;
netConn
.
on
(
'
netAvailable
'
,
(
value
)
=>
{
if
(
value
===
undefined
)
{
console
.
info
(
"
${caseName} on netAvailable fail
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable
"
+
value
.
netId
);
returnValue
=
value
.
netId
;
}
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
(
value
)
=>
{
if
(
value
===
undefined
)
{
console
.
info
(
"
${caseName} on netCapabilitiesChange fail
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle
"
+
value
.
netHandle
.
netId
);
expect
(
value
.
netHandle
.
netId
>=
ETH_100
).
assertTrue
();
}
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
value
)
=>
{
if
(
value
===
undefined
)
{
console
.
info
(
"
${caseName} on netConnectionPropertiesChange fail
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange hdndle
"
+
value
.
netHandle
.
netId
);
}
});
netConn
.
on
(
'
netLost
'
,
(
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} netLost fail
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost
"
+
value
.
netId
);
}
});
netConn
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail ${error}
"
);
}
});
await
sleep
(
DELAY
);
console
.
info
(
"
${caseName} returnValue
"
+
returnValue
);
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result : ${error}
"
);
done
();
}
done
();
});
done
();
});
/**
* @tc.number Telephony_NetworkManager_register_Async_2300
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_register_Async_2300
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_register_Async_2300
'
;
let
netConn
=
connection
.
createNetConnection
();
netConn
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
return
;
}
netConn
.
on
(
'
netAvailable
'
,
function
(
value
)
{
console
.
log
(
"
netAvailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netBlockStatusChange
'
,
function
(
value
)
{
console
.
log
(
"
netBlockStatusChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netCapabilitiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netConnectionPropertiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netLost
'
,
function
(
value
)
{
console
.
log
(
"
netLost
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netUnavailable
'
,
function
(
value
)
{
console
.
log
(
"
netUnavailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregister result:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
}
done
();
});
});
});
/**
* @tc.number Telephony_NetworkManager_unregister_Async_0100
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_unregister_Async_0100
'
,
0
,
async
function
(
done
)
{
if
(
!
envReady
)
{
console
.
info
(
"
The environment was not ready
"
);
done
();
return
;
}
let
caseName
=
'
Telephony_NetworkManager_unregister_Async_0100
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
0
],
networkCap
:
[
0
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT_1
);
netConn
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable :
"
+
value
.
netId
);
done
();
}
});
netConn
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
done
();
}
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle = :
"
+
value
.
netHandle
.
netId
);
done
();
}
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
done
();
}
});
netConn
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost
"
+
value
.
netId
);
done
();
}
});
netConn
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable
"
+
value
.
netId
);
done
();
}
});
netConn
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail ${error}
"
);
}
});
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result : ${error}
"
);
expect
().
assertFail
();
done
();
}
/**
* @tc.number Telephony_NetworkManager_unregister_Async_0100
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_unregister_Async_0100
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_unregister_Async_0100
'
;
let
netSpecifier
=
{
netCapabilities
:
{
linkUpBandwidthKbps
:
0
,
linkDownBandwidthKbps
:
0
,
bearerTypes
:
[
0
],
networkCap
:
[
0
],
},
bearerPrivateIdentifier
:
'
123
'
}
let
netConn
=
connection
.
createNetConnection
(
netSpecifier
,
TIMEOUT
);
netConn
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
done
();
return
;
}
netConn
.
on
(
'
netAvailable
'
,
function
(
value
)
{
console
.
log
(
"
netAvailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netBlockStatusChange
'
,
function
(
value
)
{
console
.
log
(
"
netBlockStatusChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netCapabilitiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netConnectionPropertiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netLost
'
,
function
(
value
)
{
console
.
log
(
"
netLost
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netUnavailable
'
,
function
(
value
)
{
console
.
log
(
"
netUnavailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregister result:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
}
done
();
});
});
});
done
();
});
done
();
});
/**
* @tc.number Telephony_NetworkManager_unregister_Async_0200
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_unregister_Async_0200
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_unregister_Async_0200
'
;
let
netConn
=
connection
.
createNetConnection
();
netConn
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
return
;
}
netConn
.
on
(
'
netAvailable
'
,
function
(
value
)
{
console
.
log
(
"
netAvailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netBlockStatusChange
'
,
function
(
value
)
{
console
.
log
(
"
netBlockStatusChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netCapabilitiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netConnectionPropertiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netLost
'
,
function
(
value
)
{
console
.
log
(
"
netLost
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netUnavailable
'
,
function
(
value
)
{
console
.
log
(
"
netUnavailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregister result:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
}
done
();
});
});
});
/**
* @tc.number Telephony_NetworkManager_unregister_Async_0200
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_unregister_Async_0200
'
,
0
,
async
function
(
done
)
{
if
(
!
envReady
)
{
console
.
info
(
"
The environment was not ready
"
);
done
();
return
;
}
let
caseName
=
'
Telephony_NetworkManager_unregister_Async_0200
'
;
let
netConn
=
connection
.
createNetConnection
();
netConn
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable :
"
+
value
.
netId
);
done
();
}
});
netConn
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
done
();
}
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle = :
"
+
value
.
netHandle
.
netId
);
done
();
}
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
done
();
}
});
netConn
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost
"
+
value
.
netId
);
done
();
}
});
netConn
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable
"
+
value
.
netId
);
done
();
}
});
netConn
.
register
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail ${error}
"
);
}
});
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result : ${error}
"
);
expect
().
assertFail
();
done
();
}
done
();
});
done
();
});
/**
* @tc.number Telephony_NetworkManager_unregister_Async_0300
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_unregister_Async_0300
'
,
0
,
async
function
(
done
)
{
if
(
!
envReady
)
{
console
.
info
(
"
The environment was not ready
"
);
done
();
return
;
}
let
caseName
=
'
Telephony_NetworkManager_unregister_Async_0300
'
;
let
netConn
=
connection
.
createNetConnection
();
netConn
.
on
(
'
netAvailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail: ${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netAvailable :
"
+
value
.
netId
);
done
();
}
});
netConn
.
on
(
'
netBlockStatusChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netBlockStatusChange handle = :
"
+
value
.
netHandle
.
netId
);
done
();
}
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netCapabilitiesChange handle = :
"
+
value
.
netHandle
.
netId
);
done
();
}
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netConnectionPropertiesChange handle = :
"
+
value
.
netHandle
.
netId
);
done
();
}
});
netConn
.
on
(
'
netLost
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netLost
"
+
value
.
netId
);
done
();
}
});
netConn
.
on
(
'
netUnavailable
'
,
(
error
,
value
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} register fail :${error}
"
);
expect
().
assertFail
();
done
();
}
else
{
console
.
info
(
"
${caseName} netUnavailable
"
+
value
.
netId
);
done
();
}
});
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
"
${caseName} unregister result : ${error}
"
);
expect
().
assertFail
();
done
();
}
done
();
});
done
();
});
});
}
\ No newline at end of file
/**
* @tc.number Telephony_NetworkManager_unregister_Async_0300
* @tc.name Enter bearerTypes add networkCap as empty ,set class NetConnection,
* call Register () to activate the default network ,and see if the callback information is generated
* @tc.desc Function test
*/
it
(
'
Telephony_NetworkManager_unregister_Async_0300
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
Telephony_NetworkManager_unregister_Async_0300
'
;
let
netConn
=
connection
.
createNetConnection
();
netConn
.
register
(
function
(
error
)
{
if
(
error
)
{
console
.
info
(
caseName
+
"
register fail:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
return
;
}
netConn
.
on
(
'
netAvailable
'
,
function
(
value
)
{
console
.
log
(
"
netAvailable
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netBlockStatusChange
'
,
function
(
value
)
{
console
.
log
(
"
netBlockStatusChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netCapabilitiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netCapabilitiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netConnectionPropertiesChange
'
,
function
(
value
)
{
console
.
log
(
"
netConnectionPropertiesChange
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netLost
'
,
function
(
value
)
{
console
.
log
(
"
netLost
"
+
JSON
.
stringify
(
value
));
});
netConn
.
on
(
'
netUnavailable
'
,
function
(
value
)
{
console
.
log
(
"
netUnavailable
"
+
JSON
.
stringify
(
value
));
});
expect
(
true
).
assertTrue
();
netConn
.
unregister
((
error
)
=>
{
if
(
error
)
{
console
.
info
(
caseName
+
"
unregister result:
"
+
JSON
.
stringify
(
error
));
expect
().
assertFail
();
done
();
}
done
();
});
});
});
});
}
\ No newline at end of file
telephony/telephonyjstest/observer/entry/src/main/ets/test/ObserverJsunit.test.ets
浏览文件 @
519d67c5
...
...
@@ -19,7 +19,6 @@ import observer from '@ohos.telephony.observer';
export default function ObserverJsunit() {
describe('ObserverJsunit', function () {
console.log("************* Observer Test start *************");
let envReady = false;
/*
* @tc.number : Telephony_observer_observer_DataConnectState_0100
...
...
@@ -446,11 +445,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_NONE property of LockReason
*/
it('Telephony_observer_LockReason_SIM_NONE_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_NONE_0100 Test start *************")
expect(0).assertEqual(observer.LockReason.SIM_NONE);
done();
...
...
@@ -463,11 +457,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_PIN property of LockReason
*/
it('Telephony_observer_LockReason_SIM_PIN_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_PIN_0100 Test start *************");
expect(1).assertEqual(observer.LockReason.SIM_PIN);
done();
...
...
@@ -480,11 +469,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_PUK property of LockReason
*/
it('Telephony_observer_LockReason_SIM_PUK_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_PUK_0100 Test start *************");
expect(2).assertEqual(observer.LockReason.SIM_PUK);
done();
...
...
@@ -497,11 +481,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_PN_PIN property of LockReason
*/
it('Telephony_observer_LockReason_SIM_PN_PIN_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_PN_PIN_0100 Test start *************");
expect(3).assertEqual(observer.LockReason.SIM_PN_PIN);
done();
...
...
@@ -513,11 +492,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_PN_PUK property of LockReason
*/
it('Telephony_observer_LockReason_SIM_PN_PUK_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_PN_PUK_0100 Test start *************");
expect(4).assertEqual(observer.LockReason.SIM_PN_PUK);
done();
...
...
@@ -530,11 +504,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_PU_PIN property of LockReason
*/
it('Telephony_observer_LockReason_SIM_PU_PIN_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_PU_PIN_0100 Test start *************");
expect(5).assertEqual(observer.LockReason.SIM_PU_PIN);
done();
...
...
@@ -547,11 +516,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_PU_PUK property of LockReason
*/
it('Telephony_observer_LockReason_SIM_PU_PUK_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_PU_PUK_0100 Test start *************");
expect(6).assertEqual(observer.LockReason.SIM_PU_PUK);
done();
...
...
@@ -564,11 +528,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_PP_PIN property of LockReason
*/
it('Telephony_observer_LockReason_SIM_PP_PIN_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_PP_PIN_0100 Test start *************");
expect(7).assertEqual(observer.LockReason.SIM_PP_PIN);
done();
...
...
@@ -581,11 +540,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_PP_PUK property of LockReason
*/
it('Telephony_observer_LockReason_SIM_PP_PUK_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_PP_PUK_0100 Test start *************");
expect(8).assertEqual(observer.LockReason.SIM_PP_PUK);
done();
...
...
@@ -598,11 +552,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_PC_PIN property of LockReason
*/
it('Telephony_observer_LockReason_SIM_PC_PIN_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_PC_PIN_0100 Test start *************");
expect(9).assertEqual(observer.LockReason.SIM_PC_PIN);
done();
...
...
@@ -615,11 +564,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_PC_PUK property of LockReason
*/
it('Telephony_observer_LockReason_SIM_PC_PUK_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_PC_PUK_0100 Test start *************");
expect(10).assertEqual(observer.LockReason.SIM_PC_PUK);
done();
...
...
@@ -632,11 +576,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_SIM_PIN property of LockReason
*/
it('Telephony_observer_LockReason_SIM_SIM_PIN_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_SIM_PIN_0100 Test start *************");
expect(11).assertEqual(observer.LockReason.SIM_SIM_PIN);
done();
...
...
@@ -649,11 +588,6 @@ export default function ObserverJsunit() {
* @tc.desc : check the SIM_SIM_PUK property of LockReason
*/
it('Telephony_observer_LockReason_SIM_SIM_PUK_0100', 0, function (done) {
if (!envReady) {
console.info("The environment was not ready");
done();
return;
}
console.log("************* Telephony_observer_LockReason_SIM_SIM_PUK_0100 Test start *************");
expect(12).assertEqual(observer.LockReason.SIM_SIM_PUK);
done();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录