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