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

!7534 fix: 更新电池广播查询枚举为字符串

Merge pull request !7534 from ShiJie/master
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
import commonEvent from '@ohos.commonEvent'; import commonEvent from '@ohos.commonEvent';
import batteryInfo from '@ohos.batteryInfo';
import { describe, it, expect } from '@ohos/hypium' import { describe, it, expect } from '@ohos/hypium'
export default function BatteryCommonEventTest() { export default function BatteryCommonEventTest() {
...@@ -7444,8 +7445,9 @@ function createBatteryChangedSubscriber() { ...@@ -7444,8 +7445,9 @@ function createBatteryChangedSubscriber() {
console.info("commonEventData event: " + commonEventData.event); console.info("commonEventData event: " + commonEventData.event);
console.info("commonEventData bundleName: " + commonEventData.bundleName); console.info("commonEventData bundleName: " + commonEventData.bundleName);
console.info("commonEventData data: " + commonEventData.data); console.info("commonEventData data: " + commonEventData.data);
console.info("commonEventData parameter: " + commonEventData.parameters[0]); let socKey = batteryInfo.CommonEventBatteryChangedKey.EXTRA_SOC;
var capacity = commonEventData.parameters['0']; console.info("commonEventData parameter: " + commonEventData.parameters[socKey]);
var capacity = commonEventData.parameters[socKey];
console.info("capacity is:" + capacity); console.info("capacity is:" + capacity);
expect(capacity >= 0 && capacity <= 100).assertTrue(); expect(capacity >= 0 && capacity <= 100).assertTrue();
}); });
......
...@@ -368,17 +368,6 @@ describe('BatteryUnitTest', function () { ...@@ -368,17 +368,6 @@ describe('BatteryUnitTest', function () {
expect(batteryLevelState == 7).assertTrue(); expect(batteryLevelState == 7).assertTrue();
}) })
/**
* @tc.number SUB_PowerSystem_BatteryManager_JSTest_1820
* @tc.name remainingChargeTime_JSTest
* @tc.desc Battry Present Interface Test
*/
it('remainingChargeTime_JSTest', 0, function () {
let remainingChargeTime = batteryInfo.estimatedRemainingChargeTime;
console.info('remainingChargeTime = ' + remainingChargeTime);
expect(remainingChargeTime >= -1).assertTrue();
})
/** /**
* @tc.number SUB_PowerSystem_BatteryManager_JSTest_1830 * @tc.number SUB_PowerSystem_BatteryManager_JSTest_1830
* @tc.name CommonEventBatteryChangedCode_EXTRA_SOC_JSTest * @tc.name CommonEventBatteryChangedCode_EXTRA_SOC_JSTest
...@@ -386,129 +375,96 @@ describe('BatteryUnitTest', function () { ...@@ -386,129 +375,96 @@ describe('BatteryUnitTest', function () {
*/ */
it('CommonEventBatteryChangedCode_EXTRA_SOC_JSTest', 0, function () { it('CommonEventBatteryChangedCode_EXTRA_SOC_JSTest', 0, function () {
console.info('CommonEventBatteryChangedCode_EXTRA_SOC = ' console.info('CommonEventBatteryChangedCode_EXTRA_SOC = '
+ batteryInfo.CommonEventBatteryChangedCode.EXTRA_SOC); + batteryInfo.CommonEventBatteryChangedKey.EXTRA_SOC);
expect(batteryInfo.CommonEventBatteryChangedCode.EXTRA_SOC == 0).assertTrue(); expect(batteryInfo.CommonEventBatteryChangedKey.EXTRA_SOC == 'soc').assertTrue();
}) })
/** /**
* @tc.number SUB_PowerSystem_BatteryManager_JSTest_1840 * @tc.number SUB_PowerSystem_BatteryManager_JSTest_1940
* @tc.name CommonEventBatteryChangedCode_EXTRA_VOLTAGE_JSTest * @tc.name CommonEventBatteryChangedCode_EXTRA_CHARGE_STATE_JSTest
* @tc.desc Battry Present Interface Test * @tc.desc Battry Present Interface Test
*/ */
it('CommonEventBatteryChangedCode_EXTRA_VOLTAGE_JSTest', 0, function () { it('CommonEventBatteryChangedCode_EXTRA_CHARGE_STATE_JSTest', 0, function () {
console.info('CommonEventBatteryChangedCode_EXTRA_VOLTAGE = ' console.info('CommonEventBatteryChangedCode_EXTRA_CHARGE_STATE = '
+ batteryInfo.CommonEventBatteryChangedCode.EXTRA_VOLTAGE); + batteryInfo.CommonEventBatteryChangedKey.EXTRA_CHARGE_STATE);
expect(batteryInfo.CommonEventBatteryChangedCode.EXTRA_VOLTAGE == 1).assertTrue(); expect(batteryInfo.CommonEventBatteryChangedKey.EXTRA_CHARGE_STATE == 'chargeState').assertTrue();
}) })
/** /**
* @tc.number SUB_PowerSystem_BatteryManager_JSTest_1850 * @tc.number SUB_PowerSystem_BatteryManager_JSTest_1850
* @tc.name CommonEventBatteryChangedCode_EXTRA_TEMPERATURE_JSTest
* @tc.desc Battry Present Interface Test
*/
it('CommonEventBatteryChangedCode_EXTRA_TEMPERATURE_JSTest', 0, function () {
console.info('CommonEventBatteryChangedCode_EXTRA_TEMPERATURE = '
+ batteryInfo.CommonEventBatteryChangedCode.EXTRA_TEMPERATURE);
expect(batteryInfo.CommonEventBatteryChangedCode.EXTRA_TEMPERATURE == 2).assertTrue();
})
/**
* @tc.number SUB_PowerSystem_BatteryManager_JSTest_1860
* @tc.name CommonEventBatteryChangedCode_EXTRA_HEALTH_STATE_JSTest * @tc.name CommonEventBatteryChangedCode_EXTRA_HEALTH_STATE_JSTest
* @tc.desc Battry Present Interface Test * @tc.desc Battry Present Interface Test
*/ */
it('CommonEventBatteryChangedCode_EXTRA_HEALTH_STATE_JSTest', 0, function () { it('CommonEventBatteryChangedCode_EXTRA_HEALTH_STATE_JSTest', 0, function () {
console.info('CommonEventBatteryChangedCode_EXTRA_HEALTH_STATE = ' console.info('CommonEventBatteryChangedCode_EXTRA_HEALTH_STATE = '
+ batteryInfo.CommonEventBatteryChangedCode.EXTRA_HEALTH_STATE); + batteryInfo.CommonEventBatteryChangedKey.EXTRA_HEALTH_STATE);
expect(batteryInfo.CommonEventBatteryChangedCode.EXTRA_HEALTH_STATE == 3).assertTrue(); expect(batteryInfo.CommonEventBatteryChangedKey.EXTRA_HEALTH_STATE == 'healthState').assertTrue();
}) })
/** /**
* @tc.number SUB_PowerSystem_BatteryManager_JSTest_1870 * @tc.number SUB_PowerSystem_BatteryManager_JSTest_1860
* @tc.name CommonEventBatteryChangedCode_EXTRA_PLUGGED_TYPE_JSTest * @tc.name CommonEventBatteryChangedCode_EXTRA_PLUGGED_TYPE_JSTest
* @tc.desc Battry Present Interface Test * @tc.desc Battry Present Interface Test
*/ */
it('CommonEventBatteryChangedCode_EXTRA_PLUGGED_TYPE_JSTest', 0, function () { it('CommonEventBatteryChangedCode_EXTRA_PLUGGED_TYPE_JSTest', 0, function () {
console.info('CommonEventBatteryChangedCode_EXTRA_PLUGGED_TYPE = ' console.info('CommonEventBatteryChangedCode_EXTRA_PLUGGED_TYPE = '
+ batteryInfo.CommonEventBatteryChangedCode.EXTRA_PLUGGED_TYPE); + batteryInfo.CommonEventBatteryChangedKey.EXTRA_PLUGGED_TYPE);
expect(batteryInfo.CommonEventBatteryChangedCode.EXTRA_PLUGGED_TYPE == 4).assertTrue(); expect(batteryInfo.CommonEventBatteryChangedKey.EXTRA_PLUGGED_TYPE == 'pluggedType').assertTrue();
})
/**
* @tc.number SUB_PowerSystem_BatteryManager_JSTest_1880
* @tc.name CommonEventBatteryChangedCode_EXTRA_MAX_CURRENT_JSTest
* @tc.desc Battry Present Interface Test
*/
it('CommonEventBatteryChangedCode_EXTRA_MAX_CURRENT_JSTest', 0, function () {
console.info('CommonEventBatteryChangedCode_EXTRA_MAX_CURRENT = '
+ batteryInfo.CommonEventBatteryChangedCode.EXTRA_MAX_CURRENT);
expect(batteryInfo.CommonEventBatteryChangedCode.EXTRA_MAX_CURRENT == 5).assertTrue();
}) })
/** /**
* @tc.number SUB_PowerSystem_BatteryManager_JSTest_1890 * @tc.number SUB_PowerSystem_BatteryManager_JSTest_1870
* @tc.name CommonEventBatteryChangedCode_EXTRA_MAX_VOLTAGE_JSTest * @tc.name CommonEventBatteryChangedCode_EXTRA_VOLTAGE_JSTest
* @tc.desc Battry Present Interface Test * @tc.desc Battry Present Interface Test
*/ */
it('CommonEventBatteryChangedCode_EXTRA_MAX_VOLTAGE_JSTest', 0, function () { it('CommonEventBatteryChangedCode_EXTRA_VOLTAGE_JSTest', 0, function () {
console.info('CommonEventBatteryChangedCode_EXTRA_MAX_VOLTAGE = ' console.info('CommonEventBatteryChangedCode_EXTRA_VOLTAGE = '
+ batteryInfo.CommonEventBatteryChangedCode.EXTRA_MAX_VOLTAGE); + batteryInfo.CommonEventBatteryChangedKey.EXTRA_VOLTAGE);
expect(batteryInfo.CommonEventBatteryChangedCode.EXTRA_MAX_VOLTAGE == 6).assertTrue(); expect(batteryInfo.CommonEventBatteryChangedKey.EXTRA_VOLTAGE == 'voltage').assertTrue();
}) })
/** /**
* @tc.number SUB_PowerSystem_BatteryManager_JSTest_1900 * @tc.number SUB_PowerSystem_BatteryManager_JSTest_1880
* @tc.name CommonEventBatteryChangedCode_EXTRA_CHARGE_STATE_JSTest * @tc.name CommonEventBatteryChangedCode_EXTRA_TECHNOLOGY_JSTest
* @tc.desc Battry Present Interface Test * @tc.desc Battry Present Interface Test
*/ */
it('CommonEventBatteryChangedCode_EXTRA_CHARGE_STATE_JSTest', 0, function () { it('CommonEventBatteryChangedCode_EXTRA_TECHNOLOGY_JSTest', 0, function () {
console.info('CommonEventBatteryChangedCode_EXTRA_CHARGE_STATE = ' console.info('CommonEventBatteryChangedCode_EXTRA_TECHNOLOGY = '
+ batteryInfo.CommonEventBatteryChangedCode.EXTRA_CHARGE_STATE); + batteryInfo.CommonEventBatteryChangedKey.EXTRA_TECHNOLOGY);
expect(batteryInfo.CommonEventBatteryChangedCode.EXTRA_CHARGE_STATE == 7).assertTrue(); expect(batteryInfo.CommonEventBatteryChangedKey.EXTRA_TECHNOLOGY == 'technology').assertTrue();
}) })
/** /**
* @tc.number SUB_PowerSystem_BatteryManager_JSTest_1910 * @tc.number SUB_PowerSystem_BatteryManager_JSTest_1890
* @tc.name CommonEventBatteryChangedCode_EXTRA_CHARGE_COUNTER_JSTest * @tc.name CommonEventBatteryChangedCode_EXTRA_TEMPERATURE_JSTest
* @tc.desc Battry Present Interface Test * @tc.desc Battry Present Interface Test
*/ */
it('CommonEventBatteryChangedCode_EXTRA_CHARGE_COUNTER_JSTest', 0, function () { it('CommonEventBatteryChangedCode_EXTRA_TEMPERATURE_JSTest', 0, function () {
console.info('CommonEventBatteryChangedCode_EXTRA_CHARGE_COUNTER = ' console.info('CommonEventBatteryChangedCode_EXTRA_TEMPERATURE = '
+ batteryInfo.CommonEventBatteryChangedCode.EXTRA_CHARGE_COUNTER); + batteryInfo.CommonEventBatteryChangedKey.EXTRA_TEMPERATURE);
expect(batteryInfo.CommonEventBatteryChangedCode.EXTRA_CHARGE_COUNTER == 8).assertTrue(); expect(batteryInfo.CommonEventBatteryChangedKey.EXTRA_TEMPERATURE == 'temperature').assertTrue();
}) })
/** /**
* @tc.number SUB_PowerSystem_BatteryManager_JSTest_1920 * @tc.number SUB_PowerSystem_BatteryManager_JSTest_1900
* @tc.name CommonEventBatteryChangedCode_EXTRA_PRESENT_JSTest * @tc.name CommonEventBatteryChangedCode_EXTRA_PRESENT_JSTest
* @tc.desc Battry Present Interface Test * @tc.desc Battry Present Interface Test
*/ */
it('CommonEventBatteryChangedCode_EXTRA_PRESENT_JSTest', 0, function () { it('CommonEventBatteryChangedCode_EXTRA_PRESENT_JSTest', 0, function () {
console.info('CommonEventBatteryChangedCode_EXTRA_PRESENT = ' console.info('CommonEventBatteryChangedCode_EXTRA_PRESENT = '
+ batteryInfo.CommonEventBatteryChangedCode.EXTRA_PRESENT); + batteryInfo.CommonEventBatteryChangedKey.EXTRA_PRESENT);
expect(batteryInfo.CommonEventBatteryChangedCode.EXTRA_PRESENT == 9).assertTrue(); expect(batteryInfo.CommonEventBatteryChangedKey.EXTRA_PRESENT == 'present').assertTrue();
})
/**
* @tc.number SUB_PowerSystem_BatteryManager_JSTest_1930
* @tc.name CommonEventBatteryChangedCode_EXTRA_TECHNOLOGY_JSTest
* @tc.desc Battry Present Interface Test
*/
it('CommonEventBatteryChangedCode_EXTRA_TECHNOLOGY_JSTest', 0, function () {
console.info('CommonEventBatteryChangedCode_EXTRA_TECHNOLOGY = '
+ batteryInfo.CommonEventBatteryChangedCode.EXTRA_TECHNOLOGY);
expect(batteryInfo.CommonEventBatteryChangedCode.EXTRA_TECHNOLOGY == 10).assertTrue();
}) })
/** /**
* @tc.number SUB_PowerSystem_BatteryManager_JSTest_1940 * @tc.number SUB_PowerSystem_BatteryManager_JSTest_1910
* @tc.name CommonEventBatteryChangedCode_CAPACITY_LEVEL_JSTest * @tc.name CommonEventBatteryChangedCode_CAPACITY_LEVEL_JSTest
* @tc.desc Battry Present Interface Test * @tc.desc Battry Present Interface Test
*/ */
it('CommonEventBatteryChangedCode_CAPACITY_LEVEL_JSTest', 0, function () { it('CommonEventBatteryChangedCode_CAPACITY_LEVEL_JSTest', 0, function () {
console.info('CommonEventBatteryChangedCode_CAPACITY_LEVEL = ' console.info('CommonEventBatteryChangedCode_CAPACITY_LEVEL = '
+ batteryInfo.CommonEventBatteryChangedCode.EXTRA_CAPACITY_LEVEL); + batteryInfo.CommonEventBatteryChangedKey.EXTRA_CAPACITY_LEVEL);
expect(batteryInfo.CommonEventBatteryChangedCode.EXTRA_CAPACITY_LEVEL == 11).assertTrue(); expect(batteryInfo.CommonEventBatteryChangedKey.EXTRA_CAPACITY_LEVEL == 'capacityLevel').assertTrue();
}) })
}) })
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册