未验证 提交 9d71b998 编写于 作者: O openharmony_ci 提交者: Gitee

!5591 电话子系统新增接口,添加用例

Merge pull request !5591 from 李昊/master
...@@ -202,5 +202,14 @@ describe("ActsCellularDataAbnormalTest", function () { ...@@ -202,5 +202,14 @@ describe("ActsCellularDataAbnormalTest", function () {
done(); done();
} }
}) })
it("Telephony_CellularData_getDefaultCellularDataSlotIdSync_0100", 0, async function (done) {
let data = cellular.getDefaultCellularDataSlotIdSync();
console.info("Telephony_CellularData_getDefaultCellularDataSlotIdSync_0100 " + JSON.stringify(data));
expect(data == 0 || data == 1).assertTrue;
done();
});
}) })
} }
...@@ -158,5 +158,11 @@ export default function Telephony_NETMANAGER_TestDNSTest() { ...@@ -158,5 +158,11 @@ export default function Telephony_NETMANAGER_TestDNSTest() {
}) })
}); });
it('Telephony_NETMANAGER_TestDNS_Test0900', 0, function(done){
let netHandle = netConnection.getDefaultNetSync();
console.info("Telephony_NETMANAGER_TestDNS_Test0900 " + JSON.stringify(netHandle));
expect(netHandle.netId).assertEqual(100);
done();
});
}); });
} }
\ No newline at end of file
...@@ -18,16 +18,20 @@ ohos_js_hap_suite("ActsObserverEtsTest") { ...@@ -18,16 +18,20 @@ ohos_js_hap_suite("ActsObserverEtsTest") {
deps = [ deps = [
":ace_demo_ets_assets", ":ace_demo_ets_assets",
":ace_demo_ets_resources", ":ace_demo_ets_resources",
":ace_demo_ets_test_assets",
] ]
ets2abc = true ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b" certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsObserverEtsTest" hap_name = "ActsObserverEtsTest"
part_name = "netstack" part_name = "ril_adapter"
subsystem_name = "communication" subsystem_name = "telephony"
} }
ohos_js_assets("ace_demo_ets_assets") { ohos_js_assets("ace_demo_ets_assets") {
source_dir = "./entry/src/main/ets/MainAbility" source_dir = "./entry/src/main/ets/MainAbility"
} }
ohos_js_assets("ace_demo_ets_test_assets") {
source_dir = "./entry/src/main/ets/TestAbility"
}
ohos_resources("ace_demo_ets_resources") { ohos_resources("ace_demo_ets_resources") {
sources = [ "./entry/src/main/resources" ] sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json" hap_profile = "./entry/src/main/config.json"
......
{ {
"description": "Configuration for hjunit demo Tests", "description": "Configuration for hjunit demo Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "OHJSUnitTest",
"test-timeout": "1500000", "test-timeout": "2000000",
"package": "com.ohos.observer", "bundle-name": "com.ohos.observer",
"shell-timeout": "60000" "package-name": "com.ohos.observer",
"shell-timeout": "2000000"
}, },
"kits": [ "kits": [
{ {
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
"package": "com.ohos.observer", "package": "com.ohos.observer",
"name": ".MyApplication", "name": ".MyApplication",
"mainAbility": ".MainAbility", "mainAbility": ".MainAbility",
"srcPath": "MainAbility", "srcPath": "",
"deviceType": [ "deviceType": [
"phone" "phone"
], ],
...@@ -50,6 +50,19 @@ ...@@ -50,6 +50,19 @@
"label": "$string:entry_MainAbility", "label": "$string:entry_MainAbility",
"type": "page", "type": "page",
"launchType": "standard" "launchType": "standard"
},
{
"orientation": "unspecified",
"visible": true,
"srcPath": "TestAbility",
"name": ".TestAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"formsEnabled": false,
"label": "$string:TestAbility_label",
"type": "page",
"launchType": "standard"
} }
], ],
"reqPermissions": [ "reqPermissions": [
...@@ -130,6 +143,20 @@ ...@@ -130,6 +143,20 @@
"designWidth": 720, "designWidth": 720,
"autoDesignWidth": false "autoDesignWidth": false
} }
},
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
} }
] ]
} }
......
...@@ -13,39 +13,11 @@ ...@@ -13,39 +13,11 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import file from '@system.file';
import {Core, ExpectExtend, InstrumentLog, ReportExtend} from "deccjsunit/index.ets";
import testsuite from "../test/List.test.ets";
import featureAbility from "@ohos.ability.featureAbility";
@Entry @Entry
@Component @Component
struct MyComponent { struct MyComponent {
aboutToAppear() { aboutToAppear() {
console.info("start run testcase!!!!")
featureAbility.getWant()
.then((Want) => {
const core = Core.getInstance();
const expectExtend = new ExpectExtend({
'id': 'extend'
});
core.addService('expect', expectExtend);
const reportExtend = new ReportExtend(file);
core.addService('report', reportExtend);
core.init();
core.subscribeEvent('task', reportExtend);
const configService = core.getDefaultService('config');
Want.parameters['timeout'] = 100000
console.info('parameters---->' + JSON.stringify(Want.parameters));
configService.setConfig(Want.parameters);
testsuite();
core.execute();
console.info('Operation successful. Data: ' + JSON.stringify(Want));
})
.catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
})
} }
build() { build() {
......
/*
* Copyright (C) 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
*
* 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from 'hypium/index'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('Application onCreate')
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info('Application onDestroy')
},
}
\ No newline at end of file
/*
* Copyright (C) 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
*
* 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 router from '@system.router';
@Entry
@Component
struct Index {
aboutToAppear() {
console.info('TestAbility index aboutToAppear')
}
@State message: string = 'Hello World'
build() {
Row() {
Column() {
Text(this.message)
.fontSize(50)
.fontWeight(FontWeight.Bold)
Button() {
Text('next page')
.fontSize(20)
.fontWeight(FontWeight.Bold)
}.type(ButtonType.Capsule)
.margin({
top: 20
})
.backgroundColor('#0D9FFB')
.width('35%')
.height('5%')
.onClick(()=>{
})
}
.width('100%')
}
.height('100%')
}
}
\ No newline at end of file
/*
* Copyright (C) 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
*
* 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 TestRunner from '@ohos.application.testRunner'
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
var abilityDelegator = undefined
var abilityDelegatorArguments = undefined
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
async function onAbilityCreateCallback() {
console.log('onAbilityCreateCallback');
}
async function addAbilityMonitorCallback(err: any) {
console.info('addAbilityMonitorCallback : ' + JSON.stringify(err))
}
export default class OpenHarmonyTestRunner implements TestRunner {
constructor() {
}
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
}
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd,
(err: any, d: any) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + d.stdResult);
console.info('executeShellCommand : data : ' + d.exitCode);
})
console.info('OpenHarmonyTestRunner onRun call abilityDelegator.getAppContext')
var context = abilityDelegator.getAppContext()
console.info('getAppContext : ' + JSON.stringify(context))
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ No newline at end of file
...@@ -67,12 +67,10 @@ export default function observerJsunit() { ...@@ -67,12 +67,10 @@ export default function observerJsunit() {
*/ */
it('Telephony_observer_observer_DataConnectState_0200', 0, function (done) { it('Telephony_observer_observer_DataConnectState_0200', 0, function (done) {
console.log("************* Telephony_observer_observer_DataConnectState_0200 Test start *************") console.log("************* Telephony_observer_observer_DataConnectState_0200 Test start *************")
if (utils.notCheck) { console.log("Telephony_observer_observer_DataConnectState_0200" + observer.DataConnectState)
expect(true).assertTrue() expect(observer.DataConnectState == undefined).assertTrue();
done()
}
// console.log(observer.DataConnectState)
console.log("************* Telephony_observer_observer_DataConnectState_0200 Test end *************") console.log("************* Telephony_observer_observer_DataConnectState_0200 Test end *************")
done();
}) })
/* /*
...@@ -82,11 +80,8 @@ export default function observerJsunit() { ...@@ -82,11 +80,8 @@ export default function observerJsunit() {
*/ */
it('Telephony_observer_observer_RatType_0100', 0, async function (done) { it('Telephony_observer_observer_RatType_0100', 0, async function (done) {
console.log("************* Telephony_observer_observer_RatType_0100 Test start *************") console.log("************* Telephony_observer_observer_RatType_0100 Test start *************")
if (utils.notCheck) { console.log("Telephony_observer_observer_RatType_0100" +observer.RatType)
expect(true).assertTrue() expect(observer.RatType == undefined).assertTrue();
done()
}
// console.log(observer.RatType)
console.log("************* Telephony_observer_observer_RatType_0100 Test end *************") console.log("************* Telephony_observer_observer_RatType_0100 Test end *************")
done() done()
}) })
...@@ -103,7 +98,6 @@ export default function observerJsunit() { ...@@ -103,7 +98,6 @@ export default function observerJsunit() {
done() done()
return return
}) })
setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_on_networkStateChange_0100 Test end *************") console.log("************* Telephony_observer_observer_on_networkStateChange_0100 Test end *************")
done() done()
}) })
...@@ -122,7 +116,6 @@ export default function observerJsunit() { ...@@ -122,7 +116,6 @@ export default function observerJsunit() {
done() done()
return return
}) })
setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_on_networkStateChange_0200 Test end *************") console.log("************* Telephony_observer_observer_on_networkStateChange_0200 Test end *************")
done() done()
}) })
...@@ -139,7 +132,6 @@ export default function observerJsunit() { ...@@ -139,7 +132,6 @@ export default function observerJsunit() {
done() done()
return return
}) })
setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_off_networkStateChange_0100 Test end *************") console.log("************* Telephony_observer_observer_off_networkStateChange_0100 Test end *************")
done() done()
}) })
...@@ -156,7 +148,6 @@ export default function observerJsunit() { ...@@ -156,7 +148,6 @@ export default function observerJsunit() {
done() done()
return return
}) })
setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_on_signalInfoChange_0100 Test end *************") console.log("************* Telephony_observer_observer_on_signalInfoChange_0100 Test end *************")
done() done()
}) })
...@@ -175,7 +166,6 @@ export default function observerJsunit() { ...@@ -175,7 +166,6 @@ export default function observerJsunit() {
done() done()
return return
}) })
setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_on_signalInfoChange_0200 Test end *************") console.log("************* Telephony_observer_observer_on_signalInfoChange_0200 Test end *************")
done() done()
}) })
...@@ -192,7 +182,6 @@ export default function observerJsunit() { ...@@ -192,7 +182,6 @@ export default function observerJsunit() {
done() done()
return return
}) })
setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_off_signalInfoChange_0100 Test end *************") console.log("************* Telephony_observer_observer_off_signalInfoChange_0100 Test end *************")
done() done()
}) })
...@@ -211,7 +200,6 @@ export default function observerJsunit() { ...@@ -211,7 +200,6 @@ export default function observerJsunit() {
done() done()
return return
}) })
setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_on_cellularDataConnectionStateChange_0100 Test end *************") console.log("************* Telephony_observer_observer_on_cellularDataConnectionStateChange_0100 Test end *************")
done() done()
}) })
...@@ -230,7 +218,6 @@ export default function observerJsunit() { ...@@ -230,7 +218,6 @@ export default function observerJsunit() {
done() done()
return return
}) })
setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_on_cellularDataConnectionStateChange_0200 Test end *************") console.log("************* Telephony_observer_observer_on_cellularDataConnectionStateChange_0200 Test end *************")
done() done()
}) })
...@@ -247,7 +234,6 @@ export default function observerJsunit() { ...@@ -247,7 +234,6 @@ export default function observerJsunit() {
done() done()
return return
}) })
setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_off_cellularDataConnectionStateChange_0100 Test end *************") console.log("************* Telephony_observer_observer_off_cellularDataConnectionStateChange_0100 Test end *************")
done() done()
}) })
...@@ -264,7 +250,6 @@ export default function observerJsunit() { ...@@ -264,7 +250,6 @@ export default function observerJsunit() {
done() done()
return return
}) })
setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_on_cellularDataFlowChange_0100 Test end *************") console.log("************* Telephony_observer_observer_on_cellularDataFlowChange_0100 Test end *************")
done() done()
}) })
...@@ -283,7 +268,6 @@ export default function observerJsunit() { ...@@ -283,7 +268,6 @@ export default function observerJsunit() {
done() done()
return return
}) })
setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_on_cellularDataFlowChange_0200 Test end *************") console.log("************* Telephony_observer_observer_on_cellularDataFlowChange_0200 Test end *************")
done() done()
}) })
...@@ -300,7 +284,6 @@ export default function observerJsunit() { ...@@ -300,7 +284,6 @@ export default function observerJsunit() {
done() done()
return return
}) })
setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_off_cellularDataFlowChange_0100 Test end *************") console.log("************* Telephony_observer_observer_off_cellularDataFlowChange_0100 Test end *************")
done() done()
}) })
...@@ -317,7 +300,6 @@ export default function observerJsunit() { ...@@ -317,7 +300,6 @@ export default function observerJsunit() {
done() done()
return return
}) })
setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_on_callStateChange_0100 Test end *************") console.log("************* Telephony_observer_observer_on_callStateChange_0100 Test end *************")
done() done()
}) })
...@@ -336,7 +318,6 @@ export default function observerJsunit() { ...@@ -336,7 +318,6 @@ export default function observerJsunit() {
done() done()
return return
}) })
setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_on_callStateChange_0200 Test end *************") console.log("************* Telephony_observer_observer_on_callStateChange_0200 Test end *************")
done() done()
}) })
...@@ -353,7 +334,6 @@ export default function observerJsunit() { ...@@ -353,7 +334,6 @@ export default function observerJsunit() {
done() done()
return return
}) })
setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_off_callStateChange_0100 Test end *************") console.log("************* Telephony_observer_observer_off_callStateChange_0100 Test end *************")
done() done()
}) })
...@@ -370,7 +350,6 @@ export default function observerJsunit() { ...@@ -370,7 +350,6 @@ export default function observerJsunit() {
done() done()
return return
}) })
setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_on_simStateChange_0100 Test end *************") console.log("************* Telephony_observer_observer_on_simStateChange_0100 Test end *************")
done() done()
}) })
...@@ -389,7 +368,6 @@ export default function observerJsunit() { ...@@ -389,7 +368,6 @@ export default function observerJsunit() {
done() done()
return return
}) })
setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_on_simStateChange_0200 Test end *************") console.log("************* Telephony_observer_observer_on_simStateChange_0200 Test end *************")
done() done()
}) })
...@@ -406,7 +384,6 @@ export default function observerJsunit() { ...@@ -406,7 +384,6 @@ export default function observerJsunit() {
done() done()
return return
}) })
setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_off_simStateChange_0100 Test end *************") console.log("************* Telephony_observer_observer_off_simStateChange_0100 Test end *************")
done() done()
}) })
......
...@@ -7,6 +7,14 @@ ...@@ -7,6 +7,14 @@
{ {
"name": "description_mainability", "name": "description_mainability",
"value": "ETS_Empty Ability" "value": "ETS_Empty Ability"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
} }
] ]
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册