提交 a56ee4f7 编写于 作者: S ShiJie

add batterystats xts

Signed-off-by: NShiJie <shijie20@huawei.com>
Change-Id: I7af139a50021b54d2901cb2933cfa4dc4abe568f
上级 b6dc84b1
# 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("powermgr_batterystats_test") {
hap_profile = "./src/main/config.json"
deps = [
":powermgr_batterystats_js_assets",
":powermgr_batterystats_resources",
]
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsPowerMgrBatterystatsTest"
}
ohos_js_assets("powermgr_batterystats_js_assets") {
source_dir = "./src/main/js/default"
}
ohos_resources("powermgr_batterystats_resources") {
sources = [ "./src/main/resources" ]
hap_profile = "./src/main/config.json"
}
{
"description": "Configuration for powermgr batterystats Tests",
"driver": {
"type": "JSUnitTest",
"test-timeout": "60000",
"package": "com.example.mybatterystatsapp",
"shell-timeout": "60000"
},
"kits": [
{
"test-file-name": [
"ActsPowerMgrBatterystatsTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.example.mybatterystatsapp",
"vendor": "example",
"version": {
"code": 1,
"name": "1.0"
},
"apiVersion": {
"compatible": 4,
"target": 5
}
},
"deviceConfig": {},
"module": {
"package": "com.example.mybatterystatsapp",
"name": ".MyApplication",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry"
},
"abilities": [
{
"visible": true,
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"name": "com.example.mybatterystatsapp.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:app_name",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"pages": [
"pages/index/index"
],
"name": "default",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
/*
* 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 device from '@system.device';
export default {
onCreate() {
console.info('AceApplication onCreate');
},
onDestroy() {
console.info('AceApplication onDestroy');
}
};
{
"strings": {
"hello": "Hello",
"world": "World"
}
}
\ No newline at end of file
{
"strings": {
"hello": "您好",
"world": "世界"
}
}
\ No newline at end of file
.container {
flex-direction: column;
justify-content: center;
align-items: center;
}
.title {
font-size: 100px;
}
<div class="container">
<text class="title">
{{ $t('strings.hello') }} {{ title }}
</text>
</div>
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import app from '@system.app'
//import {Core, ExpectExtend, ReportExtend, InstrumentLog} from 'deccjsunit/index'
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
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require('./batterystats_uint.test.js')
\ No newline at end of file
/*
* Copyright (C) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import app from '@system.app'
import batterystats from "@ohos.batterystats"
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
describe('appInfoTest', function () {
console.log("*************Batterystats API Test Begin*************");
const MSEC_1000 = 1000;
const MSEC_10000 = 10000;
/**
/* @tc.number batterystats_js_001
* @tc.name Batterystats_001
* @tc.desc BatteryStats getBatteryStats Interface Test type = -2
*/
it('Batterystats_001', 0, async function (done) {
console.info("enter");
var getBatteryStats;
let promise = batteryStats.getBatteryStats().then(function (value) {
getBatteryStats = value;
console.info("ing");
}, function (msg) {
console.info("Promise获取的异常值:" + msg);
});
await promise;
console.info("wait");
var found = false;
for (let i = 0; i < getBatteryStats.length; i++) {
if (getBatteryStats[i].type === -2) {
found = true;
}
}
done();
console.info("found:" + found);
expect(found).assertEqual(true);
})
/* @tc.number batterystats_js_002
* @tc.name Batterystats_002
* @tc.desc BatteryStats getAppPowerValue Interface Test uid = 111
*/
it('Batterystats_002', 0, async function (done) {
console.info("enter");
await new Promise((resolve, reject) =>{
setTimeout(()=>{
var power = batterystats.getAppPowerValue(111);
console.info("power is: " + power);
expect(cold >= 0).assertEqual('1');
resolve();
}, MSEC_10000);
})
done();
})
/* @tc.number batterystats_js_003
* @tc.name Batterystats_003
* @tc.desc BatteryStats getAppPowerPercent Interface Test uid = 111
*/
it('Batterystats_003', 0, async function (done) {
console.info("enter");
await new Promise((resolve, reject) =>{
setTimeout(()=>{
var powerPercent = batterystats.getAppPowerPercent(111);
console.info("percent is: " + powerPercent);
expect(cold >= 0).assertEqual('1');
resolve();
}, MSEC_10000);
})
done();
})
/* @tc.number batterystats_js_004
* @tc.name Batterystats_004
* @tc.desc BatteryStats getHardwareUnitPowerValue Interface Test type = -14
*/
it('Batterystats_004', 0, async function (done) {
console.info("enter");
await new Promise((resolve, reject) =>{
setTimeout(()=>{
var power = batterystats.getAppPowerValue(batterystats.StatsType.CONSUMPTION_TYPE_IDLE);
console.info("power is: " + power);
expect(cold >= 0).assertEqual('1');
resolve();
}, MSEC_10000);
})
done();
})
/* @tc.number batterystats_js_005
* @tc.name Batterystats_005
* @tc.desc BatteryStats getHardwareUnitPowerPercent Interface Test type = -14
*/
it('Batterystats_005', 0, async function (done) {
console.info("enter");
await new Promise((resolve, reject) =>{
setTimeout(()=>{
var percent = batterystats.getHardwareUnitPowerPercent(batterystats.StatsType.CONSUMPTION_TYPE_IDLE);
console.info("percent is: " + percent);
expect(cold >= 0).assertEqual('1');
resolve();
}, MSEC_10000);
})
done();
})
})
\ No newline at end of file
{
"string": [
{
"name": "app_name",
"value": "MyBatterystatsApp"
},
{
"name": "mainability_description",
"value": "JS_Phone_Empty Feature Ability"
}
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册