Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
b64f0635
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看板
未验证
提交
b64f0635
编写于
4月 15, 2023
作者:
O
openharmony_ci
提交者:
Gitee
4月 15, 2023
浏览文件
操作
浏览文件
下载
差异文件
!7882 新增MDNS接口用例
Merge pull request !7882 from zhangfuzhi/master
上级
6c7300dc
c5456496
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
1037 addition
and
3 deletion
+1037
-3
telephony/telephonyjstest/netmanager_base/dns/src/main/js/test/List.test.js
...yjstest/netmanager_base/dns/src/main/js/test/List.test.js
+5
-3
telephony/telephonyjstest/netmanager_base/dns/src/main/js/test/NetworkManagerMdns.test.js
...ager_base/dns/src/main/js/test/NetworkManagerMdns.test.js
+1032
-0
未找到文件。
telephony/telephonyjstest/netmanager_base/dns/src/main/js/test/List.test.js
浏览文件 @
b64f0635
/**
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Copyright (C) 2022
-2023
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
...
...
@@ -12,8 +12,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
Telephony_NETMANAGER_TestDNSTest
from
'
./NetworkManagerDNS.test.js
'
import
Telephony_NETMANAGER_TestDNSTest
from
'
./NetworkManagerDNS.test.js
'
;
import
Telephony_NETMANAGER_MDNSTest
from
'
./NetworkManagerMdns.test
'
;
export
default
function
testsuite
()
{
Telephony_NETMANAGER_TestDNSTest
()
Telephony_NETMANAGER_TestDNSTest
();
Telephony_NETMANAGER_MDNSTest
();
}
telephony/telephonyjstest/netmanager_base/dns/src/main/js/test/NetworkManagerMdns.test.js
0 → 100644
浏览文件 @
b64f0635
/*
* Copyright (C) 2023 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
{
describe
,
expect
,
it
,
afterEach
}
from
'
@ohos/hypium
'
;
import
mdns
from
'
@ohos.net.mdns
'
;
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
let
bundleName
=
featureAbility
.
getContext
();
let
delayTime
=
3000
;
let
startSearching_status
;
let
stopSearching_status
;
let
found_status
;
let
lost_status
;
function
startSearching
()
{
console
.
log
(
`SUB_Telephony_ run startSearching function`
);
startSearching_status
=
true
;
}
function
stopSearching
()
{
console
.
log
(
`SUB_Telephony_ run stopSearching function`
);
stopSearching_status
=
true
;
}
function
found
()
{
console
.
log
(
`SUB_Telephony_ run found function`
);
found_status
=
true
;
}
function
lost
()
{
console
.
log
(
`SUB_Telephony_ run lost function`
);
lost_status
=
true
;
}
let
localServiceInfo
=
{
serviceType
:
"
_print._tcp
"
,
serviceName
:
"
into type
"
,
port
:
5555
,
host
:
{
address
:
"
10.14.0.7
"
,
family
:
1
,
port
:
5555
,
},
serviceAttribute
:
[
{
key
:
"
111
"
,
value
:
[
1
]
}
]
}
function
myExpect
(
value
)
{
expect
(
value
.
serviceType
).
assertEqual
(
localServiceInfo
.
serviceType
);
expect
(
value
.
serviceName
).
assertEqual
(
localServiceInfo
.
serviceName
);
expect
(
value
.
port
).
assertEqual
(
localServiceInfo
.
port
);
expect
(
value
.
host
.
address
).
assertEqual
(
localServiceInfo
.
host
.
address
);
expect
(
value
.
host
.
family
).
assertEqual
(
localServiceInfo
.
host
.
family
);
expect
(
value
.
host
.
port
).
assertEqual
(
localServiceInfo
.
host
.
port
);
expect
(
value
.
serviceAttribute
[
0
].
key
[
0
]).
assertEqual
(
localServiceInfo
.
serviceAttribute
[
0
].
key
[
0
]);
expect
(
value
.
serviceAttribute
[
0
].
value
[
0
]).
assertEqual
(
localServiceInfo
.
serviceAttribute
[
0
].
value
[
0
]);
}
export
default
function
NetworkManagerMdnsTest
()
{
describe
(
'
NetworkManagerMdnsTest
'
,
function
()
{
afterEach
(
async
function
()
{
mdns
.
removeLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`removeLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
}
else
{
console
.
log
(
` removeLocalService success
${
JSON
.
stringify
(
data
)}
`
);
}
});
});
/**
* @tc.number SUB_Telephony_NetManager_addLocalService_Async_0100
* @tc.name Test addLocalService() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_addLocalService_Async_0100
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_addLocalService_Async_0100
'
;
mdns
.
addLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
addLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
addLocalService success`
);
myExpect
(
data
);
mdns
.
removeLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
removeLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
removeLocalService success`
);
myExpect
(
data
);
done
();
}
});
}
});
});
/**
* @tc.number SUB_Telephony_NetManager_addLocalService_Async_0400
* @tc.name Test addLocalService() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_addLocalService_Async_0400
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_addLocalService_Async_0400
'
;
mdns
.
addLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
addLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
addLocalService success`
);
myExpect
(
data
);
mdns
.
addLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
addLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
!=
undefined
).
assertEqual
(
true
);
mdns
.
removeLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
removeLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
removeLocalService success`
);
myExpect
(
data
);
done
();
}
});
}
else
{
console
.
log
(
`
${
caseName
}
addLocalService success`
);
expect
().
assertFail
();
done
();
}
});
}
});
});
/**
* @tc.number SUB_Telephony_NetManager_addLocalService_Async_0500
* @tc.name Test addLocalService() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_addLocalService_Async_0500
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_addLocalService_Async_0500
'
;
let
localServiceInfo
=
{}
mdns
.
addLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
addLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
!=
undefined
).
assertEqual
(
true
);
done
();
}
else
{
console
.
log
(
`
${
caseName
}
addLocalService success`
);
expect
().
assertFail
();
done
();
}
});
});
/**
* @tc.number SUB_Telephony_NetManager_addLocalService_Async_0600
* @tc.name Test addLocalService() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_addLocalService_Async_0600
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_addLocalService_Async_0600
'
;
try
{
mdns
.
addLocalService
(
null
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
addLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
addLocalService success`
);
expect
().
assertFail
();
done
();
}
});
}
catch
(
err
)
{
console
.
log
(
`
${
caseName
}
addLocalService into catch
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
!=
undefined
).
assertEqual
(
true
)
done
();
}
});
/**
* @tc.number SUB_Telephony_NetManager_addLocalService_Promise_0100
* @tc.name Test addLocalService() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_addLocalService_Promise_0100
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_addLocalService_Promise_0100
'
;
mdns
.
addLocalService
(
bundleName
,
localServiceInfo
).
then
((
data
)
=>
{
console
.
log
(
`
${
caseName
}
addLocalService success `
);
myExpect
(
data
);
mdns
.
removeLocalService
(
bundleName
,
localServiceInfo
).
then
((
data
)
=>
{
console
.
log
(
`
${
caseName
}
removeLocalService success `
);
myExpect
(
data
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
`
${
caseName
}
removeLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
});
}).
catch
((
err
)
=>
{
console
.
log
(
`
${
caseName
}
addLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
});
});
/**
* @tc.number SUB_Telephony_NetManager_addLocalService_Promise_0400
* @tc.name Test addLocalService() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_addLocalService_Promise_0400
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_addLocalService_Promise_0400
'
;
mdns
.
addLocalService
(
bundleName
,
localServiceInfo
).
then
((
data
)
=>
{
console
.
log
(
`
${
caseName
}
addLocalService success `
);
myExpect
(
data
);
mdns
.
addLocalService
(
bundleName
,
localServiceInfo
).
then
((
data
)
=>
{
console
.
log
(
`
${
caseName
}
addLocalService success `
);
expect
().
assertFail
();
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
`
${
caseName
}
addLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
!=
undefined
).
assertEqual
(
true
);
mdns
.
removeLocalService
(
bundleName
,
localServiceInfo
).
then
((
data
)
=>
{
console
.
log
(
`
${
caseName
}
removeLocalService success `
);
myExpect
(
data
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
`
${
caseName
}
removeLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
});
});
}).
catch
((
err
)
=>
{
console
.
log
(
`
${
caseName
}
addLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
});
});
/**
* @tc.number SUB_Telephony_NetManager_addLocalService_Promise_0500
* @tc.name Test addLocalService() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_addLocalService_Promise_0500
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_addLocalService_Promise_0500
'
;
let
localServiceInfo
=
{}
mdns
.
addLocalService
(
bundleName
,
localServiceInfo
).
then
((
data
)
=>
{
console
.
log
(
`
${
caseName
}
addLocalService success `
);
expect
().
assertFail
();
}).
catch
((
err
)
=>
{
console
.
log
(
`
${
caseName
}
addLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
!=
undefined
).
assertEqual
(
true
);
done
();
});
});
/**
* @tc.number SUB_Telephony_NetManager_addLocalService_Promise_0600
* @tc.name Test addLocalService() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_addLocalService_Promise_0600
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_addLocalService_Promise_0600
'
;
try
{
mdns
.
addLocalService
(
null
,
localServiceInfo
).
then
((
data
)
=>
{
console
.
log
(
`
${
caseName
}
addLocalService success `
);
expect
().
assertFail
();
}).
catch
((
err
)
=>
{
console
.
log
(
`
${
caseName
}
addLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
});
}
catch
(
err
)
{
console
.
log
(
`
${
caseName
}
addLocalService into catch
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
!=
undefined
).
assertEqual
(
true
)
done
();
}
});
/**
* @tc.number SUB_Telephony_NetManager_removeLocalService_Async_0100
* @tc.name Test removeLocalService() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_removeLocalService_Async_0100
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_removeLocalService_Async_0100
'
;
mdns
.
addLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
addLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
addLocalService success `
);
myExpect
(
data
);
mdns
.
removeLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
removeLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
removeLocalService success `
);
expect
(
err
).
assertEqual
(
undefined
);
myExpect
(
data
);
done
();
}
});
}
});
});
/**
* @tc.number SUB_Telephony_NetManager_removeLocalService_Async_0400
* @tc.name Test removeLocalService() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_removeLocalService_Async_0400
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_removeLocalService_Async_0400
'
;
mdns
.
addLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
addLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
addLocalService success `
);
myExpect
(
data
);
mdns
.
removeLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
removeLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
removeLocalService success `
);
expect
(
err
).
assertEqual
(
undefined
);
myExpect
(
data
);
mdns
.
removeLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
removeLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
!=
undefined
).
assertEqual
(
true
);
done
();
}
else
{
console
.
log
(
`
${
caseName
}
removeLocalService success `
);
expect
().
assertFail
();
done
();
}
});
}
});
}
});
});
/**
* @tc.number SUB_Telephony_NetManager_removeLocalService_Async_0500
* @tc.name Test removeLocalService() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_removeLocalService_Async_0500
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_removeLocalService_Async_0500
'
;
let
localServiceInfo
=
{}
mdns
.
removeLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
removeLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
!=
undefined
).
assertEqual
(
true
);
done
();
}
else
{
console
.
log
(
`
${
caseName
}
removeLocalService success `
);
expect
().
assertFail
();
done
();
}
});
});
/**
* @tc.number SUB_Telephony_NetManager_removeLocalService_Async_0600
* @tc.name Test removeLocalService() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_removeLocalService_Async_0600
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_removeLocalService_Async_0600
'
;
try
{
mdns
.
removeLocalService
(
null
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
removeLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
removeLocalService success `
);
expect
().
assertFail
();
done
();
}
});
}
catch
(
err
)
{
console
.
log
(
`
${
caseName
}
removeLocalService into catch
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
!=
undefined
).
assertEqual
(
true
);
done
();
}
});
/**
* @tc.number SUB_Telephony_NetManager_removeLocalService_Promise_0100
* @tc.name Test removeLocalService() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_removeLocalService_Promise_0100
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_removeLocalService_Promise_0100
'
;
mdns
.
addLocalService
(
bundleName
,
localServiceInfo
).
then
((
data
)
=>
{
console
.
log
(
`
${
caseName
}
addLocalService success `
);
myExpect
(
data
);
mdns
.
removeLocalService
(
bundleName
,
localServiceInfo
).
then
((
data
)
=>
{
console
.
log
(
`
${
caseName
}
removeLocalService success`
);
myExpect
(
data
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
`
${
caseName
}
removeLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
});
}).
catch
((
err
)
=>
{
console
.
log
(
`
${
caseName
}
addLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
});
});
/**
* @tc.number SUB_Telephony_NetManager_removeLocalService_Promise_0400
* @tc.name Test removeLocalService() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_removeLocalService_Promise_0400
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_removeLocalService_Promise_0400
'
;
mdns
.
addLocalService
(
bundleName
,
localServiceInfo
).
then
((
data
)
=>
{
console
.
log
(
`
${
caseName
}
addLocalService success `
);
myExpect
(
data
);
mdns
.
removeLocalService
(
bundleName
,
localServiceInfo
).
then
((
data
)
=>
{
console
.
log
(
`
${
caseName
}
removeLocalService success`
);
myExpect
(
data
);
mdns
.
removeLocalService
(
bundleName
,
localServiceInfo
).
then
((
data
)
=>
{
console
.
log
(
`
${
caseName
}
removeLocalService success`
);
expect
().
assertFail
();
myExpect
(
data
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
`
${
caseName
}
removeLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
!=
undefined
).
assertEqual
(
true
);
done
();
});
}).
catch
((
err
)
=>
{
console
.
log
(
`
${
caseName
}
removeLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
});
}).
catch
((
err
)
=>
{
console
.
log
(
`
${
caseName
}
addLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
});
});
/**
* @tc.number SUB_Telephony_NetManager_removeLocalService_Promise_0500
* @tc.name Test removeLocalService() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_removeLocalService_Promise_0500
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_removeLocalService_Promise_0500
'
;
let
localServiceInfo
=
{}
mdns
.
removeLocalService
(
bundleName
,
localServiceInfo
).
then
((
data
)
=>
{
console
.
log
(
`
${
caseName
}
removeLocalService success`
);
expect
().
assertFail
();
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
`
${
caseName
}
removeLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
!=
undefined
).
assertEqual
(
true
);
done
();
});
});
/**
* @tc.number SUB_Telephony_NetManager_removeLocalService_Promise_0600
* @tc.name Test removeLocalService() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_removeLocalService_Promise_0600
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_removeLocalService_Promise_0600
'
;
try
{
mdns
.
removeLocalService
(
null
,
localServiceInfo
).
then
((
data
)
=>
{
console
.
log
(
`
${
caseName
}
removeLocalService success`
);
expect
().
assertFail
();
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
`
${
caseName
}
removeLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
});
}
catch
(
err
)
{
console
.
log
(
`
${
caseName
}
removeLocalService into catch
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
!=
undefined
).
assertEqual
(
true
);
done
();
}
});
/**
* @tc.number SUB_Telephony_NetManager_createDiscoveryService_0100
* @tc.name Test createDiscoveryService() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_createDiscoveryService_0100
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_createDiscoveryService_0100
'
;
let
discoveryService
=
mdns
.
createDiscoveryService
(
bundleName
,
"
_print._tcp
"
);
if
(
discoveryService
!=
undefined
)
{
console
.
log
(
`
${
caseName
}
createDiscoveryService success`
);
expect
(
discoveryService
).
assertInstanceOf
(
'
Object
'
);
done
();
}
else
{
console
.
log
(
`
${
caseName
}
createDiscoveryService fail`
);
expect
().
assertFail
();
done
();
}
});
/**
* @tc.number SUB_Telephony_NetManager_createDiscoveryService_0400
* @tc.name Test createDiscoveryService() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_createDiscoveryService_0400
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_createDiscoveryService_0400
'
;
let
discoveryService
=
mdns
.
createDiscoveryService
(
bundleName
,
null
);
if
(
discoveryService
!=
undefined
)
{
console
.
log
(
`
${
caseName
}
createDiscoveryService success`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
createDiscoveryService fail`
);
expect
(
discoveryService
==
undefined
).
assertEqual
(
true
);
done
();
}
});
/**
* @tc.number SUB_Telephony_NetManager_createDiscoveryService_0500
* @tc.name Test createDiscoveryService() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_createDiscoveryService_0500
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_createDiscoveryService_0500
'
;
let
discoveryService
=
mdns
.
createDiscoveryService
(
null
,
"
_print._tcp
"
);
if
(
discoveryService
!=
undefined
)
{
console
.
log
(
`
${
caseName
}
createDiscoveryService success`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
createDiscoveryService fail`
);
expect
(
discoveryService
==
undefined
).
assertEqual
(
true
);
done
();
}
});
/**
* @tc.number SUB_Telephony_NetManager_resolveLocalService_Async_0100
* @tc.name Test resolveLocalService() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_resolveLocalService_Async_0100
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_resolveLocalService_Async_0100
'
;
mdns
.
addLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
addLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
addLocalService success`
);
myExpect
(
data
);
mdns
.
resolveLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
resolveLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
resolveLocalService success `
);
expect
(
err
).
assertEqual
(
undefined
);
expect
(
data
.
serviceType
).
assertEqual
(
localServiceInfo
.
serviceType
);
expect
(
data
.
serviceName
).
assertEqual
(
localServiceInfo
.
serviceName
);
expect
(
data
.
port
).
assertEqual
(
localServiceInfo
.
port
);
expect
(
typeof
(
data
.
host
.
address
)).
assertEqual
(
typeof
(
localServiceInfo
.
host
.
address
));
expect
(
data
.
host
.
family
).
assertEqual
(
localServiceInfo
.
host
.
family
);
expect
(
data
.
host
.
port
).
assertEqual
(
localServiceInfo
.
host
.
port
);
expect
(
data
.
serviceAttribute
[
0
].
key
[
0
]).
assertEqual
(
localServiceInfo
.
serviceAttribute
[
0
].
key
[
0
]);
expect
(
data
.
serviceAttribute
[
0
].
value
[
0
]).
assertEqual
(
localServiceInfo
.
serviceAttribute
[
0
].
value
[
0
]);
mdns
.
removeLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
removeLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
removeLocalService success `
);
expect
(
err
).
assertEqual
(
undefined
);
myExpect
(
data
);
done
();
}
});
}
});
}
});
});
/**
* @tc.number SUB_Telephony_NetManager_resolveLocalService_Async_0400
* @tc.name Test resolveLocalService() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_resolveLocalService_Async_0400
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_resolveLocalService_Async_0400
'
;
let
localServiceInfo
=
{};
mdns
.
resolveLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
resolveLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
!=
undefined
).
assertEqual
(
true
);
done
();
}
else
{
console
.
log
(
`
${
caseName
}
resolveLocalService success `
);
expect
().
assertFail
();
done
();
}
});
});
/**
* @tc.number SUB_Telephony_NetManager_resolveLocalService_Async_0500
* @tc.name Test resolveLocalService() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_resolveLocalService_Async_0500
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_resolveLocalService_Async_0500
'
;
try
{
mdns
.
resolveLocalService
(
null
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
resolveLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
resolveLocalService success `
);
expect
().
assertFail
();
done
();
}
});
}
catch
(
err
)
{
console
.
log
(
`
${
caseName
}
resolveLocalService into catch
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
!=
undefined
).
assertEqual
(
true
);
done
();
}
});
/**
* @tc.number SUB_Telephony_NetManager_resolveLocalService_Promise_0100
* @tc.name Test resolveLocalService() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_resolveLocalService_Promise_0100
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_resolveLocalService_Promise_0100
'
;
mdns
.
addLocalService
(
bundleName
,
localServiceInfo
).
then
((
data
)
=>
{
console
.
log
(
`
${
caseName
}
addLocalService success `
);
myExpect
(
data
);
mdns
.
resolveLocalService
(
bundleName
,
localServiceInfo
).
then
((
data
)
=>
{
console
.
log
(
`
${
caseName
}
resolveLocalService success `
);
expect
(
data
.
serviceType
).
assertEqual
(
localServiceInfo
.
serviceType
);
expect
(
data
.
serviceName
).
assertEqual
(
localServiceInfo
.
serviceName
);
expect
(
data
.
port
).
assertEqual
(
localServiceInfo
.
port
);
expect
(
typeof
(
data
.
host
.
address
)).
assertEqual
(
typeof
(
localServiceInfo
.
host
.
address
));
expect
(
data
.
host
.
family
).
assertEqual
(
localServiceInfo
.
host
.
family
);
expect
(
data
.
host
.
port
).
assertEqual
(
localServiceInfo
.
host
.
port
);
expect
(
data
.
serviceAttribute
[
0
].
key
[
0
]).
assertEqual
(
localServiceInfo
.
serviceAttribute
[
0
].
key
[
0
]);
expect
(
data
.
serviceAttribute
[
0
].
value
[
0
]).
assertEqual
(
localServiceInfo
.
serviceAttribute
[
0
].
value
[
0
]);
mdns
.
removeLocalService
(
bundleName
,
localServiceInfo
).
then
((
data
)
=>
{
console
.
log
(
`
${
caseName
}
removeLocalService success `
);
myExpect
(
data
);
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
`
${
caseName
}
removeLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
});
}).
catch
((
err
)
=>
{
console
.
log
(
`
${
caseName
}
resolveLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
});
}).
catch
((
err
)
=>
{
console
.
log
(
`
${
caseName
}
addLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
});
});
/**
* @tc.number SUB_Telephony_NetManager_resolveLocalService_Promise_0400
* @tc.name Test resolveLocalService() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_resolveLocalService_Promise_0400
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_resolveLocalService_Promise_0400
'
;
let
localServiceInfo
=
{};
mdns
.
resolveLocalService
(
bundleName
,
localServiceInfo
).
then
((
data
)
=>
{
console
.
log
(
`
${
caseName
}
resolveLocalService success `
);
expect
().
assertFail
();
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
`
${
caseName
}
resolveLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
!=
undefined
).
assertEqual
(
true
);
done
();
});
});
/**
* @tc.number SUB_Telephony_NetManager_resolveLocalService_Promise_0500
* @tc.name Test resolveLocalService() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_resolveLocalService_Promise_0500
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_resolveLocalService_Promise_0500
'
;
try
{
mdns
.
resolveLocalService
(
null
,
localServiceInfo
).
then
((
data
)
=>
{
console
.
log
(
`
${
caseName
}
resolveLocalService success `
);
expect
().
assertFail
();
done
();
}).
catch
((
err
)
=>
{
console
.
log
(
`
${
caseName
}
resolveLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
});
}
catch
(
err
)
{
console
.
log
(
`
${
caseName
}
resolveLocalService into catch
${
JSON
.
stringify
(
err
)}
`
);
expect
(
err
!=
undefined
).
assertEqual
(
true
);
done
();
}
});
/**
* @tc.number SUB_Telephony_NetManager_startSearchingMDNS_0100
* @tc.name Test startSearchingMDNS() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_startSearchingMDNS_0100
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_startSearchingMDNS_0100
'
;
startSearching_status
=
false
;
let
discoveryService
=
mdns
.
createDiscoveryService
(
bundleName
,
"
_print._tcp
"
);
discoveryService
.
on
(
"
discoveryStart
"
,
startSearching
);
mdns
.
addLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
addLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
addLocalService success `
);
discoveryService
.
startSearchingMDNS
();
setTimeout
(()
=>
{
discoveryService
.
stopSearchingMDNS
();
setTimeout
(()
=>
{
mdns
.
removeLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
removeLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
removeLocalService success `
);
expect
(
err
).
assertEqual
(
undefined
);
setTimeout
(()
=>
{
expect
(
startSearching_status
).
assertEqual
(
true
);
done
();
},
delayTime
)
}
});
},
delayTime
)
},
delayTime
)
}
});
});
/**
* @tc.number SUB_Telephony_NetManager_stopSearchingMDNS_0100
* @tc.name Test stopSearchingMDNS() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_stopSearchingMDNS_0100
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_stopSearchingMDNS_0100
'
;
stopSearching_status
=
false
;
let
discoveryService
=
mdns
.
createDiscoveryService
(
bundleName
,
"
_print._tcp
"
);
discoveryService
.
on
(
"
discoveryStop
"
,
stopSearching
);
mdns
.
addLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
addLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
addLocalService success `
);
discoveryService
.
startSearchingMDNS
();
setTimeout
(()
=>
{
discoveryService
.
stopSearchingMDNS
();
setTimeout
(()
=>
{
mdns
.
removeLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
removeLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
removeLocalService success `
);
expect
(
err
).
assertEqual
(
undefined
);
setTimeout
(()
=>
{
expect
(
stopSearching_status
).
assertEqual
(
true
);
done
();
},
delayTime
)
}
});
},
delayTime
)
},
delayTime
)
}
});
});
/**
* @tc.number SUB_Telephony_NetManager_on_discoveryStart_0100
* @tc.name Test on() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_on_discoveryStart_0100
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_on_discoveryStart_0100
'
;
startSearching_status
=
false
;
let
discoveryService
=
mdns
.
createDiscoveryService
(
bundleName
,
"
_print._tcp
"
);
discoveryService
.
on
(
"
discoveryStart
"
,
startSearching
);
mdns
.
addLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
addLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
addLocalService success`
);
discoveryService
.
startSearchingMDNS
();
setTimeout
(()
=>
{
discoveryService
.
stopSearchingMDNS
();
setTimeout
(()
=>
{
mdns
.
removeLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
removeLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
removeLocalService success`
);
expect
(
err
).
assertEqual
(
undefined
);
setTimeout
(()
=>
{
expect
(
startSearching_status
).
assertEqual
(
true
);
done
();
},
delayTime
)
}
});
},
delayTime
)
},
delayTime
)
}
});
});
/**
* @tc.number SUB_Telephony_NetManager_on_discoveryStop_0100
* @tc.name Test on() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_on_discoveryStop_0100
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_on_discoveryStop_0100
'
;
stopSearching_status
=
false
;
let
discoveryService
=
mdns
.
createDiscoveryService
(
bundleName
,
"
_print._tcp
"
);
discoveryService
.
on
(
"
discoveryStop
"
,
stopSearching
);
mdns
.
addLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
addLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
addLocalService success `
);
discoveryService
.
startSearchingMDNS
();
setTimeout
(()
=>
{
discoveryService
.
stopSearchingMDNS
();
setTimeout
(()
=>
{
mdns
.
removeLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
removeLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
removeLocalService success `
);
expect
(
err
).
assertEqual
(
undefined
);
setTimeout
(()
=>
{
expect
(
stopSearching_status
).
assertEqual
(
true
);
done
();
},
delayTime
)
}
});
},
delayTime
)
},
delayTime
)
}
});
});
/**
* @tc.number SUB_Telephony_NetManager_on_serviceFound_0100
* @tc.name Test on() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_on_serviceFound_0100
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_on_serviceFound_0100
'
;
found_status
=
false
;
let
discoveryService
=
mdns
.
createDiscoveryService
(
bundleName
,
"
_print._tcp
"
);
discoveryService
.
on
(
"
serviceFound
"
,
found
);
mdns
.
addLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
addLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
addLocalService success `
);
discoveryService
.
startSearchingMDNS
();
setTimeout
(()
=>
{
discoveryService
.
stopSearchingMDNS
();
setTimeout
(()
=>
{
mdns
.
removeLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
removeLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
removeLocalService success `
);
expect
(
err
).
assertEqual
(
undefined
);
setTimeout
(()
=>
{
expect
(
found_status
).
assertEqual
(
true
);
done
();
},
delayTime
)
}
});
},
delayTime
)
},
delayTime
)
}
});
});
/**
* @tc.number SUB_Telephony_NetManager_on_serviceLost_0100
* @tc.name Test on() interface
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_on_serviceLost_0100
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_on_serviceLost_0100
'
;
lost_status
=
false
;
let
discoveryService
=
mdns
.
createDiscoveryService
(
bundleName
,
"
_print._tcp
"
);
discoveryService
.
on
(
"
serviceLost
"
,
lost
);
mdns
.
addLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
addLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
addLocalService success `
);
discoveryService
.
startSearchingMDNS
();
setTimeout
(()
=>
{
mdns
.
removeLocalService
(
bundleName
,
localServiceInfo
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
log
(
`
${
caseName
}
removeLocalService fail
${
JSON
.
stringify
(
err
)}
`
);
expect
().
assertFail
();
done
();
}
else
{
console
.
log
(
`
${
caseName
}
removeLocalService success `
);
expect
(
err
).
assertEqual
(
undefined
);
setTimeout
(()
=>
{
expect
(
lost_status
).
assertEqual
(
true
);
done
();
},
delayTime
)
}
});
},
delayTime
)
}
});
});
/**
* @tc.number SUB_Telephony_NetManager_MdnsError_0100
* @tc.name Test MdnsError enum
* @tc.desc Function test
*/
it
(
'
SUB_Telephony_NetManager_MdnsError_0100
'
,
0
,
async
function
(
done
)
{
let
caseName
=
'
SUB_Telephony_NetManager_MdnsError_0100
'
;
expect
(
mdns
.
MdnsError
.
INTERNAL_ERROR
==
0
).
assertTrue
();
expect
(
mdns
.
MdnsError
.
ALREADY_ACTIVE
==
1
).
assertTrue
();
expect
(
mdns
.
MdnsError
.
MAX_LIMIT
==
2
).
assertTrue
();
console
.
info
(
caseName
+
"
test finish!
"
);
done
();
});
});
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录