diff --git a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/test/CellularDataAbnorma.test.js b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/test/CellularDataAbnorma.test.js index 019dd98b049bbca1e2501fce6f3625f8ba94e1a0..a4d56caa43a715b9ea6322ff5b5a8faf0beb66f2 100644 --- a/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/test/CellularDataAbnorma.test.js +++ b/telephony/telephonyjstest/cellular_data/cellular_data_abnormal/src/main/js/test/CellularDataAbnorma.test.js @@ -202,5 +202,14 @@ describe("ActsCellularDataAbnormalTest", function () { 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(); + }); + + }) } diff --git a/telephony/telephonyjstest/netmanager_base/dns/src/main/js/test/NetworkManagerDNS.test.js b/telephony/telephonyjstest/netmanager_base/dns/src/main/js/test/NetworkManagerDNS.test.js index 4f4c11aad964691b6f5faa671a363768afd8d59a..145bb50712f6be5994d51c8de6de4d5fe36113e5 100644 --- a/telephony/telephonyjstest/netmanager_base/dns/src/main/js/test/NetworkManagerDNS.test.js +++ b/telephony/telephonyjstest/netmanager_base/dns/src/main/js/test/NetworkManagerDNS.test.js @@ -157,6 +157,12 @@ 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 diff --git a/telephony/telephonyjstest/observer/BUILD.gn b/telephony/telephonyjstest/observer/BUILD.gn index 33e77410581d710a965e377abc146279c9d043ac..baaf67c06fbda879f51061a2d787f22de36d0689 100644 --- a/telephony/telephonyjstest/observer/BUILD.gn +++ b/telephony/telephonyjstest/observer/BUILD.gn @@ -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" diff --git a/telephony/telephonyjstest/observer/Test.json b/telephony/telephonyjstest/observer/Test.json index 1e5f519576f040a40ecc4bc8aa0f7e4f48957361..1af9adb89f1ba913a3f98a7362898346dfc2028d 100644 --- a/telephony/telephonyjstest/observer/Test.json +++ b/telephony/telephonyjstest/observer/Test.json @@ -1,10 +1,11 @@ { "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": [ { diff --git a/telephony/telephonyjstest/observer/entry/src/main/config.json b/telephony/telephonyjstest/observer/entry/src/main/config.json index c725d37861ca00572963c008682a58983af6c24e..1f5e144b4c510da093cef06f48d5141180495ad7 100644 --- a/telephony/telephonyjstest/observer/entry/src/main/config.json +++ b/telephony/telephonyjstest/observer/entry/src/main/config.json @@ -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 + } } ] } diff --git a/telephony/telephonyjstest/observer/entry/src/main/ets/MainAbility/pages/index.ets b/telephony/telephonyjstest/observer/entry/src/main/ets/MainAbility/pages/index.ets index 10359134da915c9b44b0836ba4881bca71f43f33..987f3a954fdecfaede4540d18cb97a080cb2a826 100644 --- a/telephony/telephonyjstest/observer/entry/src/main/ets/MainAbility/pages/index.ets +++ b/telephony/telephonyjstest/observer/entry/src/main/ets/MainAbility/pages/index.ets @@ -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() { diff --git a/telephony/telephonyjstest/observer/entry/src/main/ets/TestAbility/app.ets b/telephony/telephonyjstest/observer/entry/src/main/ets/TestAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..1405dd359f629939894b86e2b285cb2cc1b37aa6 --- /dev/null +++ b/telephony/telephonyjstest/observer/entry/src/main/ets/TestAbility/app.ets @@ -0,0 +1,32 @@ +/* + * 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 diff --git a/telephony/telephonyjstest/observer/entry/src/main/ets/TestAbility/pages/index.ets b/telephony/telephonyjstest/observer/entry/src/main/ets/TestAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..52663437cb619d4598126cf403d3689cb31ba131 --- /dev/null +++ b/telephony/telephonyjstest/observer/entry/src/main/ets/TestAbility/pages/index.ets @@ -0,0 +1,49 @@ +/* + * 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 diff --git a/telephony/telephonyjstest/observer/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts b/telephony/telephonyjstest/observer/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000000000000000000000000000000000000..14e78a653e030645860bcc3e7eb6c600b098127b --- /dev/null +++ b/telephony/telephonyjstest/observer/entry/src/main/ets/TestRunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,77 @@ +/* + * 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 diff --git a/telephony/telephonyjstest/observer/entry/src/main/ets/MainAbility/test/List.test.ets b/telephony/telephonyjstest/observer/entry/src/main/ets/test/List.test.ets similarity index 100% rename from telephony/telephonyjstest/observer/entry/src/main/ets/MainAbility/test/List.test.ets rename to telephony/telephonyjstest/observer/entry/src/main/ets/test/List.test.ets diff --git a/telephony/telephonyjstest/observer/entry/src/main/ets/MainAbility/test/ObserverJsunit.test.ets b/telephony/telephonyjstest/observer/entry/src/main/ets/test/ObserverJsunit.test.ets similarity index 97% rename from telephony/telephonyjstest/observer/entry/src/main/ets/MainAbility/test/ObserverJsunit.test.ets rename to telephony/telephonyjstest/observer/entry/src/main/ets/test/ObserverJsunit.test.ets index 22c8e5566e0c8a375b0da7af707fafe619522a7f..8391cdabf2ca09ad7080b64a96eb748c1e9e5ce1 100644 --- a/telephony/telephonyjstest/observer/entry/src/main/ets/MainAbility/test/ObserverJsunit.test.ets +++ b/telephony/telephonyjstest/observer/entry/src/main/ets/test/ObserverJsunit.test.ets @@ -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,6 @@ export default function observerJsunit() { done() return }) - setTimeout(timeout, 3000) console.log("************* Telephony_observer_observer_on_networkStateChange_0100 Test end *************") done() }) @@ -122,7 +116,6 @@ export default function observerJsunit() { done() return }) - setTimeout(timeout, 3000) console.log("************* Telephony_observer_observer_on_networkStateChange_0200 Test end *************") done() }) @@ -139,7 +132,6 @@ export default function observerJsunit() { done() return }) - setTimeout(timeout, 3000) console.log("************* Telephony_observer_observer_off_networkStateChange_0100 Test end *************") done() }) @@ -156,7 +148,6 @@ export default function observerJsunit() { done() return }) - setTimeout(timeout, 3000) console.log("************* Telephony_observer_observer_on_signalInfoChange_0100 Test end *************") done() }) @@ -175,7 +166,6 @@ export default function observerJsunit() { done() return }) - setTimeout(timeout, 3000) console.log("************* Telephony_observer_observer_on_signalInfoChange_0200 Test end *************") done() }) @@ -192,7 +182,6 @@ export default function observerJsunit() { done() return }) - setTimeout(timeout, 3000) console.log("************* Telephony_observer_observer_off_signalInfoChange_0100 Test end *************") done() }) @@ -211,7 +200,6 @@ export default function observerJsunit() { done() return }) - setTimeout(timeout, 3000) console.log("************* Telephony_observer_observer_on_cellularDataConnectionStateChange_0100 Test end *************") done() }) @@ -230,7 +218,6 @@ export default function observerJsunit() { done() return }) - setTimeout(timeout, 3000) console.log("************* Telephony_observer_observer_on_cellularDataConnectionStateChange_0200 Test end *************") done() }) @@ -247,7 +234,6 @@ export default function observerJsunit() { done() return }) - setTimeout(timeout, 3000) console.log("************* Telephony_observer_observer_off_cellularDataConnectionStateChange_0100 Test end *************") done() }) @@ -264,7 +250,6 @@ export default function observerJsunit() { done() return }) - setTimeout(timeout, 3000) console.log("************* Telephony_observer_observer_on_cellularDataFlowChange_0100 Test end *************") done() }) @@ -283,7 +268,6 @@ export default function observerJsunit() { done() return }) - setTimeout(timeout, 3000) console.log("************* Telephony_observer_observer_on_cellularDataFlowChange_0200 Test end *************") done() }) @@ -300,7 +284,6 @@ export default function observerJsunit() { done() return }) - setTimeout(timeout, 3000) console.log("************* Telephony_observer_observer_off_cellularDataFlowChange_0100 Test end *************") done() }) @@ -317,7 +300,6 @@ export default function observerJsunit() { done() return }) - setTimeout(timeout, 3000) console.log("************* Telephony_observer_observer_on_callStateChange_0100 Test end *************") done() }) @@ -336,7 +318,6 @@ export default function observerJsunit() { done() return }) - setTimeout(timeout, 3000) console.log("************* Telephony_observer_observer_on_callStateChange_0200 Test end *************") done() }) @@ -353,7 +334,6 @@ export default function observerJsunit() { done() return }) - setTimeout(timeout, 3000) console.log("************* Telephony_observer_observer_off_callStateChange_0100 Test end *************") done() }) @@ -370,7 +350,6 @@ export default function observerJsunit() { done() return }) - setTimeout(timeout, 3000) console.log("************* Telephony_observer_observer_on_simStateChange_0100 Test end *************") done() }) @@ -389,7 +368,6 @@ export default function observerJsunit() { done() return }) - setTimeout(timeout, 3000) console.log("************* Telephony_observer_observer_on_simStateChange_0200 Test end *************") done() }) @@ -406,7 +384,6 @@ export default function observerJsunit() { done() return }) - setTimeout(timeout, 3000) console.log("************* Telephony_observer_observer_off_simStateChange_0100 Test end *************") done() }) diff --git a/telephony/telephonyjstest/observer/entry/src/main/ets/MainAbility/test/Utils.ets b/telephony/telephonyjstest/observer/entry/src/main/ets/test/Utils.ets similarity index 100% rename from telephony/telephonyjstest/observer/entry/src/main/ets/MainAbility/test/Utils.ets rename to telephony/telephonyjstest/observer/entry/src/main/ets/test/Utils.ets diff --git a/telephony/telephonyjstest/observer/entry/src/main/ets/MainAbility/test/lib/Const.js b/telephony/telephonyjstest/observer/entry/src/main/ets/test/lib/Const.js similarity index 100% rename from telephony/telephonyjstest/observer/entry/src/main/ets/MainAbility/test/lib/Const.js rename to telephony/telephonyjstest/observer/entry/src/main/ets/test/lib/Const.js diff --git a/telephony/telephonyjstest/observer/entry/src/main/resources/base/element/string.json b/telephony/telephonyjstest/observer/entry/src/main/resources/base/element/string.json index 03b8532c53ca563f8ed6b1e21d20ad3f67a68906..498677efbde065c36668727190d3613cbf278bfc 100644 --- a/telephony/telephonyjstest/observer/entry/src/main/resources/base/element/string.json +++ b/telephony/telephonyjstest/observer/entry/src/main/resources/base/element/string.json @@ -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