提交 f6686aa5 编写于 作者: L lihao

update case

Signed-off-by: Nlihao <lihao334@huawei.com>
上级 615f81b7
......@@ -18,16 +18,20 @@ ohos_js_hap_suite("ActsObserverEtsTest") {
deps = [
":ace_demo_ets_assets",
":ace_demo_ets_resources",
":ace_demo_ets_test_assets",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsObserverEtsTest"
part_name = "netstack"
subsystem_name = "communication"
part_name = "ril_adapter"
subsystem_name = "telephony"
}
ohos_js_assets("ace_demo_ets_assets") {
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") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
......
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "1500000",
"package": "com.ohos.observer",
"shell-timeout": "60000"
"type": "OHJSUnitTest",
"test-timeout": "2000000",
"bundle-name": "com.ohos.observer",
"package-name": "com.ohos.observer",
"shell-timeout": "2000000"
},
"kits": [
{
......
......@@ -17,7 +17,7 @@
"package": "com.ohos.observer",
"name": ".MyApplication",
"mainAbility": ".MainAbility",
"srcPath": "MainAbility",
"srcPath": "",
"deviceType": [
"phone"
],
......@@ -50,6 +50,19 @@
"label": "$string:entry_MainAbility",
"type": "page",
"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": [
......@@ -130,6 +143,20 @@
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
......
......@@ -13,39 +13,11 @@
* See the License for the specific language governing permissions and
* 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
@Component
struct MyComponent {
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() {
......
/*
* 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() {
*/
it('Telephony_observer_observer_DataConnectState_0200', 0, function (done) {
console.log("************* Telephony_observer_observer_DataConnectState_0200 Test start *************")
if (utils.notCheck) {
expect(true).assertTrue()
done()
}
// console.log(observer.DataConnectState)
console.log("Telephony_observer_observer_DataConnectState_0200" + observer.DataConnectState)
expect(observer.DataConnectState == undefined).assertTrue();
console.log("************* Telephony_observer_observer_DataConnectState_0200 Test end *************")
done();
})
/*
......@@ -82,11 +80,8 @@ export default function observerJsunit() {
*/
it('Telephony_observer_observer_RatType_0100', 0, async function (done) {
console.log("************* Telephony_observer_observer_RatType_0100 Test start *************")
if (utils.notCheck) {
expect(true).assertTrue()
done()
}
// console.log(observer.RatType)
console.log("Telephony_observer_observer_RatType_0100" +observer.RatType)
expect(observer.RatType == undefined).assertTrue();
console.log("************* Telephony_observer_observer_RatType_0100 Test end *************")
done()
})
......@@ -103,7 +98,7 @@ export default function observerJsunit() {
done()
return
})
setTimeout(timeout, 3000)
//setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_on_networkStateChange_0100 Test end *************")
done()
})
......@@ -122,7 +117,7 @@ export default function observerJsunit() {
done()
return
})
setTimeout(timeout, 3000)
//setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_on_networkStateChange_0200 Test end *************")
done()
})
......@@ -139,7 +134,7 @@ export default function observerJsunit() {
done()
return
})
setTimeout(timeout, 3000)
//setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_off_networkStateChange_0100 Test end *************")
done()
})
......@@ -156,7 +151,7 @@ export default function observerJsunit() {
done()
return
})
setTimeout(timeout, 3000)
//setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_on_signalInfoChange_0100 Test end *************")
done()
})
......@@ -175,7 +170,7 @@ export default function observerJsunit() {
done()
return
})
setTimeout(timeout, 3000)
//setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_on_signalInfoChange_0200 Test end *************")
done()
})
......@@ -192,7 +187,7 @@ export default function observerJsunit() {
done()
return
})
setTimeout(timeout, 3000)
//setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_off_signalInfoChange_0100 Test end *************")
done()
})
......@@ -211,7 +206,7 @@ export default function observerJsunit() {
done()
return
})
setTimeout(timeout, 3000)
//setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_on_cellularDataConnectionStateChange_0100 Test end *************")
done()
})
......@@ -230,7 +225,7 @@ export default function observerJsunit() {
done()
return
})
setTimeout(timeout, 3000)
//setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_on_cellularDataConnectionStateChange_0200 Test end *************")
done()
})
......@@ -247,7 +242,7 @@ export default function observerJsunit() {
done()
return
})
setTimeout(timeout, 3000)
//setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_off_cellularDataConnectionStateChange_0100 Test end *************")
done()
})
......@@ -264,7 +259,7 @@ export default function observerJsunit() {
done()
return
})
setTimeout(timeout, 3000)
//setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_on_cellularDataFlowChange_0100 Test end *************")
done()
})
......@@ -283,7 +278,7 @@ export default function observerJsunit() {
done()
return
})
setTimeout(timeout, 3000)
//setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_on_cellularDataFlowChange_0200 Test end *************")
done()
})
......@@ -300,7 +295,7 @@ export default function observerJsunit() {
done()
return
})
setTimeout(timeout, 3000)
//setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_off_cellularDataFlowChange_0100 Test end *************")
done()
})
......@@ -317,7 +312,7 @@ export default function observerJsunit() {
done()
return
})
setTimeout(timeout, 3000)
//setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_on_callStateChange_0100 Test end *************")
done()
})
......@@ -336,7 +331,7 @@ export default function observerJsunit() {
done()
return
})
setTimeout(timeout, 3000)
//setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_on_callStateChange_0200 Test end *************")
done()
})
......@@ -353,7 +348,7 @@ export default function observerJsunit() {
done()
return
})
setTimeout(timeout, 3000)
//setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_off_callStateChange_0100 Test end *************")
done()
})
......@@ -370,7 +365,7 @@ export default function observerJsunit() {
done()
return
})
setTimeout(timeout, 3000)
//setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_on_simStateChange_0100 Test end *************")
done()
})
......@@ -389,7 +384,7 @@ export default function observerJsunit() {
done()
return
})
setTimeout(timeout, 3000)
//setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_on_simStateChange_0200 Test end *************")
done()
})
......@@ -406,7 +401,7 @@ export default function observerJsunit() {
done()
return
})
setTimeout(timeout, 3000)
//setTimeout(timeout, 3000)
console.log("************* Telephony_observer_observer_off_simStateChange_0100 Test end *************")
done()
})
......
......@@ -7,6 +7,14 @@
{
"name": "description_mainability",
"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.
先完成此消息的编辑!
想要评论请 注册