mirror of
https://gitee.com/openharmony/xts_dcts
synced 2025-03-03 06:16:31 +00:00
<新增用例>
Signed-off-by: bWX1145125 <bianjianliang1@huawei.com>
This commit is contained in:
parent
935007d9ce
commit
0d78a8533d
@ -20,6 +20,7 @@ group("distributedhardware") {
|
||||
"distributedaudiotest:SubDctsdisAudioTest",
|
||||
"distributedcameratest:SubDctsdisCameraTest",
|
||||
"distributedscreentest:SubDctsdisScreenTest",
|
||||
"distributedscreenjstest:SubDctsdisScreenJsTest"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
# Copyright (C) 2021 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
|
||||
@ -11,25 +11,25 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//test/xts/tools/build/suite.gni")
|
||||
import("../../../tools/build/suite.gni")
|
||||
|
||||
ohos_js_hap_suite("SubDctsdisScreenJsTest") {
|
||||
hap_profile = "./src/main/config.json"
|
||||
deps = [
|
||||
":dh_js_assets",
|
||||
":dh_js_resources",
|
||||
":distributedjs_assets",
|
||||
":distributedjs_resources",
|
||||
]
|
||||
certificate_profile = "./signature/openharmony_sx.p7b"
|
||||
hap_name = "SubDctsdisScreenJsTest"
|
||||
subsystem_name = "distributedhardware"
|
||||
part_name = "distributed_screen"
|
||||
part_name = "device_manager"
|
||||
}
|
||||
ohos_js_assets("dh_js_assets") {
|
||||
ohos_js_assets("distributedjs_assets") {
|
||||
js2abc = true
|
||||
hap_profile = "./src/main/config.json"
|
||||
source_dir = "./src/main/js"
|
||||
}
|
||||
ohos_resources("dh_js_resources") {
|
||||
ohos_resources("distributedjs_resources") {
|
||||
sources = [ "./src/main/resources" ]
|
||||
hap_profile = "./src/main/config.json"
|
||||
}
|
||||
|
@ -1,13 +1,12 @@
|
||||
{
|
||||
"description": "Configuration for Screen Tests",
|
||||
"description": "Configuration for hjunit demo Tests",
|
||||
"driver": {
|
||||
"type": "OHJSUnitTest",
|
||||
"test-timeout": "180000",
|
||||
"shell-timeout": "180000",
|
||||
"bundle-name": "cpm.ohos.distributedscreenjstest",
|
||||
"bundle-name": "com.ohos.distributedscreenjstest",
|
||||
"package-name": "com.ohos.distributedscreenjstest",
|
||||
|
||||
"testcase-timeout": 10000
|
||||
"test-timeout": "1200000",
|
||||
"testcase-timeout": "600000",
|
||||
"shell-timeout": "1200000"
|
||||
},
|
||||
"kits": [
|
||||
{
|
||||
|
Binary file not shown.
@ -1,102 +1,107 @@
|
||||
{
|
||||
"app": {
|
||||
"bundleName": "com.ohos.distributedscreenjstest",
|
||||
"vendor": "ohos",
|
||||
"version": {
|
||||
"code": 1000000,
|
||||
"name": "1.0.0"
|
||||
},
|
||||
"apiVersion": {
|
||||
"compatible": 4,
|
||||
"target": 5,
|
||||
"releaseType": "Release"
|
||||
}
|
||||
},
|
||||
"deviceConfig": {},
|
||||
"module": {
|
||||
"reqPermissions": [
|
||||
{
|
||||
"name": "ohos.permission.DISTRIBUTED_DATASYNC"
|
||||
}
|
||||
],
|
||||
"package": "com.ohos.distributedscreenjstest",
|
||||
"name": ".entry",
|
||||
"mainAbility": ".MainAbility",
|
||||
"srcPath":"",
|
||||
"deviceType": [
|
||||
"phone",
|
||||
"tablet",
|
||||
"default"
|
||||
],
|
||||
"distro": {
|
||||
"deliveryWithInstall": true,
|
||||
"moduleName": "entry",
|
||||
"moduleType": "entry",
|
||||
"installationFree": false
|
||||
},
|
||||
"abilities": [
|
||||
{
|
||||
"skills": [
|
||||
{
|
||||
"entities": [
|
||||
"entity.system.home"
|
||||
],
|
||||
"actions": [
|
||||
"action.system.home"
|
||||
]
|
||||
}
|
||||
],
|
||||
"orientation": "unspecified",
|
||||
"formsEnabled": false,
|
||||
"name": ".MainAbility",
|
||||
"srcLanguage": "js",
|
||||
"srcPath": "MainAbility",
|
||||
"icon": "$media:icon",
|
||||
"description": "$string:MainAbility_desc",
|
||||
"label": "$string:MainAbility_label",
|
||||
"type": "page",
|
||||
"visible": true,
|
||||
"launchType": "standard"
|
||||
},
|
||||
{
|
||||
"orientation": "unspecified",
|
||||
"formsEnabled": false,
|
||||
"name": ".TestAbility",
|
||||
"srcLanguage": "js",
|
||||
"srcPath": "TestAbility",
|
||||
"icon": "$media:icon",
|
||||
"description": "$string:TestAbility_desc",
|
||||
"label": "$string:TestAbility_label",
|
||||
"type": "page",
|
||||
"visible": true,
|
||||
"launchType": "standard"
|
||||
}
|
||||
],
|
||||
"js": [
|
||||
{
|
||||
"pages": [
|
||||
"pages/index/index"
|
||||
],
|
||||
"name": "default",
|
||||
"window": {
|
||||
"designWidth": 720,
|
||||
"autoDesignWidth": false
|
||||
"app": {
|
||||
"bundleName": "com.ohos.distributedscreenjstest",
|
||||
"vendor": "example",
|
||||
"version": {
|
||||
"code": 1000000,
|
||||
"name": "1.0.0"
|
||||
},
|
||||
"apiVersion": {
|
||||
"compatible": 10,
|
||||
"target": 10
|
||||
}
|
||||
},
|
||||
{
|
||||
"pages": [
|
||||
"pages/index/index"
|
||||
},
|
||||
"deviceConfig": {},
|
||||
"module": {
|
||||
"reqPermissions": [
|
||||
{
|
||||
"name": "ohos.permission.DISTRIBUTED_DATASYNC"
|
||||
},
|
||||
{
|
||||
"name": "ohos.permission.ACCESS_SERVICE_DM"
|
||||
}
|
||||
],
|
||||
"name": ".TestAbility",
|
||||
"window": {
|
||||
"designWidth": 720,
|
||||
"autoDesignWidth": false
|
||||
"package": "com.ohos.distributedscreenjstest",
|
||||
"name": ".entry",
|
||||
"mainAbility": ".MainAbility",
|
||||
"srcPath": "",
|
||||
"deviceType": [
|
||||
"phone",
|
||||
"tablet",
|
||||
"tv",
|
||||
"wearable",
|
||||
"default",
|
||||
"2in1"
|
||||
],
|
||||
"distro": {
|
||||
"deliveryWithInstall": true,
|
||||
"moduleName": "entry",
|
||||
"moduleType": "entry",
|
||||
"installationFree": false
|
||||
},
|
||||
"abilities": [
|
||||
{
|
||||
"skills": [
|
||||
{
|
||||
"entities": [
|
||||
"entity.system.home"
|
||||
],
|
||||
"actions": [
|
||||
"action.system.home"
|
||||
]
|
||||
}
|
||||
],
|
||||
"orientation": "unspecified",
|
||||
"formsEnabled": false,
|
||||
"name": ".MainAbility",
|
||||
"srcLanguage": "js",
|
||||
"srcPath": "MainAbility",
|
||||
"icon": "$media:icon",
|
||||
"description": "$string:mainability_description",
|
||||
"label": "$string:app_name",
|
||||
"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": ".MainAbility",
|
||||
"window": {
|
||||
"designWidth": 720,
|
||||
"autoDesignWidth": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"pages": [
|
||||
"pages/index/index"
|
||||
],
|
||||
"name": ".TestAbility",
|
||||
"window": {
|
||||
"designWidth": 720,
|
||||
"autoDesignWidth": false
|
||||
}
|
||||
}
|
||||
],
|
||||
"testRunner": {
|
||||
"name": "OpenHarmonyTestRunner",
|
||||
"srcPath": "TestRunner"
|
||||
}
|
||||
}
|
||||
],
|
||||
"testRunner": {
|
||||
"name": "OpenHarmonyTestRunner",
|
||||
"srcPath": "TestRunner"
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
export default {
|
||||
onCreate() {
|
||||
console.info('AceApplication onCreate');
|
||||
|
@ -2,5 +2,7 @@
|
||||
"strings": {
|
||||
"hello": "Hello",
|
||||
"world": "World"
|
||||
},
|
||||
"Files": {
|
||||
}
|
||||
}
|
@ -2,5 +2,7 @@
|
||||
"strings": {
|
||||
"hello": "您好",
|
||||
"world": "世界"
|
||||
},
|
||||
"Files": {
|
||||
}
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
* Copyright (c) 2023 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.
|
||||
*/
|
||||
|
||||
.container {
|
||||
flex-direction: column;
|
||||
|
@ -12,10 +12,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
<div class="container">
|
||||
<text class="title">
|
||||
{{ $t('strings.hello') }} {{ title }}
|
||||
{{ $t('strings.hello') }} {{title}}
|
||||
</text>
|
||||
</div>
|
||||
|
||||
|
@ -1,29 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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.
|
||||
*/
|
||||
* Copyright (c) 2023 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');
|
||||
},
|
||||
onShow() {
|
||||
console.info('onShow finish')
|
||||
},
|
||||
onReady() {
|
||||
},
|
||||
}
|
||||
|
||||
data: {
|
||||
title: ''
|
||||
},
|
||||
onInit() {
|
||||
this.title = this.$t('strings.world');
|
||||
},
|
||||
onShow() {
|
||||
console.info('onShow finish')
|
||||
},
|
||||
onReady() {
|
||||
},
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -13,20 +13,19 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
|
||||
import { Hypium } from '@ohos/hypium'
|
||||
import testsuite from '../test/List.test'
|
||||
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)
|
||||
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");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -17,12 +17,6 @@
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.btn {
|
||||
width: 50%;
|
||||
height: 100px;
|
||||
font-size: 40px;
|
||||
}
|
||||
|
||||
@media screen and (device-type: phone) and (orientation: landscape) {
|
||||
.title {
|
||||
font-size: 60px;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023 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
|
||||
@ -15,9 +15,14 @@
|
||||
|
||||
export default {
|
||||
data: {
|
||||
title: "holle world"
|
||||
title: ''
|
||||
},
|
||||
onInit() {
|
||||
this.title = this.$t('strings.world');
|
||||
}
|
||||
}
|
||||
this.title = this.$t('strings.world');
|
||||
},
|
||||
onShow() {
|
||||
console.info('onShow finish')
|
||||
},
|
||||
onReady() {
|
||||
},
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022 Huawei Device Co., Ltd.
|
||||
* Copyright (c) 2023 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
|
||||
@ -20,14 +20,14 @@ function translateParamsToString(parameters) {
|
||||
'-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]
|
||||
targetParams += ' ' + key + ' ' + parameters[key];
|
||||
}
|
||||
}
|
||||
return targetParams.trim()
|
||||
return targetParams.trim();
|
||||
}
|
||||
|
||||
export default {
|
||||
@ -36,18 +36,18 @@ function translateParamsToString(parameters) {
|
||||
},
|
||||
onRun() {
|
||||
console.log('OpenHarmonyTestRunner onRun run');
|
||||
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
|
||||
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
|
||||
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments();
|
||||
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator();
|
||||
|
||||
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility'
|
||||
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"]
|
||||
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'
|
||||
cmd += ' -D';
|
||||
}
|
||||
console.info('cmd : '+cmd);
|
||||
abilityDelegator.executeShellCommand(cmd, (err, data) => {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021 Huawei Device Co., Ltd.
|
||||
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
@ -12,9 +12,8 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import distributedScreen from './distributedscreenDevice.test.js'
|
||||
|
||||
import distributedDevice from './distributedscreenDevice.test.js'
|
||||
|
||||
export default function testsuite() {
|
||||
distributedScreen()
|
||||
}
|
||||
distributedDevice();
|
||||
}
|
||||
|
@ -1,441 +1,341 @@
|
||||
/*
|
||||
* 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
|
||||
import deviceManager from '@ohos.distributedDeviceManager';
|
||||
|
||||
export default function distributedScreen() {
|
||||
|
||||
describe('distributedScreen', function () {
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
beforeAll(async function (done) {
|
||||
console.info("beforeAll done");
|
||||
done();
|
||||
})
|
||||
|
||||
beforeEach(async function (done) {
|
||||
console.info(('beforeEach called'));
|
||||
done();
|
||||
})
|
||||
|
||||
afterEach(async function (done) {
|
||||
console.info('afterEach called');
|
||||
setTimeout(done, 4000);
|
||||
})
|
||||
|
||||
afterAll(async function (done) {
|
||||
console.info('afterAll called');
|
||||
done();
|
||||
})
|
||||
|
||||
let dmInstance = nullptr;
|
||||
let dmNetworkId = nullptr;
|
||||
let dmDeviceInfo = nullptr;
|
||||
/*
|
||||
* @tc.number SUB_DH_createDeviceManager_0001
|
||||
* @tc.name To manage devices, you must first call this method to obtain a {@code DeviceManager} instance and then
|
||||
* use this instance to call other device management methods.
|
||||
* @tc.desc Function test
|
||||
* @tc.level 0
|
||||
*/
|
||||
it("SUB_DH_createDeviceManager_0001", 0, async function (done) {
|
||||
console.info("-----------------SUB_DH_createDeviceManager_0001 start------------------------");
|
||||
try {
|
||||
dmInstance = deviceManager.createDeviceManager("com.ohos.distributedscreenjstest");
|
||||
if (err) {
|
||||
console.error("createDeviceManager errCode:" + err.code + ",errMessage:" + err.message);
|
||||
}
|
||||
console.info("createDeviceManager success");
|
||||
dmInstance.on('replyResult', (data) => console.log("replyResult on:" + JSON.stringify(data)));
|
||||
dmInstance.on('discoverSuccess', (data) => console.log("discoverSuccess on:" + JSON.stringify(data)));
|
||||
dmInstance.on('discoverFail', (data) => console.log("discoverFail on:" + JSON.stringify(data)));
|
||||
dmInstance.on('serviceDie', (data) => console.log("serviceDie on:" + JSON.stringify(data)));
|
||||
dmInstance.on('deviceNameChange', (data) => console.log("deviceNameChange on:" + JSON.stringify(data)));
|
||||
dmInstance.on('deviceStateChange', (data) => console.log("deviceStateChange on:" + JSON.stringify(data)));
|
||||
expect(dmInstance != NUll).assertTrue();
|
||||
done();
|
||||
} catch(err) {
|
||||
console.error("createDeviceManager errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect().assertFail();
|
||||
done();
|
||||
}
|
||||
await sleep(1000);
|
||||
console.info("-----------------SUB_DH_createDeviceManager_0001 end------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number SUB_DH_startDiscovering_0002
|
||||
* @tc.name Start to discover nearby devices.
|
||||
* @tc.desc Function test
|
||||
* @tc.level 0
|
||||
*/
|
||||
it("SUB_DH_startDiscovering_0002", 0, async function (done) {
|
||||
console.info("-----------------SUB_DH_startDiscovering_0002 start------------------------");
|
||||
var discoverParam = {
|
||||
"discoverTargetType":1
|
||||
};
|
||||
try {
|
||||
dmInstance.startDiscovering(discoverParam);
|
||||
console.log("startDiscovering success");
|
||||
expect().assertTrue();
|
||||
done();
|
||||
} catch(err) {
|
||||
console.error("startDiscovering errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect().assertFail();
|
||||
done();
|
||||
}
|
||||
await sleep(1000);
|
||||
console.info("-----------------SUB_DH_startDiscovering_0002 end------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number SUB_DH_getLocalDeviceNetworkId_0003
|
||||
* @tc.name Get the network id of the local device
|
||||
* @tc.desc Function test
|
||||
* @tc.level 0
|
||||
*/
|
||||
it("SUB_DH_getLocalDeviceNetworkId_0003", 0, async function (done) {
|
||||
console.info("-----------------SUB_DH_getLocalDeviceNetworkId_0003 start------------------------");
|
||||
try {
|
||||
dmNetworkId = dmInstance.getLocalDeviceNetworkId();
|
||||
if (dmNetworkId === nullptr) {
|
||||
console.error("getLocalDeviceNetworkId fail");
|
||||
}
|
||||
console.log("getLocalDeviceNetworkId dmNetworkId:" + dmNetworkId);
|
||||
expect(dmNetworkId != nullptr).assertTrue();
|
||||
done();
|
||||
} catch(err) {
|
||||
console.error("getLocalDeviceNetworkId errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect().assertFail();
|
||||
done();
|
||||
}
|
||||
await sleep(1000);
|
||||
console.info("-----------------SUB_DH_getLocalDeviceNetworkId_0003 end------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number SUB_DH_getAvailableDeviceListSync_0004
|
||||
* @tc.name Get a list of available devices. This interface query all authorized and connectable devices.
|
||||
* @tc.desc Function test
|
||||
* @tc.level 0
|
||||
*/
|
||||
it("SUB_DH_getAvailableDeviceListSync_0004", 0, async function (done) {
|
||||
console.info("-----------------SUB_DH_getAvailableDeviceListSync_0004 start------------------------");
|
||||
try {
|
||||
dmDeviceInfo = dmInstance.getAvailableDeviceListSync();
|
||||
if (dmDeviceInfo === nullptr) {
|
||||
console.log('getAvailableDeviceListSync info fail');
|
||||
}
|
||||
console.log('getAvailableDeviceListSync info:' + dmDeviceInfo);
|
||||
expect(dmDeviceInfo != nullptr).assertTrue();
|
||||
done();
|
||||
} catch (err) {
|
||||
console.error("getAvailableDeviceListSync errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect().assertFail();
|
||||
done();
|
||||
}
|
||||
await sleep(1000);
|
||||
console.info("-----------------SUB_DH_getAvailableDeviceListSync_0004 end------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number SUB_DH_getAvailableDeviceList_0005
|
||||
* @tc.name Get a list of available devices. This interface query all authorized and connectable devices.
|
||||
* @tc.desc Function test
|
||||
* @tc.level 0
|
||||
*/
|
||||
it("SUB_DH_getAvailableDeviceList_0005", 0, async function (done) {
|
||||
console.info("-----------------SUB_DH_getAvailableDeviceList_0005 start------------------------");
|
||||
try {
|
||||
dmInstance.getAvailableDeviceList((err, data) => {
|
||||
if (err) {
|
||||
console.error("getAvailableDeviceList errCode:" + err.code + ",errMessage:" + err.message);
|
||||
}
|
||||
console.log('getAvailableDeviceList info: ' + JSON.stringify(data));
|
||||
expect(data != nullptr).assertTrue();
|
||||
done();
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("getAvailableDeviceList errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect().assertFail();
|
||||
done();
|
||||
}
|
||||
await sleep(1000);
|
||||
console.info("-----------------SUB_DH_getAvailableDeviceList_0005 end------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number SUB_DH_getAvailableDeviceList_0006
|
||||
* @tc.name Get a list of available devices. This interface query all authorized and connectable devices.
|
||||
* @tc.desc Function test
|
||||
* @tc.level 0
|
||||
*/
|
||||
it("SUB_DH_getAvailableDeviceList_0006", 0, async function (done) {
|
||||
console.info("-----------------SUB_DH_getAvailableDeviceList_0006 start------------------------");
|
||||
dmInstance.getAvailableDeviceList().then((data) => {
|
||||
console.log('getAvailableDeviceList info: ' + JSON.stringify(data));
|
||||
expect(data != nullptr).assertTrue();
|
||||
done();
|
||||
}).catch((err) => {
|
||||
console.error("getAvailableDeviceList errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect().assertFail();
|
||||
done();
|
||||
})
|
||||
await sleep(1000);
|
||||
console.info("-----------------SUB_DH_getAvailableDeviceList_0006 end------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number SUB_DH_bindTarget_0007
|
||||
* @tc.name Get the device name of the local device.
|
||||
* @tc.desc Function test
|
||||
* @tc.level 0
|
||||
*/
|
||||
it("SUB_DH_bindTarget_0007", 0, async function (done) {
|
||||
console.info("-----------------SUB_DH_bindTarget_0007 start------------------------");
|
||||
let bindParam = {
|
||||
"bindType" : 1,
|
||||
"targetPkgName" : "com.ohos.distributedDeviceManager.screen",
|
||||
"appName" : "SubDctsdisScreenJsTest",
|
||||
"appOperation": "想要连接本机。",
|
||||
"customDescription": "device manager device manager device manager device manager device manager device manager device manager device manager"
|
||||
};
|
||||
try {
|
||||
dmInstance.bindTarget(dmDeviceInfo.deviceId, JSON.stringify(bindParam), (err, data) => {
|
||||
if (err) {
|
||||
console.info("bindTarget fail errCode:" + err.code + ",errMessage:" + err.message);
|
||||
}
|
||||
console.log("bindTarget:" + JSON.stringify(data));
|
||||
expect(data != nullptr).assertTrue();
|
||||
done();
|
||||
})
|
||||
} catch (err) {
|
||||
console.info("bindTarget errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect().assertFail();
|
||||
done();
|
||||
}
|
||||
await sleep(1000);
|
||||
console.info("-----------------SUB_DH_bindTarget_0007 end------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number SUB_DH_getLocalDeviceName_0008
|
||||
* @tc.name Get the device name of the local device.
|
||||
* @tc.desc Function test
|
||||
* @tc.level 0
|
||||
*/
|
||||
it("SUB_DH_getLocalDeviceName_0008", 0, async function (done) {
|
||||
console.info("-----------------SUB_DH_getLocalDeviceName_0008 start------------------------");
|
||||
try {
|
||||
let lDeviceName = dmInstance.getLocalDeviceName();
|
||||
if (lDeviceName === nullptr) {
|
||||
console.log("getLocalDeviceName fail");
|
||||
}
|
||||
console.log("Get Local Device Name:" + lDeviceName);
|
||||
expect(lDeviceName != nullptr).assertTrue();
|
||||
done();
|
||||
} catch (err) {
|
||||
console.info("getLocalDeviceName errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect().assertFail();
|
||||
done();
|
||||
}
|
||||
await sleep(1000);
|
||||
console.info("-----------------SUB_DH_getLocalDeviceName_0008 end------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number SUB_DH_getLocalDeviceType_0009
|
||||
* @tc.name Get the device type of the local device
|
||||
* @tc.desc Function test
|
||||
* @tc.level 0
|
||||
*/
|
||||
it("SUB_DH_getLocalDeviceType_0009", 0, async function (done) {
|
||||
console.info("-----------------SUB_DH_getLocalDeviceType_0009 start------------------------");
|
||||
try {
|
||||
let lDeviceType = dmInstance.getLocalDeviceType();
|
||||
if (lDeviceType === nullptr) {
|
||||
console.log("getLocalDeviceType fail");
|
||||
}
|
||||
console.log("get Local Device Type:" + lDeviceType);
|
||||
expect(lDeviceType != nullptr).assertTrue();
|
||||
done();
|
||||
} catch (err) {
|
||||
console.info("getLocalDeviceType errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect().assertFail();
|
||||
done();
|
||||
}
|
||||
await sleep(1000);
|
||||
console.info("-----------------SUB_DH_getLocalDeviceType_0009 end------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number SUB_DH_getLocalDeviceId_0010
|
||||
* @tc.name Get the device id of the local device
|
||||
* @tc.desc Function test
|
||||
* @tc.level 0
|
||||
*/
|
||||
it("SUB_DH_getLocalDeviceId_0010", 0, async function (done) {
|
||||
console.info("-----------------SUB_DH_getLocalDeviceId_0010 start------------------------");
|
||||
try {
|
||||
let lDeviceId = dmInstance.getLocalDeviceId();
|
||||
if (lDeviceId === nullptr) {
|
||||
console.log("getLocalDeviceId fail");
|
||||
}
|
||||
console.log("get Local Device Id:" + lDeviceId);
|
||||
expect(lDeviceId != nullptr).assertTrue();
|
||||
done();
|
||||
} catch (err) {
|
||||
console.info("getLocalDeviceId errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect().assertFail();
|
||||
done();
|
||||
}
|
||||
await sleep(1000);
|
||||
console.info("-----------------SUB_DH_getLocalDeviceId_0010 end------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number SUB_DH_getDeviceName_0011
|
||||
* @tc.name Get the device name by network id.
|
||||
* @tc.desc Function test
|
||||
* @tc.level 0
|
||||
*/
|
||||
it("SUB_DH_getDeviceName_0011", 0, async function (done) {
|
||||
console.info("-----------------SUB_DH_getDeviceName_0011 start------------------------");
|
||||
try {
|
||||
let deviceName = dmInstance.getDeviceName(dmNetworkId);
|
||||
if (deviceName === nullptr) {
|
||||
console.log("getDeviceName fail");
|
||||
}
|
||||
console.log("get Device Name:" + deviceName);
|
||||
expect(deviceName != nullptr).assertTrue();
|
||||
done();
|
||||
} catch (err) {
|
||||
console.info("getDeviceName errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect().assertFail();
|
||||
done();
|
||||
}
|
||||
await sleep(1000);
|
||||
console.info("-----------------SUB_DH_getDeviceName_0011 end------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number SUB_DH_getDeviceType_0012
|
||||
* @tc.name Get the device type by network id.
|
||||
* @tc.desc Function test
|
||||
* @tc.level 0
|
||||
*/
|
||||
it("SUB_DH_getDeviceType_0012", 0, async function (done) {
|
||||
console.info("-----------------SUB_DH_getDeviceType_0012 start------------------------");
|
||||
try {
|
||||
let deviceType = dmInstance.getDeviceType(dmNetworkId);
|
||||
if (deviceType === nullptr) {
|
||||
console.log("getDeviceType fail");
|
||||
}
|
||||
console.log("get Device Type:" + deviceType);
|
||||
expect(deviceType != nullptr).assertTrue();
|
||||
done();
|
||||
} catch (err) {
|
||||
console.info("getDeviceType errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect().assertFail();
|
||||
done();
|
||||
}
|
||||
await sleep(1000);
|
||||
console.info("-----------------SUB_DH_getDeviceType_0012 end------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number SUB_DH_unbindTarget_0013
|
||||
* @tc.name Unbind the specified target.
|
||||
* @tc.desc Function test
|
||||
* @tc.level 0
|
||||
*/
|
||||
it("SUB_DH_unbindTarget_0013", 0, async function (done) {
|
||||
console.info("-----------------SUB_DH_unbindTarget_0013 start------------------------");
|
||||
try {
|
||||
dmInstance.unbindTarget(dmDeviceInfo.deviceId);
|
||||
console.log("unbindTarget success");
|
||||
expect().assertTrue();
|
||||
done();
|
||||
} catch (err) {
|
||||
console.info("unbindTarget errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect().assertFail();
|
||||
done();
|
||||
}
|
||||
await sleep(1000);
|
||||
console.info("-----------------SUB_DH_unbindTarget_0013 end------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number SUB_DH_stopDiscovering_0014
|
||||
* @tc.name Stop discovering nearby devices.
|
||||
* @tc.desc Function test
|
||||
* @tc.level 0
|
||||
*/
|
||||
it("SUB_DH_stopDiscovering_0014", 0, async function (done) {
|
||||
console.info("-----------------SUB_DH_stopDiscovering_0014 start------------------------");
|
||||
try {
|
||||
dmInstance.stopDiscovering();
|
||||
console.log("stopDiscovering success");
|
||||
expect().assertTrue();
|
||||
done();
|
||||
} catch (err) {
|
||||
console.info("stopDiscovering errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect().assertFail();
|
||||
done();
|
||||
}
|
||||
await sleep(1000);
|
||||
console.info("-----------------SUB_DH_stopDiscovering_0014 end------------------------");
|
||||
});
|
||||
|
||||
/*
|
||||
* @tc.number SUB_DH_releaseDeviceManager_0015
|
||||
* @tc.name Releases the {@code DeviceManager} instance that is no longer used.
|
||||
* @tc.desc Function test
|
||||
* @tc.level 0
|
||||
*/
|
||||
it("SUB_DH_releaseDeviceManager_0015", 0, async function (done) {
|
||||
console.info("-----------------SUB_DH_releaseDeviceManager_0015 start------------------------");
|
||||
var mFilterOption = {
|
||||
targetPkgName: "com.ohos.devicemanagerui",
|
||||
sortType: 0,
|
||||
filter: JSON.stringify({
|
||||
key: 'test',
|
||||
value: 0
|
||||
})
|
||||
}
|
||||
try {
|
||||
dmInstance.off('dmFaCallback');
|
||||
dmInstance.off('discoverSuccess');
|
||||
dmInstance.off('discoverFail');
|
||||
dmInstance.off('serviceDie');
|
||||
dmInstance.off('deviceStateChange', JSON.stringify(mFilterOption), console.log("deviceStatusChange off:" + JSON.stringify(dmDeviceInfo)));
|
||||
deviceManager.releaseDeviceManager(dmInstance);
|
||||
console.log("releaseDeviceManager success");
|
||||
expect().assertTrue();
|
||||
done();
|
||||
} catch (err) {
|
||||
console.info("releaseDeviceManager errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect().assertFail();
|
||||
done();
|
||||
}
|
||||
await sleep(1000);
|
||||
console.info("-----------------SUB_DH_releaseDeviceManager_0015 end------------------------");
|
||||
});
|
||||
})
|
||||
/*
|
||||
* 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium';
|
||||
import deviceManager from '@ohos.distributedDeviceManager';
|
||||
import featureAbility from "@ohos.ability.featureAbility";
|
||||
import { UiDriver, BY } from '@ohos.UiTest';
|
||||
|
||||
export default function distributedDeviceManager() {
|
||||
|
||||
describe('distributedDeviceManager', function () {
|
||||
function sleep(ms) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
async function getPermission() {
|
||||
console.info(`getPermission is start`);
|
||||
let permissions = ['ohos.permission.DISTRIBUTED_DATASYNC'];
|
||||
let context = featureAbility.getContext();
|
||||
context.requestPermissionsFromUser(permissions, 666, (data) => {
|
||||
console.info("request success" + JSON.stringify(data));
|
||||
})
|
||||
}
|
||||
|
||||
async function driveFn() {
|
||||
try {
|
||||
let driver = await UiDriver.create();
|
||||
console.info(`come in driveFn`);
|
||||
console.info(`driver is ${JSON.stringify(driver)}`);
|
||||
sleep(2000);
|
||||
let button = await driver.findComponent(BY.text('允许'));
|
||||
console.info(`button is ${JSON.stringify(button)}`);
|
||||
sleep(5000);
|
||||
await button.click();
|
||||
} catch (err) {
|
||||
console.info('err is ' + err);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
beforeAll(async function (done) {
|
||||
console.info("beforeAll start");
|
||||
await getPermission();
|
||||
sleep(5000);
|
||||
await driveFn();
|
||||
sleep(5000);
|
||||
console.info("beforeAll done");
|
||||
done();
|
||||
})
|
||||
|
||||
beforeEach(async function (done) {
|
||||
console.info(('beforeEach called'));
|
||||
done();
|
||||
})
|
||||
|
||||
afterEach(async function (done) {
|
||||
console.info('afterEach called');
|
||||
setTimeout(done, 4000);
|
||||
})
|
||||
|
||||
afterAll(async function (done) {
|
||||
console.info('afterAll called');
|
||||
done();
|
||||
})
|
||||
|
||||
let dmInstance = null;
|
||||
let dmNetworkId = null;
|
||||
let dmDeviceInfo = null;
|
||||
let deviceId = null;
|
||||
/*
|
||||
* @tc.number SUB_DH_createDeviceManager_0001
|
||||
* @tc.name To manage devices, you must first call this method to obtain a {@code DeviceManager} instance and then
|
||||
* use this instance to call other device management methods.
|
||||
* @tc.desc Function test
|
||||
* @tc.level 0
|
||||
*/
|
||||
it("SUB_DH_createDeviceManager_0001", 0, async function (done) {
|
||||
console.info("-----------------SUB_DH_createDeviceManager_0001 start------------------------");
|
||||
try {
|
||||
dmInstance = deviceManager.createDeviceManager("com.ohos.distributedscreenjstest");
|
||||
if (!dmInstance) {
|
||||
console.error("createDeviceManager errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect(false).assertFail();
|
||||
done();
|
||||
}
|
||||
console.info("createDeviceManager success");
|
||||
dmInstance.on('replyResult', (data) => console.log("replyResult on:" + JSON.stringify(data)));
|
||||
dmInstance.on('discoverSuccess', (data) => console.log("discoverSuccess on:" + JSON.stringify(data)));
|
||||
dmInstance.on('discoverFail', (data) => console.log("discoverFail on:" + JSON.stringify(data)));
|
||||
dmInstance.on('serviceDie', (data) => console.log("serviceDie on:" + JSON.stringify(data)));
|
||||
dmInstance.on('deviceNameChange', (data) => console.log("deviceNameChange on:" + JSON.stringify(data)));
|
||||
dmInstance.on('deviceStateChange', (data) => console.log("deviceStateChange on:" + JSON.stringify(data)));
|
||||
expect(dmInstance !== null).assertTrue();
|
||||
done();
|
||||
} catch(err) {
|
||||
console.error("createDeviceManager errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect(false).assertFail();
|
||||
done();
|
||||
}
|
||||
await sleep(1000);
|
||||
console.info("-----------------SUB_DH_createDeviceManager_0001 end------------------------");
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number SUB_DH_getLocalDeviceNetworkId_0003
|
||||
* @tc.name Get the network id of the local device
|
||||
* @tc.desc Function test
|
||||
* @tc.level 0
|
||||
*/
|
||||
it("SUB_DH_getLocalDeviceNetworkId_0003", 0, async function (done) {
|
||||
console.info("-----------------SUB_DH_getLocalDeviceNetworkId_0003 start------------------------");
|
||||
try {
|
||||
dmNetworkId = dmInstance.getLocalDeviceNetworkId();
|
||||
if (dmNetworkId === null) {
|
||||
console.error("getLocalDeviceNetworkId fail");
|
||||
}
|
||||
console.log("getLocalDeviceNetworkId dmNetworkId:" + dmNetworkId);
|
||||
expect(dmNetworkId !== null).assertTrue();
|
||||
done();
|
||||
} catch(err) {
|
||||
console.error("getLocalDeviceNetworkId errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect(false).assertFail();
|
||||
done();
|
||||
}
|
||||
await sleep(1000);
|
||||
console.info("-----------------SUB_DH_getLocalDeviceNetworkId_0003 end------------------------");
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number SUB_DH_getAvailableDeviceListSync_0004
|
||||
* @tc.name Get a list of available devices. This interface query all authorized and connectable devices.
|
||||
* @tc.desc Function test
|
||||
* @tc.level 0
|
||||
*/
|
||||
it("SUB_DH_getAvailableDeviceListSync_0004", 0, async function (done) {
|
||||
console.info("-----------------SUB_DH_getAvailableDeviceListSync_0004 start------------------------");
|
||||
try {
|
||||
dmDeviceInfo = dmInstance.getAvailableDeviceListSync();
|
||||
if (dmDeviceInfo === null) {
|
||||
console.log('getAvailableDeviceListSync info fail');
|
||||
}
|
||||
console.log('getAvailableDeviceListSync info:' + dmDeviceInfo);
|
||||
console.log('getAvailableDeviceListSync info:' + JSON.stringify(dmDeviceInfo[0]["deviceId"]));
|
||||
deviceId = JSON.stringify(dmDeviceInfo[0]["deviceId"]);
|
||||
console.log('getAvailableDeviceListSync info:' + deviceId);
|
||||
expect(dmDeviceInfo !== null).assertTrue();
|
||||
done();
|
||||
} catch (err) {
|
||||
console.error("getAvailableDeviceListSync errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect(false).assertFail();
|
||||
done();
|
||||
}
|
||||
await sleep(1000);
|
||||
console.info("-----------------SUB_DH_getAvailableDeviceListSync_0004 end------------------------");
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number SUB_DH_getAvailableDeviceList_0005
|
||||
* @tc.name Get a list of available devices. This interface query all authorized and connectable devices.
|
||||
* @tc.desc Function test
|
||||
* @tc.level 0
|
||||
*/
|
||||
it("SUB_DH_getAvailableDeviceList_0005", 0, async function (done) {
|
||||
console.info("-----------------SUB_DH_getAvailableDeviceList_0005 start------------------------");
|
||||
try {
|
||||
dmInstance.getAvailableDeviceList((err, data) => {
|
||||
if (err) {
|
||||
console.error("getAvailableDeviceList errCode:" + err.code + ",errMessage:" + err.message);
|
||||
}
|
||||
console.log('getAvailableDeviceList info: ' + JSON.stringify(data));
|
||||
expect(data !== null).assertTrue();
|
||||
done();
|
||||
});
|
||||
} catch (err) {
|
||||
console.error("getAvailableDeviceList errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect(false).assertFail();
|
||||
done();
|
||||
}
|
||||
await sleep(1000);
|
||||
console.info("-----------------SUB_DH_getAvailableDeviceList_0005 end------------------------");
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number SUB_DH_getAvailableDeviceList_0006
|
||||
* @tc.name Get a list of available devices. This interface query all authorized and connectable devices.
|
||||
* @tc.desc Function test
|
||||
* @tc.level 0
|
||||
*/
|
||||
it("SUB_DH_getAvailableDeviceList_0006", 0, async function (done) {
|
||||
console.info("-----------------SUB_DH_getAvailableDeviceList_0006 start------------------------");
|
||||
dmInstance.getAvailableDeviceList().then((data) => {
|
||||
console.log('getAvailableDeviceList info: ' + JSON.stringify(data));
|
||||
expect(data !== null).assertTrue();
|
||||
done();
|
||||
}).catch((err) => {
|
||||
console.error("getAvailableDeviceList errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect(false).assertFail();
|
||||
done();
|
||||
})
|
||||
await sleep(1000);
|
||||
console.info("-----------------SUB_DH_getAvailableDeviceList_0006 end------------------------");
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number SUB_DH_getLocalDeviceName_0008
|
||||
* @tc.name Get the device name of the local device.
|
||||
* @tc.desc Function test
|
||||
* @tc.level 0
|
||||
*/
|
||||
it("SUB_DH_getLocalDeviceName_0008", 0, async function (done) {
|
||||
console.info("-----------------SUB_DH_getLocalDeviceName_0008 start------------------------");
|
||||
try {
|
||||
let lDeviceName = dmInstance.getLocalDeviceName();
|
||||
if (lDeviceName === null) {
|
||||
console.log("getLocalDeviceName fail");
|
||||
}
|
||||
console.log("Get Local Device Name:" + lDeviceName);
|
||||
expect(lDeviceName !== null).assertTrue();
|
||||
done();
|
||||
} catch (err) {
|
||||
console.info("getLocalDeviceName errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect(false).assertFail();
|
||||
done();
|
||||
}
|
||||
await sleep(1000);
|
||||
console.info("-----------------SUB_DH_getLocalDeviceName_0008 end------------------------");
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number SUB_DH_getLocalDeviceType_0009
|
||||
* @tc.name Get the device type of the local device
|
||||
* @tc.desc Function test
|
||||
* @tc.level 0
|
||||
*/
|
||||
it("SUB_DH_getLocalDeviceType_0009", 0, async function (done) {
|
||||
console.info("-----------------SUB_DH_getLocalDeviceType_0009 start------------------------");
|
||||
try {
|
||||
let lDeviceType = dmInstance.getLocalDeviceType();
|
||||
if (lDeviceType === null) {
|
||||
console.log("getLocalDeviceType fail");
|
||||
}
|
||||
console.log("get Local Device Type:" + lDeviceType);
|
||||
expect(lDeviceType !== null).assertTrue();
|
||||
done();
|
||||
} catch (err) {
|
||||
console.info("getLocalDeviceType errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect(false).assertFail();
|
||||
done();
|
||||
}
|
||||
await sleep(1000);
|
||||
console.info("-----------------SUB_DH_getLocalDeviceType_0009 end------------------------");
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number SUB_DH_getLocalDeviceId_0010
|
||||
* @tc.name Get the device id of the local device
|
||||
* @tc.desc Function test
|
||||
* @tc.level 0
|
||||
*/
|
||||
it("SUB_DH_getLocalDeviceId_0010", 0, async function (done) {
|
||||
console.info("-----------------SUB_DH_getLocalDeviceId_0010 start------------------------");
|
||||
try {
|
||||
let lDeviceId = dmInstance.getLocalDeviceId();
|
||||
if (lDeviceId === null) {
|
||||
console.log("getLocalDeviceId fail");
|
||||
}
|
||||
console.log("get Local Device Id:" + lDeviceId);
|
||||
expect(lDeviceId !== null).assertTrue();
|
||||
done();
|
||||
} catch (err) {
|
||||
console.info("getLocalDeviceId errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect(false).assertFail();
|
||||
done();
|
||||
}
|
||||
await sleep(1000);
|
||||
console.info("-----------------SUB_DH_getLocalDeviceId_0010 end------------------------");
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number SUB_DH_getDeviceName_0011
|
||||
* @tc.name Get the device name by network id.
|
||||
* @tc.desc Function test
|
||||
* @tc.level 0
|
||||
*/
|
||||
it("SUB_DH_getDeviceName_0011", 0, async function (done) {
|
||||
console.info("-----------------SUB_DH_getDeviceName_0011 start------------------------");
|
||||
try {
|
||||
let deviceName = dmInstance.getDeviceName(dmNetworkId);
|
||||
if (deviceName === null) {
|
||||
console.log("getDeviceName fail");
|
||||
}
|
||||
console.log("get Device Name:" + deviceName);
|
||||
expect(deviceName !== null).assertTrue();
|
||||
done();
|
||||
} catch (err) {
|
||||
console.info("getDeviceName errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect(false).assertFail();
|
||||
done();
|
||||
}
|
||||
await sleep(1000);
|
||||
console.info("-----------------SUB_DH_getDeviceName_0011 end------------------------");
|
||||
})
|
||||
|
||||
/*
|
||||
* @tc.number SUB_DH_getDeviceType_0012
|
||||
* @tc.name Get the device type by network id.
|
||||
* @tc.desc Function test
|
||||
* @tc.level 0
|
||||
*/
|
||||
it("SUB_DH_getDeviceType_0012", 0, async function (done) {
|
||||
console.info("-----------------SUB_DH_getDeviceType_0012 start------------------------");
|
||||
try {
|
||||
let deviceType = dmInstance.getDeviceType(dmNetworkId);
|
||||
if (deviceType === null) {
|
||||
console.log("getDeviceType fail");
|
||||
}
|
||||
console.log("get Device Type:" + deviceType);
|
||||
expect(deviceType !== null).assertTrue();
|
||||
done();
|
||||
} catch (err) {
|
||||
console.info("getDeviceType errCode:" + err.code + ",errMessage:" + err.message);
|
||||
expect(false).assertFail();
|
||||
done();
|
||||
}
|
||||
await sleep(1000);
|
||||
console.info("-----------------SUB_DH_getDeviceType_0012 end------------------------");
|
||||
})
|
||||
})
|
||||
}
|
@ -2,15 +2,15 @@
|
||||
"string": [
|
||||
{
|
||||
"name": "app_name",
|
||||
"value": "SubDctsdisScreenJsTest"
|
||||
"value": "distributedscreenjstest"
|
||||
},
|
||||
{
|
||||
"name": "mainability_description",
|
||||
"value": "JS_Phone_Empty DH"
|
||||
"value": "JS_Phone_Empty device"
|
||||
},
|
||||
{
|
||||
"name": "MainAbility_desc",
|
||||
"value": "description"
|
||||
"name": "MainAbility_desc",
|
||||
"value": "distributedscreenjstest"
|
||||
},
|
||||
{
|
||||
"name": "MainAbility_label",
|
||||
@ -25,4 +25,4 @@
|
||||
"value": "label"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user