未验证 提交 d36c8fb0 编写于 作者: O openharmony_ci 提交者: Gitee

!4333 modified FA-JS PART6

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