提交 39067c8e 编写于 作者: Q qiuxiangdong

test: Added the use case of changing an interface

Signed-off-by: Nqiuxiangdong <qiuxiangdong3@huawei.com>
上级 6c9a87b8
......@@ -134,44 +134,6 @@ describe('PowerManagerPowerTest', function () {
}, 2000);
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0050
* @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()
.then(powerMode => {
console.info('Power_Get_PowerMode_Callback_JSTest0050 power mode is ' + powerMode);
expect(powerMode >= 600 && powerMode <= 603).assertTrue();
done();
})
.catch(error => {
console.log('Power_Get_PowerMode_Callback_JSTest0050 error: ' + error);
expect().assertFail();
done();
})
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0060
* @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) => {
if (typeof error === "undefined") {
console.info('Power_Get_PowerMode_Promise_JSTest0060 power mode is ' + powerMode);
expect(powerMode >= 600 && powerMode <= 603).assertTrue();
done();
} else {
console.log('Power_Get_PowerMode_Promise_JSTest0060: ' + error);
expect().assertFail();
done();
}
})
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0070
* @tc.name Power_Device_Power_Mode_MODENORMAL_JSTest0070
......@@ -215,5 +177,186 @@ describe('PowerManagerPowerTest', function () {
console.info('MODE_EXTREME_POWER_SAVE = ' + devicePowerMode);
expect(devicePowerMode === 603).assertTrue();
})
// New interface
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0110
* @tc.name Power_Get_Set_Mode_Promise_JSTest0110
* @tc.desc Gets and sets the power mode
*/
it('Power_Get_Set_Mode_Promise_JSTest0110', 0, async function (done) {
let currentMode = power.getPowerMode();
console.info('Power_Get_Set_Mode_Promise_JSTest0110 currentMode:' + currentMode);
expect(currentMode >= power.DevicePowerMode.MODE_NORMAL &&
currentMode <= power.DevicePowerMode.MODE_EXTREME_POWER_SAVE).assertTrue();
try {
let isExec = false;
power.setPowerMode(power.DevicePowerMode.MODE_POWER_SAVE)
.then((error) => {
isExec = true;
console.info('Power_Get_Set_Mode_Promise_JSTest0110 error:' + (typeof error));
expect(typeof error === "undefined").assertTrue();
let mode = power.getPowerMode();
console.info('Power_Get_Set_Mode_Promise_JSTest0110 mode:' + mode);
expect(mode === power.DevicePowerMode.MODE_POWER_SAVE).assertTrue();
}).finally(() => {
expect(isExec).assertTrue();
})
} catch (e) {
console.info('Power_Get_Set_Mode_Promise_JSTest0110 error:' + e);
expect().assertFail();
}
power.setPowerMode(currentMode);
done();
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0120
* @tc.name Power_Get_Set_Mode_Promise_Invalid_JSTest0120
* @tc.desc Set the wrong power mode
*/
it('Power_Get_Set_Mode_Promise_Invalid_JSTest0120', 0, async function (done) {
try {
// invalid mode
power.setPowerMode('').then(() => {
console.info('Power_Get_Set_Mode_Promise_Invalid_JSTest0120 string failed');
expect().assertFail();
})
} catch (e) {
console.info('Power_Get_Set_Mode_Promise_Invalid_JSTest0120 code:' + e.code + 'msg:' + e.message);
// 401: Invalid input parameter
expect(e.code === 401).assertTrue();
}
try {
// Number of invalid parameters
power.setPowerMode('', '', 0).then(() => {
console.info('Power_Get_Set_Mode_Promise_Invalid_JSTest0120 number failed');
expect().assertFail();
})
} catch (e) {
console.info('Power_Get_Set_Mode_Promise_Invalid_JSTest0120 code:' + e.code + 'msg:' + e.message);
// 401: Invalid input parameter
expect(e.code === 401).assertTrue();
}
done();
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0130
* @tc.name Power_Get_Set_Mode_Callback_JSTest0130
* @tc.desc Gets and sets the power mode
*/
it('Power_Get_Set_Mode_Callback_JSTest0130', 0, async function (done) {
let currentMode = power.getPowerMode();
console.info('Power_Get_Set_Mode_Callback_JSTest0130 currentMode:' + currentMode);
expect(currentMode >= power.DevicePowerMode.MODE_NORMAL &&
currentMode <= power.DevicePowerMode.MODE_EXTREME_POWER_SAVE).assertTrue();
try {
power.setPowerMode(power.DevicePowerMode.MODE_PERFORMANCE, (error) => {
console.info('Power_Get_Set_Mode_Callback_JSTest0130 error:' + (typeof error));
expect(typeof error === "undefined").assertTrue();
let mode = power.getPowerMode();
console.info('Power_Get_Set_Mode_Callback_JSTest0130 mode:' + mode);
expect(mode === power.DevicePowerMode.MODE_PERFORMANCE).assertTrue();
})
} catch (e) {
console.info('Power_Get_Set_Mode_Callback_JSTest0130 error:' + e);
expect().assertFail();
}
power.setPowerMode(currentMode);
done();
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0140
* @tc.name Power_Get_Set_Mode_Callback_Invalid_JSTest0140
* @tc.desc Set the wrong power mode
*/
it('Power_Get_Set_Mode_Callback_Invalid_JSTest0140', 0, async function (done) {
try {
// invalid mode
power.setPowerMode('', (error) => {
expect().assertFail();
})
} catch (e) {
console.info('Power_Get_Set_Mode_Callback_Invalid_JSTest0140 code:' + e.code + 'msg:' + e.message);
// 401: Invalid input parameter
expect(e.code === 401).assertTrue();
}
try {
// invalid callback
power.setPowerMode(power.DevicePowerMode.MODE_PERFORMANCE, '')
} catch (e) {
console.info('Power_Get_Set_Mode_Callback_Invalid_JSTest0140 code:' + e.code + 'msg:' + e.message);
// 401: Invalid input parameter
expect(e.code === 401).assertTrue();
}
done();
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0150
* @tc.name Power_Reboot_JSTest0150
* @tc.desc reboot
*/
it('Power_Reboot_JSTest0150', 0, function () {
// Reboot tests are not performed by default
if (false) {
try {
power.reboot('Power_Reboot_JSTest0150');
} catch (e) {
console.info('Power_Reboot_JSTest0150 error:' + e);
expect().assertFail();
}
}
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0160
* @tc.name Power_Wakeup_Suspend_IsActive_JSTest0160
* @tc.desc On and Off Screen and get the current screen on and off
*/
it('Power_Wakeup_Suspend_IsActive_JSTest0160', 0, function () {
try {
power.suspend();
power.wakeup('wakeup_suspend_isPower_Wakeup_Suspend_IsActive_JSTest0160_active');
let on = power.isActive();
console.info('Power_Wakeup_Suspend_IsActive_JSTest0160 on:' + on);
expect(on).assertTrue();
power.suspend();
let off = power.isActive();
console.info('Power_Wakeup_Suspend_IsActive_JSTest0160 off:' + off);
expect(off).assertFalse();
} catch (e) {
console.info('Power_Wakeup_Suspend_IsActive_JSTest0160:' + e);
expect().assertFail();
}
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0170
* @tc.name Power_Wakeup_Invalid_JSTest0170
* @tc.desc wakeup Input invalid parameter
*/
it('Power_Wakeup_Invalid_JSTest0170', 0, function () {
try {
power.wakeup(0)
} catch (e) {
console.info('Power_Wakeup_Invalid_JSTest0170 code:' + e.code + "msg:" + e.message);
// 401: Invalid input parameter
expect(e.code === 401).assertTrue();
}
try {
// The number of parameters does not match
power.wakeup('', 0)
} catch (e) {
console.info('Power_Wakeup_Invalid_JSTest0170 code:' + e.code + "msg:" + e.message);
// 401: Invalid input parameter
expect(e.code === 401).assertTrue();
}
})
})
}
......@@ -229,5 +229,119 @@ describe('PowerManagerRunningLockTest', function () {
}
})
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0210
* @tc.name Create_Running_Lock_Promise_JSTest0210
* @tc.desc Create lock, hold lock, unlock
*/
it('Create_Running_Lock_Promise_JSTest0210', 0, async function (done) {
try {
let isExec = false;
runningLock.create("Create_Running_Lock_Promise_JSTest0210", runningLock.RunningLockType.BACKGROUND)
.then((error, runninglock) => {
isExec = true;
expect(typeof error === "undefined").assertTrue();
expect(runninglock !== null).assertTrue();
let holding = runninglock.isHolding();
console.info('Create_Running_Lock_Promise_JSTest0210 holding false:' + holding);
expect(holding).assertFalse();
runninglock.hold(1000); // hold 1000ms
holding = runninglock.isHolding();
console.info('Create_Running_Lock_Promise_JSTest0210 holding true:' + holding);
expect(holding).assertTrue();
runninglock.unhold();
expect(runninglock.isHolding()).assertFalse();
}).finally(() => {
expect(isExec).assertTrue();
})
} catch (e) {
console.info('Create_Running_Lock_Promise_JSTest0210 error:' + e);
expect().assertFail();
}
done();
})
// New interface
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0220
* @tc.name Create_Running_Lock_Promise_Invalid_JSTest0220
* @tc.desc Create lock input invalid value
*/
it('Create_Running_Lock_Promise_Invalid_JSTest0220', 0, async function (done) {
try {
runningLock.create(0, runningLock.RunningLockType.BACKGROUND)
.then((error, runninglock) => {
expect().assertFail();
})
} catch (e) {
console.info('Create_Running_Lock_Promise_Invalid_JSTest0220 code:' + e.code + "msg:" + e.message);
// 401: Invalid input parameter
expect(e.code === 401).assertTrue();
}
done();
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0230
* @tc.name Create_Running_Lock_Callback_JSTest0230
* @tc.desc Create lock, hold lock, unlock
*/
it('Create_Running_Lock_Callback_JSTest0230', 0, async function (done) {
try {
runningLock.create("Create_Running_Lock_Callback_JSTest0230", runningLock.RunningLockType.BACKGROUND,
(error, runninglock) => {
expect(typeof error === "undefined").assertTrue();
expect(runninglock !== null).assertTrue();
runninglock.hold(1000); // hold 1000ms
let holding = runninglock.isHolding();
console.info('Create_Running_Lock_Callback_JSTest0230 holding true:' + holding);
expect(holding).assertTrue();
runninglock.unhold();
holding = runninglock.isHolding();
expect(holding).assertFalse();
console.info('Create_Running_Lock_Callback_JSTest0230 holding false:' + holding);
});
} catch (e) {
console.info('Create_Running_Lock_Callback_JSTest0230 error:' + e);
expect().assertFail();
}
done();
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0240
* @tc.name Create_Running_Lock_Callback_Invalid_JSTest0240
* @tc.desc Create lock input invalid value
*/
it('Create_Running_Lock_Callback_Invalid_JSTest0240', 0, async function (done) {
try {
runningLock.create("Create_Running_Lock_Callback_Invalid_JSTest0240", "invalid",
(error, runninglock) => {
expect().assertFail();
});
} catch (e) {
console.info('Create_Running_Lock_Callback_Invalid_JSTest0240 code:' + e.code + "msg:" + e.message);
// 401: Invalid input parameter
expect(e.code === 401).assertTrue();
}
done();
})
/**
* @tc.number SUB_PowerSystem_PowerManager_JSTest_0250
* @tc.name Is_Supported_JSTest0250
* @tc.desc Checks whether the specified RunningLockType is supported.
*/
it('Is_Supported_JSTest0250', 0, async function (done) {
try {
let background = runningLock.isSupported(runningLock.RunningLockType.BACKGROUND)
expect(background).assertTrue();
} catch (e) {
console.info('Is_Supported_JSTest0250 code:' + e);
expect().assertFail();
}
done();
})
})
}
......@@ -134,5 +134,87 @@ describe('ThermalUnitTest', function () {
console.info('ThermalLevel.EMERGENCY = ' + thermalLevel);
expect(thermalLevel === 6).assertTrue();
})
/* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0100
* @tc.name Get_Level_JSTest0100
* @tc.desc Thermal acquisition kit
*/
it('Get_Level_JSTest0100', 0, async function (done) {
let level = thermal.getLevel();
console.info("Get_Level_JSTest0100 level is: " + level);
expect(level >= thermal.ThermalLevel.COOL && level <= thermal.ThermalLevel.EMERGENCY).assertTrue();
done();
})
/* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0110
* @tc.name Register_Thermal_Level_Callback_JSTest0110
* @tc.desc Thermal acquisition kit
*/
it('Register_Thermal_Level_Callback_JSTest0110', 0, async function (done) {
try {
thermal.registerThermalLevelCallback((value) => {
console.info("Register_Thermal_Level_Callback_JSTest0110 level is: " + value);
let level = thermal.getLevel();
expect(level === value).assertTrue();
})
} catch (error) {
console.info('Register_Thermal_Level_Callback_JSTest0110:' + error);
expect().assertFail();
}
done();
})
/* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0120
* @tc.name Register_Thermal_Level_Callback_JSTest0120
* @tc.desc Thermal acquisition kit
*/
it('Register_Thermal_Level_Callback_JSTest0120', 0, async function (done) {
try {
thermal.registerThermalLevelCallback('')
} catch (error) {
console.info('Register_Thermal_Level_Callback_JSTest0120 error:' + error);
// 401: Invalid input parameter
expect(error.code === 401).assertTrue();
}
done();
})
/* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0130
* @tc.name UnRegister_Thermal_Level_Callback_JSTest0130
* @tc.desc Thermal acquisition kit
*/
it('UnRegister_Thermal_Level_Callback_JSTest0130', 0, async function (done) {
try {
thermal.unregisterThermalLevelCallback('')
} catch (error) {
console.info('UnRegister_Thermal_Level_Callback_JSTest0130 error:' + error);
// 401: Invalid input parameter
expect(error.code === 401).assertTrue();
}
done();
})
/* @tc.number SUB_PowerSystem_ThermalManager_JSTest_0140
* @tc.name UnRegister_Thermal_Level_Callback_JSTest0140
* @tc.desc Thermal acquisition kit
*/
it('UnRegister_Thermal_Level_Callback_JSTest0140', 0, async function (done) {
try {
thermal.unregisterThermalLevelCallback()
} catch (error) {
console.info('Thermal_020:' + error);
expect().assertFail();
}
try {
thermal.unregisterThermalLevelCallback(() => {
expect(ture).assertTrue();
})
} catch (error) {
console.info('Thermal_020:' + error);
expect().assertFail();
}
done();
})
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册