提交 4b71d04e 编写于 作者: J jiyong_sd

modified FA-JS

Signed-off-by: Njiyong_sd <jiyong@huawei.com>
Change-Id: Ia5f0262d936342546e94b86c60dec127a72beaa2
上级 0750b7c1
......@@ -9,7 +9,7 @@
# 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.
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsBluetoothProFileJsTest") {
......@@ -23,7 +23,9 @@ ohos_js_hap_suite("ActsBluetoothProFileJsTest") {
hap_name = "ActsBluetoothProFileJsTest"
}
ohos_js_assets("bluetooth_js_assets") {
source_dir = "./src/main/js/default"
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("bluetooth_resources") {
sources = [ "./src/main/resources" ]
......
{
"description": "Configuration for bluetooth js api Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "600000",
"package": "ohos.acts.communication.bluetooth.bluetoothhost",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsBluetoothProFileJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"description": "Configuration for bluetooth js api Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"shell-timeout": "600000",
"bundle-name": "ohos.acts.communication.bluetooth.bluetoothhost",
"package-name": "ohos.acts.communication.bluetooth.bluetoothhost"
},
"kits": [
{
"test-file-name": [
"ActsBluetoothProFileJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "ohos.acts.communication.bluetooth.bluetoothhost",
"vendor": "acts",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.communication.bluetooth.bluetoothhost",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
"app": {
"bundleName": "ohos.acts.communication.bluetooth.bluetoothhost",
"vendor": "acts",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"abilities": [
{
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
"deviceConfig": {},
"module": {
"package": "ohos.acts.communication.bluetooth.bluetoothhost",
"name": ".entry",
"deviceType": [
"phone"
],
"name": "ohos.acts.communication.bluetooth.bluetoothhost.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"reqPermissions": [
{
"name": "ohos.permission.USE_BLUETOOTH",
"reason": "",
"usedScene": {
"ability": [
"ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.MANAGE_BLUETOOTH",
"reason": "",
"usedScene": {
"ability": [
"ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.DISCOVER_BLUETOOTH",
"reason": "",
"usedScene": {
"ability": [
"ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.LOCATION",
"reason": "",
"usedScene": {
"ability": [
"ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
],
"when": "inuse"
}
}
]
}
}
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"reqPermissions": [
{
"name": "ohos.permission.USE_BLUETOOTH",
"reason": "",
"usedScene": {
"ability": [
"ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.MANAGE_BLUETOOTH",
"reason": "",
"usedScene": {
"ability": [
"ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.DISCOVER_BLUETOOTH",
"reason": "",
"usedScene": {
"ability": [
"ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.LOCATION",
"reason": "",
"usedScene": {
"ability": [
"ohos.acts.communication.bluetooth.bluetoothhost.MainAbility"
],
"when": "inuse"
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"mainAbility": ".MainAbility",
"srcPath": ""
}
}
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {Core} from 'deccjsunit/index'
const core = Core.getInstance()
core.init()
require('../../test/List.test.js')
core.execute()
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
const configService = core.getDefaultService('config');
this.timeout = 15000;
configService.setConfig(this);
}
}
/*
* 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: "",
myTimeout:50000
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
},
onReady() {
console.info('onReady finish')
},
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('TestApplication onCreate')
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
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'] + '.TestAbility'
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.
* 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 {Core, ExpectExtend} from 'deccjsunit/index'
export default {
data: {
title: "",
myTimeout:50000
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
this.timeout = this.myTimeout
configService.setConfig(this)
require('../../test/List.test')
core.execute()
},
onReady() {
console.info('onReady finish')
},
}
/*
* 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 bluetooth from '@ohos.bluetooth';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
let ProfileId = {
PROFILE_A2DP_SINK : 0,
PROFILE_A2DP_SOURCE : 1,
PROFILE_AVRCP_CT : 2,
PROFILE_AVRCP_TG : 3,
PROFILE_HANDS_FREE_AUDIO_GATEWAY : 4,
PROFILE_HANDS_FREE_UNIT : 5,
PROFILE_HID_HOST : 6,
PROFILE_PAN_NETWORK : 7
}
let PlayingState = {
STATE_NOT_PLAYING : 0x0000 ,
STATE_PLAYING : 0x0001,
}
let a2dpSourceProfile = bluetooth.getProfile(1);
function on(ON_VALUE_TEST_ELEMENT) {
return new Promise((resolve, reject) => {
a2dpSourceProfile.on(ON_VALUE_TEST_ELEMENT, function (err, data) {
if (err != undefined) {
reject(err);
} else {
resolve(data);
}
})
});
}
function off(OFF_VALUE_TEST_ELEMENT) {
return new Promise((resolve, reject) => {
a2dpSourceProfile.off(OFF_VALUE_TEST_ELEMENT, function (err, data) {
if (err != undefined) {
reject(err);
} else {
resolve(data);
}
})
});
}
describe('bluetoothhostTest_host_1', function () {
beforeAll(function () {
console.info('beforeAll called')
})
beforeEach(function () {
console.info('beforeEach called')
})
afterEach(function () {
console.info('afterEach called')
})
afterAll(function () {
console.info('afterAll called')
})
function sleep(delay) {
return new Promise(resovle => setTimeout(resovle, delay))
}
async function tryToEnableBt() {
let sta = bluetooth.getState();
switch(sta){
case 0:
console.info('[bluetooth_js] bt turn off:'+ JSON.stringify(sta));
bluetooth.enableBluetooth();
await sleep(3000);
break;
case 1:
console.info('[bluetooth_js] bt turning on:'+ JSON.stringify(sta));
await sleep(3000);
break;
case 2:
console.info('[bluetooth_js] bt turn on:'+ JSON.stringify(sta));
break;
case 3:
console.info('[bluetooth_js] bt turning off:'+ JSON.stringify(sta));
bluetooth.enableBluetooth();
await sleep(3000);
break;
default:
console.info('[bluetooth_js] enable success');
}
}
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_GET_PROFILE_0001
* @tc.name testgetprofile
* @tc.desc Test getProfile api.
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_GET_PROFILE_0001', 0, async function (done) {
console.info('[bluetooth_js] a2dp get profile start');
await tryToEnableBt();
let proFile = bluetooth.getProfile(1);
console.info('[bluetooth_js] a2dp get profile result:' + JSON.stringify(proFile));
expect(proFile != null).assertEqual(true);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_SOURCCE_PROFILE_CONN_0001
* @tc.name testa2dpSourceProfileconnect
* @tc.desc Test a2dpSourceProfile connect api.
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_SOURCCE_PROFILE_CONN_0001', 0, async function (done) {
console.info('[bluetooth_js] a2dpSourceProfile the connect start');
await tryToEnableBt();
let conn = a2dpSourceProfile.connect('00:00:00:00:00:02');
expect(conn).assertTrue();
await sleep(3000);
let disConn = a2dpSourceProfile.disconnect('00:00:00:00:00:02');
console.info('[bluetooth_js] a2dpSourceProfile disconnect:' + JSON.stringify(disConn));
expect(disConn).assertTrue();
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_GET_PLAYING_STATE_0001
* @tc.name testgetPlayingState
* @tc.desc Test getPlayingState api.
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_GET_PLAYING_STATE_0001', 0, async function (done) {
console.info('[bluetooth_js] a2dpSourceProfile getPlayingState start');
await tryToEnableBt();
let state = a2dpSourceProfile.getPlayingState('00:00:00:00:00:02');
console.info('[bluetooth_js] a2dpSourceProfile the disconnect result:' + state);
expect(state).assertEqual(0);
await sleep(3000);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_GET_PROFILE_STATE_0001
* @tc.name testgetProfileState
* @tc.desc Test getProfileState api.
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_GET_PROFILE_STATE_0001', 0, async function (done) {
console.info('[bluetooth_js] a2dpSourceProfile getProfileState start');
await tryToEnableBt();
let state = bluetooth.getProfileConnState(bluetooth.ProfileId.PROFILE_A2DP_SOURCE);
console.info('[bluetooth_js] a2dpSourceProfile state is:' + state);
expect(state).assertEqual(0);
await sleep(1000);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_SOURCCE_PROFILE_ON_0001
* @tc.name testa2dpSourceProfileon
* @tc.desc Test a2dpSourceProfile on api.
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_SOURCCE_PROFILE_ON_0001', 0, async function (done) {
try {
await tryToEnableBt();
console.info('[bluetooth_js] a2dpSourceProfile the on start');
on("connectionStateChange", function (data) {
console.info("[bluetooth_js] a2dpSource_on data " + JSON.stringify(data));
expect(true).assertEqual(data !=null);
console.info("[bluetooth_js] StateChangeParam deviceId" + data.deviceId +
"ProfileConnectionState" + data.state);
});
}catch(e) {
expect(null).assertFail();
}
try {
console.info('[bluetooth_js] a2dpSourceProfile the off test start');
off("connectionStateChange", function (data) {
console.info("[bluetooth_js] a2dpSource_off data-> " + JSON.stringify(data));
expect(true).assertEqual(data ==null);
});
}catch(e) {
expect(null).assertFail();
}
done();
})
})
/*
* 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 bluetooth from '@ohos.bluetooth';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
let ProfileId = {
PROFILE_A2DP_SINK : 0,
PROFILE_A2DP_SOURCE : 1,
PROFILE_AVRCP_CT : 2,
PROFILE_AVRCP_TG : 3,
PROFILE_HANDS_FREE_AUDIO_GATEWAY : 4,
PROFILE_HANDS_FREE_UNIT : 5,
PROFILE_HID_HOST : 6,
PROFILE_PAN_NETWORK : 7
}
let PlayingState = {
STATE_NOT_PLAYING : 0x0000 ,
STATE_PLAYING : 0x0001,
}
let a2dpSourceProfile = bluetooth.getProfile(1);
function on(ON_VALUE_TEST_ELEMENT) {
return new Promise((resolve, reject) => {
a2dpSourceProfile.on(ON_VALUE_TEST_ELEMENT, function (err, data) {
if (err != undefined) {
reject(err);
} else {
resolve(data);
}
})
});
}
function off(OFF_VALUE_TEST_ELEMENT) {
return new Promise((resolve, reject) => {
a2dpSourceProfile.off(OFF_VALUE_TEST_ELEMENT, function (err, data) {
if (err != undefined) {
reject(err);
} else {
resolve(data);
}
})
});
}
export default function bluetoothhostTest_host_1() {
describe('bluetoothhostTest_host_1', function () {
beforeAll(function () {
console.info('beforeAll called')
})
beforeEach(function () {
console.info('beforeEach called')
})
afterEach(function () {
console.info('afterEach called')
})
afterAll(function () {
console.info('afterAll called')
})
function sleep(delay) {
return new Promise(resovle => setTimeout(resovle, delay))
}
async function tryToEnableBt() {
let sta = bluetooth.getState();
switch(sta){
case 0:
console.info('[bluetooth_js] bt turn off:'+ JSON.stringify(sta));
bluetooth.enableBluetooth();
await sleep(3000);
break;
case 1:
console.info('[bluetooth_js] bt turning on:'+ JSON.stringify(sta));
await sleep(3000);
break;
case 2:
console.info('[bluetooth_js] bt turn on:'+ JSON.stringify(sta));
break;
case 3:
console.info('[bluetooth_js] bt turning off:'+ JSON.stringify(sta));
bluetooth.enableBluetooth();
await sleep(3000);
break;
default:
console.info('[bluetooth_js] enable success');
}
}
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_GET_PROFILE_0001
* @tc.name testgetprofile
* @tc.desc Test getProfile api.
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_GET_PROFILE_0001', 0, async function (done) {
console.info('[bluetooth_js] a2dp get profile start');
await tryToEnableBt();
let proFile = bluetooth.getProfile(1);
console.info('[bluetooth_js] a2dp get profile result:' + JSON.stringify(proFile));
expect(proFile != null).assertEqual(true);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_SOURCCE_PROFILE_CONN_0001
* @tc.name testa2dpSourceProfileconnect
* @tc.desc Test a2dpSourceProfile connect api.
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_SOURCCE_PROFILE_CONN_0001', 0, async function (done) {
console.info('[bluetooth_js] a2dpSourceProfile the connect start');
await tryToEnableBt();
let conn = a2dpSourceProfile.connect('00:00:00:00:00:02');
expect(conn).assertTrue();
await sleep(3000);
let disConn = a2dpSourceProfile.disconnect('00:00:00:00:00:02');
console.info('[bluetooth_js] a2dpSourceProfile disconnect:' + JSON.stringify(disConn));
expect(disConn).assertTrue();
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_GET_PLAYING_STATE_0001
* @tc.name testgetPlayingState
* @tc.desc Test getPlayingState api.
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_GET_PLAYING_STATE_0001', 0, async function (done) {
console.info('[bluetooth_js] a2dpSourceProfile getPlayingState start');
await tryToEnableBt();
let state = a2dpSourceProfile.getPlayingState('00:00:00:00:00:02');
console.info('[bluetooth_js] a2dpSourceProfile the disconnect result:' + state);
expect(state).assertEqual(0);
await sleep(3000);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_GET_PROFILE_STATE_0001
* @tc.name testgetProfileState
* @tc.desc Test getProfileState api.
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_GET_PROFILE_STATE_0001', 0, async function (done) {
console.info('[bluetooth_js] a2dpSourceProfile getProfileState start');
await tryToEnableBt();
let state = bluetooth.getProfileConnState(bluetooth.ProfileId.PROFILE_A2DP_SOURCE);
console.info('[bluetooth_js] a2dpSourceProfile state is:' + state);
expect(state).assertEqual(0);
await sleep(1000);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_SOURCCE_PROFILE_ON_0001
* @tc.name testa2dpSourceProfileon
* @tc.desc Test a2dpSourceProfile on api.
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_A2DP_SOURCCE_PROFILE_ON_0001', 0, async function (done) {
try {
await tryToEnableBt();
console.info('[bluetooth_js] a2dpSourceProfile the on start');
on("connectionStateChange", function (data) {
console.info("[bluetooth_js] a2dpSource_on data " + JSON.stringify(data));
expect(true).assertEqual(data !=null);
console.info("[bluetooth_js] StateChangeParam deviceId" + data.deviceId +
"ProfileConnectionState" + data.state);
});
}catch(e) {
expect(null).assertFail();
}
try {
console.info('[bluetooth_js] a2dpSourceProfile the off test start');
off("connectionStateChange", function (data) {
console.info("[bluetooth_js] a2dpSource_off data-> " + JSON.stringify(data));
expect(true).assertEqual(data ==null);
});
}catch(e) {
expect(null).assertFail();
}
done();
})
})
}
/*
* 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 bluetooth from '@ohos.bluetooth';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
let hfpGatewayProfile = bluetooth.getProfile(4);
let ProfileId = {
PROFILE_A2DP_SINK : 0,
PROFILE_A2DP_SOURCE : 1,
PROFILE_AVRCP_CT : 2,
PROFILE_AVRCP_TG : 3,
PROFILE_HANDS_FREE_AUDIO_GATEWAY : 4,
PROFILE_HANDS_FREE_UNIT : 5,
PROFILE_HID_HOST : 6,
PROFILE_PAN_NETWORK : 7
}
function on(ON_VALUE_TEST_ELEMENT) {
return new Promise((resolve, reject) => {
hfpGatewayProfile.on(ON_VALUE_TEST_ELEMENT, function (err, data) {
if (err != undefined) {
reject(err);
} else {
resolve(data);
}
})
});
}
function off(OFF_VALUE_TEST_ELEMENT) {
return new Promise((resolve, reject) => {
hfpGatewayProfile.off(OFF_VALUE_TEST_ELEMENT, function (err, data) {
if (err != undefined) {
reject(err);
} else {
resolve(data);
}
})
});
}
describe('bluetoothhostTest_host_3', function () {
beforeAll(function () {
console.info('beforeAll called')
})
beforeEach(function () {
console.info('beforeEach called')
})
afterEach(function () {
console.info('afterEach called')
})
afterAll(function () {
console.info('afterAll called')
})
function sleep(delay) {
return new Promise(resovle => setTimeout(resovle, delay))
}
async function tryToEnableBt() {
let sta = bluetooth.getState();
switch(sta){
case 0:
console.info('[bluetooth_js] bt turn off:'+ JSON.stringify(sta));
bluetooth.enableBluetooth();
await sleep(3000);
break;
case 1:
console.info('[bluetooth_js] bt turning on:'+ JSON.stringify(sta));
await sleep(3000);
break;
case 2:
console.info('[bluetooth_js] bt turn on:'+ JSON.stringify(sta));
break;
case 3:
console.info('[bluetooth_js] bt turning off:'+ JSON.stringify(sta));
bluetooth.enableBluetooth();
await sleep(3000);
break;
default:
console.info('[bluetooth_js] enable success');
}
}
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_PROFILE_0001
* @tc.name testgetprofile
* @tc.desc Test getProfile api.
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_HFP_GET_PROFILE_0001', 0, async function (done) {
console.info('[bluetooth_js] hfp get profile start');
await tryToEnableBt();
let proFile = bluetooth.getProfile(4);
console.info('[bluetooth_js] get profile:' + JSON.stringify(proFile));
expect(proFile != null).assertEqual(true);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_HFP_GATWAY_PROFILE_CONN_0001
* @tc.name testhfpGatewayProfileconnect
* @tc.desc Test hfpGatewayProfile connect api.
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_HFP_GATWAY_PROFILE_CONN_0001', 0, async function (done) {
console.info('[bluetooth_js] hfpGatewayProfile the connect start');
await tryToEnableBt();
let conn = hfpGatewayProfile.connect('00:00:00:00:00:01');
expect(conn).assertTrue();
await sleep(2000);
let disConn = hfpGatewayProfile.disconnect('00:00:00:00:00:01');
console.info('[bluetooth_js] hfpGatewayProfile disconnect:' + disConn);
expect(disConn).assertTrue();
await sleep(2000);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_HFP_GATWAY_PROFILE_ON_0001
* @tc.name testhfpGatewayProfileon
* @tc.desc Test hfpGatewayProfile on api.
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_HFP_GATWAY_PROFILE_ON_0001', 0, async function (done) {
try {
await tryToEnableBt();
console.info('[bluetooth_js] hfpGatewayProfile the on start');
on("connectionStateChange", function (data) {
console.info("[bluetooth_js] hfpGateway_on data " + JSON.stringify(data));
expect(true).assertEqual(data !=null);
});
}catch(e) {
expect(null).assertFail();
}
try {
console.info('[bluetooth_js] hfpGatewayProfile the off test start');
off("connectionStateChange", function (data) {
console.info("[bluetooth_js] hfpGateway_off data-> " + JSON.stringify(data));
expect(true).assertEqual(data ==null);
});
}catch(e) {
expect(null).assertFail();
}
done();
})
})
/*
* 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 bluetooth from '@ohos.bluetooth';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
let hfpGatewayProfile = bluetooth.getProfile(4);
let ProfileId = {
PROFILE_A2DP_SINK : 0,
PROFILE_A2DP_SOURCE : 1,
PROFILE_AVRCP_CT : 2,
PROFILE_AVRCP_TG : 3,
PROFILE_HANDS_FREE_AUDIO_GATEWAY : 4,
PROFILE_HANDS_FREE_UNIT : 5,
PROFILE_HID_HOST : 6,
PROFILE_PAN_NETWORK : 7
}
function on(ON_VALUE_TEST_ELEMENT) {
return new Promise((resolve, reject) => {
hfpGatewayProfile.on(ON_VALUE_TEST_ELEMENT, function (err, data) {
if (err != undefined) {
reject(err);
} else {
resolve(data);
}
})
});
}
function off(OFF_VALUE_TEST_ELEMENT) {
return new Promise((resolve, reject) => {
hfpGatewayProfile.off(OFF_VALUE_TEST_ELEMENT, function (err, data) {
if (err != undefined) {
reject(err);
} else {
resolve(data);
}
})
});
}
export default function bluetoothhostTest_host_3() {
describe('bluetoothhostTest_host_3', function () {
beforeAll(function () {
console.info('beforeAll called')
})
beforeEach(function () {
console.info('beforeEach called')
})
afterEach(function () {
console.info('afterEach called')
})
afterAll(function () {
console.info('afterAll called')
})
function sleep(delay) {
return new Promise(resovle => setTimeout(resovle, delay))
}
async function tryToEnableBt() {
let sta = bluetooth.getState();
switch(sta){
case 0:
console.info('[bluetooth_js] bt turn off:'+ JSON.stringify(sta));
bluetooth.enableBluetooth();
await sleep(3000);
break;
case 1:
console.info('[bluetooth_js] bt turning on:'+ JSON.stringify(sta));
await sleep(3000);
break;
case 2:
console.info('[bluetooth_js] bt turn on:'+ JSON.stringify(sta));
break;
case 3:
console.info('[bluetooth_js] bt turning off:'+ JSON.stringify(sta));
bluetooth.enableBluetooth();
await sleep(3000);
break;
default:
console.info('[bluetooth_js] enable success');
}
}
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_PROFILE_0001
* @tc.name testgetprofile
* @tc.desc Test getProfile api.
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_HFP_GET_PROFILE_0001', 0, async function (done) {
console.info('[bluetooth_js] hfp get profile start');
await tryToEnableBt();
let proFile = bluetooth.getProfile(4);
console.info('[bluetooth_js] get profile:' + JSON.stringify(proFile));
expect(proFile != null).assertEqual(true);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_HFP_GATWAY_PROFILE_CONN_0001
* @tc.name testhfpGatewayProfileconnect
* @tc.desc Test hfpGatewayProfile connect api.
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_HFP_GATWAY_PROFILE_CONN_0001', 0, async function (done) {
console.info('[bluetooth_js] hfpGatewayProfile the connect start');
await tryToEnableBt();
let conn = hfpGatewayProfile.connect('00:00:00:00:00:01');
expect(conn).assertTrue();
await sleep(2000);
let disConn = hfpGatewayProfile.disconnect('00:00:00:00:00:01');
console.info('[bluetooth_js] hfpGatewayProfile disconnect:' + disConn);
expect(disConn).assertTrue();
await sleep(2000);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_HFP_GATWAY_PROFILE_ON_0001
* @tc.name testhfpGatewayProfileon
* @tc.desc Test hfpGatewayProfile on api.
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_HFP_GATWAY_PROFILE_ON_0001', 0, async function (done) {
try {
await tryToEnableBt();
console.info('[bluetooth_js] hfpGatewayProfile the on start');
on("connectionStateChange", function (data) {
console.info("[bluetooth_js] hfpGateway_on data " + JSON.stringify(data));
expect(true).assertEqual(data !=null);
});
}catch(e) {
expect(null).assertFail();
}
try {
console.info('[bluetooth_js] hfpGatewayProfile the off test start');
off("connectionStateChange", function (data) {
console.info("[bluetooth_js] hfpGateway_off data-> " + JSON.stringify(data));
expect(true).assertEqual(data ==null);
});
}catch(e) {
expect(null).assertFail();
}
done();
})
})
}
/*
* 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 bluetooth from '@ohos.bluetooth';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
let hidHostProfile = bluetooth.getProfile(6);
function on(ON_VALUE_TEST_ELEMENT) {
return new Promise((resolve, reject) => {
hidHostProfile.on(ON_VALUE_TEST_ELEMENT, function (err, data) {
if (err != undefined) {
reject(err);
} else {
resolve(data);
}
})
});
}
function off(OFF_VALUE_TEST_ELEMENT) {
return new Promise((resolve, reject) => {
hidHostProfile.off(OFF_VALUE_TEST_ELEMENT, function (err, data) {
if (err != undefined) {
reject(err);
} else {
resolve(data);
}
})
});
}
let ProfId = {
PROFILE_A2DP_SINK : 0,
PROFILE_A2DP_SOURCE : 1,
PROFILE_AVRCP_CT : 2,
PROFILE_AVRCP_TG : 3,
PROFILE_HANDS_FREE_AUDIO_GATEWAY : 4,
PROFILE_HANDS_FREE_UNIT : 5
}
describe('bluetoothhostTest_host_2', function () {
beforeAll(function () {
console.info('beforeAll called')
})
beforeEach(function () {
console.info('beforeEach called')
})
afterEach(function () {
console.info('afterEach called')
})
afterAll(function () {
console.info('afterAll called')
})
function sleep(delay) {
return new Promise(resovle => setTimeout(resovle, delay))
}
async function tryToEnableBt() {
let sta = bluetooth.getState();
switch(sta){
case 0:
console.info('[bluetooth_js] bt turn off:'+ JSON.stringify(sta));
bluetooth.enableBluetooth();
await sleep(3000);
break;
case 1:
console.info('[bluetooth_js] bt turning on:'+ JSON.stringify(sta));
await sleep(3000);
break;
case 2:
console.info('[bluetooth_js] bt turn on:'+ JSON.stringify(sta));
break;
case 3:
console.info('[bluetooth_js] bt turning off:'+ JSON.stringify(sta));
bluetooth.enableBluetooth();
await sleep(3000);
break;
default:
console.info('[bluetooth_js] enable success');
}
}
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_PROFILE_LOOP_0001
* @tc.name looptestgetprofile(set parameterless)
* @tc.desc Test getProfile api 1000 times.
* @tc.author defu.zheng
* @tc.size SMALL
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_PROFILE_LOOP_0001', 0, async function (done) {
console.info('[bluetooth_js] loop get profile start');
await tryToEnableBt();
let proFile = bluetooth.getProfile(6);
console.info('[bluetooth_js] loop get profile result:' + JSON.stringify(proFile));
expect(proFile != null).assertEqual(true);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_CONN_DEV_LOOP_0001
* @tc.name looptestgetConnectionDevices(bluetooth mode is off)
* @tc.desc Test getConnectionDevices api 1000 times.
* @tc.author defu.zheng
* @tc.size SMALL
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_CONN_DEV_LOOP_0001', 0, async function (done) {
console.info('[bluetooth_js] loop get connection devices start');
await tryToEnableBt();
let arrDev = hidHostProfile.getConnectionDevices();
console.info('[bluetooth_js] loop getconndev:' + JSON.stringify(arrDev)+ 'length'+ arrDev.length);
expect(arrDev.length).assertEqual(0);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_DEV_STATE_LOOP_0001
* @tc.name looptestgetDeviceState(set a null value)
* @tc.desc Test getDeviceState api 1000 times.
* @tc.author defu.zheng
* @tc.size SMALL
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_DEV_STATE_LOOP_0001', 0, async function (done) {
console.info('[bluetooth_js] loop get device state start');
await tryToEnableBt();
let devState = hidHostProfile.getDeviceState('');
console.info('[bluetooth_js] loop get device state result:' + JSON.stringify(devState));
expect(devState).assertEqual(0);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_HID_HOST_PROFILE_CONN_LOOP_0001
* @tc.name looptesthidhostprofileconnect(set a null value)
* @tc.desc Test hidHostProfile connect api 1000 times.
* @tc.author defu.zheng
* @tc.size SMALL
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_HID_HOST_PROFILE_CONN_LOOP_0001', 0, async function (done) {
console.info('[bluetooth_js] loop HidHostProfile the connect start');
await tryToEnableBt();
let conn = hidHostProfile.connect('');
console.info('[bluetooth_js] loop HidHostProfile the connect result:' + JSON.stringify(conn));
expect(conn).assertFalse();
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_HID_HOST_PROFILE_DISCONN_LOOP_0001
* @tc.name looptesthidhostprofiledisconnect(set a null value)
* @tc.desc Test hidHostProfile disconnect api 1000 times.
* @tc.author defu.zheng
* @tc.size SMALL
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_HID_HOST_PROFILE_DISCONN_LOOP_0001', 0, async function (done) {
console.info('[bluetooth_js] loop HidHostProfile the disconnect start');
await tryToEnableBt();
let disConn = hidHostProfile.disconnect('');
console.info('[bluetooth_js] loop HidHostProfile the disconnect result:' + JSON.stringify(disConn));
expect(disConn).assertFalse();
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_HID_HOST_PROFILE_ON_LOOP_0001
* @tc.name looptesthidhostprofileon
* @tc.desc Test hidHostProfile on api 1000 times.
* @tc.author defu.zheng
* @tc.size SMALL
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_HID_HOST_PROFILE_ON_LOOP_0001', 0, async function (done) {
try {
await tryToEnableBt();
console.info('[bluetooth_js] loop HidHostProfile the on start');
on("connectionStateChange", function (data) {
console.info("[bluetooth_js] HidHostProfile_on data " + JSON.stringify(data));
expect(true).assertEqual(data !=null);
});
}catch(e) {
expect(null).assertFail();
}
try {
console.info('[bluetooth_js] HidHostProfile the off test start');
off("connectionStateChange", function (data) {
console.info("[bluetooth_js] HidHostProfile_off data-> " + JSON.stringify(data));
expect(true).assertEqual(data ==null);
});
}catch(e) {
expect(null).assertFail();
}
done();
})
})
/*
* 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 bluetooth from '@ohos.bluetooth';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
let hidHostProfile = bluetooth.getProfile(6);
function on(ON_VALUE_TEST_ELEMENT) {
return new Promise((resolve, reject) => {
hidHostProfile.on(ON_VALUE_TEST_ELEMENT, function (err, data) {
if (err != undefined) {
reject(err);
} else {
resolve(data);
}
})
});
}
function off(OFF_VALUE_TEST_ELEMENT) {
return new Promise((resolve, reject) => {
hidHostProfile.off(OFF_VALUE_TEST_ELEMENT, function (err, data) {
if (err != undefined) {
reject(err);
} else {
resolve(data);
}
})
});
}
let ProfId = {
PROFILE_A2DP_SINK : 0,
PROFILE_A2DP_SOURCE : 1,
PROFILE_AVRCP_CT : 2,
PROFILE_AVRCP_TG : 3,
PROFILE_HANDS_FREE_AUDIO_GATEWAY : 4,
PROFILE_HANDS_FREE_UNIT : 5
}
export default function bluetoothhostTest_host_2() {
describe('bluetoothhostTest_host_2', function () {
beforeAll(function () {
console.info('beforeAll called')
})
beforeEach(function () {
console.info('beforeEach called')
})
afterEach(function () {
console.info('afterEach called')
})
afterAll(function () {
console.info('afterAll called')
})
function sleep(delay) {
return new Promise(resovle => setTimeout(resovle, delay))
}
async function tryToEnableBt() {
let sta = bluetooth.getState();
switch(sta){
case 0:
console.info('[bluetooth_js] bt turn off:'+ JSON.stringify(sta));
bluetooth.enableBluetooth();
await sleep(3000);
break;
case 1:
console.info('[bluetooth_js] bt turning on:'+ JSON.stringify(sta));
await sleep(3000);
break;
case 2:
console.info('[bluetooth_js] bt turn on:'+ JSON.stringify(sta));
break;
case 3:
console.info('[bluetooth_js] bt turning off:'+ JSON.stringify(sta));
bluetooth.enableBluetooth();
await sleep(3000);
break;
default:
console.info('[bluetooth_js] enable success');
}
}
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_PROFILE_LOOP_0001
* @tc.name looptestgetprofile(set parameterless)
* @tc.desc Test getProfile api 1000 times.
* @tc.author defu.zheng
* @tc.size SMALL
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_PROFILE_LOOP_0001', 0, async function (done) {
console.info('[bluetooth_js] loop get profile start');
await tryToEnableBt();
let proFile = bluetooth.getProfile(6);
console.info('[bluetooth_js] loop get profile result:' + JSON.stringify(proFile));
expect(proFile != null).assertEqual(true);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_CONN_DEV_LOOP_0001
* @tc.name looptestgetConnectionDevices(bluetooth mode is off)
* @tc.desc Test getConnectionDevices api 1000 times.
* @tc.author defu.zheng
* @tc.size SMALL
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_CONN_DEV_LOOP_0001', 0, async function (done) {
console.info('[bluetooth_js] loop get connection devices start');
await tryToEnableBt();
let arrDev = hidHostProfile.getConnectionDevices();
console.info('[bluetooth_js] loop getconndev:' + JSON.stringify(arrDev)+ 'length'+ arrDev.length);
expect(arrDev.length).assertEqual(0);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_DEV_STATE_LOOP_0001
* @tc.name looptestgetDeviceState(set a null value)
* @tc.desc Test getDeviceState api 1000 times.
* @tc.author defu.zheng
* @tc.size SMALL
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_GET_DEV_STATE_LOOP_0001', 0, async function (done) {
console.info('[bluetooth_js] loop get device state start');
await tryToEnableBt();
let devState = hidHostProfile.getDeviceState('');
console.info('[bluetooth_js] loop get device state result:' + JSON.stringify(devState));
expect(devState).assertEqual(0);
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_HID_HOST_PROFILE_CONN_LOOP_0001
* @tc.name looptesthidhostprofileconnect(set a null value)
* @tc.desc Test hidHostProfile connect api 1000 times.
* @tc.author defu.zheng
* @tc.size SMALL
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_HID_HOST_PROFILE_CONN_LOOP_0001', 0, async function (done) {
console.info('[bluetooth_js] loop HidHostProfile the connect start');
await tryToEnableBt();
let conn = hidHostProfile.connect('');
console.info('[bluetooth_js] loop HidHostProfile the connect result:' + JSON.stringify(conn));
expect(conn).assertFalse();
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_HID_HOST_PROFILE_DISCONN_LOOP_0001
* @tc.name looptesthidhostprofiledisconnect(set a null value)
* @tc.desc Test hidHostProfile disconnect api 1000 times.
* @tc.author defu.zheng
* @tc.size SMALL
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_HID_HOST_PROFILE_DISCONN_LOOP_0001', 0, async function (done) {
console.info('[bluetooth_js] loop HidHostProfile the disconnect start');
await tryToEnableBt();
let disConn = hidHostProfile.disconnect('');
console.info('[bluetooth_js] loop HidHostProfile the disconnect result:' + JSON.stringify(disConn));
expect(disConn).assertFalse();
done();
})
/**
* @tc.number SUB_COMMUNACATION_bluetooth_DEVICE_JS_HID_HOST_PROFILE_ON_LOOP_0001
* @tc.name looptesthidhostprofileon
* @tc.desc Test hidHostProfile on api 1000 times.
* @tc.author defu.zheng
* @tc.size SMALL
* @tc.type Function
* @tc.level Level 0
*/
it('SUB_COMMUNACATION_bluetooth_DEVICE_JS_HID_HOST_PROFILE_ON_LOOP_0001', 0, async function (done) {
try {
await tryToEnableBt();
console.info('[bluetooth_js] loop HidHostProfile the on start');
on("connectionStateChange", function (data) {
console.info("[bluetooth_js] HidHostProfile_on data " + JSON.stringify(data));
expect(true).assertEqual(data !=null);
});
}catch(e) {
expect(null).assertFail();
}
try {
console.info('[bluetooth_js] HidHostProfile the off test start');
off("connectionStateChange", function (data) {
console.info("[bluetooth_js] HidHostProfile_off data-> " + JSON.stringify(data));
expect(true).assertEqual(data ==null);
});
}catch(e) {
expect(null).assertFail();
}
done();
})
})
}
......@@ -13,6 +13,11 @@
* limitations under the License.
*/
require('./BluetoothHfp.test.js')
require('./BluetoothA2dp.test.js')
require('./BluetoothHid.test.js')
import bluetoothhostTest_host_1 from './BluetoothHfp.test.js'
import bluetoothhostTest_host_3 from './BluetoothA2dp.test.js'
import bluetoothhostTest_host_2 from './BluetoothHid.test.js'
export default function testsuite() {
bluetoothhostTest_host_1()
bluetoothhostTest_host_3()
bluetoothhostTest_host_2()
}
......@@ -7,6 +7,22 @@
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
},
{
"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,7 +9,7 @@
# 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.
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
......@@ -23,7 +23,9 @@ ohos_js_hap_suite("ActsP2PJSTest") {
hap_name = "ActsP2PJSApiTest"
}
ohos_js_assets("wifi_js_assets") {
source_dir = "./src/main/js/default"
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("wifi_resources") {
sources = [ "./src/main/resources" ]
......
{
"description": "Configuration for wifi js api Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "600000",
"package": "ohos.acts.communication.wifi.wifidevice",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"ActsP2PJSApiTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"description": "Configuration for wifi js api Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"shell-timeout": "600000",
"bundle-name": "ohos.acts.communication.wifi.wifidevice",
"package-name": "ohos.acts.communication.wifi.wifidevice"
},
"kits": [
{
"test-file-name": [
"ActsP2PJSApiTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
文件模式从 100755 更改为 100644
{
"app": {
"bundleName": "ohos.acts.communication.wifi.wifidevice",
"vendor": "acts",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.communication.wifi.wifidevice",
"name": ".MyApplication",
"mainAbility": "ohos.acts.communication.wifi.wifidevice.MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "wifi_standard",
"moduleType": "entry"
"app": {
"bundleName": "ohos.acts.communication.wifi.wifidevice",
"vendor": "acts",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"abilities": [
{
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
"deviceConfig": {},
"module": {
"package": "ohos.acts.communication.wifi.wifidevice",
"name": ".entry",
"mainAbility": ".MainAbility",
"deviceType": [
"phone"
],
"name": "ohos.acts.communication.wifi.wifidevice.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
"distro": {
"deliveryWithInstall": true,
"moduleName": "wifi_standard",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"defPermissions": [
{
"availableScope": [],
"grantMode": "user_grant",
"name": "ohos.permission.ACCESS_LOCATION",
"availableLevel": "system_basic",
"provisionEnable": true,
"distributedSceneEnable": true,
"label": "ACCESS_LOCATION label",
"description": "ACCESS_LOCATION description"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.MANAGE_SECURE_SETTINGS",
"availableLevel": "system_basic",
"provisionEnable": true,
"distributedSceneEnable": false,
"label": "MANAGE_SECURE_SETTINGS label",
"description": "MANAGE_SECURE_SETTINGS description"
},
{
"availableScope": [],
"grantMode": "user_grant",
"name": "ohos.permission.LOCATION",
"availableLevel": "system_basic",
"provisionEnable": true,
"distributedSceneEnable": true,
"label": "LOCATION label",
"description": "LOCATION description"
}
],
"reqPermissions": [
{
"name" : "ohos.permission.GET_WIFI_INFO",
"reason" : "use ohos.permission.GET_WIFI_INFO"
},
{
"name" : "ohos.permission.SET_WIFI_INFO",
"reason" : "use ohos.permission.SET_WIFI_INFO"
},
{
"name" : "ohos.permission.MANAGE_WIFI_CONNECTION",
"reason" : "use ohos.permission.MANAGE_WIFI_CONNECTION"
},
{
"name" : "ohos.permission.SET_WIFI_CONFIG",
"reason" : "use ohos.permission.SET_WIFI_CONFIG"
},
{
"name" : "ohos.permission.GET_WIFI_CONFIG",
"reason" : "use ohos.permission.GET_WIFI_CONFIG"
},
{
"name" : "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason" : "use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name" : "ohos.permission.GET_WIFI_LOCAL_MAC",
"reason" : "use ohos.permission.GET_WIFI_LOCAL_MAC"
},
{
"name" : "ohos.permission.GET_WIFI_PEERS_MAC",
"reason" : "use ohos.permission.GET_WIFI_PEERS_MAC"
},
{
"name" : "ohos.permission.MANAGE_WIFI_HOTSPOT",
"reason" : "use ohos.permission.MANAGE_WIFI_HOTSPOT"
},
{
"name" : "ohos.permission.GET_WIFI_INFO_INTERNAL",
"reason" : "use ohos.permission.GET_WIFI_INFO_INTERNAL"
},
{
"name": "ohos.permission.LOCATION",
"reason": "need use ohos.permission.LOCATION",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name":"ohos.permission.ACCESS_LOCATION",
"reason":"need use ohos.permission.ACCESS_LOCATION",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name":"ohos.permission.LOCATION_IN_BACKGROUND",
"reason":"need use ohos.permission.LOCATION_IN_BACKGROUND",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name":"ohos.permission.MANAGE_SECURE_SETTINGS",
"reason":"need use ohos.permission.MANAGE_SECURE_SETTINGS",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO"
}
]
}
}
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"defPermissions": [
{
"availableScope": [],
"grantMode": "user_grant",
"name": "ohos.permission.ACCESS_LOCATION",
"availableLevel": "system_basic",
"provisionEnable": true,
"distributedSceneEnable": true,
"label": "ACCESS_LOCATION label",
"description": "ACCESS_LOCATION description"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.MANAGE_SECURE_SETTINGS",
"availableLevel": "system_basic",
"provisionEnable": true,
"distributedSceneEnable": false,
"label": "MANAGE_SECURE_SETTINGS label",
"description": "MANAGE_SECURE_SETTINGS description"
},
{
"availableScope": [],
"grantMode": "user_grant",
"name": "ohos.permission.LOCATION",
"availableLevel": "system_basic",
"provisionEnable": true,
"distributedSceneEnable": true,
"label": "LOCATION label",
"description": "LOCATION description"
}
],
"reqPermissions": [
{
"name": "ohos.permission.GET_WIFI_INFO",
"reason": "use ohos.permission.GET_WIFI_INFO"
},
{
"name": "ohos.permission.SET_WIFI_INFO",
"reason": "use ohos.permission.SET_WIFI_INFO"
},
{
"name": "ohos.permission.MANAGE_WIFI_CONNECTION",
"reason": "use ohos.permission.MANAGE_WIFI_CONNECTION"
},
{
"name": "ohos.permission.SET_WIFI_CONFIG",
"reason": "use ohos.permission.SET_WIFI_CONFIG"
},
{
"name": "ohos.permission.GET_WIFI_CONFIG",
"reason": "use ohos.permission.GET_WIFI_CONFIG"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason": "use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.GET_WIFI_LOCAL_MAC",
"reason": "use ohos.permission.GET_WIFI_LOCAL_MAC"
},
{
"name": "ohos.permission.GET_WIFI_PEERS_MAC",
"reason": "use ohos.permission.GET_WIFI_PEERS_MAC"
},
{
"name": "ohos.permission.MANAGE_WIFI_HOTSPOT",
"reason": "use ohos.permission.MANAGE_WIFI_HOTSPOT"
},
{
"name": "ohos.permission.GET_WIFI_INFO_INTERNAL",
"reason": "use ohos.permission.GET_WIFI_INFO_INTERNAL"
},
{
"name": "ohos.permission.LOCATION",
"reason": "need use ohos.permission.LOCATION",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.ACCESS_LOCATION",
"reason": "need use ohos.permission.ACCESS_LOCATION",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.LOCATION_IN_BACKGROUND",
"reason": "need use ohos.permission.LOCATION_IN_BACKGROUND",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.MANAGE_SECURE_SETTINGS",
"reason": "need use ohos.permission.MANAGE_SECURE_SETTINGS",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO"
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"srcPath": ""
}
}
\ 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 {
data: {
title: '',
myTimeout: 25000
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
},
onReady() {
console.info('onReady finish')
},
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('TestApplication onCreate')
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
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'] + '.TestAbility'
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.
* 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 {Core, ExpectExtend} from 'deccjsunit/index'
export default {
data: {
title: '',
myTimeout: 25000
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
this.timeout = this.myTimeout
configService.setConfig(this)
require('../../test/List.test')
core.execute()
},
onReady() {
console.info('onReady finish')
},
}
......@@ -14,6 +14,7 @@
*/
//require('./WifiSta.test.js')
//require('./WifiSoftAP.test.js')
require('./WifiP2P.test.js')
import ACTS_WifiTest from './WifiP2P.test.js'
export default function testsuite() {
ACTS_WifiTest()
}
......@@ -7,6 +7,22 @@
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
},
{
"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,7 +9,7 @@
# 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.
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
......@@ -23,7 +23,9 @@ ohos_js_hap_suite("ActsWifiJSTest") {
hap_name = "ActsWifiJSApiTest"
}
ohos_js_assets("wifi_js_assets") {
source_dir = "./src/main/js/default"
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("wifi_resources") {
sources = [ "./src/main/resources" ]
......
{
"description": "Configuration for wifi js api Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "600000",
"package": "ohos.acts.communication.wifi.wifidevice",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"ActsWifiJSApiTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"description": "Configuration for wifi js api Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"shell-timeout": "600000",
"bundle-name": "ohos.acts.communication.wifi.wifidevice",
"package-name": "ohos.acts.communication.wifi.wifidevice"
},
"kits": [
{
"test-file-name": [
"ActsWifiJSApiTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
文件模式从 100755 更改为 100644
{
"app": {
"bundleName": "ohos.acts.communication.wifi.wifidevice",
"vendor": "acts",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.communication.wifi.wifidevice",
"name": ".MyApplication",
"mainAbility": "ohos.acts.communication.wifi.wifidevice.MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "wifi_standard",
"moduleType": "entry"
"app": {
"bundleName": "ohos.acts.communication.wifi.wifidevice",
"vendor": "acts",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"abilities": [
{
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
"deviceConfig": {},
"module": {
"package": "ohos.acts.communication.wifi.wifidevice",
"name": ".entry",
"mainAbility": ".MainAbility",
"deviceType": [
"phone"
],
"name": "ohos.acts.communication.wifi.wifidevice.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
"distro": {
"deliveryWithInstall": true,
"moduleName": "wifi_standard",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"defPermissions": [
{
"availableScope": [],
"grantMode": "user_grant",
"name": "ohos.permission.ACCESS_LOCATION",
"availableLevel": "system_basic",
"provisionEnable": true,
"distributedSceneEnable": true,
"label": "ACCESS_LOCATION label",
"description": "ACCESS_LOCATION description"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.MANAGE_SECURE_SETTINGS",
"availableLevel": "system_basic",
"provisionEnable": true,
"distributedSceneEnable": false,
"label": "MANAGE_SECURE_SETTINGS label",
"description": "MANAGE_SECURE_SETTINGS description"
},
{
"availableScope": [],
"grantMode": "user_grant",
"name": "ohos.permission.LOCATION",
"availableLevel": "system_basic",
"provisionEnable": true,
"distributedSceneEnable": true,
"label": "LOCATION label",
"description": "LOCATION description"
}
],
"reqPermissions": [
{
"name" : "ohos.permission.GET_WIFI_INFO",
"reason" : "use ohos.permission.GET_WIFI_INFO"
},
{
"name" : "ohos.permission.SET_WIFI_INFO",
"reason" : "use ohos.permission.SET_WIFI_INFO"
},
{
"name" : "ohos.permission.MANAGE_WIFI_CONNECTION",
"reason" : "use ohos.permission.MANAGE_WIFI_CONNECTION"
},
{
"name" : "ohos.permission.SET_WIFI_CONFIG",
"reason" : "use ohos.permission.SET_WIFI_CONFIG"
},
{
"name" : "ohos.permission.GET_WIFI_CONFIG",
"reason" : "use ohos.permission.GET_WIFI_CONFIG"
},
{
"name" : "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason" : "use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name" : "ohos.permission.GET_WIFI_LOCAL_MAC",
"reason" : "use ohos.permission.GET_WIFI_LOCAL_MAC"
},
{
"name" : "ohos.permission.GET_WIFI_PEERS_MAC",
"reason" : "use ohos.permission.GET_WIFI_PEERS_MAC"
},
{
"name" : "ohos.permission.MANAGE_WIFI_HOTSPOT",
"reason" : "use ohos.permission.MANAGE_WIFI_HOTSPOT"
},
{
"name" : "ohos.permission.GET_WIFI_INFO_INTERNAL",
"reason" : "use ohos.permission.GET_WIFI_INFO_INTERNAL"
},
{
"name": "ohos.permission.LOCATION",
"reason": "need use ohos.permission.LOCATION",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name":"ohos.permission.ACCESS_LOCATION",
"reason":"need use ohos.permission.ACCESS_LOCATION",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name":"ohos.permission.LOCATION_IN_BACKGROUND",
"reason":"need use ohos.permission.LOCATION_IN_BACKGROUND",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name":"ohos.permission.MANAGE_SECURE_SETTINGS",
"reason":"need use ohos.permission.MANAGE_SECURE_SETTINGS",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO"
}
]
}
}
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"defPermissions": [
{
"availableScope": [],
"grantMode": "user_grant",
"name": "ohos.permission.ACCESS_LOCATION",
"availableLevel": "system_basic",
"provisionEnable": true,
"distributedSceneEnable": true,
"label": "ACCESS_LOCATION label",
"description": "ACCESS_LOCATION description"
},
{
"availableScope": [],
"grantMode": "system_grant",
"name": "ohos.permission.MANAGE_SECURE_SETTINGS",
"availableLevel": "system_basic",
"provisionEnable": true,
"distributedSceneEnable": false,
"label": "MANAGE_SECURE_SETTINGS label",
"description": "MANAGE_SECURE_SETTINGS description"
},
{
"availableScope": [],
"grantMode": "user_grant",
"name": "ohos.permission.LOCATION",
"availableLevel": "system_basic",
"provisionEnable": true,
"distributedSceneEnable": true,
"label": "LOCATION label",
"description": "LOCATION description"
}
],
"reqPermissions": [
{
"name": "ohos.permission.GET_WIFI_INFO",
"reason": "use ohos.permission.GET_WIFI_INFO"
},
{
"name": "ohos.permission.SET_WIFI_INFO",
"reason": "use ohos.permission.SET_WIFI_INFO"
},
{
"name": "ohos.permission.MANAGE_WIFI_CONNECTION",
"reason": "use ohos.permission.MANAGE_WIFI_CONNECTION"
},
{
"name": "ohos.permission.SET_WIFI_CONFIG",
"reason": "use ohos.permission.SET_WIFI_CONFIG"
},
{
"name": "ohos.permission.GET_WIFI_CONFIG",
"reason": "use ohos.permission.GET_WIFI_CONFIG"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED",
"reason": "use ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.GET_WIFI_LOCAL_MAC",
"reason": "use ohos.permission.GET_WIFI_LOCAL_MAC"
},
{
"name": "ohos.permission.GET_WIFI_PEERS_MAC",
"reason": "use ohos.permission.GET_WIFI_PEERS_MAC"
},
{
"name": "ohos.permission.MANAGE_WIFI_HOTSPOT",
"reason": "use ohos.permission.MANAGE_WIFI_HOTSPOT"
},
{
"name": "ohos.permission.GET_WIFI_INFO_INTERNAL",
"reason": "use ohos.permission.GET_WIFI_INFO_INTERNAL"
},
{
"name": "ohos.permission.LOCATION",
"reason": "need use ohos.permission.LOCATION",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.ACCESS_LOCATION",
"reason": "need use ohos.permission.ACCESS_LOCATION",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.LOCATION_IN_BACKGROUND",
"reason": "need use ohos.permission.LOCATION_IN_BACKGROUND",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.MANAGE_SECURE_SETTINGS",
"reason": "need use ohos.permission.MANAGE_SECURE_SETTINGS",
"usedScene": {
"ability": [
"ohos.acts.location.geolocation.function.MainAbility"
],
"when": "inuse"
}
},
{
"name": "ohos.permission.GRANT_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.GRANT_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.REVOKE_SENSITIVE_PERMISSIONS",
"reason": "use ohos.permission.REVOKE_SENSITIVE_PERMISSIONS"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO_PRIVILEGED"
},
{
"name": "ohos.permission.GET_BUNDLE_INFO"
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"srcPath": ""
}
}
\ 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 {
data: {
title: '',
myTimeout: 25000
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
},
onReady() {
console.info('onReady finish')
},
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('TestApplication onCreate')
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
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'] + '.TestAbility'
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.
* 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 {Core, ExpectExtend} from 'deccjsunit/index'
export default {
data: {
title: '',
myTimeout: 25000
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
const core = Core.getInstance()
const expectExtend = new ExpectExtend({
'id': 'extend'
})
core.addService('expect', expectExtend)
core.init()
const configService = core.getDefaultService('config')
this.timeout = this.myTimeout
configService.setConfig(this)
require('../../test/List.test')
core.execute()
},
onReady() {
console.info('onReady finish')
},
}
......@@ -14,6 +14,7 @@
*/
require('./WifiSta.test.js')
//require('./WifiSoftAP.test.js')
//require('./WifiP2P.test.js')
import ACTS_WifiTest from './WifiSta.test.js'
export default function testsuite() {
ACTS_WifiTest()
}
......@@ -13,7 +13,7 @@
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import wifi from '@ohos.wifi'
......@@ -61,6 +61,7 @@ let ConnState = {
UNKNOWN: 7,
}
export default function ACTS_WifiTest() {
describe('ACTS_WifiTest', function() {
beforeEach(function() {
......@@ -424,3 +425,4 @@ describe('ACTS_WifiTest', function() {
}
......@@ -7,6 +7,22 @@
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
},
{
"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,7 +9,7 @@
# 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.
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("containerLine_js_test") {
......@@ -31,7 +31,9 @@ ohos_js_hap_suite("containerLine_js_test") {
# subsystem_name = "xts"
}
ohos_js_assets("containerLine_js_assets") {
source_dir = "./src/main/js/default"
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("containerLine_resources") {
sources = [ "./src/main/resources" ]
......
{
"description": "Configuration for startup util js api Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "300000",
"package": "com.example.containerLine",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsContainerLineJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
{
"description": "Configuration for startup util js api Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "300000",
"shell-timeout": "300000",
"bundle-name": "com.example.containerLine",
"package-name": "com.example.containerLine"
},
"kits": [
{
"test-file-name": [
"ActsContainerLineJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.containerLine",
"vendor": "example",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "com.example.containerLine",
"name": ".MyApplication",
"mainAbility": "com.example.containerLine.MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"visible": true,
"name": "com.example.containerLine.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": true
}
}
]
}
{
"app": {
"bundleName": "com.example.containerLine",
"vendor": "example",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "com.example.containerLine",
"name": ".entry",
"srcPath": "",
"mainAbility": ".MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": true
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"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.
* 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('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
/*
* 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('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 40px;
color: #000000;
opacity: 0.9;
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
@media screen and (device-type: wearable) {
.title {
font-size: 28px;
color: #FFFFFF;
}
}
@media screen and (device-type: tv) {
.container {
background-image: url("../../common/images/Wallpaper.png");
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
.title {
font-size: 100px;
color: #FFFFFF;
}
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 40px;
color: #000000;
opacity: 0.9;
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
@media screen and (device-type: wearable) {
.title {
font-size: 28px;
color: #FFFFFF;
}
}
@media screen and (device-type: tv) {
.container {
background-image: url("../../common/images/Wallpaper.png");
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
.title {
font-size: 100px;
color: #FFFFFF;
}
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
<div class="container" onswipe="touchMove">
<text class="title">
{{ $t('strings.hello') }} {{title}}
</text>
<div class="container" onswipe="touchMove">
<text class="title">
{{ $t('strings.hello') }} {{title}}
</text>
</div>
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import file from '@system.file'
import app from '@system.app'
import device from '@system.device'
import router from '@system.router'
import {Core} from 'deccjsunit/index'
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
const core = Core.getInstance()
core.init()
require('../../../test/Main.test')
core.execute()
},
onReady() {
},
/*
* 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 file from '@system.file'
import app from '@system.app'
import device from '@system.device'
import router from '@system.router'
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
},
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.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/Main.test'
export default {
onCreate() {
console.info('TestApplication onCreate')
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
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
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
此差异已折叠。
此差异已折叠。
此差异已折叠。
文件模式从 100755 更改为 100644
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册