提交 5d18ac60 编写于 作者: J jiyong_sd

modified FA-JS

Signed-off-by: Njiyong_sd <jiyong@huawei.com>
Change-Id: I94efe00c1788dec673d88e54dac6664b0052a30c
上级 136d4c6c
文件模式从 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("resourceschedule_backgroundtaskmanager_js_test") {
hap_name = "ActsResourcescheduleTaskMgrTest"
}
ohos_js_assets("resourceschedule_js_assets") {
source_dir = "./src/main/js/default"
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("resourceschedule_js_resources") {
sources = [ "./src/main/resources" ]
......
{
"description": "Configuration for resourceschedule js api Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "300000",
"package": "ohos.acts.resourceschedule.taskmgr.js.function",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsResourcescheduleTaskMgrTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount",
"mkdir /data/test"
]
},
{
"type": "PushKit",
"push": [
"ContinuousTaskRelyHap.hap->/data/test/ContinuousTaskRelyHap.hap"
]
},
{
"type": "ShellKit",
"run-command": [
"bm install -p /data/test/ContinuousTaskRelyHap.hap",
"aa start -a com.example.continuoustaskserver.MainAbility -b com.example.continuoustaskserver"
],
"teardown-command": [
"bm uninstall -n com.example.continuoustaskserver",
"rm -rf data/test"
]
}
]
}
{
"description": "Configuration for resourceschedule js api Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "300000",
"shell-timeout": "300000",
"bundle-name": "ohos.acts.resourceschedule.taskmgr.js.function",
"package-name": "ohos.acts.resourceschedule.taskmgr.js.function"
},
"kits": [
{
"test-file-name": [
"ActsResourcescheduleTaskMgrTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
},
{
"type": "ShellKit",
"run-command": [
"remount",
"mkdir /data/test"
]
},
{
"type": "PushKit",
"push": [
"ContinuousTaskRelyHap.hap->/data/test/ContinuousTaskRelyHap.hap"
]
},
{
"type": "ShellKit",
"run-command": [
"bm install -p /data/test/ContinuousTaskRelyHap.hap",
"aa start -a com.example.continuoustaskserver.MainAbility -b com.example.continuoustaskserver"
],
"teardown-command": [
"bm uninstall -n com.example.continuoustaskserver",
"rm -rf data/test"
]
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "ohos.acts.resourceschedule.taskmgr.js.function",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.resourceschedule.taskmgr.js.function",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"backgroundModes": [
"dataTransfer"
],
"name": "ohos.acts.resourceschedule.taskmgr.js.function.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": false
}
}
],
"reqPermissions": [
{
"name": "ohos.permission.KEEP_BACKGROUND_RUNNING"
}
]
}
}
{
"app": {
"bundleName": "ohos.acts.resourceschedule.taskmgr.js.function",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.resourceschedule.taskmgr.js.function",
"name": ".entry",
"deviceType": [
"phone"
],
"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"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"reqPermissions": [
{
"name": "ohos.permission.KEEP_BACKGROUND_RUNNING"
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"mainAbility": ".MainAbility",
"srcPath": ""
}
}
\ 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 {Core, ExpectExtend} 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()
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) 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.
*/
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() {
},
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('TestApplication onCreate')
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info("TestApplication onDestroy");
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import backgroundTaskManager from '@ohos.backgroundTaskManager'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe("TransientTaskJsTest", function () {
beforeAll(function() {
/*
* @tc.setup: setup invoked before all testcases
*/
console.info('beforeAll caled')
})
afterAll(function() {
/*
* @tc.teardown: teardown invoked after all testcases
*/
console.info('afterAll caled')
})
beforeEach(function() {
/*
* @tc.setup: setup invoked before each testcases
*/
console.info('beforeEach caled')
})
afterEach(function() {
/*
* @tc.teardown: teardown invoked after each testcases
*/
console.info('afterEach caled')
})
/*
* @tc.name: TransientTaskJsTest001
* @tc.desc: test request a suspend delay
* @tc.type: FUNC
* @tc.require:
*/
it("TransientTaskJsTest001", 0, async function (done) {
console.info('----------------------TransientTaskJsTest001---------------------------');
function callback() {}
let info = backgroundTaskManager.requestSuspendDelay("test", callback);
if (info.requestId != -1) {
console.info('TransientTaskJsTest001 backgroundTaskManager success, requestId:' + info.requestId);
expect(true).assertTrue();
backgroundTaskManager.cancelSuspendDelay(info.requestId)
} else {
expect(false).assertTrue();
}
done();
})
/*
* @tc.name: TransientTaskJsTest002
* @tc.desc: test transient task more than three
* @tc.type: FUNC
* @tc.require:
*/
it("TransientTaskJsTest002", 0, async function (done) {
console.info('----------------------TransientTaskJsTest002---------------------------');
function callback() {}
let info1 = backgroundTaskManager.requestSuspendDelay("test", callback);
let info2 = backgroundTaskManager.requestSuspendDelay("test", callback);
let info3 = backgroundTaskManager.requestSuspendDelay("test", callback);
let info4 = backgroundTaskManager.requestSuspendDelay("test", callback);
if (info4.requestId == -1) {
console.info('TransientTaskJsTest002 backgroundTaskManager more than three');
expect(true).assertTrue();
backgroundTaskManager.cancelSuspendDelay(info1.requestId);
backgroundTaskManager.cancelSuspendDelay(info2.requestId);
backgroundTaskManager.cancelSuspendDelay(info3.requestId);
} else {
expect(false).assertTrue();
}
done();
})
/*
* @tc.name: TransientTaskJsTest003
* @tc.desc: test getRemainingDelayTime Promise
* @tc.type: FUNC
* @tc.require:
*/
it("TransientTaskJsTest003", 0, async function (done) {
function callback() {}
let info = backgroundTaskManager.requestSuspendDelay("test", callback);
if (info.requestId != -1) {
console.info('TransientTaskJsTest003 backgroundTaskManager success, requestId:' + info.requestId);
expect(true).assertTrue();
} else {
expect(false).assertTrue();
done();
}
backgroundTaskManager.getRemainingDelayTime(info.requestId)
.then(data => {
console.info('TransientTaskJsTest003 backgroundTaskManager success, delaytime:' + data);
expect(true).assertTrue();
backgroundTaskManager.cancelSuspendDelay(info.requestId);
})
.catch(error => {
console.info('TransientTaskJsTest003 backgroundTaskManager error');
expect(false).assertTrue();
});
setTimeout(()=>{
done();
}, 500);
})
/*
* @tc.name: TransientTaskJsTest004
* @tc.desc: test getRemainingDelayTime Callback
* @tc.type: FUNC
* @tc.require:
*/
it("TransientTaskJsTest004", 0, async function (done) {
function callback() {}
let info = backgroundTaskManager.requestSuspendDelay("test", callback);
if (info.requestId != -1) {
console.info('TransientTaskJsTest004 backgroundTaskManager success, requestId:' + info.requestId);
expect(true).assertTrue();
} else {
expect(false).assertTrue();
done();
}
backgroundTaskManager.getRemainingDelayTime(info.requestId, (err, res) => {
if (!err) {
console.info('TransientTaskJsTest004 backgroundTaskManager success, delaytime:' + res);
expect(true).assertTrue();
} else {
console.info('TransientTaskJsTest004 backgroundTaskManager error');
expect(false).assertTrue();
}
backgroundTaskManager.cancelSuspendDelay(info.requestId)
});
setTimeout(()=>{
done();
}, 500);
})
/*
* @tc.name: TransientTaskJsTest005
* @tc.desc: test request a suspend delay
* @tc.type: FUNC
* @tc.require:
*/
it("TransientTaskJsTest005", 0, async function (done) {
console.info('----------------------TransientTaskJsTest005---------------------------');
function callback() {}
let info = backgroundTaskManager.requestSuspendDelay("test", callback);
if (info.actualDelayTime != -1) {
console.info('TransientTaskJsTest005 backgroundTaskManager success, actualDelayTime:' +
info.actualDelayTime);
expect(true).assertTrue();
backgroundTaskManager.cancelSuspendDelay(info.requestId)
} else {
expect(false).assertTrue();
}
done();
})
/*
* @tc.name: TransientTaskJsTest006
* @tc.desc: test DelaySuspendInfo actualDelayTime
* @tc.type: FUNC
* @tc.require:
*/
it("TransientTaskJsTest006", 0, async function (done) {
console.info('----------------------TransientTaskJsTest006---------------------------');
function callback() {}
let info = backgroundTaskManager.requestSuspendDelay("123456", callback);
if (info.requestId != -1) {
console.info('TransientTaskJsTest006 DelaySuspendInfo actualDelayTime:' +
info.actualDelayTime);
backgroundTaskManager.cancelSuspendDelay(info.requestId);
expect(true).assertTrue();
} else {
expect(false).assertTrue();
}
done();
})
})
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import backgroundTaskManager from '@ohos.backgroundTaskManager'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
export default function TransientTaskJsTest() {
describe("TransientTaskJsTest", function () {
beforeAll(function() {
/*
* @tc.setup: setup invoked before all testcases
*/
console.info('beforeAll caled')
})
afterAll(function() {
/*
* @tc.teardown: teardown invoked after all testcases
*/
console.info('afterAll caled')
})
beforeEach(function() {
/*
* @tc.setup: setup invoked before each testcases
*/
console.info('beforeEach caled')
})
afterEach(function() {
/*
* @tc.teardown: teardown invoked after each testcases
*/
console.info('afterEach caled')
})
/*
* @tc.name: TransientTaskJsTest001
* @tc.desc: test request a suspend delay
* @tc.type: FUNC
* @tc.require:
*/
it("TransientTaskJsTest001", 0, async function (done) {
console.info('----------------------TransientTaskJsTest001---------------------------');
function callback() {}
let info = backgroundTaskManager.requestSuspendDelay("test", callback);
if (info.requestId != -1) {
console.info('TransientTaskJsTest001 backgroundTaskManager success, requestId:' + info.requestId);
expect(true).assertTrue();
backgroundTaskManager.cancelSuspendDelay(info.requestId)
} else {
expect(false).assertTrue();
}
done();
})
/*
* @tc.name: TransientTaskJsTest002
* @tc.desc: test transient task more than three
* @tc.type: FUNC
* @tc.require:
*/
it("TransientTaskJsTest002", 0, async function (done) {
console.info('----------------------TransientTaskJsTest002---------------------------');
function callback() {}
let info1 = backgroundTaskManager.requestSuspendDelay("test", callback);
let info2 = backgroundTaskManager.requestSuspendDelay("test", callback);
let info3 = backgroundTaskManager.requestSuspendDelay("test", callback);
let info4 = backgroundTaskManager.requestSuspendDelay("test", callback);
if (info4.requestId == -1) {
console.info('TransientTaskJsTest002 backgroundTaskManager more than three');
expect(true).assertTrue();
backgroundTaskManager.cancelSuspendDelay(info1.requestId);
backgroundTaskManager.cancelSuspendDelay(info2.requestId);
backgroundTaskManager.cancelSuspendDelay(info3.requestId);
} else {
expect(false).assertTrue();
}
done();
})
/*
* @tc.name: TransientTaskJsTest003
* @tc.desc: test getRemainingDelayTime Promise
* @tc.type: FUNC
* @tc.require:
*/
it("TransientTaskJsTest003", 0, async function (done) {
function callback() {}
let info = backgroundTaskManager.requestSuspendDelay("test", callback);
if (info.requestId != -1) {
console.info('TransientTaskJsTest003 backgroundTaskManager success, requestId:' + info.requestId);
expect(true).assertTrue();
} else {
expect(false).assertTrue();
done();
}
backgroundTaskManager.getRemainingDelayTime(info.requestId)
.then(data => {
console.info('TransientTaskJsTest003 backgroundTaskManager success, delaytime:' + data);
expect(true).assertTrue();
backgroundTaskManager.cancelSuspendDelay(info.requestId);
})
.catch(error => {
console.info('TransientTaskJsTest003 backgroundTaskManager error');
expect(false).assertTrue();
});
setTimeout(()=>{
done();
}, 500);
})
/*
* @tc.name: TransientTaskJsTest004
* @tc.desc: test getRemainingDelayTime Callback
* @tc.type: FUNC
* @tc.require:
*/
it("TransientTaskJsTest004", 0, async function (done) {
function callback() {}
let info = backgroundTaskManager.requestSuspendDelay("test", callback);
if (info.requestId != -1) {
console.info('TransientTaskJsTest004 backgroundTaskManager success, requestId:' + info.requestId);
expect(true).assertTrue();
} else {
expect(false).assertTrue();
done();
}
backgroundTaskManager.getRemainingDelayTime(info.requestId, (err, res) => {
if (!err) {
console.info('TransientTaskJsTest004 backgroundTaskManager success, delaytime:' + res);
expect(true).assertTrue();
} else {
console.info('TransientTaskJsTest004 backgroundTaskManager error');
expect(false).assertTrue();
}
backgroundTaskManager.cancelSuspendDelay(info.requestId)
});
setTimeout(()=>{
done();
}, 500);
})
/*
* @tc.name: TransientTaskJsTest005
* @tc.desc: test request a suspend delay
* @tc.type: FUNC
* @tc.require:
*/
it("TransientTaskJsTest005", 0, async function (done) {
console.info('----------------------TransientTaskJsTest005---------------------------');
function callback() {}
let info = backgroundTaskManager.requestSuspendDelay("test", callback);
if (info.actualDelayTime != -1) {
console.info('TransientTaskJsTest005 backgroundTaskManager success, actualDelayTime:' +
info.actualDelayTime);
expect(true).assertTrue();
backgroundTaskManager.cancelSuspendDelay(info.requestId)
} else {
expect(false).assertTrue();
}
done();
})
/*
* @tc.name: TransientTaskJsTest006
* @tc.desc: test DelaySuspendInfo actualDelayTime
* @tc.type: FUNC
* @tc.require:
*/
it("TransientTaskJsTest006", 0, async function (done) {
console.info('----------------------TransientTaskJsTest006---------------------------');
function callback() {}
let info = backgroundTaskManager.requestSuspendDelay("123456", callback);
if (info.requestId != -1) {
console.info('TransientTaskJsTest006 DelaySuspendInfo actualDelayTime:' +
info.actualDelayTime);
backgroundTaskManager.cancelSuspendDelay(info.requestId);
expect(true).assertTrue();
} else {
expect(false).assertTrue();
}
done();
})
})
}
......@@ -17,10 +17,11 @@ import backgroundTaskManager from '@ohos.backgroundTaskManager';
import featureAbility from '@ohos.ability.featureAbility';
import commonEvent from '@ohos.commonEvent';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium';
const TAG = "ContinuousTaskJsTest ";
export default function ContinuousTaskJsTest() {
describe("ContinuousTaskJsTest", function () {
beforeAll(function() {
......@@ -288,4 +289,4 @@ describe("ContinuousTaskJsTest", function () {
expect(value1).assertEqual(9);
done();
})
})
\ 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.
*/
require('./BackgroundTaskMagrJs.test.js')
require('./ContinuousTaskJsunit.test.js')
/*
* 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 TransientTaskJsTest from './BackgroundTaskMagrJs.test.js'
import ContinuousTaskJsTest from './ContinuousTaskJsunit.test.js'
export default function testsuite() {
TransientTaskJsTest()
ContinuousTaskJsTest()
}
{
"string": [
{
"name": "app_name",
"value": "ResourcescheduleJSApiTest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
{
"string": [
{
"name": "app_name",
"value": "ResourcescheduleJSApiTest"
},
{
"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
/*
* 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 notification from '@ohos.notification';
import featureAbility from '@ohos.ability.featureAbility';
import wantAgent from '@ohos.wantAgent';
import backgroundTaskManager from '@ohos.backgroundTaskManager';
import particleAbility from '@ohos.ability.particleAbility';
import commonEvent from '@ohos.commonEvent';
const TAG = "BGMODE_TEST ";
let event;
let request = {
content: {
contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "title",
text: "text"
}
},
id: 1
};
let wantAgentInfo = {
wants: [
{
bundleName: "com.example.continuoustaskserver",
abilityName: "com.example.continuoustaskserver.MainAbility"
}
],
operationType: wantAgent.OperationType.START_ABILITY,
requestCode: 0,
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
};
function callback(err, data) {
if (err) {
console.error(TAG + " Operation failed");
} else {
console.info(TAG + " Operation succeed");
commonEvent.publish(event, (err) => {
if (err.code) {
console.error(TAG + "PublishCallBack failed");
} else {
console.info(TAG + "Publish succeed");
}
})
}
}
function startContinuousTaskUseApi7Callback() {
event = "startTaskUseApi7Callback";
particleAbility.startBackgroundRunning(1, request, callback);
}
function stopContinuousTaskUseApi7Callback() {
event = "stopTaskUseApi7Callback";
particleAbility.startBackgroundRunning(1, request).then(() => {
particleAbility.cancelBackgroundRunning(callback);
});
}
function startContinuousTaskUseApi8Callback() {
event = "startTaskUseApi8Callback";
wantAgent.getWantAgent(wantAgentInfo).then((data) => {
backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(),
backgroundTaskManager.BackgroundMode.LOCATION, data, callback);
});
}
function stopContinuousTaskUseApi8Callback() {
event = "stopTaskUseApi8Callback";
wantAgent.getWantAgent(wantAgentInfo).then((data) => {
return backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(),
backgroundTaskManager.BackgroundMode.LOCATION, data);
}).then(() => {
backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext(), callback);
});
}
function startContinuousTaskUseApi7Promise() {
particleAbility.startBackgroundRunning(1, request).then(() => {
commonEvent.publish("startTaskUseApi7Promise", (err) => {
if (err.code) {
console.error(TAG + "PublishCallBack failed");
} else {
console.info(TAG + "Publish succeed");
}
});
});
}
function stopContinuousTaskUseApi7Promise() {
particleAbility.startBackgroundRunning(1, request).then(() => {
return particleAbility.cancelBackgroundRunning();
}).then(() => {
commonEvent.publish("stopTaskUseApi7Promise", (err) => {
if (err.code) {
console.error(TAG + "PublishCallBack failed");
} else {
console.info(TAG + "Publish succeed");
}
});
});
}
function startContinuousTaskUseApi8Promise() {
wantAgent.getWantAgent(wantAgentInfo).then((data) => {
return backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(),
backgroundTaskManager.BackgroundMode.LOCATION, data);
}).then(() => {
commonEvent.publish("startTaskUseApi8Promise", (err) => {
if (err.code) {
console.error(TAG + "PublishCallBack failed");
} else {
console.info(TAG + "Publish succeed");
}
});
});
}
function stopContinuousTaskUseApi8Promise() {
wantAgent.getWantAgent(wantAgentInfo).then((data) => {
return backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(),
backgroundTaskManager.BackgroundMode.LOCATION, data);
}).then(() => {
return backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext());
}).then(() => {
commonEvent.publish("stopTaskUseApi8Promise", (err) => {
if (err.code) {
console.error(TAG + "PublishCallBack failed");
} else {
console.info(TAG + "Publish succeed");
}
})
})
}
function startContinuousTaskInvalidBgmode() {
wantAgent.getWantAgent(wantAgentInfo).then((data) => {
return backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(),
backgroundTaskManager.BackgroundMode.BLUETOOTH_INTERACTION, data);
}).catch(() => {
commonEvent.publish("startTaskInvalidBgmode", (err) => {
if (err.code) {
console.error(TAG + "PublishCallBack failed");
} else {
console.info(TAG + "Publish succeed");
}
});
});
}
function handleOption(want) {
switch (want.parameters.option) {
case "testcase1":
startContinuousTaskUseApi7Callback();
break;
case "testcase2":
stopContinuousTaskUseApi7Callback();
break;
case "testcase3":
startContinuousTaskUseApi8Callback();
break;
case "testcase4":
stopContinuousTaskUseApi8Callback();
break;
case "testcase5":
startContinuousTaskUseApi7Promise();
break;
case "testcase6":
stopContinuousTaskUseApi7Promise();
break;
case "testcase7":
startContinuousTaskUseApi8Promise();
break;
case "testcase8":
stopContinuousTaskUseApi8Promise();
break;
case "testcase9":
startContinuousTaskInvalidBgmode();
break;
default:
console.warn(TAG + 'Unknown option');
break;
}
}
export default {
onStart() {
console.info(TAG + 'ServiceAbility onStart');
},
onStop() {
console.info(TAG + 'ServiceAbility onStop');
},
onCommand(want, startId) {
console.info(TAG + 'ServiceAbility onCommand');
console.info(TAG + "Get onCommand want: " + JSON.stringify(want));
particleAbility.cancelBackgroundRunning();
backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext());
handleOption(want);
},
onConnect(want) {
console.info(TAG + 'ServiceAbility onConnect');
},
onDisConnect(want) {
console.info(TAG + 'ServiceAbility onDisConnect');
},
/*
* 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 notification from '@ohos.notification';
import featureAbility from '@ohos.ability.featureAbility';
import wantAgent from '@ohos.wantAgent';
import backgroundTaskManager from '@ohos.backgroundTaskManager';
import particleAbility from '@ohos.ability.particleAbility';
import commonEvent from '@ohos.commonEvent';
const TAG = "BGMODE_TEST ";
let event;
let request = {
content: {
contentType: notification.ContentType.NOTIFICATION_CONTENT_BASIC_TEXT,
normal: {
title: "title",
text: "text"
}
},
id: 1
};
let wantAgentInfo = {
wants: [
{
bundleName: "com.example.continuoustaskserver",
abilityName: "com.example.continuoustaskserver.MainAbility"
}
],
operationType: wantAgent.OperationType.START_ABILITY,
requestCode: 0,
wantAgentFlags: [wantAgent.WantAgentFlags.UPDATE_PRESENT_FLAG]
};
function callback(err, data) {
if (err) {
console.error(TAG + " Operation failed");
} else {
console.info(TAG + " Operation succeed");
commonEvent.publish(event, (err) => {
if (err.code) {
console.error(TAG + "PublishCallBack failed");
} else {
console.info(TAG + "Publish succeed");
}
})
}
}
function startContinuousTaskUseApi7Callback() {
event = "startTaskUseApi7Callback";
particleAbility.startBackgroundRunning(1, request, callback);
}
function stopContinuousTaskUseApi7Callback() {
event = "stopTaskUseApi7Callback";
particleAbility.startBackgroundRunning(1, request).then(() => {
particleAbility.cancelBackgroundRunning(callback);
});
}
function startContinuousTaskUseApi8Callback() {
event = "startTaskUseApi8Callback";
wantAgent.getWantAgent(wantAgentInfo).then((data) => {
backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(),
backgroundTaskManager.BackgroundMode.LOCATION, data, callback);
});
}
function stopContinuousTaskUseApi8Callback() {
event = "stopTaskUseApi8Callback";
wantAgent.getWantAgent(wantAgentInfo).then((data) => {
return backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(),
backgroundTaskManager.BackgroundMode.LOCATION, data);
}).then(() => {
backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext(), callback);
});
}
function startContinuousTaskUseApi7Promise() {
particleAbility.startBackgroundRunning(1, request).then(() => {
commonEvent.publish("startTaskUseApi7Promise", (err) => {
if (err.code) {
console.error(TAG + "PublishCallBack failed");
} else {
console.info(TAG + "Publish succeed");
}
});
});
}
function stopContinuousTaskUseApi7Promise() {
particleAbility.startBackgroundRunning(1, request).then(() => {
return particleAbility.cancelBackgroundRunning();
}).then(() => {
commonEvent.publish("stopTaskUseApi7Promise", (err) => {
if (err.code) {
console.error(TAG + "PublishCallBack failed");
} else {
console.info(TAG + "Publish succeed");
}
});
});
}
function startContinuousTaskUseApi8Promise() {
wantAgent.getWantAgent(wantAgentInfo).then((data) => {
return backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(),
backgroundTaskManager.BackgroundMode.LOCATION, data);
}).then(() => {
commonEvent.publish("startTaskUseApi8Promise", (err) => {
if (err.code) {
console.error(TAG + "PublishCallBack failed");
} else {
console.info(TAG + "Publish succeed");
}
});
});
}
function stopContinuousTaskUseApi8Promise() {
wantAgent.getWantAgent(wantAgentInfo).then((data) => {
return backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(),
backgroundTaskManager.BackgroundMode.LOCATION, data);
}).then(() => {
return backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext());
}).then(() => {
commonEvent.publish("stopTaskUseApi8Promise", (err) => {
if (err.code) {
console.error(TAG + "PublishCallBack failed");
} else {
console.info(TAG + "Publish succeed");
}
})
})
}
function startContinuousTaskInvalidBgmode() {
wantAgent.getWantAgent(wantAgentInfo).then((data) => {
return backgroundTaskManager.startBackgroundRunning(featureAbility.getContext(),
backgroundTaskManager.BackgroundMode.BLUETOOTH_INTERACTION, data);
}).catch(() => {
commonEvent.publish("startTaskInvalidBgmode", (err) => {
if (err.code) {
console.error(TAG + "PublishCallBack failed");
} else {
console.info(TAG + "Publish succeed");
}
});
});
}
function handleOption(want) {
switch (want.parameters.option) {
case "testcase1":
startContinuousTaskUseApi7Callback();
break;
case "testcase2":
stopContinuousTaskUseApi7Callback();
break;
case "testcase3":
startContinuousTaskUseApi8Callback();
break;
case "testcase4":
stopContinuousTaskUseApi8Callback();
break;
case "testcase5":
startContinuousTaskUseApi7Promise();
break;
case "testcase6":
stopContinuousTaskUseApi7Promise();
break;
case "testcase7":
startContinuousTaskUseApi8Promise();
break;
case "testcase8":
stopContinuousTaskUseApi8Promise();
break;
case "testcase9":
startContinuousTaskInvalidBgmode();
break;
default:
console.warn(TAG + 'Unknown option');
break;
}
}
export default {
onStart() {
console.info(TAG + 'ServiceAbility onStart');
},
onStop() {
console.info(TAG + 'ServiceAbility onStop');
},
onCommand(want, startId) {
console.info(TAG + 'ServiceAbility onCommand');
console.info(TAG + "Get onCommand want: " + JSON.stringify(want));
particleAbility.cancelBackgroundRunning();
backgroundTaskManager.stopBackgroundRunning(featureAbility.getContext());
handleOption(want);
},
onConnect(want) {
console.info(TAG + 'ServiceAbility onConnect');
},
onDisConnect(want) {
console.info(TAG + 'ServiceAbility onDisConnect');
},
};
\ 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
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
<div class="container">
<text class="title">
{{title}}
</text>
</div>
<div class="container">
<text class="title">
{{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.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
},
onReady() {
console.info('onReady');
},
/*
* 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.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
},
onShow() {
console.info('onShow finish')
},
onReady() {
console.info('onReady');
},
}
\ No newline at end of file
......@@ -9,7 +9,7 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
......@@ -23,7 +23,9 @@ ohos_js_hap_suite("resourceschedule_deviceusagestatisticsjsunit_js_test") {
hap_name = "ActsResourcescheduleDeviceUsageStatisticsJsunitTest"
}
ohos_js_assets("resourceschedule_js_assets") {
source_dir = "./src/main/js/default"
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("resourceschedule_js_resources") {
sources = [ "./src/main/resources" ]
......
{
"description": "Configuration for resourceschedule js api Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "300000",
"package": "ohos.acts.resourceschedule.deviceusagestatisticsjsunit.js.function",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsResourcescheduleDeviceUsageStatisticsJsunitTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"description": "Configuration for resourceschedule js api Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "300000",
"shell-timeout": "300000",
"bundle-name": "ohos.acts.resourceschedule.deviceusagestatisticsjsunit.js.function",
"package-name": "ohos.acts.resourceschedule.deviceusagestatisticsjsunit.js.function"
},
"kits": [
{
"test-file-name": [
"ActsResourcescheduleDeviceUsageStatisticsJsunitTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "ohos.acts.resourceschedule.deviceusagestatisticsjsunit.js.function",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.resourceschedule.deviceusagestatisticsjsunit.js.function",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "ohos.acts.resourceschedule.deviceusagestatisticsjsunit.js.function.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": false
}
}
],
"defPermissions": [
{
"name": "ohos.permission.BUNDLE_ACTIVE_INFO"
}
],
"reqPermissions": [
{
"name": "ohos.permission.BUNDLE_ACTIVE_INFO"
}
]
}
}
{
"app": {
"bundleName": "ohos.acts.resourceschedule.deviceusagestatisticsjsunit.js.function",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.resourceschedule.deviceusagestatisticsjsunit.js.function",
"name": ".entry",
"deviceType": [
"phone"
],
"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"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"defPermissions": [
{
"name": "ohos.permission.BUNDLE_ACTIVE_INFO"
}
],
"reqPermissions": [
{
"name": "ohos.permission.BUNDLE_ACTIVE_INFO"
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"mainAbility": ".MainAbility",
"srcPath": ""
}
}
\ 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 {Core, ExpectExtend} 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()
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) 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.
*/
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() {
},
}
/*
* 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);
})
}
};
......@@ -14,7 +14,7 @@
*/
import bundlestate from '@ohos.bundleState';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
function onInit() {
let obj = {startTime: 0,endTime: 0};
......@@ -37,6 +37,7 @@ const toMerge = {
"infosBeginTime": 1629907200000,
"infosEndTime": 1629993599999
}
export default function bundlestate() {
describe('bundlestate', function() {
console.info('Start test tvmw bundlestate######################');
beforeAll(function() {
......@@ -507,4 +508,4 @@ describe('bundlestate', function() {
console.info('isIdleState_065 end');
})
})
\ No newline at end of file
})}
......@@ -15,8 +15,9 @@
import bundleState from '@ohos.bundleState'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
export default function DeviceUsageStatisticsJsTest() {
describe("DeviceUsageStatisticsJsTest", function () {
beforeAll(function() {
......@@ -410,4 +411,4 @@ describe("DeviceUsageStatisticsJsTest", function () {
done();
}, 500);
})
})
\ 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.
*/
require('./DeviceUsageStatisticsJsunit.test.js')
require('./BundleState.test.js')
/*
* 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 bundlestate from './BundleState.test.js'
import DeviceUsageStatisticsJsTest from './DeviceUsageStatisticsJsunit.test.js'
export default function testsuite() {
bundlestate()
DeviceUsageStatisticsJsTest()
}
{
"string": [
{
"name": "app_name",
"value": "ResourcescheduleJSApiTest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
{
"string": [
{
"name": "app_name",
"value": "ResourcescheduleJSApiTest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
......@@ -9,7 +9,7 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
......@@ -23,7 +23,9 @@ ohos_js_hap_suite("resourceschedule_reminderagent_js_test") {
hap_name = "ActsResourcescheduleReminderAgentTest"
}
ohos_js_assets("resourceschedule_js_assets") {
source_dir = "./src/main/js/default"
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("resourceschedule_js_resources") {
sources = [ "./src/main/resources" ]
......
{
"description": "Configuration for resourceschedule js api Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "300000",
"package": "ohos.acts.resourceschedule.reminderagent.js.function",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsResourcescheduleReminderAgentTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"description": "Configuration for resourceschedule js api Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "300000",
"shell-timeout": "300000",
"bundle-name": "ohos.acts.resourceschedule.reminderagent.js.function",
"package-name": "ohos.acts.resourceschedule.reminderagent.js.function"
},
"kits": [
{
"test-file-name": [
"ActsResourcescheduleReminderAgentTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "ohos.acts.resourceschedule.reminderagent.js.function",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.resourceschedule.reminderagent.js.function",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "ohos.acts.resourceschedule.reminderagent.js.function.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": false
}
}
],
"reqPermissions": [
{
"name": "ohos.permission.PUBLISH_AGENT_REMINDER",
"reason": "SYSTEM_GRANT",
"usedScene": {
"ability": [
".FormAbility"
],
"when": "inuse"
}
}
]
}
}
{
"app": {
"bundleName": "ohos.acts.resourceschedule.reminderagent.js.function",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.resourceschedule.reminderagent.js.function",
"name": ".entry",
"deviceType": [
"phone"
],
"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"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"pages": [
"pages/index/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
],
"reqPermissions": [
{
"name": "ohos.permission.PUBLISH_AGENT_REMINDER",
"reason": "SYSTEM_GRANT",
"usedScene": {
"ability": [
".FormAbility"
],
"when": "inuse"
}
}
],
"testRunner": {
"name": "OpenHarmonyTestRunner",
"srcPath": "TestRunner"
},
"mainAbility": ".MainAbility",
"srcPath": ""
}
}
\ 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 {Core, ExpectExtend} 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()
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) 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.
*/
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() {
},
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('TestApplication onCreate')
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info("TestApplication onDestroy");
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
/*
* Copyright (C) 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.
*/
require('./ReminderAgentJs.test.js')
/*
* 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 ReminderAgentTest from './ReminderAgentJs.test.js'
export default function testsuite() {
ReminderAgentTest()
}
{
"string": [
{
"name": "app_name",
"value": "ResourcescheduleJSApiTest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
{
"string": [
{
"name": "app_name",
"value": "ResourcescheduleJSApiTest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
},
{
"name": "MainAbility_desc",
"value": "description"
},
{
"name": "MainAbility_label",
"value": "label"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
}
]
}
\ No newline at end of file
......@@ -9,7 +9,7 @@
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import("//test/xts/tools/build/suite.gni")
......@@ -23,7 +23,9 @@ ohos_js_hap_suite("resourceschedule_workscheduler_js_test") {
hap_name = "ActsResourcescheduleWorkSchedulerTest"
}
ohos_js_assets("resourceschedule_js_assets") {
source_dir = "./src/main/js/default"
js2abc = true
hap_profile = "./src/main/config.json"
source_dir = "./src/main/js"
}
ohos_resources("resourceschedule_js_resources") {
sources = [ "./src/main/resources" ]
......
{
"description": "Configuration for resourceschedule js api Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "300000",
"package": "ohos.acts.resourceschedule.workscheduler.js.function",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsResourcescheduleWorkSchedulerTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"description": "Configuration for resourceschedule js api Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "300000",
"shell-timeout": "300000",
"bundle-name": "ohos.acts.resourceschedule.workscheduler.js.function",
"package-name": "ohos.acts.resourceschedule.workscheduler.js.function"
},
"kits": [
{
"test-file-name": [
"ActsResourcescheduleWorkSchedulerTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
\ No newline at end of file
{
"app": {
"bundleName": "ohos.acts.resourceschedule.workscheduler.js.function",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.resourceschedule.workscheduler.js.function",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "ohos.acts.resourceschedule.workscheduler.js.function.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": false
}
}
]
}
}
{
"app": {
"bundleName": "ohos.acts.resourceschedule.workscheduler.js.function",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "ohos.acts.resourceschedule.workscheduler.js.function",
"name": ".entry",
"deviceType": [
"phone"
],
"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"
}
],
"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
/*
* 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 {Core, ExpectExtend} 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()
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) 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.
*/
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() {
},
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from '@ohos/hypium'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('TestApplication onCreate')
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info("TestApplication onDestroy");
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
},
"Files": {
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
},
"Files": {
}
}
\ No newline at end of file
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
}
.title {
font-size: 60px;
text-align: center;
width: 100%;
height: 40%;
margin: 10px;
}
@media screen and (device-type: phone) and (orientation: landscape) {
.title {
font-size: 60px;
}
}
@media screen and (device-type: tablet) and (orientation: landscape) {
.title {
font-size: 100px;
}
}
\ No newline at end of file
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export default {
data: {
title: ""
},
onInit() {
this.title = this.$t('strings.world');
}
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
function translateParamsToString(parameters) {
const keySet = new Set([
'-s class', '-s notClass', '-s suite', '-s itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package', '-s dryRun'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
targetParams += ' ' + key + ' ' + parameters[key]
}
}
return targetParams.trim()
}
export default {
onPrepare() {
console.info('OpenHarmonyTestRunner OnPrepare')
},
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
var abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
var abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.TestAbility'
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters)
var debug = abilityDelegatorArguments.parameters["-D"]
console.info('debug value : '+debug)
if (debug == 'true')
{
cmd += ' -D'
}
console.info('cmd : '+cmd)
abilityDelegator.executeShellCommand(cmd, (err, data) => {
console.info('executeShellCommand : err : ' + JSON.stringify(err));
console.info('executeShellCommand : data : ' + data.stdResult);
console.info('executeShellCommand : data : ' + data.exitCode);
})
}
};
/*
* Copyright (C) 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.
*/
require('./WorkScheduler.test.js')
require('./WorkSchedulerJs.performance.js')
/*
* 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 WorkSchedulerJsTest from './WorkScheduler.test.js'
import WorkSchedulerPerformanceTest from './WorkSchedulerJs.performance.js'
export default function testsuite() {
WorkSchedulerJsTest()
WorkSchedulerPerformanceTest()
}
/*
* 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 workscheduler from '@ohos.workScheduler'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe("WorkSchedulerPerformanceTest", function () {
console.log("**********WorkScheduler Performance Test Begin**********")
performanceStartWork()
performanceStopWork()
performanceGetWorkStatusCallback()
performanceGetWorkStatusPromise()
performanceObtainAllWorksCallback()
performanceObtainAllWorksPromise()
performanceIsLastWorkTimeOutCallback()
performanceIsLastWorkTimeOutPromise()
performanceStopAndClearWorks()
console.log("**********WorkScheduler Performance Test End**********")
})
function performanceStartWork() {
it('WorkSchedulerPerformance_001', 0, async function(done) {
let totalTime = 0
let workInfo = {
workId: 201,
batteryStatus: workscheduler.BatteryStatus.BATTERY_STATUS_LOW,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
let startTime = new Date().getTime()
workscheduler.startWork(workInfo)
totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_001: startWork WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
}
function performanceStopWork() {
it('WorkSchedulerPerformance_002', 0, async function(done) {
let totalTime = 0
let workingInfo = {
workId: 202,
batteryStatus: workscheduler.BatteryStatus.BATTERY_STATUS_LOW,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workingInfo)
let workInfo = {
workId: 202,
batteryStatus: workscheduler.BatteryStatus.BATTERY_STATUS_LOW,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
let startTime = new Date().getTime()
workscheduler.stopWork(workInfo, false)
totalTime= new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_002: stopWork WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
}
function performanceGetWorkStatusCallback() {
it('WorkSchedulerPerformance_003', 0, async function(done) {
let workInfo = {
workId: 203,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
await workscheduler.getWorkStatus(203, (err, res) => {
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_003: getWorkStatus callback WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
})
}
function performanceGetWorkStatusPromise() {
it('WorkSchedulerPerformance_004', 0, async function(done) {
let workInfo = {
workId: 204,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
startTime = new Date().getTime()
await workscheduler.getWorkStatus(204)
.then((res) => {
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_004: getWorkStatus promise WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
.catch((err) => {
done()
})
})
}
function performanceObtainAllWorksCallback() {
it('WorkSchedulerPerformance_005', 0, async function(done) {
let workInfo = {
workId: 205,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
await workscheduler.obtainAllWorks((err, res) => {
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_005: obtainAllWorks callback WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
})
}
function performanceObtainAllWorksPromise() {
it('WorkSchedulerPerformance_006', 0, async function(done) {
let workInfo = {
workId: 206,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
await workscheduler.obtainAllWorks()
.then((res) => {
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_006: obtainAllWorks promise WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
.catch((err) => {
done()
})
})
}
function performanceIsLastWorkTimeOutCallback() {
it('WorkSchedulerPerformance_007', 0, async function(done) {
let workInfo = {
workId: 207,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
await workscheduler.isLastWorkTimeOut(207, (err, res) => {
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_007: isLastWorkTimeOut callback WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
})
}
function performanceIsLastWorkTimeOutPromise() {
it('WorkSchedulerPerformance_008', 0, async function(done) {
let workInfo = {
workId: 208,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
await workscheduler.isLastWorkTimeOut(208)
.then((res) => {
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_008: isLastWorkTimeOut promise WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
.catch((err) => {
done()
})
})
}
function performanceStopAndClearWorks() {
it('WorkSchedulerPerformance_009', 0, function() {
let workInfo = {
workId: 209,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
workscheduler.stopAndClearWorks()
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_009: stopAndClearWorks WaitTime: ' + totalTime + 'ms')
})
}
/*
* 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 workscheduler from '@ohos.workScheduler'
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
export default function WorkSchedulerPerformanceTest() {
describe("WorkSchedulerPerformanceTest", function () {
console.log("**********WorkScheduler Performance Test Begin**********")
performanceStartWork()
performanceStopWork()
performanceGetWorkStatusCallback()
performanceGetWorkStatusPromise()
performanceObtainAllWorksCallback()
performanceObtainAllWorksPromise()
performanceIsLastWorkTimeOutCallback()
performanceIsLastWorkTimeOutPromise()
performanceStopAndClearWorks()
console.log("**********WorkScheduler Performance Test End**********")
})
function performanceStartWork() {
it('WorkSchedulerPerformance_001', 0, async function(done) {
let totalTime = 0
let workInfo = {
workId: 201,
batteryStatus: workscheduler.BatteryStatus.BATTERY_STATUS_LOW,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
let startTime = new Date().getTime()
workscheduler.startWork(workInfo)
totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_001: startWork WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
}
function performanceStopWork() {
it('WorkSchedulerPerformance_002', 0, async function(done) {
let totalTime = 0
let workingInfo = {
workId: 202,
batteryStatus: workscheduler.BatteryStatus.BATTERY_STATUS_LOW,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workingInfo)
let workInfo = {
workId: 202,
batteryStatus: workscheduler.BatteryStatus.BATTERY_STATUS_LOW,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
let startTime = new Date().getTime()
workscheduler.stopWork(workInfo, false)
totalTime= new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_002: stopWork WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
}
function performanceGetWorkStatusCallback() {
it('WorkSchedulerPerformance_003', 0, async function(done) {
let workInfo = {
workId: 203,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
await workscheduler.getWorkStatus(203, (err, res) => {
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_003: getWorkStatus callback WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
})
}
function performanceGetWorkStatusPromise() {
it('WorkSchedulerPerformance_004', 0, async function(done) {
let workInfo = {
workId: 204,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
startTime = new Date().getTime()
await workscheduler.getWorkStatus(204)
.then((res) => {
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_004: getWorkStatus promise WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
.catch((err) => {
done()
})
})
}
function performanceObtainAllWorksCallback() {
it('WorkSchedulerPerformance_005', 0, async function(done) {
let workInfo = {
workId: 205,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
await workscheduler.obtainAllWorks((err, res) => {
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_005: obtainAllWorks callback WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
})
}
function performanceObtainAllWorksPromise() {
it('WorkSchedulerPerformance_006', 0, async function(done) {
let workInfo = {
workId: 206,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
await workscheduler.obtainAllWorks()
.then((res) => {
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_006: obtainAllWorks promise WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
.catch((err) => {
done()
})
})
}
function performanceIsLastWorkTimeOutCallback() {
it('WorkSchedulerPerformance_007', 0, async function(done) {
let workInfo = {
workId: 207,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
await workscheduler.isLastWorkTimeOut(207, (err, res) => {
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_007: isLastWorkTimeOut callback WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
})
}
function performanceIsLastWorkTimeOutPromise() {
it('WorkSchedulerPerformance_008', 0, async function(done) {
let workInfo = {
workId: 208,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
await workscheduler.isLastWorkTimeOut(208)
.then((res) => {
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_008: isLastWorkTimeOut promise WaitTime: ' + totalTime + 'ms')
workscheduler.stopAndClearWorks()
done()
})
.catch((err) => {
done()
})
})
}
function performanceStopAndClearWorks() {
it('WorkSchedulerPerformance_009', 0, function() {
let workInfo = {
workId: 209,
storageRequest: workscheduler.StorageRequest.STORAGE_LEVEL_LOW_OR_OKAY,
bundleName: "ohos.acts.resourceschedule.workscheduler.js.function",
abilityName: "ohos.acts.resourceschedule.workscheduler.js.function.WorkSchedulerAppService"
}
workscheduler.startWork(workInfo)
let startTime = new Date().getTime()
workscheduler.stopAndClearWorks()
let totalTime = new Date().getTime() - startTime
console.info('WorkSchedulerPerformance_009: stopAndClearWorks WaitTime: ' + totalTime + 'ms')
})
}
}
{
"string": [
{
"name": "app_name",
"value": "ResourcescheduleJSApiTest"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
{
"string": [
{
"name": "app_name",
"value": "ResourcescheduleJSApiTest"
},
{
"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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册