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

!4419 Adapt to the new framework_part19

Merge pull request !4419 from jiyong/local-20220720
......@@ -9,7 +9,7 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import("//build/ohos_var.gni")
......
......@@ -9,7 +9,7 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import("//build/ohos_var.gni")
......
......@@ -9,12 +9,12 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("continuationmanager_js_test") {
hap_profile = "./entry/src/main/config.json"
hap_profile = "./src/main/config.json"
deps = [
":continuationmanager_js_assets",
":continuationmanager_resources",
......@@ -23,9 +23,11 @@ ohos_js_hap_suite("continuationmanager_js_test") {
hap_name = "ActsContinuationManagerJsTest"
}
ohos_js_assets("continuationmanager_js_assets") {
source_dir = "./entry/src/main/js/default"
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("continuationmanager_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "1200000",
"package": "ohos.acts.distributedschedule.continuationmanager",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsContinuationManagerJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"description": "Configuration for hjunit demo Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "1200000",
"shell-timeout": "1200000",
"bundle-name": "ohos.acts.distributedschedule.continuationmanager",
"package-name": "ohos.acts.distributedschedule.continuationmanager"
},
"kits": [
{
"test-file-name": [
"ActsContinuationManagerJsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "ohos.acts.distributedschedule.continuationmanager",
"vendor": "example",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.distributedschedule.continuationmanager",
"name": ".MyApplication",
"mainAbility": "ohos.acts.distributedschedule.continuationmanager.MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "ohos.acts.distributedschedule.continuationmanager.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": true
}
}
]
}
}
\ No newline at end of file
{
"app": {
"bundleName": "ohos.acts.distributedschedule.continuationmanager",
"vendor": "example",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.distributedschedule.continuationmanager",
"name": ".entry",
"mainAbility": ".MainAbility",
"deviceType": [
"phone"
],
"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": true
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"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 {
onCreate() {
console.info('TestApplication onCreate');
},
onDestroy() {
console.info('TestApplication onDestroy');
}
};
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
onCreate() {
console.info('TestApplication onCreate');
},
onDestroy() {
console.info('TestApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ 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.
*/
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
/*
* 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.
*/
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
/*
* 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.
*/
<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.
*/
<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.
*/
import {Core} from 'deccjsunit/index'
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: ''
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
const core = Core.getInstance()
core.init()
require('../../test/List.test')
core.execute()
},
onReady() {
},
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const injectRef = Object.getPrototypeOf(global) || global
injectRef.regeneratorRuntime = require('@babel/runtime/regenerator')
export default {
data: {
title: ''
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
},
onReady() {
},
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/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": {
}
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
{
"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>
<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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
import continuationManager from '@ohos.continuation.continuationManager';
const TEST_DEVICE_ID = "test_deviceId";
const TEST_CONNECT_STATUS = continuationManager.DeviceConnectState.CONNECTED;
let token = -1;
describe('ContinuationManagerTest', function() {
beforeAll(async function (done) {
console.info('beforeAll');
done();
})
afterAll(async function (done) {
console.info('afterAll');
done();
})
beforeEach(async function (done) {
console.info('beforeEach');
await continuationManager.register(function (err, data) {
token = data;
console.info('beforeEach register success');
done();
});
console.info('beforeEach end');
})
afterEach(async function (done) {
console.info('afterEach');
await continuationManager.unregister(token, function (err, data) {
console.info('afterEach unregister success');
done();
});
console.info('afterEach end');
})
/**
* @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_REGISTER_0100
* @tc.name [JS-API8]ContinuationManager.register().
* @tc.desc Test Js Api ContinuationManager.register() testcase 001
*/
it('testRegister001', 0, async function(done) {
try {
continuationManager.register(function (err, data) {
expect(err.code == 0).assertTrue();
expect(data - token == 1).assertTrue();
done();
});
} catch (e) {
console.info("testRegister001 " + e);
expect(null).assertFail();
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_UNREGISTER_0100
* @tc.name [JS-API8]ContinuationManager.unregister().
* @tc.desc Test Js Api ContinuationManager.unregister() testcase 001
*/
it('testUnregister001', 0, async function(done) {
try {
continuationManager.unregister(token, function (err, data) {
expect(err.code == 0).assertTrue();
expect(data == undefined).assertTrue();
})
done();
} catch (e) {
console.info("testUnregister001 " + e);
expect(null).assertFail();
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_ON_0100
* @tc.name [JS-API8]ContinuationManager.on().
* @tc.desc Test Js Api ContinuationManager.on() testcase 001
*/
it('testOn001', 0, async function(done) {
try {
continuationManager.on("deviceConnect", function (data) {
expect(data == undefined).assertTrue();
});
done();
} catch (e) {
console.info("testOn001 " + e);
expect(null).assertFail();
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_ON_0200
* @tc.name [JS-API8]ContinuationManager.on().
* @tc.desc Test Js Api ContinuationManager.on() testcase 002
*/
it('testOn002', 0, async function(done) {
try {
continuationManager.on("deviceDisconnect", function (data) {
expect(data == undefined).assertTrue();
});
done();
} catch (e) {
console.info("testOn002 " + e);
expect(null).assertFail();
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_ON_0300
* @tc.name [JS-API9]ContinuationManager.on().
* @tc.desc Test Js Api ContinuationManager.on() testcase 003
*/
it('testOn003', 0, async function(done) {
try {
continuationManager.on("deviceConnect", token, function (data) {
expect(data == undefined).assertTrue();
})
done();
} catch (e) {
console.info("testOn003 " + e);
expect(null).assertFail();
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_ON_0400
* @tc.name [JS-API9]ContinuationManager.on().
* @tc.desc Test Js Api ContinuationManager.on() testcase 004
*/
it('testOn004', 0, async function(done) {
try {
continuationManager.on("deviceDisconnect", token, function (data) {
expect(data == undefined).assertTrue();
});
done();
} catch (e) {
console.info("testOn004 " + e);
expect(null).assertFail();
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_OFF_0100
* @tc.name [JS-API8]ContinuationManager.off().
* @tc.desc Test Js Api ContinuationManager.off() testcase 001
*/
it('testOff001', 0, async function(done) {
try {
continuationManager.off("deviceConnect", function (data) {
expect(data == undefined).assertTrue();
});
done();
} catch (e) {
console.info("testOff001 " + e);
expect(null).assertFail();
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_OFF_0200
* @tc.name [JS-API8]ContinuationManager.off().
* @tc.desc Test Js Api ContinuationManager.off() testcase 002
*/
it('testOff002', 0, async function(done) {
try {
continuationManager.off("deviceDisconnect", function (data) {
expect(data == undefined).assertTrue();
});
done();
} catch (e) {
console.info("testOff002 " + e);
expect(null).assertFail();
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_OFF_0300
* @tc.name [JS-API9]ContinuationManager.off().
* @tc.desc Test Js Api ContinuationManager.off() testcase 003
*/
it('testOff003', 0, async function(done) {
try {
continuationManager.off("deviceConnect", token);
done();
} catch (e) {
console.info("testOff003 " + e);
expect(null).assertFail();
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_OFF_0400
* @tc.name [JS-API9]ContinuationManager.off().
* @tc.desc Test Js Api ContinuationManager.off() testcase 004
*/
it('testOff004', 0, async function(done) {
try {
continuationManager.off("deviceDisconnect", token);
done();
} catch (e) {
console.info("testOff004 " + e);
expect(null).assertFail();
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_STARTDEVICEMANAGER_0100
* @tc.name [JS-API8]ContinuationManager.startDeviceManager().
* @tc.desc Test Js Api ContinuationManager.startDeviceManager() testcase 001
*/
it('testStartDeviceManager001', 0, async function(done) {
try {
continuationManager.startDeviceManager(token, function (err, data) {
expect(err.code != 0).assertTrue();
expect(data == undefined).assertTrue();
});
done();
} catch (e) {
console.info("testStartDeviceManager001 " + e);
expect(null).assertFail();
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_UPDATECONNECTSTATUS_0100
* @tc.name [JS-API8]ContinuationManager.updateConnectStatus().
* @tc.desc Test Js Api ContinuationManager.updateConnectStatus() testcase 001
*/
it('testUpdateConnectStatus001', 0, async function(done) {
try {
continuationManager.updateConnectStatus(token, TEST_DEVICE_ID, TEST_CONNECT_STATUS, function (err, data) {
expect(err.code != 0).assertTrue();
expect(data == undefined).assertTrue();
});
done();
} catch (e) {
console.info("testUpdateConnectStatus001 " + e);
expect(null).assertFail();
done();
}
})
})
\ 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 { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import continuationManager from '@ohos.continuation.continuationManager';
const TEST_DEVICE_ID = "test_deviceId";
const TEST_CONNECT_STATUS = continuationManager.DeviceConnectState.CONNECTED;
let token = -1;
export default function ContinuationManagerTest() {
describe('ContinuationManagerTest', function() {
beforeAll(async function (done) {
console.info('beforeAll');
done();
})
afterAll(async function (done) {
console.info('afterAll');
done();
})
beforeEach(async function (done) {
console.info('beforeEach');
await continuationManager.register(function (err, data) {
token = data;
console.info('beforeEach register success');
done();
});
console.info('beforeEach end');
})
afterEach(async function (done) {
console.info('afterEach');
await continuationManager.unregister(token, function (err, data) {
console.info('afterEach unregister success');
done();
});
console.info('afterEach end');
})
/**
* @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_REGISTER_0100
* @tc.name [JS-API8]ContinuationManager.register().
* @tc.desc Test Js Api ContinuationManager.register() testcase 001
*/
it('testRegister001', 0, async function(done) {
try {
continuationManager.register(function (err, data) {
expect(err.code == 0).assertTrue();
expect(data - token == 1).assertTrue();
done();
});
} catch (e) {
console.info("testRegister001 " + e);
expect(null).assertFail();
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_UNREGISTER_0100
* @tc.name [JS-API8]ContinuationManager.unregister().
* @tc.desc Test Js Api ContinuationManager.unregister() testcase 001
*/
it('testUnregister001', 0, async function(done) {
try {
continuationManager.unregister(token, function (err, data) {
expect(err.code == 0).assertTrue();
expect(data == undefined).assertTrue();
})
done();
} catch (e) {
console.info("testUnregister001 " + e);
expect(null).assertFail();
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_ON_0100
* @tc.name [JS-API8]ContinuationManager.on().
* @tc.desc Test Js Api ContinuationManager.on() testcase 001
*/
it('testOn001', 0, async function(done) {
try {
continuationManager.on("deviceConnect", function (data) {
expect(data == undefined).assertTrue();
});
done();
} catch (e) {
console.info("testOn001 " + e);
expect(null).assertFail();
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_ON_0200
* @tc.name [JS-API8]ContinuationManager.on().
* @tc.desc Test Js Api ContinuationManager.on() testcase 002
*/
it('testOn002', 0, async function(done) {
try {
continuationManager.on("deviceDisconnect", function (data) {
expect(data == undefined).assertTrue();
});
done();
} catch (e) {
console.info("testOn002 " + e);
expect(null).assertFail();
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_ON_0300
* @tc.name [JS-API9]ContinuationManager.on().
* @tc.desc Test Js Api ContinuationManager.on() testcase 003
*/
it('testOn003', 0, async function(done) {
try {
continuationManager.on("deviceConnect", token, function (data) {
expect(data == undefined).assertTrue();
})
done();
} catch (e) {
console.info("testOn003 " + e);
expect(null).assertFail();
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_ON_0400
* @tc.name [JS-API9]ContinuationManager.on().
* @tc.desc Test Js Api ContinuationManager.on() testcase 004
*/
it('testOn004', 0, async function(done) {
try {
continuationManager.on("deviceDisconnect", token, function (data) {
expect(data == undefined).assertTrue();
});
done();
} catch (e) {
console.info("testOn004 " + e);
expect(null).assertFail();
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_OFF_0100
* @tc.name [JS-API8]ContinuationManager.off().
* @tc.desc Test Js Api ContinuationManager.off() testcase 001
*/
it('testOff001', 0, async function(done) {
try {
continuationManager.off("deviceConnect", function (data) {
expect(data == undefined).assertTrue();
});
done();
} catch (e) {
console.info("testOff001 " + e);
expect(null).assertFail();
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_OFF_0200
* @tc.name [JS-API8]ContinuationManager.off().
* @tc.desc Test Js Api ContinuationManager.off() testcase 002
*/
it('testOff002', 0, async function(done) {
try {
continuationManager.off("deviceDisconnect", function (data) {
expect(data == undefined).assertTrue();
});
done();
} catch (e) {
console.info("testOff002 " + e);
expect(null).assertFail();
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_OFF_0300
* @tc.name [JS-API9]ContinuationManager.off().
* @tc.desc Test Js Api ContinuationManager.off() testcase 003
*/
it('testOff003', 0, async function(done) {
try {
continuationManager.off("deviceConnect", token);
done();
} catch (e) {
console.info("testOff003 " + e);
expect(null).assertFail();
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_OFF_0400
* @tc.name [JS-API9]ContinuationManager.off().
* @tc.desc Test Js Api ContinuationManager.off() testcase 004
*/
it('testOff004', 0, async function(done) {
try {
continuationManager.off("deviceDisconnect", token);
done();
} catch (e) {
console.info("testOff004 " + e);
expect(null).assertFail();
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_STARTDEVICEMANAGER_0100
* @tc.name [JS-API8]ContinuationManager.startDeviceManager().
* @tc.desc Test Js Api ContinuationManager.startDeviceManager() testcase 001
*/
it('testStartDeviceManager001', 0, async function(done) {
try {
continuationManager.startDeviceManager(token, function (err, data) {
expect(err.code != 0).assertTrue();
expect(data == undefined).assertTrue();
});
done();
} catch (e) {
console.info("testStartDeviceManager001 " + e);
expect(null).assertFail();
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDSCHEDULE_CONTINUATIONMANAGER_UPDATECONNECTSTATUS_0100
* @tc.name [JS-API8]ContinuationManager.updateConnectStatus().
* @tc.desc Test Js Api ContinuationManager.updateConnectStatus() testcase 001
*/
it('testUpdateConnectStatus001', 0, async function(done) {
try {
continuationManager.updateConnectStatus(token, TEST_DEVICE_ID, TEST_CONNECT_STATUS, function (err, data) {
expect(err.code != 0).assertTrue();
expect(data == undefined).assertTrue();
});
done();
} catch (e) {
console.info("testUpdateConnectStatus001 " + e);
expect(null).assertFail();
done();
}
})
})}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./ContinuationManagerJsunit.test.js')
\ 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 ContinuationManagerTest from './ContinuationManagerJsunit.test.js'
export default function testsuite() {
ContinuationManagerTest()
}
{
"string": [
{
"name": "app_name",
"value": "ContinuationManagerJsTest"
},
{
"name": "mainability_description",
"value": "hap sample empty page"
}
]
}
{
"string": [
{
"name": "app_name",
"value": "ContinuationManagerJsTest"
},
{
"name": "mainability_description",
"value": "hap sample empty page"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
}
......@@ -9,7 +9,7 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
......@@ -23,7 +23,9 @@ ohos_js_hap_suite("powermgr_power_test") {
hap_name = "ActsPowerMgrPowerTest"
}
ohos_js_assets("powermgr_power_js_assets") {
source_dir = "./src/main/js/default"
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("powermgr_power_resources") {
sources = [ "./src/main/resources" ]
......
{
"description": "Configuration for powermgr power Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "60000",
"package": "com.example.mypowerapp",
"shell-timeout": "60000"
},
"kits": [
{
"type": "ShellKit",
"run-command": [
"power-shell wakeup"
]
},
{
"test-file-name": [
"ActsPowerMgrPowerTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
{
"description": "Configuration for powermgr power Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "60000",
"shell-timeout": "60000",
"bundle-name": "com.example.mypowerapp",
"package-name": "com.example.mypowerapp"
},
"kits": [
{
"type": "ShellKit",
"run-command": [
"power-shell wakeup"
]
},
{
"test-file-name": [
"ActsPowerMgrPowerTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
文件模式从 100755 更改为 100644
{
"app": {
"bundleName": "com.example.mypowerapp",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "com.example.mypowerapp",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
"app": {
"bundleName": "com.example.mypowerapp",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"abilities": [
{
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
"deviceConfig": {},
"module": {
"package": "com.example.mypowerapp",
"name": ".entry",
"deviceType": [
"phone"
],
"name": "com.example.mypowerapp.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"mainAbility": ".MainAbility",
"srcPath": ""
}
}
\ No newline at end of file
{
"strings": {
"hello": "Hello",
"world": "World"
}
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
/*
* 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.
*/
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
/*
* 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.
*/
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
<!--
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.
-->
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
<!--
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.
-->
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* 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.
*/
import app from '@system.app'
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
},
onReady() {
},
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/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": {
}
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
{
"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>
<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) 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.
*/
import app from '@system.app'
import {Core, ExpectExtend} from 'deccjsunit/index'
export default {
data: {
title: ""
},
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')
configService.setConfig(this)
require('../../test/List.test')
core.execute()
},
onReady() {
},
}
\ No newline at end of file
......@@ -12,6 +12,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./power_manager_running_lock.test.js')
require('./power_manager_power.test.js')
import appInfoTest_power_1 from './power_manager_power.test.js'
import appInfoTest_power_2 from './power_manager_running_lock.test.js'
export default function testsuite() {
appInfoTest_power_1()
appInfoTest_power_2()
}
/*
* 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.
*/
import power from '@ohos.power';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
describe('appInfoTest_power_1', function () {
console.log("*************Power Unit Test Begin*************");
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0010
* @tc.name Power_Is_Screnn_On_Promise_JSTest0010
* @tc.desc Checks whether the screen of a device is on or off
*/
it('Power_Is_Screnn_On_Promise_JSTest0010', 0, async function (done) {
power.wakeupDevice("Power_Is_Screnn_On_Promise_JSTest0010");
power.isScreenOn()
.then(screenOn => {
console.info('Power_Is_Screnn_On_Promise_JSTest0010 screenOn is ' + screenOn);
expect(screenOn).assertTrue();
console.info('Power_Is_Screnn_On_Promise_JSTest0010 success');
done();
})
.catch(error => {
console.log('Power_Is_Screnn_On_Promise_JSTest0010 error: ' + error);
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0020
* @tc.name Power_Is_Screnn_On_Callback_JSTest0020
* @tc.desc Checks whether the screen of a device is on or off
*/
it('Power_Is_Screnn_On_Callback_JSTest0020', 0, async function (done) {
power.wakeupDevice("Power_Is_Screnn_On_Callback_JSTest0020");
power.isScreenOn((error, screenOn) => {
if (typeof error === "undefined") {
console.info('Power_Is_Screnn_On_Callback_JSTest0020 screenOn is ' + screenOn);
expect(screenOn).assertTrue();
console.info('Power_Is_Screnn_On_Callback_JSTest0020 success');
done();
} else {
console.log('Power_Is_Screnn_On_Callback_JSTest0020: ' + error);
expect().assertFail();
done();
}
})
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0030
* @tc.name Power_WakeupDevices_String_JSTest0030
* @tc.desc Try to wakeup the device and let screen on
*/
it('Power_WakeupDevices_String_JSTest0030', 0, async function (done) {
power.isScreenOn()
.then(screenOn => {
console.info('Power_WakeupDevices_String_JSTest0030: The current screenOn is ' + screenOn);
if (screenOn) {
power.suspendDevice();
}
})
.catch(error => {
console.log('Power_WakeupDevices_String_JSTest0030 error: ' + error);
expect().assertFail();
done();
})
setTimeout(function(){
power.wakeupDevice("Power_WakeupDevices_String_JSTest0030");
power.isScreenOn()
.then(screenOn => {
console.info('Power_WakeupDevices_String_JSTest0030: The current screenOn is ' + screenOn);
expect(screenOn).assertTrue();
console.info('Power_WakeupDevices_String_JSTest0030 success');
done();
})
.catch(error => {
console.log('Power_WakeupDevices_String_JSTest0030 error: ' + error);
expect().assertFail();
done();
})
}, 2000);
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0040
* @tc.name Power_SuspendDevices_JSTest0040
* @tc.desc Try to suspend the device and let screen off
*/
it('Power_SuspendDevices_JSTest0040', 0, async function (done) {
power.isScreenOn()
.then(screenOn => {
console.info('Power_SuspendDevices_JSTest0040: The current screenOn is ' + screenOn);
if (!screenOn) {
power.wakeupDevice("Power_SuspendDevices_JSTest0040");
}
})
.catch(error => {
console.log('Power_SuspendDevices_JSTest0040 error: ' + error);
expect().assertFail();
done();
})
setTimeout(function(){
power.suspendDevice();
console.info('Power_SuspendDevices_JSTest0040: SuspendDevice end');
power.isScreenOn()
.then(screenOn => {
console.info('Power_SuspendDevices_JSTest0040: The current screenOn is ' + screenOn);
expect(screenOn).assertFalse();
console.info('Power_SuspendDevices_JSTest0040 success');
done();
})
.catch(error => {
console.log('Power_SuspendDevices_JSTest0040 error: ' + error);
expect().assertFail();
done();
})
}, 2000);
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0050
* @tc.name Power_Get_PowerMode_Callback_JSTest0050
* @tc.desc Get The mode the device
*/
it('Power_Get_PowerMode_Callback_JSTest0050', 0, async function (done) {
power.getPowerMode()
.then(powerMode => {
console.info('Power_Get_PowerMode_Callback_JSTest0050 power mode is ' + powerMode);
expect(powerMode >= 600 && powerMode <= 603).assertTrue();
done();
})
.catch(error => {
console.log('Power_Get_PowerMode_Callback_JSTest0050 error: ' + error);
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0060
* @tc.name Power_Get_PowerMode_Promise_JSTest0060
* @tc.desc Get The mode the device
*/
it('Power_Get_PowerMode_Promise_JSTest0060', 0, async function (done) {
power.getPowerMode((error, powerMode) => {
if (typeof error === "undefined") {
console.info('Power_Get_PowerMode_Promise_JSTest0060 power mode is ' + powerMode);
expect(powerMode >= 600 && powerMode <= 603).assertTrue();
done();
} else {
console.log('Power_Get_PowerMode_Promise_JSTest0060: ' + error);
expect().assertFail();
done();
}
})
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0070
* @tc.name Power_Device_Power_Mode_MODENORMAL_JSTest0070
* @tc.desc Get device power mode MODE_NORMAL
*/
it('Power_Device_Power_Mode_MODENORMAL_JSTest0070', 0, function () {
let devicePowerMode = power.DevicePowerMode.MODE_NORMAL;
console.info('MODE_NORMAL = ' + devicePowerMode);
expect(devicePowerMode === 600).assertTrue();
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0080
* @tc.name Power_Device_Power_Mode_MODEPOWERSAVE_JSTest0080
* @tc.desc Get device power mode MODE_POWER_SAVE
*/
it('Power_Device_Power_Mode_MODEPOWERSAVE_JSTest0080', 0, function () {
let devicePowerMode = power.DevicePowerMode.MODE_POWER_SAVE;
console.info('MODE_POWER_SAVE = ' + devicePowerMode);
expect(devicePowerMode === 601).assertTrue();
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0090
* @tc.name Power_Device_pPower_Mode_MODEPERFORMANCE_JSTest0090
* @tc.desc Get device power mode MODE_PERFORMANCE
*/
it('Power_Device_pPower_Mode_MODEPERFORMANCE_JSTest0090', 0, function () {
let devicePowerMode = power.DevicePowerMode.MODE_PERFORMANCE;
console.info('MODE_PERFORMANCE = ' + devicePowerMode);
expect(devicePowerMode === 602).assertTrue();
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0100
* @tc.name Power_Device_Power_Mode_MODE_EXTREME_POWER_SAVE_JSTest0100
* @tc.desc Get device power mode MODE_EXTREME_POWER_SAVE
*/
it('Power_Device_Power_Mode_MODE_EXTREME_POWER_SAVE_JSTest0100', 0, function () {
let devicePowerMode = power.DevicePowerMode.MODE_EXTREME_POWER_SAVE;
console.info('MODE_EXTREME_POWER_SAVE = ' + devicePowerMode);
expect(devicePowerMode === 603).assertTrue();
})
})
/*
* 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.
*/
import power from '@ohos.power';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
export default function appInfoTest_power_1() {
describe('appInfoTest_power_1', function () {
console.log("*************Power Unit Test Begin*************");
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0010
* @tc.name Power_Is_Screnn_On_Promise_JSTest0010
* @tc.desc Checks whether the screen of a device is on or off
*/
it('Power_Is_Screnn_On_Promise_JSTest0010', 0, async function (done) {
power.wakeupDevice("Power_Is_Screnn_On_Promise_JSTest0010");
power.isScreenOn()
.then(screenOn => {
console.info('Power_Is_Screnn_On_Promise_JSTest0010 screenOn is ' + screenOn);
expect(screenOn).assertTrue();
console.info('Power_Is_Screnn_On_Promise_JSTest0010 success');
done();
})
.catch(error => {
console.log('Power_Is_Screnn_On_Promise_JSTest0010 error: ' + error);
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0020
* @tc.name Power_Is_Screnn_On_Callback_JSTest0020
* @tc.desc Checks whether the screen of a device is on or off
*/
it('Power_Is_Screnn_On_Callback_JSTest0020', 0, async function (done) {
power.wakeupDevice("Power_Is_Screnn_On_Callback_JSTest0020");
power.isScreenOn((error, screenOn) => {
if (typeof error === "undefined") {
console.info('Power_Is_Screnn_On_Callback_JSTest0020 screenOn is ' + screenOn);
expect(screenOn).assertTrue();
console.info('Power_Is_Screnn_On_Callback_JSTest0020 success');
done();
} else {
console.log('Power_Is_Screnn_On_Callback_JSTest0020: ' + error);
expect().assertFail();
done();
}
})
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0030
* @tc.name Power_WakeupDevices_String_JSTest0030
* @tc.desc Try to wakeup the device and let screen on
*/
it('Power_WakeupDevices_String_JSTest0030', 0, async function (done) {
power.isScreenOn()
.then(screenOn => {
console.info('Power_WakeupDevices_String_JSTest0030: The current screenOn is ' + screenOn);
if (screenOn) {
power.suspendDevice();
}
})
.catch(error => {
console.log('Power_WakeupDevices_String_JSTest0030 error: ' + error);
expect().assertFail();
done();
})
setTimeout(function(){
power.wakeupDevice("Power_WakeupDevices_String_JSTest0030");
power.isScreenOn()
.then(screenOn => {
console.info('Power_WakeupDevices_String_JSTest0030: The current screenOn is ' + screenOn);
expect(screenOn).assertTrue();
console.info('Power_WakeupDevices_String_JSTest0030 success');
done();
})
.catch(error => {
console.log('Power_WakeupDevices_String_JSTest0030 error: ' + error);
expect().assertFail();
done();
})
}, 2000);
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0040
* @tc.name Power_SuspendDevices_JSTest0040
* @tc.desc Try to suspend the device and let screen off
*/
it('Power_SuspendDevices_JSTest0040', 0, async function (done) {
power.isScreenOn()
.then(screenOn => {
console.info('Power_SuspendDevices_JSTest0040: The current screenOn is ' + screenOn);
if (!screenOn) {
power.wakeupDevice("Power_SuspendDevices_JSTest0040");
}
})
.catch(error => {
console.log('Power_SuspendDevices_JSTest0040 error: ' + error);
expect().assertFail();
done();
})
setTimeout(function(){
power.suspendDevice();
console.info('Power_SuspendDevices_JSTest0040: SuspendDevice end');
power.isScreenOn()
.then(screenOn => {
console.info('Power_SuspendDevices_JSTest0040: The current screenOn is ' + screenOn);
expect(screenOn).assertFalse();
console.info('Power_SuspendDevices_JSTest0040 success');
done();
})
.catch(error => {
console.log('Power_SuspendDevices_JSTest0040 error: ' + error);
expect().assertFail();
done();
})
}, 2000);
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0050
* @tc.name Power_Get_PowerMode_Callback_JSTest0050
* @tc.desc Get The mode the device
*/
it('Power_Get_PowerMode_Callback_JSTest0050', 0, async function (done) {
power.getPowerMode()
.then(powerMode => {
console.info('Power_Get_PowerMode_Callback_JSTest0050 power mode is ' + powerMode);
expect(powerMode >= 600 && powerMode <= 603).assertTrue();
done();
})
.catch(error => {
console.log('Power_Get_PowerMode_Callback_JSTest0050 error: ' + error);
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0060
* @tc.name Power_Get_PowerMode_Promise_JSTest0060
* @tc.desc Get The mode the device
*/
it('Power_Get_PowerMode_Promise_JSTest0060', 0, async function (done) {
power.getPowerMode((error, powerMode) => {
if (typeof error === "undefined") {
console.info('Power_Get_PowerMode_Promise_JSTest0060 power mode is ' + powerMode);
expect(powerMode >= 600 && powerMode <= 603).assertTrue();
done();
} else {
console.log('Power_Get_PowerMode_Promise_JSTest0060: ' + error);
expect().assertFail();
done();
}
})
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0070
* @tc.name Power_Device_Power_Mode_MODENORMAL_JSTest0070
* @tc.desc Get device power mode MODE_NORMAL
*/
it('Power_Device_Power_Mode_MODENORMAL_JSTest0070', 0, function () {
let devicePowerMode = power.DevicePowerMode.MODE_NORMAL;
console.info('MODE_NORMAL = ' + devicePowerMode);
expect(devicePowerMode === 600).assertTrue();
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0080
* @tc.name Power_Device_Power_Mode_MODEPOWERSAVE_JSTest0080
* @tc.desc Get device power mode MODE_POWER_SAVE
*/
it('Power_Device_Power_Mode_MODEPOWERSAVE_JSTest0080', 0, function () {
let devicePowerMode = power.DevicePowerMode.MODE_POWER_SAVE;
console.info('MODE_POWER_SAVE = ' + devicePowerMode);
expect(devicePowerMode === 601).assertTrue();
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0090
* @tc.name Power_Device_pPower_Mode_MODEPERFORMANCE_JSTest0090
* @tc.desc Get device power mode MODE_PERFORMANCE
*/
it('Power_Device_pPower_Mode_MODEPERFORMANCE_JSTest0090', 0, function () {
let devicePowerMode = power.DevicePowerMode.MODE_PERFORMANCE;
console.info('MODE_PERFORMANCE = ' + devicePowerMode);
expect(devicePowerMode === 602).assertTrue();
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0100
* @tc.name Power_Device_Power_Mode_MODE_EXTREME_POWER_SAVE_JSTest0100
* @tc.desc Get device power mode MODE_EXTREME_POWER_SAVE
*/
it('Power_Device_Power_Mode_MODE_EXTREME_POWER_SAVE_JSTest0100', 0, function () {
let devicePowerMode = power.DevicePowerMode.MODE_EXTREME_POWER_SAVE;
console.info('MODE_EXTREME_POWER_SAVE = ' + devicePowerMode);
expect(devicePowerMode === 603).assertTrue();
})
})
}
/*
* 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.
*/
import power from '@ohos.power';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index'
describe('appInfoTest', function () {
console.log("*************Power Unit Test Begin*************");
/**
* @tc.number power_js_001
* @tc.name power_creat_shutdownDevice_test
* @tc.desc Device shutdown interface validation
*/
it('creat_shutdownDevice_test01', 0, async function () {
function shutPromise(){
new Promise(function(resolve,reject){
power.isScreenOn((error, screenOn)=>{
if(screenOn){
console.log('devices shutdown error');
reject(screenOn);
}else{
console.log('devices shutdown success');
resolve(error);
}
},1000)
})
}
power.shutdownDevice("shutsown");
shutPromise();
})
/**
* @tc.number power_js_002
* @tc.name power_creat_shutdownDevice_test
* @tc.desc Device shutdown interface validation
*/
it('creat_shutdownDevice_test02', 0, async function () {
power.isScreenOn()
.then(screenOn => {
console.info('power_shutdownDevice_test: The current screenOn is ' + screenOn);
if (!screenOn) {
power.wakeupDevice("power_shutdownDevice_test");
}
})
.catch(error => {
console.log('power_shutdownDevice_test error: ' + error);
expect().assertFail();
done();
})
power.shutdownDevice("shutsown");
console.info('power_shutdownDevice_test: shutdownDevice end');
setTimeout(function(){
power.isScreenOn()
.then(screenOn => {
console.info('power_shutdownDevice_test: The current screenOn is ' + screenOn);
expect(screenOn).assertFalse();
console.info('power_shutdownDevice_test success');
done();
})
.catch(error => {
console.log('power_shutdownDevice_test error: ' + error);
expect().assertFail();
done();
})
}, 2000);
})
/**
* @tc.number power_js_003
* @tc.name power_creat_rebootDeviceDevice_test
* @tc.desc Device reboot interface verification
*/
it('creat_rebootDeviceDevice_test', 0, async function () {
power.isScreenOn()
.then(screenOn => {
console.info('power_rebootDevice_test: The current screenOn is ' + screenOn);
if (!screenOn) {
power.wakeupDevice("power_rebootDevice_test");
}
})
.catch(error => {
console.log('power_rebootDevice_test error: ' + error);
expect().assertFail();
done();
})
power.rebootDevice("shutsown");
console.info('power_rebootDevice_test: rebootDevice end');
setTimeout(function(){
power.isScreenOn()
.then(screenOn => {
console.info('power_rebootDevice_test: The current screenOn is ' + screenOn);
expect(screenOn).assertFalse();
console.info('power_rebootDevice_test success');
done();
})
.catch(error => {
console.log('power_rebootDevice_test error: ' + error);
expect().assertFail();
done();
})
}, 2000);
})
})
\ No newline at end of file
/*
* 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.
*/
import power from '@ohos.power';
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
export default function appInfoTest() {
describe('appInfoTest', function () {
console.log("*************Power Unit Test Begin*************");
/**
* @tc.number power_js_001
* @tc.name power_creat_shutdownDevice_test
* @tc.desc Device shutdown interface validation
*/
it('creat_shutdownDevice_test01', 0, async function () {
function shutPromise(){
new Promise(function(resolve,reject){
power.isScreenOn((error, screenOn)=>{
if(screenOn){
console.log('devices shutdown error');
reject(screenOn);
}else{
console.log('devices shutdown success');
resolve(error);
}
},1000)
})
}
power.shutdownDevice("shutsown");
shutPromise();
})
/**
* @tc.number power_js_002
* @tc.name power_creat_shutdownDevice_test
* @tc.desc Device shutdown interface validation
*/
it('creat_shutdownDevice_test02', 0, async function () {
power.isScreenOn()
.then(screenOn => {
console.info('power_shutdownDevice_test: The current screenOn is ' + screenOn);
if (!screenOn) {
power.wakeupDevice("power_shutdownDevice_test");
}
})
.catch(error => {
console.log('power_shutdownDevice_test error: ' + error);
expect().assertFail();
done();
})
power.shutdownDevice("shutsown");
console.info('power_shutdownDevice_test: shutdownDevice end');
setTimeout(function(){
power.isScreenOn()
.then(screenOn => {
console.info('power_shutdownDevice_test: The current screenOn is ' + screenOn);
expect(screenOn).assertFalse();
console.info('power_shutdownDevice_test success');
done();
})
.catch(error => {
console.log('power_shutdownDevice_test error: ' + error);
expect().assertFail();
done();
})
}, 2000);
})
/**
* @tc.number power_js_003
* @tc.name power_creat_rebootDeviceDevice_test
* @tc.desc Device reboot interface verification
*/
it('creat_rebootDeviceDevice_test', 0, async function () {
power.isScreenOn()
.then(screenOn => {
console.info('power_rebootDevice_test: The current screenOn is ' + screenOn);
if (!screenOn) {
power.wakeupDevice("power_rebootDevice_test");
}
})
.catch(error => {
console.log('power_rebootDevice_test error: ' + error);
expect().assertFail();
done();
})
power.rebootDevice("shutsown");
console.info('power_rebootDevice_test: rebootDevice end');
setTimeout(function(){
power.isScreenOn()
.then(screenOn => {
console.info('power_rebootDevice_test: The current screenOn is ' + screenOn);
expect(screenOn).assertFalse();
console.info('power_rebootDevice_test success');
done();
})
.catch(error => {
console.log('power_rebootDevice_test error: ' + error);
expect().assertFail();
done();
})
}, 2000);
})
})}
/*
* 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 runningLock from '@ohos.runninglock';
import power from '@ohos.power';
import brightness from '@ohos.brightness';
import { describe, it, expect } from 'deccjsunit/index';
describe('appInfoTest_power_3', function () {
console.log("*************Power Performance Test Begin*************");
const MAXNUM = 1000;
const MIDNUM = 100;
const MS_TO_US = 1000;
const LIMIT_TIME = 1500;
const LIMIT_TIME_LONG = 4000;
/**
* @tc.number PowerPerformance_001
* @tc.name createRunningLock_test
* @tc.desc Interface is called normally
*/
it('PowerPerformance_001', 0, async function (done) {
let startTime = new Date().getTime();
for (let i = 0; i < MIDNUM; i++) {
await runningLock.createRunningLock("test", runningLock.RunningLockType.BACKGROUND)
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MIDNUM * MS_TO_US; //us
console.info(`POWER_Performance_001: Promise: runningLock.createRunningLock Wait Time : ${waitTime}`);
avgTime < LIMIT_TIME_LONG ? expect(true).assertTrue() : expect(false).assertTrue();
done();
})
/**
* @tc.number PowerPerformance_003
* @tc.name lock_test
* @tc.desc Interface is called normally
*/
it('PowerPerformance_003', 0, async function (done) {
let avgTime = 0;
runningLock.createRunningLock("test", runningLock.RunningLockType.BACKGROUND, (error, runningLock) => {
if (typeof error === "undefined") {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
runningLock.lock(500);
}
let waitTime = new Date().getTime() - startTime;
avgTime = avgTime + waitTime; //us
console.info(`PowerPerformance_003: Promise: runningLock.lock Wait Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
runningLock.unlock();
done();
} else {
console.log('PowerPerformance_003: ' + error);
console.info('PowerPerformance_003: lock is ' + runningLock);
done();
}
})
})
/**
* @tc.number PowerPerformance_004
* @tc.name unlock_test
* @tc.desc Interface is called normally
*/
it('PowerPerformance_004', 0, async function (done) {
let avgTime = 0;
runningLock.createRunningLock("test", runningLock.RunningLockType.BACKGROUND, (error, runningLock) => {
if (typeof error === "undefined") {
runningLock.lock(500);
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
runningLock.unlock();
}
let waitTime = new Date().getTime() - startTime;
avgTime = avgTime + waitTime; //us
console.info(`PowerPerformance_004: Promise: runningLock.unlock Wait Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
done();
} else {
console.log('PowerPerformance_004: ' + error);
console.info('PowerPerformance_004: lock is ' + runningLock);
done();
}
})
})
/**
* @tc.number PowerPerformance_005
* @tc.name isProximitySupported_test
* @tc.desc Interface is called normally
*/
it('PowerPerformance_005', 0, async function (done) {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
await runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL)
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`PowerPerformance_005: Promise: await runningLock.isRunningLockTypeSupported Wait Time :
${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
done();
})
/**
* @tc.number PowerPerformance_006
* @tc.name isScreenOn_test
* @tc.desc AsyncCallback<boolean> judge whether the screen is lit and return to true
*/
it('PowerPerformance_006', 0, async function (done) {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
await power.isScreenOn()
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`PowerPerformance_006: Promise: await power.isScreenOn Wait Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
done();
})
/**
* @tc.number PowerPerformance_007
* @tc.name setValue_test
* @tc.desc Interface is called normally
*/
it('PowerPerformance_007', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
brightness.setValue(100);
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`PowerPerformance_007: Promise: brightness.setValue Wait Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
})
/*
* 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 runningLock from '@ohos.runninglock';
import power from '@ohos.power';
import brightness from '@ohos.brightness';
import { describe, it, expect } from '@ohos/hypium';
export default function appInfoTest_power_3() {
describe('appInfoTest_power_3', function () {
console.log("*************Power Performance Test Begin*************");
const MAXNUM = 1000;
const MIDNUM = 100;
const MS_TO_US = 1000;
const LIMIT_TIME = 1500;
const LIMIT_TIME_LONG = 4000;
/**
* @tc.number PowerPerformance_001
* @tc.name createRunningLock_test
* @tc.desc Interface is called normally
*/
it('PowerPerformance_001', 0, async function (done) {
let startTime = new Date().getTime();
for (let i = 0; i < MIDNUM; i++) {
await runningLock.createRunningLock("test", runningLock.RunningLockType.BACKGROUND)
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MIDNUM * MS_TO_US; //us
console.info(`POWER_Performance_001: Promise: runningLock.createRunningLock Wait Time : ${waitTime}`);
avgTime < LIMIT_TIME_LONG ? expect(true).assertTrue() : expect(false).assertTrue();
done();
})
/**
* @tc.number PowerPerformance_003
* @tc.name lock_test
* @tc.desc Interface is called normally
*/
it('PowerPerformance_003', 0, async function (done) {
let avgTime = 0;
runningLock.createRunningLock("test", runningLock.RunningLockType.BACKGROUND, (error, runningLock) => {
if (typeof error === "undefined") {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
runningLock.lock(500);
}
let waitTime = new Date().getTime() - startTime;
avgTime = avgTime + waitTime; //us
console.info(`PowerPerformance_003: Promise: runningLock.lock Wait Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
runningLock.unlock();
done();
} else {
console.log('PowerPerformance_003: ' + error);
console.info('PowerPerformance_003: lock is ' + runningLock);
done();
}
})
})
/**
* @tc.number PowerPerformance_004
* @tc.name unlock_test
* @tc.desc Interface is called normally
*/
it('PowerPerformance_004', 0, async function (done) {
let avgTime = 0;
runningLock.createRunningLock("test", runningLock.RunningLockType.BACKGROUND, (error, runningLock) => {
if (typeof error === "undefined") {
runningLock.lock(500);
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
runningLock.unlock();
}
let waitTime = new Date().getTime() - startTime;
avgTime = avgTime + waitTime; //us
console.info(`PowerPerformance_004: Promise: runningLock.unlock Wait Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
done();
} else {
console.log('PowerPerformance_004: ' + error);
console.info('PowerPerformance_004: lock is ' + runningLock);
done();
}
})
})
/**
* @tc.number PowerPerformance_005
* @tc.name isProximitySupported_test
* @tc.desc Interface is called normally
*/
it('PowerPerformance_005', 0, async function (done) {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
await runningLock.isRunningLockTypeSupported(runningLock.RunningLockType.PROXIMITY_SCREEN_CONTROL)
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`PowerPerformance_005: Promise: await runningLock.isRunningLockTypeSupported Wait Time :
${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
done();
})
/**
* @tc.number PowerPerformance_006
* @tc.name isScreenOn_test
* @tc.desc AsyncCallback<boolean> judge whether the screen is lit and return to true
*/
it('PowerPerformance_006', 0, async function (done) {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
await power.isScreenOn()
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`PowerPerformance_006: Promise: await power.isScreenOn Wait Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
done();
})
/**
* @tc.number PowerPerformance_007
* @tc.name setValue_test
* @tc.desc Interface is called normally
*/
it('PowerPerformance_007', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
brightness.setValue(100);
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime / MAXNUM * MS_TO_US; //us
console.info(`PowerPerformance_007: Promise: brightness.setValue Wait Time : ${waitTime}`);
avgTime < LIMIT_TIME ? expect(true).assertTrue() : expect(false).assertTrue();
})
})
}
......@@ -7,6 +7,22 @@
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
文件模式从 100755 更改为 100644
......@@ -9,7 +9,7 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
......@@ -23,7 +23,9 @@ ohos_js_hap_suite("powermgr_thermal_test") {
hap_name = "ActsPowerMgrThermalTest"
}
ohos_js_assets("powermgr_thermal_js_assets") {
source_dir = "./src/main/js/default"
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("powermgr_thermal_resources") {
sources = [ "./src/main/resources" ]
......
{
"description": "Configuration for powermgr thermal Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "120000",
"package": "com.example.mythermalapp",
"shell-timeout": "120000"
},
"kits": [
{
"test-file-name": [
"ActsPowerMgrThermalTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"description": "Configuration for powermgr thermal Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "120000",
"shell-timeout": "120000",
"bundle-name": "com.example.mythermalapp",
"package-name": "com.example.mythermalapp"
},
"kits": [
{
"test-file-name": [
"ActsPowerMgrThermalTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "com.example.mythermalapp",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "com.example.mythermalapp",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
"app": {
"bundleName": "com.example.mythermalapp",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"abilities": [
{
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
"deviceConfig": {},
"module": {
"package": "com.example.mythermalapp",
"name": ".entry",
"deviceType": [
"phone"
],
"name": "com.example.mythermalapp.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"formsEnabled": false,
"name": ".MainAbility",
"srcLanguage": "js",
"srcPath": "MainAbility",
"icon": "$media:icon",
"description": "$string:MainAbility_desc",
"label": "$string:MainAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
},
{
"orientation": "unspecified",
"formsEnabled": false,
"name": ".TestAbility",
"srcLanguage": "js",
"srcPath": "TestAbility",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"label": "$string:TestAbility_label",
"type": "page",
"visible": true,
"launchType": "standard"
}
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"mainAbility": ".MainAbility",
"srcPath": ""
}
}
\ No newline at end of file
{
"strings": {
"hello": "Hello",
"world": "World"
}
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
/*
* 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.
*/
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
/*
* 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.
*/
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
<!--
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.
-->
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
<!--
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.
-->
<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.
*/
import app from '@system.app'
import {Core, ExpectExtend} from 'deccjsunit/index'
export default {
data: {
title: ""
},
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')
configService.setConfig(this)
require('../../test/List.test')
core.execute()
},
onReady() {
},
}
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import app from '@system.app'
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
},
onReady() {
},
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import 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);
})
}
};
......@@ -12,4 +12,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./thermal_unittest.test.js')
\ No newline at end of file
import appInfoTest_thermal_1 from './thermal_unittest.test.js'
export default function testsuite() {
appInfoTest_thermal_1()
}
/*
* 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 commonEvent from '@ohos.commonEvent';
import thermal from "@ohos.thermal"
describe('appInfoTest_thermal_3', function () {
console.log("*************Thermal commonEvent Test Begin*************");
/**
* @tc.number ThermalCommonEventTest_001
* @tc.name subscribe thermal level changed common event
* @tc.desc Thermal acquisition kit
*/
it('ThermalCommonEventTest_001', 0, function (done) {
createSubscriber();
done();
})
console.log("*************Thermal commonEvent Test End*************");
})
function createSubscriber() {
let commonEventSubscribeInfo = {
events: [commonEvent.Support.COMMON_EVENT_THERMAL_LEVEL_CHANGED],
};
commonEvent.createSubscriber(commonEventSubscribeInfo)
.then(subscriber => {
console.info('createSubscriber success');
let mySubscriber = subscriber;
console.log(subscriber);
if (subscriber == "" || subscriber == undefined || subscriber == null) {
console.info("createSubscriber failed");
}
mySubscriber.getCode()
.then((data) => {
console.info('Subscriber getCode success : ' + JSON.stringify(data));
}).catch((error) => {
console.error('Subscriber getCode error because: ' + JSON.stringify(error));
})
mySubscriber.getData()
.then((data) => {
console.info('Subscriber getData success : ' + JSON.stringify(data));
}).catch((error) => {
console.error('Subscriber getData error because: ' + JSON.stringify(error));
})
console.info('subscribe begin ');
commonEvent.subscribe(mySubscriber, (error, commonEventData) => {
console.error('err code: ' + JSON.stringify(error));
console.info('subscribe callback: ' + JSON.stringify(commonEventData));
console.info("commonEventData event: " + commonEventData.event);
console.info("commonEventData bundleName: " + commonEventData.bundleName);
console.info("commonEventData data: " + commonEventData.data);
console.info("commonEventData parameter: " + commonEventData.parameters[0]);
let level = -1;
expect(level >= thermal.ThermalLevel.COOL && warm <= level.ThermalLevel.EMERGENCY).assertTrue();
});
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
});
}
\ 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 commonEvent from '@ohos.commonEvent';
import thermal from "@ohos.thermal"
export default function appInfoTest_thermal_3() {
describe('appInfoTest_thermal_3', function () {
console.log("*************Thermal commonEvent Test Begin*************");
/**
* @tc.number ThermalCommonEventTest_001
* @tc.name subscribe thermal level changed common event
* @tc.desc Thermal acquisition kit
*/
it('ThermalCommonEventTest_001', 0, function (done) {
createSubscriber();
done();
})
console.log("*************Thermal commonEvent Test End*************");
})
function createSubscriber() {
let commonEventSubscribeInfo = {
events: [commonEvent.Support.COMMON_EVENT_THERMAL_LEVEL_CHANGED],
};
commonEvent.createSubscriber(commonEventSubscribeInfo)
.then(subscriber => {
console.info('createSubscriber success');
let mySubscriber = subscriber;
console.log(subscriber);
if (subscriber == "" || subscriber == undefined || subscriber == null) {
console.info("createSubscriber failed");
}
mySubscriber.getCode()
.then((data) => {
console.info('Subscriber getCode success : ' + JSON.stringify(data));
}).catch((error) => {
console.error('Subscriber getCode error because: ' + JSON.stringify(error));
})
mySubscriber.getData()
.then((data) => {
console.info('Subscriber getData success : ' + JSON.stringify(data));
}).catch((error) => {
console.error('Subscriber getData error because: ' + JSON.stringify(error));
})
console.info('subscribe begin ');
commonEvent.subscribe(mySubscriber, (error, commonEventData) => {
console.error('err code: ' + JSON.stringify(error));
console.info('subscribe callback: ' + JSON.stringify(commonEventData));
console.info("commonEventData event: " + commonEventData.event);
console.info("commonEventData bundleName: " + commonEventData.bundleName);
console.info("commonEventData data: " + commonEventData.data);
console.info("commonEventData parameter: " + commonEventData.parameters[0]);
let level = -1;
expect(level >= thermal.ThermalLevel.COOL && warm <= level.ThermalLevel.EMERGENCY).assertTrue();
});
}).catch((error) => {
console.error('Operation failed. Cause: ' + JSON.stringify(error));
});
}}
/*
* 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 thermal from "@ohos.thermal"
import { describe, it, expect } from 'deccjsunit/index';
describe('appInfoTest_thermal_4', function () {
console.log("*************Thermal Performance Test Begin*************");
performanceTest1();
performanceTest2();
performanceTest3();
console.log("*************Thermal Performance Test End*************");
})
function performanceTest1() {
let MAXNUM = 1000;
/**
* @tc.number ThermalPerformance_001
* @tc.name test get thermal level
* @tc.desc Thermal acquisition kit
*/
it('ThermalPerformance_001', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
let level = thermal.getThermalLevel();
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime; //us
console.info(`ThermalPerformance_001: Promise: getlevel Wait Time : ${waitTime}`);
})
}
function performanceTest2() {
let MAXNUM = 1000;
/**
* @tc.number ThermalPerformance_002
* @tc.name subscribe thermal level
* @tc.desc Thermal acquisition kit
*/
it('ThermalPerformance_002', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
thermal.subscribeThermalLevel((level) => {
console.info("hot level is: " + level);
})
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime; //us
console.info(`ThermalPerformance_002: Promise: subscribeThermalLevel Wait Time : ${waitTime}`);
})
}
function performanceTest3() {
let MAXNUM = 1000;
/**
* @tc.number ThermalPerformance_002
* @tc.name subscribe thermal level
* @tc.desc Thermal acquisition kit
*/
it('ThermalPerformance_003', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
thermal.unsubscribeThermalLevel(() => {
console.info("unsubscribe success.");
});
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime; //us
console.info(`ThermalPerformance_003: Promise: unsubscribeThermalLevel Wait Time : ${waitTime}`);
})
}
/*
* 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 thermal from "@ohos.thermal"
import { describe, it, expect } from '@ohos/hypium';
export default function appInfoTest_thermal_4() {
describe('appInfoTest_thermal_4', function () {
console.log("*************Thermal Performance Test Begin*************");
performanceTest1();
performanceTest2();
performanceTest3();
console.log("*************Thermal Performance Test End*************");
})
function performanceTest1() {
let MAXNUM = 1000;
/**
* @tc.number ThermalPerformance_001
* @tc.name test get thermal level
* @tc.desc Thermal acquisition kit
*/
it('ThermalPerformance_001', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
let level = thermal.getThermalLevel();
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime; //us
console.info(`ThermalPerformance_001: Promise: getlevel Wait Time : ${waitTime}`);
})
}
function performanceTest2() {
let MAXNUM = 1000;
/**
* @tc.number ThermalPerformance_002
* @tc.name subscribe thermal level
* @tc.desc Thermal acquisition kit
*/
it('ThermalPerformance_002', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
thermal.subscribeThermalLevel((level) => {
console.info("hot level is: " + level);
})
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime; //us
console.info(`ThermalPerformance_002: Promise: subscribeThermalLevel Wait Time : ${waitTime}`);
})
}
function performanceTest3() {
let MAXNUM = 1000;
/**
* @tc.number ThermalPerformance_002
* @tc.name subscribe thermal level
* @tc.desc Thermal acquisition kit
*/
it('ThermalPerformance_003', 0, function () {
let startTime = new Date().getTime();
for (let i = 0; i < MAXNUM; i++) {
thermal.unsubscribeThermalLevel(() => {
console.info("unsubscribe success.");
});
}
let waitTime = new Date().getTime() - startTime;
let avgTime = waitTime; //us
console.info(`ThermalPerformance_003: Promise: unsubscribeThermalLevel Wait Time : ${waitTime}`);
})
}
}
......@@ -7,6 +7,22 @@
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
......@@ -9,7 +9,7 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
......
......@@ -9,12 +9,12 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsCallManagerIms2CallTest") {
hap_profile = "./entry/src/main/config.json"
hap_profile = "./src/main/config.json"
deps = [
":hjs_demo_js_assets",
":hjs_demo_resources",
......@@ -23,9 +23,11 @@ ohos_js_hap_suite("ActsCallManagerIms2CallTest") {
hap_name = "ActsCallManagerIms2CallTest"
}
ohos_js_assets("hjs_demo_js_assets") {
source_dir = "./entry/src/main/js/default"
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("hjs_demo_resources") {
sources = [ "./entry/src/main/js/resources" ]
hap_profile = "./entry/src/main/config.json"
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for ActsCallManagerIms2CallTest Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "1800000",
"package": "com.ohos.actscallmanagerims2calltest",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"$module.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"description": "Configuration for ActsCallManagerIms2CallTest Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "1800000",
"bundle-name": "com.ohos.actscallmanagerims2calltest",
"package-name": "com.ohos.actscallmanagerims2calltest",
"shell-timeout": "1800000",
"testcase-timeout": "30000"
},
"kits": [
{
"test-file-name": [
"$module.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册