提交 a52e9ff8 编写于 作者: J jiyong_sd

Adapt to the new framework

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