Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
d56bd2b3
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看板
未验证
提交
d56bd2b3
编写于
11月 21, 2022
作者:
O
openharmony_ci
提交者:
Gitee
11月 21, 2022
浏览文件
操作
浏览文件
下载
差异文件
!6589 优化搜网部分测试用例
Merge pull request !6589 from zhangfuzhi/master
上级
3dc67152
8b46343f
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
194 addition
and
116 deletion
+194
-116
telephony/telephonyjstest/netmanager_base/network_nowifi/src/main/js/test/Http.nowifi.test.js
..._base/network_nowifi/src/main/js/test/Http.nowifi.test.js
+124
-88
telephony/telephonyjstest/network_search/network_search_errors/src/main/js/test/NetworkSearchErrors.test.js
...earch_errors/src/main/js/test/NetworkSearchErrors.test.js
+70
-28
未找到文件。
telephony/telephonyjstest/netmanager_base/network_nowifi/src/main/js/test/Http.nowifi.test.js
浏览文件 @
d56bd2b3
...
...
@@ -14,107 +14,143 @@
*/
import
network
from
'
@system.network
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
{
describe
,
it
,
expect
}
from
'
@ohos/hypium
'
;
import
connection
from
'
@ohos.net.connection
'
;
export
default
function
Telephony_NetManager_NetWorkTest
()
{
describe
(
"
Telephony_NetManager_NetWorkTest
"
,
function
()
{
describe
(
"
Telephony_NetManager_NetWorkTest
"
,
function
()
{
/**
* @tc.number Telephony_NetManager_NetWorkTest_GetType_None_0100
* @tc.name Whether the GetType method is called successfully without WiFi
* @tc.desc Function test
*/
it
(
"
Telephony_NetManager_NetWorkTest_GetType_None_0100
"
,
0
,
function
(
done
)
{
network
.
getType
({
success
:
function
(
data
)
{
console
.
info
(
"
NetManager getType
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
type
===
"
none
"
).
assertTrue
()
expect
(
data
.
metered
===
false
).
assertTrue
()
network
.
unsubscribe
()
done
();
},
fail
:
function
(
data
,
code
)
{
expect
().
assertFail
();
done
();
},
complete
:
function
()
{
expect
().
assertTrue
()
let
networkAvailable
=
()
=>
{
connection
.
getDefaultNet
(
function
(
error
,
netHandle
)
{
if
(
error
||
netHandle
.
netId
>=
100
)
{
console
.
info
(
"
Network available or Network error:
"
+
error
);
return
true
;
}
return
false
;
})
}
/**
* @tc.number Telephony_NetManager_NetWorkTest_GetType_None_0100
* @tc.name Whether the GetType method is called successfully without WiFi
* @tc.desc Function test
*/
it
(
"
Telephony_NetManager_NetWorkTest_GetType_None_0100
"
,
0
,
function
(
done
)
{
if
(
networkAvailable
)
{
console
.
warn
(
"
No network environment required
"
);
done
();
return
;
}
})
done
();
});
network
.
getType
({
success
:
function
(
data
)
{
console
.
info
(
"
NetManager getType
"
+
JSON
.
stringify
(
data
));
expect
(
data
.
type
===
"
none
"
).
assertTrue
();
expect
(
data
.
metered
===
false
).
assertTrue
();
network
.
unsubscribe
();
done
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
data:
"
+
JSON
.
stringify
(
data
)
+
"
code:
"
+
JSON
.
stringify
(
code
));
expect
().
assertFail
();
done
();
},
complete
:
function
()
{
expect
().
assertTrue
();
done
();
}
})
done
();
});
/**
* @tc.number Telephony_NetManager_NetWorkTest_GetType_None_0200
* @tc.name Whether to call GetType method again without WiFi
* @tc.desc Function test
*/
it
(
"
Telephony_NetManager_NetWorkTest_GetType_None_0200
"
,
0
,
function
(
done
)
{
network
.
getType
({
success
:
function
(
data
)
{
console
.
info
(
"
NetManager getType 1
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
type
===
"
none
"
).
assertTrue
()
expect
(
data
.
metered
===
false
).
assertTrue
()
network
.
unsubscribe
()
done
();
console
.
info
(
"
NetManager Telephony_NetManager_NetWorkTest_GetType_none_1 end
"
)
},
fail
:
function
(
data
,
code
)
{
expect
().
assertFail
();
done
();
},
complete
:
function
()
{
expect
().
assertTrue
()
/**
* @tc.number Telephony_NetManager_NetWorkTest_GetType_None_0200
* @tc.name Whether to call GetType method again without WiFi
* @tc.desc Function test
*/
it
(
"
Telephony_NetManager_NetWorkTest_GetType_None_0200
"
,
0
,
function
(
done
)
{
if
(
networkAvailable
)
{
console
.
warn
(
"
No network environment required
"
);
done
();
return
;
}
})
done
();
});
network
.
getType
({
success
:
function
(
data
)
{
console
.
info
(
"
NetManager getType 1
"
+
JSON
.
stringify
(
data
));
expect
(
data
.
type
===
"
none
"
).
assertTrue
();
expect
(
data
.
metered
===
false
).
assertTrue
();
network
.
unsubscribe
();
done
();
console
.
info
(
"
NetManager Telephony_NetManager_NetWorkTest_GetType_none_1 end
"
);
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
data:
"
+
JSON
.
stringify
(
data
)
+
"
code:
"
+
JSON
.
stringify
(
code
));
expect
().
assertFail
();
done
();
},
complete
:
function
()
{
expect
().
assertTrue
();
done
();
}
})
done
();
});
/**
* @tc.number Telephony_NetManager_NetWorkTest_Subscribe_None_0100
* @tc.name Whether the subscribe method is called successfully without WiFi
* @tc.desc Function test
*/
it
(
"
Telephony_NetManager_NetWorkTest_Subscribe_None_0100
"
,
0
,
function
(
done
)
{
network
.
subscribe
({
success
:
function
(
data
)
{
console
.
info
(
"
NetManager subscribe
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
type
===
"
none
"
).
assertTrue
()
expect
(
data
.
metered
===
false
).
assertTrue
()
network
.
unsubscribe
()
done
();
},
fail
:
function
(
data
,
code
)
{
expect
().
assertFail
()
/**
* @tc.number Telephony_NetManager_NetWorkTest_Subscribe_None_0100
* @tc.name Whether the subscribe method is called successfully without WiFi
* @tc.desc Function test
*/
it
(
"
Telephony_NetManager_NetWorkTest_Subscribe_None_0100
"
,
0
,
function
(
done
)
{
if
(
networkAvailable
)
{
console
.
warn
(
"
No network environment required
"
);
done
();
return
;
}
})
done
();
});
network
.
subscribe
({
success
:
function
(
data
)
{
console
.
info
(
"
NetManager subscribe
"
+
JSON
.
stringify
(
data
));
expect
(
data
.
type
===
"
none
"
).
assertTrue
();
expect
(
data
.
metered
===
false
).
assertTrue
();
network
.
unsubscribe
();
done
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
data:
"
+
JSON
.
stringify
(
data
)
+
"
code:
"
+
JSON
.
stringify
(
code
));
expect
().
assertFail
();
done
();
}
})
done
();
});
/**
* @tc.number Telephony_NetManager_NetWorkTest_Subscribe_None_0200
* @tc.name Whether to call the subscribe method again without WiFi
* @tc.desc Function test
*/
it
(
"
Telephony_NetManager_NetWorkTest_Subscribe_None_0200
"
,
0
,
function
(
done
)
{
network
.
subscribe
({
success
:
function
(
data
)
{
console
.
info
(
"
NetManager subscribe
"
+
JSON
.
stringify
(
data
))
expect
(
data
.
type
===
"
none
"
).
assertTrue
()
expect
(
data
.
metered
===
false
).
assertTrue
()
network
.
unsubscribe
()
done
();
},
fail
:
function
(
data
,
code
)
{
expect
().
assertFail
()
/**
* @tc.number Telephony_NetManager_NetWorkTest_Subscribe_None_0200
* @tc.name Whether to call the subscribe method again without WiFi
* @tc.desc Function test
*/
it
(
"
Telephony_NetManager_NetWorkTest_Subscribe_None_0200
"
,
0
,
function
(
done
)
{
if
(
networkAvailable
)
{
console
.
warn
(
"
No network environment required
"
);
done
();
return
;
}
})
done
();
});
network
.
subscribe
({
success
:
function
(
data
)
{
console
.
info
(
"
NetManager subscribe
"
+
JSON
.
stringify
(
data
));
expect
(
data
.
type
===
"
none
"
).
assertTrue
();
expect
(
data
.
metered
===
false
).
assertTrue
();
network
.
unsubscribe
();
done
();
},
fail
:
function
(
data
,
code
)
{
console
.
log
(
"
data:
"
+
JSON
.
stringify
(
data
)
+
"
code:
"
+
JSON
.
stringify
(
code
));
expect
().
assertFail
();
done
();
}
})
done
();
});
});
});
}
\ No newline at end of file
telephony/telephonyjstest/network_search/network_search_errors/src/main/js/test/NetworkSearchErrors.test.js
浏览文件 @
d56bd2b3
/*
* 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
...
...
@@ -15,7 +15,7 @@
import
radio
from
'
@ohos.telephony.radio
'
;
import
observer
from
'
@ohos.telephony.observer
'
;
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
import
{
describe
,
beforeAll
,
beforeEach
,
afterEach
,
afterAll
,
it
,
expect
}
from
'
@ohos/hypium
'
;
export
default
function
ActsNetworkSearchTest
()
{
describe
(
'
ActsNetworkSearchTest
'
,
function
()
{
...
...
@@ -195,13 +195,13 @@ describe('ActsNetworkSearchTest', function () {
console
.
info
(
`Telephony_NetworkSearch_getISOCountryCodeForNetwork_Promise_0400 finish data:
${
JSON
.
stringify
(
data
)}
`
);
expect
(
data
.
length
===
0
).
assertTrue
();
done
();
}
catch
(
err
)
{
console
.
info
(
`Telephony_NetworkSearch_getISOCountryCodeForNetwork_Promise_0400 fail err:
${
err
}
`
);
expect
(
err
.
code
).
assertEqual
(
202
);
done
();
return
;
}
done
();
});
/**
...
...
@@ -381,13 +381,14 @@ describe('ActsNetworkSearchTest', function () {
* @tc.desc Function test
*/
it
(
'
Telephony_NetworkSearch_isRadioOn_Async_0200
'
,
0
,
async
function
(
done
)
{
radio
.
isRadioOn
((
err
)
=>
{
radio
.
isRadioOn
((
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
`Telephony_NetworkSearch_isRadioOn_Async_0200 fail:
${
err
}
`
);
console
.
error
(
'
When the device has no modem, the interface reports an error
'
+
JSON
.
stringify
(
err
)
);
done
();
return
;
}
console
.
info
(
'
Telephony_NetworkSearch_isRadioOn_Async_0200 finish
'
);
console
.
info
(
'
Telephony_NetworkSearch_isRadioOn_Async_0200 finish
'
+
JSON
.
stringify
(
data
));
expect
(
data
==
true
).
assertTrue
();
done
();
});
});
...
...
@@ -399,11 +400,12 @@ describe('ActsNetworkSearchTest', function () {
*/
it
(
'
Telephony_NetworkSearch_isRadioOn_Promise_0200
'
,
0
,
async
function
(
done
)
{
try
{
await
radio
.
isRadioOn
();
console
.
info
(
'
Telephony_NetworkSearch_isRadioOn_Promise_0200 success
'
);
let
data
=
await
radio
.
isRadioOn
();
console
.
info
(
'
Telephony_NetworkSearch_isRadioOn_Promise_0200 finish
'
+
JSON
.
stringify
(
data
));
expect
(
data
==
true
).
assertTrue
();
done
();
}
catch
(
err
)
{
console
.
info
(
`Telephony_NetworkSearch_isRadioOn_Promise_0200 fail
${
err
}
`
);
console
.
error
(
'
When the device has no modem, the interface reports an error
'
+
JSON
.
stringify
(
err
)
);
done
();
}
});
...
...
@@ -413,14 +415,15 @@ describe('ActsNetworkSearchTest', function () {
* @tc.name testIsRadioOn_0300
* @tc.desc Test isRadioOn api by callback.
*/
it
(
'
Telephony_NetworkSearch_isRadioOn_Async_0300
'
,
0
,
async
function
(
done
)
{
radio
.
isRadioOn
(
0
,
(
err
)
=>
{
it
(
'
Telephony_NetworkSearch_isRadioOn_Async_0300
'
,
0
,
async
function
(
done
)
{
radio
.
isRadioOn
(
0
,
(
err
,
data
)
=>
{
if
(
err
)
{
console
.
info
(
`Telephony_NetworkSearch_isRadioOn_Async_0300 fail:
${
err
}
`
);
console
.
error
(
'
When the device has no modem, the interface reports an error
'
+
JSON
.
stringify
(
err
)
);
done
();
return
;
}
console
.
info
(
'
Telephony_NetworkSearch_isRadioOn_Async_0300 finish
'
);
console
.
info
(
'
Telephony_NetworkSearch_isRadioOn_Async_0300 finish
'
+
JSON
.
stringify
(
data
));
expect
(
data
==
true
).
assertTrue
();
done
();
});
});
...
...
@@ -432,11 +435,12 @@ describe('ActsNetworkSearchTest', function () {
*/
it
(
'
Telephony_NetworkSearch_isRadioOn_Promise_0300
'
,
0
,
async
function
(
done
)
{
try
{
await
radio
.
isRadioOn
(
0
);
console
.
info
(
'
Telephony_NetworkSearch_isRadioOn_Promise_0300 success
'
);
let
data
=
await
radio
.
isRadioOn
(
0
);
console
.
info
(
'
Telephony_NetworkSearch_isRadioOn_Promise_0300 finish
'
+
JSON
.
stringify
(
data
));
expect
(
data
==
true
).
assertTrue
();
done
();
}
catch
(
err
)
{
console
.
info
(
`Telephony_NetworkSearch_isRadioOn_Promise_0300 fail
${
err
}
`
);
console
.
error
(
'
When the device has no modem, the interface reports an error
'
+
JSON
.
stringify
(
err
)
);
done
();
}
});
...
...
@@ -447,11 +451,18 @@ describe('ActsNetworkSearchTest', function () {
* @tc.desc Function test
*/
it
(
'
Telephony_StateRegistry_on_0200
'
,
0
,
async
function
(
done
)
{
observer
.
on
(
'
networkStateChange
'
,
{
slotId
:
SLOT_0
},
(
networkState
)
=>
{
console
.
info
(
`Telephony_StateRegistry_on_0200 networkStateChanged data:
${
JSON
.
stringify
(
networkState
)}
`
);
try
{
observer
.
on
(
'
networkStateChange
'
,
{
slotId
:
0
},
NetworkState
=>
{
console
.
log
(
"
on networkStateChange, NetworkState:
"
+
JSON
.
stringify
(
NetworkState
));
expect
(
typeof
NetworkState
===
undefined
).
assertFalse
();
});
done
();
});
done
();
}
catch
(
error
)
{
expect
(
false
).
assertTrue
();
done
();
}
});
/**
...
...
@@ -460,8 +471,20 @@ describe('ActsNetworkSearchTest', function () {
* @tc.desc Function test
*/
it
(
'
Telephony_StateRegistry_off_0200
'
,
0
,
async
function
(
done
)
{
observer
.
off
(
'
networkStateChange
'
);
done
();
try
{
let
callback
=
NetworkState
=>
{
console
.
log
(
"
on networkStateChange, NetworkState:
"
+
JSON
.
stringify
(
NetworkState
));
expect
(
typeof
NetworkState
===
undefined
).
assertFalse
();
}
observer
.
on
(
'
networkStateChange
'
,
callback
);
// 可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。
observer
.
off
(
'
networkStateChange
'
,
callback
);
observer
.
off
(
'
networkStateChange
'
);
done
();
}
catch
(
error
)
{
expect
(
false
).
assertTrue
();
done
();
}
});
/**
...
...
@@ -470,11 +493,18 @@ describe('ActsNetworkSearchTest', function () {
* @tc.desc Function test
*/
it
(
'
Telephony_StateRegistry_on_0300
'
,
0
,
async
function
(
done
)
{
observer
.
on
(
'
signalInfoChange
'
,
{
slotId
:
SLOT_0
},
(
networkState
)
=>
{
console
.
info
(
`Telephony_StateRegistry_on_0200 networkStateChanged data:
${
JSON
.
stringify
(
networkState
)}
`
);
try
{
observer
.
on
(
'
signalInfoChange
'
,
{
slotId
:
0
},
SignalInformation
=>
{
console
.
log
(
"
on signalInfoChange, SignalInformation:
"
+
JSON
.
stringify
(
SignalInformation
));
expect
(
typeof
SignalInformation
===
undefined
).
assertFalse
();
});
done
();
});
done
();
}
catch
(
error
)
{
expect
(
false
).
assertTrue
();
done
();
}
});
/**
...
...
@@ -483,8 +513,20 @@ describe('ActsNetworkSearchTest', function () {
* @tc.desc Function test
*/
it
(
'
Telephony_StateRegistry_off_0300
'
,
0
,
async
function
(
done
)
{
observer
.
off
(
'
signalInfoChange
'
);
done
();
try
{
let
callback
=
SignalInformation
=>
{
console
.
log
(
"
on signalInfoChange, SignalInformation:
"
+
JSON
.
stringify
(
SignalInformation
));
expect
(
typeof
SignalInformation
===
undefined
).
assertFalse
();
}
observer
.
on
(
'
signalInfoChange
'
,
callback
);
// 可以指定传入on中的callback取消一个订阅,也可以不指定callback清空所有订阅。
observer
.
off
(
'
signalInfoChange
'
,
callback
);
observer
.
off
(
'
signalInfoChange
'
);
done
();
}
catch
(
error
)
{
expect
(
false
).
assertTrue
();
done
();
}
});
});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录