提交 3c667879 编写于 作者: J jiyong_sd

modified FA-JS

Signed-off-by: Njiyong_sd <jiyong@huawei.com>
Change-Id: I0dbe1e549fdf907c2cf4cdd19cc0c1bcddddaf23
上级 2b52be99
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# 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("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsJSHTTPTest") { ohos_js_hap_suite("ActsJSHTTPTest") {
hap_profile = "./entry/src/main/config.json" hap_profile = "./src/main/config.json"
deps = [ deps = [
":hjs_demo_js_assets", ":hjs_demo_js_assets",
":hjs_demo_resources", ":hjs_demo_resources",
...@@ -23,9 +23,11 @@ ohos_js_hap_suite("ActsJSHTTPTest") { ...@@ -23,9 +23,11 @@ ohos_js_hap_suite("ActsJSHTTPTest") {
hap_name = "ActsJSHTTPTest" hap_name = "ActsJSHTTPTest"
} }
ohos_js_assets("hjs_demo_js_assets") { ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default" js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
} }
ohos_resources("hjs_demo_resources") { ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ] sources = [ "./src/main/resources" ]
hap_profile = "./entry/src/main/config.json" hap_profile = "./src/main/config.json"
} }
{ {
"description": "Function test of sim manager interface", "description": "Function test of sim manager interface",
"driver": { "driver": {
"type": "JSUnitTest", "type": "OHJSUnitTest",
"test-timeout": "900000", "test-timeout": "900000",
"package": "com.ohos.jshttp", "bundle-name": "com.ohos.jshttp",
"shell-timeout": "60000" "package-name": "com.ohos.jshttp",
}, "shell-timeout": "900000"
"kits": [ },
{ "kits": [
"test-file-name": [ {
"$module.hap" "test-file-name": [
], "$module.hap"
"type": "AppInstallKit", ],
"cleanup-apps": true "type": "AppInstallKit",
} "cleanup-apps": true
] }
} ]
}
{ {
"app": { "app": {
"bundleName": "com.ohos.jshttp", "bundleName": "com.ohos.jshttp",
"vendor": "ohos", "vendor": "ohos",
"version": { "version": {
"code": 1000000, "code": 1000000,
"name": "1.0.0" "name": "1.0.0"
}, },
"apiVersion": { "apiVersion": {
"compatible": 4, "compatible": 4,
"target": 5, "target": 5,
"releaseType": "Release" "releaseType": "Release"
} }
}, },
"deviceConfig": {}, "deviceConfig": {},
"module": { "module": {
"package": "com.ohos.jshttp", "package": "com.ohos.jshttp",
"name": ".MyApplication", "name": ".entry",
"deviceType": [ "mainAbility": ".MainAbility",
"phone" "srcPath":"",
], "deviceType": [
"distro": { "phone"
"deliveryWithInstall": true, ],
"moduleName": "entry", "distro": {
"moduleType": "entry" "deliveryWithInstall": true,
}, "moduleName": "entry",
"abilities": [ "moduleType": "entry"
{ },
"visible": true, "abilities": [
"skills": [ {
{ "skills": [
"entities": [ {
"entity.system.home" "entities": [
], "entity.system.home"
"actions": [ ],
"action.system.home" "actions": [
] "action.system.home"
} ]
], }
"name": "com.ohos.jshttp.MainAbility", ],
"icon": "$media:icon", "orientation": "unspecified",
"description": "$string:mainability_description", "formsEnabled": false,
"label": "$string:app_name", "name": ".MainAbility",
"type": "page", "srcLanguage": "js",
"launchType": "standard" "srcPath": "MainAbility",
} "icon": "$media:icon",
], "description": "$string:MainAbility_desc",
"reqPermissions": [ "label": "$string:MainAbility_label",
{ "type": "page",
"name": "ohos.permission.LOCATION", "visible": true,
"reason": "need use ohos.permission.LOCATION" "launchType": "standard"
}, },
{ {
"name":"ohos.permission.SET_TELEPHONY_STATE", "orientation": "unspecified",
"reason":"need use ohos.permission.SET_TELEPHONY_STATE" "formsEnabled": false,
}, "name": ".TestAbility",
{ "srcLanguage": "js",
"name":"ohos.permission.GET_TELEPHONY_STATE", "srcPath": "TestAbility",
"reason":"need use ohos.permission.GET_TELEPHONY_STATE" "icon": "$media:icon",
}, "description": "$string:TestAbility_desc",
{ "label": "$string:TestAbility_label",
"name":"ohos.permission.PLACE_CALL", "type": "page",
"reason":"need use ohos.permission.PLACE_CALL" "visible": true,
}, "launchType": "standard"
{ }
"name":"ohos.permission.READ_CONTACTS", ],
"reason":"need use ohos.permission.READ_CONTACTS" "reqPermissions": [
}, {
{ "name": "ohos.permission.LOCATION",
"name":"ohos.permission.WRITE_CONTACTS", "reason": "need use ohos.permission.LOCATION"
"reason":"need use ohos.permission.WRITE_CONTACTS" },
}, {
{ "name":"ohos.permission.SET_TELEPHONY_STATE",
"name":"ohos.permission.SEND_MESSAGES", "reason":"need use ohos.permission.SET_TELEPHONY_STATE"
"reason":"need use ohos.permission.SEND_MESSAGES" },
}, {
{ "name":"ohos.permission.GET_TELEPHONY_STATE",
"name":"ohos.permission.RECEIVE_SMS", "reason":"need use ohos.permission.GET_TELEPHONY_STATE"
"reason":"need use ohos.permission.RECEIVE_SMS" },
}, {
{ "name":"ohos.permission.PLACE_CALL",
"name":"ohos.permission.READ_CALL_LOG", "reason":"need use ohos.permission.PLACE_CALL"
"reason":"need use ohos.permission.READ_CALL_LOG" },
}, {
{ "name":"ohos.permission.READ_CONTACTS",
"name":"ohos.permission.GET_NETWORK_INFO", "reason":"need use ohos.permission.READ_CONTACTS"
"reason":"need use ohos.permission.GET_NETWORK_INFO" },
}, {
{ "name":"ohos.permission.WRITE_CONTACTS",
"name":"ohos.permission.INTERNET", "reason":"need use ohos.permission.WRITE_CONTACTS"
"reason":"need use ohos.permission.INTERNET" },
} {
], "name":"ohos.permission.SEND_MESSAGES",
"js": [ "reason":"need use ohos.permission.SEND_MESSAGES"
{ },
"pages": [ {
"pages/index/index" "name":"ohos.permission.RECEIVE_SMS",
], "reason":"need use ohos.permission.RECEIVE_SMS"
"name": "default", },
"window": { {
"designWidth": 720, "name":"ohos.permission.READ_CALL_LOG",
"autoDesignWidth": false "reason":"need use ohos.permission.READ_CALL_LOG"
} },
} {
] "name":"ohos.permission.GET_NETWORK_INFO",
} "reason":"need use ohos.permission.GET_NETWORK_INFO"
},
{
"name":"ohos.permission.INTERNET",
"reason":"need use ohos.permission.INTERNET"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
}
}
} }
\ No newline at end of file
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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.
*/ */
export default {
export default { onCreate () {
onCreate () { console.info('TestApplication onCreate');
console.info('TestApplication onCreate'); },
}, onDestroy () {
onDestroy () { console.info('TestApplication onDestroy');
console.info('TestApplication onDestroy'); }
} };
};
{ {
"strings": { "strings": {
"hello": "Hello", "hello": "Hello",
"world": "World" "world": "World"
}, },
"Files": { "Files": {
} }
} }
\ No newline at end of file
{ {
"strings": { "strings": {
"hello": "您好", "hello": "您好",
"world": "世界" "world": "世界"
}, },
"Files": { "Files": {
} }
} }
\ No newline at end of file
.container { .container {
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.title { .title {
font-size: 100px; font-size: 100px;
} }
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 file from '@system.file';
import app from '@system.app'; import app from '@system.app';
import device from '@system.device'; import device from '@system.device';
import router from '@system.router'; import router from '@system.router';
import {Core, ExpectExtend} from 'deccjsunit/index'; import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
const injectRef = Object.getPrototypeOf(global) || global import testsuite from '../../../test/List.test'
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
const injectRef = Object.getPrototypeOf(global) || global
export default { injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
data: {
title: '' export default {
}, data: {
onInit () { title: ''
this.title = this.$t('strings.world'); },
}, onInit () {
onShow () { this.title = this.$t('strings.world');
console.info('onShow finish!'); },
const core = Core.getInstance(); onShow () {
const expectExtend = new ExpectExtend({ console.info('onShow finish!');
'id': 'extend' var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
}); var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
core.addService('expect', expectExtend); console.info('start run testcase!!!')
core.init(); Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
const configService = core.getDefaultService('config'); onReady () {
this.timeout = 30000 },
configService.setConfig(this);
require('../../../test/List.test');
core.execute();
},
onReady () {
},
}; };
\ 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.
*/
export default {
onCreate() {
console.info('TestApplication onCreate');
},
onDestroy() {
console.info('TestApplication onDestroy');
}
};
{ {
"strings": { "strings": {
"hello": "Hello", "hello": "Hello",
"world": "World" "world": "World"
}, },
"Files": { "Files": {
} }
} }
\ No newline at end of file
{ {
"strings": { "strings": {
"hello": "您好", "hello": "您好",
"world": "世界" "world": "世界"
}, },
"Files": { "Files": {
} }
} }
\ No newline at end of file
.container { .container {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
left: 0px; left: 0px;
top: 0px; top: 0px;
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.title { .title {
font-size: 60px; font-size: 60px;
text-align: center; text-align: center;
width: 100%; width: 100%;
height: 40%; height: 40%;
margin: 10px; margin: 10px;
} }
@media screen and (device-type: phone) and (orientation: landscape) { @media screen and (device-type: phone) and (orientation: landscape) {
.title { .title {
font-size: 60px; font-size: 60px;
} }
} }
@media screen and (device-type: tablet) and (orientation: landscape) { @media screen and (device-type: tablet) and (orientation: landscape) {
.title { .title {
font-size: 100px; font-size: 100px;
} }
} }
\ No newline at end of file
<div class="container"> <div class="container">
<text class="title"> <text class="title">
{{ $t('strings.hello') }} {{ title }} {{ $t('strings.hello') }} {{ title }}
</text> </text>
</div> </div>
/*
* 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.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* 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'
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', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
/** /**
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 Telephony_NETSTACK_HTTPTest from './NetworkManagerHttp.test.js'
require('./Http.wifi.test');
export default function testsuite() {
Telephony_NETSTACK_HTTPTest()
}
/** /**
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License") * Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 netHttp from '@ohos.net.http'; import netHttp from '@ohos.net.http';
import {describe, afterAll, it, expect, beforeAll, afterEach} from 'deccjsunit/index'; import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
export default function Telephony_NETSTACK_HTTPTest() {
describe('Telephony_NETSTACK_HTTPTest',function(){
describe('Telephony_NETSTACK_HTTPTest',function(){
/**
* @tc.number Telephony_NETSTACK_HttpTestBasicGet_0100 /**
* @tc.name 基本场景,测试能否GET一个网址 * @tc.number Telephony_NETSTACK_HttpTestBasicGet_0100
* @tc.desc Function test` * @tc.name 基本场景,测试能否GET一个网址
*/ * @tc.desc Function test`
*/
it('Telephony_NETSTACK_HttpTestBasicGet_0100', 0, function(done){
let http = netHttp.createHttp() it('Telephony_NETSTACK_HttpTestBasicGet_0100', 0, function(done){
http.request("https://httpbin.org/anything").then(function(data){ let http = netHttp.createHttp()
expect(data.responseCode === netHttp.ResponseCode.OK).assertTrue(); http.request("https://httpbin.org/anything").then(function(data){
done(); expect(data.responseCode === netHttp.ResponseCode.OK).assertTrue();
}) done();
}); })
});
/**
* @tc.number Telephony_NETSTACK_HttpTestUserAgent_0100 /**
* @tc.name 返回用户代理 * @tc.number Telephony_NETSTACK_HttpTestUserAgent_0100
* @tc.desc Function test` * @tc.name 返回用户代理
*/ * @tc.desc Function test`
*/
it('Telephony_NETSTACK_HttpTestUserAgent_0100', 0, function(done){
let http = netHttp.createHttp() it('Telephony_NETSTACK_HttpTestUserAgent_0100', 0, function(done){
http.request("https://httpbin.org/user-agent").then(function(data){ let http = netHttp.createHttp()
expect(data.responseCode === netHttp.ResponseCode.OK).assertTrue(); http.request("https://httpbin.org/user-agent").then(function(data){
console.info(JSON.stringify(data)); expect(data.responseCode === netHttp.ResponseCode.OK).assertTrue();
expect(JSON.parse(data.result)["user-agent"] === "libcurl-agent/1.0").assertTrue(); console.info(JSON.stringify(data));
done(); expect(JSON.parse(data.result)["user-agent"] === "libcurl-agent/1.0").assertTrue();
}) done();
}); })
});
/**
* @tc.number Telephony_NETSTACK_HttpTestHeader_0100 /**
* @tc.name 返回Header * @tc.number Telephony_NETSTACK_HttpTestHeader_0100
* @tc.desc Function test` * @tc.name 返回Header
*/ * @tc.desc Function test`
*/
it('Telephony_NETSTACK_HttpTestHeader_0100', 0, function(done){
let http = netHttp.createHttp(); it('Telephony_NETSTACK_HttpTestHeader_0100', 0, function(done){
http.request("https://httpbin.org/headers").then(function(data){ let http = netHttp.createHttp();
expect(data.responseCode === netHttp.ResponseCode.OK).assertTrue() http.request("https://httpbin.org/headers").then(function(data){
console.info("NETSTACK ####" + JSON.stringify(JSON.parse(data.result))) expect(data.responseCode === netHttp.ResponseCode.OK).assertTrue()
expect(JSON.parse(data.result)["headers"]["Content-Type"] === "application/json").assertTrue() console.info("NETSTACK ####" + JSON.stringify(JSON.parse(data.result)))
done() expect(JSON.parse(data.result)["headers"]["Content-Type"] === "application/json").assertTrue()
}) done()
}); })
});
/**
* @tc.number Telephony_NETSTACK_HttpTestPost /**
* @tc.name 返回post内容 * @tc.number Telephony_NETSTACK_HttpTestPost
* @tc.desc Function test` * @tc.name 返回post内容
*/ * @tc.desc Function test`
*/
it('Telephony_NETSTACK_HttpTestPost_0100', 0, function(done){
let http = netHttp.createHttp() it('Telephony_NETSTACK_HttpTestPost_0100', 0, function(done){
http.request("https://httpbin.org/post" ,{ let http = netHttp.createHttp()
method : netHttp.RequestMethod.POST, http.request("https://httpbin.org/post" ,{
extraData : "MineMine" method : netHttp.RequestMethod.POST,
}).then(function(data){ extraData : "MineMine"
expect(data.responseCode === netHttp.ResponseCode.OK).assertTrue() }).then(function(data){
expect(JSON.parse(data.result)["data"] === "MineMine").assertTrue() expect(data.responseCode === netHttp.ResponseCode.OK).assertTrue()
done(); expect(JSON.parse(data.result)["data"] === "MineMine").assertTrue()
}) done();
}); })
});
/**
* @tc.number Telephony_NETSTACK_HttpTestPUT /**
* @tc.name 返回put内容 * @tc.number Telephony_NETSTACK_HttpTestPUT
* @tc.desc Function test` * @tc.name 返回put内容
*/ * @tc.desc Function test`
*/
it('Telephony_NETSTACK_HttpTestPut_0100', 0, function(done){
let http = netHttp.createHttp() it('Telephony_NETSTACK_HttpTestPut_0100', 0, function(done){
http.request("https://httpbin.org/put" ,{ let http = netHttp.createHttp()
method : netHttp.RequestMethod.PUT, http.request("https://httpbin.org/put" ,{
extraData : "MineMine" method : netHttp.RequestMethod.PUT,
}).then(function(data){ extraData : "MineMine"
expect(data.responseCode === netHttp.ResponseCode.OK).assertTrue() }).then(function(data){
expect(JSON.parse(data.result)["data"] === "MineMine").assertTrue() expect(data.responseCode === netHttp.ResponseCode.OK).assertTrue()
done(); expect(JSON.parse(data.result)["data"] === "MineMine").assertTrue()
}) done();
}); })
});
/**
* @tc.number Telephony_NETSTACK_HttpTestCookies /**
* @tc.name 返回Cookies内容 * @tc.number Telephony_NETSTACK_HttpTestCookies
* @tc.desc Function test` * @tc.name 返回Cookies内容
*/ * @tc.desc Function test`
*/
it('Telephony_NETSTACK_HttpTestCookies_0100', 0, function(done){
let http = netHttp.createHttp() it('Telephony_NETSTACK_HttpTestCookies_0100', 0, function(done){
http.request("https://httpbin.org/cookies/set/name/value").then(function(data){ let http = netHttp.createHttp()
expect(data.responseCode === netHttp.ResponseCode.OK).assertTrue() http.request("https://httpbin.org/cookies/set/name/value").then(function(data){
expect(data.cookies !== "").assertTrue() expect(data.responseCode === netHttp.ResponseCode.OK).assertTrue()
done(); expect(data.cookies !== "").assertTrue()
}) done();
}); })
});
/**
* @tc.number Telephony_NETSTACK_HttpTestEncode /**
* @tc.name 返回Cookies内容 * @tc.number Telephony_NETSTACK_HttpTestEncode
* @tc.desc Function test` * @tc.name 返回Cookies内容
*/ * @tc.desc Function test`
*/
it('Telephony_NETSTACK_HttpTestEncode_0100', 0, function(done){
let http = netHttp.createHttp() it('Telephony_NETSTACK_HttpTestEncode_0100', 0, function(done){
http.request("https://httpbin.org/response-headers?key1=val1&key2=val2",{ let http = netHttp.createHttp()
extraData : { http.request("https://httpbin.org/response-headers?key1=val1&key2=val2",{
"name1" : "mine1", extraData : {
"name2" : "mine2", "name1" : "mine1",
} "name2" : "mine2",
}).then(function(data){ }
expect(data.responseCode === netHttp.ResponseCode.OK).assertTrue() }).then(function(data){
expect(JSON.parse(data.result)["key1"] === "val1").assertTrue() expect(data.responseCode === netHttp.ResponseCode.OK).assertTrue()
expect(JSON.parse(data.result)["key2"] === "val2").assertTrue() expect(JSON.parse(data.result)["key1"] === "val1").assertTrue()
expect(JSON.parse(data.result)["name1"] === "mine1").assertTrue() expect(JSON.parse(data.result)["key2"] === "val2").assertTrue()
expect(JSON.parse(data.result)["name2"] === "mine2").assertTrue() expect(JSON.parse(data.result)["name1"] === "mine1").assertTrue()
done(); expect(JSON.parse(data.result)["name2"] === "mine2").assertTrue()
}) done();
}); })
}); });
});
}
{ {
"string": [ "string": [
{ {
"name": "app_name", "name": "app_name",
"value": "Sim Test" "value": "Sim Test"
}, },
{ {
"name": "mainability_description", "name": "mainability_description",
"value": "Sim Test - sim manager interface test" "value": "Sim Test - sim manager interface test"
} },
] {
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
} }
\ No newline at end of file
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# 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("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsNetworkNowifiTest") { ohos_js_hap_suite("ActsNetworkNowifiTest") {
hap_profile = "./entry/src/main/config.json" hap_profile = "./src/main/config.json"
deps = [ deps = [
":hjs_demo_js_assets", ":hjs_demo_js_assets",
":hjs_demo_resources", ":hjs_demo_resources",
...@@ -23,9 +23,11 @@ ohos_js_hap_suite("ActsNetworkNowifiTest") { ...@@ -23,9 +23,11 @@ ohos_js_hap_suite("ActsNetworkNowifiTest") {
hap_name = "ActsNetworkNowifiTest" hap_name = "ActsNetworkNowifiTest"
} }
ohos_js_assets("hjs_demo_js_assets") { ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default" js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
} }
ohos_resources("hjs_demo_resources") { ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ] sources = [ "./src/main/resources" ]
hap_profile = "./entry/src/main/config.json" hap_profile = "./src/main/config.json"
} }
{ {
"description": "Function test of sim manager interface", "description": "Function test of sim manager interface",
"driver": { "driver": {
"type": "JSUnitTest", "type": "OHJSUnitTest",
"test-timeout": "1800000", "test-timeout": "1800000",
"package": "com.ohos.network_nowifi", "bundle-name": "com.ohos.network_nowifi",
"shell-timeout": "60000" "package-name": "com.ohos.network_nowifi",
}, "shell-timeout": "1800000"
"kits": [ },
{ "kits": [
"test-file-name": [ {
"$module.hap" "test-file-name": [
], "$module.hap"
"type": "AppInstallKit", ],
"cleanup-apps": true "type": "AppInstallKit",
} "cleanup-apps": true
] }
} ]
}
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
{ {
"app": { "app": {
"vendor": "ohos", "vendor": "ohos",
"bundleName": "com.ohos.network_nowifi", "bundleName": "com.ohos.network_nowifi",
"version": { "version": {
"code": 1000000, "code": 1000000,
"name": "1.0.0" "name": "1.0.0"
}, },
"apiVersion": { "apiVersion": {
"compatible": 4, "compatible": 4,
"target": 5, "target": 5,
"releaseType": "Release" "releaseType": "Release"
} }
}, },
"deviceConfig": {}, "deviceConfig": {},
"module": { "module": {
"mainAbility": ".MainAbility", "mainAbility": ".MainAbility",
"deviceType": [ "deviceType": [
"phone" "phone"
], ],
"abilities": [ "abilities": [
{ {
"skills": [ "skills": [
{ {
"entities": [ "entities": [
"entity.system.home" "entity.system.home"
], ],
"actions": [ "actions": [
"action.system.home" "action.system.home"
] ]
} }
], ],
"visible": true, "orientation": "unspecified",
"name": ".MainAbility", "formsEnabled": false,
"icon": "$media:icon", "name": ".MainAbility",
"description": "$string:MainAbility_desc", "srcLanguage": "js",
"label": "$string:MainAbility_label", "srcPath": "MainAbility",
"type": "page", "icon": "$media:icon",
"launchType": "standard" "description": "$string:MainAbility_desc",
} "label": "$string:MainAbility_label",
], "type": "page",
"reqPermissions": [ "visible": true,
{ "launchType": "standard"
"name":"ohos.permission.GET_NETWORK_INFO", },
"reason":"need use ohos.permission.GET_NETWORK_INFO" {
} "orientation": "unspecified",
], "formsEnabled": false,
"distro": { "name": ".TestAbility",
"moduleType": "entry", "srcLanguage": "js",
"installationFree": false, "srcPath": "TestAbility",
"deliveryWithInstall": true, "icon": "$media:icon",
"moduleName": "entry" "description": "$string:TestAbility_desc",
}, "label": "$string:TestAbility_label",
"package": "com.ohos.network_nowifi", "type": "page",
"srcPath": "", "visible": true,
"name": ".entry", "launchType": "standard"
"js": [ }
{ ],
"pages": [ "reqPermissions": [
"pages/index/index" {
], "name":"ohos.permission.GET_NETWORK_INFO",
"name": "default", "reason":"need use ohos.permission.GET_NETWORK_INFO"
"window": { }
"designWidth": 720, ],
"autoDesignWidth": false "distro": {
} "moduleType": "entry",
} "installationFree": false,
] "deliveryWithInstall": true,
} "moduleName": "entry"
},
"package": "com.ohos.network_nowifi",
"srcPath": "",
"name": ".entry",
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
}
}
} }
\ No newline at end of file
/* /*
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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.
*/ */
export default { export default {
onCreate() { onCreate() {
console.info("Application onCreate"); console.info("Application onCreate");
}, },
onDestroy() { onDestroy() {
console.info("Application onDestroy"); console.info("Application onDestroy");
} }
}; };
{ {
"strings": { "strings": {
"hello": "Hello", "hello": "Hello",
"world": "World" "world": "World"
}, },
"Files": { "Files": {
} }
} }
\ No newline at end of file
{ {
"strings": { "strings": {
"hello": "您好", "hello": "您好",
"world": "世界" "world": "世界"
}, },
"Files": { "Files": {
} }
} }
\ No newline at end of file
.container { .container {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
left: 0px; left: 0px;
top: 0px; top: 0px;
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.title { .title {
font-size: 60px; font-size: 60px;
text-align: center; text-align: center;
width: 100%; width: 100%;
height: 40%; height: 40%;
margin: 10px; margin: 10px;
} }
@media screen and (device-type: phone) and (orientation: landscape) { @media screen and (device-type: phone) and (orientation: landscape) {
.title { .title {
font-size: 60px; font-size: 60px;
} }
} }
@media screen and (device-type: tablet) and (orientation: landscape) { @media screen and (device-type: tablet) and (orientation: landscape) {
.title { .title {
font-size: 100px; font-size: 100px;
} }
} }
\ No newline at end of file
<div class="container"> <div class="container">
<text class="title"> <text class="title">
{{ $t('strings.hello') }} {{ title }} {{ $t('strings.hello') }} {{ title }}
</text> </text>
</div> </div>
/* /*
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 file from '@system.file';
import app from '@system.app'; import app from '@system.app';
import device from '@system.device'; import device from '@system.device';
import router from '@system.router'; import router from '@system.router';
import {Core, ExpectExtend} from 'deccjsunit/index'; import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
const injectRef = Object.getPrototypeOf(global) || global import testsuite from '../../../test/List.test'
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
const injectRef = Object.getPrototypeOf(global) || global
export default { injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
data: {
title: '' export default {
}, data: {
onInit () { title: ''
this.title = this.$t('strings.world'); },
}, onInit () {
onShow () { this.title = this.$t('strings.world');
console.info('onShow finish!'); },
const core = Core.getInstance(); onShow () {
const expectExtend = new ExpectExtend({ console.info('onShow finish!');
'id': 'extend' var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
}); var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
core.addService('expect', expectExtend); console.info('start run testcase!!!')
core.init(); Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
const configService = core.getDefaultService('config'); onReady () {
this.timeout = 30000 },
configService.setConfig(this);
require('../../../test/List.test');
core.execute();
},
onReady () {
},
}; };
\ 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.
*/
export default {
onCreate() {
console.info('TestApplication onCreate');
},
onDestroy() {
console.info('TestApplication onDestroy');
}
};
{ {
"strings": { "strings": {
"hello": "Hello", "hello": "Hello",
"world": "World" "world": "World"
}, },
"Files": { "Files": {
} }
} }
\ No newline at end of file
{ {
"strings": { "strings": {
"hello": "您好", "hello": "您好",
"world": "世界" "world": "世界"
}, },
"Files": { "Files": {
} }
} }
\ No newline at end of file
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ No newline at end of file
<div class="container"> <div class="container">
<text class="title"> <text class="title">
{{ $t('strings.hello') }} {{ title }} {{ $t('strings.hello') }} {{ title }}
</text> </text>
</div> </div>
/*
* 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.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* 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'
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', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
/** /**
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License") * Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 network from '@system.network'; import network from '@system.network';
import { describe, afterAll, it, expect, beforeAll, afterEach } from 'deccjsunit/index'; import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
export default function Telephony_NetManager_NetWorkTest() {
describe("Telephony_NetManager_NetWorkTest", function () {
describe("Telephony_NetManager_NetWorkTest", function () {
/**
* @tc.number Telephony_NetManager_NetWorkTest_GetType_None_0100 /**
* @tc.name Whether the GetType method is called successfully without WiFi * @tc.number Telephony_NetManager_NetWorkTest_GetType_None_0100
* @tc.desc Function test * @tc.name Whether the GetType method is called successfully without WiFi
*/ * @tc.desc Function test
it("Telephony_NetManager_NetWorkTest_GetType_None_0100", 0, function (done) { */
network.getType({ it("Telephony_NetManager_NetWorkTest_GetType_None_0100", 0, function (done) {
success: function (data) { network.getType({
console.info("NetManager getType " + JSON.stringify(data)) success: function (data) {
expect(data.type === "none").assertTrue() console.info("NetManager getType " + JSON.stringify(data))
expect(data.metered === false).assertTrue() expect(data.type === "none").assertTrue()
network.unsubscribe() expect(data.metered === false).assertTrue()
done(); network.unsubscribe()
}, done();
fail: function (data, code) { },
expect().assertFail(); fail: function (data, code) {
done(); expect().assertFail();
}, done();
complete: function () { },
expect().assertTrue() complete: function () {
done(); expect().assertTrue()
} done();
}) }
done(); })
}); done();
});
/**
* @tc.number Telephony_NetManager_NetWorkTest_GetType_None_0200 /**
* @tc.name Whether to call GetType method again without WiFi * @tc.number Telephony_NetManager_NetWorkTest_GetType_None_0200
* @tc.desc Function test * @tc.name Whether to call GetType method again without WiFi
*/ * @tc.desc Function test
it("Telephony_NetManager_NetWorkTest_GetType_None_0200", 0, function (done) { */
network.getType({ it("Telephony_NetManager_NetWorkTest_GetType_None_0200", 0, function (done) {
success: function (data) { network.getType({
console.info("NetManager getType 1 " + JSON.stringify(data)) success: function (data) {
expect(data.type === "none").assertTrue() console.info("NetManager getType 1 " + JSON.stringify(data))
expect(data.metered === false).assertTrue() expect(data.type === "none").assertTrue()
network.unsubscribe() expect(data.metered === false).assertTrue()
done(); network.unsubscribe()
console.info("NetManager Telephony_NetManager_NetWorkTest_GetType_none_1 end") done();
}, console.info("NetManager Telephony_NetManager_NetWorkTest_GetType_none_1 end")
fail: function (data, code) { },
expect().assertFail(); fail: function (data, code) {
done(); expect().assertFail();
}, done();
complete: function () { },
expect().assertTrue() complete: function () {
done(); expect().assertTrue()
} done();
}) }
done(); })
}); done();
});
/**
* @tc.number Telephony_NetManager_NetWorkTest_Subscribe_None_0100 /**
* @tc.name Whether the subscribe method is called successfully without WiFi * @tc.number Telephony_NetManager_NetWorkTest_Subscribe_None_0100
* @tc.desc Function test * @tc.name Whether the subscribe method is called successfully without WiFi
*/ * @tc.desc Function test
it("Telephony_NetManager_NetWorkTest_Subscribe_None_0100", 0, function (done) { */
network.subscribe({ it("Telephony_NetManager_NetWorkTest_Subscribe_None_0100", 0, function (done) {
success: function (data) { network.subscribe({
console.info("NetManager subscribe " + JSON.stringify(data)) success: function (data) {
expect(data.type === "none").assertTrue() console.info("NetManager subscribe " + JSON.stringify(data))
expect(data.metered === false).assertTrue() expect(data.type === "none").assertTrue()
network.unsubscribe() expect(data.metered === false).assertTrue()
done(); network.unsubscribe()
}, done();
fail: function (data, code) { },
expect().assertFail() fail: function (data, code) {
done(); expect().assertFail()
} done();
}) }
done(); })
}); done();
});
/**
* @tc.number Telephony_NetManager_NetWorkTest_Subscribe_None_0200 /**
* @tc.name Whether to call the subscribe method again without WiFi * @tc.number Telephony_NetManager_NetWorkTest_Subscribe_None_0200
* @tc.desc Function test * @tc.name Whether to call the subscribe method again without WiFi
*/ * @tc.desc Function test
it("Telephony_NetManager_NetWorkTest_Subscribe_None_0200", 0, function (done) { */
network.subscribe({ it("Telephony_NetManager_NetWorkTest_Subscribe_None_0200", 0, function (done) {
success: function (data) { network.subscribe({
console.info("NetManager subscribe " + JSON.stringify(data)) success: function (data) {
expect(data.type === "none").assertTrue() console.info("NetManager subscribe " + JSON.stringify(data))
expect(data.metered === false).assertTrue() expect(data.type === "none").assertTrue()
network.unsubscribe() expect(data.metered === false).assertTrue()
done(); network.unsubscribe()
}, done();
fail: function (data, code) { },
expect().assertFail() fail: function (data, code) {
done(); expect().assertFail()
} done();
}) }
done(); })
}); done();
});
});
\ No newline at end of file });
}
\ No newline at end of file
/** /**
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 Telephony_NetManager_NetWorkTest from './Http.nowifi.test.js'
require('./NetStackSocket.test'); export default function testsuite() {
\ No newline at end of file Telephony_NetManager_NetWorkTest()
}
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# 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("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsNetworkWifiTest") { ohos_js_hap_suite("ActsNetworkWifiTest") {
hap_profile = "./entry/src/main/config.json" hap_profile = "./src/main/config.json"
deps = [ deps = [
":hjs_demo_js_assets", ":hjs_demo_js_assets",
":hjs_demo_resources", ":hjs_demo_resources",
...@@ -23,9 +23,11 @@ ohos_js_hap_suite("ActsNetworkWifiTest") { ...@@ -23,9 +23,11 @@ ohos_js_hap_suite("ActsNetworkWifiTest") {
hap_name = "ActsNetworkWifiTest" hap_name = "ActsNetworkWifiTest"
} }
ohos_js_assets("hjs_demo_js_assets") { ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default" js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
} }
ohos_resources("hjs_demo_resources") { ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ] sources = [ "./src/main/resources" ]
hap_profile = "./entry/src/main/config.json" hap_profile = "./src/main/config.json"
} }
{ {
"description": "Function test of sim manager interface", "description": "Function test of sim manager interface",
"driver": { "driver": {
"type": "JSUnitTest", "type": "OHJSUnitTest",
"test-timeout": "900000", "test-timeout": "900000",
"package": "com.ohos.network_wifi", "bundle-name": "com.ohos.network_wifi",
"shell-timeout": "60000" "package-name": "com.ohos.network_wifi",
}, "shell-timeout": "900000"
"kits": [ },
{ "kits": [
"test-file-name": [ {
"$module.hap" "test-file-name": [
], "$module.hap"
"type": "AppInstallKit", ],
"cleanup-apps": true "type": "AppInstallKit",
} "cleanup-apps": true
] }
} ]
}
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
{ {
"app": { "app": {
"vendor": "ohos", "vendor": "ohos",
"bundleName": "com.ohos.network_wifi", "bundleName": "com.ohos.network_wifi",
"version": { "version": {
"code": 1000000, "code": 1000000,
"name": "1.0.0" "name": "1.0.0"
}, },
"apiVersion": { "apiVersion": {
"compatible": 4, "compatible": 4,
"target": 5, "target": 5,
"releaseType": "Release" "releaseType": "Release"
} }
}, },
"deviceConfig": {}, "deviceConfig": {},
"module": { "module": {
"mainAbility": ".MainAbility", "mainAbility": ".MainAbility",
"deviceType": [ "deviceType": [
"phone" "phone"
], ],
"abilities": [ "abilities": [
{ {
"skills": [ "skills": [
{ {
"entities": [ "entities": [
"entity.system.home" "entity.system.home"
], ],
"actions": [ "actions": [
"action.system.home" "action.system.home"
] ]
} }
], ],
"visible": true, "orientation": "unspecified",
"name": ".MainAbility", "formsEnabled": false,
"icon": "$media:icon", "name": ".MainAbility",
"description": "$string:MainAbility_desc", "srcLanguage": "js",
"label": "$string:MainAbility_label", "srcPath": "MainAbility",
"type": "page", "icon": "$media:icon",
"launchType": "standard" "description": "$string:MainAbility_desc",
} "label": "$string:MainAbility_label",
], "type": "page",
"reqPermissions": [ "visible": true,
{ "launchType": "standard"
"name":"ohos.permission.GET_NETWORK_INFO", },
"reason":"need use ohos.permission.GET_NETWORK_INFO" {
} "orientation": "unspecified",
], "formsEnabled": false,
"distro": { "name": ".TestAbility",
"moduleType": "entry", "srcLanguage": "js",
"installationFree": false, "srcPath": "TestAbility",
"deliveryWithInstall": true, "icon": "$media:icon",
"moduleName": "entry" "description": "$string:TestAbility_desc",
}, "label": "$string:TestAbility_label",
"package": "com.ohos.network_wifi", "type": "page",
"srcPath": "", "visible": true,
"name": ".entry", "launchType": "standard"
"js": [ }
{ ],
"pages": [ "reqPermissions": [
"pages/index/index" {
], "name":"ohos.permission.GET_NETWORK_INFO",
"name": "default", "reason":"need use ohos.permission.GET_NETWORK_INFO"
"window": { }
"designWidth": 720, ],
"autoDesignWidth": false "distro": {
} "moduleType": "entry",
} "installationFree": false,
] "deliveryWithInstall": true,
} "moduleName": "entry"
},
"package": "com.ohos.network_wifi",
"srcPath": "",
"name": ".entry",
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
}
}
} }
\ No newline at end of file
/* /*
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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.
*/ */
export default { export default {
onCreate() { onCreate() {
console.info("Application onCreate"); console.info("Application onCreate");
}, },
onDestroy() { onDestroy() {
console.info("Application onDestroy"); console.info("Application onDestroy");
} }
}; };
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ No newline at end of file
<div class="container"> <div class="container">
<text class="title"> <text class="title">
{{ $t('strings.hello') }} {{ title }} {{ $t('strings.hello') }} {{ title }}
</text> </text>
</div> </div>
/* /*
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 file from '@system.file';
import app from '@system.app'; import app from '@system.app';
import device from '@system.device'; import device from '@system.device';
import router from '@system.router'; import router from '@system.router';
import {Core, ExpectExtend} from 'deccjsunit/index'; import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
const injectRef = Object.getPrototypeOf(global) || global import testsuite from '../../../test/List.test'
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
const injectRef = Object.getPrototypeOf(global) || global
export default { injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
data: {
title: '' export default {
}, data: {
onInit () { title: ''
this.title = this.$t('strings.world'); },
}, onInit () {
onShow () { this.title = this.$t('strings.world');
console.info('onShow finish!'); },
const core = Core.getInstance(); onShow () {
const expectExtend = new ExpectExtend({ console.info('onShow finish!');
'id': 'extend' var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
}); var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
core.addService('expect', expectExtend); console.info('start run testcase!!!')
core.init(); Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
const configService = core.getDefaultService('config'); onReady () {
this.timeout = 30000 },
configService.setConfig(this);
require('../../../test/List.test');
core.execute();
},
onReady () {
},
}; };
\ 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.
*/
export default {
onCreate() {
console.info('TestApplication onCreate');
},
onDestroy() {
console.info('TestApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* 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.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* 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'
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', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
/** /**
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License") * Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 network from '@system.network'; import network from '@system.network';
import {describe, afterAll, it, expect, beforeAll, afterEach} from 'deccjsunit/index'; import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
export default function Telephony_NetManager_NetWorkTest() {
describe("Telephony_NetManager_NetWorkTest", function () {
describe("Telephony_NetManager_NetWorkTest", function () {
/**
* @tc.number Telephony_NetManager_NetWorkTest_GetType_WiFi_0100 /**
* @tc.name Whether the GetType method is called successfully with WiFi * @tc.number Telephony_NetManager_NetWorkTest_GetType_WiFi_0100
* @tc.desc Function test * @tc.name Whether the GetType method is called successfully with WiFi
*/ * @tc.desc Function test
it("Telephony_NetManager_NetWorkTest_GetType_WiFi_0100", 0, function (done) { */
network.getType({ it("Telephony_NetManager_NetWorkTest_GetType_WiFi_0100", 0, function (done) {
success : function(data){ network.getType({
console.info("NetManager getType "+ JSON.stringify(data)) success : function(data){
expect(data.type === "WiFi").assertTrue() console.info("NetManager getType "+ JSON.stringify(data))
expect(data.metered === false).assertTrue() expect(data.type === "WiFi").assertTrue()
network.unsubscribe() expect(data.metered === false).assertTrue()
done(); network.unsubscribe()
}, done();
fail : function(data,code){ },
expect().assertFail() fail : function(data,code){
done(); expect().assertFail()
}, done();
complete : function(){ },
expect().assertTrue() complete : function(){
done(); expect().assertTrue()
} done();
}) }
done(); })
}); done();
});
/**
* @tc.number Telephony_NetManager_NetWorkTest_GetType_WiFi_0200 /**
* @tc.name Whether to call GetType method again with WiFi * @tc.number Telephony_NetManager_NetWorkTest_GetType_WiFi_0200
* @tc.desc Function test * @tc.name Whether to call GetType method again with WiFi
*/ * @tc.desc Function test
it("Telephony_NetManager_NetWorkTest_GetType_WiFi_0200", 0, function (done) { */
network.getType({ it("Telephony_NetManager_NetWorkTest_GetType_WiFi_0200", 0, function (done) {
success : function(data){ network.getType({
console.info("NetManager getType "+ JSON.stringify(data)) success : function(data){
expect(data.type === "WiFi").assertTrue() console.info("NetManager getType "+ JSON.stringify(data))
expect(data.metered === false).assertTrue() expect(data.type === "WiFi").assertTrue()
network.unsubscribe() expect(data.metered === false).assertTrue()
done(); network.unsubscribe()
console.info("Telephony_NetManager_NetWorkTest_GetType_wifi_1 end") done();
}, console.info("Telephony_NetManager_NetWorkTest_GetType_wifi_1 end")
fail : function(data,code){ },
expect().assertFail() fail : function(data,code){
done(); expect().assertFail()
}, done();
complete : function(){ },
expect().assertTrue() complete : function(){
done(); expect().assertTrue()
} done();
}) }
done(); })
}); done();
});
/**
* @tc.number Telephony_NetManager_NetWorkTest_Subscribe_WiFi_0100 /**
* @tc.name Whether the subscribe method is called successfully with WiFi * @tc.number Telephony_NetManager_NetWorkTest_Subscribe_WiFi_0100
* @tc.desc Function test * @tc.name Whether the subscribe method is called successfully with WiFi
*/ * @tc.desc Function test
it("Telephony_NetManager_NetWorkTest_Subscribe_WiFi_0100", 0, function (done) { */
network.subscribe({ it("Telephony_NetManager_NetWorkTest_Subscribe_WiFi_0100", 0, function (done) {
success : function(data){ network.subscribe({
console.info("NetManager subscribe "+JSON.stringify(data)) success : function(data){
expect(data.type === "WiFi").assertTrue() console.info("NetManager subscribe "+JSON.stringify(data))
expect(data.metered === false).assertTrue() expect(data.type === "WiFi").assertTrue()
network.unsubscribe() expect(data.metered === false).assertTrue()
done(); network.unsubscribe()
}, done();
fail : function(data,code){ },
expect().assertFail() fail : function(data,code){
done(); expect().assertFail()
} done();
}) }
done(); })
}); done();
});
/**
* @tc.number Telephony_NetManager_NetWorkTest_Subscribe_WiFi_0200 /**
* @tc.name Whether to call the subscribe method again with WiFi * @tc.number Telephony_NetManager_NetWorkTest_Subscribe_WiFi_0200
* @tc.desc Function test * @tc.name Whether to call the subscribe method again with WiFi
*/ * @tc.desc Function test
it("Telephony_NetManager_NetWorkTest_Subscribe_WiFi_0200", 0, function (done) { */
network.subscribe({ it("Telephony_NetManager_NetWorkTest_Subscribe_WiFi_0200", 0, function (done) {
success : function(data){ network.subscribe({
console.info("NetManager subscribe 1 "+JSON.stringify(data)) success : function(data){
expect(data.type === "WiFi").assertTrue() console.info("NetManager subscribe 1 "+JSON.stringify(data))
expect(data.metered === false).assertTrue() expect(data.type === "WiFi").assertTrue()
network.unsubscribe() expect(data.metered === false).assertTrue()
done(); network.unsubscribe()
}, done();
fail : function(data,code){ },
expect().assertFail() fail : function(data,code){
done(); expect().assertFail()
} done();
}) }
done(); })
}); done();
});
})
\ No newline at end of file })
}
\ No newline at end of file
/** /**
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 Telephony_NetManager_NetWorkTest from './Http.wifi.test.js'
export default function testsuite() {
require('./NetworkManagerHttp.test'); Telephony_NetManager_NetWorkTest()
}
{
"string": [
{
"name": "entry_desc",
"value": "description"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# 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("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsSocketTest") { ohos_js_hap_suite("ActsSocketTest") {
hap_profile = "./entry/src/main/config.json" hap_profile = "./src/main/config.json"
deps = [ deps = [
":hjs_demo_js_assets", ":hjs_demo_js_assets",
":hjs_demo_resources", ":hjs_demo_resources",
...@@ -23,9 +23,11 @@ ohos_js_hap_suite("ActsSocketTest") { ...@@ -23,9 +23,11 @@ ohos_js_hap_suite("ActsSocketTest") {
hap_name = "ActsSocketTest" hap_name = "ActsSocketTest"
} }
ohos_js_assets("hjs_demo_js_assets") { ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default" js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
} }
ohos_resources("hjs_demo_resources") { ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ] sources = [ "./src/main/resources" ]
hap_profile = "./entry/src/main/config.json" hap_profile = "./src/main/config.json"
} }
{ {
"description": "Function test of sim manager interface", "description": "Function test of sim manager interface",
"driver": { "driver": {
"type": "JSUnitTest", "type": "OHJSUnitTest",
"test-timeout": "1800000", "test-timeout": "1800000",
"package": "com.ohos.socket", "bundle-name": "com.ohos.socket",
"shell-timeout": "60000" "package-name": "com.ohos.socket",
}, "shell-timeout": "1800000"
"kits": [ },
{ "kits": [
"test-file-name": [ {
"$module.hap" "test-file-name": [
], "$module.hap"
"type": "AppInstallKit", ],
"cleanup-apps": true "type": "AppInstallKit",
} "cleanup-apps": true
] }
} ]
}
{
"string": [
{
"name": "app_name",
"value": "Sim Test"
},
{
"name": "mainability_description",
"value": "Sim Test - sim manager interface test"
}
]
}
\ No newline at end of file
{ {
"app": { "app": {
"bundleName": "com.ohos.socket", "bundleName": "com.ohos.socket",
"vendor": "ohos", "vendor": "ohos",
"version": { "version": {
"code": 1000000, "code": 1000000,
"name": "1.0.0" "name": "1.0.0"
}, },
"apiVersion": { "apiVersion": {
"compatible": 4, "compatible": 4,
"target": 5, "target": 5,
"releaseType": "Release" "releaseType": "Release"
} }
}, },
"deviceConfig": {}, "deviceConfig": {},
"module": { "module": {
"package": "com.ohos.socket", "package": "com.ohos.socket",
"name": ".MyApplication", "name": ".entry",
"deviceType": [ "mainAbility": ".MainAbility",
"phone" "srcPath":"",
], "deviceType": [
"distro": { "phone"
"deliveryWithInstall": true, ],
"moduleName": "entry", "distro": {
"moduleType": "entry" "deliveryWithInstall": true,
}, "moduleName": "entry",
"abilities": [ "moduleType": "entry"
{ },
"visible": true, "abilities": [
"skills": [ {
{ "skills": [
"entities": [ {
"entity.system.home" "entities": [
], "entity.system.home"
"actions": [ ],
"action.system.home" "actions": [
] "action.system.home"
} ]
], }
"name": "com.ohos.socket.MainAbility", ],
"icon": "$media:icon", "orientation": "unspecified",
"description": "$string:mainability_description", "formsEnabled": false,
"label": "$string:app_name", "name": ".MainAbility",
"type": "page", "srcLanguage": "js",
"launchType": "standard" "srcPath": "MainAbility",
} "icon": "$media:icon",
], "description": "$string:MainAbility_desc",
"reqPermissions": [ "label": "$string:MainAbility_label",
{ "type": "page",
"name": "ohos.permission.LOCATION", "visible": true,
"reason": "need use ohos.permission.LOCATION" "launchType": "standard"
}, },
{ {
"name":"ohos.permission.SET_TELEPHONY_STATE", "orientation": "unspecified",
"reason":"need use ohos.permission.SET_TELEPHONY_STATE" "formsEnabled": false,
}, "name": ".TestAbility",
{ "srcLanguage": "js",
"name":"ohos.permission.GET_TELEPHONY_STATE", "srcPath": "TestAbility",
"reason":"need use ohos.permission.GET_TELEPHONY_STATE" "icon": "$media:icon",
}, "description": "$string:TestAbility_desc",
{ "label": "$string:TestAbility_label",
"name":"ohos.permission.PLACE_CALL", "type": "page",
"reason":"need use ohos.permission.PLACE_CALL" "visible": true,
}, "launchType": "standard"
{ }
"name":"ohos.permission.READ_CONTACTS", ],
"reason":"need use ohos.permission.READ_CONTACTS" "reqPermissions": [
}, {
{ "name": "ohos.permission.LOCATION",
"name":"ohos.permission.WRITE_CONTACTS", "reason": "need use ohos.permission.LOCATION"
"reason":"need use ohos.permission.WRITE_CONTACTS" },
}, {
{ "name":"ohos.permission.SET_TELEPHONY_STATE",
"name":"ohos.permission.SEND_MESSAGES", "reason":"need use ohos.permission.SET_TELEPHONY_STATE"
"reason":"need use ohos.permission.SEND_MESSAGES" },
}, {
{ "name":"ohos.permission.GET_TELEPHONY_STATE",
"name":"ohos.permission.RECEIVE_SMS", "reason":"need use ohos.permission.GET_TELEPHONY_STATE"
"reason":"need use ohos.permission.RECEIVE_SMS" },
}, {
{ "name":"ohos.permission.PLACE_CALL",
"name":"ohos.permission.READ_CALL_LOG", "reason":"need use ohos.permission.PLACE_CALL"
"reason":"need use ohos.permission.READ_CALL_LOG" },
}, {
{ "name":"ohos.permission.READ_CONTACTS",
"name":"ohos.permission.GET_NETWORK_INFO", "reason":"need use ohos.permission.READ_CONTACTS"
"reason":"need use ohos.permission.GET_NETWORK_INFO" },
}, {
{ "name":"ohos.permission.WRITE_CONTACTS",
"name":"ohos.permission.INTERNET", "reason":"need use ohos.permission.WRITE_CONTACTS"
"reason":"need use ohos.permission.INTERNET" },
} {
], "name":"ohos.permission.SEND_MESSAGES",
"js": [ "reason":"need use ohos.permission.SEND_MESSAGES"
{ },
"pages": [ {
"pages/index/index" "name":"ohos.permission.RECEIVE_SMS",
], "reason":"need use ohos.permission.RECEIVE_SMS"
"name": "default", },
"window": { {
"designWidth": 720, "name":"ohos.permission.READ_CALL_LOG",
"autoDesignWidth": false "reason":"need use ohos.permission.READ_CALL_LOG"
} },
} {
] "name":"ohos.permission.GET_NETWORK_INFO",
} "reason":"need use ohos.permission.GET_NETWORK_INFO"
},
{
"name":"ohos.permission.INTERNET",
"reason":"need use ohos.permission.INTERNET"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
}
}
} }
\ No newline at end of file
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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.
*/ */
export default { export default {
onCreate () { onCreate () {
console.info('TestApplication onCreate'); console.info('TestApplication onCreate');
}, },
onDestroy () { onDestroy () {
console.info('TestApplication onDestroy'); console.info('TestApplication onDestroy');
} }
}; };
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.container { .container {
flex-direction: column; flex-direction: column;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
} }
.title { .title {
font-size: 100px; font-size: 100px;
} }
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 file from '@system.file';
import app from '@system.app'; import app from '@system.app';
import device from '@system.device'; import device from '@system.device';
import router from '@system.router'; import router from '@system.router';
import {Core, ExpectExtend} from 'deccjsunit/index'; import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
const injectRef = Object.getPrototypeOf(global) || global import testsuite from '../../../test/List.test'
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
const injectRef = Object.getPrototypeOf(global) || global
export default { injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
data: {
title: '' export default {
}, data: {
onInit () { title: ''
this.title = this.$t('strings.world'); },
}, onInit () {
onShow () { this.title = this.$t('strings.world');
console.info('onShow finish!'); },
const core = Core.getInstance(); onShow () {
const expectExtend = new ExpectExtend({ console.info('onShow finish!');
'id': 'extend' var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
}); var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
core.addService('expect', expectExtend); console.info('start run testcase!!!')
core.init(); Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
const configService = core.getDefaultService('config'); onReady () {
this.timeout = 30000 },
configService.setConfig(this);
require('../../../test/List.test');
core.execute();
},
onReady () {
},
}; };
\ 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.
*/
export default {
onCreate() {
console.info('TestApplication onCreate');
},
onDestroy() {
console.info('TestApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* 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.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* 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'
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', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
/** /**
* Copyright (C) 2022 Huawei Device Co., Ltd. * Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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 Telephony_NETSTACK_SocketTest from './NetStackSocket.test.js'
require('./Http.nowifi.test');
export default function testsuite() {
Telephony_NETSTACK_SocketTest()
}
\ No newline at end of file
{ {
"string": [ "string": [
{ {
"name": "app_name", "name": "app_name",
"value": "Sim Test" "value": "Sim Test"
}, },
{ {
"name": "mainability_description", "name": "mainability_description",
"value": "Sim Test - sim manager interface test" "value": "Sim Test - sim manager interface test"
} },
] {
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
} }
\ No newline at end of file
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
import("//test/xts/tools/build/suite.gni") import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsNetworkSearchTest") { ohos_js_hap_suite("ActsNetworkSearchTest") {
hap_profile = "./entry/src/main/config.json" hap_profile = "./src/main/config.json"
deps = [ deps = [
":hjs_demo_js_assets", ":hjs_demo_js_assets",
":hjs_demo_resources", ":hjs_demo_resources",
...@@ -22,9 +22,11 @@ ohos_js_hap_suite("ActsNetworkSearchTest") { ...@@ -22,9 +22,11 @@ ohos_js_hap_suite("ActsNetworkSearchTest") {
hap_name = "ActsNetworkSearchTest" hap_name = "ActsNetworkSearchTest"
} }
ohos_js_assets("hjs_demo_js_assets") { ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default" js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
} }
ohos_resources("hjs_demo_resources") { ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ] sources = [ "./src/main/resources" ]
hap_profile = "./entry/src/main/config.json" hap_profile = "./src/main/config.json"
} }
{ {
"description": "Configuration for NetworkSearch Tests", "description": "Configuration for NetworkSearch Tests",
"driver": { "driver": {
"type": "JSUnitTest", "type": "OHJSUnitTest",
"test-timeout": "2100000", "test-timeout": "2100000",
"package": "com.ohos.networksearch", "bundle-name": "com.ohos.networksearch",
"shell-timeout": "60000" "package-name": "com.ohos.networksearch",
}, "shell-timeout": "2100000"
"kits": [ },
{ "kits": [
"test-file-name": [ {
"$module.hap" "test-file-name": [
], "$module.hap"
"type": "AppInstallKit", ],
"cleanup-apps": true "type": "AppInstallKit",
} "cleanup-apps": true
] }
} ]
}
{
"string": [
{
"name": "app_name",
"value": "NetworkSearchTest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ No newline at end of file
/* /*
* Copyright (C) 2021 Huawei Device Co., Ltd. * Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* 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.
*/ */
export default { export default {
onCreate() { onCreate() {
console.info('AceApplication onCreate'); console.info('AceApplication onCreate');
}, },
onDestroy() { onDestroy() {
console.info('AceApplication onDestroy'); console.info('AceApplication onDestroy');
} }
}; };
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册