提交 574a5237 编写于 作者: G gaoxi

os

Signed-off-by: Ngaoxi <gaoxi785@huawei.com>
上级 a6e883dd
......@@ -21,7 +21,7 @@ group("telephonyjstest") {
"netmanager_socket:ActsNetManagerSocketEtsTest",
"network_search:network_search",
"observer:ActsObserverEtsTest",
"radiostatistic:ActsRadiostatisticEtsTest",
"radiostatistic:ActsRadioStatisticEtsTest",
"sim:sim",
"sms_mms:sms_mms",
]
......
......@@ -18,7 +18,6 @@ ohos_js_hap_suite("ActsNetManagerHttpEtsTest") {
deps = [
":ace_demo_ets_assets",
":ace_demo_ets_resources",
":ace_demo_ets_test_assets",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
......@@ -27,9 +26,6 @@ ohos_js_hap_suite("ActsNetManagerHttpEtsTest") {
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": "OHJSUnitTest",
"test-timeout": "1800000",
"bundle-name": "com.ohos.netmanagerhttp",
"package-name": "com.ohos.netmanagerhttp",
"shell-timeout": "1800000"
"type": "JSUnitTest",
"test-timeout": "1500000",
"package": "com.ohos.netmanagerhttp",
"shell-timeout": "60000"
},
"kits": [
{
......
......@@ -17,7 +17,7 @@
"package": "com.ohos.netmanagerhttp",
"name": ".MyApplication",
"mainAbility": ".MainAbility",
"srcPath": "",
"srcPath": "MainAbility",
"deviceType": [
"phone"
],
......@@ -50,19 +50,6 @@
"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": [
......@@ -146,20 +133,6 @@
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
......
......@@ -13,11 +13,39 @@
* 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) 2021 Huawei Device Co., Ltd.
* 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
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, afterAll, it, expect, afterEach} from 'hypium/index';
import {describe, beforeAll, afterAll, it, expect, afterEach} from 'deccjsunit/index';
import http from '@ohos.net.http';
export default function httpJsunit() {
......
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* 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
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, afterAll, it, expect, afterEach} from 'deccjsunit/index.ets';
import {describe, beforeAll, afterAll, it, expect, afterEach} from 'deccjsunit/index';
import http from '@ohos.net.http';
import utils from './Utils.ets'
......
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* 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
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, afterAll, it, expect, afterEach} from 'hypium/index';
import {describe, beforeAll, afterAll, it, expect, afterEach} from 'deccjsunit/index';
import http from '@ohos.net.http';
import utils from './Utils.ets'
......
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* 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
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, afterAll, it, expect, afterEach} from 'hypium/index';
import {describe, beforeAll, afterAll, it, expect, afterEach} from 'deccjsunit/index';
import http from '@ohos.net.http';
import utils from './Utils.ets'
......
......@@ -14,12 +14,12 @@
*/
//other import
import httpJsunit from './HttpJsunit.test.ets'
import responseCodeJsunit from './ResponseCodeJsunit.test.ets';
import requestMethodJsunit from './RequestMethodJsunit.test.ets';
import httpResponseJsunit from './HttpResponseJsunit.test.ets';
import HttpRequestOptionsJsunit from './HttpRequestOptionsJsunit.test.ets';
import httpRequestJsunit from './HttpRequestJsunit.test.ets';
import httpJsunit from './HttpJsunit.test'
import responseCodeJsunit from './ResponseCodeJsunit.test';
import requestMethodJsunit from './RequestMethodJsunit.test';
import httpResponseJsunit from './HttpResponseJsunit.test';
import HttpRequestOptionsJsunit from './HttpRequestOptionsJsunit.test';
import httpRequestJsunit from './HttpRequestJsunit.test';
export default function testsuite() {
//other
......
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* 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
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, afterAll, it, expect, afterEach} from 'hypium/index';
import {describe, beforeAll, afterAll, it, expect, afterEach} from 'deccjsunit/index';
import http from '@ohos.net.http';
import utils from './Utils.ets'
......
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* 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
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, afterAll, it, expect, afterEach} from 'hypium/index';
import {describe, beforeAll, afterAll, it, expect, afterEach} from 'deccjsunit/index';
import http from '@ohos.net.http';
export default function responseCodeJsunit() {
......
/*
* 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
......@@ -7,14 +7,6 @@
{
"name": "description_mainability",
"value": "ETS_Empty Ability"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
......@@ -18,7 +18,6 @@ ohos_js_hap_suite("ActsNetManagerSocketEtsTest") {
deps = [
":ace_demo_ets_assets",
":ace_demo_ets_resources",
":ace_demo_ets_test_assets",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
......@@ -27,9 +26,6 @@ ohos_js_hap_suite("ActsNetManagerSocketEtsTest") {
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": "OHJSUnitTest",
"test-timeout": "1800000",
"bundle-name": "com.ohos.netmanagersocket",
"package-name": "com.ohos.netmanagersocket",
"shell-timeout": "1800000"
"type": "JSUnitTest",
"test-timeout": "1500000",
"package": "com.ohos.netmanagersocket",
"shell-timeout": "60000"
},
"kits": [
{
......
......@@ -17,7 +17,7 @@
"package": "com.ohos.netmanagersocket",
"name": ".MyApplication",
"mainAbility": ".MainAbility",
"srcPath": "",
"srcPath": "MainAbility",
"deviceType": [
"phone"
],
......@@ -50,19 +50,6 @@
"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": [
......@@ -146,20 +133,6 @@
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
......
......@@ -13,11 +13,39 @@
* 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() {
......
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, it, expect} from 'hypium/index';
import {describe, it, expect} from 'deccjsunit/index';
import connection from '@ohos.net.connection'
import utils from './Utils.ets'
......
// @ts-nocheck
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* 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
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
import connection from '@ohos.net.connection';
import {describe, it, expect} from 'hypium/index';
import {describe, it, expect} from 'deccjsunit/index';
import utils from './Utils.ets'
export default function connectionSecondJsUnit() {
......
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
......@@ -14,7 +14,7 @@
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'hypium/index';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index';
import socket from '@ohos.net.socket'
import utils from './Utils.ets'
......@@ -655,7 +655,7 @@ export default function socketJsunit() {
broadcast: true
}
try{
udp.setExtraOptions(udpExtraOptions, funtion(error,data) {
udp.setExtraOptions(udpExtraOptions, function(error,data) {
if (error) {
expect().assertFail();
console.log(`${caseName} error, case failed,error: ` + JSON.stringify(error));
......@@ -901,10 +901,11 @@ export default function socketJsunit() {
it('Telephony_Socket_UDPSocket_off_error_0100', 0, function (done) {
console.log("************* Telephony_Socket_UDPSocket_off_error_0100 Test start*************");
let caseName = "Telephony_Socket_UDPSocket_off_error_0100"
udp.off("error", error => {
console.log(`${caseName} fail, error:${toString(error)}`);
expect().assertFail();
});
let callback = err =>{
console.log(caseName +" on error, err:" + JSON.stringify(err));
}
udp.on('error', callback);
udp.off('error', callback);
expect(true).assertTrue();
console.log("************* Telephony_Socket_UDPSocket_off_error_0100 Test end*************");
done();
......@@ -1611,10 +1612,11 @@ export default function socketJsunit() {
it('Telephony_Socket_TCPSocket_off_error_0100', 0, function (done) {
console.log("************* Telephony_Socket_TCPSocket_off_error_0100 Test start*************");
let caseName = "Telephony_Socket_TCPSocket_off_error_0100"
tcp.off("error", error => {
console.log(`${caseName} fail, error:${toString(error)}`);
expect().assertFail();
});
let callback = err =>{
console.log(caseName +" on error, err:" + JSON.stringify(err));
}
tcp.on('error', callback);
tcp.off('error', callback);
expect(true).assertTrue();
console.log("************* Telephony_Socket_TCPSocket_off_error_0100 Test end*************");
done();
......
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
......@@ -14,7 +13,7 @@
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'hypium/index';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index';
import webSocket from '@ohos.net.webSocket'
import utils from './Utils.ets'
......
/*
* 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('TestApplication 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('TestApplication 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';
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from 'hypium/index'
import testsuite from '../../test/List.test'
@Entry
@Component
struct Index {
aboutToAppear() {
console.info('TestAbility index aboutToAppear')
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
}
@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
......@@ -7,14 +7,6 @@
{
"name": "description_mainability",
"value": "ETS_Empty Ability"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
......@@ -13,23 +13,19 @@
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsRadiostatisticEtsTest") {
ohos_js_hap_suite("ActsRadioStatisticEtsTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":ace_demo_ets_assets",
":ace_demo_ets_resources",
":ace_demo_ets_test_assets",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsRadiostatisticEtsTest"
hap_name = "ActsRadioStatisticEtsTest"
}
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": "OHJSUnitTest",
"test-timeout": "2000000",
"bundle-name": "com.ohos.radiostatistic",
"package-name": "com.ohos.radiostatistic",
"shell-timeout": "2000000"
"type": "JSUnitTest",
"test-timeout": "1500000",
"package": "com.ohos.radiostatistic",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsRadiostatisticEtsTest.hap"
"ActsRadioStatisticEtsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
......
......@@ -17,7 +17,7 @@
"package": "com.ohos.radiostatistic",
"name": ".MyApplication",
"mainAbility": ".MainAbility",
"srcPath": "",
"srcPath": "MainAbility",
"deviceType": [
"phone"
],
......@@ -50,19 +50,6 @@
"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": [
......@@ -146,20 +133,6 @@
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
......
......@@ -13,11 +13,39 @@
* 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() {
......
// @ts-nocheck
/**
* Copyright (C) 2021 Huawei Device Co., Ltd.
* 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
......@@ -13,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import call from '@ohos.telephony.call';
import utils from './Utils.ets'
......
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
......@@ -14,10 +13,10 @@
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'hypium/index'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import convertxml from '@ohos.convertxml'
export default function convertOptionsJsunit() {
describe('XmlTest_telephony1',function () {
describe('XmlTest',function () {
console.log("************* settings Test start*************");
it('Telephony_convertxml_ConvertXML_0100', 0, async function (done) {
var xml =
......
/**
* Copyright (C) 2021 Huawei Device Co., Ltd.
* 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
......@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'hypium/index'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import data from '@ohos.telephony.data';
......
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
......
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
......@@ -13,7 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets";
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index";
import radio from '@ohos.telephony.radio';
import utils from './Utils.ets'
......@@ -65,10 +64,8 @@ export default function radioSecondJsunit() {
const CELL_INFO_MIN = 0;
const TIME_RADIO_TURNON = 10000;
console.log("************* radio Test start*************");
/**
/**
* @tc.number Telephony_NetworkSearch_NetworkState_Async_0100
* @tc.name Test getNrOptionMode() to check the callback result
* @tc.desc Function test
......@@ -195,34 +192,35 @@ export default function radioSecondJsunit() {
})
/**
* @tc.number Telephony_NetworkSearch_getRadioTech_Async_0500
* @tc.name TestGetRadioTech_0500
* @tc.desc Test getRadioTech() api by callback .SlotId parameter input is 0
*/
* @tc.number Telephony_NetworkSearch_getRadioTech_Async_0500
* @tc.name TestGetRadioTech_0500
* @tc.desc Test getRadioTech() api by callback, SlotId parameter input is 0
*/
it("Telephony_NetworkSearch_getRadioTech_Async_0500", 0, async function(done){
radio.getRadioTech(0, (err, data) => {
if (err) {
console.log(`Telephony_NetworkSearch_getRadioTech_Async_0500 fail err: ${err}`);
console.info(`Telephony_NetworkSearch_getRadioTech_Async_0500 fail err: ${err}`);
expect(err.code === '-1').assertTrue();
done();
return;
}
console.log(`Telephony_NetworkSearch_getRadioTech_Async_0500 success ${data}`);
console.info(`Telephony_NetworkSearch_getRadioTech_Async_0500 success ${data}`);
expect(true).assertTrue();
done();
});
});
/**
* @tc.number Telephony_NetworkSearch_getRadioTech_Promise_0500
* @tc.name TestGetRadioTech_0500
* @tc.desc SlotId parameter input is 0 ,Test getRadioTech() api by promise
*/
* @tc.number Telephony_NetworkSearch_getRadioTech_Promise_0500
* @tc.name testGetRadioTech_0500
* @tc.desc SlotId parameter input is 0, test getRadioTech() api by promise.
*/
it("Telephony_NetworkSearch_getRadioTech_Promise_0500", 0, async function(done){
try {
let data = await radio.getRadioTech(0);
console.log(`Telephony_NetworkSearch_getRadioTech_Promise_0500 success`);
expect(true).assertTrue();
done();
} catch (err) {
console.log(`Telephony_NetworkSearch_getRadioTech_Promise_0500 fail err: ${err}`);
expect(err.code === '-1').assertTrue();
......@@ -359,6 +357,10 @@ export default function radioSecondJsunit() {
done();
});
console.log("************* radio Test end*************");
function assertCellInformation(data) {
expect(data !== '' && data != undefined && data != null).assertTrue();
......
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
......@@ -13,11 +12,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets";
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index";
import mms from '@ohos.telephony.sms';
import utils from './Utils.ets'
export default function smsUiJsunit() {
describe('appInfoTest_telephony1', function () {
describe('appInfoTest', function () {
const SMS_SEND_DST_NUMBER = '';
const TRUE_SLOT_ID = 0;
......
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* 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
......@@ -13,11 +12,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'hypium/index';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index';
import statistics from '@ohos.net.statistics';
import utils from './Utils.ets'
export default function statisticsUiJsunit() {
describe('appInfoTest_telephony2', function () {
describe('appInfoTest', function () {
const DATA_0 = 0;
/**
......
/*
* 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
......@@ -7,14 +7,6 @@
{
"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.
先完成此消息的编辑!
想要评论请 注册